aboutsummaryrefslogtreecommitdiffstats
path: root/appc-client/client-lib/src/test
diff options
context:
space:
mode:
authorSkip Wonnell <kw5258@att.com>2017-08-29 22:39:17 -0500
committerMarcus Williams <marcus.williams@intel.com>2017-08-30 15:36:41 +0000
commitabe9420ac5220879d4790f9020c583cb037dd577 (patch)
tree178e8b7b0cdaa6317064add7e5e29299459188c5 /appc-client/client-lib/src/test
parent8c9631e438b9491424df0f43d43445f098436834 (diff)
Initial add of APPC client libraries
Issue-ID: APPC-180 Change-Id: Ie0be2b518b90bb7f9996e9260c43fef75d1a5821 Signed-off-by: Skip Wonnell <kw5258@att.com>
Diffstat (limited to 'appc-client/client-lib/src/test')
-rw-r--r--appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/core/ResponseManagerTest.java163
-rw-r--r--appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/core/SyncFlowTest.java151
-rw-r--r--appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/protocol/APPCMessageReaderWriterTest.java104
-rw-r--r--appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/protocol/TestAsyncProtocolImpl.java91
-rw-r--r--appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/protocol/TestAsyncProtocolImplMissingProps.java75
-rw-r--r--appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/protocol/TestAsyncProtocolImplNullCallback.java60
-rw-r--r--appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/protocol/TestUEBMessagingService.java70
-rw-r--r--appc-client/client-lib/src/test/resources/ueb.missing.properties30
-rw-r--r--appc-client/client-lib/src/test/resources/ueb.properties29
9 files changed, 773 insertions, 0 deletions
diff --git a/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/core/ResponseManagerTest.java b/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/core/ResponseManagerTest.java
new file mode 100644
index 000000000..d1720f03b
--- /dev/null
+++ b/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/core/ResponseManagerTest.java
@@ -0,0 +1,163 @@
+/*-
+ * ============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.openecomp.appc.client.impl.core;
+
+import org.openecomp.appc.client.impl.core.AsyncRequestResponseHandler;
+import org.openecomp.appc.client.impl.core.CoreException;
+import org.openecomp.appc.client.impl.core.CoreManager;
+import org.openecomp.appc.client.impl.core.ICoreAsyncResponseHandler;
+import org.openecomp.appc.client.impl.core.MessageContext;
+import org.openecomp.appc.client.impl.protocol.AsyncProtocol;
+import org.openecomp.appc.client.impl.protocol.ProtocolException;
+import org.openecomp.appc.client.impl.protocol.RetrieveMessageCallback;
+import org.junit.Before;
+
+import java.util.Properties;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import static org.mockito.Mockito.mock;
+
+public class ResponseManagerTest {
+
+ private final ExecutorService executorService = Executors.newFixedThreadPool(10);
+ ICoreAsyncResponseHandler listener1 = new ListenerImpl();
+ ICoreAsyncResponseHandler listener2 = new SleeepListenerImpl();
+ ICoreAsyncResponseHandler listener3 = new ListenerImpl();
+ CoreManager coreManager = null;
+
+ public void initialize() throws CoreException {
+ Properties prop = new Properties();
+ prop.setProperty("client.pool.size", "10");
+ prop.setProperty("client.response.timeout", "7000");
+ coreManager = new ResponseManagerTest.CoreManagerTest(prop);
+ }
+
+ void asyncRequest(String request, ICoreAsyncResponseHandler businessCallback, String correlationId, String rpcName) throws CoreException {
+ AsyncRequestResponseHandler requestResponseHandler = new AsyncRequestResponseHandler(correlationId, businessCallback, coreManager);
+ requestResponseHandler.sendRequest(request, correlationId, rpcName);
+ }
+
+ public void simpleResponseTest() throws Exception {
+ System.out.println("simpleResponseTest");
+ asyncRequest("request 1", listener1,"vasia1", "test");
+ MessageContext msgCtx = new MessageContext();
+ msgCtx.setCorrelationID("vasia1");
+ msgCtx.setType("response");
+ coreManager.getProtocolCallback().onResponse("vasia1 response",msgCtx);
+ coreManager.getProtocolCallback().onResponse("vasia2 response",msgCtx);
+ Thread.sleep(10);
+ }
+
+ public void twoResponseTest() throws Exception {
+ System.out.println("twoResponseTest");
+ asyncRequest("twoResponseTest request 1", listener2,"vasia2", "test");
+ MessageContext msgCtx = new MessageContext();
+ msgCtx.setCorrelationID("vasia2");
+ msgCtx.setType("response");
+ coreManager.getProtocolCallback().onResponse("second of vasia2",msgCtx);
+ Thread.sleep(100);
+ asyncRequest("twoResponseTest request 2", listener1,"vasia1", "test");
+ MessageContext msgCtx2 = new MessageContext();
+ msgCtx2.setCorrelationID("vasia1");
+ msgCtx2.setType("response");
+ coreManager.getProtocolCallback().onResponse("first of vasia1",msgCtx2);
+ Thread.sleep(150);
+ }
+
+ public void threeResponseTest() throws Exception {
+ System.out.println("treeResponseTest");
+ asyncRequest("threeResponseTest request 2", listener1,"vasia4", "test");
+ asyncRequest("threeResponseTest request 1", listener2,"vasia2", "test");
+ MessageContext msgCtx2 = new MessageContext();
+ msgCtx2.setCorrelationID("vasia2");
+ msgCtx2.setType("response");
+ coreManager.getProtocolCallback().onResponse("second of vasia2",msgCtx2);
+
+ asyncRequest("threeResponseTest request 2", listener1,"vasia1", "test");
+ MessageContext msgCtx1 = new MessageContext();
+ msgCtx1.setCorrelationID("vasia1");
+ msgCtx1.setType("response");
+ coreManager.getProtocolCallback().onResponse("vasia1",msgCtx1);
+
+ asyncRequest("threeResponseTest request 3", listener3,"vasia3", "test");
+ MessageContext msgCtx3 = new MessageContext();
+ msgCtx3.setCorrelationID("vasia3");
+ msgCtx3.setType("response");
+ coreManager.getProtocolCallback().onResponse("three1",msgCtx3);
+
+ coreManager.getProtocolCallback().onResponse("three2", msgCtx3);
+
+ coreManager.getProtocolCallback().onResponse("first1", msgCtx1);
+ Thread.sleep(250);
+
+ coreManager.getProtocolCallback().onResponse("first2", msgCtx1);
+ Thread.sleep(10000);
+ }
+
+ private class ListenerImpl implements ICoreAsyncResponseHandler{
+
+ public boolean onResponse(String message, String type) {
+ System.out.println("callback " + message);
+ return message != null;
+ }
+
+ @Override
+ public void onException(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private class SleeepListenerImpl implements ICoreAsyncResponseHandler{
+
+ public boolean onResponse(String message, String type) {
+ try {
+ Thread.sleep(150);
+ System.out.println("sleep callback " + message);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return message != null;
+ }
+
+ @Override
+ public void onException(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ class CoreManagerTest extends CoreManager{
+ CoreManagerTest(Properties properties) throws CoreException {
+ super(properties);
+ protocol = mock(AsyncProtocol.class);
+ }
+ protected void sendRequest2Protocol(String request, String corrId, String rpcName) throws CoreException {
+ }
+
+ protected void initProtocol(Properties properties, RetrieveMessageCallback protocolCallback) throws ProtocolException {
+
+ }
+ }
+}
diff --git a/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/core/SyncFlowTest.java b/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/core/SyncFlowTest.java
new file mode 100644
index 000000000..4b4bce578
--- /dev/null
+++ b/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/core/SyncFlowTest.java
@@ -0,0 +1,151 @@
+/*-
+ * ============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.openecomp.appc.client.impl.core;
+
+import org.openecomp.appc.client.impl.core.CoreException;
+import org.openecomp.appc.client.impl.core.CoreManager;
+import org.openecomp.appc.client.impl.core.ICoreSyncResponseHandler;
+import org.openecomp.appc.client.impl.core.MessageContext;
+import org.openecomp.appc.client.impl.core.SyncRequestResponseHandler;
+import org.openecomp.appc.client.impl.protocol.AsyncProtocol;
+import org.openecomp.appc.client.impl.protocol.ProtocolException;
+import org.openecomp.appc.client.impl.protocol.RetrieveMessageCallback;
+import org.junit.Assert;
+import org.junit.Before;
+
+import java.util.Properties;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeoutException;
+
+import static org.mockito.Mockito.mock;
+
+public class SyncFlowTest {
+ CoreManager coreManager = null;
+
+ public void initialize() throws CoreException {
+ Properties prop = new Properties();
+ prop.setProperty("client.pool.size", "10");
+ prop.setProperty("client.response.timeout", "7000");
+ coreManager = new CoreManagerTest(prop);
+ }
+
+ <T> T syncRequest(String request, ICoreSyncResponseHandler businessCallback, String correlationId, String rpcName ) throws CoreException, TimeoutException {
+ SyncRequestResponseHandler requestResponseHandler = new SyncRequestResponseHandler(correlationId, businessCallback, coreManager);
+ requestResponseHandler.sendRequest(request, correlationId, rpcName);
+ T responseObject = (T) requestResponseHandler.getResponse();
+ return responseObject;
+ }
+
+ public void blockRequestTest(){
+ ICoreSyncResponseHandler handler = new ICoreSyncResponseHandlerImpl1();
+ try {
+ syncRequest("request 1", handler, "vasia1", "test");
+ }catch (Throwable e){
+ e.printStackTrace();
+ Assert.assertTrue(e != null);
+ }
+
+ }
+
+ public <T> void blockRequestSucceedTest() throws InterruptedException {
+ ExecutorService executorService = Executors.newFixedThreadPool(2);
+ final ICoreSyncResponseHandler handler = new ICoreSyncResponseHandlerImpl1();
+ try {
+ executorService.submit(new Runnable() {
+ public void run() {
+ System.out.println("Send request");
+ T response;
+ try {
+ response = syncRequest("request 1", handler, "vasia1", "test");
+ System.out.println("=======" + response.toString());
+ } catch (CoreException e) {
+ e.printStackTrace();
+ } catch (TimeoutException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }catch (Throwable e){
+ Assert.assertTrue((RuntimeException)e != null);
+ }
+ Thread.sleep(2000);
+ executorService.submit(new Runnable() {
+ public void run() {
+ MessageContext ctx = new MessageContext();
+ ctx.setCorrelationID("vasia1");
+ ctx.setType("response");
+ try {
+ System.out.println("Send response 1");
+ coreManager.getProtocolCallback().onResponse("response for request 1", ctx);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+
+ Thread.sleep(2000);
+ executorService.submit(new Runnable() {
+ public void run() {
+ MessageContext ctx = new MessageContext();
+ ctx.setCorrelationID("vasia1");
+ ctx.setType("response");
+ try {
+ System.out.println("Send response 2");
+ coreManager.getProtocolCallback().onResponse("response for request 1 final", ctx);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ Thread.sleep(1000);
+
+ }
+
+ class ICoreSyncResponseHandlerImpl1 implements ICoreSyncResponseHandler{
+
+
+ public <T> T onResponse(String message, String type) {
+ System.out.println("Received message = " + message) ;
+ if(message.contains("final")){
+ return (T) new String(message);
+ }
+ return null;
+ }
+ }
+
+ class CoreManagerTest extends CoreManager{
+ CoreManagerTest(Properties properties) throws CoreException {
+ super(properties);
+ protocol = mock(AsyncProtocol.class);
+ }
+ protected void sendRequest2Protocol(String request, String corrId, String rpcName) throws CoreException {
+ }
+
+ protected void initProtocol(Properties properties, RetrieveMessageCallback protocolCallback) throws ProtocolException{
+
+ }
+ }
+}
diff --git a/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/protocol/APPCMessageReaderWriterTest.java b/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/protocol/APPCMessageReaderWriterTest.java
new file mode 100644
index 000000000..91f615720
--- /dev/null
+++ b/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/protocol/APPCMessageReaderWriterTest.java
@@ -0,0 +1,104 @@
+/*-
+ * ============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.openecomp.appc.client.impl.protocol;
+
+import org.openecomp.appc.client.impl.core.MessageContext;
+import org.openecomp.appc.client.impl.protocol.APPCMessageReaderWriter;
+import org.openecomp.appc.client.impl.protocol.ProtocolException;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.io.StringWriter;
+
+public class APPCMessageReaderWriterTest {
+
+ private APPCMessageReaderWriter messageReaderWriter;
+ private ObjectMapper mapper;
+
+ private static final String VERSION = "2.0";
+ private static final String TYPE = "typeTest";
+ private static final String CORRELATION_ID = "correlationIdTest";
+ private static final String PARTITION = "partitionTest";
+ private static final String RPC = "rpcTest";
+ private static final String PAYLOAD = "{\"key1\":\"val1\",\"key2\":\"val2\",\"key3\":{\"key3.1\":\"val3.1\"}}";
+
+ @Before
+ public void init() throws IOException {
+ mapper = new ObjectMapper();
+ messageReaderWriter = new APPCMessageReaderWriter();
+ }
+
+ @Test
+ public void writeTest() throws IOException, ProtocolException {
+ MessageContext context = new MessageContext();
+ context.setType(TYPE);
+ context.setCorrelationID(CORRELATION_ID);
+ context.setPartiton(PARTITION);
+ context.setRpc(RPC);
+ String payload = PAYLOAD;
+ String message = messageReaderWriter.write(payload, context);
+
+ JsonNode messageJson = mapper.readTree(message);
+ Assert.assertEquals(VERSION, messageJson.get("version").asText());
+ Assert.assertEquals(context.getType(), messageJson.get("type").asText());
+ Assert.assertEquals(context.getCorrelationID(), messageJson.get("correlation-id").asText());
+ Assert.assertEquals(context.getPartiton(), messageJson.get("cambria.partition").asText());
+ Assert.assertEquals(context.getRpc(), messageJson.get("rpc-name").asText());
+ Assert.assertEquals(payload, messageJson.get("body").toString());
+ }
+
+ @Test
+ public void readTest() throws IOException, ProtocolException {
+ ObjectNode node = mapper.createObjectNode();
+ node.put("version", VERSION);
+ node.put("type", TYPE);
+ node.put("correlation-id", CORRELATION_ID);
+ node.put("cambria.partition", PARTITION);
+ node.put("rpc-name", RPC);
+ JsonNode payload = mapper.valueToTree(PAYLOAD);
+ node.set("body", payload);
+ String message = node.toString();
+
+ MessageContext returnContext = new MessageContext();
+ String returnPayload = messageReaderWriter.read(message, returnContext);
+
+ Assert.assertEquals(TYPE, returnContext.getType());
+ Assert.assertEquals(CORRELATION_ID, returnContext.getCorrelationID());
+ Assert.assertEquals(PARTITION, returnContext.getPartiton());
+ Assert.assertEquals(RPC, returnContext.getRpc());
+ Assert.assertEquals(payload.toString(), returnPayload);
+ }
+
+}
diff --git a/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/protocol/TestAsyncProtocolImpl.java b/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/protocol/TestAsyncProtocolImpl.java
new file mode 100644
index 000000000..046f5a814
--- /dev/null
+++ b/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/protocol/TestAsyncProtocolImpl.java
@@ -0,0 +1,91 @@
+/*-
+ * ============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.openecomp.appc.client.impl.protocol;
+
+import org.openecomp.appc.client.impl.core.MessageContext;
+import org.openecomp.appc.client.impl.protocol.AsyncProtocol;
+import org.openecomp.appc.client.impl.protocol.AsyncProtocolImpl;
+import org.openecomp.appc.client.impl.protocol.ProtocolException;
+import org.openecomp.appc.client.impl.protocol.RetrieveMessageCallback;
+import org.openecomp.appc.client.impl.protocol.UEBPropertiesKeys;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+public class TestAsyncProtocolImpl {
+
+ private static AsyncProtocol protocol;
+ private static AtomicBoolean gotResponse;
+ private static Properties props;
+
+ private static class TestCallback implements RetrieveMessageCallback{
+
+ public void onResponse(String payload, MessageContext context) {
+ Assert.assertNotEquals(null, payload);
+ Assert.assertNotEquals(null, context);
+ protocol = null;
+ gotResponse.set(true);
+ }
+ }
+
+ @BeforeClass
+ public static void setUp() throws IOException, ProtocolException {
+
+ gotResponse = new AtomicBoolean(false);
+
+ props = new Properties();
+ String propFileName = "ueb.properties";
+
+ InputStream input = TestAsyncProtocolImpl.class.getClassLoader().getResourceAsStream(propFileName);
+
+ props.load(input);
+
+ protocol = new AsyncProtocolImpl();
+ protocol.init(props, new TestCallback());
+ }
+
+ public void testSendRequest() throws ProtocolException {
+
+ MessageContext context = new MessageContext();
+ context.setType("Test");
+
+ protocol.sendRequest("{\"Test\":\"\"}", context);
+
+ try {
+ Long timeToSleep = Long.parseLong((String)props.get(UEBPropertiesKeys.TOPIC_READ_TIMEOUT))*2;
+ Thread.sleep(timeToSleep);
+ } catch (InterruptedException e) {
+ Assert.assertFalse(e.getMessage(), false);
+ }
+ if (gotResponse.get() == false) {
+ Assert.assertFalse("Message was not read !", true);
+ }
+ }
+}
diff --git a/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/protocol/TestAsyncProtocolImplMissingProps.java b/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/protocol/TestAsyncProtocolImplMissingProps.java
new file mode 100644
index 000000000..9611a7900
--- /dev/null
+++ b/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/protocol/TestAsyncProtocolImplMissingProps.java
@@ -0,0 +1,75 @@
+/*-
+ * ============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.openecomp.appc.client.impl.protocol;
+
+import org.openecomp.appc.client.impl.core.MessageContext;
+import org.openecomp.appc.client.impl.protocol.AsyncProtocol;
+import org.openecomp.appc.client.impl.protocol.AsyncProtocolImpl;
+import org.openecomp.appc.client.impl.protocol.RetrieveMessageCallback;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+public class TestAsyncProtocolImplMissingProps {
+
+ private static AsyncProtocol protocol;
+
+ private static class TestCallback implements RetrieveMessageCallback {
+
+ public void onResponse(String payload, MessageContext context) {
+ Assert.assertFalse("bad Callback !",false);
+ }
+ }
+
+ @Test
+ /**
+ * protocol should throw illegal argument exception due to null properties
+ */
+ public void testSetUpMissingProps() {
+
+ Properties props = new Properties();
+ String propFileName = "ueb.missing.properties";
+
+ InputStream input = TestAsyncProtocolImplMissingProps.class.getClassLoader().getResourceAsStream(propFileName);
+
+ try {
+ props.load(input);
+ } catch (IOException e) {
+ Assert.assertFalse(e.getMessage(),false);
+ }
+
+ protocol = new AsyncProtocolImpl();
+ try {
+ protocol.init(props, new TestCallback());
+ } catch (IllegalArgumentException e) {
+ Assert.assertTrue(true);
+ } catch (Exception e) {
+ Assert.assertFalse(e.getMessage(),false);
+ }
+ }
+}
diff --git a/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/protocol/TestAsyncProtocolImplNullCallback.java b/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/protocol/TestAsyncProtocolImplNullCallback.java
new file mode 100644
index 000000000..e537037f7
--- /dev/null
+++ b/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/protocol/TestAsyncProtocolImplNullCallback.java
@@ -0,0 +1,60 @@
+/*-
+ * ============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.openecomp.appc.client.impl.protocol;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openecomp.appc.client.impl.protocol.AsyncProtocol;
+import org.openecomp.appc.client.impl.protocol.AsyncProtocolImpl;
+import org.openecomp.appc.client.impl.protocol.ProtocolException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+public class TestAsyncProtocolImplNullCallback {
+
+ private static AsyncProtocol protocol;
+
+ public void testSetUpNoCallback() throws IOException {
+
+ Properties props = new Properties();
+ String propFileName = "ueb.properties";
+
+ InputStream input = TestAsyncProtocolImpl.class.getClassLoader().getResourceAsStream(propFileName);
+
+ props.load(input);
+
+ protocol = new AsyncProtocolImpl();
+
+ try {
+ protocol.init(props, null);
+ } catch (ProtocolException e) {
+ Assert.assertTrue(true);
+ } catch (Exception e){
+ Assert.assertFalse(e.getMessage(),false);
+ }
+ }
+}
diff --git a/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/protocol/TestUEBMessagingService.java b/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/protocol/TestUEBMessagingService.java
new file mode 100644
index 000000000..109065ab4
--- /dev/null
+++ b/appc-client/client-lib/src/test/java/org/openecomp/appc/client/impl/protocol/TestUEBMessagingService.java
@@ -0,0 +1,70 @@
+/*-
+ * ============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.openecomp.appc.client.impl.protocol;
+
+import org.junit.*;
+import org.junit.runners.MethodSorters;
+import org.openecomp.appc.client.impl.protocol.MessagingService;
+import org.openecomp.appc.client.impl.protocol.UEBMessagingService;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.GeneralSecurityException;
+import java.util.List;
+import java.util.Properties;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestUEBMessagingService {
+
+ private static MessagingService ueb;
+
+ public static void setUp() throws IOException, GeneralSecurityException, NoSuchFieldException, IllegalAccessException {
+
+ Properties props = new Properties();
+ String propFileName = "ueb.properties";
+
+ InputStream input = TestUEBMessagingService.class.getClassLoader().getResourceAsStream(propFileName);
+
+ props.load(input);
+
+ ueb = new UEBMessagingService();
+ ueb.init(props);
+ }
+
+ public void test1Send() throws IOException {
+ System.out.println("Here");
+
+ String message = "Test Message Service";
+ ueb.send(null,message);
+ }
+
+ public void test2Fetch() throws IOException {
+
+ System.out.println("Here2");
+ List<String> messages = ueb.fetch(1);
+ Assert.assertEquals(1,messages.size());
+ }
+
+}
diff --git a/appc-client/client-lib/src/test/resources/ueb.missing.properties b/appc-client/client-lib/src/test/resources/ueb.missing.properties
new file mode 100644
index 000000000..54ba58284
--- /dev/null
+++ b/appc-client/client-lib/src/test/resources/ueb.missing.properties
@@ -0,0 +1,30 @@
+###
+# ============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=========================================================
+###
+
+topic.read=APPC-UNIT-TEST
+topic.read.timeout=60000
+topic.write=APPC-UNIT-TEST
+client.name=APPC-CLIENT
+client.id=0
+
diff --git a/appc-client/client-lib/src/test/resources/ueb.properties b/appc-client/client-lib/src/test/resources/ueb.properties
new file mode 100644
index 000000000..026d5f4e8
--- /dev/null
+++ b/appc-client/client-lib/src/test/resources/ueb.properties
@@ -0,0 +1,29 @@
+###
+# ============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=========================================================
+###
+
+poolMembers=10.147.29.67:3904
+topic.read=APPC-TEST1
+topic.read.timeout=2500
+topic.write=APPC-TEST1
+