summaryrefslogtreecommitdiffstats
path: root/cadi/client/src/test/java/org
diff options
context:
space:
mode:
authorIanHowell <ian.howell@att.com>2018-04-06 09:57:16 -0500
committerIanHowell <ian.howell@att.com>2018-04-10 10:49:25 -0500
commit9b0ed8da9474c99c13fbdff62894c09311cf9036 (patch)
tree5e63ccd07951ddcc3333130560e32b9ef973c6e0 /cadi/client/src/test/java/org
parent1b6fe335be7f1dfbf83e87db016506c3a4f7c413 (diff)
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 <ian.howell@att.com> 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 <ian.howell@att.com> Improve coverage of the Tafs Issue-ID: AAF-128 Change-Id: I07f9ebee0a64c598047e74801a266898107783f7 Signed-off-by: IanHowell <ian.howell@att.com> Improve test coverage of XReader Issue-ID: AAF-128 Change-Id: I9b369b803743166027170b4a8ca50bd337e45b7b Signed-off-by: IanHowell <ian.howell@att.com> Improve coverage of GreatCircle Issue-ID: AAF-128 Change-Id: Id5e41a481db1106d050fb216664c1aa1e07cef2a Signed-off-by: IanHowell <ian.howell@att.com> Suppress test output Issue-ID: AAF-128 Change-Id: I7a7afe7617c81403d27baf89353f175d9cead165 Signed-off-by: IanHowell <ian.howell@att.com> Move JU_DNSLocator to the correct package Change-Id: Ic8feddf7444afcaaaa252a40d340116597533f46 Signed-off-by: IanHowell <ian.howell@att.com>
Diffstat (limited to 'cadi/client/src/test/java/org')
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_GreatCircle.java62
-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.java79
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/client/test/JU_HolderTest.java79
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");
- }
-}