aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEddy Hautot <eh552t@intl.att.com>2018-03-01 14:24:25 +0000
committerGerrit Code Review <gerrit@onap.org>2018-03-01 14:24:25 +0000
commit1be4bc8c604c7b4fb537a7cbc901eb8df2c6d3bc (patch)
tree198e6c52c951e74fcfc348d870600404084bc872 /src
parent14a54c4172a594cb194f744b0c617d89334c3138 (diff)
parentdc03cc0e64ec732d59b063331054073c85b4bf89 (diff)
Merge "Fix the tests"
Diffstat (limited to 'src')
-rw-r--r--src/test/java/org/onap/clamp/clds/AbstractItCase.java44
-rw-r--r--src/test/java/org/onap/clamp/clds/it/CldsDaoItCase.java3
-rw-r--r--src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java3
-rw-r--r--src/test/java/org/onap/clamp/clds/it/CldsTemplateServiceItCase.java3
-rw-r--r--src/test/java/org/onap/clamp/clds/it/DcaeHttpConnectionManagerItCase.java3
-rw-r--r--src/test/java/org/onap/clamp/clds/it/HolmesPolicyDelegateItCase.java3
-rw-r--r--src/test/java/org/onap/clamp/clds/it/HttpsItCase.java14
-rw-r--r--src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java8
-rw-r--r--src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java10
-rw-r--r--src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesItCase.java6
-rw-r--r--src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java3
-rw-r--r--src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java7
-rw-r--r--src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java (renamed from src/test/java/org/onap/clamp/clds/it/CldsReferencePropertiesItCase.java)47
13 files changed, 67 insertions, 87 deletions
diff --git a/src/test/java/org/onap/clamp/clds/AbstractItCase.java b/src/test/java/org/onap/clamp/clds/AbstractItCase.java
deleted file mode 100644
index 7e290884..00000000
--- a/src/test/java/org/onap/clamp/clds/AbstractItCase.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * 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============================================
- * ===================================================================
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- */
-
-package org.onap.clamp.clds;
-
-import org.junit.BeforeClass;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.config.CldsReferenceProperties;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ActiveProfiles;
-
-@ActiveProfiles("clamp-default")
-public abstract class AbstractItCase {
-
- @Autowired
- protected CldsReferenceProperties refProp;
- @Autowired
- protected PolicyClient policyClient;
-
- @BeforeClass
- public static void oneTimeSetUp() {
- System.setProperty("CLDS_DCAE_URL", "http://localhost:13786/cl-dcae-services");
- }
-}
diff --git a/src/test/java/org/onap/clamp/clds/it/CldsDaoItCase.java b/src/test/java/org/onap/clamp/clds/it/CldsDaoItCase.java
index 1e9a9ed5..861921c1 100644
--- a/src/test/java/org/onap/clamp/clds/it/CldsDaoItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/CldsDaoItCase.java
@@ -42,7 +42,6 @@ import org.apache.commons.codec.DecoderException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.clamp.clds.AbstractItCase;
import org.onap.clamp.clds.client.req.sdc.SdcCatalogServices;
import org.onap.clamp.clds.dao.CldsDao;
import org.onap.clamp.clds.model.CLDSMonitoringDetails;
@@ -62,7 +61,7 @@ import org.springframework.test.context.junit4.SpringRunner;
*/
@RunWith(SpringRunner.class)
@SpringBootTest
-public class CldsDaoItCase extends AbstractItCase {
+public class CldsDaoItCase {
protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsDao.class);
@Autowired
diff --git a/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java b/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java
index 932434de..c2b6fb16 100644
--- a/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java
@@ -45,7 +45,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
-import org.onap.clamp.clds.AbstractItCase;
import org.onap.clamp.clds.dao.CldsDao;
import org.onap.clamp.clds.model.CldsHealthCheck;
import org.onap.clamp.clds.model.CldsInfo;
@@ -65,7 +64,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-public class CldsServiceItCase extends AbstractItCase {
+public class CldsServiceItCase {
@Autowired
private CldsService cldsService;
diff --git a/src/test/java/org/onap/clamp/clds/it/CldsTemplateServiceItCase.java b/src/test/java/org/onap/clamp/clds/it/CldsTemplateServiceItCase.java
index 626cf957..1caa637c 100644
--- a/src/test/java/org/onap/clamp/clds/it/CldsTemplateServiceItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/CldsTemplateServiceItCase.java
@@ -41,7 +41,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
-import org.onap.clamp.clds.AbstractItCase;
import org.onap.clamp.clds.dao.CldsDao;
import org.onap.clamp.clds.model.CldsTemplate;
import org.onap.clamp.clds.model.ValueItem;
@@ -57,7 +56,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-public class CldsTemplateServiceItCase extends AbstractItCase {
+public class CldsTemplateServiceItCase {
protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsTemplateServiceItCase.class);
@Autowired
diff --git a/src/test/java/org/onap/clamp/clds/it/DcaeHttpConnectionManagerItCase.java b/src/test/java/org/onap/clamp/clds/it/DcaeHttpConnectionManagerItCase.java
index 2bdef978..7c4f46d0 100644
--- a/src/test/java/org/onap/clamp/clds/it/DcaeHttpConnectionManagerItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/DcaeHttpConnectionManagerItCase.java
@@ -44,7 +44,6 @@ import javax.ws.rs.BadRequestException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.clamp.clds.AbstractItCase;
import org.onap.clamp.clds.client.DcaeHttpConnectionManager;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
@@ -58,7 +57,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
@TestPropertySource(locations = "classpath:https/https-test.properties")
-public class DcaeHttpConnectionManagerItCase extends AbstractItCase {
+public class DcaeHttpConnectionManagerItCase {
@Value("${server.port}")
private String httpsPort;
diff --git a/src/test/java/org/onap/clamp/clds/it/HolmesPolicyDelegateItCase.java b/src/test/java/org/onap/clamp/clds/it/HolmesPolicyDelegateItCase.java
index c530a059..29b28a8a 100644
--- a/src/test/java/org/onap/clamp/clds/it/HolmesPolicyDelegateItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/HolmesPolicyDelegateItCase.java
@@ -29,7 +29,6 @@ import java.io.IOException;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.clamp.clds.AbstractItCase;
import org.onap.clamp.clds.client.HolmesPolicyDelegate;
import org.onap.clamp.clds.model.properties.Holmes;
import org.onap.clamp.clds.model.properties.ModelProperties;
@@ -42,7 +41,7 @@ import org.springframework.test.context.junit4.SpringRunner;
*/
@RunWith(SpringRunner.class)
@SpringBootTest
-public class HolmesPolicyDelegateItCase extends AbstractItCase {
+public class HolmesPolicyDelegateItCase {
@Test
public void testCreatePolicyJson() throws IOException {
diff --git a/src/test/java/org/onap/clamp/clds/it/HttpsItCase.java b/src/test/java/org/onap/clamp/clds/it/HttpsItCase.java
index 9befc40b..73c447b8 100644
--- a/src/test/java/org/onap/clamp/clds/it/HttpsItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/HttpsItCase.java
@@ -38,7 +38,6 @@ import javax.net.ssl.X509TrustManager;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.clamp.clds.AbstractItCase;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -55,11 +54,10 @@ import org.springframework.web.client.RestTemplate;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
@TestPropertySource(locations = "classpath:https/https-test.properties")
-public class HttpsItCase extends AbstractItCase {
+public class HttpsItCase {
@Value("${server.port}")
private String httpsPort;
-
@Value("${server.http-to-https-redirection.port}")
private String httpPort;
@@ -68,7 +66,6 @@ public class HttpsItCase extends AbstractItCase {
*/
@BeforeClass
public static void setUp() {
-
try {
// setup ssl context to ignore certificate errors
SSLContext ctx = SSLContext.getInstance("TLS");
@@ -89,12 +86,13 @@ public class HttpsItCase extends AbstractItCase {
return null;
}
};
- ctx.init(null, new TrustManager[] { tm }, null);
+ ctx.init(null, new TrustManager[] {
+ tm
+ }, null);
SSLContext.setDefault(ctx);
} catch (Exception ex) {
ex.printStackTrace();
}
-
}
@Test
@@ -108,16 +106,13 @@ public class HttpsItCase extends AbstractItCase {
}
});
template.setRequestFactory(factory);
-
ResponseEntity<String> entity = template
.getForEntity("http://localhost:" + this.httpPort + "/designer/index.html", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND);
-
ResponseEntity<String> httpsEntity = template
.getForEntity("https://localhost:" + this.httpsPort + "/designer/index.html", String.class);
assertThat(httpsEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(httpsEntity.getBody()).contains("CLDS");
-
}
/**
@@ -141,5 +136,4 @@ public class HttpsItCase extends AbstractItCase {
super.prepareConnection(connection, httpMethod);
}
}
-
}
diff --git a/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java b/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java
index 873b0192..04bc9594 100644
--- a/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java
@@ -35,8 +35,8 @@ import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.clamp.clds.AbstractItCase;
import org.onap.clamp.clds.client.req.policy.OperationalPolicyReq;
+import org.onap.clamp.clds.config.CldsReferenceProperties;
import org.onap.clamp.clds.model.CldsEvent;
import org.onap.clamp.clds.model.properties.ModelProperties;
import org.onap.clamp.clds.model.properties.Policy;
@@ -44,12 +44,16 @@ import org.onap.clamp.clds.model.properties.PolicyChain;
import org.onap.clamp.clds.util.ResourceFileUtil;
import org.onap.policy.api.AttributeType;
import org.onap.policy.controlloop.policy.builder.BuilderException;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
-public class OperationPolicyReqItCase extends AbstractItCase {
+public class OperationPolicyReqItCase {
+
+ @Autowired
+ private CldsReferenceProperties refProp;
@Test
public void formatAttributesTest() throws IOException, BuilderException {
diff --git a/src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java b/src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java
index 0e8a2177..eb17c22c 100644
--- a/src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java
@@ -33,9 +33,10 @@ import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.clamp.clds.AbstractItCase;
import org.onap.clamp.clds.client.req.policy.OperationalPolicyReq;
+import org.onap.clamp.clds.client.req.policy.PolicyClient;
import org.onap.clamp.clds.client.req.tca.TcaRequestFormatter;
+import org.onap.clamp.clds.config.CldsReferenceProperties;
import org.onap.clamp.clds.model.CldsEvent;
import org.onap.clamp.clds.model.properties.ModelProperties;
import org.onap.clamp.clds.model.properties.Policy;
@@ -43,6 +44,7 @@ import org.onap.clamp.clds.model.properties.PolicyChain;
import org.onap.clamp.clds.model.properties.Tca;
import org.onap.clamp.clds.util.ResourceFileUtil;
import org.onap.policy.api.AttributeType;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -52,8 +54,12 @@ import org.springframework.test.context.junit4.SpringRunner;
*/
@RunWith(SpringRunner.class)
@SpringBootTest
-public class PolicyClientItCase extends AbstractItCase {
+public class PolicyClientItCase {
+ @Autowired
+ private CldsReferenceProperties refProp;
+ @Autowired
+ protected PolicyClient policyClient;
String modelProp;
String modelBpmnProp;
String modelName;
diff --git a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesItCase.java b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesItCase.java
index 7f962215..d873aa48 100644
--- a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesItCase.java
@@ -32,8 +32,8 @@ import org.apache.commons.io.IOUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
-import org.onap.clamp.clds.AbstractItCase;
import org.onap.clamp.clds.client.req.sdc.SdcCatalogServices;
+import org.onap.clamp.clds.config.CldsReferenceProperties;
import org.onap.clamp.clds.model.CldsAlarmCondition;
import org.onap.clamp.clds.model.CldsServiceData;
import org.onap.clamp.clds.model.sdc.SdcResource;
@@ -48,9 +48,11 @@ import org.springframework.test.context.junit4.SpringRunner;
*/
@RunWith(SpringRunner.class)
@SpringBootTest
-public class SdcCatalogServicesItCase extends AbstractItCase {
+public class SdcCatalogServicesItCase {
@Autowired
+ private CldsReferenceProperties refProp;
+ @Autowired
private SdcCatalogServices sdcCatalogWired = new SdcCatalogServices();
@Test
diff --git a/src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java b/src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java
index 2efc5286..ce9c15c0 100644
--- a/src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java
@@ -35,7 +35,6 @@ import org.apache.commons.codec.DecoderException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.clamp.clds.AbstractItCase;
import org.onap.clamp.clds.client.req.sdc.SdcRequests;
import org.onap.clamp.clds.model.CldsEvent;
import org.onap.clamp.clds.model.properties.ModelProperties;
@@ -47,7 +46,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
-public class SdcReqItCase extends AbstractItCase {
+public class SdcReqItCase {
@Autowired
private SdcRequests sdcReq;
diff --git a/src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java b/src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java
index c290a386..24f127c3 100644
--- a/src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java
@@ -32,12 +32,13 @@ import org.json.JSONException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.clamp.clds.AbstractItCase;
import org.onap.clamp.clds.client.req.tca.TcaRequestFormatter;
+import org.onap.clamp.clds.config.CldsReferenceProperties;
import org.onap.clamp.clds.model.CldsEvent;
import org.onap.clamp.clds.model.properties.ModelProperties;
import org.onap.clamp.clds.util.ResourceFileUtil;
import org.skyscreamer.jsonassert.JSONAssert;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -46,8 +47,10 @@ import org.springframework.test.context.junit4.SpringRunner;
*/
@RunWith(SpringRunner.class)
@SpringBootTest
-public class TcaRequestFormatterItCase extends AbstractItCase {
+public class TcaRequestFormatterItCase {
+ @Autowired
+ private CldsReferenceProperties refProp;
private String modelProp;
private String modelBpmn;
private String modelName;
diff --git a/src/test/java/org/onap/clamp/clds/it/CldsReferencePropertiesItCase.java b/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java
index 6c94fc16..79b26111 100644
--- a/src/test/java/org/onap/clamp/clds/it/CldsReferencePropertiesItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java
@@ -21,18 +21,20 @@
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-package org.onap.clamp.clds.it;
+package org.onap.clamp.clds.it.config;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.IOException;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.clamp.clds.AbstractItCase;
+import org.onap.clamp.clds.config.CldsReferenceProperties;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -41,9 +43,23 @@ import org.springframework.test.context.junit4.SpringRunner;
*/
@RunWith(SpringRunner.class)
@SpringBootTest
-public class CldsReferencePropertiesItCase extends AbstractItCase {
+public class CldsReferencePropertiesItCase {
+
+ @Autowired
+ private CldsReferenceProperties refProp;
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsReferencePropertiesItCase.class);
+ /**
+ * Test getting a value the properties in string.
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testGetStringValue() throws IOException {
+ assertEquals(refProp.getStringValue("policy.onap.name"), "DCAE");
+ assertEquals(refProp.getStringValue("policy.ms.policyNamePrefix", ""), "Config_MS_");
+ assertEquals(refProp.getStringValue("policy.ms.policyNamePrefix", "testos"), "Config_MS_");
+ assertEquals(refProp.getStringValue("policy.ms", "policyNamePrefix"), "Config_MS_");
+ }
/**
* Test getting prop value as a JSON Node / template.
@@ -53,11 +69,16 @@ public class CldsReferencePropertiesItCase extends AbstractItCase {
*/
@Test
public void testJsonTemplate() throws IOException {
- ObjectNode root = (ObjectNode) refProp.getJsonTemplate("tca.template");
- root.put("closedLoopControlName", "ClosedLoop-FRWL-SIG-1582f840-2881-11e6-b4ec-005056a9d756");
- ObjectMapper mapper = new ObjectMapper();
- String jsonText = mapper.writeValueAsString(root);
- logger.error("Exception caught IllegalArgumentException as expected");
- // assertEquals(topicsJson, ref.getTopicsToJson());
+ // ui.location.default={"DC1":"Data Center 1","DC2":"Data Center
+ // 2","DC3":"Data Center 3"}
+ ObjectNode root = (ObjectNode) refProp.getJsonTemplate("ui.location.default");
+ assertNotNull(root);
+ assertEquals(root.get("DC1").asText(), "Data Center 1");
+ // Test composite key
+ root = (ObjectNode) refProp.getJsonTemplate("ui.location", "default");
+ assertNotNull(root);
+ assertEquals(root.get("DC1").asText(), "Data Center 1");
+ root = (ObjectNode) refProp.getJsonTemplate("ui.location", "");
+ assertNull(root);
}
}