Add so-simulator integration test 94/141494/2
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Tue, 8 Jul 2025 13:30:12 +0000 (15:30 +0200)
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Tue, 8 Jul 2025 14:10:34 +0000 (16:10 +0200)
- define integration test to assert that the so-simulator
  has a working application context
- change spring.boot.version to springboot.version in so-simulator module to override the
  global property of the same name. This ensures that all spring boot deps of this module
  are in version 2.0.9 (before, some were in 2.4.12 which lead to incompatibilities)
- add dependency management for spring cloud in so-simulator module to make sure that it
  is in a spring boot 2.0.9-compatible version
- override javassist version (3.22.0-GA -> 3.25.0-GA) to have a java 11 compatible version
- downgrade h2 dependency (2.1.214 -> 1.4.200) to be compatible with the citrus-simulator
  dependencies
- update logback (1.2.7 -> 1.2.11)

Issue-ID: SO-4200
Change-Id: I2e58cc0c59193a0a1268958a398699e577f25b1d
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
pom.xml
so-simulator/pom.xml
so-simulator/src/test/java/org/onap/so/simulator/SimulatorIntegrationTest.java [new file with mode: 0644]
so-simulator/src/test/resources/citrus-context.xml
so-simulator/src/test/resources/logback-spring.xml [new file with mode: 0644]

diff --git a/pom.xml b/pom.xml
index 8579dfc..f51fd3a 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -78,7 +78,7 @@
     <onap-logging-version>1.6.9</onap-logging-version>
     <jackson.version>2.14.3</jackson.version>
     <grpc.version>1.25.0</grpc.version>
-    <logback.version>1.2.7</logback.version>
+    <logback.version>1.2.11</logback.version>
   </properties>
   <distributionManagement>
     <repository>
index 323cf7d..eddb8fe 100644 (file)
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
     <citrus.simulator.version>1.1.0</citrus.simulator.version>
-    <spring.boot.version>2.0.9.RELEASE</spring.boot.version>
+    <springboot.version>2.0.9.RELEASE</springboot.version>
+    <spring-cloud.version>Finchley.RC2</spring-cloud.version>
+    <junit-jupiter.version>5.6.0</junit-jupiter.version>
   </properties>
   <dependencyManagement>
     <dependencies>
       <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-dependencies</artifactId>
