diff options
Diffstat (limited to 'src/test/java/org/onap/dmaap/mr/tools')
11 files changed, 1592 insertions, 0 deletions
diff --git a/src/test/java/org/onap/dmaap/mr/tools/ApiKeyCommandTest.java b/src/test/java/org/onap/dmaap/mr/tools/ApiKeyCommandTest.java new file mode 100644 index 0000000..e022bf5 --- /dev/null +++ b/src/test/java/org/onap/dmaap/mr/tools/ApiKeyCommandTest.java @@ -0,0 +1,217 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2017 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.mr.tools; + +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.io.PrintStream; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import com.att.nsa.apiClient.credentials.ApiCredential; +import com.att.nsa.apiClient.http.HttpException; +import com.att.nsa.apiClient.http.HttpObjectNotFoundException; +import com.att.nsa.cmdtool.CommandNotReadyException; +import org.onap.dmaap.mr.client.MRClient.MRApiException; +import org.onap.dmaap.mr.client.MRClientFactory; +import org.onap.dmaap.mr.client.MRIdentityManager; +import org.onap.dmaap.mr.client.MRIdentityManager.ApiKey; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ MRClientFactory.class }) +public class ApiKeyCommandTest { + + @InjectMocks + private ApiKeyCommand command; + @Mock + private MRIdentityManager tm; + @Mock + private ApiKey ti; + @Mock + private ApiKey key; + @Mock + private ApiCredential ac; + @Mock + private PrintStream printStream; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + PowerMockito.mockStatic(MRClientFactory.class); + PowerMockito.when(MRClientFactory.createIdentityManager(Arrays.asList("localhost"), null, null)).thenReturn(tm); + PowerMockito.when(tm.getApiKey("testtopic")).thenReturn(key); + PowerMockito.when(tm.createApiKey("testtopic", "1")).thenReturn(ac); + + } + + @After + public void tearDown() throws Exception { + + } + + @Test + public void testGetMatches() { + + command.getMatches(); + assertTrue(true); + + } + + @Test + public void testCheckReady() { + + try { + command.checkReady(new MRCommandContext()); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + + @Test + public void testExecute() { + + String[] parts1 = { "create", "testtopic", "1" }; + String[] parts2 = { "list", "testtopic", "1" }; + String[] parts3 = { "revoke", "write", "read" }; + List<String[]> parts = Arrays.asList(parts1, parts2, parts3); + for (Iterator iterator = parts.iterator(); iterator.hasNext();) { + String[] part = (String[]) iterator.next(); + + try { + command.execute(part, new MRCommandContext(), printStream); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + } + + @Test + public void testExecute_error1() throws HttpObjectNotFoundException, HttpException, MRApiException, IOException { + PowerMockito.when(tm.getApiKey("testtopic")).thenThrow(new IOException("error")); + String[] parts1 = { "create", "testtopic", "1" }; + String[] parts2 = { "list", "testtopic", "1" }; + String[] parts3 = { "revoke", "write", "read" }; + List<String[]> parts = Arrays.asList(parts1, parts2, parts3); + for (Iterator iterator = parts.iterator(); iterator.hasNext();) { + String[] part = (String[]) iterator.next(); + + try { + command.execute(part, new MRCommandContext(), printStream); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + } + + } + + @Test + public void testExecute_error2() throws HttpObjectNotFoundException, HttpException, MRApiException, IOException { + PowerMockito.when(tm.getApiKey("testtopic")).thenThrow(new MRApiException("error")); + String[] parts1 = { "create", "testtopic", "1" }; + String[] parts2 = { "list", "testtopic", "1" }; + String[] parts3 = { "revoke", "write", "read" }; + List<String[]> parts = Arrays.asList(parts1, parts2, parts3); + for (Iterator iterator = parts.iterator(); iterator.hasNext();) { + String[] part = (String[]) iterator.next(); + + try { + command.execute(part, new MRCommandContext(),printStream); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + } + + @Test + public void testExecute_error3() throws HttpObjectNotFoundException, HttpException, MRApiException, IOException { + PowerMockito.when(tm.getApiKey("testtopic")).thenThrow(new HttpException(500, "error")); + String[] parts1 = { "create", "testtopic", "1" }; + String[] parts2 = { "list", "testtopic", "1" }; + String[] parts3 = { "revoke", "write", "read" }; + List<String[]> parts = Arrays.asList(parts1, parts2, parts3); + for (Iterator iterator = parts.iterator(); iterator.hasNext();) { + String[] part = (String[]) iterator.next(); + + try { + command.execute(part, new MRCommandContext(), printStream); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + } + + } + + @Test + public void testExecute_error4() throws HttpObjectNotFoundException, HttpException, MRApiException, IOException { + PowerMockito.when(tm.getApiKey("testtopic")).thenThrow(new HttpObjectNotFoundException("error")); + String[] parts1 = { "create", "testtopic", "1" }; + String[] parts2 = { "list", "testtopic", "1" }; + String[] parts3 = { "revoke", "write", "read" }; + List<String[]> parts = Arrays.asList(parts1, parts2, parts3); + for (Iterator iterator = parts.iterator(); iterator.hasNext();) { + String[] part = (String[]) iterator.next(); + + try { + command.execute(part, new MRCommandContext(), printStream); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + } + + @Test + public void testDisplayHelp() { + + command.displayHelp(printStream); + assertTrue(true); + + } + +} diff --git a/src/test/java/org/onap/dmaap/mr/tools/AuthCommandTest.java b/src/test/java/org/onap/dmaap/mr/tools/AuthCommandTest.java new file mode 100644 index 0000000..9f9011a --- /dev/null +++ b/src/test/java/org/onap/dmaap/mr/tools/AuthCommandTest.java @@ -0,0 +1,113 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2017 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.mr.tools; + +import static org.junit.Assert.assertTrue; + +import java.io.PrintStream; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.modules.junit4.PowerMockRunner; + +import com.att.nsa.cmdtool.CommandNotReadyException; + +@RunWith(PowerMockRunner.class) +public class AuthCommandTest { + @InjectMocks + private AuthCommand command = null; + @Mock + private PrintStream printStream; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + + } + + @After + public void tearDown() throws Exception { + + } + + @Test + public void testGetMatches() { + + command.getMatches(); + assertTrue(true); + + } + + @Test + public void testCheckReady() { + + try { + command.checkReady(new MRCommandContext()); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + + @Test + public void testExecute() { + + try { + String[] parts = new String[5]; + command.execute(parts, new MRCommandContext(), printStream); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + + @Test + public void testExecute1() { + + try { + String[] parts = { "userName", "password" }; + command.execute(parts, new MRCommandContext(), printStream); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + + @Test + public void testDisplayHelp() { + + command.displayHelp(printStream); + assertTrue(true); + + } + +} diff --git a/src/test/java/org/onap/dmaap/mr/tools/ClusterCommandTest.java b/src/test/java/org/onap/dmaap/mr/tools/ClusterCommandTest.java new file mode 100644 index 0000000..0dc2f64 --- /dev/null +++ b/src/test/java/org/onap/dmaap/mr/tools/ClusterCommandTest.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2017 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.mr.tools; + +import static org.junit.Assert.assertTrue; + +import java.io.FileNotFoundException; +import java.io.PrintStream; +import java.util.Arrays; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.modules.junit4.PowerMockRunner; + +import com.att.nsa.cmdtool.CommandNotReadyException; + +@RunWith(PowerMockRunner.class) +public class ClusterCommandTest { + @InjectMocks + private ClusterCommand command; + @Mock + private MRCommandContext context; + @Mock + private PrintStream printStream; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + PowerMockito.when(context.getCluster()).thenReturn(Arrays.asList("localhost")); + } + + @After + public void tearDown() throws Exception { + + } + + @Test + public void testGetMatches() { + + command.getMatches(); + assertTrue(true); + + } + + @Test + public void testCheckReady() { + + try { + command.checkReady(context); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + + @Test + public void testExecute() throws FileNotFoundException, CommandNotReadyException { + String[] parts = { "create", "testtopic", "1", "1" }; + command.execute(parts, context, printStream); + assertTrue(true); + + } + + @Test + public void testExecute1() throws FileNotFoundException, CommandNotReadyException { + String[] parts = {}; + command.execute(parts, context, printStream); + assertTrue(true); + + } + + @Test + public void testDisplayHelp() { + + command.displayHelp(printStream); + assertTrue(true); + + } + +} diff --git a/src/test/java/org/onap/dmaap/mr/tools/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/tools/JUnitTestSuite.java new file mode 100644 index 0000000..ca79f9b --- /dev/null +++ b/src/test/java/org/onap/dmaap/mr/tools/JUnitTestSuite.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2017 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.mr.tools; + +import junit.framework.TestSuite; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; +import org.apache.log4j.Logger; + +@RunWith(Suite.class) +@SuiteClasses({ ApiKeyCommandTest.class, AuthCommandTest.class, ClusterCommandTest.class, + MessageCommandTest.class, MRCommandContextTest.class, TopicCommandTest.class, TraceCommandTest.class,}) + +public class JUnitTestSuite { + private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class); + + public static void main(String[] args) { + LOGGER.info("Running the test suite"); + + TestSuite tstSuite = new TestSuite(); + LOGGER.info("Total Test Counts " + tstSuite.countTestCases()); + } + +} diff --git a/src/test/java/org/onap/dmaap/mr/tools/MRCommandContextTest.java b/src/test/java/org/onap/dmaap/mr/tools/MRCommandContextTest.java new file mode 100644 index 0000000..038e321 --- /dev/null +++ b/src/test/java/org/onap/dmaap/mr/tools/MRCommandContextTest.java @@ -0,0 +1,165 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2017 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.mr.tools; + +import static org.junit.Assert.assertTrue; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.concurrent.TimeUnit; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.att.nsa.apiClient.http.HttpTracer; +import com.att.nsa.cmdtool.CommandNotReadyException; +import org.onap.dmaap.mr.client.HostSelector; +import org.onap.dmaap.mr.client.MRClient; +import org.onap.dmaap.mr.client.MRPublisher.message; +import org.onap.dmaap.mr.test.support.MRBatchingPublisherMock.Entry; + +public class MRCommandContextTest { + private MRCommandContext command = null; + private String[] parts = new String[5]; + + @Before + public void setUp() throws Exception { + command = new MRCommandContext(); + + for (int i = 0; i < parts.length; i++) { + parts[i] = "String" + (i + 1); + } + + } + + @After + public void tearDown() throws Exception { + + } + + @Test + public void testRequestShutdown() { + + command.requestShutdown(); + assertTrue(true); + + } + + @Test + public void testShouldContinue() { + + command.shouldContinue(); + assertTrue(true); + + } + + @Test + public void testSetAuth() { + + command.setAuth("key", "pwd"); + assertTrue(true); + + } + + @Test + public void testClearAuth() { + + command.clearAuth(); + assertTrue(true); + + } + + @Test + public void testCheckClusterReady() { + + command.checkClusterReady(); + assertTrue(true); + + } + + @Test + public void testGetCluster() { + + command.getCluster(); + assertTrue(true); + + } + + @Test + public void testClearCluster() { + + command.clearCluster(); + assertTrue(true); + + } + + @Test + public void testAddClusterHost() { + + command.addClusterHost("host"); + assertTrue(true); + + } + + @Test + public void testGetApiKey() { + + command.getApiKey(); + assertTrue(true); + + } + + @Test + public void testGetApiPwd() { + + command.getApiPwd(); + assertTrue(true); + + } + + @Test + public void testUseTracer() { + + command.useTracer(null); + assertTrue(true); + + } + + @Test + public void testNoTracer() { + + command.noTracer(); + assertTrue(true); + + } + + @Test + public void testApplyTracer() { + + command.applyTracer(null); + assertTrue(true); + + } + +} diff --git a/src/test/java/org/onap/dmaap/mr/tools/MessageCommandTest.java b/src/test/java/org/onap/dmaap/mr/tools/MessageCommandTest.java new file mode 100644 index 0000000..f32cb43 --- /dev/null +++ b/src/test/java/org/onap/dmaap/mr/tools/MessageCommandTest.java @@ -0,0 +1,214 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2017 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.mr.tools; + +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.io.PrintStream; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import com.att.nsa.cmdtool.CommandNotReadyException; +import org.onap.dmaap.mr.client.MRBatchingPublisher; +import org.onap.dmaap.mr.client.MRClientFactory; +import org.onap.dmaap.mr.client.MRConsumer; +import org.onap.dmaap.mr.client.MRTopicManager.TopicInfo; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ MRClientFactory.class, ToolsUtil.class }) +public class MessageCommandTest { + @InjectMocks + private MessageCommand command; + @Mock + private MRConsumer tm; + @Mock + private TopicInfo ti; + @Mock + private MRBatchingPublisher pub; + @Mock + private MRConsumer cc; + @Mock + private PrintStream printStream; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + PowerMockito.mockStatic(MRClientFactory.class); + PowerMockito.mockStatic(ToolsUtil.class); + PowerMockito.when(MRClientFactory.createConsumer(Arrays.asList("localhost"), "testtopic", "2", "3", -1, -1, + null, null, null)).thenReturn(cc); + + } + + @After + public void tearDown() throws Exception { + + } + + @Test + public void testGetMatches() { + + command.getMatches(); + assertTrue(true); + + } + + @Test + public void testCheckReady() { + + try { + command.checkReady(new MRCommandContext()); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + + @Test + public void testExecute() { + + String[] parts1 = { "read", "testtopic", "2", "3" }; + String[] parts2 = { "write", "testtopic", "2", "3" }; + List<String[]> parts = Arrays.asList(parts1, parts2); + for (Iterator iterator = parts.iterator(); iterator.hasNext();) { + String[] part = (String[]) iterator.next(); + + MRCommandContext context = new MRCommandContext(); + PowerMockito.when(ToolsUtil.createBatchPublisher(context, "testtopic")).thenReturn(pub); + try { + command.execute(part, context, printStream); + } catch (CommandNotReadyException e) { + assertTrue(true); + } + } + assertTrue(true); + + } + + @Test + public void testExecute_error1() { + try { + PowerMockito.doThrow(new Exception()).when(cc).fetch(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + String[] parts1 = { "read", "testtopic", "2", "3" }; + String[] parts2 = { "write", "testtopic", "2", "3" }; + List<String[]> parts = Arrays.asList(parts1, parts2); + for (Iterator iterator = parts.iterator(); iterator.hasNext();) { + String[] part = (String[]) iterator.next(); + + MRCommandContext context = new MRCommandContext(); + PowerMockito.when(ToolsUtil.createBatchPublisher(context, "testtopic")).thenReturn(pub); + try { + command.execute(part, context, printStream); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + assertTrue(true); + + } + + @Test + public void testExecute_error2() { + try { + PowerMockito.doThrow(new IOException()).when(pub).close(500, TimeUnit.MILLISECONDS); + PowerMockito.doThrow(new IOException()).when(pub).send("2", "3"); + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + String[] parts1 = { "read", "testtopic", "2", "3" }; + String[] parts2 = { "write", "testtopic", "2", "3" }; + List<String[]> parts = Arrays.asList(parts1, parts2); + for (Iterator iterator = parts.iterator(); iterator.hasNext();) { + String[] part = (String[]) iterator.next(); + + MRCommandContext context = new MRCommandContext(); + PowerMockito.when(ToolsUtil.createBatchPublisher(context, "testtopic")).thenReturn(pub); + try { + command.execute(part, context, printStream); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + assertTrue(true); + + } + + /* + * @Test public void testExecute_error3() { + * + * try { PowerMockito.doThrow(new IOException()).when(pub).send("2", "3"); + * PowerMockito.doThrow(new InterruptedException()).when(pub).close(500, + * TimeUnit.MILLISECONDS); } catch (IOException e) { // TODO Auto-generated + * catch block e.printStackTrace(); } catch (InterruptedException e) { // + * TODO Auto-generated catch block e.printStackTrace(); } String[] parts1 = + * { "read", "testtopic", "2", "3" }; String[] parts2 = { "write", + * "testtopic", "2", "3" }; List<String[]> parts = Arrays.asList(parts1, + * parts2); for (Iterator iterator = parts.iterator(); iterator.hasNext();) + * { String[] part = (String[]) iterator.next(); PrintStream printStream = + * new PrintStream(System.out); + * + * MRCommandContext context = new MRCommandContext(); + * PowerMockito.when(ToolsUtil.createBatchPublisher(context, + * "testtopic")).thenReturn(pub); try { command.execute(part, context, + * printStream); } catch (CommandNotReadyException e) { // TODO + * Auto-generated catch block e.printStackTrace(); } } assertTrue(true); + * + * } + */ + + @Test + public void testDisplayHelp() { + + command.displayHelp(printStream); + + } + +} diff --git a/src/test/java/org/onap/dmaap/mr/tools/TestRunner.java b/src/test/java/org/onap/dmaap/mr/tools/TestRunner.java new file mode 100644 index 0000000..fff3bd7 --- /dev/null +++ b/src/test/java/org/onap/dmaap/mr/tools/TestRunner.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2017 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.mr.tools; + +import org.junit.runner.JUnitCore; +import org.junit.runner.Result; +import org.junit.runner.notification.Failure; +import org.apache.log4j.Logger; + +public class TestRunner { + private static final Logger LOGGER = Logger.getLogger(TestRunner.class); + + public static void main(String[] args) { + // TODO Auto-generated method stub + Result result = JUnitCore.runClasses(JUnitTestSuite.class); + for (Failure failure : result.getFailures()) { + LOGGER.info(failure.toString()); + + } + LOGGER.info(result.wasSuccessful()); + } + +} diff --git a/src/test/java/org/onap/dmaap/mr/tools/ToolsUtilTest.java b/src/test/java/org/onap/dmaap/mr/tools/ToolsUtilTest.java new file mode 100644 index 0000000..080d6d5 --- /dev/null +++ b/src/test/java/org/onap/dmaap/mr/tools/ToolsUtilTest.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2018 Nokia + * ================================================================================ + * 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========================================================= + */ + +/** + * @author marcin.migdal@nokia.com + */ +package org.onap.dmaap.mr.tools; + +import org.onap.dmaap.mr.client.MRBatchingPublisher; +import java.util.Arrays; +import java.util.List; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; + +public class ToolsUtilTest { + + private final static List<String> clusters = Arrays.asList("Cluster1", "Cluster2"); + private final static String apiKey = "apiKey"; + private final static String apiPassword = "apiPassword"; + private final static String topicName = "topicName"; + + @Test + public void createBatchPublisher() { + MRCommandContext mrCommandContext = Mockito.mock(MRCommandContext.class); + Mockito.when(mrCommandContext.getCluster()).thenReturn(clusters); + Mockito.when(mrCommandContext.getApiKey()).thenReturn(apiKey); + Mockito.when(mrCommandContext.getApiPwd()).thenReturn(apiPassword); + + MRBatchingPublisher mrBatchingPublisher = ToolsUtil.createBatchPublisher(mrCommandContext, topicName); + + Assert.assertNotNull(mrBatchingPublisher); + } +} diff --git a/src/test/java/org/onap/dmaap/mr/tools/TopicCommandTest.java b/src/test/java/org/onap/dmaap/mr/tools/TopicCommandTest.java new file mode 100644 index 0000000..e8dd073 --- /dev/null +++ b/src/test/java/org/onap/dmaap/mr/tools/TopicCommandTest.java @@ -0,0 +1,224 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2017 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.mr.tools; + +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.io.PrintStream; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import com.att.nsa.apiClient.http.HttpException; +import com.att.nsa.apiClient.http.HttpObjectNotFoundException; +import com.att.nsa.cmdtool.CommandNotReadyException; +import org.onap.dmaap.mr.client.MRClientFactory; +import org.onap.dmaap.mr.client.MRTopicManager.TopicInfo; +import org.onap.dmaap.mr.client.MRTopicManager; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ MRClientFactory.class }) +public class TopicCommandTest { + @InjectMocks + private TopicCommand command; + @Mock + private MRTopicManager tm; + @Mock + private TopicInfo ti; + @Mock + private PrintStream printStream; + + @Before + public void setUp() throws Exception { + + MockitoAnnotations.initMocks(this); + PowerMockito.mockStatic(MRClientFactory.class); + PowerMockito.when(MRClientFactory.createTopicManager(Arrays.asList("localhost"), null, null)).thenReturn(tm); + PowerMockito.when(tm.getTopicMetadata("testtopic")).thenReturn(ti); + + } + + @After + public void tearDown() throws Exception { + + } + + @Test + public void testGetMatches() { + + command.getMatches(); + assertTrue(true); + + } + + @Test + public void testCheckReady() { + + try { + command.checkReady(new MRCommandContext()); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + + @Test + public void testExecute() { + + String[] parts1 = { "create", "testtopic", "1", "1" }; + String[] parts2 = { "grant", "write", "read", "1" }; + String[] parts3 = { "revoke", "write", "read", "1" }; + String[] parts4 = { "list", "testtopic", "1", "1" }; + List<String[]> parts = Arrays.asList(parts1, parts2, parts3, parts4); + for (Iterator iterator = parts.iterator(); iterator.hasNext();) { + String[] part = (String[]) iterator.next(); + + try { + command.execute(part, new MRCommandContext(), printStream); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + + } + + @Test + public void testExecute_error() { + + String[] parts1 = { "create", "testtopic", "1", "1" }; + String[] parts2 = { "grant", "write", "read", "1" }; + String[] parts3 = { "revoke", "write", "read", "1" }; + String[] parts4 = { "list", "testtopic", "1", "1" }; + List<String[]> parts = Arrays.asList(parts1, parts2, parts3, parts4); + for (Iterator iterator = parts.iterator(); iterator.hasNext();) { + String[] part = (String[]) iterator.next(); + + try { + command.execute(part, new MRCommandContext(), printStream); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + + } + + @Test + public void testExecute_error_1() throws com.att.nsa.apiClient.http.HttpException, IOException { + PowerMockito.when(tm.getTopicMetadata("testtopic")).thenThrow(new IOException("error")); + PowerMockito.doThrow(new IOException()).when(tm).createTopic("testtopic", "", 1, 1); + PowerMockito.doThrow(new IOException()).when(tm).revokeProducer("read", "1"); + String[] parts1 = { "create", "testtopic", "1", "1" }; + String[] parts2 = { "grant", "read", "read", "1" }; + String[] parts3 = { "revoke", "write", "read", "1" }; + String[] parts4 = { "list", "testtopic", "1", "1" }; + List<String[]> parts = Arrays.asList(parts1, parts2, parts3, parts4); + for (Iterator iterator = parts.iterator(); iterator.hasNext();) { + String[] part = (String[]) iterator.next(); + + try { + command.execute(part, new MRCommandContext(), printStream); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + + } + + @Test + public void testExecute_error_2() throws com.att.nsa.apiClient.http.HttpException, IOException { + PowerMockito.when(tm.getTopicMetadata("testtopic")).thenThrow(new HttpObjectNotFoundException("error")); + PowerMockito.doThrow(new HttpException(500, "error")).when(tm).createTopic("testtopic", "", 1, 1); + PowerMockito.doThrow(new HttpException(500, "error")).when(tm).revokeConsumer("read", "1"); + PowerMockito.doThrow(new HttpException(500, "error")).when(tm).allowConsumer("read", "1"); + String[] parts1 = { "create", "testtopic", "1", "1" }; + String[] parts2 = { "grant", "write", "write", "1" }; + String[] parts3 = { "revoke", "read", "read", "1" }; + String[] parts4 = { "list", "testtopic", "1", "1" }; + List<String[]> parts = Arrays.asList(parts1, parts2, parts3, parts4); + for (Iterator iterator = parts.iterator(); iterator.hasNext();) { + String[] part = (String[]) iterator.next(); + + try { + command.execute(part, new MRCommandContext(), printStream); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + + } + + @Test + public void testExecute_error_3() throws com.att.nsa.apiClient.http.HttpException, IOException { + PowerMockito.doThrow(new HttpException(500, "error")).when(tm).createTopic("testtopic", "", 1, 1); + PowerMockito.doThrow(new HttpException(500, "error")).when(tm).allowProducer("read", "1"); + String[] parts1 = { "create", "testtopic", "1a", "1a" }; + String[] parts2 = { "grant", "write", "read", "1" }; + List<String[]> parts = Arrays.asList(parts1, parts2); + for (Iterator iterator = parts.iterator(); iterator.hasNext();) { + String[] part = (String[]) iterator.next(); + + try { + command.execute(part, new MRCommandContext(), printStream); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + + } + + @Test + public void testDisplayHelp() { + + command.displayHelp(printStream); + assertTrue(true); + + } + +} diff --git a/src/test/java/org/onap/dmaap/mr/tools/TraceCommandTest.java b/src/test/java/org/onap/dmaap/mr/tools/TraceCommandTest.java new file mode 100644 index 0000000..de76acd --- /dev/null +++ b/src/test/java/org/onap/dmaap/mr/tools/TraceCommandTest.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2017 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.mr.tools; + +import static org.junit.Assert.assertTrue; + +import java.io.PrintStream; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.modules.junit4.PowerMockRunner; + +import com.att.nsa.cmdtool.CommandNotReadyException; + +@RunWith(PowerMockRunner.class) +public class TraceCommandTest { + @InjectMocks + private TraceCommand command; + private String[] parts = new String[5]; + @Mock + private PrintStream printStream; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + for (int i = 0; i < parts.length; i++) { + parts[i] = "String" + (i + 1); + } + + } + + @After + public void tearDown() throws Exception { + + } + + @Test + public void testGetMatches() { + + command.getMatches(); + assertTrue(true); + + } + + @Test + public void testCheckReady() { + + try { + command.checkReady(new MRCommandContext()); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + + @Test + public void testExecute() { + + try { + command.execute(parts, new MRCommandContext(), printStream); + } catch (CommandNotReadyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + + @Test + public void testDisplayHelp() { + + command.displayHelp(printStream); + assertTrue(true); + + } + +} diff --git a/src/test/java/org/onap/dmaap/mr/tools/ValidatorUtilTest.java b/src/test/java/org/onap/dmaap/mr/tools/ValidatorUtilTest.java new file mode 100644 index 0000000..1306a30 --- /dev/null +++ b/src/test/java/org/onap/dmaap/mr/tools/ValidatorUtilTest.java @@ -0,0 +1,315 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * org.onap.dmaap + * ================================================================================ + * Copyright © 2018 IBM 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * + *******************************************************************************/ + +package org.onap.dmaap.mr.tools; + +import static org.junit.Assert.assertEquals; + +import java.util.Properties; + +import org.junit.Test; + +import org.onap.dmaap.mr.test.clients.ProtocolTypeConstants; + +public class ValidatorUtilTest { + + @Test + public void testValidateForDME2WithNullServiceName() { + Properties props = new Properties(); + props.setProperty("TransportType", ProtocolTypeConstants.DME2.getValue()); + try{ + ValidatorUtil.validatePublisher(props); + } catch(IllegalArgumentException e) { + assertEquals(e.getMessage(), "Servicename is needed"); + } + + } + + @Test + public void testValidateForDME2WithNullTopic() { + Properties props = new Properties(); + props.setProperty("TransportType", ProtocolTypeConstants.DME2.getValue()); + props.setProperty("ServiceName", "ServiceName"); + try{ + ValidatorUtil.validatePublisher(props); + } catch(IllegalArgumentException e) { + assertEquals(e.getMessage(), "topic is needed"); + } + + } + + @Test + public void testValidateForDME2WithNullUserName() { + Properties props = new Properties(); + props.setProperty("TransportType", ProtocolTypeConstants.DME2.getValue()); + props.setProperty("ServiceName", "ServiceName"); + props.setProperty("topic", "topic"); + try{ + ValidatorUtil.validatePublisher(props); + } catch(IllegalArgumentException e) { + assertEquals(e.getMessage(), "username is needed"); + } + + } + + @Test + public void testValidateForDME2WithNullPassword() { + Properties props = new Properties(); + props.setProperty("TransportType", ProtocolTypeConstants.DME2.getValue()); + props.setProperty("ServiceName", "ServiceName"); + props.setProperty("topic", "topic"); + props.setProperty("username", "username"); + + try{ + ValidatorUtil.validatePublisher(props); + } catch(IllegalArgumentException e) { + assertEquals(e.getMessage(), "password is needed"); + } + + } + + + + + @Test + public void testValidateForNonDME2WithNullServiceName() { + Properties props = new Properties(); + props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue()); + try{ + ValidatorUtil.validatePublisher(props); + } catch(IllegalArgumentException e) { + assertEquals(e.getMessage(), "Servicename is needed"); + } + + } + + @Test + public void testValidateForNonDME2WithNullTopic() { + Properties props = new Properties(); + props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue()); + props.setProperty("host", "ServiceName"); + try{ + ValidatorUtil.validatePublisher(props); + } catch(IllegalArgumentException e) { + assertEquals(e.getMessage(), "topic is needed"); + } + + } + + @Test + public void testValidateForNonDME2WithNullContenttype() { + Properties props = new Properties(); + props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue()); + props.setProperty("host", "ServiceName"); + props.setProperty("topic", "topic"); + try{ + ValidatorUtil.validatePublisher(props); + } catch(IllegalArgumentException e) { + assertEquals(e.getMessage(), "contenttype is needed"); + } + + } + + + @Test + public void testValidateForNonDME2WithNullUserName() { + Properties props = new Properties(); + props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue()); + props.setProperty("host", "ServiceName"); + props.setProperty("topic", "topic"); + props.setProperty("contenttype", "contenttype"); + try{ + ValidatorUtil.validatePublisher(props); + } catch(IllegalArgumentException e) { + assertEquals(e.getMessage(), "username is needed"); + } + + } + + @Test + public void testValidateForNonDME2WithNullPassword() { + Properties props = new Properties(); + props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue()); + props.setProperty("host", "ServiceName"); + props.setProperty("topic", "topic"); + props.setProperty("username", "username"); + props.setProperty("contenttype", "contenttype"); + + try{ + ValidatorUtil.validatePublisher(props); + } catch(IllegalArgumentException e) { + assertEquals(e.getMessage(), "password is needed"); + } + + } + + @Test + public void testValidateForNonDME2WithAuthKey() { + Properties props = new Properties(); + props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue()); + props.setProperty("host", "ServiceName"); + props.setProperty("topic", "topic"); + props.setProperty("username", "username"); + props.setProperty("contenttype", "contenttype"); + props.setProperty("password", "password"); + + try{ + ValidatorUtil.validatePublisher(props); + } catch(IllegalArgumentException e) { + assertEquals(e.getMessage(), "authKey is needed"); + } + + } + + @Test + public void testValidateForNonDME2WithOutAuthDate() { + Properties props = new Properties(); + props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue()); + props.setProperty("host", "ServiceName"); + props.setProperty("topic", "topic"); + props.setProperty("username", "username"); + props.setProperty("contenttype", "contenttype"); + props.setProperty("password", "password"); + props.setProperty("authKey", "authKey"); + + + try{ + ValidatorUtil.validatePublisher(props); + } catch(IllegalArgumentException e) { + assertEquals(e.getMessage(), "authDate is needed"); + } + } + + @Test + public void testValidateForNonDME2WithAuthDate() { + Properties props = new Properties(); + props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue()); + props.setProperty("host", "ServiceName"); + props.setProperty("topic", "topic"); + props.setProperty("username", "username"); + props.setProperty("contenttype", "contenttype"); + props.setProperty("password", "password"); + props.setProperty("authKey", "authKey"); + props.setProperty("authDate", "authDate"); + + try{ + ValidatorUtil.validatePublisher(props); + } catch(IllegalArgumentException e) { + assertEquals(e.getMessage(), "maxBatchSize is needed"); + } + } + + + @Test + public void testValidateForNonDME2WithMaxAgeMs() { + Properties props = new Properties(); + props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue()); + props.setProperty("host", "ServiceName"); + props.setProperty("topic", "topic"); + props.setProperty("username", "username"); + props.setProperty("contenttype", "contenttype"); + props.setProperty("password", "password"); + props.setProperty("authKey", "authKey"); + props.setProperty("authDate", "authDate"); + props.setProperty("maxBatchSize", "maxBatchSize"); + + try{ + ValidatorUtil.validatePublisher(props); + } catch(IllegalArgumentException e) { + assertEquals(e.getMessage(), "maxAgeMs is needed"); + } + + + + } + + @Test + public void testValidateForNonDME2WithMessageSentThreadOccurance() { + Properties props = new Properties(); + props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue()); + props.setProperty("host", "ServiceName"); + props.setProperty("topic", "topic"); + props.setProperty("username", "username"); + props.setProperty("contenttype", "contenttype"); + props.setProperty("password", "password"); + props.setProperty("authKey", "authKey"); + props.setProperty("authDate", "authDate"); + props.setProperty("maxBatchSize", "maxBatchSize"); + props.setProperty("maxAgeMs", "maxAgeMs"); + + try{ + ValidatorUtil.validatePublisher(props); + } catch(IllegalArgumentException e) { + assertEquals(e.getMessage(), "MessageSentThreadOccurance is needed"); + } + + } + + + @Test + public void testValidateSubscriberWithoutGroup() { + Properties props = new Properties(); + props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue()); + props.setProperty("host", "ServiceName"); + props.setProperty("topic", "topic"); + props.setProperty("username", "username"); + props.setProperty("contenttype", "contenttype"); + props.setProperty("password", "password"); + props.setProperty("authKey", "authKey"); + props.setProperty("authDate", "authDate"); + props.setProperty("maxBatchSize", "maxBatchSize"); + props.setProperty("maxAgeMs", "maxAgeMs"); + + try{ + ValidatorUtil.validateSubscriber(props); + } catch(IllegalArgumentException e) { + assertEquals(e.getMessage(), "group is needed"); + } + } + + @Test + public void testValidateSubscriberWithoutCustomer() { + Properties props = new Properties(); + props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue()); + props.setProperty("host", "ServiceName"); + props.setProperty("topic", "topic"); + props.setProperty("username", "username"); + props.setProperty("contenttype", "contenttype"); + props.setProperty("password", "password"); + props.setProperty("authKey", "authKey"); + props.setProperty("authDate", "authDate"); + props.setProperty("maxBatchSize", "maxBatchSize"); + props.setProperty("maxAgeMs", "maxAgeMs"); + props.setProperty("group", "group"); + + try{ + ValidatorUtil.validateSubscriber(props); + } catch(IllegalArgumentException e) { + assertEquals(e.getMessage(), "Consumer (Id) is needed"); + } + } + + + + + +} |