Resolved slf4j binding conflict in tests 15/59115/2
authorvempo <vitaliy.emporopulo@amdocs.com>
Sun, 5 Aug 2018 15:06:55 +0000 (18:06 +0300)
committerAvi Gaffa <avi.gaffa@amdocs.com>
Mon, 6 Aug 2018 10:26:55 +0000 (10:26 +0000)
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 <vitaliy.emporopulo@amdocs.com>
onboarding/pom.xml
openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml
openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/pom.xml
openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/pom.xml
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
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
openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/src/test/resources/logback-test.xml
openecomp-be/api/pom.xml

index f310178..aa34550 100644 (file)
                 <version>1.16.20</version>
                 <scope>provided</scope>
             </dependency>
+            <dependency>
+                <groupId>org.springframework</groupId>
+                <artifactId>spring-context</artifactId>
+                <version>${spring.framework.version}</version>
+            </dependency>
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-webmvc</artifactId>
                 <artifactId>commons-lang3</artifactId>
                 <version>${commons.lang3.version}</version>
             </dependency>
+            <dependency>
+                <groupId>io.swagger</groupId>
+                <artifactId>swagger-annotations</artifactId>
+                <version>${swagger.version}</version>
+            </dependency>
             <dependency>
                 <groupId>org.testng</groupId>
                 <artifactId>testng</artifactId>
index 550e019..d7b4807 100644 (file)
@@ -10,7 +10,7 @@
                <groupId>org.openecomp.sdc</groupId>
                <artifactId>openecomp-sdc-api</artifactId>
                <version>1.3.0-SNAPSHOT</version>
-               <relativePath>../</relativePath>
+               <relativePath>../pom.xml</relativePath>
        </parent>
 
        <modules>
index d68184e..c037d4c 100644 (file)
@@ -17,6 +17,6 @@
     <modules>
         <module>/vendor-software-products-rest-services</module>
         <module>/vendor-software-products-rest-types</module>
-       <module>/vnf-repository-rest-services</module>
+        <module>/vnf-repository-rest-services</module>
     </modules>
 </project>
index d504f70..bc11770 100644 (file)
         <dependency>
             <groupId>javax.ws.rs</groupId>
             <artifactId>javax.ws.rs-api</artifactId>
-            <version>${ws.rs.version}</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>io.swagger</groupId>
             <artifactId>swagger-annotations</artifactId>
-            <version>${swagger.version}</version>
         </dependency>
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-context</artifactId>
-            <version>${spring.framework.version}</version>
         </dependency>
         <dependency>
             <groupId>org.openecomp.sdc.onboarding</groupId>
             <scope>runtime</scope>
         </dependency>
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-simple</artifactId>
-            <version>${slf4j.version}</version>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
-            <version>${junit.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
index be14c45..6f76bf4 100644 (file)
@@ -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);
     }
 
index b0f53ba..0f79003 100644 (file)
@@ -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());
index 278f2ac..a439105 100644 (file)
@@ -1,13 +1,16 @@
 <configuration>
 
-    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+        <file>target/unit-tests.log</file>
+        <append>true</append>
+        <immediateFlush>true</immediateFlush>
         <encoder>
             <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
         </encoder>
     </appender>
 
     <root level="warn">
-        <appender-ref ref="STDOUT" />
+        <appender-ref ref="FILE" />
     </root>
 
 </configuration>
\ No newline at end of file
index b8209b6..30b3824 100644 (file)
@@ -12,7 +12,7 @@
                <groupId>org.openecomp.sdc</groupId>
                <artifactId>openecomp-sdc</artifactId>
                <version>1.3.0-SNAPSHOT</version>
-               <relativePath>..</relativePath>
+               <relativePath>../pom.xml</relativePath>
        </parent>
 
        <modules>