diff options
author | efiacor <fiachra.corcoran@est.tech> | 2021-11-26 13:55:33 +0000 |
---|---|---|
committer | efiacor <fiachra.corcoran@est.tech> | 2021-11-26 13:56:58 +0000 |
commit | 7de14af42606ea0afbb376e6f05de793108d555b (patch) | |
tree | 2096710265ba62c1547d1eacf829780229c8b6f9 /dmaap-bc/src/test | |
parent | daf8076254e3e0ae562c0e27bbd2d0910e79f8d1 (diff) |
[DMAAP-BC] Fix failing jenkins
Signed-off-by: efiacor <fiachra.corcoran@est.tech>
Change-Id: I5183451b4c86e7be5ddc2f38ad83de9658eafb82
Issue-ID: DMAAP-1682
Diffstat (limited to 'dmaap-bc/src/test')
44 files changed, 247 insertions, 825 deletions
diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/aaf/AafServiceFactoryTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/aaf/AafServiceFactoryTest.java index 45ff2b1..633742f 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/aaf/AafServiceFactoryTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/aaf/AafServiceFactoryTest.java @@ -20,7 +20,12 @@ package org.onap.dmaap.dbcapi.aaf; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.BDDMockito.given; + import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -28,10 +33,6 @@ import org.mockito.runners.MockitoJUnitRunner; import org.onap.dmaap.dbcapi.aaf.AafService.ServiceType; import org.onap.dmaap.dbcapi.util.DmaapConfig; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.BDDMockito.given; - @RunWith(MockitoJUnitRunner.class) public class AafServiceFactoryTest { @@ -45,6 +46,11 @@ public class AafServiceFactoryTest { private DmaapConfig dmaapConfig; private AafServiceFactory aafServiceFactory; + @BeforeClass + public static void setUpClass() { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); + } + @Before public void setUp() throws Exception { aafServiceFactory = new AafServiceFactory(dmaapConfig); diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/aaf/AafServiceImplTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/aaf/AafServiceImplTest.java index ffd130e..03d19cb 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/aaf/AafServiceImplTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/aaf/AafServiceImplTest.java @@ -50,6 +50,7 @@ public class AafServiceImplTest { @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); MockitoAnnotations.initMocks(this); given(aafConnection.postAaf(any(AafObject.class), anyString())).willReturn(CREATED); given(aafConnection.delAaf(any(AafObject.class), anyString())).willReturn(OK); @@ -58,7 +59,6 @@ public class AafServiceImplTest { @Test public void shouldReturnCorrectIdentity() { - assertEquals(IDENTITY, aafService.getIdentity()); } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/authentication/ApiPermsTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/authentication/ApiPermsTest.java index ea749ce..0c905fe 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/authentication/ApiPermsTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/authentication/ApiPermsTest.java @@ -25,13 +25,17 @@ import static org.junit.Assert.assertTrue; import javax.ws.rs.core.Application; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; +import org.junit.Before; import org.junit.Test; -import org.onap.dmaap.dbcapi.authentication.ApiPerms; - public class ApiPermsTest extends JerseyTest { + @Before + public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); + } + @Override protected Application configure() { return new ResourceConfig() diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/authentication/ApiPolicyTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/authentication/ApiPolicyTest.java index 7b9fbb3..19a8efa 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/authentication/ApiPolicyTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/authentication/ApiPolicyTest.java @@ -20,19 +20,24 @@ package org.onap.dmaap.dbcapi.authentication; -import org.junit.Test; -import org.onap.dmaap.dbcapi.aaf.DmaapPerm; - -import java.util.Properties; - import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import java.util.Properties; +import org.junit.Before; +import org.junit.Test; +import org.onap.dmaap.dbcapi.aaf.DmaapPerm; + public class ApiPolicyTest { private Properties properties = new Properties(); private ApiPolicy apiPolicy; + @Before + public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); + } + @Test public void check_shouldExecuteAuthorizationApi() throws Exception { properties.put("ApiPermission.Class", "org.onap.dmaap.dbcapi.authentication.ApiPolicyTest$DummyApiAuthorization"); diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/client/DrProvConnectionTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/client/DrProvConnectionTest.java index 4c44e0a..1b38838 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/client/DrProvConnectionTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/client/DrProvConnectionTest.java @@ -53,6 +53,7 @@ public class DrProvConnectionTest { @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); ns = new DrProvConnection(); } @@ -63,16 +64,13 @@ public class DrProvConnectionTest { @Test public void test1() { - - - rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.DrProvConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" ); - + rh.reflect( "org.onap.dmaap.dbcapi.client.DrProvConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" ); } @Test public void test2() { String v = "Validate"; - rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.DrProvConnection", "set", v ); + rh.reflect( "org.onap.dmaap.dbcapi.client.DrProvConnection", "set", v ); } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/client/MrProvConnectionTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/client/MrProvConnectionTest.java index 0614cf9..121a3d7 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/client/MrProvConnectionTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/client/MrProvConnectionTest.java @@ -47,6 +47,7 @@ public class MrProvConnectionTest { @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); ns = new MrProvConnection(); ts = new TopicService(); mcs = new MR_ClusterService(); @@ -61,14 +62,14 @@ public class MrProvConnectionTest { public void test1() { - rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrProvConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" ); + rh.reflect( "org.onap.dmaap.dbcapi.client.MrProvConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" ); } @Test public void test2() { String v = "Validate"; - rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrProvConnection", "set", v ); + rh.reflect( "org.onap.dmaap.dbcapi.client.MrProvConnection", "set", v ); } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/client/MrTopicConnectionTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/client/MrTopicConnectionTest.java index af33ec6..f235feb 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/client/MrTopicConnectionTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/client/MrTopicConnectionTest.java @@ -46,6 +46,7 @@ public class MrTopicConnectionTest { @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); ns = new MrTopicConnection( "aUser", "aPwd" ); ts = new TopicService(); mcs = new MR_ClusterService(); @@ -60,14 +61,14 @@ public class MrTopicConnectionTest { public void test1() { - rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrTopicConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" ); + rh.reflect( "org.onap.dmaap.dbcapi.client.MrTopicConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" ); } @Test public void test2() { String v = "Validate"; - rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrTopicConnection", "set", v ); + rh.reflect( "org.onap.dmaap.dbcapi.client.MrTopicConnection", "set", v ); } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/database/DBFieldHandlerTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/database/DBFieldHandlerTest.java index f68b9ed..547c3b6 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/database/DBFieldHandlerTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/database/DBFieldHandlerTest.java @@ -25,49 +25,11 @@ package org.onap.dmaap.dbcapi.database; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; -import java.sql.PreparedStatement; -import java.sql.ResultSet; import org.junit.Test; import org.onap.dmaap.dbcapi.logging.BaseLoggingClass; -import org.onap.dmaap.dbcapi.model.ReplicationType; -import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; public class DBFieldHandlerTest extends BaseLoggingClass { - private static final String fmt = "%24s: %s%n"; - - ReflectionHarness rh = new ReflectionHarness(); - - private static class TopicReplicationTypeHandler implements DBFieldHandler.SqlOp { - public Object get(ResultSet rs, int index) throws Exception { - int val = rs.getInt(index); - - return (ReplicationType.valueOf(val)); - } - - public void set(PreparedStatement ps, int index, Object val) throws Exception { - if (val == null) { - ps.setInt(index, 0); - return; - } - @SuppressWarnings("unchecked") - ReplicationType rep = (ReplicationType) val; - ps.setInt(index, rep.getValue()); - } - } - - @Test - public void test1() { - // rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrTopicConnection", "get", - // "idNotSet@namespaceNotSet:pwdNotSet" ); - } - - @Test - public void test2() { - String v = "Validate"; - // rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrTopicConnection", "set", v ); - } - @Test public void test3() { try { diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/database/DBMapTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/database/DBMapTest.java index abd4aee..968a48c 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/database/DBMapTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/database/DBMapTest.java @@ -19,66 +19,35 @@ */ package org.onap.dmaap.dbcapi.database; -import org.onap.dmaap.dbcapi.model.*; -import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; -import org.onap.dmaap.dbcapi.util.Singleton; - -import org.junit.After; +import java.util.Map; import org.junit.Before; import org.junit.Test; -import java.util.*; +import org.onap.dmaap.dbcapi.model.DcaeLocation; +import org.onap.dmaap.dbcapi.model.Dmaap; +import org.onap.dmaap.dbcapi.util.Singleton; public class DBMapTest { - private static final String fmt = "%24s: %s%n"; - - ReflectionHarness rh = new ReflectionHarness(); - - private static Singleton<Dmaap> dmaap; private static Map<String, DcaeLocation> dcaeLocations; - @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); } - @After - public void tearDown() throws Exception { - } - - @Test public void test1() { - - - //rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrTopicConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" ); - - } - - @Test - public void test2() { - String v = "Validate"; - //rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrTopicConnection", "set", v ); - - } - - @Test - public void test3() { try { - dmaap = new DBSingleton<Dmaap>(Dmaap.class, "dmaap"); + dmaap = new DBSingleton<>(Dmaap.class, "dmaap"); Dmaap nd = new Dmaap.DmaapBuilder().createDmaap(); dmaap.update(nd); } catch (Exception e ) { } try { - dcaeLocations = new DBMap<DcaeLocation>(DcaeLocation.class, "dcae_location", "dcae_location_name"); + dcaeLocations = new DBMap<>(DcaeLocation.class, "dcae_location", "dcae_location_name"); } catch (Exception e ) { } - } - - - } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/database/DBSingletonTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/database/DBSingletonTest.java index 003f250..ce2a848 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/database/DBSingletonTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/database/DBSingletonTest.java @@ -20,35 +20,21 @@ */ package org.onap.dmaap.dbcapi.database; -import org.onap.dmaap.dbcapi.model.*; -import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; - -import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.onap.dmaap.dbcapi.model.Dmaap; public class DBSingletonTest { - - private static final String fmt = "%24s: %s%n"; - - ReflectionHarness rh = new ReflectionHarness(); - - @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); } - @After - public void tearDown() throws Exception { - } - - - @Test public void test3() { try { - DBSingleton<Dmaap> dmaap = new DBSingleton<Dmaap>(Dmaap.class, "dmaap"); + DBSingleton<Dmaap> dmaap = new DBSingleton<>(Dmaap.class, "dmaap"); Dmaap d = new Dmaap.DmaapBuilder().createDmaap(); dmaap.init( d ); d = dmaap.get(); @@ -57,11 +43,6 @@ public class DBSingletonTest { dmaap.remove(); } catch (Exception e ) { } - } - - - - } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/database/LoadSchemaTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/database/LoadSchemaTest.java index 99065d3..14ad2af 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/database/LoadSchemaTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/database/LoadSchemaTest.java @@ -19,42 +19,28 @@ */ package org.onap.dmaap.dbcapi.database; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; public class LoadSchemaTest { - private static final String fmt = "%24s: %s%n"; - ReflectionHarness rh = new ReflectionHarness(); - LoadSchema ls; - - @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); } - @After - public void tearDown() throws Exception { - } - - @Test public void test1() { - - rh.reflect( "org.onap.dmaap.dbcapi.database.LoadSchema", "get", "idNotSet@namespaceNotSet:pwdNotSet" ); - } @Test public void test2() { String v = "Validate"; rh.reflect( "org.onap.dmaap.dbcapi.database.LoadSchema", "set", v ); - } @Test diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/database/TableHandlerTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/database/TableHandlerTest.java index 978f3ad..b497547 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/database/TableHandlerTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/database/TableHandlerTest.java @@ -19,20 +19,15 @@ */ package org.onap.dmaap.dbcapi.database; -import org.onap.dmaap.dbcapi.model.*; -import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; - -import static org.junit.Assert.*; - -import org.junit.After; +import java.sql.PreparedStatement; +import java.sql.ResultSet; import org.junit.Before; import org.junit.Test; -import java.sql.*; +import org.onap.dmaap.dbcapi.model.ReplicationType; +import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; public class TableHandlerTest { - private static final String fmt = "%24s: %s%n"; - ReflectionHarness rh = new ReflectionHarness(); private static class TopicReplicationTypeHandler implements DBFieldHandler.SqlOp { @@ -52,30 +47,20 @@ public class TableHandlerTest { } } - - @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); } - @After - public void tearDown() throws Exception { - } - - @Test public void test1() { - - - rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrTopicConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" ); - + rh.reflect( "org.onap.dmaap.dbcapi.client.MrTopicConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" ); } @Test public void test2() { String v = "Validate"; - //rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrTopicConnection", "set", v ); - + rh.reflect( "org.onap.dmaap.dbcapi.client.MrTopicConnection", "set", v ); } @Test @@ -99,8 +84,5 @@ public class TableHandlerTest { } } - - - } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/model/MRClientTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/model/MRClientTest.java index ba95a85..f6027a8 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/model/MRClientTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/model/MRClientTest.java @@ -22,23 +22,22 @@ package org.onap.dmaap.dbcapi.model; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; public class MRClientTest { - private static final String fmt = "%24s: %s%n"; - ReflectionHarness rh = new ReflectionHarness(); String d, t, f, c, m; @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); d = "central-onap"; t = "org.onap.dmaap.interestingTopic"; f = "mrc.onap.org:3904/events/org.onap.dmaap.interestingTopic"; @@ -46,13 +45,8 @@ public class MRClientTest { m = "m12345"; } - @After - public void tearDown() throws Exception { - } - @Test public void test1() { - // can't use simple reflection to test for null since null constructor // initializes some fields. // rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Client", "get", null ); @@ -84,7 +78,6 @@ public class MRClientTest { @Test public void test3() { - String v = "Validate"; rh.reflect("org.onap.dmaap.dbcapi.model.MR_Client", "set", v); } @@ -105,7 +98,6 @@ public class MRClientTest { assertEquals(false, mrClient.isPublisher()); assertEquals(false, mrClient.isSubscriber()); assertEquals("test", mrClient.getAction()[0]); - } } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/model/MR_ClusterTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/model/MR_ClusterTest.java index 2200627..fe0ca85 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/model/MR_ClusterTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/model/MR_ClusterTest.java @@ -19,9 +19,8 @@ */ package org.onap.dmaap.dbcapi.model; -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; @@ -32,6 +31,7 @@ public class MR_ClusterTest { @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); d = "central-onap"; fqdn = "mr.onap.org"; repGrp = "zeppelin"; @@ -44,14 +44,8 @@ public class MR_ClusterTest { } - @After - public void tearDown() throws Exception { - } - - @Test public void testMR_ClusterClassDefaultConstructor() { - MR_Cluster t = new MR_Cluster(); assertTrue( t.getDcaeLocationName() == null ); @@ -120,16 +114,10 @@ public class MR_ClusterTest { assertTrue(fqtn.contains(topic2)); } - - @Test public void testsetter() { - String v = "validate"; - - - rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Cluster", "set", v ); - + rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Cluster", "set", v ); } } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/model/MirrorMakerTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/model/MirrorMakerTest.java index 39de2be..872c4b7 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/model/MirrorMakerTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/model/MirrorMakerTest.java @@ -19,42 +19,29 @@ */ package org.onap.dmaap.dbcapi.model; -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; -import org.junit.After; +import java.util.ArrayList; import org.junit.Before; import org.junit.Test; import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; -import java.util.ArrayList; - public class MirrorMakerTest { - private static final String fmt = "%24s: %s%n"; - ReflectionHarness rh = new ReflectionHarness(); - @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); } - @After - public void tearDown() throws Exception { - } - - @Test public void test1() { - - - rh.reflect( "org.onap.dmaap.dbcapi.model.MirrorMaker", "get", null ); - + rh.reflect( "org.onap.dmaap.dbcapi.model.MirrorMaker", "get", null ); } @Test public void test2() { - String v = "Validate"; rh.reflect( "org.onap.dmaap.dbcapi.model.MirrorMaker", "set", v ); } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/model/TopicTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/model/TopicTest.java index 5da3aed..d7598b0 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/model/TopicTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/model/TopicTest.java @@ -24,7 +24,6 @@ package org.onap.dmaap.dbcapi.model; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onap.dmaap.dbcapi.model.DmaapObject.DmaapObject_Status; @@ -38,6 +37,7 @@ public class TopicTest { @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); f = "org.onap.dmaap.interestingTopic"; t = "interestingTopic"; d = "A so very interesting topic"; @@ -45,10 +45,6 @@ public class TopicTest { o = "m12345"; } - @After - public void tearDown() throws Exception { - } - @Test public void test1() { rh.reflect("org.onap.dmaap.dbcapi.model.Topic", "get", null); diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/AAFAuthenticationFilterTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/AAFAuthenticationFilterTest.java index 76fe914..e3f61c7 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/AAFAuthenticationFilterTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/AAFAuthenticationFilterTest.java @@ -19,26 +19,21 @@ */ package org.onap.dmaap.dbcapi.resources; -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.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verifyZeroInteractions; -import java.io.PrintWriter; -import java.io.StringWriter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -70,6 +65,11 @@ public class AAFAuthenticationFilterTest { @Rule public ExpectedException thrown = ExpectedException.none(); + @BeforeClass + public static void setUpClass(){ + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); + } + @Before public void setUp() throws Exception { doReturn(dmaapConfig).when(filter).getConfig(); @@ -131,65 +131,4 @@ public class AAFAuthenticationFilterTest { //when filter.init(filterConfig); } - - /* - * See https://jira.onap.org/browse/DMAAP-1361 for why this is commented out - @Test - public void init_shouldInitializeCADI_whenAafIsUsed_andValidCadiPropertiesSet() throws Exception { - //given - doReturn("true").when(dmaapConfig).getProperty(eq(AAFAuthenticationFilter.CADI_AUTHN_FLAG), anyString()); - doReturn("src/test/resources/cadi.properties").when(dmaapConfig).getProperty(AAFAuthenticationFilter.CADI_PROPERTIES); - - //when - filter.init(filterConfig); - - //then - assertTrue(filter.isCadiEnabled()); - assertNotNull(filter.getCadiFilter()); - } - - @Test - public void doFilter_shouldUseCADIfilter_andAuthenticateUser_whenAAFisUsed_andUserIsValid() throws Exception{ - //given - initCADIFilter(); - doReturn(200).when(servletResponse).getStatus(); - - //when - filter.doFilter(servletRequest,servletResponse,filterChain); - - //then - verify(cadiFilterMock).doFilter(servletRequest,servletResponse,filterChain); - verify(servletResponse).getStatus(); - verifyNoMoreInteractions(servletResponse); - verifyZeroInteractions(filterChain, servletRequest); - } - - @Test - public void doFilter_shouldUseCADIfilter_andReturnAuthenticationError_whenAAFisUsed_andUserInvalid() throws Exception{ - //given - String errorResponseJson = "{\"code\":401,\"message\":\"invalid or no credentials provided\",\"fields\":\"Authentication\",\"2xx\":false}"; - initCADIFilter(); - doReturn(401).when(servletResponse).getStatus(); - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - doReturn(pw).when(servletResponse).getWriter(); - - //when - filter.doFilter(servletRequest,servletResponse,filterChain); - - //then - verify(cadiFilterMock).doFilter(servletRequest,servletResponse,filterChain); - verify(servletResponse).getStatus(); - verify(servletResponse).setContentType("application/json"); - verifyZeroInteractions(filterChain, servletRequest); - assertEquals(errorResponseJson, sw.toString()); - } - - private void initCADIFilter() throws Exception{ - doReturn("true").when(dmaapConfig).getProperty(eq(AAFAuthenticationFilter.CADI_AUTHN_FLAG), anyString()); - doReturn("src/test/resources/cadi.properties").when(dmaapConfig).getProperty(AAFAuthenticationFilter.CADI_PROPERTIES); - filter.init(filterConfig); - filter.setCadiFilter(cadiFilterMock); - } -*/ }
\ No newline at end of file diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/AAFAuthorizationFilterTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/AAFAuthorizationFilterTest.java index ba11b01..c58c6fe 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/AAFAuthorizationFilterTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/AAFAuthorizationFilterTest.java @@ -39,6 +39,7 @@ import javax.servlet.FilterConfig; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -69,6 +70,10 @@ public class AAFAuthorizationFilterTest { @Mock private DmaapService dmaapService; + @BeforeClass + public static void setUpClass(){ + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); + } @Before public void setUp() throws Exception { filter.setPermissionBuilder(permissionBuilder); diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/DR_NodeResourceTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/DR_NodeResourceTest.java index f131d8f..ed3d087 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/DR_NodeResourceTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/DR_NodeResourceTest.java @@ -19,6 +19,14 @@ */ package org.onap.dmaap.dbcapi.resources; +import static javax.ws.rs.client.Entity.entity; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import javax.ws.rs.client.Entity; +import javax.ws.rs.core.Response; import org.glassfish.jersey.server.ResourceConfig; import org.junit.AfterClass; import org.junit.Before; @@ -29,15 +37,6 @@ import org.onap.dmaap.dbcapi.model.ApiError; import org.onap.dmaap.dbcapi.model.DR_Node; import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.Response; - -import static javax.ws.rs.client.Entity.entity; -import static javax.ws.rs.core.MediaType.APPLICATION_JSON; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - public class DR_NodeResourceTest { @@ -46,6 +45,7 @@ public class DR_NodeResourceTest { @BeforeClass public static void setUpClass() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); DatabaseClass.getDmaap().init(DMAAP_OBJECT_FACTORY.genDmaap()); testContainer = new FastJerseyTestContainer(new ResourceConfig() diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/DR_PubResourceTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/DR_PubResourceTest.java index 340f362..f0f55d8 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/DR_PubResourceTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/DR_PubResourceTest.java @@ -53,6 +53,7 @@ public class DR_PubResourceTest { @BeforeClass public static void setUpClass() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); //TODO: init is still needed here to assure that dmaap is not null DatabaseClass.getDmaap().init(DMAAP_OBJECT_FACTORY.genDmaap()); diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/DR_SubResourceTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/DR_SubResourceTest.java index 13b89ea..319e952 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/DR_SubResourceTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/DR_SubResourceTest.java @@ -54,6 +54,7 @@ public class DR_SubResourceTest { @BeforeClass public static void setUpClass() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); //TODO: init is still needed here to assure that dmaap is not null DatabaseClass.getDmaap().init(DMAAP_OBJECT_FACTORY.genDmaap()); diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/DcaeLocationResourceTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/DcaeLocationResourceTest.java index ff07927..20023e4 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/DcaeLocationResourceTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/DcaeLocationResourceTest.java @@ -19,23 +19,18 @@ */ package org.onap.dmaap.dbcapi.resources; -import org.onap.dmaap.dbcapi.model.*; -import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory; - -import static org.junit.Assert.*; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import static org.junit.Assert.assertTrue; -import org.glassfish.jersey.test.JerseyTest; -import org.glassfish.jersey.server.ResourceConfig; import javax.ws.rs.client.Entity; import javax.ws.rs.core.Application; -import javax.ws.rs.core.Response; import javax.ws.rs.core.MediaType; -import javax.ws.rs.Path; -import javax.ws.rs.GET; +import javax.ws.rs.core.Response; +import org.glassfish.jersey.server.ResourceConfig; +import org.glassfish.jersey.test.JerseyTest; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.dmaap.dbcapi.model.DcaeLocation; +import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory; public class DcaeLocationResourceTest extends JerseyTest { @@ -47,21 +42,10 @@ public class DcaeLocationResourceTest extends JerseyTest { return new ResourceConfig( DcaeLocationResource.class ); } - private static final String fmt = "%24s: %s%n"; - - - -/* may conflict with test framework! - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { + @BeforeClass + public static void setUpClass(){ + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); } -*/ - - @Test public void GetTest() { @@ -122,8 +106,5 @@ public class DcaeLocationResourceTest extends JerseyTest { System.out.println( "DELETE dcaeLocation resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) ); assertTrue( resp.getStatus() == 204 ); } - - - } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/DmaapResourceTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/DmaapResourceTest.java index 29ccb40..70acac3 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/DmaapResourceTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/DmaapResourceTest.java @@ -27,6 +27,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; +import org.junit.BeforeClass; import org.junit.Test; import org.onap.dmaap.dbcapi.model.Dmaap; import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory; @@ -36,28 +37,16 @@ public class DmaapResourceTest extends JerseyTest { static DmaapObjectFactory factory = new DmaapObjectFactory(); + @BeforeClass + public static void setUpClass(){ + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); + } + @Override protected Application configure() { return new ResourceConfig( DmaapResource.class ); - //return new ResourceConfig( HelloResource.class ); } - private static final String fmt = "%24s: %s%n"; - - - -/* may conflict with test framework! - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } -*/ - - - @Test public void GetTest() { Response resp = target( "dmaap").request().get( Response.class ); diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/FeedResourceTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/FeedResourceTest.java index 89dca8a..c15d8ae 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/FeedResourceTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/FeedResourceTest.java @@ -18,49 +18,30 @@ * ============LICENSE_END========================================================= */ package org.onap.dmaap.dbcapi.resources; -import org.onap.dmaap.dbcapi.model.*; -import org.onap.dmaap.dbcapi.service.*; -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import java.util.*; -import java.sql.*; - -import org.glassfish.jersey.test.JerseyTest; -import org.glassfish.jersey.server.ResourceConfig; import javax.ws.rs.client.Entity; import javax.ws.rs.core.Application; -import javax.ws.rs.core.Response; import javax.ws.rs.core.MediaType; -import javax.ws.rs.Path; -import javax.ws.rs.GET; +import javax.ws.rs.core.Response; +import org.glassfish.jersey.server.ResourceConfig; +import org.glassfish.jersey.test.JerseyTest; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.dmaap.dbcapi.model.Feed; public class FeedResourceTest extends JerseyTest { + @BeforeClass + public static void setUpClass(){ + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); + } @Override protected Application configure() { return new ResourceConfig( FeedResource.class ); } - private static final String fmt = "%24s: %s%n"; - - - -/* may conflict with test framework! - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } -*/ - - - @Test public void GetTest() { Response resp = target( "feeds").request().get( Response.class ); @@ -77,28 +58,5 @@ public class FeedResourceTest extends JerseyTest { assertTrue( resp.getStatus() == 200 ); } -/* - @Test - public void PutTest() { - - Feed feed = new Feed( "aPutTest", "1.0", "a unit test", "dgl", "unrestricted" ); - Entity<Feed> reqEntity = Entity.entity( feed, MediaType.APPLICATION_JSON ); - Response resp = target( "feeds").request().post( reqEntity, Response.class ); - System.out.println( "POST feed resp=" + resp.getStatus() ); - String postResp = resp.readEntity( String.class ); - System.out.println( "postResp=" + postResp ); - Feed rFeed = new Feed( postResp ); getting a null pointer here - rFeed.setSuspended( true ); - String target = new String ("feeds/" + rFeed.getFeedId() ); - System.out.println( "PUT feed target=" + target ); - reqEntity = Entity.entity( rFeed, MediaType.APPLICATION_JSON ); - resp = target( target ).request().put( reqEntity, Response.class ); - System.out.println( "PUT feed resp=" + resp.getStatus() ); - assertTrue( resp.getStatus() == 200 ); - } -*/ - - - } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/InfoResourceTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/InfoResourceTest.java index 3f57f58..57a9699 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/InfoResourceTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/InfoResourceTest.java @@ -18,24 +18,14 @@ * ============LICENSE_END========================================================= */ package org.onap.dmaap.dbcapi.resources; -import org.onap.dmaap.dbcapi.model.*; -import org.onap.dmaap.dbcapi.service.*; -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import java.util.*; -import java.sql.*; - -import org.glassfish.jersey.test.JerseyTest; -import org.glassfish.jersey.server.ResourceConfig; -import javax.ws.rs.client.Entity; import javax.ws.rs.core.Application; import javax.ws.rs.core.Response; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.Path; -import javax.ws.rs.GET; +import org.glassfish.jersey.server.ResourceConfig; +import org.glassfish.jersey.test.JerseyTest; +import org.junit.BeforeClass; +import org.junit.Test; public class InfoResourceTest extends JerseyTest { @@ -44,23 +34,11 @@ public class InfoResourceTest extends JerseyTest { protected Application configure() { return new ResourceConfig( InfoResource.class ); } - - private static final String fmt = "%24s: %s%n"; - - - -/* may conflict with test framework! - @Before - public void setUp() throws Exception { + @BeforeClass + public static void setUpClass(){ + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); } - @After - public void tearDown() throws Exception { - } -*/ - - - @Test public void GetTest() { Response resp = target( "info").request().get( Response.class ); diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/MR_ClientResourceTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/MR_ClientResourceTest.java index abe2e45..bbd4dd0 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/MR_ClientResourceTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/MR_ClientResourceTest.java @@ -20,6 +20,14 @@ package org.onap.dmaap.dbcapi.resources; +import static javax.ws.rs.client.Entity.entity; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import javax.ws.rs.client.Entity; +import javax.ws.rs.core.Response; import org.glassfish.jersey.server.ResourceConfig; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -31,15 +39,6 @@ import org.onap.dmaap.dbcapi.model.MR_Cluster; import org.onap.dmaap.dbcapi.model.Topic; import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.Response; - -import static javax.ws.rs.client.Entity.entity; -import static javax.ws.rs.core.MediaType.APPLICATION_JSON; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - public class MR_ClientResourceTest { private static final DmaapObjectFactory DMAAP_OBJECT_FACTORY = new DmaapObjectFactory(); @@ -47,6 +46,7 @@ public class MR_ClientResourceTest { @BeforeClass public static void setUpClass() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); DatabaseClass.getDmaap().init(DMAAP_OBJECT_FACTORY.genDmaap()); testContainer = new FastJerseyTestContainer(new ResourceConfig() diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/MR_ClusterResourceTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/MR_ClusterResourceTest.java index 9027f13..b97d3a1 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/MR_ClusterResourceTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/MR_ClusterResourceTest.java @@ -50,6 +50,7 @@ public class MR_ClusterResourceTest { @BeforeClass public static void setUpClass() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); DatabaseClass.getDmaap().init(DMAAP_OBJECT_FACTORY.genDmaap()); testContainer = new FastJerseyTestContainer(new ResourceConfig() diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/TopicResourceTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/TopicResourceTest.java index 5b7c46d..7c82711 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/TopicResourceTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/resources/TopicResourceTest.java @@ -54,6 +54,7 @@ public class TopicResourceTest { @BeforeClass public static void setUpClass() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); //TODO: init is still needed here to assure that dmaap is not null DatabaseClass.getDmaap().init(DMAAP_OBJECT_FACTORY.genDmaap()); diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/server/JettyServerTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/server/JettyServerTest.java index 35c9243..0582b32 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/server/JettyServerTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/server/JettyServerTest.java @@ -19,26 +19,21 @@ */ package org.onap.dmaap.dbcapi.server; -import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; -import org.onap.dmaap.dbcapi.util.DmaapConfig; -import static org.junit.Assert.*; - +import java.util.Properties; import org.junit.After; import org.junit.Before; import org.junit.Test; -import java.util.Properties; +import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; +import org.onap.dmaap.dbcapi.util.DmaapConfig; public class JettyServerTest { - private static final String fmt = "%24s: %s%n"; - ReflectionHarness rh = new ReflectionHarness(); - - - JettyServer m = null; + JettyServer m = null; @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); Properties p = DmaapConfig.getConfig(); try { m = new JettyServer(p); @@ -54,26 +49,15 @@ public class JettyServerTest { } } - @Test public void test1() { - - - rh.reflect( "org.onap.dmaap.dbcapi.server.JettyServer", "get", null ); - + rh.reflect( "org.onap.dmaap.dbcapi.server.JettyServer", "get", null ); } @Test public void test2() { String v = "Validate"; rh.reflect( "org.onap.dmaap.dbcapi.server.JettyServer", "set", v ); - } - @Test - public void test3() { - } - - - } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/server/MainTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/server/MainTest.java deleted file mode 100644 index 0e74f45..0000000 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/server/MainTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * org.onap.dmaap - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.dmaap.dbcapi.server; - -import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; - -import static org.junit.Assert.*; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class MainTest { - - private static final String fmt = "%24s: %s%n"; - - ReflectionHarness rh = new ReflectionHarness(); - - Main m; - - - @Before - public void setUp() throws Exception { - //m = new Main(); - } - - @After - public void tearDown() throws Exception { - } - - - @Test - public void test1() { - - - rh.reflect( "org.onap.dmaap.dbcapi.server.Main", "get", null ); - - } - - @Test - public void test2() { - String v = "Validate"; - rh.reflect( "org.onap.dmaap.dbcapi.server.Main", "set", v ); - - } - -/* - @Test - public void test3() { - String[] args = { "--help", "--version" }; - - try { - m.main( args ); - } catch (Exception e ) { - } - - } -*/ - - - -} diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/AafTopicSetupServiceTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/AafTopicSetupServiceTest.java index 0ca406a..aaac537 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/AafTopicSetupServiceTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/AafTopicSetupServiceTest.java @@ -19,6 +19,13 @@ */ package org.onap.dmaap.dbcapi.service; +import static com.google.common.collect.Lists.newArrayList; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.BDDMockito.given; + +import java.util.List; import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.junit.Before; @@ -37,14 +44,6 @@ import org.onap.dmaap.dbcapi.model.Dmaap; import org.onap.dmaap.dbcapi.model.Topic; import org.onap.dmaap.dbcapi.util.DmaapConfig; -import java.util.List; - -import static com.google.common.collect.Lists.newArrayList; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.BDDMockito.given; - @RunWith(JUnitParamsRunner.class) public class AafTopicSetupServiceTest { @@ -65,6 +64,7 @@ public class AafTopicSetupServiceTest { @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); MockitoAnnotations.initMocks(this); Dmaap dmaap = new Dmaap(); dmaap.setTopicNsRoot(TOPIC_NS_ROOT); diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/ApiServiceTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/ApiServiceTest.java index c860e55..ae1e427 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/ApiServiceTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/ApiServiceTest.java @@ -27,14 +27,13 @@ import org.junit.Test; public class ApiServiceTest { - private static final String fmt = "%24s: %s%n"; - ReflectionHarness rh = new ReflectionHarness(); ApiService ds; @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); ds = new ApiService(); } @@ -42,15 +41,6 @@ public class ApiServiceTest { public void tearDown() throws Exception { } - - @Test - public void test1() { - - - //rh.reflect( "org.onap.dmaap.dbcapi.service.ApiService", "get", null ); - - } - @Test public void test2() { String v = "Validate"; diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/DR_NodeServiceTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/DR_NodeServiceTest.java index 307d5b5..512365e 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/DR_NodeServiceTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/DR_NodeServiceTest.java @@ -19,21 +19,18 @@ */ package org.onap.dmaap.dbcapi.service; -import org.onap.dmaap.dbcapi.model.*; -import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory; -import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; - -import static org.junit.Assert.*; - +import java.util.List; import org.junit.After; import org.junit.Before; import org.junit.Test; -import java.util.List; +import org.onap.dmaap.dbcapi.model.ApiError; +import org.onap.dmaap.dbcapi.model.DR_Node; +import org.onap.dmaap.dbcapi.model.DcaeLocation; +import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory; +import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; public class DR_NodeServiceTest { - private static final String fmt = "%24s: %s%n"; - ReflectionHarness rh = new ReflectionHarness(); static DmaapObjectFactory factory = new DmaapObjectFactory(); @@ -41,6 +38,7 @@ public class DR_NodeServiceTest { @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); ns = new DR_NodeService(); } @@ -51,17 +49,13 @@ public class DR_NodeServiceTest { @Test public void test1() { - - - rh.reflect( "org.onap.dmaap.dbcapi.service.DR_NodeService", "get", null ); - + rh.reflect( "org.onap.dmaap.dbcapi.service.DR_NodeService", "get", null ); } @Test public void test2() { String v = "Validate"; rh.reflect( "org.onap.dmaap.dbcapi.service.DR_NodeService", "set", v ); - } @Test @@ -88,9 +82,6 @@ public class DR_NodeServiceTest { } n2 = ns.removeDr_Node( f, err ); - } - - } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/DmaapServiceTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/DmaapServiceTest.java index b8b660f..5b96f29 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/DmaapServiceTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/DmaapServiceTest.java @@ -19,7 +19,6 @@ */ package org.onap.dmaap.dbcapi.service; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onap.dmaap.dbcapi.model.Dmaap; @@ -27,35 +26,20 @@ import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; public class DmaapServiceTest { - private static final String fmt = "%24s: %s%n"; - ReflectionHarness rh = new ReflectionHarness(); DmaapService ds; @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); ds = new DmaapService(); } - @After - public void tearDown() throws Exception { - } - - - @Test - public void test1() { - - - //rh.reflect( "org.onap.dmaap.dbcapi.service.DmaapService", "get", null ); - - } - @Test public void test2() { String v = "Validate"; rh.reflect( "org.onap.dmaap.dbcapi.service.DmaapService", "set", v ); - } @Test diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/Dr_PubServiceTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/Dr_PubServiceTest.java index 2cfe475..90e1024 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/Dr_PubServiceTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/Dr_PubServiceTest.java @@ -19,21 +19,20 @@ */ package org.onap.dmaap.dbcapi.service; -import org.onap.dmaap.dbcapi.model.*; -import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; - -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; -import org.junit.After; +import java.util.ArrayList; +import java.util.List; import org.junit.Before; import org.junit.Test; -import java.util.List; -import java.util.ArrayList; +import org.onap.dmaap.dbcapi.model.ApiError; +import org.onap.dmaap.dbcapi.model.DR_Pub; +import org.onap.dmaap.dbcapi.model.DcaeLocation; +import org.onap.dmaap.dbcapi.model.Feed; +import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; public class Dr_PubServiceTest { - private static final String fmt = "%24s: %s%n"; - ReflectionHarness rh = new ReflectionHarness(); DR_PubService ns; @@ -41,28 +40,21 @@ public class Dr_PubServiceTest { @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); ns = new DR_PubService(); fs = new FeedService(); } - @After - public void tearDown() throws Exception { - } - @Test public void test1() { - - - rh.reflect( "org.onap.dmaap.dbcapi.service.DR_PubService", "get", null ); - + rh.reflect( "org.onap.dmaap.dbcapi.service.DR_PubService", "get", null ); } @Test public void test2() { String v = "Validate"; rh.reflect( "org.onap.dmaap.dbcapi.service.DR_PubService", "set", v ); - } @Test @@ -93,16 +85,10 @@ public class Dr_PubServiceTest { } n2 = ns.removeDr_Pub( n2.getPubId(), err ); - - } @Test public void test4() { ArrayList<DR_Pub> l = ns.getDr_PubsByFeedId( "1" ); - - } - - } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/FeedServiceTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/FeedServiceTest.java index 478647b..9f169ef 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/FeedServiceTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/FeedServiceTest.java @@ -20,7 +20,6 @@ package org.onap.dmaap.dbcapi.service; import java.util.List; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onap.dmaap.dbcapi.model.ApiError; @@ -29,35 +28,26 @@ import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; public class FeedServiceTest { - private static final String fmt = "%24s: %s%n"; - ReflectionHarness rh = new ReflectionHarness(); FeedService ds; @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); ds = new FeedService(); } - @After - public void tearDown() throws Exception { - } - @Test public void test1() { - - - rh.reflect( "org.onap.dmaap.dbcapi.service.FeedService", "get", null ); - + rh.reflect( "org.onap.dmaap.dbcapi.service.FeedService", "get", null ); } @Test public void test2() { String v = "Validate"; rh.reflect( "org.onap.dmaap.dbcapi.service.FeedService", "set", v ); - } @Test @@ -86,7 +76,6 @@ public class FeedServiceTest { @Test public void test5() { List<Feed> f = ds.getAllFeeds( "aName", "1.0", "startsWith" ); - } @@ -97,6 +86,4 @@ public class FeedServiceTest { assert( 200 == err.getCode()); } - - } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClientServiceTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClientServiceTest.java index e80697a..aa5dd6d 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClientServiceTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClientServiceTest.java @@ -22,8 +22,6 @@ package org.onap.dmaap.dbcapi.service; import static org.junit.Assert.assertTrue; import java.util.List; - -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onap.dmaap.dbcapi.model.ApiError; @@ -36,8 +34,6 @@ import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; public class MR_ClientServiceTest { - private static final String fmt = "%24s: %s%n"; - private static DmaapObjectFactory factory = new DmaapObjectFactory(); ReflectionHarness rh = new ReflectionHarness(); @@ -52,6 +48,7 @@ public class MR_ClientServiceTest { @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); ts = new TopicService(); mcs = new MR_ClusterService(); cls = new MR_ClientService(); @@ -68,24 +65,15 @@ public class MR_ClientServiceTest { MR_Cluster n2 = mcs.addMr_Cluster( node, err ); } - @After - public void tearDown() throws Exception { - } - - @Test public void test1() { - - - rh.reflect( "org.onap.dmaap.dbcapi.service.MR_ClientService", "get", null ); - + rh.reflect( "org.onap.dmaap.dbcapi.service.MR_ClientService", "get", null ); } @Test public void test2() { String v = "Validate"; rh.reflect( "org.onap.dmaap.dbcapi.service.MR_ClientService", "set", v ); - } @Test @@ -129,7 +117,5 @@ public class MR_ClientServiceTest { c = cls.addMr_Client( c, topic, err ); assertTrue( err.getCode() == 200 ); - } - } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClusterServiceTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClusterServiceTest.java index 8ae2667..7a35de3 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClusterServiceTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClusterServiceTest.java @@ -19,47 +19,35 @@ */ package org.onap.dmaap.dbcapi.service; -import org.onap.dmaap.dbcapi.model.*; -import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; - -import static org.junit.Assert.*; - -import org.junit.After; +import java.util.List; import org.junit.Before; import org.junit.Test; -import java.util.List; +import org.onap.dmaap.dbcapi.model.ApiError; +import org.onap.dmaap.dbcapi.model.DcaeLocation; +import org.onap.dmaap.dbcapi.model.MR_Cluster; +import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; public class MR_ClusterServiceTest { - private static final String fmt = "%24s: %s%n"; - ReflectionHarness rh = new ReflectionHarness(); MR_ClusterService ns; @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); ns = new MR_ClusterService(); } - @After - public void tearDown() throws Exception { - } - - @Test public void test1() { - - - rh.reflect( "org.onap.dmaap.dbcapi.service.MR_ClusterService", "get", null ); - + rh.reflect( "org.onap.dmaap.dbcapi.service.MR_ClusterService", "get", null ); } @Test public void test2() { String v = "Validate"; rh.reflect( "org.onap.dmaap.dbcapi.service.MR_ClusterService", "set", v ); - } @Test @@ -84,44 +72,7 @@ public class MR_ClusterServiceTest { if ( n2 != null ) { n2 = ns.updateMr_Cluster( n2, err ); } - n2 = ns.removeMr_Cluster( f, err ); - - - } - -/* - @Test - public void test4() { - List<MR_Client> l = cls.getAllMr_Clients(); - - ArrayList<MR_Client> al = cls.getAllMrClients( "foo" ); - - ArrayList<MR_Client> al2 = cls.getClientsByLocation( "central" ); - } - - @Test - public void test5() { - Topic topic = new Topic(); - ApiError err = new ApiError(); - topic.setTopicName( "test3" ); - topic.setFqtnStyle( FqtnType.Validator("none") ); - topic.getFqtn(); - Topic nTopic = ts.addTopic( topic, err ); - if ( nTopic != null ) { - assertTrue( nTopic.getTopicName().equals( topic.getTopicName() )); - } - String[] actions = { "pub", "view" }; - MR_Client c = new MR_Client( "central-onap", "org.onap.dmaap.demo.interestingTopic2", "org.onap.clientApp.publisher", actions ); - - c = cls.addMr_Client( c, topic, err ); - if ( c != null ) { - actions[0] = "sub"; - c.setAction( actions ); - c = cls.updateMr_Client( c, err ); - assertTrue( err.getCode() == 200 ); - } } -*/ } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/MirrorMakerServiceTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/MirrorMakerServiceTest.java index f247bad..efe6b41 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/MirrorMakerServiceTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/MirrorMakerServiceTest.java @@ -19,21 +19,25 @@ */ package org.onap.dmaap.dbcapi.service; -import org.onap.dmaap.dbcapi.model.*; -import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory; -import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; - -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; -import org.junit.After; +import java.util.ArrayList; +import java.util.List; import org.junit.Before; import org.junit.Test; -import java.util.List; -import java.util.ArrayList; +import org.onap.dmaap.dbcapi.model.ApiError; +import org.onap.dmaap.dbcapi.model.DcaeLocation; +import org.onap.dmaap.dbcapi.model.Dmaap; +import org.onap.dmaap.dbcapi.model.MR_Client; +import org.onap.dmaap.dbcapi.model.MR_Cluster; +import org.onap.dmaap.dbcapi.model.MirrorMaker; +import org.onap.dmaap.dbcapi.model.ReplicationType; +import org.onap.dmaap.dbcapi.model.Topic; +import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory; +import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; public class MirrorMakerServiceTest { - private static final String fmt = "%24s: %s%n"; private static DmaapObjectFactory factory = new DmaapObjectFactory(); ReflectionHarness rh = new ReflectionHarness(); @@ -45,12 +49,12 @@ public class MirrorMakerServiceTest { private Topic replicationTopic; - DmaapService ds; String locname; @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); mms = new MirrorMakerService(); ts = new TopicService(); assert( ts != null ); @@ -93,36 +97,17 @@ public class MirrorMakerServiceTest { clients.add( pub ); replicationTopic.setClients( clients ); - } - @After - public void tearDown() throws Exception { - } - - -// @Test -// public void test_getters() { -// -// -// rh.reflect( "org.onap.dmaap.dbcapi.service.MirrorMakerService", "get", null ); -// -// } - @Test public void test_setters() { String v = "Validate"; rh.reflect( "org.onap.dmaap.dbcapi.service.MirrorMakerService", "set", v ); - } - - @Test public void CreateMirrorMakerWithSingleTopic() { ApiError err = new ApiError(); - - Topic nTopic = ts.addTopic(replicationTopic, err, true ); assertTrue( err.getCode() == 200 ); @@ -178,8 +163,7 @@ public class MirrorMakerServiceTest { MirrorMaker mm = mms.getMirrorMaker(name); - MirrorMaker mm2 = mms.splitMM(mm); - + MirrorMaker mm2 = mms.splitMM(mm); } } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/MirrorMakerServiceTestMockito.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/MirrorMakerServiceTestMockito.java index 5beadc6..b0199bc 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/MirrorMakerServiceTestMockito.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/MirrorMakerServiceTestMockito.java @@ -20,25 +20,10 @@ package org.onap.dmaap.dbcapi.service; 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.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; -import java.io.PrintWriter; -import java.io.StringWriter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -72,26 +57,16 @@ public class MirrorMakerServiceTestMockito { @Rule public ExpectedException thrown = ExpectedException.none(); - @Before - public void setUp() throws Exception { - + @BeforeClass + public static void setUpClass() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); } @Test - public void init_normalConstructor() throws Exception { - //given - - - //when - - - //then + public void init_normalConstructor() { assertEquals( MirrorMakerService.getProvUserPwd(), MirrorMakerService.PROV_PWD_DEFAULT); assertEquals( MirrorMakerService.getDefaultConsumerPort(), MirrorMakerService.TARGET_REPLICATION_PORT_DEFAULT); assertEquals( MirrorMakerService.getDefaultProducerPort(), MirrorMakerService.SOURCE_REPLICATION_PORT_DEFAULT); } - // Todo: learn how to make more tests in Mockito - - } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/TopicServiceTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/TopicServiceTest.java index a37ce02..8d57496 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/TopicServiceTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/service/TopicServiceTest.java @@ -20,26 +20,6 @@ package org.onap.dmaap.dbcapi.service; -import com.google.common.collect.ImmutableMap; -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.dmaap.dbcapi.model.ApiError; -import org.onap.dmaap.dbcapi.model.MR_Client; -import org.onap.dmaap.dbcapi.model.Topic; -import org.onap.dmaap.dbcapi.util.DmaapConfig; - -import javax.ws.rs.core.Response; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.collect.Lists.newArrayList; import static javax.ws.rs.core.Response.Status.NOT_FOUND; @@ -56,6 +36,26 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.verifyZeroInteractions; import static org.onap.dmaap.dbcapi.model.ReplicationType.REPLICATION_GLOBAL_TO_FQDN; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.ws.rs.core.Response; +import org.hamcrest.BaseMatcher; +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.dmaap.dbcapi.model.ApiError; +import org.onap.dmaap.dbcapi.model.MR_Client; +import org.onap.dmaap.dbcapi.model.Topic; +import org.onap.dmaap.dbcapi.util.DmaapConfig; + @RunWith(MockitoJUnitRunner.class) public class TopicServiceTest { @@ -75,6 +75,12 @@ public class TopicServiceTest { @Mock private AafTopicSetupService aafTopicSetupService; + @BeforeClass + public static void setUpClass(){ + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); + + } + @Before public void setUp() throws Exception { given(dmaapConfig.getProperty("MR.globalHost", "global.host.not.set")).willReturn(GLOBAL_MR_HOST); diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/util/DmaapConfigTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/util/DmaapConfigTest.java index 6ef05c0..9b097e7 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/util/DmaapConfigTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/util/DmaapConfigTest.java @@ -19,54 +19,34 @@ */ package org.onap.dmaap.dbcapi.util; -import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; - -import static org.junit.Assert.*; - -import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; public class DmaapConfigTest { - private static final String fmt = "%24s: %s%n"; - ReflectionHarness rh = new ReflectionHarness(); - DmaapConfig g; - - @Before public void setUp() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); } - @After - public void tearDown() throws Exception { - } - - @Test public void test1() { - - - rh.reflect( "org.onap.dmaap.dbcapi.util.DmaapConfig", "get", "" ); - + rh.reflect( "org.onap.dmaap.dbcapi.util.DmaapConfig", "get", "" ); } @Test public void test2() { String v = "Validate"; rh.reflect( "org.onap.dmaap.dbcapi.util.DmaapConfig", "set", v ); - } @Test public void test3() { - - String f = g.getConfigFileName(); + DmaapConfig.getConfigFileName(); + DmaapConfig.getSSLSocketFactory(); } - - - } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/util/GraphTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/util/GraphTest.java index 770ee65..903d73b 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/util/GraphTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/util/GraphTest.java @@ -19,50 +19,33 @@ */ package org.onap.dmaap.dbcapi.util; -import org.onap.dmaap.dbcapi.model.*; -import org.onap.dmaap.dbcapi.service.*; -import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; - -import static org.junit.Assert.*; - -import org.junit.After; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; import org.junit.Before; import org.junit.Test; -import java.util.*; +import org.onap.dmaap.dbcapi.model.DcaeLocation; +import org.onap.dmaap.dbcapi.model.MR_Client; +import org.onap.dmaap.dbcapi.service.DcaeLocationService; +import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; public class GraphTest { - private static final String fmt = "%24s: %s%n"; - ReflectionHarness rh = new ReflectionHarness(); Graph g; - @Before public void setUp() throws Exception { - HashMap<String, String> hm = new HashMap<String,String>(); + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); + HashMap<String, String> hm = new HashMap<>(); g = new Graph( hm ); } - @After - public void tearDown() throws Exception { - } - - @Test public void test1() { - - - rh.reflect( "org.onap.dmaap.dbcapi.util.Graph", "get", "idNotSet@namespaceNotSet:pwdNotSet" ); - - } - - @Test - public void test2() { - String v = "Validate"; - //rh.reflect( "org.onap.dmaap.dbcapi.util.Graph", "set", v ); - + rh.reflect( "org.onap.dmaap.dbcapi.util.Graph", "get", "idNotSet@namespaceNotSet:pwdNotSet" ); } @Test @@ -82,7 +65,6 @@ public class GraphTest { HashMap<String, String> hm = new HashMap<String, String>(); - String s = g.put( "aKey", "aVal" ); s = g.get( "aKey" ); @@ -93,10 +75,7 @@ public class GraphTest { hm = g.getGraph(); Collection<String> k = g.getKeys(); - } - - } diff --git a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/util/PermissionBuilderTest.java b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/util/PermissionBuilderTest.java index 8db9d2e..310497f 100644 --- a/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/util/PermissionBuilderTest.java +++ b/dmaap-bc/src/test/java/org/onap/dmaap/dbcapi/util/PermissionBuilderTest.java @@ -24,7 +24,9 @@ import static org.mockito.Mockito.atMost; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; + import javax.servlet.http.HttpServletRequest; +import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -45,6 +47,10 @@ public class PermissionBuilderTest { @Mock private HttpServletRequest request; + @BeforeClass + public static void setUpClass() throws Exception { + System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties"); + } @Test public void updateDmaapInstance_shouldSetBootInstance_whenDmaapIsNotInitialized() { |