-        <version>${spring.boot.version}</version>
+        <version>${springboot.version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework.cloud</groupId>
+        <artifactId>spring-cloud-dependencies</artifactId>
+        <version>${spring-cloud.version}</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
+      <!-- TODO: Update spring-boot > 2.0.9, then remove this
+           This is a transitive dependency of hibernate that
+           in it's original version is not compatibel with Java 11 -->
+      <dependency>
+        <groupId>org.javassist</groupId>
+        <artifactId>javassist</artifactId>
+        <version>3.25.0-GA</version>
+      </dependency>
+      <dependency>
+        <groupId>com.h2database</groupId>
+        <artifactId>h2</artifactId>
+        <version>1.4.200</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
   <dependencies>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter</artifactId>
+      <version>${junit-jupiter.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.platform</groupId>
+      <artifactId>junit-platform-commons</artifactId>
+      <version>1.6.0</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.testng</groupId>
+      <artifactId>testng</artifactId>
+      <scope>test</scope>
+      <version>6.14.3</version>
+    </dependency>
     <!-- Citrus Simulator -->
     <dependency>
       <groupId>com.consol.citrus</groupId>
@@ -55,6 +99,7 @@
       <artifactId>aai-client</artifactId>
       <version>${project.version}</version>
     </dependency>
+
     <dependency>
       <groupId>org.glassfish.jersey.core</groupId>
       <artifactId>jersey-client</artifactId>
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>3.1.2</version>
+        <dependencies>
+          <dependency>
+            <groupId>org.apache.maven.surefire</groupId>
+            <artifactId>surefire-testng</artifactId>
+            <version>3.1.2</version>
+          </dependency>
+        </dependencies>
+      </plugin>
     </plugins>
   </build>
 
diff --git a/so-simulator/src/test/java/org/onap/so/simulator/SimulatorIntegrationTest.java b/so-simulator/src/test/java/org/onap/so/simulator/SimulatorIntegrationTest.java
new file mode 100644 (file)
index 0000000..18a36f4
--- /dev/null
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2025 Deutsche Telekom.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.simulator;
+
+import static org.junit.Assert.assertTrue;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.SpringApplication;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpStatus;
+import org.springframework.test.context.ContextConfiguration;
+import org.testng.annotations.Test;
+import com.consol.citrus.annotations.CitrusTest;
+import com.consol.citrus.dsl.runner.TestRunner;
+import com.consol.citrus.dsl.runner.TestRunnerBeforeSuiteSupport;
+import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;
+import com.consol.citrus.http.client.HttpClient;
+
+@Test
+@ContextConfiguration(classes = org.onap.so.simulator.SimulatorIntegrationTest.EndpointConfig.class)
+public class SimulatorIntegrationTest extends TestNGCitrusTestDesigner {
+
+    @Autowired
+    @Qualifier("simulatorClient")
+    private HttpClient apiClient;
+
+    @CitrusTest
+    public void thatRequestCanBeMade() {
+        http().client(apiClient).send().get("/sim/v1/tenantOne/stacks/network_dummy_id/stackId");
+        http().client(apiClient).receive().response(HttpStatus.OK);
+        assertTrue(true);
+    }
+
+    @Configuration
+    public static class EndpointConfig {
+        @Bean
+        public TestRunnerBeforeSuiteSupport startEmbeddedSimulator() {
+            return new TestRunnerBeforeSuiteSupport() {
+                @Override
+                public void beforeSuite(TestRunner runner) {
+                    SpringApplication.run(Simulator.class);
+                }
+            };
+        }
+    }
+}
index f491dbc..dd1b8ea 100644 (file)
@@ -8,16 +8,10 @@
        http://www.citrusframework.org/schema/http/config http://www.citrusframework.org/schema/http/config/citrus-http-config.xsd
        http://www.citrusframework.org/schema/config http://www.citrusframework.org/schema/config/citrus-config.xsd">
 
-  <citrus:schema-repository id="schemaRepository">
-    <citrus:locations>
-      <citrus:location path="classpath:xsd/HelloService.xsd"/>
-    </citrus:locations>
-  </citrus:schema-repository>
-
   <!-- Test Http REST client -->
   <citrus-http:client
       id="simulatorClient"
-      request-url="http://localhost:8080/services/rest/simulator"
+      request-url="http://localhost:10000"
       timeout="5000"/>
 
-</beans>
\ No newline at end of file
+</beans>
diff --git a/so-simulator/src/test/resources/logback-spring.xml b/so-simulator/src/test/resources/logback-spring.xml
new file mode 100644 (file)
index 0000000..02d6a80
--- /dev/null
@@ -0,0 +1,49 @@
+<configuration scan="true" debug="false">
+       <include resource="org/springframework/boot/logging/logback/base.xml" />
+
+       <property name="queueSize" value="256" />
+       <property name="maxFileSize" value="20MB" />
+       <property name="maxHistory" value="30" />
+       <property name="totalSizeCap" value="20MB" />
+
+       <!-- log file names -->
+       <property name="debugLogName" value="debug" />
+
+       <property name="currentTimeStamp" value="%d{&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&quot;,UTC}"/>
+
+       <property name="debugPattern"
+               value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%thread|%X{RequestID}| %logger{50} - %msg%n" />
+
+       <appender name="Debug"
+               class="ch.qos.logback.core.ConsoleAppender">
+               <encoder>
+                       <pattern>${debugPattern}</pattern>
+               </encoder>
+       </appender>
+
+       <appender name="asyncDebug" class="ch.qos.logback.classic.AsyncAppender">
+               <queueSize>256</queueSize>
+               <appender-ref ref="Debug" />
+               <includeCallerData>true</includeCallerData>
+       </appender>
+
+       <!-- Sim Logs go here-->
+       <logger name="com.consol.citrus" level="DEBUG" additivity="false">
+               <appender-ref ref="asyncDebug" />
+       </logger>
+
+
+       <logger name="com.consol.citrus.simulator.http.HttpRequestAnnotationMatcher" level="WARN" additivity="false">
+               <appender-ref ref="asyncDebug" />
+       </logger>
+
+       <logger name="org.onap.so" level="DEBUG" additivity="false">
+               <appender-ref ref="asyncDebug" />
+       </logger>
+
+
+       <root level="INFO">
+               <appender-ref ref="asyncDebug" />
+       </root>
+
+</configuration>