diff options
author | IanHowell <ian.howell@att.com> | 2018-04-06 09:57:16 -0500 |
---|---|---|
committer | IanHowell <ian.howell@att.com> | 2018-04-10 10:49:25 -0500 |
commit | 9b0ed8da9474c99c13fbdff62894c09311cf9036 (patch) | |
tree | 5e63ccd07951ddcc3333130560e32b9ef973c6e0 /auth/auth-cass/src/test | |
parent | 1b6fe335be7f1dfbf83e87db016506c3a4f7c413 (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 'auth/auth-cass/src/test')
-rw-r--r-- | auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_Cached.java | 42 |
1 files changed, 29 insertions, 13 deletions
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<Trans> ciDaoMock; + @Mock AuthzEnv authzEnvMock; + @Mock CIDAO<AuthzTrans> 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<Trans, DataStub> cached = new Cached<Trans, DataStub>(ciDaoMock, name, 1, 30000L); + assertThat(cached.cacheIdx("1234567890"), is(0)); } - @Test(expected=ArithmeticException.class) + @Test public void testInvalidate(){ - int Res = cached.invalidate(name); + Cached<Trans, DataStub> cached = new Cached<Trans, DataStub>(ciDaoMock, name, 5, 30000L); + cached.add("test", new ArrayList<DataStub>()); + cached.invalidate("test"); + cached.invalidate("test1"); } @SuppressWarnings("static-access") @Test public void testStopTimer(){ + Cached<Trans, DataStub> cached = new Cached<Trans, DataStub>(ciDaoMock, name, 1, 30000L); cached.stopTimer(); assertTrue(true); } @@ -80,6 +91,7 @@ public class JU_Cached { @SuppressWarnings("static-access") @Test public void testStartRefresh(){ + Cached<Trans, DataStub> cached = new Cached<Trans, DataStub>(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; } + } } |