diff options
Diffstat (limited to 'cadi/client/src')
-rw-r--r-- | cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_GreatCircle.java | 62 | ||||
-rw-r--r-- | cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Holder.java (renamed from cadi/client/src/test/java/org/onap/aaf/client/test/JU_DNSLocator.java) | 36 | ||||
-rw-r--r-- | cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java (renamed from cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_DNSLocator.java) | 0 | ||||
-rw-r--r-- | cadi/client/src/test/java/org/onap/aaf/cadi/routing/test/JU_GreatCircle.java | 79 | ||||
-rw-r--r-- | cadi/client/src/test/java/org/onap/aaf/client/test/JU_HolderTest.java | 79 |
5 files changed, 92 insertions, 164 deletions
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/client/test/JU_DNSLocator.java b/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Holder.java index 777b4f98..079951f5 100644 --- a/cadi/client/src/test/java/org/onap/aaf/client/test/JU_DNSLocator.java +++ b/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Holder.java @@ -19,37 +19,27 @@ * * * * ******************************************************************************/ -package org.onap.aaf.client.test; +package org.onap.aaf.cadi.client.test; -import java.net.URI; -import java.net.URL; -import java.net.URLConnection; - -import org.junit.AfterClass; +import static org.junit.Assert.*; +import static org.hamcrest.CoreMatchers.*; 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 { +import org.onap.aaf.cadi.client.Holder; - @AfterClass - public static void tearDownAfterClass() throws Exception { - } +public class JU_Holder { @Test public void test() { + String str1 = "a string"; + String str2 = "another string"; + Holder<String> holder = new Holder<String>(str1); + assertThat(holder.get(), is(str1)); + assertThat(holder.toString(), is(str1)); - 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(); - } + 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/client/test/JU_DNSLocator.java b/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java index b97667d5..b97667d5 100644 --- 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/locator/test/JU_DNSLocator.java 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_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<String> holder = new Holder<String>("StringHolder"); - assertEquals(holder.get(), "StringHolder"); - - holder.set("New String"); - assertEquals(holder.get(), "New String"); - } - - @Test - public void testSet4() { - Holder<String> holder = new Holder<String>("StringHolder"); - assertEquals(holder.get(), "StringHolder"); - - holder.set("New String1"); - assertEquals(holder.get(), "New String1"); - } - @Test - public void testSet1() { - Holder<String> holder = new Holder<String>("StringHolder"); - assertEquals(holder.get(), "StringHolder"); - - holder.set("New String2"); - assertEquals(holder.get(), "New String2"); - } - - @Test - public void testSet2() { - Holder<String> holder = new Holder<String>("StringHolder"); - assertEquals(holder.get(), "StringHolder"); - - holder.set("New String3"); - assertEquals(holder.get(), "New String3"); - } - - @Test - public void testSet3() { - Holder<String> holder = new Holder<String>("StringHolder"); - assertEquals(holder.get(), "StringHolder"); - - holder.set("New String4"); - assertEquals(holder.get(), "New String4"); - } -} |