summaryrefslogtreecommitdiffstats
path: root/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp
diff options
context:
space:
mode:
authorPatrick Brady <pb071s@att.com>2017-12-13 11:19:06 -0800
committerPatrick Brady <pb071s@att.com>2017-12-13 11:19:17 -0800
commit781b1a6df324419c846c84ea983c18fc8362bfd3 (patch)
tree580008010dd50ca32db2ef6dc2e36628cf8c2b5b /appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp
parent161df8a94bb3b0c34ed16fd4fdba078bd1eeef9a (diff)
Third part of onap rename
This part of the commit changes the folder structure on all other folders of appc. Change-Id: I8acfa11cdfcdcd36be0e137245d1dd7324f1abd3 Signed-off-by: Patrick Brady <pb071s@att.com> Issue-ID: APPC-13
Diffstat (limited to 'appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp')
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/LCM/TestConverter.java94
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/LCM1607/model/TestJsonGenericMessages.java102
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/TestAbstractListener.java101
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/TestAppcDmaapListenerActivator.java49
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/TestListenerProperties.java157
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/demo/model/TestEnums.java61
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/demo/model/TestMessages.java163
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestController.java29
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestEventHandler.java173
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestListener.java115
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/util/TestMapper.java107
11 files changed, 0 insertions, 1151 deletions
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/LCM/TestConverter.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/LCM/TestConverter.java
deleted file mode 100644
index f9fb7f408..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/LCM/TestConverter.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.listener.LCM;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import org.junit.Assert;
-import org.junit.Test;
-import org.onap.appc.listener.LCM.conv.Converter;
-import org.onap.appc.listener.LCM.model.DmaapIncomingMessage;
-import org.onap.appc.listener.LCM.model.DmaapOutgoingMessage;
-import org.onap.appc.listener.util.Mapper;
-
-public class TestConverter {
-
- private String jsonInputBodyStr ="{\"input\":{ \"common-header\": { \"timestamp\": \"2016-08-03T08:50:18.97Z\", \"api-ver\": \"1\", \"originator-id\": \"1\", \"request-id\": \"123\", \"sub-request-id\": \"1\", \"flags\": { \"force\":\"TRUE\", \"ttl\":\"9900\" } }, \"action\": \"Stop\", \"action-identifiers\": { \"vnf-id\": \"TEST\" } }}";
- private String jsonOutputBodyStr ="{\"output\":{\"common-header\":{\"timestamp\":\"2016-08-03T08:50:18.97Z\",\"api-ver\":\"1\",\"flags\":{\"force\":\"TRUE\",\"ttl\":\"9900\"},\"sub-request-id\":\"1\",\"request-id\":\"123\",\"originator-id\":\"1\"},\"status\":{\"value\":\"TestException\",\"code\":200}}}";
-
- @Test
- public void buildDmaapOutgoingMessageWithUnexpectedErrorTest() throws JsonProcessingException {
- DmaapIncomingMessage dmaapIncomingMessage = buildDmaapIncomingMessage();
- String errMsg = "TestException";
- DmaapOutgoingMessage dmaapOutgoingMessage = Converter.buildDmaapOutgoingMessageWithUnexpectedError(dmaapIncomingMessage, new Exception(errMsg));
- int code = dmaapOutgoingMessage.getBody().get("output").get("status").get("code").asInt();
- String value = dmaapOutgoingMessage.getBody().get("output").get("status").get("value").asText();
- Assert.assertEquals(200,code);
- Assert.assertEquals(errMsg,value);
- }
-
- private static String expectedDmaapOutgoingMessageAsJsonString = "{\"body\":{\"output\":{\"common-header\":{\"timestamp\":\"2016-08-03T08:50:18.97Z\",\"api-ver\":\"1\",\"flags\":{\"force\":\"TRUE\",\"ttl\":\"9900\"},\"sub-request-id\":\"1\",\"request-id\":\"123\",\"originator-id\":\"1\"},\"status\":{\"value\":\"TestException\",\"code\":200}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"test\"}";
- @Test
- public void convDmaapOutgoingMessageToJsonStringTest() throws JsonProcessingException {
- DmaapOutgoingMessage dmaapOutgoingMessage = buildDmaapOutgoingMessage();
- String dmaapOutgoingMessageAsJsonString = Converter.convDmaapOutgoingMessageToJsonString(dmaapOutgoingMessage);
-// Assert.assertEquals(dmaapOutgoingMessageAsJsonString,dmaapOutgoingMessageAsJsonString);
- Assert.assertEquals(expectedDmaapOutgoingMessageAsJsonString,dmaapOutgoingMessageAsJsonString);
- }
-
- private DmaapIncomingMessage buildDmaapIncomingMessage() {
- DmaapIncomingMessage dmaapIncomingMessage = new DmaapIncomingMessage();
- dmaapIncomingMessage.setRpcName("test");
- JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(jsonInputBodyStr);
- dmaapIncomingMessage.setBody(jsonNode);
- return dmaapIncomingMessage;
-
- }
-
- private DmaapOutgoingMessage buildDmaapOutgoingMessage() {
- DmaapOutgoingMessage dmaapOutgoingMessage = new DmaapOutgoingMessage();
- dmaapOutgoingMessage.setRpcName("test");
- JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(jsonOutputBodyStr);
- dmaapOutgoingMessage.setBody(jsonNode);
- return dmaapOutgoingMessage;
-
- }
-
-
- @Test
- public void extractRequestIdWithSubIdTest() {
- DmaapIncomingMessage dmaapIncomingMessage = buildDmaapIncomingMessage();
- String equestIdWithSubId = Converter.extractRequestIdWithSubId(dmaapIncomingMessage.getBody());
- Assert.assertEquals("123-1",equestIdWithSubId);
- }
-
- @Test
- public void extractStatusCodeTest() {
- DmaapOutgoingMessage dmaapOutgoingMessage = buildDmaapOutgoingMessage();
- Integer statusCode = Converter.extractStatusCode(dmaapOutgoingMessage.getBody());
- Assert.assertEquals(200L,statusCode.longValue());
- }
-
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/LCM1607/model/TestJsonGenericMessages.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/LCM1607/model/TestJsonGenericMessages.java
deleted file mode 100644
index f28bd8cb3..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/LCM1607/model/TestJsonGenericMessages.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.listener.LCM1607.model;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.Assert;
-import org.junit.Test;
-import org.onap.appc.listener.util.Mapper;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-
-public class TestJsonGenericMessages {/*
-
- @Test
- public void serializeIncomingMessage() {
-
- final String expectedJson = "{\"CommonHeader\":{\"TimeStamp\":\"2016-05-02 19:50:37.09\",\"TransactionID\":\"1\",\"APIver\":\"1.01\",\"RequestTrack\":[\"1\",\"4\",\"12\",\"3\"],\"Flags\":null,\"SubrequestID\":null,\"OriginatorID\":\"2\"},\"Payload\":\"{ \\\"command\\\": \\\"start\\\", \\\"target-id\\\": \\\"111\\\", \\\"flag10\\\": {\\\"object-1\\\": {\\\"key-1\\\": \\\"key\\\", \\\"value-1\\\": \\\"value\\\" }} }\",\"Action\":\"CONFIGURE\",\"ObjectID\":\"200\",\"TargetID\":\"100\"}";
- InputBody msg = createIncomingMessage();
-
- String json = Mapper.toJsonObject(msg).toString();
- //System.out.println(json);
- Assert.assertEquals(expectedJson, json);
- }
-
- @Test
- public void deserializeIncomingMessage() throws IOException {
- final String originalJson = "{\"CommonHeader\":{\"TimeStamp\":\"2016-05-02 19:50:37.09\",\"TransactionID\":\"1\",\"Flags\":{\"FORCE\":\"Y\",\"TTL\":\"12\"},\"SubrequestID\":\"2345\",\"OriginatorID\":\"2\",\"APIver\":\"1.01\"}, \"Payload\": \" \\\"Graceful\\\" : \\\"Yes\\\" \",\"Action\":\"CONFIGURE\",\"ObjectID\":\"200\",\"TargetID\":\"100\"}";
-
- ObjectMapper mapper = new ObjectMapper();
- InputBody msg = mapper.readValue(originalJson, InputBody.class);
-
- Assert.assertNotNull(msg);
- Assert.assertEquals("2016-05-02 19:50:37.09", msg.getCommonHeader().getTimeStamp());
- Assert.assertEquals("1", msg.getCommonHeader().getRequestID());
- Assert.assertEquals("1.01", msg.getCommonHeader().getApiVer());
- Assert.assertEquals("200", msg.getObjectId());
- Assert.assertEquals("100", msg.getTargetId());
- Assert.assertEquals(" \"Graceful\" : \"Yes\" ", msg.getPayload());
- Assert.assertEquals("CONFIGURE", msg.getAction());
-
- }
-
- @Test
- public void serializeResponseMessage() {
- InputBody imsg = createIncomingMessage();
- OutputBody omsg = new OutputBody(imsg);
- omsg.setStatus(new ResponseStatus("200", "OK"));
-
- String json = Mapper.toJsonObject(omsg).toString();
- System.out.println(json);
- //Assert.assertEquals(expectedJson, json);
- Assert.assertNotEquals("", json);
-
- }
-
- private InputBody createIncomingMessage() {
- InputBody msg = new InputBody();
- CommonHeader rh = new CommonHeader();
- rh.setTimeStamp("2016-05-02 19:50:37.09");
- rh.setApiVer("1.01");
- rh.setRequestID("1");
- rh.setOriginatorId("2");
-
-
- Map<String, String> flags = new HashMap<>();
- flags.put("FORCE", "Y");
- flags.put("TTL", "12");
-
- msg.setCommonHeader(rh);
- msg.setAction("CONFIGURE");
- msg.setTargetId("100");
- msg.setObjectId("200");
- msg.setPayloadAsString("{ \"command\": \"start\", \"target-id\": \"111\", \"flag10\": {\"object-1\": {\"key-1\": \"key\", \"value-1\": \"value\" }} }");
- return msg;
- }
-*/
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/TestAbstractListener.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/TestAbstractListener.java
deleted file mode 100644
index a21bcd416..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/TestAbstractListener.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.listener;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Properties;
-import java.util.concurrent.ThreadPoolExecutor;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.appc.listener.AbstractListener;
-import org.onap.appc.listener.ListenerProperties;
-
-public class TestAbstractListener {
-
- private class DummyListener extends AbstractListener {
- public DummyListener(ListenerProperties props) {
- super(props);
- }
-
- public boolean getRun() {
- return run.get();
- }
-
- public ThreadPoolExecutor getExecutor() {
- return executor;
- }
- }
-
- private DummyListener listener;
- private ListenerProperties props;
-
- @Before
- public void setup() throws Exception {
- Properties regularProps = new Properties();
- regularProps.load(getClass().getResourceAsStream("/org/onap/appc/default.properties"));
- props = new ListenerProperties("", regularProps);
- listener = new DummyListener(props);
- }
-
- @Test
- public void testRun() {
- Thread t = new Thread(listener);
- t.run();
- assertFalse(t.isAlive()); // Should die immediately
- }
-
- @Test
- public void testStop() {
- listener.stop();
- assertFalse(listener.getRun());
- assertTrue(listener.getExecutor().isShutdown());
- }
-
- @Test
- public void testStopNow() {
- listener.stopNow();
- assertFalse(listener.getRun());
- assertTrue(listener.getExecutor().isShutdown());
- }
-
- @Test
- public void testBenchmark() {
- String out = listener.getBenchmark();
- assertNotNull(out);
- assertTrue(out.contains(listener.getListenerId()));
- }
-
- @Test
- public void testListenerId() {
- assertEquals(props.getPrefix(), listener.getListenerId());
- listener.setListenerId("newId");
- assertEquals("newId", listener.getListenerId());
- }
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/TestAppcDmaapListenerActivator.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/TestAppcDmaapListenerActivator.java
deleted file mode 100644
index 6bb96b95c..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/TestAppcDmaapListenerActivator.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.listener;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import org.junit.Test;
-import org.onap.appc.listener.AppcEventListenerActivator;
-
-public class TestAppcDmaapListenerActivator {
-
- @Test
- public void testStartStop() {
- // TODO - How do we tests activators
- AppcEventListenerActivator appc = new AppcEventListenerActivator();
- try {
- appc.start(null);
- Thread.sleep(2000);
- appc.stop(null);
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- assertNotNull(appc.getName());
- }
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/TestListenerProperties.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/TestListenerProperties.java
deleted file mode 100644
index 42c263394..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/TestListenerProperties.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.listener;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.Properties;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.appc.adapter.factory.MessageService;
-import org.onap.appc.listener.AbstractListener;
-import org.onap.appc.listener.ListenerProperties;
-import org.onap.appc.listener.ListenerProperties.KEYS;
-
-public class TestListenerProperties {
-
- private Properties good, bad, both;
- private String prefix;
-
- private ListenerProperties props;
-
- @Before
- public void setup() {
- prefix = "test";
- good = new Properties();
- bad = new Properties();
- both = new Properties();
-
- good.setProperty(String.format("%s.%s", prefix, "a"), "1");
- good.setProperty(String.format("%s.%s", prefix, "a.b"), "2");
- good.setProperty(String.format("%s.%s", prefix, "a.b.c"), "3");
-
- bad.setProperty(prefix, "NA");
- bad.setProperty(prefix + ".", "NA");
- bad.setProperty(String.format("%s.%s", prefix + "x", "bad"), "NA");
- bad.setProperty(String.format("%s.%s", "x" + prefix, "bad"), "NA");
-
- for (String key : good.stringPropertyNames()) {
- both.put(key, good.getProperty(key));
- }
- for (String key : bad.stringPropertyNames()) {
- both.put(key, bad.getProperty(key));
- }
-
- props = new ListenerProperties(prefix, both);
- }
-
- @Test
- public void testConstructor() {
- props = new ListenerProperties(prefix, good);
- assertEquals(prefix, props.getPrefix());
- assertEquals(good.size(), props.getProperties().size());
-
- props = new ListenerProperties(prefix, bad);
- assertEquals(prefix, props.getPrefix());
- assertTrue(props.getProperties().isEmpty());
-
- props = new ListenerProperties(prefix, both);
- assertEquals(prefix, props.getPrefix());
- assertEquals(good.size(), props.getProperties().size());
-
- for (Object val : props.getProperties().values()) {
- assertFalse("NA".equals(val.toString()));
- }
-
- assertTrue(props.toString().contains(prefix));
- }
-
- @Test
- public void testGetClass() {
- assertNull(props.getListenerClass());
- props.setListenerClass(AbstractListener.class);
- assertNotNull(props.getListenerClass());
- assertEquals(AbstractListener.class, props.getListenerClass());
- }
-
- @Test
- public void testMessageServices() {
- // Hardcode count so tests must be updated when values are added
- assertEquals(1, MessageService.values().length);
-
- // Bad Input
- MessageService def = MessageService.DMaaP;
- assertEquals(def, MessageService.parse(null));
- assertEquals(def, MessageService.parse(""));
- assertEquals(def, MessageService.parse("NotDMaaP"));
-
- // DMaaP case sensitivity
- assertEquals(MessageService.DMaaP, MessageService.parse("dmaap"));
- assertEquals(MessageService.DMaaP, MessageService.parse("DMAAP"));
- assertEquals(MessageService.DMaaP, MessageService.parse("DMaaP"));
- }
-
- @Test
- public void testKeys() {
- // Hardcode count so tests must be updated when values are added
- assertEquals(15, ListenerProperties.KEYS.values().length);
-
- Properties tmp = new Properties();
- try {
- tmp.load(getClass().getResourceAsStream("/org/onap/appc/default.properties"));
- } catch (Exception e) {
- fail("Could not load properties to test");
- }
- String realPrefix = tmp.getProperty("test.prefix");
- assertNotNull(realPrefix);
- props = new ListenerProperties(realPrefix, tmp);
-
- for (KEYS key : ListenerProperties.KEYS.values()) {
- assertNotNull(key.getFullProp(realPrefix));
- assertNotNull(props.getProperty(key));
- assertNotNull(props.getProperty(key.getPropertySuffix()));
- }
- }
-
- @Test
- public void testDisabled() throws Exception {
- assertFalse(props.isDisabled());
- props.getProperties().put(KEYS.DISABLED.getPropertySuffix(), "TRUE");
- assertTrue(props.isDisabled());
- props.getProperties().put(KEYS.DISABLED.getPropertySuffix(), "N/A");
- assertFalse(props.isDisabled());
- props.getProperties().put(KEYS.DISABLED.getPropertySuffix(), "fAlse");
- assertFalse(props.isDisabled());
- props.getProperties().remove(KEYS.DISABLED.getPropertySuffix());
- assertFalse(props.isDisabled());
- }
-
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/demo/model/TestEnums.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/demo/model/TestEnums.java
deleted file mode 100644
index f201e02f0..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/demo/model/TestEnums.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.listener.demo.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-import org.junit.Test;
-import org.onap.appc.listener.demo.model.Action;
-import org.onap.appc.listener.demo.model.Status;
-
-public class TestEnums {
-
- @Test
- public void testAction() {
- assertEquals(Action.Rebuild, Action.toAction("Rebuild"));
- assertEquals(Action.Restart, Action.toAction("restart"));
- assertEquals(Action.Migrate, Action.toAction("MIGRATE"));
- assertEquals(Action.Evacuate, Action.toAction("Evacuate"));
- assertNull(Action.toAction("Unknown"));
- assertNull(Action.toAction(null));
-
- assertEquals(6, Action.values().length);
- }
-
- @Test
- public void testStatus() {
-
- assertEquals(Status.ACCEPTED, Status.toStatus("accepted"));
- assertEquals(Status.SUCCESS, Status.toStatus("SuCcEsS"));
- assertEquals(Status.FAILURE, Status.toStatus("Failure"));
- assertNull(Status.toStatus("Unknown"));
- assertNull(Status.toStatus(null));
-
- assertEquals(3, Status.values().length);
-
- }
-
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/demo/model/TestMessages.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/demo/model/TestMessages.java
deleted file mode 100644
index 3eedd88a3..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/demo/model/TestMessages.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.listener.demo.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.apache.commons.io.IOUtils;
-import org.json.JSONObject;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.onap.appc.listener.demo.model.IncomingMessage;
-import org.onap.appc.listener.demo.model.OutgoingMessage;
-import org.onap.appc.listener.demo.model.Status;
-import org.onap.appc.listener.util.Mapper;
-
-public class TestMessages {
- private IncomingMessage in;
- private OutgoingMessage out;
-
- private String incomingStr;
- private String outgoingStr;
-
- @Before
- public void setup() {
- try {
- incomingStr = IOUtils.toString(getClass().getResourceAsStream("/IncomingMessagedemo.txt"), "UTF-8");
- outgoingStr = IOUtils.toString(getClass().getResourceAsStream("/OutgoingMessagedemo.txt"), "UTF-8");
- assertNotNull(incomingStr);
- assertNotNull(outgoingStr);
-
- in = Mapper.mapOne(incomingStr, IncomingMessage.class);
-
- out = Mapper.mapOne(outgoingStr, OutgoingMessage.class);
-
- assertNotNull(in);
- assertNotNull(out);
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- // NOTE Test Mapper will be used to test an event from dmaap.
- @Test
- public void testGetterSetter() {
- assertNotNull(in);
- assertNotNull(in.getAction());
- assertNotNull(in.getHeader().getApiVer());
- assertNotNull(in.getHeader().getOriginatorId());
- assertNotNull(in.getHeader().getRequestID());
- assertNotNull(in.getHeader().getSubRequestId());
- assertNotNull(in.getHeader().getTimeStamp());
-
- assertNotNull(out);
- assertNotNull(out.getHeader().getApiVer());
- assertNotNull(out.getHeader().getOriginatorId());
- assertNotNull(out.getHeader().getRequestID());
- assertNotNull(out.getHeader().getSubRequestId());
- assertNotNull(out.getHeader().getTimeStamp());
- assertNotNull(out.getStatus().getCode());
- assertNotNull(out.getStatus().getValue());
-
- }
-
- @Test
- @Ignore
- public void testIncommingToOutgoing(){
- OutgoingMessage newOut;
- newOut = Mapper.mapOne(in.toOutgoing(Status.ACCEPTED), OutgoingMessage.class);
- assertNotNull(newOut);
- assertNotNull(newOut.getHeader().getApiVer());
- assertNotNull(newOut.getHeader().getOriginatorId());
- assertNotNull(newOut.getHeader().getRequestID());
- assertNotNull(newOut.getHeader().getSubRequestId());
- assertNotNull(newOut.getHeader().getTimeStamp());
- assertNotNull(newOut.getStatus().getCode());
- assertNotNull(newOut.getStatus().getValue());
- }
-
- @Test
- @Ignore
- public void testToString() {
- in = new IncomingMessage();
- assertNotNull(in.toString());
- String id = "test";
- //in.setId(id);
- assertNotNull(in.toString());
- assertTrue(in.toString().contains(id));
- }
-
-
- @Test
- @Ignore
- public void testOutgoingUpdateTime() {
- //String old = out.getResponseTime();
- out.updateResponseTime();
- //assertFalse(old.equals(out.getResponseTime()));
- }
-
- // Testing for 1510
- @Test
- @Ignore
- public void testOutgoingToJson() {
- // Message Set
- String message = "MSG";
- //out.setMessage(message);
- JSONObject json = out.toResponse();
- assertNotNull(json);
- String respStr = json.getString("response");
- //assertTrue(respStr.contains(out.getResponse().getValue()));
-
- String msgStr = json.getString("message");
- assertNotNull(msgStr);
- //assertFalse(msgStr.contains(out.getOriginalRequest())); // False for 1602
- //assertTrue(msgStr.contains(out.getMessage()));
-
- // Null Message
- //out.setMessage(null);
- json = out.toResponse();
- assertNotNull(json);
- msgStr = json.getString("message");
- assertNotNull(msgStr);
- //assertFalse(msgStr.contains(out.getOriginalRequest())); // False for 1602
- //assertTrue(msgStr.contains(out.getResponse().getValue()));
-
- // Echoing request
- //assertNotNull(out.getOriginalRequest());
- }
-
- @Test
- @Ignore
- public void testOutgoingToString() {
- String s = out.toString();
- //assertTrue(s.contains(out.getId()));
- }
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestController.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestController.java
deleted file mode 100644
index d44bb22cc..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestController.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.listener.impl;
-
-public class TestController {
-
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestEventHandler.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestEventHandler.java
deleted file mode 100644
index 992566358..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestEventHandler.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.listener.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-
-import org.apache.commons.lang3.StringUtils;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.onap.appc.listener.EventHandler;
-import org.onap.appc.listener.ListenerProperties;
-import org.onap.appc.listener.impl.EventHandlerImpl;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-/**
- * Test the ProviderAdapter implementation.
- *
- */
-
-public class TestEventHandler {
-
- private ListenerProperties prop;
-
- private EventHandler adapter;
-
- private static final String PROP_FILE = "/org/onap/appc/default.properties";
-
- private static final String MESSAGE_FILE = "/DCAEResponse.txt";
-
- /**
- * Setup the test environment.
- *
- * @throws NoSuchMethodException
- * @throws SecurityException
- * @throws NoSuchFieldException
- */
- @Before
- public void setup() {
- Properties allProps = new Properties();
- try {
- allProps.load(getClass().getResourceAsStream(PROP_FILE));
- allProps.remove("appc.ClosedLoop.topic.read.filter");
- prop = new ListenerProperties("appc.ClosedLoop", allProps);
- } catch (IOException e) {
- System.out.println("WARNING: Failed to load properties file: " + PROP_FILE);
- }
- adapter = new EventHandlerImpl(prop);
- }
-
- @Test
- public void testInitialProperties() {
- assertEquals(prop.getProperty("topic.read"), adapter.getReadTopic());
- assertTrue(adapter.getWriteTopics().contains(prop.getProperty("topic.write")));
- assertEquals(prop.getProperty("client.name"), adapter.getClientName());
- assertEquals(prop.getProperty("client.name.id"), adapter.getClientId());
-
- String hostStr = prop.getProperty("poolMembers");
- int hostCount = hostStr.length()>0 ? hostStr.split(",").length : 0;
- assertEquals(hostCount, adapter.getPool().size());
- }
-
- @Test
- public void testGettersAndSetters() {
- String readTopic = "read";
- Set<String> writeTopic = new HashSet<String>();
- writeTopic.add("write");
- String clientName = "APPC-TEST";
- String clientId = "00";
- String newHost = "google.com";
-
- adapter.setReadTopic(readTopic);
- assertEquals(readTopic, adapter.getReadTopic());
-
- adapter.setWriteTopics(writeTopic);
- assertEquals(writeTopic, adapter.getWriteTopics());
-
- adapter.setClientName(clientName);
- assertEquals(clientName, adapter.getClientName());
-
- adapter.setClientId(clientId);
- assertEquals(clientId, adapter.getClientId());
-
- adapter.setCredentials("fake", "secret");
- adapter.clearCredentials();
-
- int oldSize = adapter.getPool().size();
- adapter.addToPool(newHost);
- assertEquals(oldSize + 1, adapter.getPool().size());
- assertTrue(adapter.getPool().contains(newHost));
-
- adapter.removeFromPool(newHost);
- assertEquals(oldSize, adapter.getPool().size());
- assertFalse(adapter.getPool().contains(newHost));
-
- }
-
-// @Test
- public void testRun() {
- // Runoff any old data
- List<String> result1 = adapter.getIncomingEvents();
- assertNotNull(result1);
-
- // Post new data
- DummyObj data = new DummyObj();
- data.key = "value";
- adapter.postStatus(data.toJson());
-
- // Wait to account for network delay
- sleep(2000);
-
- // Get data back
- List<DummyObj> result2 = adapter.getIncomingEvents(DummyObj.class);
- assertNotNull(result2);
-// assertEquals(1, result2.size());
- assertEquals(data.toJson(), result2.get(0).toJson());
- }
-
- @JsonSerialize
- public static class DummyObj implements Serializable {
- @JsonProperty("request") // Call request for default filter
- public String key;
-
- public DummyObj() {
- }
-
- public String toJson() {
- return String.format("{\"request\": \"%s\"}", key);
- }
- }
-
- private void sleep(long ms) {
- try {
- Thread.sleep(ms);
- } catch (Exception e) {
- return;
- }
- }
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestListener.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestListener.java
deleted file mode 100644
index 67ad9bf1d..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestListener.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.listener.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.util.Properties;
-
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.onap.appc.listener.Listener;
-import org.onap.appc.listener.ListenerProperties;
-import org.onap.appc.listener.demo.impl.ListenerImpl;
-
-@Ignore
-public class TestListener {
-
- private static final String PROP_FILE = "/org/onap/appc/default.properties";
-
- private Listener listener;
-
- private Properties props;
-
- @Before
- public void setup() {
- props = new Properties();
- try {
- props.load(getClass().getResourceAsStream(PROP_FILE));
- props.setProperty("topic.read", "DCAE-CLOSED-LOOP-EVENTS-DEV1510SIM");
- } catch (Exception e) {
- e.printStackTrace();
- fail("Failed to setup test: " + e.getMessage());
- }
- listener = new ListenerImpl(new ListenerProperties("appc.ClosedLoop", props));
- }
-
- @Test
- public void testListenerId() {
- String originalId = listener.getListenerId();
- String newId = originalId + "-new";
-
- listener.setListenerId(newId);
- assertEquals(newId, listener.getListenerId());
- }
-
- @Test
- public void testRun() {
- try {
- Thread t = new Thread(listener);
- t.start();
-
- Thread.sleep(5000);
-
- listener.stopNow();
-
- System.out.println(listener.getBenchmark());
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void testUpdateProperties() {
-
- }
-
- @Test
- public void printSampleData() {
- try {
- props.setProperty("threads.queuesize.min", "1");
- props.setProperty("threads.queuesize.max", "1");
- props.setProperty("threads.poolsize.min", "1");
- props.setProperty("threads.poolsize.max", "1");
-
- Thread t = new Thread(listener);
- t.start();
-
- Thread.sleep(2000);
-
- listener.stop();
-
- System.out.println(listener.getBenchmark());
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/util/TestMapper.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/util/TestMapper.java
deleted file mode 100644
index de726194f..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/util/TestMapper.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.listener.util;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.json.JSONObject;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.appc.listener.util.Mapper;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-public class TestMapper {
-
- private String dummyJson = "{\"a\":\"%s\"}";
- private DummyObj dummyObj = new DummyObj();
-
- @JsonSerialize
- public static class DummyObj implements Serializable {
- @JsonProperty("a")
- public String a;
-
- public DummyObj() {
- }
- }
-
- @Before
- public void setup() {
- }
-
- @Test
- public void testGetMapper() {
- assertNotNull(Mapper.getMapper());
- }
-
- @Test
- public void testToJsonObject() {
- JSONObject out;
- out = Mapper.toJsonObject(".");
- assertNull(out);
-
- String value = "b";
- out = Mapper.toJsonObject(String.format(dummyJson, value));
- assertNotNull(out);
- assertEquals(value, out.get("a"));
- }
-
- @Test
- public void testConstructor() {
- // Only here for code coverage
- Mapper m = new Mapper();
- assertNotNull(m);
- }
-
- @Test
- public void testMap() {
- List<String> in = new ArrayList<String>();
- in.add("");
- in.add(null);
-
- List<DummyObj> out = Mapper.mapList(in, DummyObj.class);
- assertNotNull(out);
- assertTrue(out.isEmpty());
-
- in.add(String.format(dummyJson, "1"));
- in.add("{\"invalid\":\"yes\"}");
- in.add(String.format(dummyJson, "2"));
-
- out = Mapper.mapList(in, DummyObj.class);
- assertNotNull(out);
- assertEquals(2, out.size());
- assertEquals("1", out.get(0).a);
- assertEquals("2", out.get(1).a);
- }
-
-}