--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+public class DMaaPCambriaExceptionMapperTest {\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testToResponse() {\r
+ \r
+ DMaaPCambriaExceptionMapper mapper = new DMaaPCambriaExceptionMapper();\r
+ \r
+ try {\r
+ mapper.toResponse(null);\r
+ } catch(NullPointerException e) {\r
+ assertTrue(true);\r
+ }\r
+ \r
+ \r
+ \r
+ \r
+ \r
+ }\r
+ \r
+ \r
+ \r
+ \r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+public class DMaaPWebExceptionMapperTest {\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testToResponse() {\r
+ \r
+ DMaaPWebExceptionMapper mapper = new DMaaPWebExceptionMapper();\r
+ \r
+ try {\r
+ mapper.toResponse(null);\r
+ } catch(NullPointerException e) {\r
+ assertTrue(true);\r
+ }\r
+ \r
+ \r
+ \r
+ \r
+ \r
+ }\r
+ \r
+ \r
+ \r
+ \r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+public class HelloWorldTest {\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testToResponse() {\r
+ \r
+ HelloWorld hello = new HelloWorld();\r
+ \r
+ try {\r
+ hello.speak(null);\r
+ } catch(NullPointerException e) {\r
+ assertTrue(true);\r
+ }\r
+ \r
+ \r
+ }\r
+ \r
+ \r
+ \r
+ \r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap;\r
+\r
+import junit.framework.TestSuite;\r
+\r
+import org.junit.runner.RunWith;\r
+import org.junit.runners.Suite;\r
+import org.junit.runners.Suite.SuiteClasses;\r
+import org.apache.log4j.Logger;\r
+\r
+@RunWith(Suite.class)\r
+@SuiteClasses({ DMaaPCambriaExceptionMapperTest.class, DMaaPWebExceptionMapper.class, \r
+ JaxrsEchoServiceTest.class, HelloWorldTest.class, JaxrsUserServiceTest.class })\r
+public class JUnitTestSuite {\r
+ private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);\r
+\r
+ public static void main(String[] args) {\r
+ LOGGER.info("Running the test suite");\r
+ \r
+ TestSuite tstSuite = new TestSuite();\r
+ LOGGER.info("Total Test Counts " + tstSuite.countTestCases());\r
+ }\r
+\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+public class JaxrsEchoServiceTest {\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testPing() {\r
+\r
+ JaxrsEchoService service = new JaxrsEchoService();\r
+\r
+ service.ping("hello");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testGetProperty() {\r
+\r
+ JaxrsEchoService service = new JaxrsEchoService();\r
+\r
+ service.getProperty("filename", "hello");\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+public class JaxrsUserServiceTest {\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testLookupUser() {\r
+\r
+ JaxrsUserService service = new JaxrsUserService();\r
+\r
+ service.lookupUser("userid");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ \r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap;\r
+\r
+import org.junit.runner.JUnitCore;\r
+import org.junit.runner.Result;\r
+import org.junit.runner.notification.Failure;\r
+import org.apache.log4j.Logger;\r
+\r
+public class TestRunner {\r
+ private static final Logger LOGGER = Logger.getLogger(TestRunner.class);\r
+\r
+ public static void main(String[] args) {\r
+ // TODO Auto-generated method stub\r
+ Result result = JUnitCore.runClasses(JUnitTestSuite.class);\r
+ for (Failure failure : result.getFailures()) {\r
+ LOGGER.info(failure.toString());\r
+ \r
+ }\r
+ LOGGER.info(result.wasSuccessful());\r
+ }\r
+\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.filemonitor;\r
+\r
+import junit.framework.TestSuite;\r
+\r
+import org.junit.runner.RunWith;\r
+import org.junit.runners.Suite;\r
+import org.junit.runners.Suite.SuiteClasses;\r
+import org.apache.log4j.Logger;\r
+\r
+@RunWith(Suite.class)\r
+@SuiteClasses({ ServicePropertiesListenerTest.class, ServicePropertiesMapTest.class, \r
+ ServicePropertyServiceTest.class, })\r
+public class JUnitTestSuite {\r
+ private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);\r
+\r
+ public static void main(String[] args) {\r
+ LOGGER.info("Running the test suite");\r
+ \r
+ TestSuite tstSuite = new TestSuite();\r
+ LOGGER.info("Total Test Counts " + tstSuite.countTestCases());\r
+ }\r
+\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.filemonitor;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import java.io.File;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+public class ServicePropertiesListenerTest {\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testUpdate() {\r
+\r
+ ServicePropertiesListener listener = new ServicePropertiesListener();\r
+\r
+ try {\r
+ listener.update(new File(":/file"));\r
+ } catch (Exception e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.filemonitor;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import java.io.File;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+public class ServicePropertiesMapTest {\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testRefresh() {\r
+\r
+ ServicePropertiesMap map = new ServicePropertiesMap();\r
+\r
+ try {\r
+ map.refresh(new File(":/file"));\r
+ } catch (Exception e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testGetProperty() {\r
+\r
+ ServicePropertiesMap map = new ServicePropertiesMap();\r
+\r
+ try {\r
+ map.getProperty("filename", "propertykey");\r
+ } catch (Exception e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+\r
+ assertTrue(true);\r
+ }\r
+\r
+ @Test\r
+ public void testGetProperties() {\r
+\r
+ ServicePropertiesMap map = new ServicePropertiesMap();\r
+\r
+ try {\r
+ map.getProperties("filename");\r
+ } catch (Exception e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testIfNullThenEmpty() {\r
+\r
+ ServicePropertiesMap map = new ServicePropertiesMap();\r
+\r
+ try {\r
+ map.getProperties("filename");\r
+ } catch (Exception e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.filemonitor;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import java.io.File;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+public class ServicePropertyServiceTest {\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testInit() {\r
+\r
+ ServicePropertyService service = new ServicePropertyService();\r
+ try {\r
+ service.init();\r
+ } catch (Exception e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testsetLoadOnStartup() {\r
+\r
+ ServicePropertyService service = new ServicePropertyService();\r
+ try {\r
+ service.setLoadOnStartup(true);\r
+ } catch (Exception e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testSetSsfFileMonitorPollingInterval() {\r
+\r
+ ServicePropertyService service = new ServicePropertyService();\r
+ try {\r
+ service.setSsfFileMonitorPollingInterval("interval");\r
+ } catch (Exception e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testSetSsfFileMonitorThreadpoolSize() {\r
+\r
+ ServicePropertyService service = new ServicePropertyService();\r
+ try {\r
+ service.setSsfFileMonitorThreadpoolSize("threadPoolSize");\r
+ } catch (Exception e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testIsLoadOnStartup() {\r
+ ServicePropertyService service = new ServicePropertyService();\r
+ service.isLoadOnStartup();\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetSsfFileMonitorPollingInterval() {\r
+ ServicePropertyService service = new ServicePropertyService();\r
+ service.getSsfFileMonitorPollingInterval();\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetSsfFileMonitorThreadpoolSize() {\r
+ ServicePropertyService service = new ServicePropertyService();\r
+ service.getSsfFileMonitorThreadpoolSize();\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetFileChangedListener() {\r
+ ServicePropertyService service = new ServicePropertyService();\r
+ service.getFileChangedListener();\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testSetFileChangedListener() {\r
+ ServicePropertyService service = new ServicePropertyService();\r
+ service.setFileChangedListener(null);\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetFilePropertiesMap() {\r
+ ServicePropertyService service = new ServicePropertyService();\r
+ service.getFilePropertiesMap();\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testSetFilePropertiesMap() {\r
+ ServicePropertyService service = new ServicePropertyService();\r
+ service.setFilePropertiesMap(null);\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.filemonitor;\r
+\r
+import org.junit.runner.JUnitCore;\r
+import org.junit.runner.Result;\r
+import org.junit.runner.notification.Failure;\r
+import org.apache.log4j.Logger;\r
+\r
+public class TestRunner {\r
+ private static final Logger LOGGER = Logger.getLogger(TestRunner.class);\r
+\r
+ public static void main(String[] args) {\r
+ // TODO Auto-generated method stub\r
+ Result result = JUnitCore.runClasses(JUnitTestSuite.class);\r
+ for (Failure failure : result.getFailures()) {\r
+ LOGGER.info(failure.toString());\r
+ \r
+ }\r
+ LOGGER.info(result.wasSuccessful());\r
+ }\r
+\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.mmagent;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+public class CreateMirrorMakerTest {\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testGetCreateMirrorMaker() {\r
+\r
+ CreateMirrorMaker mMaker = new CreateMirrorMaker();\r
+ mMaker.getCreateMirrorMaker();\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testSetCreateMirrorMaker() {\r
+\r
+ CreateMirrorMaker mMaker = new CreateMirrorMaker();\r
+ mMaker.setCreateMirrorMaker(new MirrorMaker());\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testGetMessageID() {\r
+\r
+ CreateMirrorMaker mMaker = new CreateMirrorMaker();\r
+ mMaker.getMessageID();\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testSetMessageID() {\r
+\r
+ CreateMirrorMaker mMaker = new CreateMirrorMaker();\r
+ mMaker.setMessageID("messageID");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.mmagent;\r
+\r
+import junit.framework.TestSuite;\r
+\r
+import org.junit.runner.RunWith;\r
+import org.junit.runners.Suite;\r
+import org.junit.runners.Suite.SuiteClasses;\r
+import org.apache.log4j.Logger;\r
+\r
+@RunWith(Suite.class)\r
+@SuiteClasses({ CreateMirrorMakerTest.class, MirrorMakerTest.class, \r
+ UpdateMirrorMakerTest.class, UpdateWhiteListTest.class,})\r
+public class JUnitTestSuite {\r
+ private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);\r
+\r
+ public static void main(String[] args) {\r
+ LOGGER.info("Running the test suite");\r
+ \r
+ TestSuite tstSuite = new TestSuite();\r
+ LOGGER.info("Total Test Counts " + tstSuite.countTestCases());\r
+ }\r
+\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.mmagent;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+public class MirrorMakerTest {\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testGetStatus() {\r
+\r
+ MirrorMaker mMaker = new MirrorMaker();\r
+ mMaker.getStatus();\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testSetStatus() {\r
+\r
+ MirrorMaker mMaker = new MirrorMaker();\r
+ mMaker.setStatus("status");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetName() {\r
+\r
+ MirrorMaker mMaker = new MirrorMaker();\r
+ mMaker.getName();\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testSetName() {\r
+\r
+ MirrorMaker mMaker = new MirrorMaker();\r
+ mMaker.setName("name");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ \r
+ @Test\r
+ public void testGetConsumer() {\r
+\r
+ MirrorMaker mMaker = new MirrorMaker();\r
+ mMaker.getConsumer();\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testSetConsumer() {\r
+\r
+ MirrorMaker mMaker = new MirrorMaker();\r
+ mMaker.setConsumer("consumer");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetProducer() {\r
+\r
+ MirrorMaker mMaker = new MirrorMaker();\r
+ mMaker.getProducer();\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testSetProducer() {\r
+\r
+ MirrorMaker mMaker = new MirrorMaker();\r
+ mMaker.setProducer("producer");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+\r
+ @Test\r
+ public void testGetWhitelist() {\r
+\r
+ MirrorMaker mMaker = new MirrorMaker();\r
+ mMaker.getWhitelist();\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testSetWhitelist() {\r
+\r
+ MirrorMaker mMaker = new MirrorMaker();\r
+ mMaker.setWhitelist("whitelist");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ \r
+}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.mmagent;\r
+\r
+import org.junit.runner.JUnitCore;\r
+import org.junit.runner.Result;\r
+import org.junit.runner.notification.Failure;\r
+import org.apache.log4j.Logger;\r
+\r
+public class TestRunner {\r
+ private static final Logger LOGGER = Logger.getLogger(TestRunner.class);\r
+\r
+ public static void main(String[] args) {\r
+ // TODO Auto-generated method stub\r
+ Result result = JUnitCore.runClasses(JUnitTestSuite.class);\r
+ for (Failure failure : result.getFailures()) {\r
+ LOGGER.info(failure.toString());\r
+ \r
+ }\r
+ LOGGER.info(result.wasSuccessful());\r
+ }\r
+\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.mmagent;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+public class UpdateMirrorMakerTest {\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testGetUpdateMirrorMaker() {\r
+\r
+ UpdateMirrorMaker mMaker = new UpdateMirrorMaker();\r
+ mMaker.getUpdateMirrorMaker();\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testSetUpdateMirrorMaker() {\r
+\r
+ UpdateMirrorMaker mMaker = new UpdateMirrorMaker();\r
+ mMaker.setUpdateMirrorMaker(new MirrorMaker());\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetMessageID() {\r
+\r
+ UpdateMirrorMaker mMaker = new UpdateMirrorMaker();\r
+ mMaker.getMessageID();\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testSetMessageID() {\r
+\r
+ UpdateMirrorMaker mMaker = new UpdateMirrorMaker();\r
+ mMaker.setMessageID("messageID");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.mmagent;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+public class UpdateWhiteListTest {\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testGetUpdateWhiteList() {\r
+\r
+ UpdateWhiteList wList = new UpdateWhiteList();\r
+ wList.getUpdateWhiteList();\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testSetUpdateWhiteList() {\r
+\r
+ UpdateWhiteList wList = new UpdateWhiteList();\r
+ wList.setUpdateWhiteList(new MirrorMaker());\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetMessageID() {\r
+\r
+ UpdateWhiteList wList = new UpdateWhiteList();\r
+ wList.getMessageID();\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testSetMessageID() {\r
+\r
+ UpdateWhiteList wList = new UpdateWhiteList();\r
+ wList.setMessageID("messageID");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ \r
+ \r
+\r
+\r
+\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.service;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+/*import org.mockito.InjectMocks;\r
+import org.mockito.Mock;\r
+import org.mockito.MockitoAnnotations;\r
+import com.att.nsa.cambria.CambriaApiException;\r
+import static org.mockito.Mockito.when;\r
+*/\r
+import javax.servlet.http.HttpServletRequest;\r
+\r
+import com.att.nsa.cambria.beans.DMaaPContext;\r
+import java.util.Enumeration;\r
+import com.att.nsa.cambria.service.AdminService;\r
+import com.att.nsa.configs.ConfigDbException;\r
+import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;\r
+\r
+public class AdminRestServiceTest {/*\r
+\r
+ @InjectMocks\r
+ AdminRestService adminRestService;\r
+\r
+ @Mock\r
+ AdminService adminService;\r
+\r
+ @Mock\r
+ DMaaPContext dmaapContext;\r
+\r
+ @Mock\r
+ HttpServletRequest httpServReq;\r
+\r
+ @Mock\r
+ Enumeration headerNames;\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ MockitoAnnotations.initMocks(this);\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testGetConsumerCache() throws CambriaApiException, AccessDeniedException {\r
+ adminRestService.getConsumerCache();\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testDropConsumerCache() throws CambriaApiException, AccessDeniedException {\r
+ adminRestService.dropConsumerCache();\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testGetBlacklist() throws CambriaApiException, AccessDeniedException {\r
+\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+ when(httpServReq.getHeaderNames()).thenReturn(headerNames);\r
+ when(headerNames.nextElement()).thenReturn("key");\r
+ when(httpServReq.getHeader("key")).thenReturn("value");\r
+\r
+ adminRestService.getBlacklist();\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testAddToBlacklist() throws CambriaApiException, AccessDeniedException {\r
+\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+\r
+ adminRestService.addToBlacklist("120.120.120.120");\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testRemoveFromBlacklist() throws CambriaApiException, AccessDeniedException, ConfigDbException {\r
+\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+\r
+ adminRestService.removeFromBlacklist("120.120.120.120");\r
+\r
+ }\r
+\r
+*/}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.service;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import java.lang.reflect.InvocationTargetException;\r
+import java.lang.reflect.Method;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+import com.att.nsa.cambria.CambriaApiException;\r
+import com.att.nsa.cambria.beans.ApiKeyBean;\r
+import com.att.nsa.configs.ConfigDbException;\r
+import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;\r
+\r
+public class ApiKeysRestServiceTest {\r
+\r
+ private ApiKeysRestService service = null;\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ service = new ApiKeysRestService();\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testGetAllApiKeys() {\r
+\r
+ try {\r
+ service.getAllApiKeys();\r
+ } catch (CambriaApiException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (NullPointerException e) {\r
+ assertTrue(true);\r
+ }\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetApiKey() {\r
+\r
+ try {\r
+ service.getApiKey("apikeyName");\r
+ } catch (CambriaApiException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (NullPointerException e) {\r
+ assertTrue(true);\r
+ }\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testCreateApiKey() {\r
+\r
+ try {\r
+ service.createApiKey(new ApiKeyBean("hs647a@att.com", "test apikey"));\r
+ } catch (CambriaApiException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (NullPointerException e) {\r
+ assertTrue(true);\r
+ }\r
+\r
+ }\r
+\r
+ \r
+ @Test\r
+ public void testUpdateApiKey() {\r
+\r
+ try {\r
+ service.updateApiKey("apikeyName", new ApiKeyBean("hs647a@att.com", "test apikey"));\r
+ } catch (CambriaApiException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (NullPointerException e) {\r
+ assertTrue(true);\r
+ }\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testDeleteApiKey() {\r
+\r
+ try {\r
+ service.deleteApiKey("apikeyName");\r
+ } catch (CambriaApiException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (NullPointerException e) {\r
+ assertTrue(true);\r
+ }\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetDmaapContext() {\r
+ Class clazz = null;\r
+ Method method = null;\r
+ try {\r
+ clazz = Class.forName("ApiKeysRestService");\r
+ Object obj = clazz.newInstance();\r
+ method = clazz.getDeclaredMethod("getDmaapContext", null);\r
+ method.setAccessible(true);\r
+ method.invoke(obj, null);\r
+ } catch (ClassNotFoundException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (NoSuchMethodException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (SecurityException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (InstantiationException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (IllegalAccessException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (IllegalArgumentException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (InvocationTargetException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+\r
+ assertTrue(true);\r
+ }\r
+\r
+ \r
+ \r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package com.att.nsa.dmaap.service;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+import org.junit.runner.RunWith;\r
+/*import org.mockito.InjectMocks;\r
+import org.mockito.Mock;\r
+import org.mockito.Mockito;\r
+import org.mockito.MockitoAnnotations;\r
+import org.powermock.core.classloader.annotations.PrepareForTest;\r
+import org.powermock.modules.junit4.PowerMockRunner;*/\r
+\r
+import com.att.ajsc.beans.PropertiesMapBean;\r
+import com.att.nsa.cambria.CambriaApiException;\r
+import com.att.nsa.cambria.backends.ConsumerFactory.UnavailableException;\r
+import com.att.nsa.cambria.service.EventsService;\r
+import com.att.nsa.configs.ConfigDbException;\r
+import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;\r
+\r
+//import static org.mockito.Mockito.when;\r
+\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+\r
+import javax.servlet.ServletInputStream;\r
+import javax.servlet.ServletOutputStream;\r
+import javax.servlet.http.HttpServletRequest;\r
+\r
+import com.att.nsa.cambria.beans.DMaaPContext;\r
+import com.att.nsa.cambria.exception.DMaaPAccessDeniedException;\r
+import com.att.nsa.cambria.exception.ErrorResponse;\r
+import com.att.nsa.cambria.metabroker.Broker.TopicExistsException;\r
+\r
+/*@RunWith(PowerMockRunner.class)\r
+@PrepareForTest({ PropertiesMapBean.class })*/\r
+public class EventsRestServiceTest {/*\r
+\r
+ @InjectMocks\r
+ EventsRestService eventsRestRestService;\r
+\r
+ @Mock\r
+ private EventsService eventsService;\r
+ \r
+ @Mock\r
+ ErrorResponse errorResponse;\r
+ \r
+ @Mock\r
+ DMaaPContext dmaapContext;\r
+\r
+ @Mock\r
+ InputStream iStream;\r
+\r
+ @Mock\r
+ ServletInputStream servletInputStream;\r
+\r
+ @Mock\r
+ HttpServletRequest httpServReq;\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ MockitoAnnotations.initMocks(this);\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testGetEvents() throws CambriaApiException {\r
+\r
+ eventsRestRestService.getEvents("topicName", "consumergroup", "consumerid");\r
+\r
+ }\r
+\r
+ @Test(expected = TopicExistsException.class)\r
+ public void testGetEvents_TopicExistException() throws CambriaApiException, ConfigDbException, TopicExistsException,\r
+ UnavailableException, IOException, AccessDeniedException {\r
+\r
+ Mockito.doThrow(new TopicExistsException("topic exists")).when(eventsService).getEvents(dmaapContext,\r
+ "topicName", "consumergroup", "consumerid");\r
+\r
+ eventsService.getEvents(dmaapContext, "topicName", "consumergroup", "consumerid");\r
+\r
+ }\r
+ \r
+ @Test(expected = DMaaPAccessDeniedException.class)\r
+ public void testGetEvents_DMaaPAccessDeniedException() throws CambriaApiException, ConfigDbException, TopicExistsException,\r
+ UnavailableException, IOException, AccessDeniedException {\r
+\r
+ Mockito.doThrow(new DMaaPAccessDeniedException(errorResponse)).when(eventsService).getEvents(dmaapContext,\r
+ "topicName", "consumergroup", "consumerid");\r
+\r
+ eventsService.getEvents(dmaapContext, "topicName", "consumergroup", "consumerid");\r
+\r
+ }\r
+ \r
+ @Test(expected = DMaaPAccessDeniedException.class)\r
+ public void testGetEvents_DMaaPAccessDeniedException() throws CambriaApiException, ConfigDbException, TopicExistsException,\r
+ UnavailableException, IOException, AccessDeniedException {\r
+\r
+ Mockito.doThrow(new DMaaPAccessDeniedException(errorResponse)).when(eventsService).getEvents(dmaapContext,\r
+ "topicName", "consumergroup", "consumerid");\r
+\r
+ eventsService.getEvents(dmaapContext, "topicName", "consumergroup", "consumerid");\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testPushEvents() throws CambriaApiException {\r
+\r
+ eventsRestRestService.pushEvents("topicName", iStream, "partitionKey");\r
+\r
+ }\r
+ \r
+\r
+ @Test\r
+ public void testPushEvents_TopicExistException() throws CambriaApiException {\r
+\r
+ eventsRestRestService.pushEvents("topicName", iStream, "partitionKey");\r
+\r
+ }\r
+\r
+ @Test\r
+ public void tesTPushEventsWithTransaction() throws CambriaApiException, IOException {\r
+ // when(dmaapContext.getRequest()).th\r
+ // thenReturn(httpServReq);\r
+ when(httpServReq.getInputStream()).thenReturn(servletInputStream);\r
+ eventsRestRestService.pushEventsWithTransaction("topicName", "partitionKey");\r
+\r
+ }\r
+\r
+*/}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.service;\r
+\r
+import junit.framework.TestSuite;\r
+\r
+import org.junit.runner.RunWith;\r
+import org.junit.runners.Suite;\r
+import org.junit.runners.Suite.SuiteClasses;\r
+import org.apache.log4j.Logger;\r
+\r
+@RunWith(Suite.class)\r
+@SuiteClasses({ AdminRestServiceTest.class, ApiKeysRestServiceTest.class, \r
+ EventsRestServiceTest.class, MetricsRestServiceTest.class, MMRestServiceTest.class, \r
+ TopicRestServiceTest.class, TransactionRestServiceTest.class, UIRestServicesTest.class,})\r
+public class JUnitTestSuite {\r
+ private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);\r
+\r
+ public static void main(String[] args) {\r
+ LOGGER.info("Running the test suite");\r
+ \r
+ TestSuite tstSuite = new TestSuite();\r
+ LOGGER.info("Total Test Counts " + tstSuite.countTestCases());\r
+ }\r
+\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.service;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+//import static org.mockito.Matchers.anyString;\r
+//import static org.mockito.Mockito.when;\r
+\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+\r
+import javax.servlet.ServletOutputStream;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+import org.junit.After;\r
+import org.json.JSONArray;\r
+import org.json.JSONException;\r
+import org.json.JSONObject;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+import org.junit.runner.RunWith;\r
+/*import org.mockito.InjectMocks;\r
+import org.mockito.Mock;\r
+import org.mockito.MockitoAnnotations;\r
+import org.powermock.api.mockito.PowerMockito;\r
+import org.powermock.core.classloader.annotations.PrepareForTest;\r
+import org.powermock.modules.junit4.PowerMockRunner;*/\r
+\r
+import com.att.ajsc.beans.PropertiesMapBean;\r
+import com.att.ajsc.filemonitor.AJSCPropertiesMap;\r
+import com.att.nsa.cambria.CambriaApiException;\r
+import com.att.nsa.cambria.beans.DMaaPContext;\r
+import com.att.nsa.cambria.beans.DMaaPKafkaMetaBroker;\r
+import com.att.nsa.cambria.constants.CambriaConstants;\r
+import com.att.nsa.cambria.exception.DMaaPAccessDeniedException;\r
+import com.att.nsa.cambria.exception.DMaaPErrorMessages;\r
+import com.att.nsa.cambria.metabroker.Broker.TopicExistsException;\r
+import com.att.nsa.cambria.metabroker.Topic;\r
+import com.att.nsa.cambria.security.DMaaPAAFAuthenticator;\r
+import com.att.nsa.cambria.security.DMaaPAAFAuthenticatorImpl;\r
+import com.att.nsa.cambria.security.DMaaPAuthenticator;\r
+import com.att.nsa.cambria.service.MMService;\r
+import com.att.nsa.cambria.utils.ConfigurationReader;\r
+import com.att.nsa.configs.ConfigDbException;\r
+import com.att.nsa.dmaap.mmagent.CreateMirrorMaker;\r
+import com.att.nsa.dmaap.mmagent.MirrorMaker;\r
+import com.att.nsa.dmaap.mmagent.UpdateMirrorMaker;\r
+import com.att.nsa.security.NsaAcl;\r
+import com.att.nsa.security.NsaApiKey;\r
+import com.att.nsa.security.db.simple.NsaSimpleApiKey;\r
+\r
+//@RunWith(MockitoJUnitRunner.class)\r
+/*@RunWith(PowerMockRunner.class)\r
+@PrepareForTest({ PropertiesMapBean.class, AJSCPropertiesMap.class })*/\r
+public class MMRestServiceTest {/*\r
+\r
+ @InjectMocks\r
+ MMRestService mmRestService;\r
+\r
+ @Mock\r
+ private MMService mmservice;\r
+\r
+ @Mock\r
+ CreateMirrorMaker cMirroMaker;\r
+\r
+ @Mock\r
+ UpdateMirrorMaker uMirroMaker;\r
+\r
+ private TopicRestService service = new TopicRestService();\r
+ @Mock\r
+ private DMaaPErrorMessages errorMessages;\r
+\r
+ @Mock\r
+ DMaaPContext dmaapContext;\r
+\r
+ @Mock\r
+ ConfigurationReader configReader;\r
+\r
+ @Mock\r
+ ServletOutputStream oStream;\r
+\r
+ @Mock\r
+ DMaaPAuthenticator<NsaSimpleApiKey> dmaaPAuthenticator;\r
+\r
+ @Mock\r
+ MirrorMaker mMaker;\r
+\r
+ @Mock\r
+ DMaaPAAFAuthenticator dmaapAAFauthenticator;\r
+\r
+ @Mock\r
+ DMaaPAAFAuthenticatorImpl impl;\r
+\r
+ @Mock\r
+ NsaApiKey user;\r
+\r
+ @Mock\r
+ NsaSimpleApiKey nsaSimpleApiKey;\r
+\r
+ @Mock\r
+ HttpServletRequest httpServReq;\r
+\r
+ @Mock\r
+ HttpServletResponse httpServRes;\r
+\r
+ @Mock\r
+ InputStream iStream;\r
+\r
+ @Mock\r
+ DMaaPKafkaMetaBroker dmaapKafkaMetaBroker;\r
+\r
+ @Mock\r
+ Topic createdTopic;\r
+\r
+ @Mock\r
+ NsaAcl nsaAcl;\r
+\r
+ @Mock\r
+ JSONObject jsonObj;\r
+\r
+ @Mock\r
+ JSONArray jsonArray;\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+\r
+ MockitoAnnotations.initMocks(this);\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+\r
+ @Test\r
+ public void testCallCreateMirrorMaker() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
+ TopicExistsException, JSONException, ConfigDbException {\r
+\r
+ Assert.assertNotNull(mmRestService);\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+ when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "admin")).thenReturn(true);\r
+ when(httpServReq.isUserInRole("admin")).thenReturn(true);\r
+\r
+ PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
+\r
+ assertTrue(true);\r
+ when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeradmin.aaf"))\r
+ .thenReturn("admin");\r
+\r
+ when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormaker.timeout"))\r
+ .thenReturn("100");\r
+\r
+ when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormaker.topic"))\r
+ .thenReturn("mirrormaker.topic");\r
+\r
+ when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormaker.consumergroup"))\r
+ .thenReturn("mirrormaker.consumergroup");\r
+\r
+ when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormaker.consumerid"))\r
+ .thenReturn("mirrormaker.consumerid");\r
+\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+\r
+ when(httpServReq.isUserInRole("admin")).thenReturn(true);\r
+ \r
+\r
+ // when(httpServReq.getHeader("Authorization")).thenReturn("Admin");\r
+ when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "admin.aaf")).thenReturn(true);\r
+ when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "admin")).thenReturn(true);\r
+ when(httpServReq.getHeader("Authorization")).thenReturn("Admin");\r
+ when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "admin")).thenReturn(true);\r
+\r
+ when(cMirroMaker.getCreateMirrorMaker()).thenReturn(mMaker);\r
+\r
+ when(mMaker.getName()).thenReturn("mirroMakerName");\r
+ when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+ when(httpServReq.getHeader("Authorization")).thenReturn("Authorization");\r
+\r
+ when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
+ when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
+ when(httpServReq.getMethod()).thenReturn("HEAD");\r
+\r
+ when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null);\r
+\r
+ mmRestService.callCreateMirrorMaker(iStream);\r
+ }\r
+\r
+ @Test\r
+ public void testCallListAllMirrorMaker() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
+ TopicExistsException, JSONException, ConfigDbException {\r
+\r
+ Assert.assertNotNull(mmRestService);\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+ when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "admin")).thenReturn(true);\r
+ when(httpServReq.isUserInRole("admin")).thenReturn(true);\r
+\r
+ PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
+\r
+ assertTrue(true);\r
+ when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeradmin.aaf"))\r
+ .thenReturn("admin");\r
+\r
+ when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormaker.timeout"))\r
+ .thenReturn("100");\r
+\r
+ when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormaker.topic"))\r
+ .thenReturn("mirrormaker.topic");\r
+\r
+ when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormaker.consumergroup"))\r
+ .thenReturn("mirrormaker.consumergroup");\r
+\r
+ when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormaker.consumerid"))\r
+ .thenReturn("mirrormaker.consumerid");\r
+\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+\r
+ when(httpServReq.isUserInRole("admin")).thenReturn(true);\r
+ \r
+\r
+ // when(httpServReq.getHeader("Authorization")).thenReturn("Admin");\r
+ when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "admin.aaf")).thenReturn(true);\r
+ when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "admin")).thenReturn(true);\r
+ when(httpServReq.getHeader("Authorization")).thenReturn("Admin");\r
+ when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "admin")).thenReturn(true);\r
+\r
+ when(cMirroMaker.getCreateMirrorMaker()).thenReturn(mMaker);\r
+\r
+ when(mMaker.getName()).thenReturn("mirroMakerName");\r
+ when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+ when(httpServReq.getHeader("Authorization")).thenReturn("Authorization");\r
+\r
+ when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
+ when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
+ when(httpServReq.getMethod()).thenReturn("HEAD");\r
+\r
+ when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null);\r
+\r
+ mmRestService.callListAllMirrorMaker(iStream);\r
+ }\r
+\r
+\r
+*/}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.service;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+import org.junit.runner.RunWith;\r
+/*import org.mockito.InjectMocks;\r
+import org.mockito.Mock;\r
+import org.mockito.MockitoAnnotations;\r
+import org.powermock.core.classloader.annotations.PrepareForTest;\r
+import org.powermock.modules.junit4.PowerMockRunner;*/\r
+\r
+import com.att.ajsc.beans.PropertiesMapBean;\r
+import com.att.nsa.cambria.CambriaApiException;\r
+import com.att.nsa.cambria.service.MetricsService;\r
+\r
+\r
+/*@RunWith(PowerMockRunner.class)\r
+@PrepareForTest({ PropertiesMapBean.class })*/\r
+public class MetricsRestServiceTest {/*\r
+\r
+ @InjectMocks\r
+ MetricsRestService metricsRestService;\r
+\r
+ @Mock\r
+ private MetricsService metricsService;\r
+ \r
+ @Before\r
+ public void setUp() throws Exception {\r
+ MockitoAnnotations.initMocks(this);\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testGetMetrics() throws CambriaApiException {\r
+\r
+ metricsRestService.getMetrics();\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetMetricsByName() throws CambriaApiException {\r
+\r
+ metricsRestService.getMetricsByName("metricsName");\r
+\r
+ }\r
+\r
+\r
+\r
+*/}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.service;\r
+\r
+import org.junit.runner.JUnitCore;\r
+import org.junit.runner.Result;\r
+import org.junit.runner.notification.Failure;\r
+import org.apache.log4j.Logger;\r
+\r
+public class TestRunner {\r
+ private static final Logger LOGGER = Logger.getLogger(TestRunner.class);\r
+\r
+ public static void main(String[] args) {\r
+ // TODO Auto-generated method stub\r
+ Result result = JUnitCore.runClasses(JUnitTestSuite.class);\r
+ for (Failure failure : result.getFailures()) {\r
+ LOGGER.info(failure.toString());\r
+ \r
+ }\r
+ LOGGER.info(result.wasSuccessful());\r
+ }\r
+\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.service;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+/*import static org.mockito.Matchers.anyString;\r
+import static org.mockito.Mockito.when;*/\r
+\r
+import java.io.IOException;\r
+import javax.servlet.ServletOutputStream;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+import org.junit.After;\r
+import org.json.JSONArray;\r
+import org.json.JSONException;\r
+import org.json.JSONObject;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+import org.junit.runner.RunWith;\r
+/*import org.mockito.InjectMocks;\r
+import org.mockito.Mock;\r
+import org.mockito.MockitoAnnotations;\r
+import org.powermock.api.mockito.PowerMockito;\r
+import org.powermock.core.classloader.annotations.PrepareForTest;\r
+import org.powermock.modules.junit4.PowerMockRunner;*/\r
+\r
+import com.att.ajsc.beans.PropertiesMapBean;\r
+import com.att.nsa.cambria.CambriaApiException;\r
+import com.att.nsa.cambria.beans.DMaaPContext;\r
+import com.att.nsa.cambria.beans.DMaaPKafkaMetaBroker;\r
+import com.att.nsa.cambria.beans.TopicBean;\r
+import com.att.nsa.cambria.constants.CambriaConstants;\r
+import com.att.nsa.cambria.exception.DMaaPAccessDeniedException;\r
+import com.att.nsa.cambria.exception.DMaaPErrorMessages;\r
+import com.att.nsa.cambria.metabroker.Broker.TopicExistsException;\r
+import com.att.nsa.cambria.metabroker.Topic;\r
+import com.att.nsa.cambria.security.DMaaPAAFAuthenticator;\r
+import com.att.nsa.cambria.security.DMaaPAuthenticator;\r
+import com.att.nsa.cambria.service.TopicService;\r
+import com.att.nsa.cambria.utils.ConfigurationReader;\r
+import com.att.nsa.cambria.utils.DMaaPResponseBuilder;\r
+import com.att.nsa.configs.ConfigDbException;\r
+import com.att.nsa.security.NsaAcl;\r
+import com.att.nsa.security.NsaApiKey;\r
+import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;\r
+import com.att.nsa.security.db.simple.NsaSimpleApiKey;\r
+\r
+//@RunWith(MockitoJUnitRunner.class)\r
+/*@RunWith(PowerMockRunner.class)\r
+@PrepareForTest({ PropertiesMapBean.class })*/\r
+public class TopicRestServiceTest {/*\r
+\r
+ @InjectMocks\r
+ TopicRestService topicService;\r
+\r
+ @Mock\r
+ private TopicService tService;\r
+\r
+ private TopicRestService service = new TopicRestService();\r
+ @Mock\r
+ private DMaaPErrorMessages errorMessages;\r
+\r
+ @Mock\r
+ DMaaPContext dmaapContext;\r
+\r
+ @Mock\r
+ ConfigurationReader configReader;\r
+\r
+ @Mock\r
+ ServletOutputStream oStream;\r
+\r
+ @Mock\r
+ DMaaPAuthenticator<NsaSimpleApiKey> dmaaPAuthenticator;\r
+\r
+ @Mock\r
+ DMaaPAAFAuthenticator dmaapAAFauthenticator;\r
+ @Mock\r
+ NsaApiKey user;\r
+\r
+ @Mock\r
+ NsaSimpleApiKey nsaSimpleApiKey;\r
+\r
+ @Mock\r
+ HttpServletRequest httpServReq;\r
+\r
+ @Mock\r
+ HttpServletResponse httpServRes;\r
+\r
+ @Mock\r
+ DMaaPKafkaMetaBroker dmaapKafkaMetaBroker;\r
+\r
+ @Mock\r
+ Topic createdTopic;\r
+\r
+ @Mock\r
+ NsaAcl nsaAcl;\r
+\r
+ @Mock\r
+ JSONObject jsonObj;\r
+\r
+ @Mock\r
+ JSONArray jsonArray;\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+\r
+ MockitoAnnotations.initMocks(this);\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test(expected = DMaaPAccessDeniedException.class)\r
+ public void testGetTopics() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
+ TopicExistsException, JSONException, ConfigDbException {\r
+\r
+ Assert.assertNotNull(topicService);\r
+\r
+ PowerMockito.mockStatic(PropertiesMapBean.class);\r
+\r
+ assertTrue(true);\r
+ when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf"))\r
+ .thenReturn("namespace");\r
+\r
+ PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
+ when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+ when(httpServReq.getHeader("Authorization")).thenReturn("Authorization");\r
+\r
+ when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
+ when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
+ when(httpServReq.getMethod()).thenReturn("HEAD");\r
+\r
+ when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null);\r
+\r
+ topicService.getTopics();\r
+ }\r
+\r
+ @Test\r
+ public void testGetTopics_nullAuth() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
+ TopicExistsException, JSONException, ConfigDbException {\r
+\r
+ Assert.assertNotNull(topicService);\r
+\r
+ PowerMockito.mockStatic(PropertiesMapBean.class);\r
+\r
+ assertTrue(true);\r
+ when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf"))\r
+ .thenReturn("namespace");\r
+\r
+ PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
+ when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+ when(httpServReq.getHeader("Authorization")).thenReturn(null);\r
+\r
+ when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
+ String perms = "namespace" + "|" + "*" + "|" + "view";\r
+ when(dmaapAAFauthenticator.aafAuthentication(httpServReq, perms)).thenReturn(true);\r
+\r
+ when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null);\r
+\r
+ topicService.getTopics();\r
+ }\r
+\r
+ @Test(expected = DMaaPAccessDeniedException.class)\r
+ public void testGetAllTopics() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
+ TopicExistsException, JSONException, ConfigDbException {\r
+\r
+ Assert.assertNotNull(topicService);\r
+\r
+ PowerMockito.mockStatic(PropertiesMapBean.class);\r
+\r
+ assertTrue(true);\r
+ when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf"))\r
+ .thenReturn("namespace");\r
+\r
+ PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
+ when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+ when(httpServReq.getHeader("Authorization")).thenReturn("Authorization");\r
+\r
+ when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
+\r
+ topicService.getAllTopics();\r
+ }\r
+\r
+ @Test\r
+ public void testGetAllTopics_nullAuth() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
+ TopicExistsException, JSONException, ConfigDbException {\r
+\r
+ Assert.assertNotNull(topicService);\r
+ PowerMockito.mockStatic(PropertiesMapBean.class);\r
+\r
+ assertTrue(true);\r
+ when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf"))\r
+ .thenReturn("namespace");\r
+\r
+ PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
+ when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+ when(httpServReq.getHeader("Authorization")).thenReturn(null);\r
+\r
+ when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
+\r
+ topicService.getAllTopics();\r
+ }\r
+\r
+ @Test(expected = DMaaPAccessDeniedException.class)\r
+ public void testGetTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
+ TopicExistsException, JSONException, ConfigDbException {\r
+\r
+ Assert.assertNotNull(topicService);\r
+\r
+ PowerMockito.mockStatic(PropertiesMapBean.class);\r
+\r
+ assertTrue(true);\r
+ when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "enforced.topic.name.AAF"))\r
+ .thenReturn("enfTopicName");\r
+\r
+ PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
+ when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+ when(httpServReq.getHeader("Authorization")).thenReturn("Authorization");\r
+\r
+ when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
+\r
+ topicService.getTopic("topicName");\r
+ }\r
+\r
+ @Test\r
+ public void testGetTopic_nullAuth() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
+ TopicExistsException, JSONException, ConfigDbException {\r
+\r
+ Assert.assertNotNull(topicService);\r
+\r
+ PowerMockito.mockStatic(PropertiesMapBean.class);\r
+\r
+ assertTrue(true);\r
+ when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "enforced.topic.name.AAF"))\r
+ .thenReturn("enfTopicName");\r
+\r
+ PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
+ when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+ when(httpServReq.getHeader("Authorization")).thenReturn(null);\r
+\r
+ when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
+\r
+ topicService.getTopic("topicName");\r
+ }\r
+\r
+ @Test\r
+ public void testCreateTopic()\r
+ throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {\r
+\r
+ Assert.assertNotNull(topicService);\r
+\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+ when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
+ when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
+ when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
+\r
+ TopicBean topicBean = new TopicBean();\r
+ topicBean.setTopicName("enfTopicNamePlusExtra");\r
+\r
+ topicService.createTopic(topicBean);\r
+ }\r
+\r
+ @Test\r
+ public void testDeleteTopic()\r
+ throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {\r
+\r
+ Assert.assertNotNull(topicService);\r
+\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+ when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
+ when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
+ when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
+\r
+ TopicBean topicBean = new TopicBean();\r
+ topicBean.setTopicName("enfTopicNamePlusExtra");\r
+\r
+ topicService.deleteTopic("enfTopicNamePlusExtra");\r
+ }\r
+\r
+ @Test\r
+ public void testGetPublishersByTopicName()\r
+ throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {\r
+\r
+ Assert.assertNotNull(topicService);\r
+\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+ when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
+ when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
+ when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
+\r
+ TopicBean topicBean = new TopicBean();\r
+ topicBean.setTopicName("enfTopicNamePlusExtra");\r
+\r
+ topicService.getPublishersByTopicName("enfTopicNamePlusExtra");\r
+ }\r
+\r
+ @Test\r
+ public void testPermitPublisherForTopic()\r
+ throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {\r
+\r
+ Assert.assertNotNull(topicService);\r
+\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+ when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
+ when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
+ when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
+\r
+ TopicBean topicBean = new TopicBean();\r
+ topicBean.setTopicName("enfTopicNamePlusExtra");\r
+\r
+ topicService.permitPublisherForTopic("enfTopicNamePlusExtra", "producerID");\r
+ }\r
+\r
+ @Test\r
+ public void testDenyPublisherForTopic()\r
+ throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {\r
+\r
+ Assert.assertNotNull(topicService);\r
+\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+ when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
+ when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
+ when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
+\r
+ TopicBean topicBean = new TopicBean();\r
+ topicBean.setTopicName("enfTopicNamePlusExtra");\r
+\r
+ topicService.denyPublisherForTopic("enfTopicNamePlusExtra", "producerID");\r
+ }\r
+\r
+ @Test\r
+ public void testGetConsumersByTopicName() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
+ TopicExistsException, AccessDeniedException {\r
+\r
+ Assert.assertNotNull(topicService);\r
+\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+ when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
+ when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
+ when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
+\r
+ TopicBean topicBean = new TopicBean();\r
+ topicBean.setTopicName("enfTopicNamePlusExtra");\r
+\r
+ topicService.getConsumersByTopicName("enfTopicNamePlusExtra");\r
+ }\r
+\r
+ @Test\r
+ public void testPermitConsumerForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
+ TopicExistsException, AccessDeniedException {\r
+\r
+ Assert.assertNotNull(topicService);\r
+\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+ when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
+ when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
+ when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
+\r
+ TopicBean topicBean = new TopicBean();\r
+ topicBean.setTopicName("enfTopicNamePlusExtra");\r
+\r
+ topicService.permitConsumerForTopic("enfTopicNamePlusExtra", "consumerID");\r
+ }\r
+\r
+ @Test\r
+ public void testDenyConsumerForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
+ TopicExistsException, AccessDeniedException {\r
+\r
+ Assert.assertNotNull(topicService);\r
+\r
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
+ when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
+ when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
+ when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
+\r
+ TopicBean topicBean = new TopicBean();\r
+ topicBean.setTopicName("enfTopicNamePlusExtra");\r
+\r
+ topicService.denyConsumerForTopic("enfTopicNamePlusExtra", "consumerID");\r
+ }\r
+\r
+*/}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.service;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import java.lang.reflect.InvocationTargetException;\r
+import java.lang.reflect.Method;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
+/*import org.mockito.InjectMocks;\r
+import org.mockito.Mock;\r
+import org.mockito.MockitoAnnotations;\r
+import org.powermock.core.classloader.annotations.PrepareForTest;\r
+import org.powermock.modules.junit4.PowerMockRunner;*/\r
+\r
+import com.att.ajsc.beans.PropertiesMapBean;\r
+import com.att.nsa.cambria.CambriaApiException;\r
+import com.att.nsa.cambria.beans.DMaaPContext;\r
+import com.att.nsa.cambria.service.EventsService;\r
+import com.att.nsa.cambria.service.TransactionService;\r
+import com.att.nsa.configs.ConfigDbException;\r
+import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;\r
+\r
+/*@RunWith(PowerMockRunner.class)\r
+@PrepareForTest({ PropertiesMapBean.class })*/\r
+public class TransactionRestServiceTest {/*\r
+\r
+ @InjectMocks\r
+ TransactionRestService transactionRestService;\r
+\r
+ @Mock\r
+ private TransactionService transactionService;\r
+\r
+ @Mock\r
+ DMaaPContext dmaapContext;\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ MockitoAnnotations.initMocks(this);\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testGetAllTransactionObjs() throws CambriaApiException {\r
+\r
+ transactionRestService.getAllTransactionObjs();\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testGetTransactionObj() throws CambriaApiException {\r
+\r
+ transactionRestService.getTransactionObj("transactionId");\r
+\r
+ }\r
+\r
+*/}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.service;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import java.lang.reflect.InvocationTargetException;\r
+import java.lang.reflect.Method;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+import com.att.nsa.cambria.CambriaApiException;\r
+import com.att.nsa.configs.ConfigDbException;\r
+import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;\r
+\r
+public class UIRestServicesTest {\r
+\r
+ private UIRestServices service = null;\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ service = new UIRestServices();\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testHello() {\r
+\r
+ try {\r
+ service.hello();\r
+ } catch (NullPointerException e) {\r
+ assertTrue(true);\r
+ }\r
+ assertTrue(true);\r
+ }\r
+ \r
+ @Test\r
+ public void testGetApiKeysTable() {\r
+\r
+ try {\r
+ service.getApiKeysTable();\r
+ } catch (NullPointerException e) {\r
+ assertTrue(true);\r
+ }\r
+ assertTrue(true);\r
+ }\r
+ \r
+\r
+ @Test\r
+ public void testGetApiKey() {\r
+\r
+ try {\r
+ service.getApiKey("apikey");\r
+ } catch (NullPointerException e) {\r
+ assertTrue(true);\r
+ }\r
+ assertTrue(true);\r
+ }\r
+ \r
+ @Test\r
+ public void testGetTopicsTable() {\r
+\r
+ try {\r
+ service.getTopicsTable();\r
+ } catch (NullPointerException e) {\r
+ assertTrue(true);\r
+ }\r
+ assertTrue(true);\r
+ }\r
+ \r
+ @Test\r
+ public void testGetTopic() {\r
+\r
+ try {\r
+ service.getTopic("topicName");\r
+ } catch (NullPointerException e) {\r
+ assertTrue(true);\r
+ }\r
+ assertTrue(true);\r
+ }\r
+ \r
+ @Test\r
+ public void testGetDmaapContext() {\r
+ Class clazz = null;\r
+ Method method = null;\r
+ try {\r
+ clazz = Class.forName("UIRestServices");\r
+ Object obj = clazz.newInstance();\r
+ method = clazz.getDeclaredMethod("getDmaapContext", null);\r
+ method.setAccessible(true);\r
+ method.invoke(obj, null);\r
+ } catch (ClassNotFoundException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (NoSuchMethodException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (SecurityException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (InstantiationException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (IllegalAccessException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (IllegalArgumentException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (InvocationTargetException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+\r
+ assertTrue(true);\r
+ }\r
+ \r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.tools;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+public class ConfigToolContextTest {\r
+ \r
+ private ConfigToolContext context;\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ context = new ConfigToolContext(null, "connStr", null);\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testRequestShutdown() {\r
+\r
+ context.requestShutdown();\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testShouldContinue() {\r
+\r
+ context.shouldContinue();\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetDb() {\r
+\r
+ context.getDb();\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetMetrics() {\r
+\r
+ context.getMetrics();\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetConnectionString() {\r
+\r
+ context.getConnectionString();\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.tools;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import java.lang.reflect.Constructor;\r
+import java.lang.reflect.InvocationTargetException;\r
+import java.lang.reflect.Method;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+public class ConfigToolTest {\r
+\r
+ private String[] parts = new String[5];\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+\r
+ for (int i = 0; i < parts.length; i++) {\r
+ parts[i] = "string" + (i + 1);\r
+ }\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ public void callMethodViaReflection(String outer, String inner, String methodName, Object... args) {\r
+\r
+ String foreNameString = outer + "$" + inner;\r
+ Object parent = new ConfigTool();\r
+\r
+ Class<?> innerClass;\r
+ try {\r
+ innerClass = Class.forName(foreNameString);\r
+ Constructor<?> constructor = innerClass.getDeclaredConstructor(ConfigTool.class);\r
+ constructor.setAccessible(true);\r
+ Object child = constructor.newInstance(parent);\r
+\r
+ // invoking method on inner class object\r
+ Method method = innerClass.getDeclaredMethod(methodName, null);\r
+ method.setAccessible(true);// in case of unaccessible method\r
+ method.invoke(child, args);\r
+ } catch (ClassNotFoundException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (NoSuchMethodException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (SecurityException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (InstantiationException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (IllegalAccessException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (IllegalArgumentException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (InvocationTargetException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testGetMatches() {\r
+\r
+ callMethodViaReflection("ConfigTool", "ListTopicCommand", "getMatches");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testCheckReady() {\r
+\r
+ callMethodViaReflection("ConfigTool", "ListTopicCommand", "checkReady", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testExecute() {\r
+\r
+ callMethodViaReflection("ConfigTool", "ListTopicCommand", "execute", parts, null, null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testDisplayHelp() {\r
+\r
+ callMethodViaReflection("ConfigTool", "ListTopicCommand", "displayHelp", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testGetMatches2() {\r
+\r
+ callMethodViaReflection("ConfigTool", "WriteTopicCommand", "getMatches");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testCheckReady2() {\r
+\r
+ callMethodViaReflection("ConfigTool", "WriteTopicCommand", "checkReady", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testExecute2() {\r
+\r
+ callMethodViaReflection("ConfigTool", "WriteTopicCommand", "execute", parts, null, null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testDisplayHelp2() {\r
+\r
+ callMethodViaReflection("ConfigTool", "WriteTopicCommand", "displayHelp", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testGetMatches3() {\r
+\r
+ callMethodViaReflection("ConfigTool", "ReadTopicCommand", "getMatches");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testCheckReady3() {\r
+\r
+ callMethodViaReflection("ConfigTool", "ReadTopicCommand", "checkReady", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testExecute3() {\r
+\r
+ callMethodViaReflection("ConfigTool", "ReadTopicCommand", "execute", parts, null, null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testDisplayHelp3() {\r
+\r
+ callMethodViaReflection("ConfigTool", "ReadTopicCommand", "displayHelp", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testGetMatches4() {\r
+\r
+ callMethodViaReflection("ConfigTool", "InitSecureTopicCommand", "getMatches");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testCheckReady4() {\r
+\r
+ callMethodViaReflection("ConfigTool", "InitSecureTopicCommand", "checkReady", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testExecute4() {\r
+\r
+ callMethodViaReflection("ConfigTool", "InitSecureTopicCommand", "execute", parts, null, null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testDisplayHelp4() {\r
+\r
+ callMethodViaReflection("ConfigTool", "InitSecureTopicCommand", "displayHelp", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testGetMatches5() {\r
+\r
+ callMethodViaReflection("ConfigTool", "SetTopicOwnerCommand", "getMatches");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testCheckReady5() {\r
+\r
+ callMethodViaReflection("ConfigTool", "SetTopicOwnerCommand", "checkReady", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testExecute5() {\r
+\r
+ callMethodViaReflection("ConfigTool", "SetTopicOwnerCommand", "execute", parts, null, null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testDisplayHelp5() {\r
+\r
+ callMethodViaReflection("ConfigTool", "SetTopicOwnerCommand", "displayHelp", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetMatches6() {\r
+\r
+ callMethodViaReflection("ConfigTool", "ListApiKeysCommand", "getMatches");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testCheckReady6() {\r
+\r
+ callMethodViaReflection("ConfigTool", "ListApiKeysCommand", "checkReady", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testExecute6() {\r
+\r
+ callMethodViaReflection("ConfigTool", "ListApiKeysCommand", "execute", parts, null, null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testDisplayHelp6() {\r
+\r
+ callMethodViaReflection("ConfigTool", "ListApiKeysCommand", "displayHelp", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetMatches7() {\r
+\r
+ callMethodViaReflection("ConfigTool", "PutApiCommand", "getMatches");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testCheckReady7() {\r
+\r
+ callMethodViaReflection("ConfigTool", "PutApiCommand", "checkReady", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testExecute7() {\r
+\r
+ callMethodViaReflection("ConfigTool", "PutApiCommand", "execute", parts, null, null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testDisplayHelp7() {\r
+\r
+ callMethodViaReflection("ConfigTool", "PutApiCommand", "displayHelp", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetMatches8() {\r
+\r
+ callMethodViaReflection("ConfigTool", "writeApiKeyCommand", "getMatches");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testCheckReady8() {\r
+\r
+ callMethodViaReflection("ConfigTool", "writeApiKeyCommand", "checkReady", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testExecute8() {\r
+\r
+ callMethodViaReflection("ConfigTool", "writeApiKeyCommand", "execute", parts, null, null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testDisplayHelp8() {\r
+\r
+ callMethodViaReflection("ConfigTool", "writeApiKeyCommand", "displayHelp", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetMatches9() {\r
+\r
+ callMethodViaReflection("ConfigTool", "EncryptApiKeysCommand", "getMatches");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testCheckReady9() {\r
+\r
+ callMethodViaReflection("ConfigTool", "EncryptApiKeysCommand", "checkReady", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testExecute9() {\r
+\r
+ callMethodViaReflection("ConfigTool", "EncryptApiKeysCommand", "execute", parts, null, null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testDisplayHelp9() {\r
+\r
+ callMethodViaReflection("ConfigTool", "EncryptApiKeysCommand", "displayHelp", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetMatches10() {\r
+\r
+ callMethodViaReflection("ConfigTool", "DecryptApiKeysCommand", "getMatches");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testCheckReady10() {\r
+\r
+ callMethodViaReflection("ConfigTool", "DecryptApiKeysCommand", "checkReady", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testExecute10() {\r
+\r
+ callMethodViaReflection("ConfigTool", "DecryptApiKeysCommand", "execute", parts, null, null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testDisplayHelp10() {\r
+\r
+ callMethodViaReflection("ConfigTool", "DecryptApiKeysCommand", "displayHelp", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetMatches11() {\r
+\r
+ callMethodViaReflection("ConfigTool", "NodeFetchCommand", "getMatches");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testCheckReady11() {\r
+\r
+ callMethodViaReflection("ConfigTool", "NodeFetchCommand", "checkReady", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testExecute11() {\r
+\r
+ callMethodViaReflection("ConfigTool", "NodeFetchCommand", "execute", parts, null, null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testDisplayHelp11() {\r
+\r
+ callMethodViaReflection("ConfigTool", "NodeFetchCommand", "displayHelp", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testGetMatches12() {\r
+\r
+ callMethodViaReflection("ConfigTool", "DropOldConsumerGroupsCommand", "getMatches");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testCheckReady12() {\r
+\r
+ callMethodViaReflection("ConfigTool", "DropOldConsumerGroupsCommand", "checkReady", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testExecute12() {\r
+\r
+ callMethodViaReflection("ConfigTool", "DropOldConsumerGroupsCommand", "execute", parts, null, null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testDisplayHelp12() {\r
+\r
+ callMethodViaReflection("ConfigTool", "DropOldConsumerGroupsCommand", "displayHelp", null);\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.tools;\r
+\r
+import junit.framework.TestSuite;\r
+\r
+import org.junit.runner.RunWith;\r
+import org.junit.runners.Suite;\r
+import org.junit.runners.Suite.SuiteClasses;\r
+import org.apache.log4j.Logger;\r
+\r
+@RunWith(Suite.class)\r
+@SuiteClasses({ ConfigToolTest.class, ConfigToolContextTest.class,})\r
+public class JUnitTestSuite {\r
+ private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);\r
+\r
+ public static void main(String[] args) {\r
+ LOGGER.info("Running the test suite");\r
+ \r
+ TestSuite tstSuite = new TestSuite();\r
+ LOGGER.info("Total Test Counts " + tstSuite.countTestCases());\r
+ }\r
+\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.tools;\r
+\r
+import org.junit.runner.JUnitCore;\r
+import org.junit.runner.Result;\r
+import org.junit.runner.notification.Failure;\r
+import org.apache.log4j.Logger;\r
+\r
+public class TestRunner {\r
+ private static final Logger LOGGER = Logger.getLogger(TestRunner.class);\r
+\r
+ public static void main(String[] args) {\r
+ // TODO Auto-generated method stub\r
+ Result result = JUnitCore.runClasses(JUnitTestSuite.class);\r
+ for (Failure failure : result.getFailures()) {\r
+ LOGGER.info(failure.toString());\r
+ \r
+ }\r
+ LOGGER.info(result.wasSuccessful());\r
+ }\r
+\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.util;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+public class ContentLengthInterceptorTest {\r
+\r
+ private ContentLengthInterceptor interceptor = null;\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ interceptor = new ContentLengthInterceptor();\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testAllowOrReject() {\r
+\r
+ try {\r
+ interceptor.allowOrReject(null, null, null);\r
+ } catch (Exception e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testGetDefLength() {\r
+\r
+ interceptor.getDefLength();\r
+\r
+ assertTrue(true);\r
+\r
+ \r
+ }\r
+ \r
+ @Test\r
+ public void testSetDefLength() {\r
+\r
+ interceptor.setDefLength("defLength");\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.util;\r
+\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+import org.junit.runner.RunWith;\r
+/*import org.mockito.InjectMocks;\r
+import org.mockito.Mock;\r
+import org.mockito.MockitoAnnotations;\r
+import org.powermock.core.classloader.annotations.PrepareForTest;\r
+import org.powermock.modules.junit4.PowerMockRunner;\r
+\r
+import com.att.ajsc.beans.PropertiesMapBean;\r
+import static org.mockito.Mockito.when;\r
+*/\r
+import java.io.IOException;\r
+import javax.servlet.FilterChain;\r
+import javax.servlet.ServletException;\r
+import javax.servlet.ServletResponse;\r
+import javax.servlet.http.HttpServletRequest;\r
+\r
+import com.att.nsa.cambria.beans.DMaaPContext;\r
+import com.att.nsa.cambria.exception.DMaaPResponseCode;\r
+\r
+/*@RunWith(PowerMockRunner.class)\r
+@PrepareForTest({ PropertiesMapBean.class, DMaaPResponseCode.class })*/\r
+public class DMaaPAuthFilterTest {/*\r
+ \r
+ @InjectMocks\r
+ DMaaPAuthFilter filter;\r
+ \r
+ @Mock\r
+ HttpServletRequest req; \r
+ \r
+ @Mock\r
+ ServletResponse res;\r
+ \r
+ \r
+ @Mock\r
+ FilterChain chain;\r
+ \r
+ @Mock\r
+ DMaaPContext dmaapContext;\r
+ \r
+ @Before\r
+ public void setUp() throws Exception {\r
+ MockitoAnnotations.initMocks(this);\r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testDoFilter() throws IOException, ServletException {\r
+ \r
+ when(dmaapContext.getRequest()).thenReturn(req);\r
+ when(req.getHeader("Authorization")).thenReturn("Authorization");\r
+ \r
+ //when(dmaapContext.getResponse()).thenReturn(res);\r
+ filter.doFilter(req, res, chain);\r
+\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testDoFilter_nullAuth() throws IOException, ServletException {\r
+ \r
+ when(dmaapContext.getRequest()).thenReturn(req);\r
+ //when(req.getHeader("Authorization")).thenReturn("Authorization");\r
+ \r
+ //when(dmaapContext.getResponse()).thenReturn(res);\r
+ filter.doFilter(req, res, chain);\r
+\r
+\r
+ }\r
+\r
+ \r
+ \r
+*/}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.util;\r
+\r
+import junit.framework.TestSuite;\r
+\r
+import org.junit.runner.RunWith;\r
+import org.junit.runners.Suite;\r
+import org.junit.runners.Suite.SuiteClasses;\r
+import org.apache.log4j.Logger;\r
+\r
+@RunWith(Suite.class)\r
+@SuiteClasses({ ContentLengthInterceptorTest.class, DMaaPAuthFilterTest.class, ServicePropertiesMapBeanTest.class})\r
+public class JUnitTestSuite {\r
+ private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);\r
+\r
+ public static void main(String[] args) {\r
+ LOGGER.info("Running the test suite");\r
+ \r
+ TestSuite tstSuite = new TestSuite();\r
+ LOGGER.info("Total Test Counts " + tstSuite.countTestCases());\r
+ }\r
+\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.util;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+public class ServicePropertiesMapBeanTest {\r
+\r
+ \r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ \r
+ }\r
+\r
+ @After\r
+ public void tearDown() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void testGetProperty() {\r
+ \r
+ \r
+ try {\r
+ ServicePropertiesMapBean.getProperty(null, null);\r
+ } catch (Exception e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+\r
+ assertTrue(true);\r
+\r
+ }\r
+\r
+ \r
+ \r
+}
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP Policy Engine\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package com.att.nsa.dmaap.util;\r
+\r
+import org.junit.runner.JUnitCore;\r
+import org.junit.runner.Result;\r
+import org.junit.runner.notification.Failure;\r
+import org.apache.log4j.Logger;\r
+\r
+public class TestRunner {\r
+ private static final Logger LOGGER = Logger.getLogger(TestRunner.class);\r
+\r
+ public static void main(String[] args) {\r
+ // TODO Auto-generated method stub\r
+ Result result = JUnitCore.runClasses(JUnitTestSuite.class);\r
+ for (Failure failure : result.getFailures()) {\r
+ LOGGER.info(failure.toString());\r
+ \r
+ }\r
+ LOGGER.info(result.wasSuccessful());\r
+ }\r
+\r
+}\r