summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml23
-rw-r--r--src/test/java/org/onap/aai/validation/TestApplication.java23
-rw-r--r--src/test/java/org/onap/aai/validation/config/TestTopicConfig.java42
-rw-r--r--src/test/java/org/onap/aai/validation/modeldriven/validator/TestModelDrivenValidator.java19
-rw-r--r--src/test/java/org/onap/aai/validation/services/TestInfoService.java23
-rw-r--r--src/test/resources/test-application.properties6
6 files changed, 84 insertions, 52 deletions
diff --git a/pom.xml b/pom.xml
index 18f0139..dbffda5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -213,19 +213,18 @@ limitations under the License.
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-library</artifactId>
+ <scope>test</scope>
+ </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.10.19</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-library</artifactId>
- <scope>test</scope>
- </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
diff --git a/src/test/java/org/onap/aai/validation/TestApplication.java b/src/test/java/org/onap/aai/validation/TestApplication.java
index 26d480a..3dfa177 100644
--- a/src/test/java/org/onap/aai/validation/TestApplication.java
+++ b/src/test/java/org/onap/aai/validation/TestApplication.java
@@ -1,7 +1,10 @@
/**
- * ============LICENSE_START===================================================
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved.
* Copyright (c) 2018-2019 European Software Marketing Ltd.
- * ============================================================================
+ * ================================================================================
* 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
@@ -13,7 +16,7 @@
* 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=====================================================
+ * ============LICENSE_END=========================================================
*/
package org.onap.aai.validation;
@@ -21,11 +24,17 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestPropertySource;
/**
* Invoke the Spring Boot Application (primarily for code coverage).
*
*/
+@SpringBootTest(classes = ValidationServiceApplication.class)
+@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties", "classpath:application.properties"})
+@ContextConfiguration(locations = {"classpath:validation-service-beans.xml"})
public class TestApplication {
@Rule
@@ -35,6 +44,7 @@ public class TestApplication {
public void init() {
System.setProperty("CONFIG_HOME", "src/test/resources/model-validation/instance-validator");
System.setProperty("APP_HOME", ".");
+ System.setProperty("schema.translator.list", "config");
System.clearProperty("KEY_STORE_PASSWORD");
}
@@ -46,4 +56,11 @@ public class TestApplication {
ValidationServiceApplication.main(null);
}
+ @Test
+ public void testApplicationWithNullKeyStorePassword() {
+ expectedEx.expect(IllegalArgumentException.class);
+ expectedEx.expectMessage("roperty KEY_STORE_PASSWORD not set");
+ ValidationServiceApplication.main(new String[] {});
+ }
+
}
diff --git a/src/test/java/org/onap/aai/validation/config/TestTopicConfig.java b/src/test/java/org/onap/aai/validation/config/TestTopicConfig.java
index 30e28d8..f323331 100644
--- a/src/test/java/org/onap/aai/validation/config/TestTopicConfig.java
+++ b/src/test/java/org/onap/aai/validation/config/TestTopicConfig.java
@@ -1,20 +1,24 @@
-/*
- * ============LICENSE_START===================================================
- * Copyright (c) 2018 Amdocs
- * ============================================================================
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2018-2019 European Software Marketing Ltd.
+ * ================================================================================
* 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
+ * 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=====================================================
+ * ============LICENSE_END=========================================================
*/
+
package org.onap.aai.validation.config;
import static org.hamcrest.Matchers.containsInAnyOrder;
@@ -23,17 +27,21 @@ import static org.junit.Assert.assertThat;
import java.util.List;
import java.util.Properties;
-import javax.annotation.Resource;
import javax.inject.Inject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.validation.config.TopicConfig.Topic;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Import;
import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
+@SpringBootTest
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"classpath:/topic-config/test-validation-service-beans.xml"})
+@Import(TopicPropertiesConfig.class)
+@TestPropertySource(locations = { "classpath:test-application.properties" })
+@ContextConfiguration(locations = { "classpath:topic-config/test-validation-service-beans.xml" })
public class TestTopicConfig {
static {
@@ -41,26 +49,22 @@ public class TestTopicConfig {
}
@Inject
- private TopicConfig topicConfigurations;
+ private TopicConfig topicConfig;
- @Resource(name = "topicProperties")
+ @Inject
private Properties topicProperties;
-
@Test
public void testGetTopicProperties() throws Exception {
assertThat(topicProperties.getProperty("aai-event.name"), is("aai-event"));
assertThat(topicProperties.getProperty("aai-data-export.name"), is("aai-data-export"));
}
-
-
@Test
public void testGetConsumerTopicsFromTopicConfig() throws Exception {
- assertThat(topicConfigurations.getConsumerTopicNames(), containsInAnyOrder("aai-event", "aai-data-export"));
+ assertThat(topicConfig.getConsumerTopicNames(), containsInAnyOrder("aai-event", "aai-data-export"));
}
-
@Test
public void testGetConsumerTopicConfigurationObjects() throws Exception {
Topic eventTopic = new TopicConfig("aai-event", "aai-data-integrity").new Topic();
@@ -81,7 +85,7 @@ public class TestTopicConfig {
exportTopic.setConsumerId("export-dummy-consumer-id");
exportTopic.setTransportType("export-dummy-transport-type");
- List<Topic> consumerTopics = topicConfigurations.getConsumerTopics();
+ List<Topic> consumerTopics = topicConfig.getConsumerTopics();
assertThat(consumerTopics, containsInAnyOrder(eventTopic, exportTopic));
}
@@ -96,10 +100,8 @@ public class TestTopicConfig {
integrityTopic.setPassword("integrity-dummy-password");
integrityTopic.setTransportType("integrity-dummy-transport-type");
- List<Topic> publisherTopics = topicConfigurations.getPublisherTopics();
+ List<Topic> publisherTopics = topicConfig.getPublisherTopics();
assertThat(publisherTopics, containsInAnyOrder(integrityTopic));
}
-
-
}
diff --git a/src/test/java/org/onap/aai/validation/modeldriven/validator/TestModelDrivenValidator.java b/src/test/java/org/onap/aai/validation/modeldriven/validator/TestModelDrivenValidator.java
index de06357..5a58f41 100644
--- a/src/test/java/org/onap/aai/validation/modeldriven/validator/TestModelDrivenValidator.java
+++ b/src/test/java/org/onap/aai/validation/modeldriven/validator/TestModelDrivenValidator.java
@@ -1,7 +1,10 @@
/**
- * ============LICENSE_START===================================================
- * Copyright (c) 2018-2019 Amdocs
- * ============================================================================
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2018-2019 European Software Marketing Ltd.
+ * ================================================================================
* 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
@@ -13,7 +16,7 @@
* 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=====================================================
+ * ============LICENSE_END=========================================================
*/
package org.onap.aai.validation.modeldriven.validator;
@@ -35,8 +38,6 @@ import org.dom4j.Element;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.onap.aai.validation.controller.ValidationController;
@@ -46,10 +47,13 @@ import org.onap.aai.validation.modeldriven.parser.XMLModelParser;
import org.onap.aai.validation.result.ValidationResult;
import org.onap.aai.validation.result.Violation;
import org.onap.aai.validation.test.util.TestUtil;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+@SpringBootTest
@RunWith(SpringJUnit4ClassRunner.class)
@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties"})
@ContextConfiguration(locations = {"classpath:model-validation/instance-validator/test-validation-service-beans.xml"})
@@ -63,10 +67,9 @@ public class TestModelDrivenValidator {
private static final String MODEL_ID_ATTRIBUTE_MNV = "model-name-version-id";
private static final String MODEL_ID_ATTRIBUTE_MID = "model-id";
- @Mock
+ @MockBean
private ModelCacheManager mockModelCacheManager;
- @InjectMocks
@Inject
private ModelDrivenValidator modelDrivenValidator;
diff --git a/src/test/java/org/onap/aai/validation/services/TestInfoService.java b/src/test/java/org/onap/aai/validation/services/TestInfoService.java
index ac9591a..f99748a 100644
--- a/src/test/java/org/onap/aai/validation/services/TestInfoService.java
+++ b/src/test/java/org/onap/aai/validation/services/TestInfoService.java
@@ -1,7 +1,10 @@
/**
- * ============LICENSE_START===================================================
- * Copyright (c) 2018-2019 Amdocs
- * ============================================================================
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2018-2019 European Software Marketing Ltd.
+ * ================================================================================
* 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
@@ -13,7 +16,7 @@
* 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=====================================================
+ * ============LICENSE_END=========================================================
*/
package org.onap.aai.validation.services;
@@ -37,13 +40,15 @@ import org.onap.aai.validation.exception.ValidationServiceException;
import org.onap.aai.validation.publisher.MockEventPublisher;
import org.onap.aai.validation.test.util.TestEntity;
import org.onap.aai.validation.test.util.TestUtil;
+import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+@SpringBootTest
@RunWith(SpringJUnit4ClassRunner.class)
-@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties", "classpath:application.properties"})
-@ContextConfiguration(locations = {"classpath:/info-service/test-validation-service-beans.xml"})
+@TestPropertySource(locations = { "classpath:oxm-reader/schemaIngest.properties", "classpath:application.properties" })
+@ContextConfiguration(locations = { "classpath:/info-service/test-validation-service-beans.xml" })
public class TestInfoService {
static {
@@ -51,9 +56,9 @@ public class TestInfoService {
}
enum TestData {
- // @formatter:off
- VSERVER("rule-driven-validator/test_events/vserver-create-event.json");
- // @formatter:on
+ VSERVER(
+ "rule-driven-validator/test_events/vserver-create-event.json"
+ );
private String filename;
diff --git a/src/test/resources/test-application.properties b/src/test/resources/test-application.properties
new file mode 100644
index 0000000..38b2962
--- /dev/null
+++ b/src/test/resources/test-application.properties
@@ -0,0 +1,6 @@
+consumer.topic.names=aai-event,aai-data-export
+publisher.topic.names=aai-data-integrity
+
+topics.properties.location=src/test/resources/topic-config/
+
+server.ssl.key-store=