aboutsummaryrefslogtreecommitdiffstats
path: root/services/appc-dmaap-service/appc-message-adapter-factory
diff options
context:
space:
mode:
Diffstat (limited to 'services/appc-dmaap-service/appc-message-adapter-factory')
-rw-r--r--services/appc-dmaap-service/appc-message-adapter-factory/.gitignore1
-rw-r--r--services/appc-dmaap-service/appc-message-adapter-factory/pom.xml79
-rw-r--r--services/appc-dmaap-service/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java59
-rw-r--r--services/appc-dmaap-service/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/MessageService.java58
-rw-r--r--services/appc-dmaap-service/appc-message-adapter-factory/src/main/resources/org/onap/appc/default.properties25
-rw-r--r--services/appc-dmaap-service/appc-message-adapter-factory/src/test/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImplTest.java58
-rw-r--r--services/appc-dmaap-service/appc-message-adapter-factory/src/test/java/org/onap/appc/adapter/factory/MessageServiceTest.java49
7 files changed, 329 insertions, 0 deletions
diff --git a/services/appc-dmaap-service/appc-message-adapter-factory/.gitignore b/services/appc-dmaap-service/appc-message-adapter-factory/.gitignore
new file mode 100644
index 000000000..eacf31a67
--- /dev/null
+++ b/services/appc-dmaap-service/appc-message-adapter-factory/.gitignore
@@ -0,0 +1 @@
+/target-ide/
diff --git a/services/appc-dmaap-service/appc-message-adapter-factory/pom.xml b/services/appc-dmaap-service/appc-message-adapter-factory/pom.xml
new file mode 100644
index 000000000..f234c92dd
--- /dev/null
+++ b/services/appc-dmaap-service/appc-message-adapter-factory/pom.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ONAP : APPC
+ ================================================================================
+ Copyright (C) 2017-2019 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.
+ ============LICENSE_END=========================================================
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.appc.parent</groupId>
+ <artifactId>binding-parent</artifactId>
+ <version>2.6.2</version>
+ <relativePath />
+ </parent>
+
+ <groupId>org.onap.appc.services.dmaap</groupId>
+ <artifactId>appc-message-adapter-factory</artifactId>
+ <packaging>jar</packaging>
+ <name>appc-message-adapter-factory</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.onap.appc.services.dmaap</groupId>
+ <artifactId>appc-dmaap-adapter-bundle</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onap.appc.services.dmaap</groupId>
+ <artifactId>appc-message-adapter-api</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <version>1.7.0-SNAPSHOT</version>
+</project>
diff --git a/services/appc-dmaap-service/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java b/services/appc-dmaap-service/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java
new file mode 100644
index 000000000..d182f4769
--- /dev/null
+++ b/services/appc-dmaap-service/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.adapter.factory;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.onap.appc.adapter.message.Consumer;
+import org.onap.appc.adapter.message.MessageAdapterFactory;
+import org.onap.appc.adapter.message.Producer;
+import org.onap.appc.adapter.messaging.dmaap.http.HttpDmaapConsumerImpl;
+import org.onap.appc.adapter.messaging.dmaap.http.HttpDmaapProducerImpl;
+
+public class DmaapMessageAdapterFactoryImpl implements MessageAdapterFactory {
+
+
+ @Override
+ public Producer createProducer(Collection<String> pools, String writeTopic, String apiKey, String apiSecret) {
+ return new HttpDmaapProducerImpl(pools, writeTopic);
+ }
+
+ @Override
+ public Producer createProducer(Collection<String> pools, Set<String> writeTopics, String apiKey, String apiSecret) {
+ String topic = "";
+ for(String s : writeTopics){
+ topic = s;
+ }
+ return new HttpDmaapProducerImpl(pools, topic);
+ }
+
+ @Override
+ public Consumer createConsumer(Collection<String> pool, String readTopic,
+ String clientName, String clientId, String filterJson, String apiKey, String apiSecret) {
+ return new HttpDmaapConsumerImpl(pool, readTopic, clientName, clientId, apiKey, apiSecret, filterJson);
+ }
+}
diff --git a/services/appc-dmaap-service/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/MessageService.java b/services/appc-dmaap-service/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/MessageService.java
new file mode 100644
index 000000000..f7c51be29
--- /dev/null
+++ b/services/appc-dmaap-service/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/MessageService.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.adapter.factory;
+/**
+ * The message service types that are available. Only DMaaP available
+ **/
+public enum MessageService {
+ DMaaP("dmaap");
+
+ private String val;
+
+ private MessageService(String val) {
+ this.val = val;
+ }
+
+ public String getValue() {
+ return val;
+ }
+
+ /**
+ * Tries to match a string to a MessageService. If no match is found, returns the default (DMaaP)
+ *
+ * @param input
+ * the string to try and match
+ * @return A MessasgeService
+ */
+ public static MessageService parse(String input) {
+ if (input != null) {
+ for (MessageService ms : MessageService.values()) {
+ if (input.equalsIgnoreCase(ms.getValue())) {
+ return ms;
+ }
+ }
+ }
+ return MessageService.DMaaP; // Default
+ }
+}
diff --git a/services/appc-dmaap-service/appc-message-adapter-factory/src/main/resources/org/onap/appc/default.properties b/services/appc-dmaap-service/appc-message-adapter-factory/src/main/resources/org/onap/appc/default.properties
new file mode 100644
index 000000000..da25a66a4
--- /dev/null
+++ b/services/appc-dmaap-service/appc-message-adapter-factory/src/main/resources/org/onap/appc/default.properties
@@ -0,0 +1,25 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP : APPC
+# ================================================================================
+# Copyright (C) 2017-2018 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.
+#
+# ============LICENSE_END=========================================================
+###
+
+org.onap.appc.bootstrap.file=appc.properties
+org.onap.appc.bootstrap.path=/opt/onap/appc/data/properties,${user.home},.
diff --git a/services/appc-dmaap-service/appc-message-adapter-factory/src/test/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImplTest.java b/services/appc-dmaap-service/appc-message-adapter-factory/src/test/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImplTest.java
new file mode 100644
index 000000000..bfc469d7b
--- /dev/null
+++ b/services/appc-dmaap-service/appc-message-adapter-factory/src/test/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImplTest.java
@@ -0,0 +1,58 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2019 Ericsson
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.adapter.factory;
+
+import static org.junit.Assert.assertTrue;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.appc.adapter.message.Consumer;
+import org.onap.appc.adapter.message.Producer;
+
+public class DmaapMessageAdapterFactoryImplTest {
+
+ private DmaapMessageAdapterFactoryImpl factory;
+ private Collection<String> pools;
+
+ @Before
+ public void setup() {
+ factory = new DmaapMessageAdapterFactoryImpl();
+ pools = new ArrayList<>();
+ pools.add("http://server:1");
+ }
+
+ @Test
+ public void testCreateProducer() {
+ Set<String> writeTopics = new HashSet<>();
+ assertTrue(factory.createProducer(pools, writeTopics, null, null) instanceof Producer);
+ assertTrue(factory.createProducer(pools, "TEST" , null, null) instanceof Producer);
+ }
+
+ @Test
+ public void testCreateConsumer() {
+ assertTrue(factory.createConsumer(pools, "TEST", null, null, null, null, null) instanceof Consumer);
+ }
+
+}
diff --git a/services/appc-dmaap-service/appc-message-adapter-factory/src/test/java/org/onap/appc/adapter/factory/MessageServiceTest.java b/services/appc-dmaap-service/appc-message-adapter-factory/src/test/java/org/onap/appc/adapter/factory/MessageServiceTest.java
new file mode 100644
index 000000000..47fa1f6f3
--- /dev/null
+++ b/services/appc-dmaap-service/appc-message-adapter-factory/src/test/java/org/onap/appc/adapter/factory/MessageServiceTest.java
@@ -0,0 +1,49 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : APPC
+* ================================================================================
+* Copyright 2018 TechMahindra
+*=================================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ============LICENSE_END=========================================================
+*/
+package org.onap.appc.adapter.factory;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MessageServiceTest {
+
+ private MessageService messageService = MessageService.DMaaP;
+
+ @Test
+ public void testName() {
+ Assert.assertEquals("DMaaP", messageService.name());
+ }
+
+ @Test
+ public void testGetValue() {
+ Assert.assertEquals("dmaap", messageService.getValue());
+ }
+
+ @Test
+ public void testParse() {
+ Assert.assertEquals(messageService, MessageService.parse("DMAAP"));
+ }
+
+ @Test
+ public void testParse_Null() {
+ Assert.assertEquals(MessageService.DMaaP, MessageService.parse(null));
+ }
+
+}