package org.onap.dmaap.dbcapi.aaf;
-
-
-
-
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
+import java.net.ConnectException;
import java.net.ProtocolException;
import java.net.URL;
import java.net.UnknownHostException;
-import java.net.ConnectException;
-
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLHandshakeException;
-
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.commons.codec.binary.Base64;
public class AafConnection extends BaseLoggingClass {
-
-
-
-
private String aafCred;
private String unit_test;
-
-
private HttpsURLConnection uc;
-
public AafConnection( String cred ) {
aafCred = cred;
DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig();
unit_test = p.getProperty( "UnitTest", "No" );
-
}
-
private boolean makeConnection( String pURL ) {
try {
return sb.toString();
}
-
-
public int postAaf( AafObject obj, String pURL ) {
logger.info( "entry: postAaf() to " + pURL );
public void setProvFQDN(String provFQDN) {
Main.provFQDN = provFQDN;
}
- private Main() {
+ Main() {
}
public static void main(String[] args) {
(new Main()).main();
package org.onap.dmaap.dbcapi.aaf;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.BDDMockito.given;
+
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.onap.dmaap.dbcapi.aaf.AafService.ServiceType;
import org.onap.dmaap.dbcapi.util.DmaapConfig;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.BDDMockito.given;
-
@RunWith(MockitoJUnitRunner.class)
public class AafServiceFactoryTest {
private DmaapConfig dmaapConfig;
private AafServiceFactory aafServiceFactory;
+ @BeforeClass
+ public static void setUpClass() {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
+ }
+
@Before
public void setUp() throws Exception {
aafServiceFactory = new AafServiceFactory(dmaapConfig);
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
MockitoAnnotations.initMocks(this);
given(aafConnection.postAaf(any(AafObject.class), anyString())).willReturn(CREATED);
given(aafConnection.delAaf(any(AafObject.class), anyString())).willReturn(OK);
@Test
public void shouldReturnCorrectIdentity() {
-
assertEquals(IDENTITY, aafService.getIdentity());
}
import javax.ws.rs.core.Application;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
+import org.junit.Before;
import org.junit.Test;
-import org.onap.dmaap.dbcapi.authentication.ApiPerms;
-
public class ApiPermsTest extends JerseyTest {
+ @Before
+ public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
+ }
+
@Override
protected Application configure() {
return new ResourceConfig()
package org.onap.dmaap.dbcapi.authentication;
-import org.junit.Test;
-import org.onap.dmaap.dbcapi.aaf.DmaapPerm;
-
-import java.util.Properties;
-
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import java.util.Properties;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dbcapi.aaf.DmaapPerm;
+
public class ApiPolicyTest {
private Properties properties = new Properties();
private ApiPolicy apiPolicy;
+ @Before
+ public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
+ }
+
@Test
public void check_shouldExecuteAuthorizationApi() throws Exception {
properties.put("ApiPermission.Class", "org.onap.dmaap.dbcapi.authentication.ApiPolicyTest$DummyApiAuthorization");
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
ns = new DrProvConnection();
}
@Test
public void test1() {
-
-
- rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.DrProvConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" );
-
+ rh.reflect( "org.onap.dmaap.dbcapi.client.DrProvConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" );
}
@Test
public void test2() {
String v = "Validate";
- rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.DrProvConnection", "set", v );
+ rh.reflect( "org.onap.dmaap.dbcapi.client.DrProvConnection", "set", v );
}
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
ns = new MrProvConnection();
ts = new TopicService();
mcs = new MR_ClusterService();
public void test1() {
- rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrProvConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" );
+ rh.reflect( "org.onap.dmaap.dbcapi.client.MrProvConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" );
}
@Test
public void test2() {
String v = "Validate";
- rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrProvConnection", "set", v );
+ rh.reflect( "org.onap.dmaap.dbcapi.client.MrProvConnection", "set", v );
}
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
ns = new MrTopicConnection( "aUser", "aPwd" );
ts = new TopicService();
mcs = new MR_ClusterService();
public void test1() {
- rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrTopicConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" );
+ rh.reflect( "org.onap.dmaap.dbcapi.client.MrTopicConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" );
}
@Test
public void test2() {
String v = "Validate";
- rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrTopicConnection", "set", v );
+ rh.reflect( "org.onap.dmaap.dbcapi.client.MrTopicConnection", "set", v );
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
import org.junit.Test;
import org.onap.dmaap.dbcapi.logging.BaseLoggingClass;
-import org.onap.dmaap.dbcapi.model.ReplicationType;
-import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
public class DBFieldHandlerTest extends BaseLoggingClass {
- private static final String fmt = "%24s: %s%n";
-
- ReflectionHarness rh = new ReflectionHarness();
-
- private static class TopicReplicationTypeHandler implements DBFieldHandler.SqlOp {
- public Object get(ResultSet rs, int index) throws Exception {
- int val = rs.getInt(index);
-
- return (ReplicationType.valueOf(val));
- }
-
- public void set(PreparedStatement ps, int index, Object val) throws Exception {
- if (val == null) {
- ps.setInt(index, 0);
- return;
- }
- @SuppressWarnings("unchecked")
- ReplicationType rep = (ReplicationType) val;
- ps.setInt(index, rep.getValue());
- }
- }
-
- @Test
- public void test1() {
- // rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrTopicConnection", "get",
- // "idNotSet@namespaceNotSet:pwdNotSet" );
- }
-
- @Test
- public void test2() {
- String v = "Validate";
- // rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrTopicConnection", "set", v );
- }
-
@Test
public void test3() {
try {
*/
package org.onap.dmaap.dbcapi.database;
-import org.onap.dmaap.dbcapi.model.*;
-import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
-import org.onap.dmaap.dbcapi.util.Singleton;
-
-import org.junit.After;
+import java.util.Map;
import org.junit.Before;
import org.junit.Test;
-import java.util.*;
+import org.onap.dmaap.dbcapi.model.DcaeLocation;
+import org.onap.dmaap.dbcapi.model.Dmaap;
+import org.onap.dmaap.dbcapi.util.Singleton;
public class DBMapTest {
- private static final String fmt = "%24s: %s%n";
-
- ReflectionHarness rh = new ReflectionHarness();
-
-
private static Singleton<Dmaap> dmaap;
private static Map<String, DcaeLocation> dcaeLocations;
-
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
}
- @After
- public void tearDown() throws Exception {
- }
-
-
@Test
public void test1() {
-
-
- //rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrTopicConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" );
-
- }
-
- @Test
- public void test2() {
- String v = "Validate";
- //rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrTopicConnection", "set", v );
-
- }
-
- @Test
- public void test3() {
try {
- dmaap = new DBSingleton<Dmaap>(Dmaap.class, "dmaap");
+ dmaap = new DBSingleton<>(Dmaap.class, "dmaap");
Dmaap nd = new Dmaap.DmaapBuilder().createDmaap();
dmaap.update(nd);
} catch (Exception e ) {
}
try {
- dcaeLocations = new DBMap<DcaeLocation>(DcaeLocation.class, "dcae_location", "dcae_location_name");
+ dcaeLocations = new DBMap<>(DcaeLocation.class, "dcae_location", "dcae_location_name");
} catch (Exception e ) {
}
-
}
-
-
-
}
*/
package org.onap.dmaap.dbcapi.database;
-import org.onap.dmaap.dbcapi.model.*;
-import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
-
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.dmaap.dbcapi.model.Dmaap;
public class DBSingletonTest {
-
- private static final String fmt = "%24s: %s%n";
-
- ReflectionHarness rh = new ReflectionHarness();
-
-
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
}
- @After
- public void tearDown() throws Exception {
- }
-
-
-
@Test
public void test3() {
try {
- DBSingleton<Dmaap> dmaap = new DBSingleton<Dmaap>(Dmaap.class, "dmaap");
+ DBSingleton<Dmaap> dmaap = new DBSingleton<>(Dmaap.class, "dmaap");
Dmaap d = new Dmaap.DmaapBuilder().createDmaap();
dmaap.init( d );
d = dmaap.get();
dmaap.remove();
} catch (Exception e ) {
}
-
}
-
-
-
-
}
*/
package org.onap.dmaap.dbcapi.database;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
public class LoadSchemaTest {
- private static final String fmt = "%24s: %s%n";
-
ReflectionHarness rh = new ReflectionHarness();
- LoadSchema ls;
-
-
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
}
- @After
- public void tearDown() throws Exception {
- }
-
-
@Test
public void test1() {
-
-
rh.reflect( "org.onap.dmaap.dbcapi.database.LoadSchema", "get", "idNotSet@namespaceNotSet:pwdNotSet" );
-
}
@Test
public void test2() {
String v = "Validate";
rh.reflect( "org.onap.dmaap.dbcapi.database.LoadSchema", "set", v );
-
}
@Test
*/
package org.onap.dmaap.dbcapi.database;
-import org.onap.dmaap.dbcapi.model.*;
-import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
import org.junit.Before;
import org.junit.Test;
-import java.sql.*;
+import org.onap.dmaap.dbcapi.model.ReplicationType;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
public class TableHandlerTest {
- private static final String fmt = "%24s: %s%n";
-
ReflectionHarness rh = new ReflectionHarness();
private static class TopicReplicationTypeHandler implements DBFieldHandler.SqlOp {
}
}
-
-
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
}
- @After
- public void tearDown() throws Exception {
- }
-
-
@Test
public void test1() {
-
-
- rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrTopicConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" );
-
+ rh.reflect( "org.onap.dmaap.dbcapi.client.MrTopicConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" );
}
@Test
public void test2() {
String v = "Validate";
- //rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrTopicConnection", "set", v );
-
+ rh.reflect( "org.onap.dmaap.dbcapi.client.MrTopicConnection", "set", v );
}
@Test
}
}
-
-
-
}
package org.onap.dmaap.dbcapi.model;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
public class MRClientTest {
- private static final String fmt = "%24s: %s%n";
-
ReflectionHarness rh = new ReflectionHarness();
String d, t, f, c, m;
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
d = "central-onap";
t = "org.onap.dmaap.interestingTopic";
f = "mrc.onap.org:3904/events/org.onap.dmaap.interestingTopic";
m = "m12345";
}
- @After
- public void tearDown() throws Exception {
- }
-
@Test
public void test1() {
-
// can't use simple reflection to test for null since null constructor
// initializes some fields.
// rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Client", "get", null );
@Test
public void test3() {
-
String v = "Validate";
rh.reflect("org.onap.dmaap.dbcapi.model.MR_Client", "set", v);
}
assertEquals(false, mrClient.isPublisher());
assertEquals(false, mrClient.isSubscriber());
assertEquals("test", mrClient.getAction()[0]);
-
}
}
*/
package org.onap.dmaap.dbcapi.model;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
d = "central-onap";
fqdn = "mr.onap.org";
repGrp = "zeppelin";
}
- @After
- public void tearDown() throws Exception {
- }
-
-
@Test
public void testMR_ClusterClassDefaultConstructor() {
-
MR_Cluster t = new MR_Cluster();
assertTrue( t.getDcaeLocationName() == null );
assertTrue(fqtn.contains(topic2));
}
-
-
@Test
public void testsetter() {
-
String v = "validate";
-
-
- rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Cluster", "set", v );
-
+ rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Cluster", "set", v );
}
}
*/
package org.onap.dmaap.dbcapi.model;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
-import org.junit.After;
+import java.util.ArrayList;
import org.junit.Before;
import org.junit.Test;
import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
-import java.util.ArrayList;
-
public class MirrorMakerTest {
- private static final String fmt = "%24s: %s%n";
-
ReflectionHarness rh = new ReflectionHarness();
-
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
}
- @After
- public void tearDown() throws Exception {
- }
-
-
@Test
public void test1() {
-
-
- rh.reflect( "org.onap.dmaap.dbcapi.model.MirrorMaker", "get", null );
-
+ rh.reflect( "org.onap.dmaap.dbcapi.model.MirrorMaker", "get", null );
}
@Test
public void test2() {
-
String v = "Validate";
rh.reflect( "org.onap.dmaap.dbcapi.model.MirrorMaker", "set", v );
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.dmaap.dbcapi.model.DmaapObject.DmaapObject_Status;
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
f = "org.onap.dmaap.interestingTopic";
t = "interestingTopic";
d = "A so very interesting topic";
o = "m12345";
}
- @After
- public void tearDown() throws Exception {
- }
-
@Test
public void test1() {
rh.reflect("org.onap.dmaap.dbcapi.model.Topic", "get", null);
*/
package org.onap.dmaap.dbcapi.resources;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
-import java.io.PrintWriter;
-import java.io.StringWriter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@Rule
public ExpectedException thrown = ExpectedException.none();
+ @BeforeClass
+ public static void setUpClass(){
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
+ }
+
@Before
public void setUp() throws Exception {
doReturn(dmaapConfig).when(filter).getConfig();
//when
filter.init(filterConfig);
}
-
- /*
- * See https://jira.onap.org/browse/DMAAP-1361 for why this is commented out
- @Test
- public void init_shouldInitializeCADI_whenAafIsUsed_andValidCadiPropertiesSet() throws Exception {
- //given
- doReturn("true").when(dmaapConfig).getProperty(eq(AAFAuthenticationFilter.CADI_AUTHN_FLAG), anyString());
- doReturn("src/test/resources/cadi.properties").when(dmaapConfig).getProperty(AAFAuthenticationFilter.CADI_PROPERTIES);
-
- //when
- filter.init(filterConfig);
-
- //then
- assertTrue(filter.isCadiEnabled());
- assertNotNull(filter.getCadiFilter());
- }
-
- @Test
- public void doFilter_shouldUseCADIfilter_andAuthenticateUser_whenAAFisUsed_andUserIsValid() throws Exception{
- //given
- initCADIFilter();
- doReturn(200).when(servletResponse).getStatus();
-
- //when
- filter.doFilter(servletRequest,servletResponse,filterChain);
-
- //then
- verify(cadiFilterMock).doFilter(servletRequest,servletResponse,filterChain);
- verify(servletResponse).getStatus();
- verifyNoMoreInteractions(servletResponse);
- verifyZeroInteractions(filterChain, servletRequest);
- }
-
- @Test
- public void doFilter_shouldUseCADIfilter_andReturnAuthenticationError_whenAAFisUsed_andUserInvalid() throws Exception{
- //given
- String errorResponseJson = "{\"code\":401,\"message\":\"invalid or no credentials provided\",\"fields\":\"Authentication\",\"2xx\":false}";
- initCADIFilter();
- doReturn(401).when(servletResponse).getStatus();
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- doReturn(pw).when(servletResponse).getWriter();
-
- //when
- filter.doFilter(servletRequest,servletResponse,filterChain);
-
- //then
- verify(cadiFilterMock).doFilter(servletRequest,servletResponse,filterChain);
- verify(servletResponse).getStatus();
- verify(servletResponse).setContentType("application/json");
- verifyZeroInteractions(filterChain, servletRequest);
- assertEquals(errorResponseJson, sw.toString());
- }
-
- private void initCADIFilter() throws Exception{
- doReturn("true").when(dmaapConfig).getProperty(eq(AAFAuthenticationFilter.CADI_AUTHN_FLAG), anyString());
- doReturn("src/test/resources/cadi.properties").when(dmaapConfig).getProperty(AAFAuthenticationFilter.CADI_PROPERTIES);
- filter.init(filterConfig);
- filter.setCadiFilter(cadiFilterMock);
- }
-*/
}
\ No newline at end of file
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@Mock
private DmaapService dmaapService;
+ @BeforeClass
+ public static void setUpClass(){
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
+ }
@Before
public void setUp() throws Exception {
filter.setPermissionBuilder(permissionBuilder);
*/
package org.onap.dmaap.dbcapi.resources;
+import static javax.ws.rs.client.Entity.entity;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig;
import org.junit.AfterClass;
import org.junit.Before;
import org.onap.dmaap.dbcapi.model.DR_Node;
import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.Response;
-
-import static javax.ws.rs.client.Entity.entity;
-import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
public class DR_NodeResourceTest {
@BeforeClass
public static void setUpClass() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
DatabaseClass.getDmaap().init(DMAAP_OBJECT_FACTORY.genDmaap());
testContainer = new FastJerseyTestContainer(new ResourceConfig()
@BeforeClass
public static void setUpClass() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
//TODO: init is still needed here to assure that dmaap is not null
DatabaseClass.getDmaap().init(DMAAP_OBJECT_FACTORY.genDmaap());
@BeforeClass
public static void setUpClass() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
//TODO: init is still needed here to assure that dmaap is not null
DatabaseClass.getDmaap().init(DMAAP_OBJECT_FACTORY.genDmaap());
*/
package org.onap.dmaap.dbcapi.resources;
-import org.onap.dmaap.dbcapi.model.*;
-import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.Assert.assertTrue;
-import org.glassfish.jersey.test.JerseyTest;
-import org.glassfish.jersey.server.ResourceConfig;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Application;
-import javax.ws.rs.core.Response;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.Path;
-import javax.ws.rs.GET;
+import javax.ws.rs.core.Response;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.dmaap.dbcapi.model.DcaeLocation;
+import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
public class DcaeLocationResourceTest extends JerseyTest {
return new ResourceConfig( DcaeLocationResource.class );
}
- private static final String fmt = "%24s: %s%n";
-
-
-
-/* may conflict with test framework!
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
+ @BeforeClass
+ public static void setUpClass(){
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
}
-*/
-
-
@Test
public void GetTest() {
System.out.println( "DELETE dcaeLocation resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
assertTrue( resp.getStatus() == 204 );
}
-
-
-
}
import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.dmaap.dbcapi.model.Dmaap;
import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
static DmaapObjectFactory factory = new DmaapObjectFactory();
+ @BeforeClass
+ public static void setUpClass(){
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
+ }
+
@Override
protected Application configure() {
return new ResourceConfig( DmaapResource.class );
- //return new ResourceConfig( HelloResource.class );
}
- private static final String fmt = "%24s: %s%n";
-
-
-
-/* may conflict with test framework!
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-*/
-
-
-
@Test
public void GetTest() {
Response resp = target( "dmaap").request().get( Response.class );
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.resources;
-import org.onap.dmaap.dbcapi.model.*;
-import org.onap.dmaap.dbcapi.service.*;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import java.util.*;
-import java.sql.*;
-
-import org.glassfish.jersey.test.JerseyTest;
-import org.glassfish.jersey.server.ResourceConfig;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Application;
-import javax.ws.rs.core.Response;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.Path;
-import javax.ws.rs.GET;
+import javax.ws.rs.core.Response;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.dmaap.dbcapi.model.Feed;
public class FeedResourceTest extends JerseyTest {
+ @BeforeClass
+ public static void setUpClass(){
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
+ }
@Override
protected Application configure() {
return new ResourceConfig( FeedResource.class );
}
- private static final String fmt = "%24s: %s%n";
-
-
-
-/* may conflict with test framework!
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-*/
-
-
-
@Test
public void GetTest() {
Response resp = target( "feeds").request().get( Response.class );
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 );
- }
-*/
-
-
-
}
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.resources;
-import org.onap.dmaap.dbcapi.model.*;
-import org.onap.dmaap.dbcapi.service.*;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import java.util.*;
-import java.sql.*;
-
-import org.glassfish.jersey.test.JerseyTest;
-import org.glassfish.jersey.server.ResourceConfig;
-import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Response;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.Path;
-import javax.ws.rs.GET;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.junit.BeforeClass;
+import org.junit.Test;
public class InfoResourceTest extends JerseyTest {
protected Application configure() {
return new ResourceConfig( InfoResource.class );
}
-
- private static final String fmt = "%24s: %s%n";
-
-
-
-/* may conflict with test framework!
- @Before
- public void setUp() throws Exception {
+ @BeforeClass
+ public static void setUpClass(){
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
}
- @After
- public void tearDown() throws Exception {
- }
-*/
-
-
-
@Test
public void GetTest() {
Response resp = target( "info").request().get( Response.class );
package org.onap.dmaap.dbcapi.resources;
+import static javax.ws.rs.client.Entity.entity;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.onap.dmaap.dbcapi.model.Topic;
import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.Response;
-
-import static javax.ws.rs.client.Entity.entity;
-import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
public class MR_ClientResourceTest {
private static final DmaapObjectFactory DMAAP_OBJECT_FACTORY = new DmaapObjectFactory();
@BeforeClass
public static void setUpClass() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
DatabaseClass.getDmaap().init(DMAAP_OBJECT_FACTORY.genDmaap());
testContainer = new FastJerseyTestContainer(new ResourceConfig()
@BeforeClass
public static void setUpClass() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
DatabaseClass.getDmaap().init(DMAAP_OBJECT_FACTORY.genDmaap());
testContainer = new FastJerseyTestContainer(new ResourceConfig()
@BeforeClass
public static void setUpClass() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
//TODO: init is still needed here to assure that dmaap is not null
DatabaseClass.getDmaap().init(DMAAP_OBJECT_FACTORY.genDmaap());
*/
package org.onap.dmaap.dbcapi.server;
-import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
-import org.onap.dmaap.dbcapi.util.DmaapConfig;
-import static org.junit.Assert.*;
-
+import java.util.Properties;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import java.util.Properties;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+import org.onap.dmaap.dbcapi.util.DmaapConfig;
public class JettyServerTest {
- private static final String fmt = "%24s: %s%n";
-
ReflectionHarness rh = new ReflectionHarness();
-
-
- JettyServer m = null;
+ JettyServer m = null;
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
Properties p = DmaapConfig.getConfig();
try {
m = new JettyServer(p);
}
}
-
@Test
public void test1() {
-
-
- rh.reflect( "org.onap.dmaap.dbcapi.server.JettyServer", "get", null );
-
+ rh.reflect( "org.onap.dmaap.dbcapi.server.JettyServer", "get", null );
}
@Test
public void test2() {
String v = "Validate";
rh.reflect( "org.onap.dmaap.dbcapi.server.JettyServer", "set", v );
-
}
- @Test
- public void test3() {
- }
-
-
-
}
+++ /dev/null
-/*-
- * ============LICENSE_START=======================================================
- * org.onap.dmaap
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.dmaap.dbcapi.server;
-
-import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class MainTest {
-
- private static final String fmt = "%24s: %s%n";
-
- ReflectionHarness rh = new ReflectionHarness();
-
- Main m;
-
-
- @Before
- public void setUp() throws Exception {
- //m = new Main();
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
-
- @Test
- public void test1() {
-
-
- rh.reflect( "org.onap.dmaap.dbcapi.server.Main", "get", null );
-
- }
-
- @Test
- public void test2() {
- String v = "Validate";
- rh.reflect( "org.onap.dmaap.dbcapi.server.Main", "set", v );
-
- }
-
-/*
- @Test
- public void test3() {
- String[] args = { "--help", "--version" };
-
- try {
- m.main( args );
- } catch (Exception e ) {
- }
-
- }
-*/
-
-
-
-}
*/
package org.onap.dmaap.dbcapi.service;
+import static com.google.common.collect.Lists.newArrayList;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.BDDMockito.given;
+
+import java.util.List;
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.junit.Before;
import org.onap.dmaap.dbcapi.model.Topic;
import org.onap.dmaap.dbcapi.util.DmaapConfig;
-import java.util.List;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.BDDMockito.given;
-
@RunWith(JUnitParamsRunner.class)
public class AafTopicSetupServiceTest {
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
MockitoAnnotations.initMocks(this);
Dmaap dmaap = new Dmaap();
dmaap.setTopicNsRoot(TOPIC_NS_ROOT);
public class ApiServiceTest {
- private static final String fmt = "%24s: %s%n";
-
ReflectionHarness rh = new ReflectionHarness();
ApiService ds;
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
ds = new ApiService();
}
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";
*/
package org.onap.dmaap.dbcapi.service;
-import org.onap.dmaap.dbcapi.model.*;
-import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
-import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
-
-import static org.junit.Assert.*;
-
+import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import java.util.List;
+import org.onap.dmaap.dbcapi.model.ApiError;
+import org.onap.dmaap.dbcapi.model.DR_Node;
+import org.onap.dmaap.dbcapi.model.DcaeLocation;
+import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
public class DR_NodeServiceTest {
- private static final String fmt = "%24s: %s%n";
-
ReflectionHarness rh = new ReflectionHarness();
static DmaapObjectFactory factory = new DmaapObjectFactory();
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
ns = new DR_NodeService();
}
@Test
public void test1() {
-
-
- rh.reflect( "org.onap.dmaap.dbcapi.service.DR_NodeService", "get", null );
-
+ rh.reflect( "org.onap.dmaap.dbcapi.service.DR_NodeService", "get", null );
}
@Test
public void test2() {
String v = "Validate";
rh.reflect( "org.onap.dmaap.dbcapi.service.DR_NodeService", "set", v );
-
}
@Test
}
n2 = ns.removeDr_Node( f, err );
-
}
-
-
}
*/
package org.onap.dmaap.dbcapi.service;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.dmaap.dbcapi.model.Dmaap;
public class DmaapServiceTest {
- private static final String fmt = "%24s: %s%n";
-
ReflectionHarness rh = new ReflectionHarness();
DmaapService ds;
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
ds = new DmaapService();
}
- @After
- public void tearDown() throws Exception {
- }
-
-
- @Test
- public void test1() {
-
-
- //rh.reflect( "org.onap.dmaap.dbcapi.service.DmaapService", "get", null );
-
- }
-
@Test
public void test2() {
String v = "Validate";
rh.reflect( "org.onap.dmaap.dbcapi.service.DmaapService", "set", v );
-
}
@Test
*/
package org.onap.dmaap.dbcapi.service;
-import org.onap.dmaap.dbcapi.model.*;
-import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
-
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
-import org.junit.After;
+import java.util.ArrayList;
+import java.util.List;
import org.junit.Before;
import org.junit.Test;
-import java.util.List;
-import java.util.ArrayList;
+import org.onap.dmaap.dbcapi.model.ApiError;
+import org.onap.dmaap.dbcapi.model.DR_Pub;
+import org.onap.dmaap.dbcapi.model.DcaeLocation;
+import org.onap.dmaap.dbcapi.model.Feed;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
public class Dr_PubServiceTest {
- private static final String fmt = "%24s: %s%n";
-
ReflectionHarness rh = new ReflectionHarness();
DR_PubService ns;
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
ns = new DR_PubService();
fs = new FeedService();
}
- @After
- public void tearDown() throws Exception {
- }
-
@Test
public void test1() {
-
-
- rh.reflect( "org.onap.dmaap.dbcapi.service.DR_PubService", "get", null );
-
+ rh.reflect( "org.onap.dmaap.dbcapi.service.DR_PubService", "get", null );
}
@Test
public void test2() {
String v = "Validate";
rh.reflect( "org.onap.dmaap.dbcapi.service.DR_PubService", "set", v );
-
}
@Test
}
n2 = ns.removeDr_Pub( n2.getPubId(), err );
-
-
}
@Test
public void test4() {
ArrayList<DR_Pub> l = ns.getDr_PubsByFeedId( "1" );
-
-
}
-
-
}
package org.onap.dmaap.dbcapi.service;
import java.util.List;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.dmaap.dbcapi.model.ApiError;
public class FeedServiceTest {
- private static final String fmt = "%24s: %s%n";
-
ReflectionHarness rh = new ReflectionHarness();
FeedService ds;
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
ds = new FeedService();
}
- @After
- public void tearDown() throws Exception {
- }
-
@Test
public void test1() {
-
-
- rh.reflect( "org.onap.dmaap.dbcapi.service.FeedService", "get", null );
-
+ rh.reflect( "org.onap.dmaap.dbcapi.service.FeedService", "get", null );
}
@Test
public void test2() {
String v = "Validate";
rh.reflect( "org.onap.dmaap.dbcapi.service.FeedService", "set", v );
-
}
@Test
@Test
public void test5() {
List<Feed> f = ds.getAllFeeds( "aName", "1.0", "startsWith" );
-
}
assert( 200 == err.getCode());
}
-
-
}
import static org.junit.Assert.assertTrue;
import java.util.List;
-
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.dmaap.dbcapi.model.ApiError;
public class MR_ClientServiceTest {
- private static final String fmt = "%24s: %s%n";
-
private static DmaapObjectFactory factory = new DmaapObjectFactory();
ReflectionHarness rh = new ReflectionHarness();
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
ts = new TopicService();
mcs = new MR_ClusterService();
cls = new MR_ClientService();
MR_Cluster n2 = mcs.addMr_Cluster( node, err );
}
- @After
- public void tearDown() throws Exception {
- }
-
-
@Test
public void test1() {
-
-
- rh.reflect( "org.onap.dmaap.dbcapi.service.MR_ClientService", "get", null );
-
+ rh.reflect( "org.onap.dmaap.dbcapi.service.MR_ClientService", "get", null );
}
@Test
public void test2() {
String v = "Validate";
rh.reflect( "org.onap.dmaap.dbcapi.service.MR_ClientService", "set", v );
-
}
@Test
c = cls.addMr_Client( c, topic, err );
assertTrue( err.getCode() == 200 );
-
}
-
}
*/
package org.onap.dmaap.dbcapi.service;
-import org.onap.dmaap.dbcapi.model.*;
-import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
+import java.util.List;
import org.junit.Before;
import org.junit.Test;
-import java.util.List;
+import org.onap.dmaap.dbcapi.model.ApiError;
+import org.onap.dmaap.dbcapi.model.DcaeLocation;
+import org.onap.dmaap.dbcapi.model.MR_Cluster;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
public class MR_ClusterServiceTest {
- private static final String fmt = "%24s: %s%n";
-
ReflectionHarness rh = new ReflectionHarness();
MR_ClusterService ns;
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
ns = new MR_ClusterService();
}
- @After
- public void tearDown() throws Exception {
- }
-
-
@Test
public void test1() {
-
-
- rh.reflect( "org.onap.dmaap.dbcapi.service.MR_ClusterService", "get", null );
-
+ rh.reflect( "org.onap.dmaap.dbcapi.service.MR_ClusterService", "get", null );
}
@Test
public void test2() {
String v = "Validate";
rh.reflect( "org.onap.dmaap.dbcapi.service.MR_ClusterService", "set", v );
-
}
@Test
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 );
- }
}
-*/
}
*/
package org.onap.dmaap.dbcapi.service;
-import org.onap.dmaap.dbcapi.model.*;
-import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
-import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
-
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
-import org.junit.After;
+import java.util.ArrayList;
+import java.util.List;
import org.junit.Before;
import org.junit.Test;
-import java.util.List;
-import java.util.ArrayList;
+import org.onap.dmaap.dbcapi.model.ApiError;
+import org.onap.dmaap.dbcapi.model.DcaeLocation;
+import org.onap.dmaap.dbcapi.model.Dmaap;
+import org.onap.dmaap.dbcapi.model.MR_Client;
+import org.onap.dmaap.dbcapi.model.MR_Cluster;
+import org.onap.dmaap.dbcapi.model.MirrorMaker;
+import org.onap.dmaap.dbcapi.model.ReplicationType;
+import org.onap.dmaap.dbcapi.model.Topic;
+import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
public class MirrorMakerServiceTest {
- private static final String fmt = "%24s: %s%n";
private static DmaapObjectFactory factory = new DmaapObjectFactory();
ReflectionHarness rh = new ReflectionHarness();
private Topic replicationTopic;
-
DmaapService ds;
String locname;
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
mms = new MirrorMakerService();
ts = new TopicService();
assert( ts != null );
clients.add( pub );
replicationTopic.setClients( clients );
-
}
- @After
- public void tearDown() throws Exception {
- }
-
-
-// @Test
-// public void test_getters() {
-//
-//
-// rh.reflect( "org.onap.dmaap.dbcapi.service.MirrorMakerService", "get", null );
-//
-// }
-
@Test
public void test_setters() {
String v = "Validate";
rh.reflect( "org.onap.dmaap.dbcapi.service.MirrorMakerService", "set", v );
-
}
-
-
@Test
public void CreateMirrorMakerWithSingleTopic() {
ApiError err = new ApiError();
-
-
Topic nTopic = ts.addTopic(replicationTopic, err, true );
assertTrue( err.getCode() == 200 );
MirrorMaker mm = mms.getMirrorMaker(name);
- MirrorMaker mm2 = mms.splitMM(mm);
-
+ MirrorMaker mm2 = mms.splitMM(mm);
}
}
package org.onap.dmaap.dbcapi.service;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.verifyZeroInteractions;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@Rule
public ExpectedException thrown = ExpectedException.none();
- @Before
- public void setUp() throws Exception {
-
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
}
@Test
- public void init_normalConstructor() throws Exception {
- //given
-
-
- //when
-
-
- //then
+ public void init_normalConstructor() {
assertEquals( MirrorMakerService.getProvUserPwd(), MirrorMakerService.PROV_PWD_DEFAULT);
assertEquals( MirrorMakerService.getDefaultConsumerPort(), MirrorMakerService.TARGET_REPLICATION_PORT_DEFAULT);
assertEquals( MirrorMakerService.getDefaultProducerPort(), MirrorMakerService.SOURCE_REPLICATION_PORT_DEFAULT);
}
- // Todo: learn how to make more tests in Mockito
-
-
}
package org.onap.dmaap.dbcapi.service;
-import com.google.common.collect.ImmutableMap;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
-import org.hamcrest.Matcher;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.dmaap.dbcapi.model.ApiError;
-import org.onap.dmaap.dbcapi.model.MR_Client;
-import org.onap.dmaap.dbcapi.model.Topic;
-import org.onap.dmaap.dbcapi.util.DmaapConfig;
-
-import javax.ws.rs.core.Response;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.collect.Lists.newArrayList;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.onap.dmaap.dbcapi.model.ReplicationType.REPLICATION_GLOBAL_TO_FQDN;
+import com.google.common.collect.ImmutableMap;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.ws.rs.core.Response;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.dmaap.dbcapi.model.ApiError;
+import org.onap.dmaap.dbcapi.model.MR_Client;
+import org.onap.dmaap.dbcapi.model.Topic;
+import org.onap.dmaap.dbcapi.util.DmaapConfig;
+
@RunWith(MockitoJUnitRunner.class)
public class TopicServiceTest {
@Mock
private AafTopicSetupService aafTopicSetupService;
+ @BeforeClass
+ public static void setUpClass(){
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
+
+ }
+
@Before
public void setUp() throws Exception {
given(dmaapConfig.getProperty("MR.globalHost", "global.host.not.set")).willReturn(GLOBAL_MR_HOST);
*/
package org.onap.dmaap.dbcapi.util;
-import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
public class DmaapConfigTest {
- private static final String fmt = "%24s: %s%n";
-
ReflectionHarness rh = new ReflectionHarness();
- DmaapConfig g;
-
-
@Before
public void setUp() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
}
- @After
- public void tearDown() throws Exception {
- }
-
-
@Test
public void test1() {
-
-
- rh.reflect( "org.onap.dmaap.dbcapi.util.DmaapConfig", "get", "" );
-
+ rh.reflect( "org.onap.dmaap.dbcapi.util.DmaapConfig", "get", "" );
}
@Test
public void test2() {
String v = "Validate";
rh.reflect( "org.onap.dmaap.dbcapi.util.DmaapConfig", "set", v );
-
}
@Test
public void test3() {
-
- String f = g.getConfigFileName();
+ DmaapConfig.getConfigFileName();
+ DmaapConfig.getSSLSocketFactory();
}
-
-
-
}
*/
package org.onap.dmaap.dbcapi.util;
-import org.onap.dmaap.dbcapi.model.*;
-import org.onap.dmaap.dbcapi.service.*;
-import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
import org.junit.Before;
import org.junit.Test;
-import java.util.*;
+import org.onap.dmaap.dbcapi.model.DcaeLocation;
+import org.onap.dmaap.dbcapi.model.MR_Client;
+import org.onap.dmaap.dbcapi.service.DcaeLocationService;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
public class GraphTest {
- private static final String fmt = "%24s: %s%n";
-
ReflectionHarness rh = new ReflectionHarness();
Graph g;
-
@Before
public void setUp() throws Exception {
- HashMap<String, String> hm = new HashMap<String,String>();
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
+ HashMap<String, String> hm = new HashMap<>();
g = new Graph( hm );
}
- @After
- public void tearDown() throws Exception {
- }
-
-
@Test
public void test1() {
-
-
- rh.reflect( "org.onap.dmaap.dbcapi.util.Graph", "get", "idNotSet@namespaceNotSet:pwdNotSet" );
-
- }
-
- @Test
- public void test2() {
- String v = "Validate";
- //rh.reflect( "org.onap.dmaap.dbcapi.util.Graph", "set", v );
-
+ rh.reflect( "org.onap.dmaap.dbcapi.util.Graph", "get", "idNotSet@namespaceNotSet:pwdNotSet" );
}
@Test
HashMap<String, String> hm = new HashMap<String, String>();
-
String s = g.put( "aKey", "aVal" );
s = g.get( "aKey" );
hm = g.getGraph();
Collection<String> k = g.getKeys();
-
}
-
-
}
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+
import javax.servlet.http.HttpServletRequest;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@Mock
private HttpServletRequest request;
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
+ }
@Test
public void updateDmaapInstance_shouldSetBootInstance_whenDmaapIsNotInitialized() {