aboutsummaryrefslogtreecommitdiffstats
path: root/appc-adapters/appc-dmaap-adapter
diff options
context:
space:
mode:
Diffstat (limited to 'appc-adapters/appc-dmaap-adapter')
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryActivator.java26
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java6
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/test/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryActivatorTest.java49
3 files changed, 67 insertions, 14 deletions
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryActivator.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryActivator.java
index 1f929fba1..fc0ded1a0 100644
--- a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryActivator.java
+++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryActivator.java
@@ -5,6 +5,8 @@
* 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.
@@ -28,19 +30,19 @@ import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
public class DmaapMessageAdapterFactoryActivator implements BundleActivator {
- private ServiceRegistration registration;
+ private ServiceRegistration registration;
- @Override
- public void start(BundleContext context) throws Exception {
- registration = context.registerService(
- MessageAdapterFactory.class.getName(),
- new DmaapMessageAdapterFactoryImpl(),
- null);
- }
+ @Override
+ public void start(BundleContext context) throws Exception {
+ registration = context.registerService(
+ MessageAdapterFactory.class.getName(),
+ new DmaapMessageAdapterFactoryImpl(),
+ null);
+ }
- @Override
- public void stop(BundleContext context) throws Exception {
- registration.unregister();
- }
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ registration.unregister();
+ }
}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java
index 6e6891dee..d182f4769 100644
--- a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java
+++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java
@@ -5,6 +5,8 @@
* 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.
@@ -34,7 +36,7 @@ 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);
@@ -46,7 +48,7 @@ public class DmaapMessageAdapterFactoryImpl implements MessageAdapterFactory {
for(String s : writeTopics){
topic = s;
}
- return new HttpDmaapProducerImpl(pools,topic);
+ return new HttpDmaapProducerImpl(pools, topic);
}
@Override
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/test/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryActivatorTest.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/test/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryActivatorTest.java
new file mode 100644
index 000000000..3a75f2d2d
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/test/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryActivatorTest.java
@@ -0,0 +1,49 @@
+/*
+ * ============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 org.junit.Test;
+import org.mockito.Mockito;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.powermock.reflect.Whitebox;
+
+
+public class DmaapMessageAdapterFactoryActivatorTest {
+
+ @Test
+ public void testStart() throws Exception {
+ DmaapMessageAdapterFactoryActivator activator = new DmaapMessageAdapterFactoryActivator();
+ BundleContext context = Mockito.mock(BundleContext.class);
+ activator.start(context);
+ Mockito.verify(context).registerService(Mockito.anyString(), Mockito.any(), Mockito.any());
+ }
+
+ @Test
+ public void testStop() throws Exception {
+ DmaapMessageAdapterFactoryActivator activator = new DmaapMessageAdapterFactoryActivator();
+ ServiceRegistration registration = Mockito.mock(ServiceRegistration.class);
+ Whitebox.setInternalState(activator, "registration", registration);
+ activator.stop(Mockito.mock(BundleContext.class));
+ Mockito.verify(registration).unregister();
+ }
+}