Add new DashboardTestServer class to support development.
Demote mockito dependencies to test scope.
Change-Id: I9dab0f9af61cad901892620d769e275091f953b8
Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
RIC Dashboard Release Notes
===========================
-Version 1.2.0, 12 July 2019
+Version 1.2.0, 17 July 2019
---------------------------
* Split URL properties into prefix/suffix parts
* Add jacoco plugin to back-end for code coverage
* Clean code of issues reported by Sonar
* Drop mock RAN names feature that supported R1 testing
* Extend mock endpoints to simulate delay seen in tests
+* Move mock configuration classes into test area
Version 1.0.5, 5 July 2019
--------------------------
# RIC Dashboard Web Application Backend
+## Launch server
+
+Run `mvn -Dspring.config.name=application-abc spring-boot:run` to run a server configured
+by the file 'application-abc.properties' in the local directory.
+
## Development server
-Run `mvn -Dspring.profiles.active=mock spring-boot:run` for a dev server. Navigate to `http://localhost:8080/swagger-ui.html`.
+Set an environment variable via JVM argument "-Dorg.oransc.ric.portal.dashboard=mock"
+and run the JUnit test case DashboardServerTest for a development server to run standalone
+with mock configuration and data that simulates the behavior of remote endpoints.
-## Alternate configuration
+## Swagger API documentation
-Run `mvn -Dspring.config.name=application-abc spring-boot:run` to read configuration from the file 'application-abc.properties' in the local directory.
+View the server's API documentation at URL `http://localhost:8080/swagger-ui.html`.
## License
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox.version}</version>
</dependency>
+ <!-- Test dependencies -->
<!-- Mockito supports development, not just testing -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
+ <scope>test</scope>
</dependency>
- <!-- Test dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
-// Using this package limits the annotation scan to the dashboard classes.
-// Do not want Spring to find the autowired annotations in the generated
-// classes.
+// Limit scan to dashboard classes; exclude generated API classes
@ComponentScan("org.oransc.ric.portal.dashboard")
public class DashboardApplication {
* container.
*/
@Configuration
-@Profile("!mock")
+@Profile("!test")
public class A1MediatorConfiguration {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
* Creates instances of the ANR xApp client APIs.
*/
@Configuration
-@Profile("!mock")
+@Profile("!test")
public class AnrXappConfiguration {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
* container.
*/
@Configuration
-@Profile("!mock")
+@Profile("!test")
public class AppManagerConfiguration {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
* Creates an E2 manager client as a bean to be managed by the Spring container.
*/
@Configuration
-@Profile("!mock")
+@Profile("!test")
public class E2ManagerConfiguration {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
--- /dev/null
+/*-
+ * ========================LICENSE_START=================================
+ * O-RAN-SC
+ * %%
+ * Copyright (C) 2019 AT&T Intellectual Property and Nokia
+ * %%
+ * 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.oransc.ric.portal.dashboard;
+
+import java.lang.invoke.MethodHandles;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+/**
+ * This class supports front-end web development. Placing this class in the test
+ * area allows excluding the mock configuration classes and the Mockito
+ * dependencies from the packaged version of the app.
+ *
+ * To launch a development server set the environment variable as listed below.
+ * This runs a Spring-Boot server with mock back-end beans, and keeps the server
+ * alive for manual testing. Supply this JVM argument:
+ *
+ * <pre>
+ * -Dorg.oransc.ric.portal.dashboard=mock
+ * </pre>
+ */
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
+@ActiveProfiles("test")
+public class DashboardTestServer {
+
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ /*
+ * Keeps the test server alive forever. Use a guard so this test is never run by
+ * Jenkins.
+ */
+ @EnabledIfSystemProperty(named = "org.oransc.ric.portal.dashboard", matches = "mock")
+ @Test
+ public void keepServerAlive() {
+ logger.warn("Keeping server alive!");
+ try {
+ synchronized (this) {
+ this.wait();
+ }
+ } catch (Exception ex) {
+ logger.warn(ex.toString());
+ }
+ }
+}
* limitations under the License.
* ========================LICENSE_END===================================
*/
-package org.oransc.ric.portal.dashboard.config;
+package org.oransc.ric.portal.dashboard.test.config;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
/**
* Creates a mock implementation of the A1 mediator client API.
*/
-@Profile("mock")
+@Profile("test")
@Configuration
public class A1MediatorMockConfiguration {
* limitations under the License.
* ========================LICENSE_END===================================
*/
-package org.oransc.ric.portal.dashboard.config;
+package org.oransc.ric.portal.dashboard.test.config;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
/**
* Creates a mock implementation of the ANR xApp client APIs.
*/
-@Profile("mock")
+@Profile("test")
@Configuration
public class AnrXappMockConfiguration {
* limitations under the License.
* ========================LICENSE_END===================================
*/
-package org.oransc.ric.portal.dashboard.config;
+package org.oransc.ric.portal.dashboard.test.config;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
* Creates an implementation of the xApp manager client that answers requests
* with mock data.
*/
-@Profile("mock")
+@Profile("test")
@Configuration
public class AppManagerMockConfiguration {
* limitations under the License.
* ========================LICENSE_END===================================
*/
-package org.oransc.ric.portal.dashboard.config;
+package org.oransc.ric.portal.dashboard.test.config;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
/**
* Creates a mock implementation of the E2 Manager client API.
*/
-@Profile("mock")
+@Profile("test")
@Configuration
public class E2ManagerMockConfiguration {
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
// Need the fake answers from the backend
-@ActiveProfiles("mock")
+@ActiveProfiles("test")
public class AbstractControllerTest {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());