Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Java] Update version of maven-surefire-plugin #5509

Merged
merged 29 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bf9095f
use more recent version of maven-surefire-plugin
sebastien-rosset Mar 3, 2020
63635e1
use more recent version of maven-surefire-plugin
sebastien-rosset Mar 3, 2020
a012279
Merge remote-tracking branch 'origin' into maven-surefire
sebastien-rosset Mar 5, 2020
4cb5ccc
Merge remote-tracking branch 'origin' into maven-surefire
sebastien-rosset Mar 6, 2020
b4712b3
Merge branch 'master' of github.com:CiscoM31/openapi-generator into m…
sebastien-rosset Mar 9, 2020
7709fe9
higher debug level for troubleshooting ci issue
sebastien-rosset Mar 10, 2020
d45f61d
Merge branch 'master' of github.com:CiscoM31/openapi-generator into m…
sebastien-rosset Mar 12, 2020
239e7e7
temporarily increase debug log to help troubleshoot
sebastien-rosset Mar 12, 2020
ba073f6
Merge branch 'master' of github.com:CiscoM31/openapi-generator into m…
sebastien-rosset Mar 14, 2020
c52b666
Merge branch 'master' of github.com:CiscoM31/openapi-generator into m…
sebastien-rosset Mar 15, 2020
8370097
Use local instance of pet store service for unit test purpose
sebastien-rosset Mar 15, 2020
1627a3d
Add more logging to troubleshoot unit test failures
sebastien-rosset Mar 15, 2020
d1b1b30
Add more logging to troubleshoot unit test failures
sebastien-rosset Mar 16, 2020
ca64be5
Add more logging to troubleshoot unit test failures
sebastien-rosset Mar 16, 2020
5d79895
Add more logging to troubleshoot unit test failures
sebastien-rosset Mar 16, 2020
bc0e06c
Merge branch 'master' of github.com:CiscoM31/openapi-generator into m…
sebastien-rosset Mar 16, 2020
5402d23
Add more logging to troubleshoot unit test failures
sebastien-rosset Mar 16, 2020
6168bd4
use random ID for Java unit test instead of fixed id
sebastien-rosset Mar 16, 2020
0672611
add code comments and specify URL for java unit test
sebastien-rosset Mar 16, 2020
368e39b
Merge branch 'master' of github.com:CiscoM31/openapi-generator into m…
sebastien-rosset Mar 17, 2020
d64ef98
reenable quiet argument
sebastien-rosset Mar 17, 2020
371388d
Merge branch 'master' of github.com:CiscoM31/openapi-generator into m…
sebastien-rosset Mar 20, 2020
4bc91db
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset Mar 24, 2020
69f4cdf
Merge remote-tracking branch 'origin' into maven-surefire
sebastien-rosset Mar 24, 2020
665e883
fix java unit test issues
sebastien-rosset Mar 24, 2020
e850841
fix java unit test issues
sebastien-rosset Mar 24, 2020
5b3b93d
Revert "fix java unit test issues"
sebastien-rosset Mar 25, 2020
0c1c1e2
fix java unit test issues
sebastien-rosset Mar 25, 2020
7816c11
Merge remote-tracking branch 'origin' into maven-surefire
sebastien-rosset Mar 25, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CI/circle_parallel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ NODE_INDEX=${CIRCLE_NODE_INDEX:-0}

set -e

function cleanup {
# Show logs of 'petstore.swagger' container to troubleshoot Unit Test failures, if any.
docker logs petstore.swagger # container name specified in circle.yml
}

trap cleanup EXIT

if [ "$NODE_INDEX" = "1" ]; then
echo "Running node $NODE_INDEX to test 'samples.circleci' defined in pom.xml ..."
java -version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.junit.*;

Expand All @@ -42,20 +45,24 @@
public class PetApiTest {

private PetApi api = new PetApi();
private static final Logger LOG = LoggerFactory.getLogger(PetApiTest.class);
// In the circle.yml file, /etc/host is configured with an entry to resolve petstore.swagger.io to 127.0.0.1
private static String basePath = "http://petstore.swagger.io:80/v2";

@Before
public void setup() {
// setup authentication
ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
apiKeyAuth.setApiKey("special-key");
api.getApiClient().setBasePath(basePath);
}

@Test
public void testApiClient() {
// the default api client is used
assertEquals(Configuration.getDefaultApiClient(), api.getApiClient());
assertNotNull(api.getApiClient());
assertEquals("http://petstore.swagger.io:80/v2", api.getApiClient().getBasePath());
assertEquals(basePath, api.getApiClient().getBasePath());
assertFalse(api.getApiClient().isDebugging());

ApiClient oldClient = api.getApiClient();
Expand All @@ -74,7 +81,7 @@ public void testApiClient() {
// set api client via setter method
api.setApiClient(oldClient);
assertNotNull(api.getApiClient());
assertEquals("http://petstore.swagger.io:80/v2", api.getApiClient().getBasePath());
assertEquals(basePath, api.getApiClient().getBasePath());
assertFalse(api.getApiClient().isDebugging());
}

Expand All @@ -85,6 +92,7 @@ public void testCreateAndGetPet() throws Exception {

Pet fetched = api.getPetById(pet.getId());
assertPetMatches(pet, fetched);
api.deletePet(pet.getId(), null);
}

@Test
Expand All @@ -98,6 +106,7 @@ public void testCreateAndGetPetWithHttpInfo() throws Exception {
Pet fetched = resp.getData();

assertPetMatches(pet, fetched);
api.deletePet(pet.getId(), null);
}

@Test
Expand Down Expand Up @@ -144,6 +153,7 @@ public void onDownloadProgress(long bytesRead, long contentLength, boolean done)
}
} while (result.isEmpty());
assertPetMatches(pet, fetched);
api.deletePet(pet.getId(), null);
}

