Skip to content
This repository has been archived by the owner on Oct 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #53 from robert2411/feature/junit5
Browse files Browse the repository at this point in the history
Update the tests to junit 5
  • Loading branch information
robert2411 authored Oct 12, 2024
2 parents ec4dcc8 + 6c1f7ef commit eab69af
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 31 deletions.
11 changes: 0 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<distributionManagement>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package com.github.robert2411.boot.starter.springfox;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.client.RestTemplate;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class SpringFoxPropertiesTest {

Expand All @@ -22,7 +19,7 @@ public class SpringFoxPropertiesTest {
@LocalServerPort
int localServerPort;

@Before
@BeforeEach
public void setup() {
restTemplate = new RestTemplateBuilder()
.rootUri("http://localhost:" + localServerPort)
Expand All @@ -31,68 +28,68 @@ public void setup() {

@Test
public void getInfoTitle() {
Assert.assertEquals("title", springFoxProperties.getInfo().getTitle());
Assertions.assertEquals("title", springFoxProperties.getInfo().getTitle());
}

@Test
public void getInfoDescription() {
Assert.assertEquals("description", springFoxProperties.getInfo().getDescription());
Assertions.assertEquals("description", springFoxProperties.getInfo().getDescription());
}

@Test
public void getInfoVersion() {
Assert.assertEquals("version", springFoxProperties.getInfo().getVersion());
Assertions.assertEquals("version", springFoxProperties.getInfo().getVersion());
}

@Test
public void getInfoTermsOfServiceUrl() {
Assert.assertEquals("termsOfServiceUrl", springFoxProperties.getInfo().getTermsOfServiceUrl());
Assertions.assertEquals("termsOfServiceUrl", springFoxProperties.getInfo().getTermsOfServiceUrl());
}

@Test
public void getInfoContactName() {
Assert.assertEquals("name", springFoxProperties.getInfo().getContact().getName());
Assertions.assertEquals("name", springFoxProperties.getInfo().getContact().getName());
}

@Test
public void getInfoContactEmail() {
Assert.assertEquals("email", springFoxProperties.getInfo().getContact().getEmail());
Assertions.assertEquals("email", springFoxProperties.getInfo().getContact().getEmail());
}

@Test
public void getInfoContactUrl() {
Assert.assertEquals("url", springFoxProperties.getInfo().getContact().getUrl());
Assertions.assertEquals("url", springFoxProperties.getInfo().getContact().getUrl());
}

@Test
public void getInfoLicenseName() {
Assert.assertEquals("name", springFoxProperties.getInfo().getLicense().getName());
Assertions.assertEquals("name", springFoxProperties.getInfo().getLicense().getName());
}

@Test
public void getInfoLicenseUrl() {
Assert.assertEquals("url", springFoxProperties.getInfo().getLicense().getUrl());
Assertions.assertEquals("url", springFoxProperties.getInfo().getLicense().getUrl());
}

@Test
public void getConfigPaths() {
Assert.assertEquals("/api/.*", springFoxProperties.getConfig().getPaths());
Assertions.assertEquals("/api/.*", springFoxProperties.getConfig().getPaths());
}

@Test
public void getConfigDocumentationType() {
Assert.assertEquals("swagger", springFoxProperties.getConfig().getDocumentationType());
Assertions.assertEquals("swagger", springFoxProperties.getConfig().getDocumentationType());
}

@Test
public void checkIfJsonPathExist() {
ResponseEntity<String> response = restTemplate.getForEntity("/v2/api-docs", String.class);
Assert.assertTrue(response.getStatusCode().is2xxSuccessful());
Assertions.assertTrue(response.getStatusCode().is2xxSuccessful());
}

@Test
public void checkIfUiPathExist() {
ResponseEntity<String> response = restTemplate.getForEntity("/swagger-ui/", String.class);
Assert.assertTrue(response.getStatusCode().is2xxSuccessful());
Assertions.assertTrue(response.getStatusCode().is2xxSuccessful());
}
}

0 comments on commit eab69af

Please sign in to comment.