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 --- .../test/java/org/onap/aaf/auth/dao/JU_Cached.java | 42 +++++++++++++++------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'auth/auth-cass/src') diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_Cached.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_Cached.java index 22f9a6f7..e942f3f1 100644 --- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_Cached.java +++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_Cached.java @@ -22,57 +22,68 @@ package org.onap.aaf.auth.dao; import static org.junit.Assert.*; +import static org.hamcrest.CoreMatchers.*; +import static org.mockito.Mockito.*; +import org.junit.*; +import org.mockito.*; +// import org.junit.runner.RunWith; +// import org.powermock.modules.junit4.PowerMockRunner; import java.util.Date; import java.util.List; +import java.util.ArrayList; import java.util.Map; import java.util.Timer; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; import org.onap.aaf.auth.cache.Cache; import org.onap.aaf.auth.cache.Cache.Dated; import org.onap.aaf.auth.dao.CIDAO; import org.onap.aaf.auth.dao.Cached; import org.onap.aaf.auth.dao.Cached.Getter; +import org.onap.aaf.auth.dao.JU_Cached.DataStub; +import org.onap.aaf.auth.dao.cass.CacheableData; import org.onap.aaf.auth.env.AuthzEnv; import org.onap.aaf.auth.env.AuthzTrans; import org.onap.aaf.auth.layer.Result; import org.onap.aaf.misc.env.Trans; -import org.powermock.modules.junit4.PowerMockRunner; -@RunWith(PowerMockRunner.class) +// @RunWith(PowerMockRunner.class) public class JU_Cached { - Cached cached; + @Mock CIDAO ciDaoMock; + @Mock AuthzEnv authzEnvMock; + @Mock CIDAO cidaoATMock; String name = "nameString"; - + @Before public void setUp(){ - cached = new Cached(ciDaoMock, name, (int)0, 30000L); + MockitoAnnotations.initMocks(this); } - @Test(expected=ArithmeticException.class) + @Test public void testCachedIdx(){ - int Result = cached.cacheIdx("1234567890"); + Cached cached = new Cached(ciDaoMock, name, 1, 30000L); + assertThat(cached.cacheIdx("1234567890"), is(0)); } - @Test(expected=ArithmeticException.class) + @Test public void testInvalidate(){ - int Res = cached.invalidate(name); + Cached cached = new Cached(ciDaoMock, name, 5, 30000L); + cached.add("test", new ArrayList()); + cached.invalidate("test"); + cached.invalidate("test1"); } @SuppressWarnings("static-access") @Test public void testStopTimer(){ + Cached cached = new Cached(ciDaoMock, name, 1, 30000L); cached.stopTimer(); assertTrue(true); } @@ -80,6 +91,7 @@ public class JU_Cached { @SuppressWarnings("static-access") @Test public void testStartRefresh(){ + Cached cached = new Cached(ciDaoMock, name, 1, 30000L); cached.startRefresh(authzEnvMock, cidaoATMock); assertTrue(true); } @@ -121,4 +133,8 @@ public class JU_Cached { // } // return rld; // } + + class DataStub extends CacheableData { + @Override public int[] invalidate(Cached cache) { return null; } + } } -- cgit 1.2.3-korg