From aa8057fa429db6852a86ad217a641bb2bf12123c Mon Sep 17 00:00:00 2001 From: vempo Date: Sun, 5 Aug 2018 18:06:55 +0300 Subject: Resolved slf4j binding conflict in tests Removed an slf4j binding, moved dependencies up to the dependencyManagement of root POM, improved logging. Change-Id: I21eb5160adac7d520363a524e679962be4754d11 Issue-ID: SDC-1278 Signed-off-by: vempo --- onboarding/pom.xml | 10 ++++++++++ openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml | 2 +- .../vendor-software-products-rest/pom.xml | 2 +- .../vnf-repository-rest-services/pom.xml | 9 ++------- .../sdcrests/vsp/rest/services/VnfPackageRepositoryImpl.java | 10 ++++++++-- .../vsp/rest/services/VnfPackageRepositoryImplTest.java | 9 +++++---- .../src/test/resources/logback-test.xml | 7 +++++-- openecomp-be/api/pom.xml | 2 +- 8 files changed, 33 insertions(+), 18 deletions(-) diff --git a/onboarding/pom.xml b/onboarding/pom.xml index f310178a12..aa34550b3e 100644 --- a/onboarding/pom.xml +++ b/onboarding/pom.xml @@ -124,6 +124,11 @@ 1.16.20 provided + + org.springframework + spring-context + ${spring.framework.version} + org.springframework spring-webmvc @@ -271,6 +276,11 @@ commons-lang3 ${commons.lang3.version} + + io.swagger + swagger-annotations + ${swagger.version} + org.testng testng diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml index 550e019b18..d7b4807be7 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml @@ -10,7 +10,7 @@ org.openecomp.sdc openecomp-sdc-api 1.3.0-SNAPSHOT - ../ + ../pom.xml diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/pom.xml index d68184e4f7..c037d4cc65 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/pom.xml @@ -17,6 +17,6 @@ /vendor-software-products-rest-services /vendor-software-products-rest-types - /vnf-repository-rest-services + /vnf-repository-rest-services diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/pom.xml index d504f70f34..bc11770bb0 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/pom.xml @@ -32,18 +32,15 @@ javax.ws.rs javax.ws.rs-api - ${ws.rs.version} provided io.swagger swagger-annotations - ${swagger.version} org.springframework spring-context - ${spring.framework.version} org.openecomp.sdc.onboarding @@ -79,15 +76,13 @@ runtime - org.slf4j - slf4j-simple - ${slf4j.version} + ch.qos.logback + logback-classic test junit junit - ${junit.version} test diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VnfPackageRepositoryImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VnfPackageRepositoryImpl.java index be14c45dc4..6f76bf4527 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VnfPackageRepositoryImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VnfPackageRepositoryImpl.java @@ -197,9 +197,15 @@ public class VnfPackageRepositoryImpl implements VnfPackageRepository { } private static Response handleUnexpectedStatus(String action, String uri, Response response) { + ErrorCode error = new GeneralErrorBuilder().build(); - LOGGER.error("Unexpected response status while {}: URI={}, Response={}", action, uri, response, - new CoreException(error)); + + if (LOGGER.isErrorEnabled()) { + String body = response.hasEntity() ? response.readEntity(String.class) : ""; + LOGGER.error("Unexpected response status while {}: URI={}, status={}, body={}", action, uri, + response.getStatus(), body, new CoreException(error)); + } + return generateInternalServerError(error); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/services/VnfPackageRepositoryImplTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/services/VnfPackageRepositoryImplTest.java index b0f53bac34..0f790036da 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/services/VnfPackageRepositoryImplTest.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/services/VnfPackageRepositoryImplTest.java @@ -53,6 +53,7 @@ public class VnfPackageRepositoryImplTest { @ClassRule public static final WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); + private static final String VSP = "anyVsp"; private static final String VERSION = "anyVersion"; private static final String USER = "anyUser"; @@ -88,7 +89,7 @@ public class VnfPackageRepositoryImplTest { @Test public void listVnfsReturnsInternalServerErrorWhenRemoteClientError() { - stubFor(get(GET_PATH).willReturn(aResponse().withStatus(403))); + stubFor(get(GET_PATH).willReturn(aResponse().withStatus(403).withBody("Forbidden"))); VnfPackageRepositoryImpl repository = new VnfPackageRepositoryImpl(config); Response response = repository.getVnfPackages(VSP, VERSION, USER); assertEquals(500, response.getStatus()); @@ -97,7 +98,7 @@ public class VnfPackageRepositoryImplTest { @Test public void listVnfsReturnsInternalServerErrorWhenRemoteReturnsNotOk() { - stubFor(get(GET_PATH).willReturn(aResponse().withStatus(204))); + stubFor(get(GET_PATH).willReturn(aResponse().withStatus(201).withBody("Created"))); VnfPackageRepositoryImpl repository = new VnfPackageRepositoryImpl(config); Response response = repository.getVnfPackages(VSP, VERSION, USER); assertEquals(500, response.getStatus()); @@ -117,7 +118,7 @@ public class VnfPackageRepositoryImplTest { @Test public void downloadVnfsReturnsInternalServerErrorWhenRemoteClientError() { - stubFor(get(DOWNLOAD_PATH).willReturn(aResponse().withStatus(403))); + stubFor(get(DOWNLOAD_PATH).willReturn(aResponse().withStatus(403).withBody("{\"error\": \"Permissions\"}"))); VnfPackageRepositoryImpl repository = new VnfPackageRepositoryImpl(config); Response response = repository.downloadVnfPackage(VSP, VERSION, CSAR, USER); assertEquals(500, response.getStatus()); @@ -126,7 +127,7 @@ public class VnfPackageRepositoryImplTest { @Test public void downloadVnfsReturnsInternalServerErrorWhenRemoteReturnsNotOk() { - stubFor(get(DOWNLOAD_PATH).willReturn(aResponse().withStatus(204))); + stubFor(get(DOWNLOAD_PATH).willReturn(aResponse().withStatus(201).withBody(new byte[0]))); VnfPackageRepositoryImpl repository = new VnfPackageRepositoryImpl(config); Response response = repository.downloadVnfPackage(VSP, VERSION, CSAR, USER); assertEquals(500, response.getStatus()); diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/src/test/resources/logback-test.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/src/test/resources/logback-test.xml index 278f2ac6ec..a439105a14 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/src/test/resources/logback-test.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/src/test/resources/logback-test.xml @@ -1,13 +1,16 @@ - + + target/unit-tests.log + true + true %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - + \ No newline at end of file diff --git a/openecomp-be/api/pom.xml b/openecomp-be/api/pom.xml index b8209b64ee..30b382431d 100644 --- a/openecomp-be/api/pom.xml +++ b/openecomp-be/api/pom.xml @@ -12,7 +12,7 @@ org.openecomp.sdc openecomp-sdc 1.3.0-SNAPSHOT - .. + ../pom.xml -- cgit 1.2.3-korg