@Test
Expand Down Expand Up @@ -197,6 +207,7 @@ public void onDownloadProgress(long bytesRead, long contentLength, boolean done)
assertEquals(404, exception.getCode());
assertEquals("Not Found", exception.getMessage());
assertEquals("application/json", exception.getResponseHeaders().get("Content-Type").get(0));
api.deletePet(pet.getId(), null);
}

@Test
Expand Down Expand Up @@ -255,26 +266,31 @@ public void testCreateAndGetMultiplePetsAsync() throws Exception {
final ApiException exception = getCallback3.getException();
assertNotNull(exception);
assertEquals(404, exception.getCode());
api.deletePet(pet1.getId(), null);
api.deletePet(pet2.getId(), null);
}


@Test
public void testUpdatePet() throws Exception {
Pet pet = createPet();
api.addPet(pet);
pet.setName("programmer");

api.updatePet(pet);

Pet fetched = api.getPetById(pet.getId());
assertPetMatches(pet, fetched);
api.deletePet(pet.getId(), null);
}

@Test
public void testFindPetsByStatus() throws Exception {
assertEquals(basePath, api.getApiClient().getBasePath());
Pet pet = createPet();
api.addPet(pet);
pet.setName("programmer");
pet.setStatus(Pet.StatusEnum.PENDING);

api.updatePet(pet);

List<Pet> pets = api.findPetsByStatus(Arrays.asList("pending"));
Expand Down Expand Up @@ -335,6 +351,7 @@ public void testUpdatePetWithForm() throws Exception {
Pet updated = api.getPetById(fetched.getId());

assertEquals(updated.getName(), "furt");
api.deletePet(pet.getId(), null);
}

@Test
Expand All @@ -343,12 +360,13 @@ public void testDeletePet() throws Exception {
api.addPet(pet);

Pet fetched = api.getPetById(pet.getId());
api.deletePet(fetched.getId(), null);
api.deletePet(pet.getId(), null);

try {
fetched = api.getPetById(fetched.getId());
fail("expected an error");
} catch (ApiException e) {
LOG.info("Code: {}. Message: {}", e.getCode(), e.getMessage());
assertEquals(404, e.getCode());
}
}
Expand All @@ -364,6 +382,7 @@ public void testUploadFile() throws Exception {
writer.close();

api.uploadFile(pet.getId(), "a test file", new File(file.getAbsolutePath()));
api.deletePet(pet.getId(), null);
}

@Test
Expand Down Expand Up @@ -396,7 +415,7 @@ public void testEqualsAndHashCode() {

private Pet createPet() {
Pet pet = new Pet();
pet.setId(1234567L);
pet.setId(ThreadLocalRandom.current().nextLong(Long.MAX_VALUE));
pet.setName("gorilla");

Category category = new Category();
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
# - run: docker pull openapitools/openapi-petstore
# - run: docker run -d -e OPENAPI_BASE_PATH=/v3 -e DISABLE_API_KEY=1 -e DISABLE_OAUTH=1 -p 80:8080 openapitools/openapi-petstore
- run: docker pull swaggerapi/petstore
- run: docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
- run: docker run --name petstore.swagger -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
- run: docker ps -a
- run: sleep 30
- run: cat /etc/hosts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<version>3.0.0-M4</version>
<configuration>
<systemProperties>
<property>
Expand All @@ -73,7 +73,7 @@
</systemProperties>
<argLine>-Xms512m -Xmx1500m</argLine>
<parallel>methods</parallel>
<forkMode>pertest</forkMode>
<threadCount>10</threadCount>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<version>3.0.0-M4</version>
<configuration>
<systemProperties>
<property>
Expand All @@ -66,7 +66,7 @@
</systemProperties>
<argLine>-Xms512m -Xmx1500m</argLine>
<parallel>methods</parallel>
<forkMode>pertest</forkMode>
<threadCount>10</threadCount>
</configuration>
</plugin>
<plugin>
Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/java/okhttp-gson/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<version>3.0.0-M4</version>
<configuration>
<systemProperties>
<property>
Expand All @@ -66,7 +66,7 @@
</systemProperties>
<argLine>-Xms512m -Xmx1500m</argLine>
<parallel>methods</parallel>
<forkMode>pertest</forkMode>
<threadCount>10</threadCount>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.junit.*;

Expand All @@ -42,20 +45,24 @@
public class PetApiTest {

private PetApi api = new PetApi();
private static final Logger LOG = LoggerFactory.getLogger(PetApiTest.class);
// In the circle.yml file, /etc/host is configured with an entry to resolve petstore.swagger.io to 127.0.0.1
private static String basePath = "http://petstore.swagger.io:80/v2";

@Before
public void setup() {
// setup authentication
ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
apiKeyAuth.setApiKey("special-key");
api.getApiClient().setBasePath(basePath);
}

@Test
public void testApiClient() {
// the default api client is used
assertEquals(Configuration.getDefaultApiClient(), api.getApiClient());
assertNotNull(api.getApiClient());
assertEquals("http://petstore.swagger.io:80/v2", api.getApiClient().getBasePath());
assertEquals(basePath, api.getApiClient().getBasePath());
assertFalse(api.getApiClient().isDebugging());

ApiClient oldClient = api.getApiClient();
Expand All @@ -74,7 +81,7 @@ public void testApiClient() {
// set api client via setter method
api.setApiClient(oldClient);
assertNotNull(api.getApiClient());
assertEquals("http://petstore.swagger.io:80/v2", api.getApiClient().getBasePath());
assertEquals(basePath, api.getApiClient().getBasePath());
assertFalse(api.getApiClient().isDebugging());
}

Expand All @@ -85,6 +92,7 @@ public void testCreateAndGetPet() throws Exception {

Pet fetched = api.getPetById(pet.getId());
assertPetMatches(pet, fetched);
api.deletePet(pet.getId(), null);
}

@Test
Expand All @@ -98,6 +106,7 @@ public void testCreateAndGetPetWithHttpInfo() throws Exception {
Pet fetched = resp.getData();

assertPetMatches(pet, fetched);
api.deletePet(pet.getId(), null);
}

@Test
Expand Down Expand Up @@ -144,6 +153,7 @@ public void onDownloadProgress(long bytesRead, long contentLength, boolean done)
}
} while (result.isEmpty());
assertPetMatches(pet, fetched);
api.deletePet(pet.getId(), null);
}

@Test
Expand Down Expand Up @@ -197,6 +207,7 @@ public void onDownloadProgress(long bytesRead, long contentLength, boolean done)
assertEquals(404, exception.getCode());
assertEquals("Not Found", exception.getMessage());
assertEquals("application/json", exception.getResponseHeaders().get("Content-Type").get(0));
api.deletePet(pet.getId(), null);
}

@Test
Expand Down Expand Up @@ -255,26 +266,31 @@ public void testCreateAndGetMultiplePetsAsync() throws Exception {
final ApiException exception = getCallback3.getException();
assertNotNull(exception);
assertEquals(404, exception.getCode());
api.deletePet(pet1.getId(), null);
api.deletePet(pet2.getId(), null);
}


@Test
public void testUpdatePet() throws Exception {
Pet pet = createPet();
api.addPet(pet);
pet.setName("programmer");

api.updatePet(pet);

Pet fetched = api.getPetById(pet.getId());
assertPetMatches(pet, fetched);
api.deletePet(pet.getId(), null);
}

@Test
public void testFindPetsByStatus() throws Exception {
assertEquals(basePath, api.getApiClient().getBasePath());
Pet pet = createPet();
api.addPet(pet);
pet.setName("programmer");
pet.setStatus(Pet.StatusEnum.PENDING);

api.updatePet(pet);

List<Pet> pets = api.findPetsByStatus(Arrays.asList("pending"));
Expand Down Expand Up @@ -335,6 +351,7 @@ public void testUpdatePetWithForm() throws Exception {
Pet updated = api.getPetById(fetched.getId());

assertEquals(updated.getName(), "furt");
api.deletePet(pet.getId(), null);
}

@Test
Expand All @@ -343,12 +360,13 @@ public void testDeletePet() throws Exception {
api.addPet(pet);

Pet fetched = api.getPetById(pet.getId());
api.deletePet(fetched.getId(), null);
api.deletePet(pet.getId(), null);

try {
fetched = api.getPetById(fetched.getId());
fail("expected an error");
} catch (ApiException e) {
LOG.info("Code: {}. Message: {}", e.getCode(), e.getMessage());
assertEquals(404, e.getCode());
}
}
Expand All @@ -364,6 +382,7 @@ public void testUploadFile() throws Exception {
writer.close();

api.uploadFile(pet.getId(), "a test file", new File(file.getAbsolutePath()));
api.deletePet(pet.getId(), null);
}

@Test
Expand Down Expand Up @@ -396,7 +415,7 @@ public void testEqualsAndHashCode() {

private Pet createPet() {
Pet pet = new Pet();
pet.setId(1234567L);
pet.setId(ThreadLocalRandom.current().nextLong(Long.MAX_VALUE));
pet.setName("gorilla");

Category category = new Category();
Expand Down