diff options
Diffstat (limited to 'src/test/java/org')
34 files changed, 2977 insertions, 24 deletions
diff --git a/src/test/java/org/onap/dmaap/dbcapi/aaf/DBSingletonTest.java b/src/test/java/org/onap/dmaap/dbcapi/aaf/DBSingletonTest.java new file mode 100644 index 0000000..f403da7 --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/aaf/DBSingletonTest.java @@ -0,0 +1,68 @@ + +/*- + * ============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.aaf.database; +import org.onap.dmaap.dbcapi.model.*; +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.*; +import java.sql.*; + +public class DBSingletonTest { + + private static final String fmt = "%24s: %s%n"; + + ReflectionHarness rh = new ReflectionHarness(); + + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + + + @Test + public void test3() { + + try { + DBSingleton<Dmaap> dmaap = new DBSingleton<Dmaap>(Dmaap.class, "dmaap"); + Dmaap d = new Dmaap(); + dmaap.init( d ); + d = dmaap.get(); + d.setDmaapName( "foo" ); + dmaap.update( d ); + dmaap.remove(); + } catch (Exception e ) { + } + + } + + + + +} + diff --git a/src/test/java/org/onap/dmaap/dbcapi/aaf/client/DrProvConnectionTest.java b/src/test/java/org/onap/dmaap/dbcapi/aaf/client/DrProvConnectionTest.java new file mode 100644 index 0000000..643b319 --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/aaf/client/DrProvConnectionTest.java @@ -0,0 +1,127 @@ +/*- + * ============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.aaf.client; +import org.onap.dmaap.dbcapi.model.*; +import org.onap.dmaap.dbcapi.service.*; +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.List; +import java.util.ArrayList; +import java.io.InputStream; +import java.io.FileInputStream; +import java.io.FileNotFoundException; + +public class DrProvConnectionTest { + + private static final String fmt = "%24s: %s%n"; + private static DmaapObjectFactory factory = new DmaapObjectFactory(); + + ReflectionHarness rh = new ReflectionHarness(); + + DrProvConnection ns; + MR_ClusterService mcs; + TopicService ts; + + @Before + public void setUp() throws Exception { + ns = new DrProvConnection(); + } + + @After + public void tearDown() throws Exception { + } + + + @Test + public void test1() { + + + rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.DrProvConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" ); + + } + + @Test + public void test2() { + String v = "Validate"; + rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.DrProvConnection", "set", v ); + + } + + @Test + public void test3() { + String locname = "central-demo"; + + DcaeLocationService dls = new DcaeLocationService(); + DcaeLocation loc = factory.genDcaeLocation( "central" ); + dls.addDcaeLocation( loc ); + + ApiError err = new ApiError(); + String[] hl = { "host1", "host2", "host3" }; + ns.makeFeedConnection( ); + ns.makeFeedConnection( "01" ); + ns.makeSubPostConnection( "part0/part1/part2/part3/part4" ); + ns.makeSubPutConnection( "44" ); + ns.makeIngressConnection( "01", "aUser", "10.10.10.10", "aNode" ); + ns.makeEgressConnection( "01", "aNode" ); + ns.makeNodesConnection( "someVar" ); + Feed feed = new Feed( "dgl feed 1" , + "v1.0", + "dgl feed 1 for testing", + "TEST", + "unclassified" + ); + ArrayList<DR_Pub> pubs = new ArrayList<DR_Pub>(); + pubs.add( new DR_Pub( "central-demo" ) ); + feed.setPubs(pubs); + + String resp = ns.doPostFeed( feed, err ); + resp = ns.doPutFeed( feed, err ); + resp = ns.doDeleteFeed( feed, err ); + + int i = ns.doXgressPost( err ); + + DR_Sub sub = factory.genDrSub( "central", feed.getFeedId() ); + assertTrue( sub != null ); + String sr = ns.doPostDr_Sub( sub, err ); + /* + * TODO: + - create a new DR_Sub based on a simulated response + - update using ns.doPutDr_Sub( sub, err ); + */ + } + + @Test + public void test4() { + ApiError err = new ApiError(); + String resp = ns.doGetNodes( err ); + ns.makeNodesConnection( "someVar", "host1|host2" ); + resp = ns.doPutNodes( err ); + try { + InputStream is = new FileInputStream( "./etc/dmaapbc.properties" ); + String body = ns.bodyToString( is ); + } catch ( FileNotFoundException fnfe ) { + } + } + +} + diff --git a/src/test/java/org/onap/dmaap/dbcapi/aaf/client/MrProvConnectionTest.java b/src/test/java/org/onap/dmaap/dbcapi/aaf/client/MrProvConnectionTest.java new file mode 100644 index 0000000..4995813 --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/aaf/client/MrProvConnectionTest.java @@ -0,0 +1,99 @@ +/*- + * ============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.aaf.client; +import org.onap.dmaap.dbcapi.model.*; +import org.onap.dmaap.dbcapi.service.*; +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.List; +import java.util.ArrayList; +import java.io.InputStream; +import java.io.FileInputStream; +import java.io.FileNotFoundException; + +public class MrProvConnectionTest { + + private static final String fmt = "%24s: %s%n"; + + ReflectionHarness rh = new ReflectionHarness(); + + MrProvConnection ns; + MR_ClusterService mcs; + TopicService ts; + + @Before + public void setUp() throws Exception { + ns = new MrProvConnection(); + ts = new TopicService(); + mcs = new MR_ClusterService(); + } + + @After + public void tearDown() throws Exception { + } + + + @Test + public void test1() { + + + rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrProvConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" ); + + } + + @Test + public void test2() { + String v = "Validate"; + rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrProvConnection", "set", v ); + + } + + @Test + public void test3() { + String locname = "central-demo"; + + DcaeLocationService dls = new DcaeLocationService(); + DcaeLocation loc = new DcaeLocation( "CLLI1234", "central-onap", locname, "aZone", "10.10.10.0/24" ); + dls.addDcaeLocation( loc ); + + ApiError err = new ApiError(); + String[] hl = { "host1", "host2", "host3" }; + MR_Cluster cluster = new MR_Cluster( locname, "localhost", "", hl ); + mcs.addMr_Cluster( cluster, err ); + ns.makeTopicConnection( cluster ); + Topic topic = new Topic(); + topic.setTopicName( "test5" ); + String resp = ns.doPostTopic( topic, err ); + + try { + InputStream is = new FileInputStream( "./etc/dmaapbc.properties" ); + String body = ns.bodyToString( is ); + } catch ( FileNotFoundException fnfe ) { + } + + } + + + +} + diff --git a/src/test/java/org/onap/dmaap/dbcapi/aaf/client/MrTopicConnectionTest.java b/src/test/java/org/onap/dmaap/dbcapi/aaf/client/MrTopicConnectionTest.java new file mode 100644 index 0000000..5bbb6a1 --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/aaf/client/MrTopicConnectionTest.java @@ -0,0 +1,98 @@ +/*- + * ============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.aaf.client; +import org.onap.dmaap.dbcapi.model.*; +import org.onap.dmaap.dbcapi.service.*; +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.List; +import java.util.ArrayList; +import java.io.InputStream; +import java.io.FileInputStream; +import java.io.FileNotFoundException; + +public class MrTopicConnectionTest { + + private static final String fmt = "%24s: %s%n"; + + ReflectionHarness rh = new ReflectionHarness(); + + MrTopicConnection ns; + MR_ClusterService mcs; + TopicService ts; + + @Before + public void setUp() throws Exception { + ns = new MrTopicConnection( "aUser", "aPwd" ); + ts = new TopicService(); + mcs = new MR_ClusterService(); + } + + @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() { + String locname = "central-demo"; + + DcaeLocationService dls = new DcaeLocationService(); + DcaeLocation loc = new DcaeLocation( "CLLI1234", "central-onap", locname, "aZone", "10.10.10.0/24" ); + dls.addDcaeLocation( loc ); + + ApiError err = new ApiError(); + String[] hl = { "host1", "host2", "host3" }; + MR_Cluster cluster = new MR_Cluster( locname, "localhost", "", hl ); + mcs.addMr_Cluster( cluster, err ); + ns.makeTopicConnection( cluster, "org.onap.dmaap.anInterestingTopic", "" ); + String msg = "{ 'key': '1234', 'val': 'hello world' }"; + ApiError e2 = ns.doPostMessage( msg ); + + try { + InputStream is = new FileInputStream( "./etc/dmaapbc.properties" ); + String body = ns.bodyToString( is ); + } catch ( FileNotFoundException fnfe ) { + } + + } + + + +} + diff --git a/src/test/java/org/onap/dmaap/dbcapi/aaf/database/DBFieldHandlerTest.java b/src/test/java/org/onap/dmaap/dbcapi/aaf/database/DBFieldHandlerTest.java new file mode 100644 index 0000000..fc17ac6 --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/aaf/database/DBFieldHandlerTest.java @@ -0,0 +1,103 @@ + +/*- + * ============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.aaf.database; +import org.onap.dmaap.dbcapi.model.*; +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.*; +import java.sql.*; + +public class DBFieldHandlerTest { + + 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()); + } + } + + + + @Before + public void setUp() throws Exception { + } + + @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 { + DBFieldHandler fh = new DBFieldHandler( String.class, "aString", 1 ); + } catch (Exception e ) { + } + + } + + @Test + public void test4() { + + try { + DBFieldHandler fh = new DBFieldHandler( String.class, "aString", 1, null ); + } catch (Exception e ) { + } + + } + + + +} + diff --git a/src/test/java/org/onap/dmaap/dbcapi/aaf/database/DBMapTest.java b/src/test/java/org/onap/dmaap/dbcapi/aaf/database/DBMapTest.java new file mode 100644 index 0000000..3fdcb52 --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/aaf/database/DBMapTest.java @@ -0,0 +1,85 @@ +/*- + * ============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.aaf.database; +import org.onap.dmaap.dbcapi.model.*; +import org.onap.dmaap.dbcapi.util.Singleton; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.*; +import java.sql.*; + +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 { + } + + @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 nd = new Dmaap(); + dmaap.update(nd); + } catch (Exception e ) { + } + try { + dcaeLocations = new DBMap<DcaeLocation>(DcaeLocation.class, "dcae_location", "dcae_location_name"); + } catch (Exception e ) { + } + + } + + + +} + diff --git a/src/test/java/org/onap/dmaap/dbcapi/aaf/database/LoadSchemaTest.java b/src/test/java/org/onap/dmaap/dbcapi/aaf/database/LoadSchemaTest.java new file mode 100644 index 0000000..d93ffd2 --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/aaf/database/LoadSchemaTest.java @@ -0,0 +1,71 @@ +/*- + * ============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.aaf.database; +import org.onap.dmaap.dbcapi.model.*; +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.*; +import java.sql.*; + +public class LoadSchemaTest { + + private static final String fmt = "%24s: %s%n"; + + ReflectionHarness rh = new ReflectionHarness(); + + LoadSchema ls; + + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + + @Test + public void test1() { + + + rh.reflect( "org.onap.dmaap.dbcapi.aaf.database.LoadSchema", "get", "idNotSet@namespaceNotSet:pwdNotSet" ); + + } + + @Test + public void test2() { + String v = "Validate"; + rh.reflect( "org.onap.dmaap.dbcapi.aaf.database.LoadSchema", "set", v ); + + } + + @Test + public void test3() { + ls = new LoadSchema(); + } + + + +} + diff --git a/src/test/java/org/onap/dmaap/dbcapi/aaf/database/TableHandlerTest.java b/src/test/java/org/onap/dmaap/dbcapi/aaf/database/TableHandlerTest.java new file mode 100644 index 0000000..266bf24 --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/aaf/database/TableHandlerTest.java @@ -0,0 +1,100 @@ +/*- + * ============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.aaf.database; +import org.onap.dmaap.dbcapi.model.*; +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.*; +import java.sql.*; + +public class TableHandlerTest { + + 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()); + } + } + + + + @Before + public void setUp() throws Exception { + } + + @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() { + TableHandler.setSpecialCase("topic", "replication_case", new TopicReplicationTypeHandler()); + + try { + ConnectionFactory cf = new ConnectionFactory(); + TableHandler th = new TableHandler( cf, TopicReplicationTypeHandler.class, "foo", "bar" ); + } catch (Exception e ) { + } + try { + ConnectionFactory cf = new ConnectionFactory(); + TableHandler th = new TableHandler( TopicReplicationTypeHandler.class, "foo", "bar" ); + th.getSpecialCase( "foo", "bar" ); + } catch (Exception e ) { + } + + } + + + +} + diff --git a/src/test/java/org/onap/dmaap/dbcapi/model/DRSubTest.java b/src/test/java/org/onap/dmaap/dbcapi/model/DRSubTest.java index 251d975..e2e48cc 100644 --- a/src/test/java/org/onap/dmaap/dbcapi/model/DRSubTest.java +++ b/src/test/java/org/onap/dmaap/dbcapi/model/DRSubTest.java @@ -37,7 +37,7 @@ public class DRSubTest { d = "central-onap"; un = "user1"; up = "secretW0rd"; - f = "234"; + f = "22"; s = "sub123"; du = "sub.server.onap.org:8443/deliver/here"; lu = "https://drps.onap.org:8443/sublog/123"; @@ -105,4 +105,34 @@ public class DRSubTest { assertTrue( lu.equals( t.getLogURL() ) ); } + + @Test + public void test3() { + String json = String.format( "{ \"%s\": \"%s\", \"%s\": false, \"%s\": { \"%s\": \"%s\", \"%s\": \"%s\", \"%s\": \"%s\" }, \"%s\": { \"%s\": \"%s\", \"%s\": \"%s\", \"%s\": \"%s\", \"%s\": true } }", + "subscriber", "owner", + "suspend", + "links", + "feed", "https://feed.onap.org/publish/22", + "self", "https://feed.onap.org/subscriber/44", + "log" , lu, + "delivery" , + "url", du, + "user", un, + "password", up, + "use100" + ); + + + DR_Sub t = new DR_Sub( json ); + + assertTrue( un.equals( t.getUsername() )); + assertTrue( up.equals( t.getUserpwd() )); + assertTrue( f.equals( t.getFeedId() )); + assertTrue( du.equals( t.getDeliveryURL() ) ); + assertTrue( lu.equals( t.getLogURL() ) ); + assertTrue( ! t.isSuspended() ); + + String o = t.toString(); + + } } diff --git a/src/test/java/org/onap/dmaap/dbcapi/model/FeedTest.java b/src/test/java/org/onap/dmaap/dbcapi/model/FeedTest.java index cc8b259..4e9a022 100644 --- a/src/test/java/org/onap/dmaap/dbcapi/model/FeedTest.java +++ b/src/test/java/org/onap/dmaap/dbcapi/model/FeedTest.java @@ -25,6 +25,8 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import java.util.ArrayList; + public class FeedTest { @@ -60,6 +62,10 @@ public class FeedTest { public void test2() { Feed t = new Feed( n, v, d, o, a ); + ArrayList<DR_Sub> subs = new ArrayList<DR_Sub>(); + DR_Sub sub = new DR_Sub( "central", "user", "pwd", "22", "server.onap.org/deliv", "log.onap.org/logs", true ); + subs.add( sub ); + t.setSubs( subs ); assertTrue( n.equals( t.getFeedName() )); assertTrue( v.equals( t.getFeedVersion() )); @@ -76,4 +82,33 @@ public class FeedTest { rh.reflect( "org.onap.dmaap.dbcapi.model.Feed", "set", v ); } + @Test + public void test4() { + String s = String.format( "{ \"%s\": \"%s\", \"%s\": \"%s\", \"%s\": \"%s\", \"%s\": \"%s\", \"%s\": false, \"%s\": { \"%s\": \"%s\", \"%s\": \"%s\", \"%s\": \"%s\" }, \"%s\": { \"%s\": \"%s\", \"%s\": [ { \"%s\": \"%s\", \"%s\": \"%s\" } ] } }", + "name", n, + "version", v, + "description", d, + "publisher", a, + "suspend", + "links", + "publish", "https://feed.onap.org/publish/22", + "subscribe" , Feed.getSubProvURL( "22" ), + "log" , "https://feed.onap.org/log/22", + "authorization", + "classification", a, + "endpoint_ids" , "id", "king", "password", "henry" ); + + + Feed t = new Feed( s ); + + assertTrue( n.equals( t.getFeedName() )); + assertTrue( v.equals( t.getFeedVersion() )); + assertTrue( d.equals( t.getFeedDescription() )); + assertTrue( a.equals( t.getAsprClassification() ) ); + assertTrue( ! t.isSuspended() ); + + String o = t.toString(); + + } + } diff --git a/src/test/java/org/onap/dmaap/dbcapi/model/MR_ClusterTest.java b/src/test/java/org/onap/dmaap/dbcapi/model/MR_ClusterTest.java new file mode 100644 index 0000000..ac7f9c4 --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/model/MR_ClusterTest.java @@ -0,0 +1,95 @@ +/*- + * ============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.model; + +import static org.junit.Assert.*; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +public class MR_ClusterTest { + String d, fqdn, a; + + ReflectionHarness rh = new ReflectionHarness(); + + @Before + public void setUp() throws Exception { + d = "central-onap"; + fqdn = "mr.onap.org"; + a = "ignore"; + } + + @After + public void tearDown() throws Exception { + } + + + @Test + public void testMR_ClusterClassDefaultConstructor() { + + MR_Cluster t = new MR_Cluster(); + + assertTrue( t.getDcaeLocationName() == null ); + assertTrue( t.getFqdn() == null ); + + } + + @Test + public void testMR_ClusterClassConstructor() { + + String[] h = { "host1", "host2", "host3" }; + MR_Cluster t = new MR_Cluster( d, fqdn, a, h ); + + t.getHosts(); + + assertTrue( t.getDcaeLocationName() == d ); + assertTrue( t.getFqdn() == fqdn ); + } + + @Test + public void testw3() { + + MR_Cluster t = new MR_Cluster(); + String[] h = { "host1", "host2", "host3" }; + t.setHosts( h ); + + assertTrue( t.getDcaeLocationName() == null ); + assertTrue( t.getFqdn() == null ); + + String fqtn = t.genTopicURL( "cluster2.onap.org", "org.onap.topic2" ); + } + + + + @Test + public void testsetter() { + + String v = "validate"; + + + rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Cluster", "set", v ); + + } + +} diff --git a/src/test/java/org/onap/dmaap/dbcapi/model/MirrorMakerTest.java b/src/test/java/org/onap/dmaap/dbcapi/model/MirrorMakerTest.java index 1949820..6c35b93 100644 --- a/src/test/java/org/onap/dmaap/dbcapi/model/MirrorMakerTest.java +++ b/src/test/java/org/onap/dmaap/dbcapi/model/MirrorMakerTest.java @@ -25,6 +25,8 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import java.util.ArrayList; + public class MirrorMakerTest { @@ -32,12 +34,9 @@ public class MirrorMakerTest { ReflectionHarness rh = new ReflectionHarness(); - String s, t; @Before public void setUp() throws Exception { - s = "source"; - t = "target"; } @After @@ -52,21 +51,52 @@ public class MirrorMakerTest { rh.reflect( "org.onap.dmaap.dbcapi.model.MirrorMaker", "get", null ); } - @Test public void test2() { - MirrorMaker m = new MirrorMaker( s, t ); - - assertTrue( s.equals( m.getSourceCluster() )); - assertTrue( t.equals( m.getTargetCluster() )); + String v = "Validate"; + rh.reflect( "org.onap.dmaap.dbcapi.model.MirrorMaker", "set", v ); } @Test public void test3() { + String f = "org.onap.interestingTopic"; + String c1 = "cluster1.onap.org"; + String c2 = "cluster2.onap.org"; + MirrorMaker t = new MirrorMaker( c1, c2 ); + String m = t.getMmName(); + + MirrorMaker.genKey( c1, c2 ); + + assertTrue( c1.equals( t.getSourceCluster() )); + assertTrue( c2.equals( t.getTargetCluster() )); + } + + + @Test + public void test4() { + String f = "org.onap.interestingTopic"; + String c1 = "cluster1.onap.org"; + String c2 = "cluster2.onap.org"; + MirrorMaker t = new MirrorMaker( c1, c2 ); + String m = t.getMmName(); + + t.addVector( f, c1, c2 ); + ArrayList<String> topics = new ArrayList<String>(); + topics.add( f ); + t.setTopics( topics ); + t.addTopic( "org.onap.topic2" ); + + int i = t.getTopicCount(); + + String s = t.toJSON(); + + s = t.updateWhiteList(); + + s = t.createMirrorMaker(); + + t.delVector( f, c1, c2 ); - String v = "Validate"; - rh.reflect( "org.onap.dmaap.dbcapi.model.MirrorMaker", "set", v ); } } diff --git a/src/test/java/org/onap/dmaap/dbcapi/model/ReplicationVectorTest.java b/src/test/java/org/onap/dmaap/dbcapi/model/ReplicationVectorTest.java new file mode 100644 index 0000000..0655b75 --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/model/ReplicationVectorTest.java @@ -0,0 +1,91 @@ +/*- + * ============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.model; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.util.ArrayList; + + +public class ReplicationVectorTest { + + private static final String fmt = "%24s: %s%n"; + + ReflectionHarness rh = new ReflectionHarness(); + + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + + @Test + public void test1() { + + + rh.reflect( "org.onap.dmaap.dbcapi.model.ReplicationVector", "get", null ); + + } + @Test + public void test2() { + + String v = "Validate"; + rh.reflect( "org.onap.dmaap.dbcapi.model.ReplicationVector", "set", v ); + } + + @Test + public void test3() { + String f = "org.onap.interestingTopic"; + String c1 = "cluster1.onap.org"; + String c2 = "cluster2.onap.org"; + ReplicationVector t = new ReplicationVector( f, c1, c2 ); + + + assertTrue( f.equals( t.getFqtn() )); + assertTrue( c1.equals( t.getSourceCluster() )); + assertTrue( c2.equals( t.getTargetCluster() )); + } + + + @Test + public void test4() { + String f = "org.onap.interestingTopic"; + String c1 = "cluster1.onap.org"; + String c2 = "cluster2.onap.org"; + ReplicationVector t = new ReplicationVector( f, c1, c2 ); + + int i = t.hashCode(); + + ReplicationVector t2 = new ReplicationVector(f, c1, c2 ); + + assertTrue( t.equals( t2 )); + assertTrue( t.equals( t )); + assertTrue( ! t.equals( f )); + } + +} diff --git a/src/test/java/org/onap/dmaap/dbcapi/resource/DcaeLocationResourceTest.java b/src/test/java/org/onap/dmaap/dbcapi/resource/DcaeLocationResourceTest.java new file mode 100644 index 0000000..dd2525f --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/resource/DcaeLocationResourceTest.java @@ -0,0 +1,90 @@ +/*- + * ============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.resources; +import org.onap.dmaap.dbcapi.model.*; +import org.onap.dmaap.dbcapi.service.*; +import static org.junit.Assert.*; + +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; + + +public class DcaeLocationResourceTest extends JerseyTest { + + static DmaapObjectFactory factory = new DmaapObjectFactory(); + + @Override + protected Application configure() { + 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 { + } +*/ + + + + @Test + public void GetTest() { + Response resp = target( "dcaeLocations").request().get( Response.class ); + System.out.println( "GET feed resp=" + resp.getStatus() ); + + assertTrue( resp.getStatus() == 200 ); + } + @Test + public void PostTest() { + DcaeLocation loc = factory.genDcaeLocation( "central" ); + Entity<DcaeLocation> reqEntity = Entity.entity( loc, MediaType.APPLICATION_JSON ); + Response resp = target( "dcaeLocations").request().post( reqEntity, Response.class ); + System.out.println( "POST dcaeLocation resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) ); + assertTrue( resp.getStatus() == 201 ); + } + + @Test + public void PutTest() { + } + + + + +} + diff --git a/src/test/java/org/onap/dmaap/dbcapi/resource/DmaapResourceTest.java b/src/test/java/org/onap/dmaap/dbcapi/resource/DmaapResourceTest.java new file mode 100644 index 0000000..4f8f602 --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/resource/DmaapResourceTest.java @@ -0,0 +1,98 @@ +/*- + * ============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.resources; +import org.onap.dmaap.dbcapi.model.*; +import org.onap.dmaap.dbcapi.service.*; +import static org.junit.Assert.*; + +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; + + +public class DmaapResourceTest extends JerseyTest { + + static DmaapObjectFactory factory = new DmaapObjectFactory(); + + @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 ); + assertTrue( resp.getStatus() == 200 ); + } + @Test + public void PostTest() { + + Dmaap dmaap = factory.genDmaap(); + Entity<Dmaap> reqEntity = Entity.entity( dmaap, MediaType.APPLICATION_JSON ); + Response resp = target( "dmaap").request().post( reqEntity, Response.class ); + System.out.println( resp.getStatus() ); + assertTrue( resp.getStatus() == 200 ); + } + + @Test + public void PutTest() { + + Dmaap dmaap = factory.genDmaap(); + Entity<Dmaap> reqEntity = Entity.entity( dmaap, MediaType.APPLICATION_JSON ); + + dmaap.setVersion( "2" ); + Response resp = target( "dmaap").request().put( reqEntity, Response.class ); + System.out.println( resp.getStatus() ); + assertTrue( resp.getStatus() == 200 ); + } + + + + +} + diff --git a/src/test/java/org/onap/dmaap/dbcapi/resource/FeedResourceTest.java b/src/test/java/org/onap/dmaap/dbcapi/resource/FeedResourceTest.java new file mode 100644 index 0000000..89dca8a --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/resource/FeedResourceTest.java @@ -0,0 +1,104 @@ +/*- + * ============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.resources; +import org.onap.dmaap.dbcapi.model.*; +import org.onap.dmaap.dbcapi.service.*; +import static org.junit.Assert.*; + +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; + + +public class FeedResourceTest extends JerseyTest { + + @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 ); + System.out.println( "GET feed resp=" + resp.getStatus() ); + + assertTrue( resp.getStatus() == 200 ); + } + @Test + public void PostTest() { + Feed feed = new Feed( "aPostTest", "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() ); + 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/src/test/java/org/onap/dmaap/dbcapi/resource/InfoResourceTest.java b/src/test/java/org/onap/dmaap/dbcapi/resource/InfoResourceTest.java new file mode 100644 index 0000000..3f57f58 --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/resource/InfoResourceTest.java @@ -0,0 +1,71 @@ +/*- + * ============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.resources; +import org.onap.dmaap.dbcapi.model.*; +import org.onap.dmaap.dbcapi.service.*; +import static org.junit.Assert.*; + +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; + + +public class InfoResourceTest extends JerseyTest { + + @Override + 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 { + } + + @After + public void tearDown() throws Exception { + } +*/ + + + + @Test + public void GetTest() { + Response resp = target( "info").request().get( Response.class ); + assertTrue( resp.getStatus() == 204 ); + } + +} + diff --git a/src/test/java/org/onap/dmaap/dbcapi/resource/MR_ClusterResourceTest.java b/src/test/java/org/onap/dmaap/dbcapi/resource/MR_ClusterResourceTest.java new file mode 100644 index 0000000..1f78c3f --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/resource/MR_ClusterResourceTest.java @@ -0,0 +1,127 @@ +/*- + * ============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.resources; +import org.onap.dmaap.dbcapi.model.*; +import org.onap.dmaap.dbcapi.service.*; +import static org.junit.Assert.*; + +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; + + +public class MR_ClusterResourceTest extends JerseyTest { + + static DmaapObjectFactory factory = new DmaapObjectFactory(); + + @Override + protected Application configure() { + return new ResourceConfig( MR_ClusterResource.class ); + } + + private static final String fmt = "%24s: %s%n"; + + + +/* may conflict with test framework! + @Before + public void preTest() throws Exception { + } + + @After + public void tearDown() throws Exception { + } +*/ + + + @Test + public void GetTest() { + Response resp = target( "mr_clusters").request().get( Response.class ); + System.out.println( "GET feed resp=" + resp.getStatus() ); + + assertTrue( resp.getStatus() == 200 ); + } + @Test + public void PostTest() { + MR_Cluster cluster = factory.genMR_Cluster( "central" ); + Entity<MR_Cluster> reqEntity = Entity.entity( cluster, MediaType.APPLICATION_JSON ); + Response resp = target( "mr_clusters").request().post( reqEntity, Response.class ); + System.out.println( "POST MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) ); + assertTrue( resp.getStatus() == 201 ); + } + + @Test + public void PutTest() { +/* + try { + DcaeLocation loc = factory.genDcaeLocation( "central" ); + Entity<DcaeLocation> reqEntity = Entity.entity( loc, MediaType.APPLICATION_JSON ); + Response resp = target( "dcaeLocations").request().post( reqEntity, Response.class ); + System.out.println( "POST dcaeLocation resp=" + resp.getStatus() + " " + resp.readEntity( String.class )); + assertTrue( resp.getStatus() == 201 ); + } catch (Exception e ) { + } +*/ + String h[] = {"host4", "host5", "host6" }; + MR_Cluster cluster = factory.genMR_Cluster( "edge" ); + Entity<MR_Cluster> reqEntity = Entity.entity( cluster, MediaType.APPLICATION_JSON ); + Response resp = target( "mr_clusters").request().post( reqEntity, Response.class ); + + // first, add it + System.out.println( "POST MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) ); + assertTrue( resp.getStatus() == 201 ); + + // now change a field + cluster.setHosts( h ); + reqEntity = Entity.entity( cluster, MediaType.APPLICATION_JSON ); + + // update with incorrect key + resp = target( "mr_clusters") + .path( cluster.getFqdn()) + .request() + .put( reqEntity, Response.class ); + System.out.println( "PUT MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity(String.class)); + assertTrue( resp.getStatus() == 404 ); + + // update with correct key + resp = target( "mr_clusters") + .path( cluster.getDcaeLocationName()) + .request() + .put( reqEntity, Response.class ); + System.out.println( "PUT MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity(String.class)); + assertTrue( resp.getStatus() == 200 ); + } + + + + +} + diff --git a/src/test/java/org/onap/dmaap/dbcapi/server/JettyServerTest.java b/src/test/java/org/onap/dmaap/dbcapi/server/JettyServerTest.java new file mode 100644 index 0000000..26ba3a6 --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/server/JettyServerTest.java @@ -0,0 +1,80 @@ +/*- + * ============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.model.*; +import org.onap.dmaap.dbcapi.util.DmaapConfig; +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.List; +import java.util.ArrayList; +import java.util.Properties; + +public class JettyServerTest { + + private static final String fmt = "%24s: %s%n"; + + ReflectionHarness rh = new ReflectionHarness(); + + + JettyServer m = null; + + @Before + public void setUp() throws Exception { + Properties p = DmaapConfig.getConfig(); + try { + m = new JettyServer(p); + } catch (Exception e ) { + } + } + + @After + public void tearDown() throws Exception { + try { + m.getServer().stop(); + } catch (Exception e ) { + } + } + + + @Test + public void test1() { + + + 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/src/test/java/org/onap/dmaap/dbcapi/server/MainTest.java b/src/test/java/org/onap/dmaap/dbcapi/server/MainTest.java new file mode 100644 index 0000000..496a93d --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/server/MainTest.java @@ -0,0 +1,79 @@ +/*- + * ============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.model.*; +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.List; +import java.util.ArrayList; + +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/src/test/java/org/onap/dmaap/dbcapi/service/ApiServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/ApiServiceTest.java new file mode 100644 index 0000000..e429fbd --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/service/ApiServiceTest.java @@ -0,0 +1,90 @@ +/*- + * ============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.service; +import org.onap.dmaap.dbcapi.model.*; +import org.onap.dmaap.dbcapi.aaf.*; +import org.onap.dmaap.dbcapi.resources.*; +import org.onap.dmaap.dbcapi.aaf.authentication.AuthenticationErrorException; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.List; +import javax.ws.rs.core.Response; + +public class ApiServiceTest { + + private static final String fmt = "%24s: %s%n"; + + ReflectionHarness rh = new ReflectionHarness(); + + ApiService ds; + + @Before + public void setUp() throws Exception { + ds = new ApiService(); + } + + @After + 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"; + rh.reflect( "org.onap.dmaap.dbcapi.service.ApiService", "set", v ); + + } + + @Test + public void test3() { + ApiService nd = new ApiService(); + nd.setAuth( "auth" ); + try { + nd.required( "aName", null, "anExpr" ); + } catch ( RequiredFieldException rfe ) { + } + String out = nd.toString(); + Response r = nd.unauthorized( "aMessage" ); + r = nd.unauthorized(); + r = nd.unavailable(); + r = nd.notFound(); + r = nd.error(); + try { + nd.checkAuthorization( "authval", "/uri/Path", "GET" ); + nd.checkAuthorization(); + } catch ( AuthenticationErrorException aee ) { + } catch ( Exception e ) { + } + } + + +} diff --git a/src/test/java/org/onap/dmaap/dbcapi/service/DR_NodeServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/DR_NodeServiceTest.java new file mode 100644 index 0000000..4f92bcd --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/service/DR_NodeServiceTest.java @@ -0,0 +1,126 @@ +/*- + * ============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.service; +import org.onap.dmaap.dbcapi.model.*; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.List; +import java.util.ArrayList; + +public class DR_NodeServiceTest { + + private static final String fmt = "%24s: %s%n"; + + ReflectionHarness rh = new ReflectionHarness(); + + DR_NodeService ns; + + @Before + public void setUp() throws Exception { + ns = new DR_NodeService(); + } + + @After + public void tearDown() throws Exception { + } + + + @Test + public void test1() { + + + 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 + public void test3() { + String f = "drsn01.onap.org"; + String locname = "central-demo"; + + DcaeLocationService dls = new DcaeLocationService(); + DcaeLocation loc = new DcaeLocation( "CLLI1234", "central-onap", locname, "aZone", "10.10.10.0/24" ); + dls.addDcaeLocation( loc ); + + ApiError err = new ApiError(); + DR_Node node = new DR_Node( f, locname, "zplvm009.onap.org", "1.0.46" ); + DR_Node n2 = ns.addDr_Node( node, err ); + + if ( n2 != null ) { + n2 = ns.getDr_Node( f, err ); + } + + List<DR_Node> l = ns.getAllDr_Nodes(); + if ( n2 != null ) { + n2.setVersion( "1.0.47" ); + n2 = ns.updateDr_Node( n2, err ); + } + + n2 = ns.removeDr_Node( 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/src/test/java/org/onap/dmaap/dbcapi/service/DcaeLocationServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/DcaeLocationServiceTest.java new file mode 100644 index 0000000..e8c7229 --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/service/DcaeLocationServiceTest.java @@ -0,0 +1,96 @@ +/*- + * ============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.service; +import org.onap.dmaap.dbcapi.model.*; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.List; + +public class DcaeLocationServiceTest { + + private static final String fmt = "%24s: %s%n"; + + ReflectionHarness rh = new ReflectionHarness(); + + DcaeLocationService ds; + + @Before + public void setUp() throws Exception { + ds = new DcaeLocationService(); + } + + @After + public void tearDown() throws Exception { + } + + + @Test + public void test1() { + + + //rh.reflect( "org.onap.dmaap.dbcapi.service.DcaeLocationService", "get", null ); + + } + + @Test + public void test2() { + String v = "Validate"; + rh.reflect( "org.onap.dmaap.dbcapi.service.DcaeLocationService", "set", v ); + + } + + @Test + public void test3() { + String n = "demo-network-c"; + DcaeLocation nd = new DcaeLocation( "CLLI0123", "central-layer", n, "zoneA", "10.10.10.0/24" ); + + DcaeLocation gd = ds.addDcaeLocation( nd ); + + assertTrue( nd.getDcaeLocationName().equals( gd.getDcaeLocationName() )); + } + + @Test + public void test4() { + List<DcaeLocation> d = ds.getAllDcaeLocations(); + + } + + @Test + public void test5() { + String n = "demo-network-c"; + DcaeLocation nd = new DcaeLocation( "CLLI9999", "central-layer", n, "zoneA", "10.10.10.0/24" ); + DcaeLocation gd = ds.updateDcaeLocation( nd ); + + assertTrue( nd.getDcaeLocationName().equals( gd.getDcaeLocationName() )); + + } + + @Test + public void test6() { + + String n = "demo-network-c"; + DcaeLocation gd = ds.removeDcaeLocation( n ); + } + +} diff --git a/src/test/java/org/onap/dmaap/dbcapi/service/DmaapServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/DmaapServiceTest.java new file mode 100644 index 0000000..e40488e --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/service/DmaapServiceTest.java @@ -0,0 +1,93 @@ +/*- + * ============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.service; +import org.onap.dmaap.dbcapi.model.*; +import org.onap.dmaap.dbcapi.aaf.*; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.List; + +public class DmaapServiceTest { + + private static final String fmt = "%24s: %s%n"; + + ReflectionHarness rh = new ReflectionHarness(); + + DmaapService ds; + + @Before + public void setUp() throws Exception { + 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 + public void test3() { + Dmaap nd = new Dmaap( "1", "org.onap.dmaap", "onap-demo", "drps.demo.onap.org", "", "MMAGENT_TOPIC", "", "" ); + ds.addDmaap( nd ); + } + + @Test + public void test4() { + Dmaap d = ds.getDmaap(); + + } + + @Test + public void test5() { + Dmaap nd = new Dmaap( "2", "org.onap.dmaap", "onap-demo", "drps.demo.onap.org", "", "MMAGENT_TOPIC", "", "" ); + ds.updateDmaap( nd ); + + } + + @Test + public void test6() { + String t = ds.getTopicPerm(); + String t2 = ds.getTopicPerm( "val2" ); + String t3 = ds.getBridgeAdminFqtn(); + + boolean b = ds.testCreateMmaTopic(); + + } + +} diff --git a/src/test/java/org/onap/dmaap/dbcapi/service/Dr_PubServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/Dr_PubServiceTest.java new file mode 100644 index 0000000..5c93dbf --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/service/Dr_PubServiceTest.java @@ -0,0 +1,108 @@ +/*- + * ============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.service; +import org.onap.dmaap.dbcapi.model.*; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.List; +import java.util.ArrayList; + +public class Dr_PubServiceTest { + + private static final String fmt = "%24s: %s%n"; + + ReflectionHarness rh = new ReflectionHarness(); + + DR_PubService ns; + FeedService fs; + + @Before + public void setUp() throws Exception { + 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 ); + + } + + @Test + public void test2() { + String v = "Validate"; + rh.reflect( "org.onap.dmaap.dbcapi.service.DR_PubService", "set", v ); + + } + + @Test + public void test3() { + String locname = "central-demo"; + + DcaeLocationService dls = new DcaeLocationService(); + DcaeLocation loc = new DcaeLocation( "CLLI1234", "central-onap", locname, "aZone", "10.10.10.0/24" ); + dls.addDcaeLocation( loc ); + + ApiError err = new ApiError(); + Feed f = new Feed( "aTest", "1.0", "a unit test", "dgl", "unrestricted" ); + f = fs.addFeed( f, err ); +/* +TODO: make this not be null... + assertTrue( f != null ); + DR_Pub node = new DR_Pub( locname, "aUser", "aPwd", f.getFeedId(), "pubId01" ); + DR_Pub n2 = ns.addDr_Pub( node ); + DR_Pub node2 = new DR_Pub( locname, "aUser", "aPwd", f.getFeedId() ); + n2 = ns.addDr_Pub( node2 ); + + if ( n2 != null ) { + n2 = ns.getDr_Pub( n2.getPubId(), err ); + } + + List<DR_Pub> l = ns.getAllDr_Pubs(); + if ( n2 != null ) { + n2 = ns.updateDr_Pub( n2 ); + } + + n2 = ns.removeDr_Pub( n2.getPubId(), err ); +*/ + + + } + + @Test + public void test4() { + ArrayList<DR_Pub> l = ns.getDr_PubsByFeedId( "1" ); + + + } + + +} diff --git a/src/test/java/org/onap/dmaap/dbcapi/service/FeedServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/FeedServiceTest.java new file mode 100644 index 0000000..832237e --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/service/FeedServiceTest.java @@ -0,0 +1,97 @@ +/*- + * ============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.service; +import org.onap.dmaap.dbcapi.model.*; +import org.onap.dmaap.dbcapi.aaf.*; +import org.onap.dmaap.dbcapi.resources.*; +import org.onap.dmaap.dbcapi.aaf.authentication.AuthenticationErrorException; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.List; +import javax.ws.rs.core.Response; + +public class FeedServiceTest { + + private static final String fmt = "%24s: %s%n"; + + ReflectionHarness rh = new ReflectionHarness(); + + FeedService ds; + + @Before + public void setUp() throws Exception { + ds = new FeedService(); + } + + @After + public void tearDown() throws Exception { + } + + + @Test + public void test1() { + + + 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 + public void test3() { + ApiError err = new ApiError(); + + Feed f = new Feed( "aTest", "1.0", "a unit test", "dgl", "unrestricted" ); + f = ds.addFeed( f, err ); + System.out.println( "f=" + f ); + + ds.updateFeed( f, err ); + + ds.removeFeed( f, err ); + } + + @Test + public void test4() { + ApiError err = new ApiError(); + Feed f = ds.getFeed( "aName", err ); + + f = ds.getFeedByName( "aName", "1.0", err ); + + f = ds.getFeedPure( "aName", err ); + } + + @Test + public void test5() { + List<Feed> f = ds.getAllFeeds( "aName", "1.0", "startsWith" ); + + } + + +} diff --git a/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClientServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClientServiceTest.java new file mode 100644 index 0000000..470ca6c --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClientServiceTest.java @@ -0,0 +1,127 @@ +/*- + * ============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.service; +import org.onap.dmaap.dbcapi.model.*; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.List; +import java.util.ArrayList; + +public class MR_ClientServiceTest { + + private static final String fmt = "%24s: %s%n"; + + private static DmaapObjectFactory factory = new DmaapObjectFactory(); + + ReflectionHarness rh = new ReflectionHarness(); + + private TopicService ts; + private MR_ClusterService mcs; + private MR_ClientService cls; + private DcaeLocationService dls; + + private String f; + private String locname; + + @Before + public void setUp() throws Exception { + ts = new TopicService(); + mcs = new MR_ClusterService(); + cls = new MR_ClientService(); + f = "mrsn01.onap.org"; + locname = "central-demo"; + + dls = new DcaeLocationService(); + DcaeLocation loc = factory.genDcaeLocation( "central" ); + dls.addDcaeLocation( loc ); + + ApiError err = new ApiError(); + String[] h = { "zplvm009.onap.org", "zplvm007.onap.org", "zplvm008.onap.org" }; + MR_Cluster node = factory.genMR_Cluster( "central" ); + 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 ); + + } + + @Test + public void test2() { + String v = "Validate"; + rh.reflect( "org.onap.dmaap.dbcapi.service.MR_ClientService", "set", v ); + + } + + @Test + public void test3() { + Topic topic = factory.genSimpleTopic( "test3" ); + ApiError err = new ApiError(); + Topic nTopic = ts.addTopic( topic, err ); + if ( nTopic != null ) { + assertTrue( nTopic.getTopicName().equals( topic.getTopicName() )); + } + String[] actions = { "pub", "view" }; + MR_Client c = factory.genPublisher( "edge", topic.getFqtn() ); + + c = cls.addMr_Client( c, topic, 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 = factory.genSimpleTopic( "test5" ); + ApiError err = new ApiError(); + Topic nTopic = ts.addTopic( topic, err ); + if ( nTopic != null ) { + assertTrue( nTopic.getTopicName().equals( topic.getTopicName() )); + } + MR_Client c = factory.genPublisher( "edge", topic.getFqtn() ); + + c = cls.addMr_Client( c, topic, err ); + if ( c != null ) { + c = factory.genSubscriber( "edge", topic.getFqtn() ); + c = cls.updateMr_Client( c, err ); + assertTrue( err.getCode() == 200 ); + } + } + +} diff --git a/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClusterServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClusterServiceTest.java new file mode 100644 index 0000000..cbf9931 --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClusterServiceTest.java @@ -0,0 +1,126 @@ +/*- + * ============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.service; +import org.onap.dmaap.dbcapi.model.*; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.List; +import java.util.ArrayList; + +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 { + 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 ); + + } + + @Test + public void test2() { + String v = "Validate"; + rh.reflect( "org.onap.dmaap.dbcapi.service.MR_ClusterService", "set", v ); + + } + + @Test + public void test3() { + String f = "mrsn01.onap.org"; + String locname = "central-demo"; + + DcaeLocationService dls = new DcaeLocationService(); + DcaeLocation loc = new DcaeLocation( "CLLI1234", "central-onap", locname, "aZone", "10.10.10.0/24" ); + dls.addDcaeLocation( loc ); + + ApiError err = new ApiError(); + String[] h = { "zplvm009.onap.org", "zplvm007.onap.org", "zplvm008.onap.org" }; + MR_Cluster node = new MR_Cluster( locname, f, "ignore", h ); + MR_Cluster n2 = ns.addMr_Cluster( node, err ); + + if ( n2 != null ) { + n2 = ns.getMr_Cluster( f, err ); + } + + List<MR_Cluster> l = ns.getAllMr_Clusters(); + 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/src/test/java/org/onap/dmaap/dbcapi/service/TopicServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/TopicServiceTest.java index 0d39350..5757522 100644 --- a/src/test/java/org/onap/dmaap/dbcapi/service/TopicServiceTest.java +++ b/src/test/java/org/onap/dmaap/dbcapi/service/TopicServiceTest.java @@ -26,6 +26,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import java.util.List; +import java.util.ArrayList; public class TopicServiceTest { @@ -34,10 +35,13 @@ public class TopicServiceTest { ReflectionHarness rh = new ReflectionHarness(); TopicService ts; + MR_ClusterService mcs; + String locname = "central-onap"; @Before public void setUp() throws Exception { ts = new TopicService(); + mcs = new MR_ClusterService(); } @After @@ -75,26 +79,62 @@ public class TopicServiceTest { } @Test + public void test3a() { + Topic topic = new Topic(); + ApiError err = new ApiError(); + topic.setTopicName( "test3" ); + topic.setFqtnStyle( FqtnType.Validator("none") ); + topic.getFqtn(); + String t = "org.onap.dmaap.interestingTopic"; + String f = "mrc.onap.org:3904/events/org.onap.dmaap.interestingTopic"; + String c = "publisher"; + String[] a = { "sub", "view" }; + MR_Client sub = new MR_Client( locname, f, c, a ); + String[] b = { "pub", "view" }; + MR_Client pub = new MR_Client( "edge", f, c, b ); + ArrayList<MR_Client> clients = new ArrayList<MR_Client>(); + + clients.add( sub ); + clients.add( pub ); + + topic.setClients( clients ); + + ts.reviewTopic( topic ); + ts.checkForBridge( topic, err ); + + Topic nTopic = ts.addTopic( topic, err ); + if ( nTopic != null ) { + assertTrue( nTopic.getTopicName().equals( topic.getTopicName() )); + } + + + ts.removeTopic( "test3", err ); + } + + @Test public void test4() { List<Topic> l = ts.getAllTopics(); } -/* @Test public void test5() { - Topic topic = new Topic(); ApiError err = new ApiError(); +/* + +TODO: find a null pointer in here... + String[] hl = { "host1", "host2", "host3" }; + String loc = "central-onap"; + MR_Cluster cluster = new MR_Cluster( loc, "localhost", "", hl ); + mcs.addMr_Cluster( cluster, err ); + Topic topic = new Topic(); topic.setTopicName( "test5" ); topic.setFqtnStyle( FqtnType.Validator("none") ); topic.setReplicationCase( ReplicationType.Validator("none") ); - topic.getFqtn(); + String f = topic.getFqtn(); Topic nTopic = ts.updateTopic( topic, err ); - if ( nTopic != null ) { - assertTrue( nTopic.getTopicName().equals( topic.getTopicName() )); - } - - } */ + assertTrue( err.getCode() == 0 ); + } } diff --git a/src/test/java/org/onap/dmaap/dbcapi/testframework/DmaapObjectFactory.java b/src/test/java/org/onap/dmaap/dbcapi/testframework/DmaapObjectFactory.java new file mode 100644 index 0000000..18a397f --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/testframework/DmaapObjectFactory.java @@ -0,0 +1,122 @@ +/* + * ============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.model; + +import static org.junit.Assert.*; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Type; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static java.lang.System.out; +import static java.lang.System.err; + +public class DmaapObjectFactory { + + /* + * we use localhost for most references so that connection attempts will resolve and not retry + * but still we expect that requests will fail. + */ + private static final String fmt = "%24s: %s%n"; + private static final String dmaap_name = "onap-ut"; + private static final String dmaap_ver = "1"; + private static final String dmaap_topic_root = "org.onap.dmaap"; + private static final String dmaap_dr = "https://localhost:8443"; + private static final String dmaap_log_url = "http://localhost:8080/log"; + private static final String dmaap_mm_topic = "org.onap.dmaap.dcae.MM_AGENT_TOPIC"; + private static final String central_loc = "SanFrancisco"; + private static final String central_layer = "central-cloud"; + private static final String central_clli = "SFCAL19240"; + private static final String central_zone = "osaz01"; + private static final String central_subnet = "10.10.10.0/24"; + private static final String central_cluster_fqdn = "localhost"; + private static final String pub_role = "org.onap.vnfapp.publisher"; + private static final String sub_role = "org.onap.vnfapp.subscriber"; + private static final String edge_loc = "Atlanta"; + private static final String edge_layer = "edge-cloud"; + private static final String edge_clli = "ATLGA10245"; + private static final String edge_zone = "osaz02"; + private static final String edge_subnet = "10.10.20.0/24"; + private static final String edge_cluster_fqdn = "localhost"; + private static final String[]hosts = { "host1", "host2", "host3" }; + + public Dmaap genDmaap() { + return new Dmaap( dmaap_ver, dmaap_topic_root, dmaap_name, dmaap_dr, dmaap_log_url, dmaap_mm_topic, "nk", "ako" ); + } + + public DcaeLocation genDcaeLocation( String layer ) { + if ( layer.contains( "edge" ) ) { + return new DcaeLocation( edge_clli, edge_layer, edge_loc, edge_zone, edge_subnet ); + } + return new DcaeLocation( central_clli, central_layer, central_loc, central_zone, central_subnet ); + } + + + public MR_Cluster genMR_Cluster( String layer ) { + if ( layer.contains( "edge" ) ) { + return new MR_Cluster( edge_loc, edge_cluster_fqdn, "ignore", hosts ); + } + return new MR_Cluster( central_loc, central_cluster_fqdn, "ignore", hosts ); + } + + public Topic genSimpleTopic( String tname ) { + Topic t = new Topic(); + t.setTopicName( tname ); + t.setFqtnStyle( FqtnType.Validator("none") ); + t.getFqtn(); + return t; + } + + public MR_Client genMR_Client( String l, String f, String r, String[] a ) { + if ( l.contains( "edge" ) ) { + return new MR_Client( edge_loc, f, r, a ); + } + return new MR_Client( central_loc, f, r, a ); + } + + public MR_Client genPublisher( String layer, String fqtn ) { + String[] actions = { "pub", "view" }; + return genMR_Client( layer, fqtn, pub_role, actions ); + } + public MR_Client genSubscriber( String layer, String fqtn ) { + String[] actions = { "sub", "view" }; + return genMR_Client( layer, fqtn, sub_role, actions ); + } + + public DR_Sub genDrSub( String l, String feed ) { + String un = "user1"; + String up = "secretW0rd"; + String du = "sub.server.onap.org:8443/deliver/here"; + String lu = "https://drps.onap.org:8443/sublog/123"; + boolean u100 = true; + + if ( l.contains( "edge" ) ) { + return new DR_Sub( edge_loc, un, up, feed, du, lu, u100 ); + } + return new DR_Sub( central_loc, un, up, feed, du, lu, u100 ); + } + + +} diff --git a/src/test/java/org/onap/dmaap/dbcapi/model/ReflectionHarness.java b/src/test/java/org/onap/dmaap/dbcapi/testframework/ReflectionHarness.java index 76167ce..8f70eca 100644 --- a/src/test/java/org/onap/dmaap/dbcapi/model/ReflectionHarness.java +++ b/src/test/java/org/onap/dmaap/dbcapi/testframework/ReflectionHarness.java @@ -52,10 +52,10 @@ public class ReflectionHarness { } private void testGetter( Class<?> c, Method m, Class<?>[] pType, String val ) { - //out.format( fmt, "testGetter: Method Name", m.getName() ); + out.format( fmt, "testGetter: Method Name", m.getName() ); Class retType = m.getReturnType(); - //out.format( fmt, "testGetter: Return Type ", retType ); - //out.format( fmt, "testGetter: val ", (val != null)?val:"null" ); + out.format( fmt, "testGetter: Return Type ", retType ); + out.format( fmt, "testGetter: val ", (val != null)?val:"null" ); assertTrue( pType.length == 0 ); try { @@ -67,10 +67,10 @@ public class ReflectionHarness { if( retType.equals( Class.forName( "java.lang.String" ) ) ) { if ( val == null ) { - //out.format( fmt, "testGetter: expected null, got ", (o != null)?o:"null" ); + out.format( fmt, "testGetter: expected null, got ", (o != null)?o:"null" ); assert( o == null ); } else { - //out.format( fmt, "testGetter: expected val, got ", (o != null)?o:"null" ); + out.format( fmt, "testGetter: expected val, got ", (o != null)?o:"null" ); assert( o.equals( val ) ); } } else { diff --git a/src/test/java/org/onap/dmaap/dbcapi/util/DmaapConfigTest.java b/src/test/java/org/onap/dmaap/dbcapi/util/DmaapConfigTest.java new file mode 100644 index 0000000..29de17d --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/util/DmaapConfigTest.java @@ -0,0 +1,73 @@ +/*- + * ============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.util; +import org.onap.dmaap.dbcapi.model.*; +import org.onap.dmaap.dbcapi.service.*; +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.*; +import java.sql.*; + +public class DmaapConfigTest { + + private static final String fmt = "%24s: %s%n"; + + ReflectionHarness rh = new ReflectionHarness(); + + DmaapConfig g; + + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + + @Test + public void test1() { + + + 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(); + } + + + +} + diff --git a/src/test/java/org/onap/dmaap/dbcapi/util/GraphTest.java b/src/test/java/org/onap/dmaap/dbcapi/util/GraphTest.java new file mode 100644 index 0000000..2d5b429 --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/util/GraphTest.java @@ -0,0 +1,100 @@ +/*- + * ============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.util; +import org.onap.dmaap.dbcapi.model.*; +import org.onap.dmaap.dbcapi.service.*; +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.*; +import java.sql.*; + +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>(); + 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 ); + + } + + @Test + public void test3() { + String loc = "central-onap"; + String[] actions = { "pub", "sub" }; + DcaeLocationService dls = new DcaeLocationService(); + DcaeLocation dl = new DcaeLocation( "CLLI123", "central-layer", loc, "aZone", "10.10.10.10" ); + dls.addDcaeLocation( dl ); + MR_Client mrc = new MR_Client(); + mrc.setAction( actions ); + List<MR_Client> cl = new ArrayList<MR_Client>(); + cl.add( mrc ); + cl.add( new MR_Client( loc, "aTopic", "ignore", actions ) ); + + g = new Graph( cl, true ); + + HashMap<String, String> hm = new HashMap<String, String>(); + + + String s = g.put( "aKey", "aVal" ); + s = g.get( "aKey" ); + + s = g.getCentralLoc(); + g.setHasCentral( true ); + g.isHasCentral(); + + hm = g.getGraph(); + + Collection<String> k = g.getKeys(); + + } + + + +} + diff --git a/src/test/java/org/onap/dmaap/dbcapi/util/RandomIntegerTest.java b/src/test/java/org/onap/dmaap/dbcapi/util/RandomIntegerTest.java new file mode 100644 index 0000000..b489608 --- /dev/null +++ b/src/test/java/org/onap/dmaap/dbcapi/util/RandomIntegerTest.java @@ -0,0 +1,74 @@ +/*- + * ============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.util; +import org.onap.dmaap.dbcapi.model.*; +import org.onap.dmaap.dbcapi.service.*; +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.util.*; +import java.sql.*; + +public class RandomIntegerTest { + + private static final String fmt = "%24s: %s%n"; + + ReflectionHarness rh = new ReflectionHarness(); + + RandomInteger ri; + + + @Before + public void setUp() throws Exception { + ri = new RandomInteger( 12434 ); + } + + @After + public void tearDown() throws Exception { + } + + + @Test + public void test1() { + + + rh.reflect( "org.onap.dmaap.dbcapi.util.RandomInteger", "get", "" ); + + } + + @Test + public void test2() { + String v = "Validate"; + rh.reflect( "org.onap.dmaap.dbcapi.util.RandomInteger", "set", v ); + + } + + @Test + public void test3() { + int i = ri.next(); + + } + + + +} + |