From 9b0ed8da9474c99c13fbdff62894c09311cf9036 Mon Sep 17 00:00:00 2001 From: IanHowell Date: Fri, 6 Apr 2018 09:57:16 -0500 Subject: Improve JUnit test coverage * Fixed a typo in DenialOfServiceTaf * Added a JUnit for DenialOfServiceTaf * Cleaned up JU_Cached, JU_AuthzEnv (WIP) Issue-ID: AAF-128 Change-Id: I76ace8aff3f72538f40068f6cc9c80f24aee7403 Signed-off-by: IanHowell Increase coverage in cadi/client and cadi/core Get coverage for Holder, NulTaf, and NullTafResp to 100% Issue-ID: AAF-128 Change-Id: Ica83c29311801d499f922ccb4c33fb7f4e58f686 Signed-off-by: IanHowell Improve coverage of the Tafs Issue-ID: AAF-128 Change-Id: I07f9ebee0a64c598047e74801a266898107783f7 Signed-off-by: IanHowell Improve test coverage of XReader Issue-ID: AAF-128 Change-Id: I9b369b803743166027170b4a8ca50bd337e45b7b Signed-off-by: IanHowell Improve coverage of GreatCircle Issue-ID: AAF-128 Change-Id: Id5e41a481db1106d050fb216664c1aa1e07cef2a Signed-off-by: IanHowell Suppress test output Issue-ID: AAF-128 Change-Id: I7a7afe7617c81403d27baf89353f175d9cead165 Signed-off-by: IanHowell Move JU_DNSLocator to the correct package Change-Id: Ic8feddf7444afcaaaa252a40d340116597533f46 Signed-off-by: IanHowell --- .../onap/aaf/cadi/client/test/JU_DNSLocator.java | 55 --------------- .../onap/aaf/cadi/client/test/JU_GreatCircle.java | 62 ----------------- .../org/onap/aaf/cadi/client/test/JU_Holder.java | 45 ++++++++++++ .../onap/aaf/cadi/locator/test/JU_DNSLocator.java | 55 +++++++++++++++ .../onap/aaf/cadi/routing/test/JU_GreatCircle.java | 79 ++++++++++++++++++++++ .../org/onap/aaf/client/test/JU_DNSLocator.java | 55 --------------- .../org/onap/aaf/client/test/JU_HolderTest.java | 79 ---------------------- 7 files changed, 179 insertions(+), 251 deletions(-) delete mode 100644 cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_DNSLocator.java delete mode 100644 cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_GreatCircle.java create mode 100644 cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Holder.java create mode 100644 cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java create mode 100644 cadi/client/src/test/java/org/onap/aaf/cadi/routing/test/JU_GreatCircle.java delete mode 100644 cadi/client/src/test/java/org/onap/aaf/client/test/JU_DNSLocator.java delete mode 100644 cadi/client/src/test/java/org/onap/aaf/client/test/JU_HolderTest.java (limited to 'cadi/client') diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_DNSLocator.java b/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_DNSLocator.java deleted file mode 100644 index b97667d5..00000000 --- a/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_DNSLocator.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * ============LICENSE_START==================================================== - * org.onap.aaf - * =========================================================================== - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * =========================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END==================================================== - * - */ - -package org.onap.aaf.cadi.client.test; - -import java.net.URI; -import java.net.URL; -import java.net.URLConnection; - -import org.junit.AfterClass; -import org.junit.Test; -import org.onap.aaf.cadi.PropAccess; -import org.onap.aaf.cadi.Locator.Item; -import org.onap.aaf.cadi.locator.DNSLocator; - -public class JU_DNSLocator { - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Test - public void test() { - - DNSLocator dl = new DNSLocator(new PropAccess(), "https", "aaf.it.att.com","8150-8152"); - try { - Item item = dl.best(); - URI uri = dl.get(item); - URL url = uri.toURL(); - URLConnection conn = url.openConnection(); - conn.connect(); - } catch (Exception e) { - e.printStackTrace(); - } - } - -} diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_GreatCircle.java b/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_GreatCircle.java deleted file mode 100644 index d2e02cbf..00000000 --- a/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_GreatCircle.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * ============LICENSE_START==================================================== - * org.onap.aaf - * =========================================================================== - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * =========================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END==================================================== - * - */ - -package org.onap.aaf.cadi.client.test; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.aaf.cadi.routing.GreatCircle; - -public class JU_GreatCircle { - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void test() { - Assert.assertEquals(7.803062505568182,GreatCircle.calc(38.627345,-90.193774, 35.252234,-81.384929),0.000000001); - Assert.assertEquals(0.0,GreatCircle.calc(38.627345,-90.193774, 38.627345,-90.193774),0.000000001); - Assert.assertEquals(7.803062505568182,GreatCircle.calc(35.252234,-81.384929,38.627345,-90.193774),0.000000001); - Assert.assertEquals(7.803062505568182,GreatCircle.calc(38.627345,-90.193774, 35.252234,-81.384929),0.000000001); - Assert.assertEquals(7.803062505568182,GreatCircle.calc(-38.627345,90.193774, -35.252234,81.384929),0.000000001); - Assert.assertEquals(105.71060033936052,GreatCircle.calc(-38.627345,90.193774, -35.252234,-81.384929),0.000000001); - Assert.assertEquals(105.71060033936052,GreatCircle.calc(38.627345,-90.193774, 35.252234,81.384929),0.000000001); - Assert.assertEquals(74.32786874922931,GreatCircle.calc(-38.627345,90.193774, 35.252234,81.384929),0.000000001); - } - -} diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Holder.java b/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Holder.java new file mode 100644 index 00000000..079951f5 --- /dev/null +++ b/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Holder.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * ============LICENSE_START==================================================== + * * org.onap.aaf + * * =========================================================================== + * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * * =========================================================================== + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * http://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * * ============LICENSE_END==================================================== + * * + * * + ******************************************************************************/ +package org.onap.aaf.cadi.client.test; + +import static org.junit.Assert.*; +import static org.hamcrest.CoreMatchers.*; +import org.junit.Test; + +import org.onap.aaf.cadi.client.Holder; + +public class JU_Holder { + + @Test + public void test() { + String str1 = "a string"; + String str2 = "another string"; + Holder holder = new Holder(str1); + assertThat(holder.get(), is(str1)); + assertThat(holder.toString(), is(str1)); + + holder.set(str2); + assertThat(holder.get(), is(str2)); + assertThat(holder.toString(), is(str2)); + } + +} diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java b/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java new file mode 100644 index 00000000..b97667d5 --- /dev/null +++ b/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java @@ -0,0 +1,55 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END==================================================== + * + */ + +package org.onap.aaf.cadi.client.test; + +import java.net.URI; +import java.net.URL; +import java.net.URLConnection; + +import org.junit.AfterClass; +import org.junit.Test; +import org.onap.aaf.cadi.PropAccess; +import org.onap.aaf.cadi.Locator.Item; +import org.onap.aaf.cadi.locator.DNSLocator; + +public class JU_DNSLocator { + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Test + public void test() { + + DNSLocator dl = new DNSLocator(new PropAccess(), "https", "aaf.it.att.com","8150-8152"); + try { + Item item = dl.best(); + URI uri = dl.get(item); + URL url = uri.toURL(); + URLConnection conn = url.openConnection(); + conn.connect(); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/routing/test/JU_GreatCircle.java b/cadi/client/src/test/java/org/onap/aaf/cadi/routing/test/JU_GreatCircle.java new file mode 100644 index 00000000..f492d4a2 --- /dev/null +++ b/cadi/client/src/test/java/org/onap/aaf/cadi/routing/test/JU_GreatCircle.java @@ -0,0 +1,79 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END==================================================== + * + */ + +package org.onap.aaf.cadi.routing.test; + +import static org.junit.Assert.*; +import org.junit.*; + +import org.onap.aaf.cadi.routing.GreatCircle; + +public class JU_GreatCircle { + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void calc1Test() { + assertEquals(7.803062505568182, GreatCircle.calc(38.627345, -90.193774, 35.252234, -81.384929), 0.000000001); + assertEquals(0.0, GreatCircle.calc(38.627345, -90.193774, 38.627345, -90.193774), 0.000000001); + assertEquals(7.803062505568182, GreatCircle.calc(35.252234, -81.384929, 38.627345, -90.193774), 0.000000001); + assertEquals(7.803062505568182, GreatCircle.calc(38.627345, -90.193774, 35.252234, -81.384929), 0.000000001); + assertEquals(7.803062505568182, GreatCircle.calc(-38.627345, 90.193774, -35.252234, 81.384929), 0.000000001); + assertEquals(105.71060033936052, GreatCircle.calc(-38.627345, 90.193774, -35.252234, -81.384929), 0.000000001); + assertEquals(105.71060033936052, GreatCircle.calc(38.627345, -90.193774, 35.252234, 81.384929), 0.000000001); + assertEquals(74.32786874922931, GreatCircle.calc(-38.627345, 90.193774, 35.252234, 81.384929), 0.000000001); + } + + @Test + public void calc2Test() { + assertEquals(7.803062505568182, GreatCircle.calc(new String[] {"38.627345", "-90.193774", "35.252234", "-81.384929"}), 0.000000001); + assertEquals(7.803062505568182, GreatCircle.calc(new String[] {"38.627345,-90.193774", "35.252234,-81.384929"}), 0.000000001); + assertEquals(7.803062505568182, GreatCircle.calc(new String[] {"38.627345,-90.193774,35.252234,-81.384929"}), 0.000000001); + + assertEquals(-1, GreatCircle.calc(new String[0]), 0.000000001); + assertEquals(-1, GreatCircle.calc(new String[] {"38.627345;-90.193774", "35.252234,-81.384929"}), 0.000000001); + assertEquals(-1, GreatCircle.calc(new String[] {"38.627345,-90.193774", "35.252234;-81.384929"}), 0.000000001); + assertEquals(-1, GreatCircle.calc(new String[] {"38.627345,-90.193774;35.252234,-81.384929"}), 0.000000001); + + assertEquals(-1, GreatCircle.calc(new String[] {"Invalid input", "Invalid input", "Invalid input", "Invalid input"}), 0.000000001); + } + + @Test + public void coverageTest() { + @SuppressWarnings("unused") + GreatCircle gc = new GreatCircle(); + } + +} diff --git a/cadi/client/src/test/java/org/onap/aaf/client/test/JU_DNSLocator.java b/cadi/client/src/test/java/org/onap/aaf/client/test/JU_DNSLocator.java deleted file mode 100644 index 777b4f98..00000000 --- a/cadi/client/src/test/java/org/onap/aaf/client/test/JU_DNSLocator.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * - ******************************************************************************/ -package org.onap.aaf.client.test; - -import java.net.URI; -import java.net.URL; -import java.net.URLConnection; - -import org.junit.AfterClass; -import org.junit.Test; -import org.onap.aaf.cadi.PropAccess; -import org.onap.aaf.cadi.Locator.Item; -import org.onap.aaf.cadi.locator.DNSLocator; - -public class JU_DNSLocator { - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Test - public void test() { - - DNSLocator dl = new DNSLocator(new PropAccess(), "https", "aaf.it.att.com","8150-8152"); - try { - Item item = dl.best(); - URI uri = dl.get(item); - URL url = uri.toURL(); - URLConnection conn = url.openConnection(); - conn.connect(); - } catch (Exception e) { - e.printStackTrace(); - } - } - -} diff --git a/cadi/client/src/test/java/org/onap/aaf/client/test/JU_HolderTest.java b/cadi/client/src/test/java/org/onap/aaf/client/test/JU_HolderTest.java deleted file mode 100644 index 51d7dd1d..00000000 --- a/cadi/client/src/test/java/org/onap/aaf/client/test/JU_HolderTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * - ******************************************************************************/ -package org.onap.aaf.client.test; - -import static org.junit.Assert.*; - -import org.junit.Test; -import org.onap.aaf.cadi.client.Holder; - -import static org.junit.Assert.*; - -import org.junit.Before; -import org.junit.Test; - -public class JU_HolderTest { - - @Test - public void testSet() { - Holder holder = new Holder("StringHolder"); - assertEquals(holder.get(), "StringHolder"); - - holder.set("New String"); - assertEquals(holder.get(), "New String"); - } - - @Test - public void testSet4() { - Holder holder = new Holder("StringHolder"); - assertEquals(holder.get(), "StringHolder"); - - holder.set("New String1"); - assertEquals(holder.get(), "New String1"); - } - @Test - public void testSet1() { - Holder holder = new Holder("StringHolder"); - assertEquals(holder.get(), "StringHolder"); - - holder.set("New String2"); - assertEquals(holder.get(), "New String2"); - } - - @Test - public void testSet2() { - Holder holder = new Holder("StringHolder"); - assertEquals(holder.get(), "StringHolder"); - - holder.set("New String3"); - assertEquals(holder.get(), "New String3"); - } - - @Test - public void testSet3() { - Holder holder = new Holder("StringHolder"); - assertEquals(holder.get(), "StringHolder"); - - holder.set("New String4"); - assertEquals(holder.get(), "New String4"); - } -} -- cgit 1.2.3-korg