summaryrefslogtreecommitdiffstats
path: root/auth/auth-core/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'auth/auth-core/src/test/java')
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/common/test/JU_Define.java78
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzEnv.java264
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransFilter.java104
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransImpl.java232
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransOnlyFilter.java120
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_NullTrans.java438
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/layer/test/JU_Result.java288
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_AbsData.java112
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_DataFile.java64
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_TextIndex.java144
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_Organization.java82
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_OrganizationException.java28
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_OrganizationFactory.java56
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/CredCompare.java58
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/JU_RequestCheck.java26
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/MultiCompare.java72
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSAttribCompare.java112
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSCompare.java78
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/PermCompare.java62
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RoleCompare.java58
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RolePermCompare.java66
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RosettaCompare.java68
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/UserRoleCompare.java58
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterMatch.java252
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterMatch1.java240
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterRoute.java8
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_CachingFileAccess.java234
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Content.java1204
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Content1.java170
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Pair.java26
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Route.java46
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_RouteReport.java12
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Routes.java52
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_TypedCode.java112
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Version.java62
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java84
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java152
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_JettyServiceStarter.java76
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/JU_Mask.java66
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/validation/test/JU_Validator.java550
40 files changed, 3007 insertions, 3007 deletions
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/common/test/JU_Define.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/common/test/JU_Define.java
index 0f986f24..68f359c5 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/common/test/JU_Define.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/common/test/JU_Define.java
@@ -37,48 +37,48 @@ import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
public class JU_Define {
- private static final String AAF_NS_DOT = "AAF_NS.";
- public static String ROOT_NS="NS.Not.Set";
- public static String ROOT_COMPANY=ROOT_NS;
- Access acc;
- @Mock
- Env envMock;
+ private static final String AAF_NS_DOT = "AAF_NS.";
+ public static String ROOT_NS="NS.Not.Set";
+ public static String ROOT_COMPANY=ROOT_NS;
+ Access acc;
+ @Mock
+ Env envMock;
- @Before
- public void setUp() throws CadiException{
- acc = mock(Access.class);
- }
-
- @Test
- public void testSet() throws CadiException {
- PropAccess prop = new PropAccess();
- prop.setProperty(AAF_NS_DOT, AAF_NS_DOT);
- prop.setProperty(Config.AAF_ROOT_NS, ".ns_Test");
- prop.setProperty(Config.AAF_ROOT_COMPANY, "company_Test");
- Define.set(prop);
- Define.ROOT_NS();
- Define.ROOT_COMPANY();
-
- PropAccess prop1 = new PropAccess();
- prop1.setProperty(AAF_NS_DOT, AAF_NS_DOT);
- prop1.setProperty(Config.AAF_ROOT_NS, ".ns_Test");
- Define.set(prop1);
- }
+ @Before
+ public void setUp() throws CadiException{
+ acc = mock(Access.class);
+ }
+
+ @Test
+ public void testSet() throws CadiException {
+ PropAccess prop = new PropAccess();
+ prop.setProperty(AAF_NS_DOT, AAF_NS_DOT);
+ prop.setProperty(Config.AAF_ROOT_NS, ".ns_Test");
+ prop.setProperty(Config.AAF_ROOT_COMPANY, "company_Test");
+ Define.set(prop);
+ Define.ROOT_NS();
+ Define.ROOT_COMPANY();
+
+ PropAccess prop1 = new PropAccess();
+ prop1.setProperty(AAF_NS_DOT, AAF_NS_DOT);
+ prop1.setProperty(Config.AAF_ROOT_NS, ".ns_Test");
+ Define.set(prop1);
+ }
-// @Test //TODO: AAF-111 exception fix
-// public void testRootNS() throws RuntimeException{
-// Define.ROOT_NS();
-// }
+// @Test //TODO: AAF-111 exception fix
+// public void testRootNS() throws RuntimeException{
+// Define.ROOT_NS();
+// }
//
-// @Test
-// public void testRootCompany() throws RuntimeException{
-// Define.ROOT_COMPANY();
-// }
+// @Test
+// public void testRootCompany() throws RuntimeException{
+// Define.ROOT_COMPANY();
+// }
- @Test
- public void testVarReplace() {
- Define.varReplace(AAF_NS_DOT);
- Define.varReplace("test");
- }
+ @Test
+ public void testVarReplace() {
+ Define.varReplace(AAF_NS_DOT);
+ Define.varReplace("test");
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzEnv.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzEnv.java
index b30085fc..b170ae55 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzEnv.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzEnv.java
@@ -41,137 +41,137 @@ import org.onap.aaf.cadi.config.Config;
public class JU_AuthzEnv {
- AuthzEnv authzEnv;
- ByteArrayOutputStream outStream;
- ByteArrayOutputStream errStream;
- enum Level {DEBUG, INFO, AUDIT, INIT, WARN, ERROR};
-
- @Before
- public void setUp() {
- outStream = new ByteArrayOutputStream();
- errStream = new ByteArrayOutputStream();
-
- System.setOut(new PrintStream(outStream));
- System.setErr(new PrintStream(errStream));
-
- authzEnv = new AuthzEnv();
- }
-
- @After
- public void tearDown() {
- System.setOut(System.out);
- System.setErr(System.err);
- }
-
- @Test
- @SuppressWarnings("unused")
- public void testConstructors() {
- AuthzEnv authzEnv1 = new AuthzEnv("Test");
- AuthzEnv authzEnv2 = new AuthzEnv((PropAccess)null);
- AuthzEnv authzEnv3 = new AuthzEnv((Properties)null);
- }
-
- @Test
- public void testTransRate() {
- Long Result = authzEnv.transRate();
- assertNotNull(Result);
- }
-
- @Test
- public void checkNewTransNoAvg() {
- assertNotNull(authzEnv.newTransNoAvg());
- }
-
- @Test
- public void checkNewTrans() {
- assertNotNull(authzEnv.newTrans());
- }
-
- @Test
- public void checkPropAccess() {
- assertNotNull(authzEnv.access());
- }
-
- @Test
- public void checkgetProperties() { //TODO:[GABE]No setter for this, add?
- assertNotNull(authzEnv.getProperties());
- assertNotNull(authzEnv.getProperties("test"));
- }
-
- @Test
- public void checkPropertyGetters(){
- authzEnv.setProperty("key","value");
- assertEquals(authzEnv.getProperty("key"), "value");
- assertEquals(authzEnv.getProperty("key","value"), "value");
- }
-
- @Test
- public void checkPropertySetters(){
- assertEquals(authzEnv.getProperty("key","value"), authzEnv.setProperty("key","value"));
- }
-
- @Test(expected = IOException.class)
- public void testDecryptException() throws IOException{
- authzEnv.setProperty(Config.CADI_KEYFILE, "test/keyfile");
- authzEnv.decrypt(null, false);
- }
-
- @Test
- public void testDecrypt() throws IOException{
- String encrypted = "encrypted";
- String Result = authzEnv.decrypt(encrypted, true);
- assertEquals("encrypted",Result);
- }
-
- @Test
- public void testClassLoader() {
- ClassLoader cLoad = mock(ClassLoader.class);
- cLoad = authzEnv.classLoader();
- assertNotNull(cLoad);
- }
-
- @Test
- public void testLoad() throws IOException {
- InputStream is = mock(InputStream.class);
- authzEnv.load(is);
- }
-
- @Test
- public void testLog() {
- Access.Level lvl = Access.Level.DEBUG;
- Object msgs = null;
- authzEnv.log(lvl, msgs);
- }
-
- @Test
- public void testLog1() {
-
- Exception e = new Exception();
- Object msgs = null;
- authzEnv.log(e, msgs);
- }
-
- @Test
- public void testPrintf() {
- Access.Level lvl = Access.Level.DEBUG;
- Object msgs = null;
- authzEnv.printf(lvl, "Test", msgs);
- }
-
- @Test
- public void testWillLog() {
- Access.Level lvl = Access.Level.DEBUG;
- Access.Level lvl1 = Access.Level.AUDIT;
- boolean test = authzEnv.willLog(lvl);
- assertFalse(test);
- test = authzEnv.willLog(lvl1);
- assertTrue(test);
- }
-
- @Test
- public void testSetLogLevel() {
- Access.Level lvl = Access.Level.DEBUG;
- authzEnv.setLogLevel(lvl);
- }
+ AuthzEnv authzEnv;
+ ByteArrayOutputStream outStream;
+ ByteArrayOutputStream errStream;
+ enum Level {DEBUG, INFO, AUDIT, INIT, WARN, ERROR};
+
+ @Before
+ public void setUp() {
+ outStream = new ByteArrayOutputStream();
+ errStream = new ByteArrayOutputStream();
+
+ System.setOut(new PrintStream(outStream));
+ System.setErr(new PrintStream(errStream));
+
+ authzEnv = new AuthzEnv();
+ }
+
+ @After
+ public void tearDown() {
+ System.setOut(System.out);
+ System.setErr(System.err);
+ }
+
+ @Test
+ @SuppressWarnings("unused")
+ public void testConstructors() {
+ AuthzEnv authzEnv1 = new AuthzEnv("Test");
+ AuthzEnv authzEnv2 = new AuthzEnv((PropAccess)null);
+ AuthzEnv authzEnv3 = new AuthzEnv((Properties)null);
+ }
+
+ @Test
+ public void testTransRate() {
+ Long Result = authzEnv.transRate();
+ assertNotNull(Result);
+ }
+
+ @Test
+ public void checkNewTransNoAvg() {
+ assertNotNull(authzEnv.newTransNoAvg());
+ }
+
+ @Test
+ public void checkNewTrans() {
+ assertNotNull(authzEnv.newTrans());
+ }
+
+ @Test
+ public void checkPropAccess() {
+ assertNotNull(authzEnv.access());
+ }
+
+ @Test
+ public void checkgetProperties() { //TODO:[GABE]No setter for this, add?
+ assertNotNull(authzEnv.getProperties());
+ assertNotNull(authzEnv.getProperties("test"));
+ }
+
+ @Test
+ public void checkPropertyGetters(){
+ authzEnv.setProperty("key","value");
+ assertEquals(authzEnv.getProperty("key"), "value");
+ assertEquals(authzEnv.getProperty("key","value"), "value");
+ }
+
+ @Test
+ public void checkPropertySetters(){
+ assertEquals(authzEnv.getProperty("key","value"), authzEnv.setProperty("key","value"));
+ }
+
+ @Test(expected = IOException.class)
+ public void testDecryptException() throws IOException{
+ authzEnv.setProperty(Config.CADI_KEYFILE, "test/keyfile");
+ authzEnv.decrypt(null, false);
+ }
+
+ @Test
+ public void testDecrypt() throws IOException{
+ String encrypted = "encrypted";
+ String Result = authzEnv.decrypt(encrypted, true);
+ assertEquals("encrypted",Result);
+ }
+
+ @Test
+ public void testClassLoader() {
+ ClassLoader cLoad = mock(ClassLoader.class);
+ cLoad = authzEnv.classLoader();
+ assertNotNull(cLoad);
+ }
+
+ @Test
+ public void testLoad() throws IOException {
+ InputStream is = mock(InputStream.class);
+ authzEnv.load(is);
+ }
+
+ @Test
+ public void testLog() {
+ Access.Level lvl = Access.Level.DEBUG;
+ Object msgs = null;
+ authzEnv.log(lvl, msgs);
+ }
+
+ @Test
+ public void testLog1() {
+
+ Exception e = new Exception();
+ Object msgs = null;
+ authzEnv.log(e, msgs);
+ }
+
+ @Test
+ public void testPrintf() {
+ Access.Level lvl = Access.Level.DEBUG;
+ Object msgs = null;
+ authzEnv.printf(lvl, "Test", msgs);
+ }
+
+ @Test
+ public void testWillLog() {
+ Access.Level lvl = Access.Level.DEBUG;
+ Access.Level lvl1 = Access.Level.AUDIT;
+ boolean test = authzEnv.willLog(lvl);
+ assertFalse(test);
+ test = authzEnv.willLog(lvl1);
+ assertTrue(test);
+ }
+
+ @Test
+ public void testSetLogLevel() {
+ Access.Level lvl = Access.Level.DEBUG;
+ authzEnv.setLogLevel(lvl);
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransFilter.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransFilter.java
index ccfb01aa..e5b4209f 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransFilter.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransFilter.java
@@ -49,62 +49,62 @@ import org.onap.aaf.misc.env.Trans.Metric;
public class JU_AuthzTransFilter {
- @Mock private AuthzEnv envMock;
- @Mock private Connector connectorMock;
- @Mock private TrustChecker tcMock;
- @Mock private AuthzTrans authzTransMock;
- @Mock private Object additionalTafLurs;
-
- private PropAccess access;
+ @Mock private AuthzEnv envMock;
+ @Mock private Connector connectorMock;
+ @Mock private TrustChecker tcMock;
+ @Mock private AuthzTrans authzTransMock;
+ @Mock private Object additionalTafLurs;
+
+ private PropAccess access;
- @Before
- public void setUp() throws CadiException{
- MockitoAnnotations.initMocks(this);
+ @Before
+ public void setUp() throws CadiException{
+ MockitoAnnotations.initMocks(this);
- access = new PropAccess(new PrintStream(new ByteArrayOutputStream()), new String[0]);
+ access = new PropAccess(new PrintStream(new ByteArrayOutputStream()), new String[0]);
- when(envMock.access()).thenReturn(access);
- }
-
- // TODO: These tests only work on the AT&T network. Fix them - Ian
- @Test
- public void testAuthenticated() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, CadiException {
-// AuthzTransFilter filter = new AuthzTransFilter(envMock, connectorMock, tcMock);
-// AuthzTransFilter aTF = new AuthzTransFilter(authzEnvMock, connectorMock, trustCheckerMock, (Object)null);
-// Class<?> c = aTF.getClass();
-// Class<?>[] cArg = new Class[2];
-// cArg[0] = AuthzTrans.class;
-// cArg[1] = Principal.class; //Steps to test a protected method
-// Method authenticatedMethod = c.getDeclaredMethod("authenticated", cArg);
-// authenticatedMethod.setAccessible(true);
-// authenticatedMethod.invoke(aTF, authzTransMock, null);
- }
-
- @Test
- public void testTallyHo() throws CadiException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
-// Slot specialLogSlot = authzEnvMock.slot("SPECIAL_LOG_SLOT");
-// LogTarget lt = mock(LogTarget.class);
-// AuthzTransFilter aTF = new AuthzTransFilter(authzEnvMock, connectorMock, trustCheckerMock, additionalTafLurs);
-// TaggedPrincipal tPrin = mock(TaggedPrincipal.class);
-// Metric met = new Metric();
-// met.total = 199.33F;
-// met.entries = 15;
-// met.buckets = new float[] {199.33F,99.33F};
-// Class<?> c = aTF.getClass();
-// Class<?>[] cArg = new Class[1];
-// cArg[0] = AuthzTrans.class; //Steps to test a protected method
-// Method tallyHoMethod = c.getDeclaredMethod("tallyHo", cArg);
+ when(envMock.access()).thenReturn(access);
+ }
+
+ // TODO: These tests only work on the AT&T network. Fix them - Ian
+ @Test
+ public void testAuthenticated() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, CadiException {
+// AuthzTransFilter filter = new AuthzTransFilter(envMock, connectorMock, tcMock);
+// AuthzTransFilter aTF = new AuthzTransFilter(authzEnvMock, connectorMock, trustCheckerMock, (Object)null);
+// Class<?> c = aTF.getClass();
+// Class<?>[] cArg = new Class[2];
+// cArg[0] = AuthzTrans.class;
+// cArg[1] = Principal.class; //Steps to test a protected method
+// Method authenticatedMethod = c.getDeclaredMethod("authenticated", cArg);
+// authenticatedMethod.setAccessible(true);
+// authenticatedMethod.invoke(aTF, authzTransMock, null);
+ }
+
+ @Test
+ public void testTallyHo() throws CadiException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+// Slot specialLogSlot = authzEnvMock.slot("SPECIAL_LOG_SLOT");
+// LogTarget lt = mock(LogTarget.class);
+// AuthzTransFilter aTF = new AuthzTransFilter(authzEnvMock, connectorMock, trustCheckerMock, additionalTafLurs);
+// TaggedPrincipal tPrin = mock(TaggedPrincipal.class);
+// Metric met = new Metric();
+// met.total = 199.33F;
+// met.entries = 15;
+// met.buckets = new float[] {199.33F,99.33F};
+// Class<?> c = aTF.getClass();
+// Class<?>[] cArg = new Class[1];
+// cArg[0] = AuthzTrans.class; //Steps to test a protected method
+// Method tallyHoMethod = c.getDeclaredMethod("tallyHo", cArg);
//
-// when(authzTransMock.auditTrail(((LogTarget)any()), anyInt(), (StringBuilder)any(), anyInt(), anyInt())).thenReturn(met);
-// tallyHoMethod.setAccessible(true);
+// when(authzTransMock.auditTrail(((LogTarget)any()), anyInt(), (StringBuilder)any(), anyInt(), anyInt())).thenReturn(met);
+// tallyHoMethod.setAccessible(true);
//
-// when(authzTransMock.get(specialLogSlot, false)).thenReturn(false);
-// when(authzTransMock.warn()).thenReturn(lt);
-// when(authzTransMock.info()).thenReturn(lt);
-// tallyHoMethod.invoke(aTF, authzTransMock);
+// when(authzTransMock.get(specialLogSlot, false)).thenReturn(false);
+// when(authzTransMock.warn()).thenReturn(lt);
+// when(authzTransMock.info()).thenReturn(lt);
+// tallyHoMethod.invoke(aTF, authzTransMock);
//
-// when(authzTransMock.getUserPrincipal()).thenReturn(tPrin);
-// tallyHoMethod.invoke(aTF, authzTransMock);
- }
-
+// when(authzTransMock.getUserPrincipal()).thenReturn(tPrin);
+// tallyHoMethod.invoke(aTF, authzTransMock);
+ }
+
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransImpl.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransImpl.java
index 317fb94a..8e6d5028 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransImpl.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransImpl.java
@@ -50,120 +50,120 @@ import junit.framework.Assert;
@RunWith(PowerMockRunner.class)
public class JU_AuthzTransImpl {
- AuthzTransImpl authzTransImpl;
- @Mock
- AuthzEnv authzEnvMock;
- AuthzTransImpl trans1;
-
- private Organization org=null;
- private AuthzTransImpl mockAuthzTransImpl;
- private static HttpServletRequest req;
- private static HttpServletResponse res;
- private Lur lur1 = mock(Lur.class);
-
- @Before
- public void setUp(){
- authzTransImpl = new AuthzTransImpl(authzEnvMock);
- req = mock(HttpServletRequest.class);
- authzTransImpl.set(req);
- when(req.getParameter("request")).thenReturn("NotNull");
- authzTransImpl.set(req);
- when(req.getParameter("request")).thenReturn("");
- authzTransImpl.set(req);
- }
-
- @Test
- public void testOrg() {
- Organization result=null;
- result = authzTransImpl.org();
- OrganizationFactory test = mock(OrganizationFactory.class);
- //result = OrganizationFactory.obtain(authzTransImpl.env(), authzTransImpl.user());
- authzTransImpl.org();
- //when(test).thenReturn(null);
- //assertTrue(true);
- }
-
- @Mock
- LogTarget logTargetMock;
-
- @Test
- public void testLogAuditTrail(){
-
- when(logTargetMock.isLoggable()).thenReturn(false);
- authzTransImpl.logAuditTrail(logTargetMock);
- when(logTargetMock.isLoggable()).thenReturn(true);
- Env delegate = mock(Env.class);
- //when(logTargetMock.isLoggable()).thenReturn(true);//TODO: Figure this out
- //authzTransImpl.logAuditTrail(logTargetMock);
- }
-
-// @Test //TODO:Fix this AAF-111
-// public void testSetUser() {
-// Principal user = mock(Principal.class);
-// authzTransImpl.setUser(user);
-// Principal user1 = authzTransImpl.getUserPrincipal();
-// String username = user1.getName();
-// Assert.assertNotNull(user1);
-// }
-
-// @Test //TODO:Fix this AAF-111
-// public void testUser() {
-// Assert.assertEquals("n/a", authzTransImpl.user());
-// Principal user = mock(Principal.class); //Unsure how to modify name
-// when(user.toString()).thenReturn("name");
-// when(user.getName()).thenReturn("name");
-// authzTransImpl.setUser(user);
-// Assert.assertEquals("name", authzTransImpl.user());
-// }
-//
- @Test
- public void testRequested() {
- REQD_TYPE user = REQD_TYPE.move;
- REQD_TYPE user1 = REQD_TYPE.future;
- HttpServletRequest req = mock(HttpServletRequest.class);
- String p = user1.name();
- boolean boolUser = authzTransImpl.requested(user);
- Assert.assertEquals(false, boolUser);
- Assert.assertNotNull(p);
- authzTransImpl.requested(user,true);
- when(authzTransImpl.requested(user)).thenReturn(null);
- Assert.assertEquals(true, authzTransImpl.requested(user));
- /* String p1 = req.getParameter(user1.name()); //unable to access private method call in all instances
- when(req.getParameter(user1.name())).thenReturn("test");
- authzTransImpl.requested(user,false);
- */
-
-
- }
-
- @Test
- public void testFish() {
- mockAuthzTransImpl = mock(AuthzTransImpl.class);
- Permission p = mock(Permission.class);
- authzTransImpl.fish(p);
- String str = "Test";
- lur1.createPerm(str);
- when(p.match(p)).thenReturn(true);
- authzTransImpl.setLur(lur1);
- authzTransImpl.fish(p);
- }
-
- @Test
- public void testSetVariables() { //TODO: refactor this better
- Assert.assertNull(authzTransImpl.agent());
- Assert.assertNull(authzTransImpl.ip());
- Assert.assertNull(authzTransImpl.path());
- Assert.assertNotNull(authzTransImpl.port());
- Assert.assertNull(authzTransImpl.meth());
- Assert.assertNull(authzTransImpl.getUserPrincipal());
- Assert.assertNotNull(authzTransImpl.user());
- }
-
- @Test
- public void testNow() {
- Date date = authzTransImpl.now();
- Assert.assertEquals(date,authzTransImpl.now());
- when(authzTransImpl.now()).thenReturn(null);
- }
-
+ AuthzTransImpl authzTransImpl;
+ @Mock
+ AuthzEnv authzEnvMock;
+ AuthzTransImpl trans1;
+
+ private Organization org=null;
+ private AuthzTransImpl mockAuthzTransImpl;
+ private static HttpServletRequest req;
+ private static HttpServletResponse res;
+ private Lur lur1 = mock(Lur.class);
+
+ @Before
+ public void setUp(){
+ authzTransImpl = new AuthzTransImpl(authzEnvMock);
+ req = mock(HttpServletRequest.class);
+ authzTransImpl.set(req);
+ when(req.getParameter("request")).thenReturn("NotNull");
+ authzTransImpl.set(req);
+ when(req.getParameter("request")).thenReturn("");
+ authzTransImpl.set(req);
+ }
+
+ @Test
+ public void testOrg() {
+ Organization result=null;
+ result = authzTransImpl.org();
+ OrganizationFactory test = mock(OrganizationFactory.class);
+ //result = OrganizationFactory.obtain(authzTransImpl.env(), authzTransImpl.user());
+ authzTransImpl.org();
+ //when(test).thenReturn(null);
+ //assertTrue(true);
+ }
+
+ @Mock
+ LogTarget logTargetMock;
+
+ @Test
+ public void testLogAuditTrail(){
+
+ when(logTargetMock.isLoggable()).thenReturn(false);
+ authzTransImpl.logAuditTrail(logTargetMock);
+ when(logTargetMock.isLoggable()).thenReturn(true);
+ Env delegate = mock(Env.class);
+ //when(logTargetMock.isLoggable()).thenReturn(true);//TODO: Figure this out
+ //authzTransImpl.logAuditTrail(logTargetMock);
+ }
+
+// @Test //TODO:Fix this AAF-111
+// public void testSetUser() {
+// Principal user = mock(Principal.class);
+// authzTransImpl.setUser(user);
+// Principal user1 = authzTransImpl.getUserPrincipal();
+// String username = user1.getName();
+// Assert.assertNotNull(user1);
+// }
+
+// @Test //TODO:Fix this AAF-111
+// public void testUser() {
+// Assert.assertEquals("n/a", authzTransImpl.user());
+// Principal user = mock(Principal.class); //Unsure how to modify name
+// when(user.toString()).thenReturn("name");
+// when(user.getName()).thenReturn("name");
+// authzTransImpl.setUser(user);
+// Assert.assertEquals("name", authzTransImpl.user());
+// }
+//
+ @Test
+ public void testRequested() {
+ REQD_TYPE user = REQD_TYPE.move;
+ REQD_TYPE user1 = REQD_TYPE.future;
+ HttpServletRequest req = mock(HttpServletRequest.class);
+ String p = user1.name();
+ boolean boolUser = authzTransImpl.requested(user);
+ Assert.assertEquals(false, boolUser);
+ Assert.assertNotNull(p);
+ authzTransImpl.requested(user,true);
+ when(authzTransImpl.requested(user)).thenReturn(null);
+ Assert.assertEquals(true, authzTransImpl.requested(user));
+ /* String p1 = req.getParameter(user1.name()); //unable to access private method call in all instances
+ when(req.getParameter(user1.name())).thenReturn("test");
+ authzTransImpl.requested(user,false);
+ */
+
+
+ }
+
+ @Test
+ public void testFish() {
+ mockAuthzTransImpl = mock(AuthzTransImpl.class);
+ Permission p = mock(Permission.class);
+ authzTransImpl.fish(p);
+ String str = "Test";
+ lur1.createPerm(str);
+ when(p.match(p)).thenReturn(true);
+ authzTransImpl.setLur(lur1);
+ authzTransImpl.fish(p);
+ }
+
+ @Test
+ public void testSetVariables() { //TODO: refactor this better
+ Assert.assertNull(authzTransImpl.agent());
+ Assert.assertNull(authzTransImpl.ip());
+ Assert.assertNull(authzTransImpl.path());
+ Assert.assertNotNull(authzTransImpl.port());
+ Assert.assertNull(authzTransImpl.meth());
+ Assert.assertNull(authzTransImpl.getUserPrincipal());
+ Assert.assertNotNull(authzTransImpl.user());
+ }
+
+ @Test
+ public void testNow() {
+ Date date = authzTransImpl.now();
+ Assert.assertEquals(date,authzTransImpl.now());
+ when(authzTransImpl.now()).thenReturn(null);
+ }
+
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransOnlyFilter.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransOnlyFilter.java
index f1243513..4d233990 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransOnlyFilter.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransOnlyFilter.java
@@ -49,71 +49,71 @@ import org.onap.aaf.misc.env.Trans.Metric;
@RunWith(MockitoJUnitRunner.class)
public class JU_AuthzTransOnlyFilter {
- AuthzTransFilter authzTransFilter;
- AuthzEnv authzEnvMock = mock(AuthzEnv.class);
- Connector connectorMock = mock(Connector.class);
- TrustChecker trustCheckerMock = mock(TrustChecker.class);
- AuthzTrans authzTransMock = mock(AuthzTrans.class);
- Object additionalTafLurs = mock(Object.class);
- ServletRequest servletRequestMock = mock(ServletRequest.class);
- AuthzTransOnlyFilter authzTransOnlyFilter;
+ AuthzTransFilter authzTransFilter;
+ AuthzEnv authzEnvMock = mock(AuthzEnv.class);
+ Connector connectorMock = mock(Connector.class);
+ TrustChecker trustCheckerMock = mock(TrustChecker.class);
+ AuthzTrans authzTransMock = mock(AuthzTrans.class);
+ Object additionalTafLurs = mock(Object.class);
+ ServletRequest servletRequestMock = mock(ServletRequest.class);
+ AuthzTransOnlyFilter authzTransOnlyFilter;
- @Before
- public void setUp(){
- authzTransOnlyFilter = new AuthzTransOnlyFilter(authzEnvMock);
- }
+ @Before
+ public void setUp(){
+ authzTransOnlyFilter = new AuthzTransOnlyFilter(authzEnvMock);
+ }
- /*@Test
- public void testProtected() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
- Method newTransMethod = AuthzTransFilter.class.getDeclaredMethod("newTrans");
- newTransMethod.setAccessible(true);
+ /*@Test
+ public void testProtected() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ Method newTransMethod = AuthzTransFilter.class.getDeclaredMethod("newTrans");
+ newTransMethod.setAccessible(true);
- newTransMethod.invoke(authzTransFilter);
- }*/
+ newTransMethod.invoke(authzTransFilter);
+ }*/
- @Test
- public void testStart() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
- AuthzTransOnlyFilter aTF = new AuthzTransOnlyFilter(authzEnvMock);
- Class c = aTF.getClass();
- Class[] cArg = new Class[2];
- cArg[0] = AuthzTrans.class;
- cArg[1] = ServletRequest.class; //Steps to test a protected method
- Method startMethod = c.getDeclaredMethod("start", cArg);
- startMethod.setAccessible(true);
- //startMethod.invoke(aTF, authzTransMock, servletRequestMock);
- }
+ @Test
+ public void testStart() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ AuthzTransOnlyFilter aTF = new AuthzTransOnlyFilter(authzEnvMock);
+ Class c = aTF.getClass();
+ Class[] cArg = new Class[2];
+ cArg[0] = AuthzTrans.class;
+ cArg[1] = ServletRequest.class; //Steps to test a protected method
+ Method startMethod = c.getDeclaredMethod("start", cArg);
+ startMethod.setAccessible(true);
+ //startMethod.invoke(aTF, authzTransMock, servletRequestMock);
+ }
- @Test
- public void testAuthenticated() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, CadiException {
- TaggedPrincipal p = mock(TaggedPrincipal.class);
- AuthzTransOnlyFilter aTF = new AuthzTransOnlyFilter(authzEnvMock);
- Class c = aTF.getClass();
- Class[] cArg = new Class[2];
- cArg[0] = AuthzTrans.class;
- cArg[1] = TaggedPrincipal.class; //Steps to test a protected method
- Method authenticatedMethod = c.getDeclaredMethod("authenticated", cArg);
- authenticatedMethod.setAccessible(true);
- authenticatedMethod.invoke(aTF,authzTransMock, null);
- }
+ @Test
+ public void testAuthenticated() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, CadiException {
+ TaggedPrincipal p = mock(TaggedPrincipal.class);
+ AuthzTransOnlyFilter aTF = new AuthzTransOnlyFilter(authzEnvMock);
+ Class c = aTF.getClass();
+ Class[] cArg = new Class[2];
+ cArg[0] = AuthzTrans.class;
+ cArg[1] = TaggedPrincipal.class; //Steps to test a protected method
+ Method authenticatedMethod = c.getDeclaredMethod("authenticated", cArg);
+ authenticatedMethod.setAccessible(true);
+ authenticatedMethod.invoke(aTF,authzTransMock, null);
+ }
- @Test
- public void testTallyHo() throws CadiException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
- AuthzTransOnlyFilter aTF = new AuthzTransOnlyFilter(authzEnvMock);
- LogTarget log = mock(LogTarget.class);
- Metric met = new Metric();
- met.total = 199.33F;
- met.entries = 15;
- met.buckets = new float[] {199.33F,99.33F};
- Class c = aTF.getClass();
- Class[] cArg = new Class[1];
- cArg[0] = AuthzTrans.class; //Steps to test a protected method
- StringBuilder sb = new StringBuilder("AuditTrail\n");
- when(authzTransMock.auditTrail(anyInt(),(StringBuilder)any(),anyInt(),anyInt())).thenReturn(met);
- when(authzTransMock.info()).thenReturn(log);
- doNothing().when(log).log((StringBuilder)any());
- Method tallyHoMethod = c.getDeclaredMethod("tallyHo", cArg);
- tallyHoMethod.setAccessible(true);
- tallyHoMethod.invoke(aTF,authzTransMock);
- }
+ @Test
+ public void testTallyHo() throws CadiException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ AuthzTransOnlyFilter aTF = new AuthzTransOnlyFilter(authzEnvMock);
+ LogTarget log = mock(LogTarget.class);
+ Metric met = new Metric();
+ met.total = 199.33F;
+ met.entries = 15;
+ met.buckets = new float[] {199.33F,99.33F};
+ Class c = aTF.getClass();
+ Class[] cArg = new Class[1];
+ cArg[0] = AuthzTrans.class; //Steps to test a protected method
+ StringBuilder sb = new StringBuilder("AuditTrail\n");
+ when(authzTransMock.auditTrail(anyInt(),(StringBuilder)any(),anyInt(),anyInt())).thenReturn(met);
+ when(authzTransMock.info()).thenReturn(log);
+ doNothing().when(log).log((StringBuilder)any());
+ Method tallyHoMethod = c.getDeclaredMethod("tallyHo", cArg);
+ tallyHoMethod.setAccessible(true);
+ tallyHoMethod.invoke(aTF,authzTransMock);
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_NullTrans.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_NullTrans.java
index e82aa163..9428bdc6 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_NullTrans.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_NullTrans.java
@@ -50,224 +50,224 @@ import java.util.Date;
@RunWith(MockitoJUnitRunner.class)
public class JU_NullTrans {
- NullTrans nullTrans;
-
- @Before
- public void setUp(){
- nullTrans = new NullTrans();
- }
-
- @Test
- public void testAuditTrail() {
- Assert.assertNull(nullTrans.auditTrail(0, null, 0));
- }
-
- @Test
- public void testSingleton() {
- AuthzTrans single = nullTrans.singleton();
- Assert.assertTrue(single instanceof AuthzTrans);
- }
-
- @Test
- public void testCheckpoints() {
- nullTrans.checkpoint("Test");
- nullTrans.checkpoint(null, 0);
- }
-
- @Test
- public void testFatal() {
- LogTarget log = nullTrans.fatal();
- Assert.assertEquals(LogTarget.NULL, log);
- }
-
- @Test
- public void testError() {
- LogTarget log = nullTrans.error();
- Assert.assertEquals(LogTarget.NULL, log);
- }
-
- @Test
- public void testAudit() {
- LogTarget log = nullTrans.audit();
- Assert.assertEquals(LogTarget.NULL, log);
- }
-
- @Test
- public void testInit() {
- LogTarget log = nullTrans.init();
- Assert.assertEquals(LogTarget.NULL, log);
- }
-
- @Test
- public void testWarn() {
- LogTarget log = nullTrans.warn();
- Assert.assertEquals(LogTarget.NULL, log);
- }
-
- @Test
- public void testInfo() {
- LogTarget log = nullTrans.info();
- Assert.assertEquals(LogTarget.NULL, log);
- }
-
- @Test
- public void testDebug() {
- LogTarget log = nullTrans.debug();
- Assert.assertEquals(LogTarget.NULL, log);
- }
+ NullTrans nullTrans;
+
+ @Before
+ public void setUp(){
+ nullTrans = new NullTrans();
+ }
+
+ @Test
+ public void testAuditTrail() {
+ Assert.assertNull(nullTrans.auditTrail(0, null, 0));
+ }
+
+ @Test
+ public void testSingleton() {
+ AuthzTrans single = nullTrans.singleton();
+ Assert.assertTrue(single instanceof AuthzTrans);
+ }
+
+ @Test
+ public void testCheckpoints() {
+ nullTrans.checkpoint("Test");
+ nullTrans.checkpoint(null, 0);
+ }
+
+ @Test
+ public void testFatal() {
+ LogTarget log = nullTrans.fatal();
+ Assert.assertEquals(LogTarget.NULL, log);
+ }
+
+ @Test
+ public void testError() {
+ LogTarget log = nullTrans.error();
+ Assert.assertEquals(LogTarget.NULL, log);
+ }
+
+ @Test
+ public void testAudit() {
+ LogTarget log = nullTrans.audit();
+ Assert.assertEquals(LogTarget.NULL, log);
+ }
+
+ @Test
+ public void testInit() {
+ LogTarget log = nullTrans.init();
+ Assert.assertEquals(LogTarget.NULL, log);
+ }
+
+ @Test
+ public void testWarn() {
+ LogTarget log = nullTrans.warn();
+ Assert.assertEquals(LogTarget.NULL, log);
+ }
+
+ @Test
+ public void testInfo() {
+ LogTarget log = nullTrans.info();
+ Assert.assertEquals(LogTarget.NULL, log);
+ }
+
+ @Test
+ public void testDebug() {
+ LogTarget log = nullTrans.debug();
+ Assert.assertEquals(LogTarget.NULL, log);
+ }
- @Test
- public void testTrace() {
- LogTarget log = nullTrans.trace();
- Assert.assertEquals(LogTarget.NULL, log);
- }
-
- @Test
- public void testStart() {
- TimeTaken test = nullTrans.start("test", 1);
- StringBuilder sb = new StringBuilder();
- test.output(sb);
- StringBuilder sb1 = new StringBuilder();
- sb1.append(test);
- String s = sb.toString();
- String s1 = sb1.toString();
- s1 = s1.trim();
- Assert.assertEquals(s,s1);
- }
-
- @Test
- public void testSetProperty() {
- String tag = "tag";
- String value = "value";
- nullTrans.setProperty(tag, value);
- String expected = nullTrans.getProperty(tag, value);
- Assert.assertEquals(expected, value);
- String expectedTag = nullTrans.getProperty(tag);
- Assert.assertEquals(expectedTag, tag);
- }
-
- @Test
- public void testDecryptor() {
- Decryptor decry = nullTrans.decryptor();
- Assert.assertNull(decry);
- }
-
- @Test
- public void testEncryptor() {
- Encryptor encry = nullTrans.encryptor();
- Assert.assertNull(encry);
- }
-
- @Test
- public void testSet() {
- HttpServletRequest req = mock(HttpServletRequest.class);
- AuthzTrans set = nullTrans.set(req);
- Assert.assertNull(set);
- }
-
- @Test
- public void testUser() {
- String user = nullTrans.user();
- Assert.assertNull(user);
- }
-
- @Test
- public void testGetUserPrincipal() {
- Principal principal = nullTrans.getUserPrincipal();
- Assert.assertNull(principal);
- }
-
- @Test
- public void testIp() {
- String ip = nullTrans.ip();
- Assert.assertNull(ip);
- }
-
- @Test
- public void testMeth() {
- String meth = nullTrans.meth();
- Assert.assertNull(meth);
- }
-
- @Test
- public void testPort() {
- int port = nullTrans.port();
- Assert.assertEquals(port,0);
- }
-
- @Test
- public void testPath() {
- String path = nullTrans.path();
- Assert.assertNull(path);
- }
-
- @Test
- public void testPut() {
- nullTrans.put(null, nullTrans);
- }
-
- @Test
- public void testSetUser() {
- Principal principal = mock(Principal.class);
- //nullTrans.setUser(principal);
- }
-
- @Test
- public void testSlot() {
- Slot slot = nullTrans.slot(null);
- Assert.assertNull(slot);
- }
-
- @Test
- public void testEnv() {
- AuthzEnv env = nullTrans.env();
- Assert.assertNull(env);
- }
-
- @Test
- public void testAgent() {
- String agent = nullTrans.agent();
- Assert.assertNull(agent);
- }
-
- @Test
- public void testSetLur() {
- nullTrans.setLur(null);
- }
-
- @Test
- public void testFish() {
- Permission perm = mock(Permission.class);
- Boolean fish = nullTrans.fish(perm);
- Assert.assertFalse(fish);
- }
-
- @Test
- public void testOrg() {
- Organization org = nullTrans.org();
- Assert.assertEquals(Organization.NULL, org);
- }
-
- @Test
- public void testLogAuditTrail() {
- LogTarget lt = mock(LogTarget.class);
- nullTrans.logAuditTrail(lt);
- }
-
- @Test
- public void testRequested() {
- Boolean reqd = nullTrans.requested(null);
- Assert.assertFalse(reqd);
- nullTrans.requested(null, true);
- }
-
- @Test
- public void testNow() {
- Date date = new Date();
- Assert.assertEquals(date,nullTrans.now());
- //when(nullTrans.now()).thenReturn(null);
- }
-
-
-
+ @Test
+ public void testTrace() {
+ LogTarget log = nullTrans.trace();
+ Assert.assertEquals(LogTarget.NULL, log);
+ }
+
+ @Test
+ public void testStart() {
+ TimeTaken test = nullTrans.start("test", 1);
+ StringBuilder sb = new StringBuilder();
+ test.output(sb);
+ StringBuilder sb1 = new StringBuilder();
+ sb1.append(test);
+ String s = sb.toString();
+ String s1 = sb1.toString();
+ s1 = s1.trim();
+ Assert.assertEquals(s,s1);
+ }
+
+ @Test
+ public void testSetProperty() {
+ String tag = "tag";
+ String value = "value";
+ nullTrans.setProperty(tag, value);
+ String expected = nullTrans.getProperty(tag, value);
+ Assert.assertEquals(expected, value);
+ String expectedTag = nullTrans.getProperty(tag);
+ Assert.assertEquals(expectedTag, tag);
+ }
+
+ @Test
+ public void testDecryptor() {
+ Decryptor decry = nullTrans.decryptor();
+ Assert.assertNull(decry);
+ }
+
+ @Test
+ public void testEncryptor() {
+ Encryptor encry = nullTrans.encryptor();
+ Assert.assertNull(encry);
+ }
+
+ @Test
+ public void testSet() {
+ HttpServletRequest req = mock(HttpServletRequest.class);
+ AuthzTrans set = nullTrans.set(req);
+ Assert.assertNull(set);
+ }
+
+ @Test
+ public void testUser() {
+ String user = nullTrans.user();
+ Assert.assertNull(user);
+ }
+
+ @Test
+ public void testGetUserPrincipal() {
+ Principal principal = nullTrans.getUserPrincipal();
+ Assert.assertNull(principal);
+ }
+
+ @Test
+ public void testIp() {
+ String ip = nullTrans.ip();
+ Assert.assertNull(ip);
+ }
+
+ @Test
+ public void testMeth() {
+ String meth = nullTrans.meth();
+ Assert.assertNull(meth);
+ }
+
+ @Test
+ public void testPort() {
+ int port = nullTrans.port();
+ Assert.assertEquals(port,0);
+ }
+
+ @Test
+ public void testPath() {
+ String path = nullTrans.path();
+ Assert.assertNull(path);
+ }
+
+ @Test
+ public void testPut() {
+ nullTrans.put(null, nullTrans);
+ }
+
+ @Test
+ public void testSetUser() {
+ Principal principal = mock(Principal.class);
+ //nullTrans.setUser(principal);
+ }
+
+ @Test
+ public void testSlot() {
+ Slot slot = nullTrans.slot(null);
+ Assert.assertNull(slot);
+ }
+
+ @Test
+ public void testEnv() {
+ AuthzEnv env = nullTrans.env();
+ Assert.assertNull(env);
+ }
+
+ @Test
+ public void testAgent() {
+ String agent = nullTrans.agent();
+ Assert.assertNull(agent);
+ }
+
+ @Test
+ public void testSetLur() {
+ nullTrans.setLur(null);
+ }
+
+ @Test
+ public void testFish() {
+ Permission perm = mock(Permission.class);
+ Boolean fish = nullTrans.fish(perm);
+ Assert.assertFalse(fish);
+ }
+
+ @Test
+ public void testOrg() {
+ Organization org = nullTrans.org();
+ Assert.assertEquals(Organization.NULL, org);
+ }
+
+ @Test
+ public void testLogAuditTrail() {
+ LogTarget lt = mock(LogTarget.class);
+ nullTrans.logAuditTrail(lt);
+ }
+
+ @Test
+ public void testRequested() {
+ Boolean reqd = nullTrans.requested(null);
+ Assert.assertFalse(reqd);
+ nullTrans.requested(null, true);
+ }
+
+ @Test
+ public void testNow() {
+ Date date = new Date();
+ Assert.assertEquals(date,nullTrans.now());
+ //when(nullTrans.now()).thenReturn(null);
+ }
+
+
+
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/layer/test/JU_Result.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/layer/test/JU_Result.java
index a172ad26..59483f46 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/layer/test/JU_Result.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/layer/test/JU_Result.java
@@ -42,150 +42,150 @@ import org.onap.aaf.auth.layer.Result;
import junit.framework.Assert;
public class JU_Result {
- Result result;
-// @Mock
-// RV value;
- int status=0;
- String details = "details";
- String[] variables;
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Before
- public void setUp(){
- //result = mock(Result.class);
-
- }
-
- @Test
- public void testOk() {
- Object value = null;
- Collection col = new ArrayList();
- List list = mock(List.class);
- Set set = mock(Set.class);
- Integer[] R = new Integer[1];
-
- Assert.assertNotNull(Result.ok());
- Assert.assertNotNull(Result.ok(value));
- Assert.assertNotNull(Result.ok(col));
- Assert.assertNotNull(Result.ok(list));
- Assert.assertNotNull(Result.ok(set));
- Assert.assertNotNull(Result.ok(R));
-
- Collection<String> col1 = new ArrayList();
- List<String> list1 = new ArrayList();
- Set<String> set1 = new HashSet<>();
- Integer[] R1 = new Integer[0];
- set1.add("derp");
- list1.add("test");
- col1.add("TEST");
-
- Assert.assertNotNull(Result.ok(col1));
- Assert.assertNotNull(Result.ok(list1));
- Assert.assertNotNull(Result.ok(set1));
- Assert.assertNotNull(Result.ok(R1));
- }
-
- @Test
- public void testErr() {
- Result result = Result.create(null, 0, null, null);
- Result r = result;
- Exception e = mock(Exception.class);
-
- Assert.assertNotNull(result.err(r)); //Result case
- Assert.assertNotNull(result.err(e)); //Exception case
- Assert.assertNotNull(result.err(0, "test", "test")); //Multiple case
-
- }
-
- @Test
- public void testCreate() {
- Result result = Result.create(null, 0, null, null);
- Assert.assertNotNull(Result.create(null, 0, null, null));
- Assert.assertNotNull(Result.create(null, 0, null, "arg"));
- Assert.assertNotNull(result.create(0, result));
- }
-
- @Test
- public void testOks() {
- Result result = Result.create(null, 0, null, null);
-
- Assert.assertNotNull(result.isOK());
- Assert.assertNotNull(result.notOK());
- Assert.assertNotNull(result.isOKhasData());
- Assert.assertNotNull(result.notOKorIsEmpty());
-
- Result result1 = Result.create(null, 5, "test", "test");
- Assert.assertNotNull(result1.emptyList(true));
- Assert.assertNotNull(result1.isOK());
- Assert.assertNotNull(result1.notOK());
- Assert.assertNotNull(result1.isOKhasData());
- Assert.assertNotNull(result1.notOKorIsEmpty());
-
- Result result2 = Result.create(null, 0, "test", "test");
- Assert.assertNotNull(result2.emptyList(false));
- Assert.assertNotNull(result2.isOKhasData());
- Assert.assertNotNull(result2.notOKorIsEmpty());
- }
-
- @Test
- public void testEmptyList() {
- Result result = Result.create(null, 0, null, null);
-
- Assert.assertNotNull(result.emptyList(true));
- Assert.assertNotNull(result.emptyList(false));
- Assert.assertFalse(result.isEmpty());
- }
-
- @Test
- public void testPartialContent() {
- Result result = Result.create(null, 0, null, null);
-
- Assert.assertNotNull(result.partialContent(true));
- Assert.assertNotNull(result.partialContent(false));
- Assert.assertFalse(result.partialContent());
-
- Result result1 = Result.create(null, 1, "test", null);
- Assert.assertNotNull(result1.partialContent(true));
- Assert.assertNotNull(result1.partialContent());
- }
-
- @Test
- public void testToString() {
- Result result = Result.create(null, 0, null, null);
-
- Assert.assertNull(result.toString() );
-
- Result result1 = Result.create(null, 5, "test", "test");
-
- Assert.assertNotNull(result1.toString());
-
- int value = 1;
- Result result2 = Result.create(value , 5, "test", "test");
-
- Assert.assertNotNull(result2.toString());
- }
-
- @Test
- public void testErrorString() {
- Result result = Result.create(null, 0, "test", "test");
- Assert.assertEquals("Error - test", result.errorString());
- Result result1 = Result.create(null, 1, "test", "test");
- Assert.assertEquals("Security - test",result1.errorString());
- Result result2 = Result.create(null, 2, "test", "test");
- Assert.assertEquals("Denied - test",result2.errorString());
- Result result3 = Result.create(null, 3, "test", "test");
- Assert.assertEquals("Policy - test",result3.errorString());
- Result result4 = Result.create(null, 4, "test", "test");
- Assert.assertEquals("BadData - test",result4.errorString());
- Result result5 = Result.create(null, 5, "test", "test");
- Assert.assertEquals("NotImplemented - test",result5.errorString());
- Result result6 = Result.create(null, 6, "test", "test");
- Assert.assertEquals("NotFound - test",result6.errorString());
- Result result7 = Result.create(null, 7, "test", "test");
- Assert.assertEquals("AlreadyExists - test",result7.errorString());
- Result result8 = Result.create(null, 8, "test", "test");
- Assert.assertEquals("ActionNotComplete - test",result8.errorString());
- }
+ Result result;
+// @Mock
+// RV value;
+ int status=0;
+ String details = "details";
+ String[] variables;
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Before
+ public void setUp(){
+ //result = mock(Result.class);
+
+ }
+
+ @Test
+ public void testOk() {
+ Object value = null;
+ Collection col = new ArrayList();
+ List list = mock(List.class);
+ Set set = mock(Set.class);
+ Integer[] R = new Integer[1];
+
+ Assert.assertNotNull(Result.ok());
+ Assert.assertNotNull(Result.ok(value));
+ Assert.assertNotNull(Result.ok(col));
+ Assert.assertNotNull(Result.ok(list));
+ Assert.assertNotNull(Result.ok(set));
+ Assert.assertNotNull(Result.ok(R));
+
+ Collection<String> col1 = new ArrayList();
+ List<String> list1 = new ArrayList();
+ Set<String> set1 = new HashSet<>();
+ Integer[] R1 = new Integer[0];
+ set1.add("derp");
+ list1.add("test");
+ col1.add("TEST");
+
+ Assert.assertNotNull(Result.ok(col1));
+ Assert.assertNotNull(Result.ok(list1));
+ Assert.assertNotNull(Result.ok(set1));
+ Assert.assertNotNull(Result.ok(R1));
+ }
+
+ @Test
+ public void testErr() {
+ Result result = Result.create(null, 0, null, null);
+ Result r = result;
+ Exception e = mock(Exception.class);
+
+ Assert.assertNotNull(result.err(r)); //Result case
+ Assert.assertNotNull(result.err(e)); //Exception case
+ Assert.assertNotNull(result.err(0, "test", "test")); //Multiple case
+
+ }
+
+ @Test
+ public void testCreate() {
+ Result result = Result.create(null, 0, null, null);
+ Assert.assertNotNull(Result.create(null, 0, null, null));
+ Assert.assertNotNull(Result.create(null, 0, null, "arg"));
+ Assert.assertNotNull(result.create(0, result));
+ }
+
+ @Test
+ public void testOks() {
+ Result result = Result.create(null, 0, null, null);
+
+ Assert.assertNotNull(result.isOK());
+ Assert.assertNotNull(result.notOK());
+ Assert.assertNotNull(result.isOKhasData());
+ Assert.assertNotNull(result.notOKorIsEmpty());
+
+ Result result1 = Result.create(null, 5, "test", "test");
+ Assert.assertNotNull(result1.emptyList(true));
+ Assert.assertNotNull(result1.isOK());
+ Assert.assertNotNull(result1.notOK());
+ Assert.assertNotNull(result1.isOKhasData());
+ Assert.assertNotNull(result1.notOKorIsEmpty());
+
+ Result result2 = Result.create(null, 0, "test", "test");
+ Assert.assertNotNull(result2.emptyList(false));
+ Assert.assertNotNull(result2.isOKhasData());
+ Assert.assertNotNull(result2.notOKorIsEmpty());
+ }
+
+ @Test
+ public void testEmptyList() {
+ Result result = Result.create(null, 0, null, null);
+
+ Assert.assertNotNull(result.emptyList(true));
+ Assert.assertNotNull(result.emptyList(false));
+ Assert.assertFalse(result.isEmpty());
+ }
+
+ @Test
+ public void testPartialContent() {
+ Result result = Result.create(null, 0, null, null);
+
+ Assert.assertNotNull(result.partialContent(true));
+ Assert.assertNotNull(result.partialContent(false));
+ Assert.assertFalse(result.partialContent());
+
+ Result result1 = Result.create(null, 1, "test", null);
+ Assert.assertNotNull(result1.partialContent(true));
+ Assert.assertNotNull(result1.partialContent());
+ }
+
+ @Test
+ public void testToString() {
+ Result result = Result.create(null, 0, null, null);
+
+ Assert.assertNull(result.toString() );
+
+ Result result1 = Result.create(null, 5, "test", "test");
+
+ Assert.assertNotNull(result1.toString());
+
+ int value = 1;
+ Result result2 = Result.create(value , 5, "test", "test");
+
+ Assert.assertNotNull(result2.toString());
+ }
+
+ @Test
+ public void testErrorString() {
+ Result result = Result.create(null, 0, "test", "test");
+ Assert.assertEquals("Error - test", result.errorString());
+ Result result1 = Result.create(null, 1, "test", "test");
+ Assert.assertEquals("Security - test",result1.errorString());
+ Result result2 = Result.create(null, 2, "test", "test");
+ Assert.assertEquals("Denied - test",result2.errorString());
+ Result result3 = Result.create(null, 3, "test", "test");
+ Assert.assertEquals("Policy - test",result3.errorString());
+ Result result4 = Result.create(null, 4, "test", "test");
+ Assert.assertEquals("BadData - test",result4.errorString());
+ Result result5 = Result.create(null, 5, "test", "test");
+ Assert.assertEquals("NotImplemented - test",result5.errorString());
+ Result result6 = Result.create(null, 6, "test", "test");
+ Assert.assertEquals("NotFound - test",result6.errorString());
+ Result result7 = Result.create(null, 7, "test", "test");
+ Assert.assertEquals("AlreadyExists - test",result7.errorString());
+ Result result8 = Result.create(null, 8, "test", "test");
+ Assert.assertEquals("ActionNotComplete - test",result8.errorString());
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_AbsData.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_AbsData.java
index dc768862..3280482c 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_AbsData.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_AbsData.java
@@ -49,68 +49,68 @@ import java.lang.reflect.Method;
import java.security.Principal;
public class JU_AbsData {
- char character = 'x';
- String filePath = "test/output_.key";
- File keyfile = new File(filePath);
- AuthzTrans trans = mock(AuthzTrans.class);
-
- private class AbsDataStub extends AbsData {
+ char character = 'x';
+ String filePath = "test/output_.key";
+ File keyfile = new File(filePath);
+ AuthzTrans trans = mock(AuthzTrans.class);
+
+ private class AbsDataStub extends AbsData {
-
- public AbsDataStub(File dataf, char sepChar, int maxLineSize, int fieldOffset) {
- super(dataf, sepChar, maxLineSize, fieldOffset);
- // TODO Auto-generated constructor stub
-
- }
-
- }
+
+ public AbsDataStub(File dataf, char sepChar, int maxLineSize, int fieldOffset) {
+ super(dataf, sepChar, maxLineSize, fieldOffset);
+ // TODO Auto-generated constructor stub
+
+ }
+
+ }
- @Test
- public void testStub() throws IOException {
- char character = 'x';
- String filePath = "test/output_.key";
- File keyfile = new File(filePath);
- FileOutputStream is = new FileOutputStream(keyfile);
+ @Test
+ public void testStub() throws IOException {
+ char character = 'x';
+ String filePath = "test/output_.key";
+ File keyfile = new File(filePath);
+ FileOutputStream is = new FileOutputStream(keyfile);
OutputStreamWriter osw = new OutputStreamWriter(is);
BufferedWriter w = new BufferedWriter(osw);
- for(int i = 0; i< 10; i++) { //Write lines to file
- w.write("a\nsdfasdfxasdf" + i + "\n");
+ for(int i = 0; i< 10; i++) { //Write lines to file
+ w.write("a\nsdfasdfxasdf" + i + "\n");
}
w.close();
- AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
- ads.skipLines(0);
- ads.name();
-
- long lng = 1823286886660L;
- //ads.open(trans, lng);
- keyfile.delete();
- }
-
- @Test
- public void testClose() throws IOException {
- AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
- ads.close(trans);
- }
-
- @Test
- public void testReuse() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
- char character = 'x';
- AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
- Reuse reuse = ads.reuse();
- reuse.reset();
- Assert.assertEquals("", reuse.at(1));
- Assert.assertNull(reuse.next());
- //reuse.atToEnd(0);
- //reuse.pos(10);
- keyfile.delete();
- }
-
- @Test
- public void testIter() throws IOException {
- AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
- TextIndex textIndex = new TextIndex(keyfile);
- //Iter iter = ads.iterator(); //Need actual input to run textIndex.create to have a datafile to read
+ AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
+ ads.skipLines(0);
+ ads.name();
+
+ long lng = 1823286886660L;
+ //ads.open(trans, lng);
+ keyfile.delete();
+ }
+
+ @Test
+ public void testClose() throws IOException {
+ AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
+ ads.close(trans);
+ }
+
+ @Test
+ public void testReuse() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ char character = 'x';
+ AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
+ Reuse reuse = ads.reuse();
+ reuse.reset();
+ Assert.assertEquals("", reuse.at(1));
+ Assert.assertNull(reuse.next());
+ //reuse.atToEnd(0);
+ //reuse.pos(10);
+ keyfile.delete();
+ }
+
+ @Test
+ public void testIter() throws IOException {
+ AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
+ TextIndex textIndex = new TextIndex(keyfile);
+ //Iter iter = ads.iterator(); //Need actual input to run textIndex.create to have a datafile to read
- }
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_DataFile.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_DataFile.java
index 559b275f..238d36d3 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_DataFile.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_DataFile.java
@@ -32,39 +32,39 @@ import org.onap.aaf.auth.local.DataFile.Token.Field;
public class JU_DataFile {
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
-// @Test
-// public void netYetTested() {
-// fail("Tests not yet implemented");
-// }
-
-// @Test
-// public void test() throws Exception {
-// File file = new File("../authz-batch/data/v1.dat");
-// DataFile df = new DataFile(file,"r");
-// int count = 0;
-// List<String> list = new ArrayList<>();
-// try {
-// df.open();
-// Token tok = df.new Token(1024000);
-// Field fld = tok.new Field('|');
-//
-// while(tok.nextLine()) {
-// ++count;
-// fld.reset();
-// list.add(fld.at(0));
-// }
-//// Collections.sort(list);
-// for(String s: list) {
-// System.out.println(s);
+// @Test
+// public void netYetTested() {
+// fail("Tests not yet implemented");
+// }
+
+// @Test
+// public void test() throws Exception {
+// File file = new File("../authz-batch/data/v1.dat");
+// DataFile df = new DataFile(file,"r");
+// int count = 0;
+// List<String> list = new ArrayList<>();
+// try {
+// df.open();
+// Token tok = df.new Token(1024000);
+// Field fld = tok.new Field('|');
+//
+// while(tok.nextLine()) {
+// ++count;
+// fld.reset();
+// list.add(fld.at(0));
+// }
+//// Collections.sort(list);
+// for(String s: list) {
+// System.out.println(s);
//
-// }
-// } finally {
-// System.out.printf("%15s:%12d\n","Total",count);
-// }
-// }
+// }
+// } finally {
+// System.out.printf("%15s:%12d\n","Total",count);
+// }
+// }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_TextIndex.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_TextIndex.java
index 1252a69d..df2d5464 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_TextIndex.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_TextIndex.java
@@ -56,88 +56,88 @@ import org.onap.aaf.misc.env.Trans;
@RunWith(MockitoJUnitRunner.class)
public class JU_TextIndex {
- TextIndex textIndex;
- Iter iter;
- Trans trans;
- DataFile datafile;
- @Mock
- File file;
-
- private class AbsDataStub extends AbsData {
+ TextIndex textIndex;
+ Iter iter;
+ Trans trans;
+ DataFile datafile;
+ @Mock
+ File file;
+
+ private class AbsDataStub extends AbsData {
-
- public AbsDataStub(File dataf, char sepChar, int maxLineSize, int fieldOffset) {
- super(dataf, sepChar, maxLineSize, fieldOffset);
- // TODO Auto-generated constructor stub
-
- }
-
- }
-
- @Before
- public void setUp() throws IOException{
- char character = 'x';
- String filePath = "test/output_key";
- File keyfile = new File(filePath);
- FileOutputStream is = new FileOutputStream(keyfile);
+
+ public AbsDataStub(File dataf, char sepChar, int maxLineSize, int fieldOffset) {
+ super(dataf, sepChar, maxLineSize, fieldOffset);
+ // TODO Auto-generated constructor stub
+
+ }
+
+ }
+
+ @Before
+ public void setUp() throws IOException{
+ char character = 'x';
+ String filePath = "test/output_key";
+ File keyfile = new File(filePath);
+ FileOutputStream is = new FileOutputStream(keyfile);
OutputStreamWriter osw = new OutputStreamWriter(is);
BufferedWriter w = new BufferedWriter(osw);
- for(int i = 0; i< 10; i++) { //Write lines to file
- w.write("a\nsdfasdfxasdf" + i + "\n");
+ for(int i = 0; i< 10; i++) { //Write lines to file
+ w.write("a\nsdfasdfxasdf" + i + "\n");
}
w.close();
- datafile = new DataFile(keyfile, "r");
- datafile.open();
- datafile = new DataFile(keyfile, "rws");// "S" for synchronized
- datafile.open();
-
- trans = mock(Trans.class);
- TimeTaken ttMock = mock(TimeTaken.class);
- TimeTaken ttMock1 = mock(TimeTaken.class);
- when(trans.start("Open Files", Env.SUB)).thenReturn(ttMock);
- when(trans.start("Read", Env.SUB)).thenReturn(ttMock);
- textIndex = new TextIndex(keyfile);
- textIndex.close();
- textIndex.open();
- //textIndex.create(trans, datafile, 4, character, 2, 0); //TODO: AAF-111 once actual input is aquired
- keyfile.delete();
-
- iter = textIndex.new Iter();
- }
-
- @Test
- public void testClose() throws IOException {
- textIndex.close();
- }
-
- @Test
- public void testFind() throws IOException {
- char character = 'x';
- String filePath = "test/output_.key";
- File keyfile = new File(filePath);
- AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
- Reuse reuse = ads.reuse();
- textIndex.find("a", reuse , 0);
- }
-
- @Test
- public void testIterNext() {
- iter.next();
- iter.hasNext();
- }
-
- @Test
- public void testIdx() throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
- TextIndex outerObject = new TextIndex(file);
+ datafile = new DataFile(keyfile, "r");
+ datafile.open();
+ datafile = new DataFile(keyfile, "rws");// "S" for synchronized
+ datafile.open();
+
+ trans = mock(Trans.class);
+ TimeTaken ttMock = mock(TimeTaken.class);
+ TimeTaken ttMock1 = mock(TimeTaken.class);
+ when(trans.start("Open Files", Env.SUB)).thenReturn(ttMock);
+ when(trans.start("Read", Env.SUB)).thenReturn(ttMock);
+ textIndex = new TextIndex(keyfile);
+ textIndex.close();
+ textIndex.open();
+ //textIndex.create(trans, datafile, 4, character, 2, 0); //TODO: AAF-111 once actual input is aquired
+ keyfile.delete();
+
+ iter = textIndex.new Iter();
+ }
+
+ @Test
+ public void testClose() throws IOException {
+ textIndex.close();
+ }
+
+ @Test
+ public void testFind() throws IOException {
+ char character = 'x';
+ String filePath = "test/output_.key";
+ File keyfile = new File(filePath);
+ AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
+ Reuse reuse = ads.reuse();
+ textIndex.find("a", reuse , 0);
+ }
+
+ @Test
+ public void testIterNext() {
+ iter.next();
+ iter.hasNext();
+ }
+
+ @Test
+ public void testIdx() throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ TextIndex outerObject = new TextIndex(file);
Class<?> idxClass = TextIndex.class.getDeclaredClasses()[0];
Constructor<?> idxConstructor = idxClass.getDeclaredConstructors()[0];
Class[] cArg = new Class[2];
- cArg[0] = Object.class;
- cArg[1] = Integer.class;
+ cArg[0] = Object.class;
+ cArg[1] = Integer.class;
idxConstructor.setAccessible(true);
//Object innerObject = idxConstructor.newInstance(outerObject,cArg);
- //idxConstructor.hashCode(); //TODO: AAF-111 access inner private class
- }
+ //idxConstructor.hashCode(); //TODO: AAF-111 access inner private class
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_Organization.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_Organization.java
index b898e885..ee95d7c4 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_Organization.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_Organization.java
@@ -43,46 +43,46 @@ import junit.framework.Assert;
public class JU_Organization {
- AuthzTrans trans;
- GregorianCalendar gc;
- @Before
- public void setUp() {
- gc = new GregorianCalendar(1900, 1, 1);
- trans = mock(AuthzTrans.class);
- }
-
- @Test
- public void test() throws OrganizationException {
- //tests for Org null
- Assert.assertEquals("n/a",Organization.NULL.getName());
- Assert.assertEquals("n/a",Organization.NULL.getDomain());
- Assert.assertEquals("n/a",Organization.NULL.getRealm());
- Assert.assertTrue(Organization.NULL.getIdentity(trans, "test") instanceof Identity);
- Assert.assertEquals("n/a",Organization.NULL.isValidID(trans, null));
- Assert.assertEquals("n/a",Organization.NULL.isValidPassword(trans, null, null, null));
- Assert.assertTrue(Organization.NULL.getIdentityTypes() instanceof HashSet);
- Assert.assertTrue(Organization.NULL.notify(trans, Notify.PasswordExpiration, null, null, null, null, null) instanceof Response);
- Assert.assertEquals(0,Organization.NULL.sendEmail(trans, null, null, null, null, null));
- Assert.assertEquals(gc.getTime(),Organization.NULL.whenToValidate(null, null));
- Assert.assertEquals(gc,Organization.NULL.expiration(gc, Expiration.Password));
- Assert.assertTrue(Organization.NULL.getApprovers(trans, null) instanceof ArrayList);
- Assert.assertEquals("",Organization.NULL.getApproverType());
- Assert.assertEquals(0,Organization.NULL.startOfDay());
- Assert.assertFalse(Organization.NULL.canHaveMultipleCreds(null));
- Assert.assertFalse(Organization.NULL.isValidCred(trans, null));
- Assert.assertEquals("Null Organization rejects all Policies",Organization.NULL.validate(trans, Policy.CHANGE_JOB, null, null));
- Assert.assertFalse(Organization.NULL.isTestEnv());
- Organization.NULL.setTestMode(true);
-
- //tests for org emailWarnings
- Assert.assertTrue(Organization.NULL.emailWarningPolicy() instanceof EmailWarnings);
- Assert.assertEquals(604800000L, Organization.NULL.emailWarningPolicy().credEmailInterval());
- Assert.assertEquals(604800000L, Organization.NULL.emailWarningPolicy().roleEmailInterval());
- Assert.assertEquals(259200000L, Organization.NULL.emailWarningPolicy().apprEmailInterval());
- Assert.assertEquals(2592000000L, Organization.NULL.emailWarningPolicy().credExpirationWarning());
- Assert.assertEquals(2592000000L, Organization.NULL.emailWarningPolicy().roleExpirationWarning());
- Assert.assertEquals(1209600000L, Organization.NULL.emailWarningPolicy().emailUrgentWarning());
- Assert.assertTrue(Organization.NULL.getPasswordRules() instanceof String[]);
+ AuthzTrans trans;
+ GregorianCalendar gc;
+ @Before
+ public void setUp() {
+ gc = new GregorianCalendar(1900, 1, 1);
+ trans = mock(AuthzTrans.class);
+ }
+
+ @Test
+ public void test() throws OrganizationException {
+ //tests for Org null
+ Assert.assertEquals("n/a",Organization.NULL.getName());
+ Assert.assertEquals("n/a",Organization.NULL.getDomain());
+ Assert.assertEquals("n/a",Organization.NULL.getRealm());
+ Assert.assertTrue(Organization.NULL.getIdentity(trans, "test") instanceof Identity);
+ Assert.assertEquals("n/a",Organization.NULL.isValidID(trans, null));
+ Assert.assertEquals("n/a",Organization.NULL.isValidPassword(trans, null, null, null));
+ Assert.assertTrue(Organization.NULL.getIdentityTypes() instanceof HashSet);
+ Assert.assertTrue(Organization.NULL.notify(trans, Notify.PasswordExpiration, null, null, null, null, null) instanceof Response);
+ Assert.assertEquals(0,Organization.NULL.sendEmail(trans, null, null, null, null, null));
+ Assert.assertEquals(gc.getTime(),Organization.NULL.whenToValidate(null, null));
+ Assert.assertEquals(gc,Organization.NULL.expiration(gc, Expiration.Password));
+ Assert.assertTrue(Organization.NULL.getApprovers(trans, null) instanceof ArrayList);
+ Assert.assertEquals("",Organization.NULL.getApproverType());
+ Assert.assertEquals(0,Organization.NULL.startOfDay());
+ Assert.assertFalse(Organization.NULL.canHaveMultipleCreds(null));
+ Assert.assertFalse(Organization.NULL.isValidCred(trans, null));
+ Assert.assertEquals("Null Organization rejects all Policies",Organization.NULL.validate(trans, Policy.CHANGE_JOB, null, null));
+ Assert.assertFalse(Organization.NULL.isTestEnv());
+ Organization.NULL.setTestMode(true);
+
+ //tests for org emailWarnings
+ Assert.assertTrue(Organization.NULL.emailWarningPolicy() instanceof EmailWarnings);
+ Assert.assertEquals(604800000L, Organization.NULL.emailWarningPolicy().credEmailInterval());
+ Assert.assertEquals(604800000L, Organization.NULL.emailWarningPolicy().roleEmailInterval());
+ Assert.assertEquals(259200000L, Organization.NULL.emailWarningPolicy().apprEmailInterval());
+ Assert.assertEquals(2592000000L, Organization.NULL.emailWarningPolicy().credExpirationWarning());
+ Assert.assertEquals(2592000000L, Organization.NULL.emailWarningPolicy().roleExpirationWarning());
+ Assert.assertEquals(1209600000L, Organization.NULL.emailWarningPolicy().emailUrgentWarning());
+ Assert.assertTrue(Organization.NULL.getPasswordRules() instanceof String[]);
- }
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_OrganizationException.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_OrganizationException.java
index 79e8a4a1..eaabfd82 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_OrganizationException.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_OrganizationException.java
@@ -32,20 +32,20 @@ import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
public class JU_OrganizationException {
- OrganizationException organizationException;
- OrganizationException organizationException1;
- OrganizationException organizationException2;
- OrganizationException organizationException3;
- OrganizationException organizationException4;
+ OrganizationException organizationException;
+ OrganizationException organizationException1;
+ OrganizationException organizationException2;
+ OrganizationException organizationException3;
+ OrganizationException organizationException4;
- @Test
- public void testOrganizationException() {
- Throwable thr = new Throwable();
- organizationException = new OrganizationException();
- organizationException1 = new OrganizationException("test");
- organizationException2 = new OrganizationException(thr);
- organizationException3 = new OrganizationException("test", thr);
- organizationException4 = new OrganizationException("test", thr, true, true);
- }
+ @Test
+ public void testOrganizationException() {
+ Throwable thr = new Throwable();
+ organizationException = new OrganizationException();
+ organizationException1 = new OrganizationException("test");
+ organizationException2 = new OrganizationException(thr);
+ organizationException3 = new OrganizationException("test", thr);
+ organizationException4 = new OrganizationException("test", thr, true, true);
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_OrganizationFactory.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_OrganizationFactory.java
index 902e94c0..87f65e92 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_OrganizationFactory.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_OrganizationFactory.java
@@ -37,35 +37,35 @@ import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
public class JU_OrganizationFactory {
- private static final String ORG_SLOT = null;
- OrganizationFactory organizationFactory;
- BasicEnv bEnv;
- @Mock
- AuthzEnv authzEnvMock;
- String orgClass="orgclass";
- String orgNS="orgns";
- @Before
- public void setUp(){
- organizationFactory = new OrganizationFactory();
- bEnv = new BasicEnv();
- }
+ private static final String ORG_SLOT = null;
+ OrganizationFactory organizationFactory;
+ BasicEnv bEnv;
+ @Mock
+ AuthzEnv authzEnvMock;
+ String orgClass="orgclass";
+ String orgNS="orgns";
+ @Before
+ public void setUp(){
+ organizationFactory = new OrganizationFactory();
+ bEnv = new BasicEnv();
+ }
- @SuppressWarnings("static-access")
- @Test
- public void testInit() throws OrganizationException {
- organizationFactory.init(bEnv);
- }
+ @SuppressWarnings("static-access")
+ @Test
+ public void testInit() throws OrganizationException {
+ organizationFactory.init(bEnv);
+ }
- @SuppressWarnings("static-access") //TODO:Fix this once real input is available AAF-111
- @Test
- public void testObtain() throws OrganizationException{
- PowerMockito.when(authzEnvMock.getProperty("Organization."+orgNS)).thenReturn("notnull");
- //organizationFactory.obtain(authzEnvMock, orgNS);
- }
+ @SuppressWarnings("static-access") //TODO:Fix this once real input is available AAF-111
+ @Test
+ public void testObtain() throws OrganizationException{
+ PowerMockito.when(authzEnvMock.getProperty("Organization."+orgNS)).thenReturn("notnull");
+ //organizationFactory.obtain(authzEnvMock, orgNS);
+ }
- @Test
- public void testGet() throws OrganizationException { //TODO: Fix with when then return on fail
- AuthzTrans trans = mock(AuthzTrans.class);
- //organizationFactory.get(trans);
- }
+ @Test
+ public void testGet() throws OrganizationException { //TODO: Fix with when then return on fail
+ AuthzTrans trans = mock(AuthzTrans.class);
+ //organizationFactory.get(trans);
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/CredCompare.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/CredCompare.java
index cac26a88..87a86d7c 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/CredCompare.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/CredCompare.java
@@ -30,35 +30,35 @@ import org.onap.aaf.misc.env.util.Chrono;
import aaf.v2_0.CredRequest;
public class CredCompare extends RosettaCompare<CredRequest> {
- public CredCompare() {
- super(CredRequest.class);
- }
-
- public static CredRequest create() {
- CredRequest rr = new CredRequest();
- String in = instance();
- rr.setId("m888"+ in + "@ns.att.com");
- rr.setPassword("Bogus0"+in);
- rr.setType(200);
- GregorianCalendar gc = new GregorianCalendar();
- rr.setStart(Chrono.timeStamp(gc));
- gc.add(GregorianCalendar.MONTH, 1);
- rr.setEnd(Chrono.timeStamp(gc));
- return rr;
- }
-
- @Override
- public void compare(CredRequest t1, CredRequest t2) {
- assertEquals(t1.getId(),t2.getId());
- assertEquals(t1.getPassword(),t2.getPassword());
- assertEquals(t1.getType(),t2.getType());
- assertEquals(t1.getStart(),t2.getStart());
- assertEquals(t1.getEnd(),t2.getEnd());
- }
+ public CredCompare() {
+ super(CredRequest.class);
+ }
+
+ public static CredRequest create() {
+ CredRequest rr = new CredRequest();
+ String in = instance();
+ rr.setId("m888"+ in + "@ns.att.com");
+ rr.setPassword("Bogus0"+in);
+ rr.setType(200);
+ GregorianCalendar gc = new GregorianCalendar();
+ rr.setStart(Chrono.timeStamp(gc));
+ gc.add(GregorianCalendar.MONTH, 1);
+ rr.setEnd(Chrono.timeStamp(gc));
+ return rr;
+ }
+
+ @Override
+ public void compare(CredRequest t1, CredRequest t2) {
+ assertEquals(t1.getId(),t2.getId());
+ assertEquals(t1.getPassword(),t2.getPassword());
+ assertEquals(t1.getType(),t2.getType());
+ assertEquals(t1.getStart(),t2.getStart());
+ assertEquals(t1.getEnd(),t2.getEnd());
+ }
- @Override
- public CredRequest newOne() {
- return create();
- }
+ @Override
+ public CredRequest newOne() {
+ return create();
+ }
} \ No newline at end of file
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/JU_RequestCheck.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/JU_RequestCheck.java
index 38bd51fc..832f5188 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/JU_RequestCheck.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/JU_RequestCheck.java
@@ -26,17 +26,17 @@ import org.onap.aaf.misc.env.APIException;
import org.onap.aaf.misc.rosetta.env.RosettaEnv;
public class JU_RequestCheck {
-
- @Test
- public void testNSRequest() throws APIException {
- RosettaEnv env = new RosettaEnv();
- new NSCompare().run(env);
- new NSAttribCompare().run(env);
- new RoleCompare().run(env);
- new PermCompare().run(env);
- new CredCompare().run(env);
- new UserRoleCompare().run(env);
- new RolePermCompare().run(env);
- new MultiCompare().run(env);
- };
+
+ @Test
+ public void testNSRequest() throws APIException {
+ RosettaEnv env = new RosettaEnv();
+ new NSCompare().run(env);
+ new NSAttribCompare().run(env);
+ new RoleCompare().run(env);
+ new PermCompare().run(env);
+ new CredCompare().run(env);
+ new UserRoleCompare().run(env);
+ new RolePermCompare().run(env);
+ new MultiCompare().run(env);
+ };
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/MultiCompare.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/MultiCompare.java
index 5450bf55..024a5237 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/MultiCompare.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/MultiCompare.java
@@ -30,40 +30,40 @@ import org.onap.aaf.misc.env.util.Chrono;
import aaf.v2_0.MultiRequest;
public class MultiCompare extends RosettaCompare<MultiRequest> {
- public MultiCompare() {
- super(MultiRequest.class);
- }
-
- @Override
- public MultiRequest newOne() {
- MultiRequest multi = new MultiRequest();
- multi.setNsRequest(NSCompare.create());
- multi.getNsAttribRequest().add(NSAttribCompare.create());
- multi.getNsAttribRequest().add(NSAttribCompare.create());
- multi.getRoleRequest().add(RoleCompare.create());
- multi.getRoleRequest().add(RoleCompare.create());
- multi.getPermRequest().add(PermCompare.create());
- multi.getPermRequest().add(PermCompare.create());
- multi.getCredRequest().add(CredCompare.create());
- multi.getCredRequest().add(CredCompare.create());
- multi.getUserRoleRequest().add(UserRoleCompare.create());
- multi.getUserRoleRequest().add(UserRoleCompare.create());
- multi.getRolePermRequest().add(RolePermCompare.create());
- multi.getRolePermRequest().add(RolePermCompare.create());
-
-
- GregorianCalendar gc = new GregorianCalendar();
- multi.setStart(Chrono.timeStamp(gc));
- gc.add(GregorianCalendar.MONTH, 1);
- multi.setEnd(Chrono.timeStamp(gc));
- return multi;
- }
-
- public void compare(MultiRequest t1, MultiRequest t2) {
- new NSCompare().compare(t1.getNsRequest(), t2.getNsRequest());
- // Will have to find by key for others.
-
- assertEquals(t1.getStart(),t2.getStart());
- assertEquals(t1.getEnd(),t2.getEnd());
- }
+ public MultiCompare() {
+ super(MultiRequest.class);
+ }
+
+ @Override
+ public MultiRequest newOne() {
+ MultiRequest multi = new MultiRequest();
+ multi.setNsRequest(NSCompare.create());
+ multi.getNsAttribRequest().add(NSAttribCompare.create());
+ multi.getNsAttribRequest().add(NSAttribCompare.create());
+ multi.getRoleRequest().add(RoleCompare.create());
+ multi.getRoleRequest().add(RoleCompare.create());
+ multi.getPermRequest().add(PermCompare.create());
+ multi.getPermRequest().add(PermCompare.create());
+ multi.getCredRequest().add(CredCompare.create());
+ multi.getCredRequest().add(CredCompare.create());
+ multi.getUserRoleRequest().add(UserRoleCompare.create());
+ multi.getUserRoleRequest().add(UserRoleCompare.create());
+ multi.getRolePermRequest().add(RolePermCompare.create());
+ multi.getRolePermRequest().add(RolePermCompare.create());
+
+
+ GregorianCalendar gc = new GregorianCalendar();
+ multi.setStart(Chrono.timeStamp(gc));
+ gc.add(GregorianCalendar.MONTH, 1);
+ multi.setEnd(Chrono.timeStamp(gc));
+ return multi;
+ }
+
+ public void compare(MultiRequest t1, MultiRequest t2) {
+ new NSCompare().compare(t1.getNsRequest(), t2.getNsRequest());
+ // Will have to find by key for others.
+
+ assertEquals(t1.getStart(),t2.getStart());
+ assertEquals(t1.getEnd(),t2.getEnd());
+ }
} \ No newline at end of file
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSAttribCompare.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSAttribCompare.java
index 9f6ce21e..acbaa9c8 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSAttribCompare.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSAttribCompare.java
@@ -32,62 +32,62 @@ import aaf.v2_0.NsAttribRequest;
import aaf.v2_0.NsAttribRequest.Attrib;
public class NSAttribCompare extends RosettaCompare<NsAttribRequest> {
- public NSAttribCompare() {
- super(NsAttribRequest.class);
- }
-
- public static NsAttribRequest create() {
- NsAttribRequest nar = new NsAttribRequest();
- String in = instance();
-
- nar.setNs("org.osaaf.ns"+in);
- Attrib attrib = new Attrib();
- attrib.setKey("swm");
- attrib.setValue("v"+instance());
- nar.getAttrib().add(attrib);
- attrib = new Attrib();
- attrib.setKey("scamp");
- attrib.setValue("v"+instance());
- nar.getAttrib().add(attrib);
- GregorianCalendar gc = new GregorianCalendar();
- nar.setStart(Chrono.timeStamp(gc));
- gc.add(GregorianCalendar.MONTH, 1);
- nar.setEnd(Chrono.timeStamp(gc));
- return nar;
- }
-
- @Override
- public void compare(NsAttribRequest t1, NsAttribRequest t2) {
- assertEquals(t1.getNs(),t2.getNs());
- for(Attrib a1 : t1.getAttrib()) {
- boolean ok = false;
- for(Attrib a2 : t2.getAttrib()) {
- if(a1.getKey().equals(a2.getKey()) &&
- a1.getValue().equals(a2.getValue())) {
- ok = true;
- break;
- }
- }
- assertTrue("a2 Attribs in a1",ok);
- }
- for(Attrib a2 : t2.getAttrib()) {
- boolean ok = false;
- for(Attrib a1 : t1.getAttrib()) {
- if(a1.getKey().equals(a2.getKey()) &&
- a1.getValue().equals(a2.getValue())) {
- ok = true;
- break;
- }
- }
- assertTrue("a2 Attribs in a1",ok);
- }
- assertEquals(t1.getStart(),t2.getStart());
- assertEquals(t1.getEnd(),t2.getEnd());
- }
+ public NSAttribCompare() {
+ super(NsAttribRequest.class);
+ }
+
+ public static NsAttribRequest create() {
+ NsAttribRequest nar = new NsAttribRequest();
+ String in = instance();
+
+ nar.setNs("org.osaaf.ns"+in);
+ Attrib attrib = new Attrib();
+ attrib.setKey("swm");
+ attrib.setValue("v"+instance());
+ nar.getAttrib().add(attrib);
+ attrib = new Attrib();
+ attrib.setKey("scamp");
+ attrib.setValue("v"+instance());
+ nar.getAttrib().add(attrib);
+ GregorianCalendar gc = new GregorianCalendar();
+ nar.setStart(Chrono.timeStamp(gc));
+ gc.add(GregorianCalendar.MONTH, 1);
+ nar.setEnd(Chrono.timeStamp(gc));
+ return nar;
+ }
+
+ @Override
+ public void compare(NsAttribRequest t1, NsAttribRequest t2) {
+ assertEquals(t1.getNs(),t2.getNs());
+ for(Attrib a1 : t1.getAttrib()) {
+ boolean ok = false;
+ for(Attrib a2 : t2.getAttrib()) {
+ if(a1.getKey().equals(a2.getKey()) &&
+ a1.getValue().equals(a2.getValue())) {
+ ok = true;
+ break;
+ }
+ }
+ assertTrue("a2 Attribs in a1",ok);
+ }
+ for(Attrib a2 : t2.getAttrib()) {
+ boolean ok = false;
+ for(Attrib a1 : t1.getAttrib()) {
+ if(a1.getKey().equals(a2.getKey()) &&
+ a1.getValue().equals(a2.getValue())) {
+ ok = true;
+ break;
+ }
+ }
+ assertTrue("a2 Attribs in a1",ok);
+ }
+ assertEquals(t1.getStart(),t2.getStart());
+ assertEquals(t1.getEnd(),t2.getEnd());
+ }
- @Override
- public NsAttribRequest newOne() {
- return create();
- }
+ @Override
+ public NsAttribRequest newOne() {
+ return create();
+ }
} \ No newline at end of file
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSCompare.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSCompare.java
index b7fc28cc..53f78b7c 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSCompare.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSCompare.java
@@ -31,45 +31,45 @@ import org.onap.aaf.misc.env.util.Chrono;
import aaf.v2_0.NsRequest;
public class NSCompare extends RosettaCompare<NsRequest> {
- public NSCompare() {
- super(NsRequest.class);
- }
-
- public static NsRequest create() {
- NsRequest nsr = new NsRequest();
- String in = instance();
- nsr.setName("org.osaaf.ns"+in);
- nsr.setDescription("Hello World"+in);
- nsr.getAdmin().add("Fred"+in);
- nsr.getAdmin().add("Barney"+in);
- nsr.getResponsible().add("Wilma"+in);
- nsr.getResponsible().add("Betty"+in);
- nsr.setType("Hello"+in);
- GregorianCalendar gc = new GregorianCalendar();
- nsr.setStart(Chrono.timeStamp(gc));
- gc.add(GregorianCalendar.MONTH, 1);
- nsr.setEnd(Chrono.timeStamp(gc));
- return nsr;
- }
-
- @Override
- public void compare(NsRequest t1, NsRequest t2) {
- assertEquals(t1.getName(),t2.getName());
- assertEquals(t1.getDescription(),t2.getDescription());
- for(String s : t1.getAdmin()) {
- assertTrue(t2.getAdmin().contains(s));
- }
- for(String s : t2.getAdmin()) {
- assertTrue(t1.getAdmin().contains(s));
- }
- assertEquals(t1.getType(),t2.getType());
- assertEquals(t1.getStart(),t2.getStart());
- assertEquals(t1.getEnd(),t2.getEnd());
- }
+ public NSCompare() {
+ super(NsRequest.class);
+ }
+
+ public static NsRequest create() {
+ NsRequest nsr = new NsRequest();
+ String in = instance();
+ nsr.setName("org.osaaf.ns"+in);
+ nsr.setDescription("Hello World"+in);
+ nsr.getAdmin().add("Fred"+in);
+ nsr.getAdmin().add("Barney"+in);
+ nsr.getResponsible().add("Wilma"+in);
+ nsr.getResponsible().add("Betty"+in);
+ nsr.setType("Hello"+in);
+ GregorianCalendar gc = new GregorianCalendar();
+ nsr.setStart(Chrono.timeStamp(gc));
+ gc.add(GregorianCalendar.MONTH, 1);
+ nsr.setEnd(Chrono.timeStamp(gc));
+ return nsr;
+ }
+
+ @Override
+ public void compare(NsRequest t1, NsRequest t2) {
+ assertEquals(t1.getName(),t2.getName());
+ assertEquals(t1.getDescription(),t2.getDescription());
+ for(String s : t1.getAdmin()) {
+ assertTrue(t2.getAdmin().contains(s));
+ }
+ for(String s : t2.getAdmin()) {
+ assertTrue(t1.getAdmin().contains(s));
+ }
+ assertEquals(t1.getType(),t2.getType());
+ assertEquals(t1.getStart(),t2.getStart());
+ assertEquals(t1.getEnd(),t2.getEnd());
+ }
- @Override
- public NsRequest newOne() {
- return create();
- }
+ @Override
+ public NsRequest newOne() {
+ return create();
+ }
} \ No newline at end of file
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/PermCompare.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/PermCompare.java
index 3d9a9fdb..92e07655 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/PermCompare.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/PermCompare.java
@@ -30,37 +30,37 @@ import org.onap.aaf.misc.env.util.Chrono;
import aaf.v2_0.PermRequest;
public class PermCompare extends RosettaCompare<PermRequest> {
- public PermCompare() {
- super(PermRequest.class);
- }
-
- public static PermRequest create() {
- PermRequest pr = new PermRequest();
- String in = instance();
- pr.setType("org.osaaf.ns.perm"+in);
- pr.setInstance("instance"+in);
- pr.setAction("read");
- pr.setDescription("Hello World, Perm"+in);
- GregorianCalendar gc = new GregorianCalendar();
- pr.setStart(Chrono.timeStamp(gc));
- gc.add(GregorianCalendar.MONTH, 1);
- pr.setEnd(Chrono.timeStamp(gc));
- return pr;
- }
-
- @Override
- public void compare(PermRequest t1, PermRequest t2) {
- assertEquals(t1.getType(),t2.getType());
- assertEquals(t1.getInstance(),t2.getInstance());
- assertEquals(t1.getAction(),t2.getAction());
- assertEquals(t1.getDescription(),t2.getDescription());
- assertEquals(t1.getStart(),t2.getStart());
- assertEquals(t1.getEnd(),t2.getEnd());
- }
+ public PermCompare() {
+ super(PermRequest.class);
+ }
+
+ public static PermRequest create() {
+ PermRequest pr = new PermRequest();
+ String in = instance();
+ pr.setType("org.osaaf.ns.perm"+in);
+ pr.setInstance("instance"+in);
+ pr.setAction("read");
+ pr.setDescription("Hello World, Perm"+in);
+ GregorianCalendar gc = new GregorianCalendar();
+ pr.setStart(Chrono.timeStamp(gc));
+ gc.add(GregorianCalendar.MONTH, 1);
+ pr.setEnd(Chrono.timeStamp(gc));
+ return pr;
+ }
+
+ @Override
+ public void compare(PermRequest t1, PermRequest t2) {
+ assertEquals(t1.getType(),t2.getType());
+ assertEquals(t1.getInstance(),t2.getInstance());
+ assertEquals(t1.getAction(),t2.getAction());
+ assertEquals(t1.getDescription(),t2.getDescription());
+ assertEquals(t1.getStart(),t2.getStart());
+ assertEquals(t1.getEnd(),t2.getEnd());
+ }
- @Override
- public PermRequest newOne() {
- return create();
- }
+ @Override
+ public PermRequest newOne() {
+ return create();
+ }
} \ No newline at end of file
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RoleCompare.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RoleCompare.java
index 35bd3370..0a3a164c 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RoleCompare.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RoleCompare.java
@@ -30,33 +30,33 @@ import org.onap.aaf.misc.env.util.Chrono;
import aaf.v2_0.RoleRequest;
public class RoleCompare extends RosettaCompare<RoleRequest> {
- public RoleCompare() {
- super(RoleRequest.class);
- }
-
- public static RoleRequest create() {
- RoleRequest rr = new RoleRequest();
- String in = instance();
- rr.setName("org.osaaf.ns.role"+in);
- rr.setDescription("Hello World, Role"+in);
- GregorianCalendar gc = new GregorianCalendar();
- rr.setStart(Chrono.timeStamp(gc));
- gc.add(GregorianCalendar.MONTH, 1);
- rr.setEnd(Chrono.timeStamp(gc));
- return rr;
- }
-
- @Override
- public void compare(RoleRequest t1, RoleRequest t2) {
- assertEquals(t1.getName(),t2.getName());
- assertEquals(t1.getDescription(),t2.getDescription());
- assertEquals(t1.getStart(),t2.getStart());
- assertEquals(t1.getEnd(),t2.getEnd());
- }
-
-
- @Override
- public RoleRequest newOne() {
- return create();
- }
+ public RoleCompare() {
+ super(RoleRequest.class);
+ }
+
+ public static RoleRequest create() {
+ RoleRequest rr = new RoleRequest();
+ String in = instance();
+ rr.setName("org.osaaf.ns.role"+in);
+ rr.setDescription("Hello World, Role"+in);
+ GregorianCalendar gc = new GregorianCalendar();
+ rr.setStart(Chrono.timeStamp(gc));
+ gc.add(GregorianCalendar.MONTH, 1);
+ rr.setEnd(Chrono.timeStamp(gc));
+ return rr;
+ }
+
+ @Override
+ public void compare(RoleRequest t1, RoleRequest t2) {
+ assertEquals(t1.getName(),t2.getName());
+ assertEquals(t1.getDescription(),t2.getDescription());
+ assertEquals(t1.getStart(),t2.getStart());
+ assertEquals(t1.getEnd(),t2.getEnd());
+ }
+
+
+ @Override
+ public RoleRequest newOne() {
+ return create();
+ }
} \ No newline at end of file
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RolePermCompare.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RolePermCompare.java
index d6ea98b9..24a84b53 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RolePermCompare.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RolePermCompare.java
@@ -31,39 +31,39 @@ import aaf.v2_0.Pkey;
import aaf.v2_0.RolePermRequest;
public class RolePermCompare extends RosettaCompare<RolePermRequest> {
- public RolePermCompare() {
- super(RolePermRequest.class);
- }
-
- public static RolePermRequest create() {
- RolePermRequest urr = new RolePermRequest();
- String in = instance();
- urr.setRole("org.osaaf.ns.role"+in);
- Pkey pkey = new Pkey();
- pkey.setType("org.osaaf.ns.myType"+in);
- pkey.setInstance("myInstance"+in);
- pkey.setAction("myAction"+in);
- urr.setPerm(pkey);
- GregorianCalendar gc = new GregorianCalendar();
- urr.setStart(Chrono.timeStamp(gc));
- gc.add(GregorianCalendar.MONTH, 1);
- urr.setEnd(Chrono.timeStamp(gc));
- return urr;
- }
-
- @Override
- public void compare(RolePermRequest t1, RolePermRequest t2) {
- assertEquals(t1.getRole(),t2.getRole());
- assertEquals(t1.getPerm().getType(),t1.getPerm().getType());
- assertEquals(t1.getPerm().getInstance(),t1.getPerm().getInstance());
- assertEquals(t1.getPerm().getAction(),t1.getPerm().getAction());
- assertEquals(t1.getStart(),t2.getStart());
- assertEquals(t1.getEnd(),t2.getEnd());
- }
+ public RolePermCompare() {
+ super(RolePermRequest.class);
+ }
+
+ public static RolePermRequest create() {
+ RolePermRequest urr = new RolePermRequest();
+ String in = instance();
+ urr.setRole("org.osaaf.ns.role"+in);
+ Pkey pkey = new Pkey();
+ pkey.setType("org.osaaf.ns.myType"+in);
+ pkey.setInstance("myInstance"+in);
+ pkey.setAction("myAction"+in);
+ urr.setPerm(pkey);
+ GregorianCalendar gc = new GregorianCalendar();
+ urr.setStart(Chrono.timeStamp(gc));
+ gc.add(GregorianCalendar.MONTH, 1);
+ urr.setEnd(Chrono.timeStamp(gc));
+ return urr;
+ }
+
+ @Override
+ public void compare(RolePermRequest t1, RolePermRequest t2) {
+ assertEquals(t1.getRole(),t2.getRole());
+ assertEquals(t1.getPerm().getType(),t1.getPerm().getType());
+ assertEquals(t1.getPerm().getInstance(),t1.getPerm().getInstance());
+ assertEquals(t1.getPerm().getAction(),t1.getPerm().getAction());
+ assertEquals(t1.getStart(),t2.getStart());
+ assertEquals(t1.getEnd(),t2.getEnd());
+ }
- @Override
- public RolePermRequest newOne() {
- return create();
- }
+ @Override
+ public RolePermRequest newOne() {
+ return create();
+ }
} \ No newline at end of file
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RosettaCompare.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RosettaCompare.java
index 8935cc9d..43703d29 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RosettaCompare.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RosettaCompare.java
@@ -29,38 +29,38 @@ import org.onap.aaf.misc.rosetta.env.RosettaData;
import org.onap.aaf.misc.rosetta.env.RosettaEnv;
public abstract class RosettaCompare<T> {
- protected Class<T> cls;
- private static int count = 0;
-
- public RosettaCompare(Class<T> cls) {
- this.cls = cls;
- }
-
- public void run(RosettaEnv env) throws APIException {
- RosettaDF<T> nsrDF = env.newDataFactory(cls);
- compare(nsrDF.newData().option(Data.PRETTY),newOne(),this);
- }
-
- private void compare(RosettaData<T> rdt, T t, RosettaCompare<T> comp) throws APIException {
- //System.out.println("########### Testing " + cls.getName() + " ##############");
- String s = rdt.load(t).out(TYPE.JSON).asString();
- //System.out.println(s);
- T t2 = rdt.in(TYPE.JSON).load(s).asObject();
- comp.compare(t, t2);
-
- //System.out.println();
-
- s = rdt.load(t).out(TYPE.XML).asString();
- //System.out.println(s);
- t2 = rdt.in(TYPE.XML).load(s).asObject();
- comp.compare(t, t2);
- }
-
- public synchronized static String instance() {
- return "_"+ ++count;
- }
-
- public abstract void compare(T t1, T t2);
- public abstract T newOne();
-
+ protected Class<T> cls;
+ private static int count = 0;
+
+ public RosettaCompare(Class<T> cls) {
+ this.cls = cls;
+ }
+
+ public void run(RosettaEnv env) throws APIException {
+ RosettaDF<T> nsrDF = env.newDataFactory(cls);
+ compare(nsrDF.newData().option(Data.PRETTY),newOne(),this);
+ }
+
+ private void compare(RosettaData<T> rdt, T t, RosettaCompare<T> comp) throws APIException {
+ //System.out.println("########### Testing " + cls.getName() + " ##############");
+ String s = rdt.load(t).out(TYPE.JSON).asString();
+ //System.out.println(s);
+ T t2 = rdt.in(TYPE.JSON).load(s).asObject();
+ comp.compare(t, t2);
+
+ //System.out.println();
+
+ s = rdt.load(t).out(TYPE.XML).asString();
+ //System.out.println(s);
+ t2 = rdt.in(TYPE.XML).load(s).asObject();
+ comp.compare(t, t2);
+ }
+
+ public synchronized static String instance() {
+ return "_"+ ++count;
+ }
+
+ public abstract void compare(T t1, T t2);
+ public abstract T newOne();
+
} \ No newline at end of file
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/UserRoleCompare.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/UserRoleCompare.java
index 542ddeb7..af61e639 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/UserRoleCompare.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/UserRoleCompare.java
@@ -30,33 +30,33 @@ import org.onap.aaf.misc.env.util.Chrono;
import aaf.v2_0.UserRoleRequest;
public class UserRoleCompare extends RosettaCompare<UserRoleRequest> {
- public UserRoleCompare() {
- super(UserRoleRequest.class);
- }
-
- public static UserRoleRequest create() {
- UserRoleRequest urr = new UserRoleRequest();
- String in = instance();
- urr.setUser("m125"+in + "@ns.att.com");
- urr.setRole("org.osaaf.ns.role"+in);
- GregorianCalendar gc = new GregorianCalendar();
- urr.setStart(Chrono.timeStamp(gc));
- gc.add(GregorianCalendar.MONTH, 1);
- urr.setEnd(Chrono.timeStamp(gc));
- return urr;
- }
-
- @Override
- public void compare(UserRoleRequest t1, UserRoleRequest t2) {
- assertEquals(t1.getUser(),t2.getUser());
- assertEquals(t1.getRole(),t2.getRole());
- assertEquals(t1.getStart(),t2.getStart());
- assertEquals(t1.getEnd(),t2.getEnd());
- }
-
-
- @Override
- public UserRoleRequest newOne() {
- return create();
- }
+ public UserRoleCompare() {
+ super(UserRoleRequest.class);
+ }
+
+ public static UserRoleRequest create() {
+ UserRoleRequest urr = new UserRoleRequest();
+ String in = instance();
+ urr.setUser("m125"+in + "@ns.att.com");
+ urr.setRole("org.osaaf.ns.role"+in);
+ GregorianCalendar gc = new GregorianCalendar();
+ urr.setStart(Chrono.timeStamp(gc));
+ gc.add(GregorianCalendar.MONTH, 1);
+ urr.setEnd(Chrono.timeStamp(gc));
+ return urr;
+ }
+
+ @Override
+ public void compare(UserRoleRequest t1, UserRoleRequest t2) {
+ assertEquals(t1.getUser(),t2.getUser());
+ assertEquals(t1.getRole(),t2.getRole());
+ assertEquals(t1.getStart(),t2.getStart());
+ assertEquals(t1.getEnd(),t2.getEnd());
+ }
+
+
+ @Override
+ public UserRoleRequest newOne() {
+ return create();
+ }
} \ No newline at end of file
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterMatch.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterMatch.java
index 7d3f057a..159c05a2 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterMatch.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterMatch.java
@@ -38,136 +38,136 @@ import org.onap.aaf.misc.env.impl.EnvFactory;
public class JU_BetterMatch {
- @Test
- public void test() {
- Trans trans = EnvFactory.newTrans();
- // Bad Match
- Match bm = new Match("/req/1.0.0/:var");
+ @Test
+ public void test() {
+ Trans trans = EnvFactory.newTrans();
+ // Bad Match
+ Match bm = new Match("/req/1.0.0/:var");
- assertTrue(bm.match("/req/1.0.0/fred"));
- assertTrue(bm.match("/req/1.0.0/wilma"));
- assertTrue(bm.match("/req/1.0.0/wilma/"));
- assertFalse(bm.match("/req/1.0.0/wilma/bambam"));
- assertFalse(bm.match("/not/valid/234"));
- assertFalse(bm.match(""));
-
- TimeTaken tt = trans.start("A", Env.SUB);
- TimeTaken tt2;
- int i = 0;
- try {
- bm = new Match(null);
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertTrue(bm.match(""));
- tt2.done();
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertTrue(bm.match(null));
- tt2.done();
- } finally {
- tt.done();
- }
-
-
- tt = trans.start("B", Env.SUB);
- i = 0;
- try {
- bm = new Match("/req/1.0.0/:urn/:ref");
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertTrue(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345"));
- tt2.done();
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertFalse(bm.match("/req/1.0.0/urn"));
- tt2.done();
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertTrue(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/"));
- tt2.done();
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/x"));
- tt2.done();
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/xyx"));
- } finally {
- tt2.done();
- tt.done();
- }
-
- tt = trans.start("C", Env.SUB);
- i = 0;
- try {
- String url = "/req/1.0.0/";
- bm = new Match(url+":urn*");
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- String value = "urn:fsdb,1.0,req,newreq/0x12345";
-
- assertTrue(bm.match(url+value));
- assertEquals("urn:fsdb,1.0,req,newreq/0x12345",bm.param(url+value, ":urn"));
- } finally {
- tt2.done();
- tt.done();
- }
+ assertTrue(bm.match("/req/1.0.0/fred"));
+ assertTrue(bm.match("/req/1.0.0/wilma"));
+ assertTrue(bm.match("/req/1.0.0/wilma/"));
+ assertFalse(bm.match("/req/1.0.0/wilma/bambam"));
+ assertFalse(bm.match("/not/valid/234"));
+ assertFalse(bm.match(""));
+
+ TimeTaken tt = trans.start("A", Env.SUB);
+ TimeTaken tt2;
+ int i = 0;
+ try {
+ bm = new Match(null);
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertTrue(bm.match(""));
+ tt2.done();
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertTrue(bm.match(null));
+ tt2.done();
+ } finally {
+ tt.done();
+ }
+
+
+ tt = trans.start("B", Env.SUB);
+ i = 0;
+ try {
+ bm = new Match("/req/1.0.0/:urn/:ref");
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertTrue(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345"));
+ tt2.done();
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertFalse(bm.match("/req/1.0.0/urn"));
+ tt2.done();
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertTrue(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/"));
+ tt2.done();
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/x"));
+ tt2.done();
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/xyx"));
+ } finally {
+ tt2.done();
+ tt.done();
+ }
+
+ tt = trans.start("C", Env.SUB);
+ i = 0;
+ try {
+ String url = "/req/1.0.0/";
+ bm = new Match(url+":urn*");
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ String value = "urn:fsdb,1.0,req,newreq/0x12345";
+
+ assertTrue(bm.match(url+value));
+ assertEquals("urn:fsdb,1.0,req,newreq/0x12345",bm.param(url+value, ":urn"));
+ } finally {
+ tt2.done();
+ tt.done();
+ }
- tt = trans.start("D", Env.SUB);
- i = 0;
- try {
- bm = new Match("/req/1.0.0/:urn/:ref*");
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertTrue(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345"));
- tt2.done();
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/"));
- } finally {
- tt2.done();
- tt.done();
- }
+ tt = trans.start("D", Env.SUB);
+ i = 0;
+ try {
+ bm = new Match("/req/1.0.0/:urn/:ref*");
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertTrue(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345"));
+ tt2.done();
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/"));
+ } finally {
+ tt2.done();
+ tt.done();
+ }
- tt = trans.start("E", Env.SUB);
- i = 0;
- try {
- bm = new Match("this*");
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertTrue(bm.match("this"));
- tt2.done();
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertTrue(bm.match("thisandthat"));
- tt2.done();
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertTrue(bm.match("this/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/"));
- } finally {
- tt2.done();
- tt.done();
- }
+ tt = trans.start("E", Env.SUB);
+ i = 0;
+ try {
+ bm = new Match("this*");
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertTrue(bm.match("this"));
+ tt2.done();
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertTrue(bm.match("thisandthat"));
+ tt2.done();
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertTrue(bm.match("this/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/"));
+ } finally {
+ tt2.done();
+ tt.done();
+ }
- tt = trans.start("F", Env.SUB);
- i = 0;
- try {
- bm = new Match("*");
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertTrue(bm.match("<pass>/this"));
- } finally {
- tt2.done();
- tt.done();
- }
-
- StringBuilder sb = new StringBuilder();
- trans.auditTrail(0, sb);
- //System.out.println(sb);
-
- }
-
- @Test
- public void specialTest() {
- Match match = new Match("/sample");
- assertTrue(match.match("/sample"));
-
- match = new Match("/lpeer//lpeer/:key/:item*");
- assertTrue(match.match("/lpeer//lpeer/x/y"));
- assertFalse(match.match("/lpeer/x/lpeer/x/y"));
+ tt = trans.start("F", Env.SUB);
+ i = 0;
+ try {
+ bm = new Match("*");
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertTrue(bm.match("<pass>/this"));
+ } finally {
+ tt2.done();
+ tt.done();
+ }
+
+ StringBuilder sb = new StringBuilder();
+ trans.auditTrail(0, sb);
+ //System.out.println(sb);
+
+ }
+
+ @Test
+ public void specialTest() {
+ Match match = new Match("/sample");
+ assertTrue(match.match("/sample"));
+
+ match = new Match("/lpeer//lpeer/:key/:item*");
+ assertTrue(match.match("/lpeer//lpeer/x/y"));
+ assertFalse(match.match("/lpeer/x/lpeer/x/y"));
- }
+ }
- @Test
- public void testGetParamNames() {
- Match bm = new Match("/req/1.0.0/:var");
- Set s = bm.getParamNames();
- Assert.assertNotNull(s);
- }
+ @Test
+ public void testGetParamNames() {
+ Match bm = new Match("/req/1.0.0/:var");
+ Set s = bm.getParamNames();
+ Assert.assertNotNull(s);
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterMatch1.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterMatch1.java
index 7fa996d3..2287889b 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterMatch1.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterMatch1.java
@@ -35,130 +35,130 @@ import org.onap.aaf.misc.env.impl.EnvFactory;
public class JU_BetterMatch1 {
- @Test
- public void test() {
- Trans trans = EnvFactory.newTrans();
- // Bad Match
- Match bm = new Match("/req/1.0.0/:var");
+ @Test
+ public void test() {
+ Trans trans = EnvFactory.newTrans();
+ // Bad Match
+ Match bm = new Match("/req/1.0.0/:var");
- assertTrue(bm.match("/req/1.0.0/fred"));
- assertTrue(bm.match("/req/1.0.0/wilma"));
- assertTrue(bm.match("/req/1.0.0/wilma/"));
- assertFalse(bm.match("/req/1.0.0/wilma/bambam"));
- assertFalse(bm.match("/not/valid/234"));
- assertFalse(bm.match(""));
-
- TimeTaken tt = trans.start("A", Env.SUB);
- TimeTaken tt2;
- int i = 0;
- try {
- bm = new Match(null);
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertTrue(bm.match(""));
- tt2.done();
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertTrue(bm.match(null));
- tt2.done();
- } finally {
- tt.done();
- }
-
-
- tt = trans.start("B", Env.SUB);
- i = 0;
- try {
- bm = new Match("/req/1.0.0/:urn/:ref");
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertTrue(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345"));
- tt2.done();
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertFalse(bm.match("/req/1.0.0/urn"));
- tt2.done();
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertTrue(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/"));
- tt2.done();
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/x"));
- tt2.done();
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/xyx"));
- } finally {
- tt2.done();
- tt.done();
- }
-
- tt = trans.start("C", Env.SUB);
- i = 0;
- try {
- String url = "/req/1.0.0/";
- bm = new Match(url+":urn*");
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- String value = "urn:fsdb,1.0,req,newreq/0x12345";
-
- assertTrue(bm.match(url+value));
- assertEquals("urn:fsdb,1.0,req,newreq/0x12345",bm.param(url+value, ":urn"));
- } finally {
- tt2.done();
- tt.done();
- }
+ assertTrue(bm.match("/req/1.0.0/fred"));
+ assertTrue(bm.match("/req/1.0.0/wilma"));
+ assertTrue(bm.match("/req/1.0.0/wilma/"));
+ assertFalse(bm.match("/req/1.0.0/wilma/bambam"));
+ assertFalse(bm.match("/not/valid/234"));
+ assertFalse(bm.match(""));
+
+ TimeTaken tt = trans.start("A", Env.SUB);
+ TimeTaken tt2;
+ int i = 0;
+ try {
+ bm = new Match(null);
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertTrue(bm.match(""));
+ tt2.done();
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertTrue(bm.match(null));
+ tt2.done();
+ } finally {
+ tt.done();
+ }
+
+
+ tt = trans.start("B", Env.SUB);
+ i = 0;
+ try {
+ bm = new Match("/req/1.0.0/:urn/:ref");
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertTrue(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345"));
+ tt2.done();
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertFalse(bm.match("/req/1.0.0/urn"));
+ tt2.done();
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertTrue(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/"));
+ tt2.done();
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/x"));
+ tt2.done();
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/xyx"));
+ } finally {
+ tt2.done();
+ tt.done();
+ }
+
+ tt = trans.start("C", Env.SUB);
+ i = 0;
+ try {
+ String url = "/req/1.0.0/";
+ bm = new Match(url+":urn*");
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ String value = "urn:fsdb,1.0,req,newreq/0x12345";
+
+ assertTrue(bm.match(url+value));
+ assertEquals("urn:fsdb,1.0,req,newreq/0x12345",bm.param(url+value, ":urn"));
+ } finally {
+ tt2.done();
+ tt.done();
+ }
- tt = trans.start("D", Env.SUB);
- i = 0;
- try {
- bm = new Match("/req/1.0.0/:urn/:ref*");
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertTrue(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345"));
- tt2.done();
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/"));
- } finally {
- tt2.done();
- tt.done();
- }
+ tt = trans.start("D", Env.SUB);
+ i = 0;
+ try {
+ bm = new Match("/req/1.0.0/:urn/:ref*");
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertTrue(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345"));
+ tt2.done();
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/"));
+ } finally {
+ tt2.done();
+ tt.done();
+ }
- tt = trans.start("E", Env.SUB);
- i = 0;
- try {
- bm = new Match("this*");
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertTrue(bm.match("this"));
- tt2.done();
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertTrue(bm.match("thisandthat"));
- tt2.done();
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertTrue(bm.match("this/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/"));
- } finally {
- tt2.done();
- tt.done();
- }
+ tt = trans.start("E", Env.SUB);
+ i = 0;
+ try {
+ bm = new Match("this*");
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertTrue(bm.match("this"));
+ tt2.done();
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertTrue(bm.match("thisandthat"));
+ tt2.done();
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertTrue(bm.match("this/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/"));
+ } finally {
+ tt2.done();
+ tt.done();
+ }
- tt = trans.start("F", Env.SUB);
- i = 0;
- try {
- bm = new Match("*");
- tt2 = trans.start(Integer.toString(++i), Env.SUB);
- assertTrue(bm.match("whatever/this"));
- } finally {
- tt2.done();
- tt.done();
- }
-
- StringBuilder sb = new StringBuilder();
- trans.auditTrail(0, sb);
- //System.out.println(sb);
-
- }
-
- @Test
- public void specialTest() {
- Match match = new Match("/sample");
- assertTrue(match.match("/sample"));
-
- match = new Match("/lpeer//lpeer/:key/:item*");
- assertTrue(match.match("/lpeer//lpeer/x/y"));
- assertFalse(match.match("/lpeer/x/lpeer/x/y"));
+ tt = trans.start("F", Env.SUB);
+ i = 0;
+ try {
+ bm = new Match("*");
+ tt2 = trans.start(Integer.toString(++i), Env.SUB);
+ assertTrue(bm.match("whatever/this"));
+ } finally {
+ tt2.done();
+ tt.done();
+ }
+
+ StringBuilder sb = new StringBuilder();
+ trans.auditTrail(0, sb);
+ //System.out.println(sb);
+
+ }
+
+ @Test
+ public void specialTest() {
+ Match match = new Match("/sample");
+ assertTrue(match.match("/sample"));
+
+ match = new Match("/lpeer//lpeer/:key/:item*");
+ assertTrue(match.match("/lpeer//lpeer/x/y"));
+ assertFalse(match.match("/lpeer/x/lpeer/x/y"));
- }
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterRoute.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterRoute.java
index d98cf5ce..2fa6b5f8 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterRoute.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterRoute.java
@@ -25,9 +25,9 @@ import org.junit.Test;
public class JU_BetterRoute {
- @Test
- public void test() {
-
- }
+ @Test
+ public void test() {
+
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_CachingFileAccess.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_CachingFileAccess.java
index 3d1f0062..207afc70 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_CachingFileAccess.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_CachingFileAccess.java
@@ -58,122 +58,122 @@ import junit.framework.Assert;
@RunWith(PowerMockRunner.class)
public class JU_CachingFileAccess {
- CachingFileAccess cachingFileAccess;
- HttpCode httpCode;
- EnvJAXB envJ;
- Trans trans;
-
-
- @Before
- public void setUp() throws IOException{
- trans = mock(Trans.class);
- HttpCode hCode = mock(HttpCode.class);
- envJ = mock(EnvJAXB.class);
- LogTarget log = mock(LogTarget.class);
- Long lng = (long) 1234134;
- when(envJ.get(envJ.staticSlot("aaf_cfa_cache_check_interval"),600000L)).thenReturn(lng);
- when(envJ.get(envJ.staticSlot("aaf_cfa_max_size"), 512000)).thenReturn(512000);
- when(envJ.get(envJ.staticSlot("aaf_cfa_web_path"))).thenReturn("TEST");
- when(envJ.getProperty("aaf_cfa_clear_command",null)).thenReturn("null");
- when(envJ.init()).thenReturn(log);
- doNothing().when(log).log((String)any());
- cachingFileAccess = new CachingFileAccess(envJ,"test");
-
-
-
- }
-
- @Test
- public void testSetEnv() {
- Store store = mock(Store.class);
- Store store1 = mock(Store.class);
- Store store2 = mock(Store.class);
- String test[] = {"aaf_cfa_web_path","aaf_cfa_cache_check_interval","aaf_cfa_max_size"};
- String test1[] = {"aaf_cfa_cache_check_interval"};
- String test2[] = {"aaf_cfa_max_size"};
- cachingFileAccess.setEnv(store, test);
- cachingFileAccess.setEnv(store1, test1); //These don't reach all the branches for some reason
- cachingFileAccess.setEnv(store2, test2);
- }
-
- @Test
- public void testHandle() throws IOException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
- HttpServletRequest req = mock(HttpServletRequest.class);
- Trans trans = mock(Trans.class);
- HttpServletResponse resp = mock(HttpServletResponse.class);
- when(req.getPathInfo()).thenReturn("path/to/file");
-
- Field matchField = HttpCode.class.getDeclaredField("match");
- matchField.setAccessible(true);
- Match match = mock(Match.class);
- when(match.param(anyString(), anyString())).thenReturn("null/");
- matchField.set(cachingFileAccess, match);
- cachingFileAccess.handle(trans, req, resp);
- when(match.param(anyString(), anyString())).thenReturn("clear");
- cachingFileAccess.handle(trans, req, resp);
- }
-
- @Test
- public void testWebPath() {
- EnvJAXB envJ = mock(EnvJAXB.class);
- String web_path_test = "TEST";
- Assert.assertEquals(web_path_test, cachingFileAccess.webPath());
- }
-
- @Test
- public void testCleanupParams() {
- NavigableMap<String,org.onap.aaf.auth.rserv.Content> content = new ConcurrentSkipListMap<>();
- cachingFileAccess.cleanupParams(50, 500); //TODO: find right input
- }
-
- @Test
- public void testLoad() throws IOException {
- cachingFileAccess.load(null, null, "1220227200L/1220227200L", null, 1320227200L );
- String filePath = "test/output_key";
- File keyfile = new File(filePath);
- RandomAccessFile randFile = new RandomAccessFile (keyfile,"rw");
-
- String dPath = "test/";
- File directoryPath = new File(dPath);
- directoryPath.mkdir();
- cachingFileAccess.load(null, dPath, "-", null, -1);
- randFile.setLength(1024 * 1024 * 8);
- cachingFileAccess.load(null, filePath, "-", null, -1);
- keyfile.delete();
- directoryPath.delete();
- String filePath1 = "test/output_key";
- File keyfile1 = new File(filePath1);
- keyfile1.createNewFile();
- cachingFileAccess.load(null, filePath1, "-", "test", -1);
- keyfile1.delete();
- }
-
- @Test
- public void testLoadOrDefault() throws IOException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, ClassNotFoundException, InstantiationException {
- String filePath = "test/output_key";
- File keyfile = new File(filePath);
- cachingFileAccess.loadOrDefault(trans, filePath, "-", null, null);
- keyfile.delete();
-
- Trans trans = mock(Trans.class);
-
- String filePath1 = "test/output_key.txt";
- //File keyfile1 = new File(filePath1);
- doAnswer(new Answer<Void>() {
- public Void answer(InvocationOnMock invocation) throws FileNotFoundException {
- throw new FileNotFoundException();
- }
- }).when(trans).info();
- //cachingFileAccess.loadOrDefault(trans, "bs", "also bs", "test", null); //TODO: Needs more testing AAF-111
- //keyfile1.delete();
- }
-
- @Test
- public void testInvalidate() {
- //NavigableMap<String,org.onap.aaf.auth.rserv.Content> content = new ConcurrentSkipListMap<>();
- //Content con = mock(Content.class);
- //content.put("hello", con);
- cachingFileAccess.invalidate("hello");
- }
+ CachingFileAccess cachingFileAccess;
+ HttpCode httpCode;
+ EnvJAXB envJ;
+ Trans trans;
+
+
+ @Before
+ public void setUp() throws IOException{
+ trans = mock(Trans.class);
+ HttpCode hCode = mock(HttpCode.class);
+ envJ = mock(EnvJAXB.class);
+ LogTarget log = mock(LogTarget.class);
+ Long lng = (long) 1234134;
+ when(envJ.get(envJ.staticSlot("aaf_cfa_cache_check_interval"),600000L)).thenReturn(lng);
+ when(envJ.get(envJ.staticSlot("aaf_cfa_max_size"), 512000)).thenReturn(512000);
+ when(envJ.get(envJ.staticSlot("aaf_cfa_web_path"))).thenReturn("TEST");
+ when(envJ.getProperty("aaf_cfa_clear_command",null)).thenReturn("null");
+ when(envJ.init()).thenReturn(log);
+ doNothing().when(log).log((String)any());
+ cachingFileAccess = new CachingFileAccess(envJ,"test");
+
+
+
+ }
+
+ @Test
+ public void testSetEnv() {
+ Store store = mock(Store.class);
+ Store store1 = mock(Store.class);
+ Store store2 = mock(Store.class);
+ String test[] = {"aaf_cfa_web_path","aaf_cfa_cache_check_interval","aaf_cfa_max_size"};
+ String test1[] = {"aaf_cfa_cache_check_interval"};
+ String test2[] = {"aaf_cfa_max_size"};
+ cachingFileAccess.setEnv(store, test);
+ cachingFileAccess.setEnv(store1, test1); //These don't reach all the branches for some reason
+ cachingFileAccess.setEnv(store2, test2);
+ }
+
+ @Test
+ public void testHandle() throws IOException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
+ HttpServletRequest req = mock(HttpServletRequest.class);
+ Trans trans = mock(Trans.class);
+ HttpServletResponse resp = mock(HttpServletResponse.class);
+ when(req.getPathInfo()).thenReturn("path/to/file");
+
+ Field matchField = HttpCode.class.getDeclaredField("match");
+ matchField.setAccessible(true);
+ Match match = mock(Match.class);
+ when(match.param(anyString(), anyString())).thenReturn("null/");
+ matchField.set(cachingFileAccess, match);
+ cachingFileAccess.handle(trans, req, resp);
+ when(match.param(anyString(), anyString())).thenReturn("clear");
+ cachingFileAccess.handle(trans, req, resp);
+ }
+
+ @Test
+ public void testWebPath() {
+ EnvJAXB envJ = mock(EnvJAXB.class);
+ String web_path_test = "TEST";
+ Assert.assertEquals(web_path_test, cachingFileAccess.webPath());
+ }
+
+ @Test
+ public void testCleanupParams() {
+ NavigableMap<String,org.onap.aaf.auth.rserv.Content> content = new ConcurrentSkipListMap<>();
+ cachingFileAccess.cleanupParams(50, 500); //TODO: find right input
+ }
+
+ @Test
+ public void testLoad() throws IOException {
+ cachingFileAccess.load(null, null, "1220227200L/1220227200L", null, 1320227200L );
+ String filePath = "test/output_key";
+ File keyfile = new File(filePath);
+ RandomAccessFile randFile = new RandomAccessFile (keyfile,"rw");
+
+ String dPath = "test/";
+ File directoryPath = new File(dPath);
+ directoryPath.mkdir();
+ cachingFileAccess.load(null, dPath, "-", null, -1);
+ randFile.setLength(1024 * 1024 * 8);
+ cachingFileAccess.load(null, filePath, "-", null, -1);
+ keyfile.delete();
+ directoryPath.delete();
+ String filePath1 = "test/output_key";
+ File keyfile1 = new File(filePath1);
+ keyfile1.createNewFile();
+ cachingFileAccess.load(null, filePath1, "-", "test", -1);
+ keyfile1.delete();
+ }
+
+ @Test
+ public void testLoadOrDefault() throws IOException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, ClassNotFoundException, InstantiationException {
+ String filePath = "test/output_key";
+ File keyfile = new File(filePath);
+ cachingFileAccess.loadOrDefault(trans, filePath, "-", null, null);
+ keyfile.delete();
+
+ Trans trans = mock(Trans.class);
+
+ String filePath1 = "test/output_key.txt";
+ //File keyfile1 = new File(filePath1);
+ doAnswer(new Answer<Void>() {
+ public Void answer(InvocationOnMock invocation) throws FileNotFoundException {
+ throw new FileNotFoundException();
+ }
+ }).when(trans).info();
+ //cachingFileAccess.loadOrDefault(trans, "bs", "also bs", "test", null); //TODO: Needs more testing AAF-111
+ //keyfile1.delete();
+ }
+
+ @Test
+ public void testInvalidate() {
+ //NavigableMap<String,org.onap.aaf.auth.rserv.Content> content = new ConcurrentSkipListMap<>();
+ //Content con = mock(Content.class);
+ //content.put("hello", con);
+ cachingFileAccess.invalidate("hello");
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Content.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Content.java
index 146473c7..65cf9bc9 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Content.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Content.java
@@ -41,621 +41,621 @@ import org.onap.aaf.misc.env.impl.EnvFactory;
* Test the functioning of the "Content" class, which holds, and routes to the right code based on Accept values
*/
public class JU_Content {
-
+
- @Test
- public void test() throws Exception {
- final String BOOL = "Boolean";
- final String XML = "XML";
- TransJAXB trans = EnvFactory.newTrans();
- try {
- HttpCode<TransJAXB, String> cBool = new HttpCode<TransJAXB,String>(BOOL,"Standard String") {
- @Override
- public void handle(TransJAXB trans, HttpServletRequest req, HttpServletResponse resp) {
- try {
- resp.getOutputStream().write(context.getBytes());
- } catch (IOException e) {
- }
- }
- };
+ @Test
+ public void test() throws Exception {
+ final String BOOL = "Boolean";
+ final String XML = "XML";
+ TransJAXB trans = EnvFactory.newTrans();
+ try {
+ HttpCode<TransJAXB, String> cBool = new HttpCode<TransJAXB,String>(BOOL,"Standard String") {
+ @Override
+ public void handle(TransJAXB trans, HttpServletRequest req, HttpServletResponse resp) {
+ try {
+ resp.getOutputStream().write(context.getBytes());
+ } catch (IOException e) {
+ }
+ }
+ };
- HttpCode<TransJAXB,String> cXML = new HttpCode<TransJAXB,String>(XML, "Standard String") {
- @Override
- public void handle(TransJAXB trans, HttpServletRequest req, HttpServletResponse resp) {
- try {
- resp.getOutputStream().write(context.getBytes());
- } catch (IOException e) {
- }
- }
- };
+ HttpCode<TransJAXB,String> cXML = new HttpCode<TransJAXB,String>(XML, "Standard String") {
+ @Override
+ public void handle(TransJAXB trans, HttpServletRequest req, HttpServletResponse resp) {
+ try {
+ resp.getOutputStream().write(context.getBytes());
+ } catch (IOException e) {
+ }
+ }
+ };
- TypedCode<TransJAXB> ct = new TypedCode<TransJAXB>()
- .add(cBool,"application/" + Boolean.class.getName()+"+xml;charset=utf8;version=1.1")
- .add(cXML,"application/xml;q=.9");
- String expected = "application/java.lang.Boolean+xml;charset=utf8;version=1.1,application/xml;q=0.9";
- assertEquals(expected,ct.toString());
+ TypedCode<TransJAXB> ct = new TypedCode<TransJAXB>()
+ .add(cBool,"application/" + Boolean.class.getName()+"+xml;charset=utf8;version=1.1")
+ .add(cXML,"application/xml;q=.9");
+ String expected = "application/java.lang.Boolean+xml;charset=utf8;version=1.1,application/xml;q=0.9";
+ assertEquals(expected,ct.toString());
- //BogusReq req = new BogusReq();
- //expected = (expected);
- //HttpServletResponse resp = new BogusResp();
-
- assertNotNull("Same Content String and Accept String",ct.prep(trans,expected));
+ //BogusReq req = new BogusReq();
+ //expected = (expected);
+ //HttpServletResponse resp = new BogusResp();
+
+ assertNotNull("Same Content String and Accept String",ct.prep(trans,expected));
- //expects Null (not run)
- // A Boolean xml that must have charset utf8 and match version 1.2 or greater
- expected = ("application/java.lang.Boolean+xml;charset=utf8;version=1.2");
- assertNull("Accept Minor Version greater than Content Minor Version",ct.prep(trans,expected));
+ //expects Null (not run)
+ // A Boolean xml that must have charset utf8 and match version 1.2 or greater
+ expected = ("application/java.lang.Boolean+xml;charset=utf8;version=1.2");
+ assertNull("Accept Minor Version greater than Content Minor Version",ct.prep(trans,expected));
- // Same with (too many) spaces
- expected = (" application/java.lang.Boolean+xml ; charset = utf8 ; version = 1.2 ");
- assertNull("Accept Minor Version greater than Content Minor Version",ct.prep(trans,expected));
+ // Same with (too many) spaces
+ expected = (" application/java.lang.Boolean+xml ; charset = utf8 ; version = 1.2 ");
+ assertNull("Accept Minor Version greater than Content Minor Version",ct.prep(trans,expected));
- //expects Null (not run)
- expected = ("application/java.lang.Boolean+xml;charset=utf8;version=2.1");
- assertNull("Major Versions not the same",ct.prep(trans,expected));
+ //expects Null (not run)
+ expected = ("application/java.lang.Boolean+xml;charset=utf8;version=2.1");
+ assertNull("Major Versions not the same",ct.prep(trans,expected));
- expected = ("application/java.lang.Boolean+xml;charset=utf8;version=1.0");
- assertNotNull("Content Minor Version is greater than Accept Minor Version",ct.prep(trans,expected));
+ expected = ("application/java.lang.Boolean+xml;charset=utf8;version=1.0");
+ assertNotNull("Content Minor Version is greater than Accept Minor Version",ct.prep(trans,expected));
- expected = "application/java.lang.Squid+xml;charset=utf8;version=1.0,application/xml;q=.9";
- assertNotNull("2nd one will have to do...",ct.prep(trans,expected));
+ expected = "application/java.lang.Squid+xml;charset=utf8;version=1.0,application/xml;q=.9";
+ assertNotNull("2nd one will have to do...",ct.prep(trans,expected));
- expected = "application/java.lang.Boolean+xml;charset=UTF8;version=1.0";
- assertNotNull("Minor Charset in Caps acceptable",ct.prep(trans,expected));
+ expected = "application/java.lang.Boolean+xml;charset=UTF8;version=1.0";
+ assertNotNull("Minor Charset in Caps acceptable",ct.prep(trans,expected));
- // expects no run
- expected="application/java.lang.Boolean+xml;charset=MyType;version=1.0";
- assertNull("Unknown Minor Charset",ct.prep(trans,expected));
+ // expects no run
+ expected="application/java.lang.Boolean+xml;charset=MyType;version=1.0";
+ assertNull("Unknown Minor Charset",ct.prep(trans,expected));
- expected="";
- assertNotNull("Blank Acceptance",ct.prep(trans,expected));
-
- expected=null;
- assertNotNull("Null Acceptance",ct.prep(trans,expected));
+ expected="";
+ assertNotNull("Blank Acceptance",ct.prep(trans,expected));
+
+ expected=null;
+ assertNotNull("Null Acceptance",ct.prep(trans,expected));
- expected = ("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
- assertNotNull("Matches application/xml, and other content not known",ct.prep(trans,expected));
-
- // No SemiColon
- expected = ("i/am/bogus,application/xml");
- assertNotNull("Match second entry, with no Semis",ct.prep(trans,expected));
+ expected = ("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
+ assertNotNull("Matches application/xml, and other content not known",ct.prep(trans,expected));
+
+ // No SemiColon
+ expected = ("i/am/bogus,application/xml");
+ assertNotNull("Match second entry, with no Semis",ct.prep(trans,expected));
- } finally {
- StringBuilder sb = new StringBuilder();
- trans.auditTrail(0, sb);
- //System.out.println(sb);
- }
- }
-//
-// Original API used HTTPServletRequest and HTTPServletResponse. Due to the fact that sometimes we use Accept, and others Content-TYpe
-// I changed it to simply accept a string
-//
-// Jonathan 3/8/2013
-//
-// @SuppressWarnings("rawtypes")
-// class BogusReq implements HttpServletRequest {
-// private String accept;
-//
-// public void accept(String accept) {
-// this.accept = accept;
-// }
-//
-// @Override
-// public Object getAttribute(String name) {
-// return accept;
-// }
-//
-//
-// @Override
-// public Enumeration getAttributeNames() {
-// return null;
-// }
-//
-// @Override
-// public String getCharacterEncoding() {
-// return null;
-// }
-//
-// @Override
-// public void setCharacterEncoding(String env)
-// throws UnsupportedEncodingException {
-//
-//
-// }
-//
-// @Override
-// public int getContentLength() {
-//
-// return 0;
-// }
-//
-// @Override
-// public String getContentType() {
-//
-// return null;
-// }
-//
-// @Override
-// public ServletInputStream getInputStream() throws IOException {
-//
-// return null;
-// }
-//
-// @Override
-// public String getParameter(String name) {
-//
-// return null;
-// }
-//
-// @Override
-// public Enumeration getParameterNames() {
-//
-// return null;
-// }
-//
-// @Override
-// public String[] getParameterValues(String name) {
-//
-// return null;
-// }
-//
-// @Override
-// public Map getParameterMap() {
-//
-// return null;
-// }
-//
-// @Override
-// public String getProtocol() {
-//
-// return null;
-// }
-//
-// @Override
-// public String getScheme() {
-//
-// return null;
-// }
-//
-// @Override
-// public String getServerName() {
-//
-// return null;
-// }
-//
-// @Override
-// public int getServerPort() {
-//
-// return 0;
-// }
-//
-// @Override
-// public BufferedReader getReader() throws IOException {
-//
-// return null;
-// }
-//
-// @Override
-// public String getRemoteAddr() {
-//
-// return null;
-// }
-//
-// @Override
-// public String getRemoteHost() {
-//
-// return null;
-// }
-//
-// @Override
-// public void setAttribute(String name, Object o) {
-//
-//
-// }
-//
-// @Override
-// public void removeAttribute(String name) {
-//
-//
-// }
-//
-// @Override
-// public Locale getLocale() {
-//
-// return null;
-// }
-//
-// @Override
-// public Enumeration getLocales() {
-//
-// return null;
-// }
-//
-// @Override
-// public boolean isSecure() {
-//
-// return false;
-// }
-//
-// @Override
-// public RequestDispatcher getRequestDispatcher(String path) {
-//
-// return null;
-// }
-//
-// @Override
-// public String getRealPath(String path) {
-//
-// return null;
-// }
-//
-// @Override
-// public int getRemotePort() {
-//
-// return 0;
-// }
-//
-// @Override
-// public String getLocalName() {
-//
-// return null;
-// }
-//
-// @Override
-// public String getLocalAddr() {
-//
-// return null;
-// }
-//
-// @Override
-// public int getLocalPort() {
-//
-// return 0;
-// }
-//
-// @Override
-// public String getAuthType() {
-//
-// return null;
-// }
-//
-// @Override
-// public Cookie[] getCookies() {
-//
-// return null;
-// }
-//
-// @Override
-// public long getDateHeader(String name) {
-//
-// return 0;
-// }
-//
-// @Override
-// public String getHeader(String name) {
-// return accept;
-// }
-//
-// @Override
-// public Enumeration getHeaders(String name) {
-//
-// return null;
-// }
-//
-// @Override
-// public Enumeration getHeaderNames() {
-//
-// return null;
-// }
-//
-// @Override
-// public int getIntHeader(String name) {
-//
-// return 0;
-// }
-//
-// @Override
-// public String getMethod() {
-//
-// return null;
-// }
-//
-// @Override
-// public String getPathInfo() {
-//
-// return null;
-// }
-//
-// @Override
-// public String getPathTranslated() {
-//
-// return null;
-// }
-//
-// @Override
-// public String getContextPath() {
-//
-// return null;
-// }
-//
-// @Override
-// public String getQueryString() {
-//
-// return null;
-// }
-//
-// @Override
-// public String getRemoteUser() {
-//
-// return null;
-// }
-//
-// @Override
-// public boolean isUserInRole(String role) {
-//
-// return false;
-// }
-//
-// @Override
-// public Principal getUserPrincipal() {
-//
-// return null;
-// }
-//
-// @Override
-// public String getRequestedSessionId() {
-//
-// return null;
-// }
-//
-// @Override
-// public String getRequestURI() {
-//
-// return null;
-// }
-//
-// @Override
-// public StringBuffer getRequestURL() {
-//
-// return null;
-// }
-//
-// @Override
-// public String getServletPath() {
-//
-// return null;
-// }
-//
-// @Override
-// public HttpSession getSession(boolean create) {
-//
-// return null;
-// }
-//
-// @Override
-// public HttpSession getSession() {
-//
-// return null;
-// }
-//
-// @Override
-// public boolean isRequestedSessionIdValid() {
-//
-// return false;
-// }
-//
-// @Override
-// public boolean isRequestedSessionIdFromCookie() {
-//
-// return false;
-// }
-//
-// @Override
-// public boolean isRequestedSessionIdFromURL() {
-//
-// return false;
-// }
-//
-// @Override
-// public boolean isRequestedSessionIdFromUrl() {
-//
-// return false;
-// }
-// }
-//
-// public class BogusResp implements HttpServletResponse {
-// public String contentType;
-//
-// @Override
-// public String getCharacterEncoding() {
-//
-// return null;
-// }
-//
-// @Override
-// public String getContentType() {
-// return contentType;
-// }
-//
-// @Override
-// public ServletOutputStream getOutputStream() throws IOException {
-//
-// return null;
-// }
-//
-// @Override
-// public PrintWriter getWriter() throws IOException {
-//
-// return null;
-// }
-//
-// @Override
-// public void setCharacterEncoding(String charset) {
-//
-//
-// }
-//
-// @Override
-// public void setContentLength(int len) {
-//
-//
-// }
-//
-// @Override
-// public void setContentType(String type) {
-// contentType = type;
-// }
-//
-// @Override
-// public void setBufferSize(int size) {
-//
-//
-// }
-//
-// @Override
-// public int getBufferSize() {
-//
-// return 0;
-// }
-//
-// @Override
-// public void flushBuffer() throws IOException {
-//
-//
-// }
-//
-// @Override
-// public void resetBuffer() {
-//
-//
-// }
-//
-// @Override
-// public boolean isCommitted() {
-//
-// return false;
-// }
-//
-// @Override
-// public void reset() {
-//
-//
-// }
-//
-// @Override
-// public void setLocale(Locale loc) {
-//
-//
-// }
-//
-// @Override
-// public Locale getLocale() {
-//
-// return null;
-// }
-//
-// @Override
-// public void addCookie(Cookie cookie) {
-//
-//
-// }
-//
-// @Override
-// public boolean containsHeader(String name) {
-//
-// return false;
-// }
-//
-// @Override
-// public String encodeURL(String url) {
-//
-// return null;
-// }
-//
-// @Override
-// public String encodeRedirectURL(String url) {
-//
-// return null;
-// }
-//
-// @Override
-// public String encodeUrl(String url) {
-//
-// return null;
-// }
-//
-// @Override
-// public String encodeRedirectUrl(String url) {
-//
-// return null;
-// }
-//
-// @Override
-// public void sendError(int sc, String msg) throws IOException {
-//
-//
-// }
-//
-// @Override
-// public void sendError(int sc) throws IOException {
-//
-//
-// }
-//
-// @Override
-// public void sendRedirect(String location) throws IOException {
-//
-//
-// }
-//
-// @Override
-// public void setDateHeader(String name, long date) {
-//
-//
-// }
-//
-// @Override
-// public void addDateHeader(String name, long date) {
-//
-//
-// }
-//
-// @Override
-// public void setHeader(String name, String value) {
-//
-//
-// }
-//
-// @Override
-// public void addHeader(String name, String value) {
-//
-//
-// }
-//
-// @Override
-// public void setIntHeader(String name, int value) {
-//
-//
-// }
-//
-// @Override
-// public void addIntHeader(String name, int value) {
-//
-//
-// }
-//
-// @Override
-// public void setStatus(int sc) {
-//
-//
-// }
-//
-// @Override
-// public void setStatus(int sc, String sm) {
-//
-//
-// }
-//
-// }
+ } finally {
+ StringBuilder sb = new StringBuilder();
+ trans.auditTrail(0, sb);
+ //System.out.println(sb);
+ }
+ }
+//
+// Original API used HTTPServletRequest and HTTPServletResponse. Due to the fact that sometimes we use Accept, and others Content-TYpe
+// I changed it to simply accept a string
+//
+// Jonathan 3/8/2013
+//
+// @SuppressWarnings("rawtypes")
+// class BogusReq implements HttpServletRequest {
+// private String accept;
+//
+// public void accept(String accept) {
+// this.accept = accept;
+// }
+//
+// @Override
+// public Object getAttribute(String name) {
+// return accept;
+// }
+//
+//
+// @Override
+// public Enumeration getAttributeNames() {
+// return null;
+// }
+//
+// @Override
+// public String getCharacterEncoding() {
+// return null;
+// }
+//
+// @Override
+// public void setCharacterEncoding(String env)
+// throws UnsupportedEncodingException {
+//
+//
+// }
+//
+// @Override
+// public int getContentLength() {
+//
+// return 0;
+// }
+//
+// @Override
+// public String getContentType() {
+//
+// return null;
+// }
+//
+// @Override
+// public ServletInputStream getInputStream() throws IOException {
+//
+// return null;
+// }
+//
+// @Override
+// public String getParameter(String name) {
+//
+// return null;
+// }
+//
+// @Override
+// public Enumeration getParameterNames() {
+//
+// return null;
+// }
+//
+// @Override
+// public String[] getParameterValues(String name) {
+//
+// return null;
+// }
+//
+// @Override
+// public Map getParameterMap() {
+//
+// return null;
+// }
+//
+// @Override
+// public String getProtocol() {
+//
+// return null;
+// }
+//
+// @Override
+// public String getScheme() {
+//
+// return null;
+// }
+//
+// @Override
+// public String getServerName() {
+//
+// return null;
+// }
+//
+// @Override
+// public int getServerPort() {
+//
+// return 0;
+// }
+//
+// @Override
+// public BufferedReader getReader() throws IOException {
+//
+// return null;
+// }
+//
+// @Override
+// public String getRemoteAddr() {
+//
+// return null;
+// }
+//
+// @Override
+// public String getRemoteHost() {
+//
+// return null;
+// }
+//
+// @Override
+// public void setAttribute(String name, Object o) {
+//
+//
+// }
+//
+// @Override
+// public void removeAttribute(String name) {
+//
+//
+// }
+//
+// @Override
+// public Locale getLocale() {
+//
+// return null;
+// }
+//
+// @Override
+// public Enumeration getLocales() {
+//
+// return null;
+// }
+//
+// @Override
+// public boolean isSecure() {
+//
+// return false;
+// }
+//
+// @Override
+// public RequestDispatcher getRequestDispatcher(String path) {
+//
+// return null;
+// }
+//
+// @Override
+// public String getRealPath(String path) {
+//
+// return null;
+// }
+//
+// @Override
+// public int getRemotePort() {
+//
+// return 0;
+// }
+//
+// @Override
+// public String getLocalName() {
+//
+// return null;
+// }
+//
+// @Override
+// public String getLocalAddr() {
+//
+// return null;
+// }
+//
+// @Override
+// public int getLocalPort() {
+//
+// return 0;
+// }
+//
+// @Override
+// public String getAuthType() {
+//
+// return null;
+// }
+//
+// @Override
+// public Cookie[] getCookies() {
+//
+// return null;
+// }
+//
+// @Override
+// public long getDateHeader(String name) {
+//
+// return 0;
+// }
+//
+// @Override
+// public String getHeader(String name) {
+// return accept;
+// }
+//
+// @Override
+// public Enumeration getHeaders(String name) {
+//
+// return null;
+// }
+//
+// @Override
+// public Enumeration getHeaderNames() {
+//
+// return null;
+// }
+//
+// @Override
+// public int getIntHeader(String name) {
+//
+// return 0;
+// }
+//
+// @Override
+// public String getMethod() {
+//
+// return null;
+// }
+//
+// @Override
+// public String getPathInfo() {
+//
+// return null;
+// }
+//
+// @Override
+// public String getPathTranslated() {
+//
+// return null;
+// }
+//
+// @Override
+// public String getContextPath() {
+//
+// return null;
+// }
+//
+// @Override
+// public String getQueryString() {
+//
+// return null;
+// }
+//
+// @Override
+// public String getRemoteUser() {
+//
+// return null;
+// }
+//
+// @Override
+// public boolean isUserInRole(String role) {
+//
+// return false;
+// }
+//
+// @Override
+// public Principal getUserPrincipal() {
+//
+// return null;
+// }
+//
+// @Override
+// public String getRequestedSessionId() {
+//
+// return null;
+// }
+//
+// @Override
+// public String getRequestURI() {
+//
+// return null;
+// }
+//
+// @Override
+// public StringBuffer getRequestURL() {
+//
+// return null;
+// }
+//
+// @Override
+// public String getServletPath() {
+//
+// return null;
+// }
+//
+// @Override
+// public HttpSession getSession(boolean create) {
+//
+// return null;
+// }
+//
+// @Override
+// public HttpSession getSession() {
+//
+// return null;
+// }
+//
+// @Override
+// public boolean isRequestedSessionIdValid() {
+//
+// return false;
+// }
+//
+// @Override
+// public boolean isRequestedSessionIdFromCookie() {
+//
+// return false;
+// }
+//
+// @Override
+// public boolean isRequestedSessionIdFromURL() {
+//
+// return false;
+// }
+//
+// @Override
+// public boolean isRequestedSessionIdFromUrl() {
+//
+// return false;
+// }
+// }
+//
+// public class BogusResp implements HttpServletResponse {
+// public String contentType;
+//
+// @Override
+// public String getCharacterEncoding() {
+//
+// return null;
+// }
+//
+// @Override
+// public String getContentType() {
+// return contentType;
+// }
+//
+// @Override
+// public ServletOutputStream getOutputStream() throws IOException {
+//
+// return null;
+// }
+//
+// @Override
+// public PrintWriter getWriter() throws IOException {
+//
+// return null;
+// }
+//
+// @Override
+// public void setCharacterEncoding(String charset) {
+//
+//
+// }
+//
+// @Override
+// public void setContentLength(int len) {
+//
+//
+// }
+//
+// @Override
+// public void setContentType(String type) {
+// contentType = type;
+// }
+//
+// @Override
+// public void setBufferSize(int size) {
+//
+//
+// }
+//
+// @Override
+// public int getBufferSize() {
+//
+// return 0;
+// }
+//
+// @Override
+// public void flushBuffer() throws IOException {
+//
+//
+// }
+//
+// @Override
+// public void resetBuffer() {
+//
+//
+// }
+//
+// @Override
+// public boolean isCommitted() {
+//
+// return false;
+// }
+//
+// @Override
+// public void reset() {
+//
+//
+// }
+//
+// @Override
+// public void setLocale(Locale loc) {
+//
+//
+// }
+//
+// @Override
+// public Locale getLocale() {
+//
+// return null;
+// }
+//
+// @Override
+// public void addCookie(Cookie cookie) {
+//
+//
+// }
+//
+// @Override
+// public boolean containsHeader(String name) {
+//
+// return false;
+// }
+//
+// @Override
+// public String encodeURL(String url) {
+//
+// return null;
+// }
+//
+// @Override
+// public String encodeRedirectURL(String url) {
+//
+// return null;
+// }
+//
+// @Override
+// public String encodeUrl(String url) {
+//
+// return null;
+// }
+//
+// @Override
+// public String encodeRedirectUrl(String url) {
+//
+// return null;
+// }
+//
+// @Override
+// public void sendError(int sc, String msg) throws IOException {
+//
+//
+// }
+//
+// @Override
+// public void sendError(int sc) throws IOException {
+//
+//
+// }
+//
+// @Override
+// public void sendRedirect(String location) throws IOException {
+//
+//
+// }
+//
+// @Override
+// public void setDateHeader(String name, long date) {
+//
+//
+// }
+//
+// @Override
+// public void addDateHeader(String name, long date) {
+//
+//
+// }
+//
+// @Override
+// public void setHeader(String name, String value) {
+//
+//
+// }
+//
+// @Override
+// public void addHeader(String name, String value) {
+//
+//
+// }
+//
+// @Override
+// public void setIntHeader(String name, int value) {
+//
+//
+// }
+//
+// @Override
+// public void addIntHeader(String name, int value) {
+//
+//
+// }
+//
+// @Override
+// public void setStatus(int sc) {
+//
+//
+// }
+//
+// @Override
+// public void setStatus(int sc, String sm) {
+//
+//
+// }
+//
+// }
//
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Content1.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Content1.java
index 18723962..0c35eaf0 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Content1.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Content1.java
@@ -41,90 +41,90 @@ import org.onap.aaf.misc.env.impl.EnvFactory;
* Test the functioning of the "Content" class, which holds, and routes to the right code based on Accept values
*/
public class JU_Content1 {
-
-
- @Test
- public void test() throws Exception {
- final String BOOL = "Boolean";
- final String XML = "XML";
- TransJAXB trans = EnvFactory.newTrans();
- try {
- HttpCode<TransJAXB, String> cBool = new HttpCode<TransJAXB,String>(BOOL,"Standard String") {
- @Override
- public void handle(TransJAXB trans, HttpServletRequest req, HttpServletResponse resp) {
- try {
- resp.getOutputStream().write(context.getBytes());
- } catch (IOException e) {
- }
- }
- };
-
- HttpCode<TransJAXB,String> cXML = new HttpCode<TransJAXB,String>(XML, "Standard String") {
- @Override
- public void handle(TransJAXB trans, HttpServletRequest req, HttpServletResponse resp) {
- try {
- resp.getOutputStream().write(context.getBytes());
- } catch (IOException e) {
- }
- }
- };
-
- TypedCode<TransJAXB> ct = new TypedCode<TransJAXB>()
- .add(cBool,"application/" + Boolean.class.getName()+"+xml;charset=utf8;version=1.1")
- .add(cXML,"application/xml;q=.9");
- String expected = "application/java.lang.Boolean+xml;charset=utf8;version=1.1,application/xml;q=0.9";
- assertEquals(expected,ct.toString());
-
- //BogusReq req = new BogusReq();
- //expected = (expected);
- //HttpServletResponse resp = new BogusResp();
-
- assertNotNull("Same Content String and Accept String",ct.prep(trans,expected));
-
- //expects Null (not run)
- // A Boolean xml that must have charset utf8 and match version 1.2 or greater
- expected = ("application/java.lang.Boolean+xml;charset=utf8;version=1.2");
- assertNull("Accept Minor Version greater than Content Minor Version",ct.prep(trans,expected));
-
- // Same with (too many) spaces
- expected = (" application/java.lang.Boolean+xml ; charset = utf8 ; version = 1.2 ");
- assertNull("Accept Minor Version greater than Content Minor Version",ct.prep(trans,expected));
-
- //expects Null (not run)
- expected = ("application/java.lang.Boolean+xml;charset=utf8;version=2.1");
- assertNull("Major Versions not the same",ct.prep(trans,expected));
-
- expected = ("application/java.lang.Boolean+xml;charset=utf8;version=1.0");
- assertNotNull("Content Minor Version is greater than Accept Minor Version",ct.prep(trans,expected));
-
- expected = "application/java.lang.Squid+xml;charset=utf8;version=1.0,application/xml;q=.9";
- assertNotNull("2nd one will have to do...",ct.prep(trans,expected));
-
- expected = "application/java.lang.Boolean+xml;charset=UTF8;version=1.0";
- assertNotNull("Minor Charset in Caps acceptable",ct.prep(trans,expected));
-
- // expects no run
- expected="application/java.lang.Boolean+xml;charset=MyType;version=1.0";
- assertNull("Unknown Minor Charset",ct.prep(trans,expected));
-
- expected="";
- assertNotNull("Blank Acceptance",ct.prep(trans,expected));
-
- expected=null;
- assertNotNull("Null Acceptance",ct.prep(trans,expected));
-
- expected = ("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
- assertNotNull("Matches application/xml, and other content not known",ct.prep(trans,expected));
-
- // No SemiColon
- expected = ("i/am/bogus,application/xml");
- assertNotNull("Match second entry, with no Semis",ct.prep(trans,expected));
-
- } finally {
- StringBuilder sb = new StringBuilder();
- trans.auditTrail(0, sb);
- //System.out.println(sb);
- }
- }
+
+
+ @Test
+ public void test() throws Exception {
+ final String BOOL = "Boolean";
+ final String XML = "XML";
+ TransJAXB trans = EnvFactory.newTrans();
+ try {
+ HttpCode<TransJAXB, String> cBool = new HttpCode<TransJAXB,String>(BOOL,"Standard String") {
+ @Override
+ public void handle(TransJAXB trans, HttpServletRequest req, HttpServletResponse resp) {
+ try {
+ resp.getOutputStream().write(context.getBytes());
+ } catch (IOException e) {
+ }
+ }
+ };
+
+ HttpCode<TransJAXB,String> cXML = new HttpCode<TransJAXB,String>(XML, "Standard String") {
+ @Override
+ public void handle(TransJAXB trans, HttpServletRequest req, HttpServletResponse resp) {
+ try {
+ resp.getOutputStream().write(context.getBytes());
+ } catch (IOException e) {
+ }
+ }
+ };
+
+ TypedCode<TransJAXB> ct = new TypedCode<TransJAXB>()
+ .add(cBool,"application/" + Boolean.class.getName()+"+xml;charset=utf8;version=1.1")
+ .add(cXML,"application/xml;q=.9");
+ String expected = "application/java.lang.Boolean+xml;charset=utf8;version=1.1,application/xml;q=0.9";
+ assertEquals(expected,ct.toString());
+
+ //BogusReq req = new BogusReq();
+ //expected = (expected);
+ //HttpServletResponse resp = new BogusResp();
+
+ assertNotNull("Same Content String and Accept String",ct.prep(trans,expected));
+
+ //expects Null (not run)
+ // A Boolean xml that must have charset utf8 and match version 1.2 or greater
+ expected = ("application/java.lang.Boolean+xml;charset=utf8;version=1.2");
+ assertNull("Accept Minor Version greater than Content Minor Version",ct.prep(trans,expected));
+
+ // Same with (too many) spaces
+ expected = (" application/java.lang.Boolean+xml ; charset = utf8 ; version = 1.2 ");
+ assertNull("Accept Minor Version greater than Content Minor Version",ct.prep(trans,expected));
+
+ //expects Null (not run)
+ expected = ("application/java.lang.Boolean+xml;charset=utf8;version=2.1");
+ assertNull("Major Versions not the same",ct.prep(trans,expected));
+
+ expected = ("application/java.lang.Boolean+xml;charset=utf8;version=1.0");
+ assertNotNull("Content Minor Version is greater than Accept Minor Version",ct.prep(trans,expected));
+
+ expected = "application/java.lang.Squid+xml;charset=utf8;version=1.0,application/xml;q=.9";
+ assertNotNull("2nd one will have to do...",ct.prep(trans,expected));
+
+ expected = "application/java.lang.Boolean+xml;charset=UTF8;version=1.0";
+ assertNotNull("Minor Charset in Caps acceptable",ct.prep(trans,expected));
+
+ // expects no run
+ expected="application/java.lang.Boolean+xml;charset=MyType;version=1.0";
+ assertNull("Unknown Minor Charset",ct.prep(trans,expected));
+
+ expected="";
+ assertNotNull("Blank Acceptance",ct.prep(trans,expected));
+
+ expected=null;
+ assertNotNull("Null Acceptance",ct.prep(trans,expected));
+
+ expected = ("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
+ assertNotNull("Matches application/xml, and other content not known",ct.prep(trans,expected));
+
+ // No SemiColon
+ expected = ("i/am/bogus,application/xml");
+ assertNotNull("Match second entry, with no Semis",ct.prep(trans,expected));
+
+ } finally {
+ StringBuilder sb = new StringBuilder();
+ trans.auditTrail(0, sb);
+ //System.out.println(sb);
+ }
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Pair.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Pair.java
index 557c7ec5..7b44fd78 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Pair.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Pair.java
@@ -30,18 +30,18 @@ import org.onap.aaf.auth.rserv.Pair;
import junit.framework.Assert;
public class JU_Pair {
- Pair<Integer, Integer> pair;
- Integer x;
- Integer y;
-
- @Before
- public void setUp(){
- pair = new Pair<Integer, Integer>(1, 2);
- }
+ Pair<Integer, Integer> pair;
+ Integer x;
+ Integer y;
+
+ @Before
+ public void setUp(){
+ pair = new Pair<Integer, Integer>(1, 2);
+ }
- @Test
- public void testToString() {
- String result = pair.toString();
- Assert.assertEquals("X: " + pair.x.toString() + "-->" + pair.y.toString(), result);
- }
+ @Test
+ public void testToString() {
+ String result = pair.toString();
+ Assert.assertEquals("X: " + pair.x.toString() + "-->" + pair.y.toString(), result);
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Route.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Route.java
index 4448a0bb..c83bf254 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Route.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Route.java
@@ -32,28 +32,28 @@ import org.onap.aaf.misc.env.Trans;
import org.onap.aaf.auth.rserv.*;
public class JU_Route {
- Route route;
- HttpCode httpCode;
- HttpMethods httpMethod;
- Trans trans;
-
- @Before
- public void setUp() { //TODO: AAF-111 complete when actual input is provided
- //httpMethod = Matchers.any(HttpMethods.class);
- //when(httpMethod.name()).thenReturn("test");
- // route = new Route(null,"path/to/place");
- }
-
-
- @Test
- public void testAdd() {
- // route.add(httpCode, "path/to/place");
- }
-
- @Test
- public void testStart() {
- // trans = mock(Trans.class);
- // route.start(trans, "test", httpCode, "test");
- }
+ Route route;
+ HttpCode httpCode;
+ HttpMethods httpMethod;
+ Trans trans;
+
+ @Before
+ public void setUp() { //TODO: AAF-111 complete when actual input is provided
+ //httpMethod = Matchers.any(HttpMethods.class);
+ //when(httpMethod.name()).thenReturn("test");
+ // route = new Route(null,"path/to/place");
+ }
+
+
+ @Test
+ public void testAdd() {
+ // route.add(httpCode, "path/to/place");
+ }
+
+ @Test
+ public void testStart() {
+ // trans = mock(Trans.class);
+ // route.start(trans, "test", httpCode, "test");
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_RouteReport.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_RouteReport.java
index a9fdff60..5c7ca8dd 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_RouteReport.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_RouteReport.java
@@ -30,11 +30,11 @@ import org.junit.Test;
public class JU_RouteReport {
- @Test
- public void test() {
- RouteReport report;
- report = new RouteReport();
- Assert.assertNotNull(report);
- }
+ @Test
+ public void test() {
+ RouteReport report;
+ report = new RouteReport();
+ Assert.assertNotNull(report);
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Routes.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Routes.java
index 2ed08841..c98922b4 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Routes.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Routes.java
@@ -42,31 +42,31 @@ import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
public class JU_Routes {
- Routes routes;
- @Mock
- HttpServletRequest reqMock;
- //TODO: Gabe [JUnit] Not visible to junit
- //CodeSetter<Trans> codeSetterMock;
- Route<Trans> routeObj;
-
- @Before
- public void setUp(){
- routes = new Routes();
- }
-
- @Test
- public void testRouteReport(){
- List listVal = routes.routeReport();
- assertNotNull(listVal);
- }
-
- @Test
- public void testDerive() throws IOException, ServletException{
- routeObj = routes.derive(reqMock, null);
-
- }
-
-
-
+ Routes routes;
+ @Mock
+ HttpServletRequest reqMock;
+ //TODO: Gabe [JUnit] Not visible to junit
+ //CodeSetter<Trans> codeSetterMock;
+ Route<Trans> routeObj;
+
+ @Before
+ public void setUp(){
+ routes = new Routes();
+ }
+
+ @Test
+ public void testRouteReport(){
+ List listVal = routes.routeReport();
+ assertNotNull(listVal);
+ }
+
+ @Test
+ public void testDerive() throws IOException, ServletException{
+ routeObj = routes.derive(reqMock, null);
+
+ }
+
+
+
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_TypedCode.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_TypedCode.java
index d5b57de0..0c117deb 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_TypedCode.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_TypedCode.java
@@ -46,61 +46,61 @@ import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
public class JU_TypedCode {
- TypedCode typedCode;
- @Mock
- RouteReport routeReportMock;
-
- @Before
- public void setUp(){
- typedCode = new TypedCode();
- }
-
- @Test
- public void testFirst(){
- String returnVal = typedCode.first();
- assertNull(returnVal);
- }
-
- @Test
- public void testAdd() {
- HttpCode<?, ?> code = mock(HttpCode.class);
- typedCode.add(code , "test", "test1", "test2");
- }
-
- @Test
- public void testPrep() throws IOException, ServletException, ClassNotFoundException {
- Trans trans = mock(Trans.class);
- TimeTaken time = new TimeTaken("yell", 2) {
- @Override
- public void output(StringBuilder sb) {
- // TODO Auto-generated method stub
- }
- };
- when(trans.start(";na=me;,prop", 8)).thenReturn(time);
- HttpCode<?, ?> code = mock(HttpCode.class);
- code.pathParam(null, null);
- code.isAuthorized(null); //Testing httpcode, currently not working
- code.no_cache();
- code.toString();
-
- typedCode.add(code , "");
- typedCode.prep(null , "q");
-
- typedCode.add(code , "t");
- typedCode.prep(trans , null);
-
- typedCode.add(code , "t");
- typedCode.prep(trans , "");
-
- typedCode.add(code, "POST /authn/validate application/CredRequest+json;charset=utf-8;version=2.0,application/json;version=2.0,*/*");
- //typedCode.prep(trans , "POST /authn/validate application/CredRequest+json;charset=utf-8;version=2.0,application/json;version=2.0,*/*");
- }
-
- @Test
- public void testRelatedTo() {
- HttpCode<?, ?> code = mock(HttpCode.class);
- StringBuilder sb = new StringBuilder();
- typedCode.relatedTo(code, sb);
- }
+ TypedCode typedCode;
+ @Mock
+ RouteReport routeReportMock;
+
+ @Before
+ public void setUp(){
+ typedCode = new TypedCode();
+ }
+
+ @Test
+ public void testFirst(){
+ String returnVal = typedCode.first();
+ assertNull(returnVal);
+ }
+
+ @Test
+ public void testAdd() {
+ HttpCode<?, ?> code = mock(HttpCode.class);
+ typedCode.add(code , "test", "test1", "test2");
+ }
+
+ @Test
+ public void testPrep() throws IOException, ServletException, ClassNotFoundException {
+ Trans trans = mock(Trans.class);
+ TimeTaken time = new TimeTaken("yell", 2) {
+ @Override
+ public void output(StringBuilder sb) {
+ // TODO Auto-generated method stub
+ }
+ };
+ when(trans.start(";na=me;,prop", 8)).thenReturn(time);
+ HttpCode<?, ?> code = mock(HttpCode.class);
+ code.pathParam(null, null);
+ code.isAuthorized(null); //Testing httpcode, currently not working
+ code.no_cache();
+ code.toString();
+
+ typedCode.add(code , "");
+ typedCode.prep(null , "q");
+
+ typedCode.add(code , "t");
+ typedCode.prep(trans , null);
+
+ typedCode.add(code , "t");
+ typedCode.prep(trans , "");
+
+ typedCode.add(code, "POST /authn/validate application/CredRequest+json;charset=utf-8;version=2.0,application/json;version=2.0,*/*");
+ //typedCode.prep(trans , "POST /authn/validate application/CredRequest+json;charset=utf-8;version=2.0,application/json;version=2.0,*/*");
+ }
+
+ @Test
+ public void testRelatedTo() {
+ HttpCode<?, ?> code = mock(HttpCode.class);
+ StringBuilder sb = new StringBuilder();
+ typedCode.relatedTo(code, sb);
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Version.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Version.java
index 617fa259..7698e220 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Version.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Version.java
@@ -34,37 +34,37 @@ import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
public class JU_Version {
- Version version;
- Version versionTest;
+ Version version;
+ Version versionTest;
-
- @Before
- public void setUp(){
- version = new Version("first\\.123");
- versionTest = new Version("first\\.124");
- }
+
+ @Before
+ public void setUp(){
+ version = new Version("first\\.123");
+ versionTest = new Version("first\\.124");
+ }
- @Test
- public void testEquals(){
- version.equals(versionTest);
- versionTest.equals(version);
- versionTest = new Version("fail\\.124");
- version.equals(versionTest);
- version.equals("This is not an object of version");
- versionTest = new Version("NoVersion\\.number");
- version.equals(versionTest);
-
-
- }
-
- @Test
- public void testToString(){
- String strVal = version.toString();
- assertNotNull(strVal);
- }
-
- @Test
- public void testHashCode() {
- Assert.assertNotNull(version.hashCode());
- }
+ @Test
+ public void testEquals(){
+ version.equals(versionTest);
+ versionTest.equals(version);
+ versionTest = new Version("fail\\.124");
+ version.equals(versionTest);
+ version.equals("This is not an object of version");
+ versionTest = new Version("NoVersion\\.number");
+ version.equals(versionTest);
+
+
+ }
+
+ @Test
+ public void testToString(){
+ String strVal = version.toString();
+ assertNotNull(strVal);
+ }
+
+ @Test
+ public void testHashCode() {
+ Assert.assertNotNull(version.hashCode());
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java
index cd73e862..3373acab 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java
@@ -62,51 +62,51 @@ import java.security.Principal;
import javax.servlet.Filter;
public class JU_AbsService {
-
- ByteArrayOutputStream outStream;
-
- private class AbsServiceStub extends AbsService {
+
+ ByteArrayOutputStream outStream;
+
+ private class AbsServiceStub extends AbsService {
- public AbsServiceStub(Access access, BasicEnv env) throws CadiException {
- super(access, env);
- // TODO Auto-generated constructor stub
- }
+ public AbsServiceStub(Access access, BasicEnv env) throws CadiException {
+ super(access, env);
+ // TODO Auto-generated constructor stub
+ }
- @Override
- public Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException {
- // TODO Auto-generated method stub
- return null;
- }
+ @Override
+ public Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException {
+ // TODO Auto-generated method stub
+ return null;
+ }
- @Override
- public Registrant[] registrants(int port) throws CadiException, LocatorException {
- // TODO Auto-generated method stub
- return null;
- }
-
- }
-
- @Before
- public void setUp() {
- outStream = new ByteArrayOutputStream();
- System.setOut(new PrintStream(outStream));
- }
-
- @After
- public void tearDown() {
- System.setOut(System.out);
- }
-
- @Test
- public void testStub() throws CadiException {
- BasicEnv bEnv = new BasicEnv();
- PropAccess prop = new PropAccess();
-
- prop.setProperty(Config.AAF_COMPONENT, "te.st:te.st");
- prop.setLogLevel(Level.DEBUG);
- AbsServiceStub absServiceStub = new AbsServiceStub(prop, bEnv); //Testing other branches requires "fails" due to exception handling, will leave that off for now.
- }
-
+ @Override
+ public Registrant[] registrants(int port) throws CadiException, LocatorException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ }
+
+ @Before
+ public void setUp() {
+ outStream = new ByteArrayOutputStream();
+ System.setOut(new PrintStream(outStream));
+ }
+
+ @After
+ public void tearDown() {
+ System.setOut(System.out);
+ }
+
+ @Test
+ public void testStub() throws CadiException {
+ BasicEnv bEnv = new BasicEnv();
+ PropAccess prop = new PropAccess();
+
+ prop.setProperty(Config.AAF_COMPONENT, "te.st:te.st");
+ prop.setLogLevel(Level.DEBUG);
+ AbsServiceStub absServiceStub = new AbsServiceStub(prop, bEnv); //Testing other branches requires "fails" due to exception handling, will leave that off for now.
+ }
+
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java
index 1a3f4417..7ba49dfa 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java
@@ -67,82 +67,82 @@ import java.security.Principal;
import javax.servlet.Filter;
public class JU_AbsServiceStarter {
-
- ByteArrayOutputStream outStream;
- AbsServiceStub absServiceStub;
- AbsServiceStarterStub absServiceStarterStub;
-
- private class AbsServiceStarterStub extends AbsServiceStarter {
-
- public AbsServiceStarterStub(AbsService service) {
- super(service);
- // TODO Auto-generated constructor stub
- }
-
- @Override
- public void _start(RServlet rserv) throws Exception {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void _propertyAdjustment() {
- // TODO Auto-generated method stub
-
- }
- }
-
- private class AbsServiceStub extends AbsService {
-
- public AbsServiceStub(Access access, BasicEnv env) throws CadiException {
- super(access, env);
- // TODO Auto-generated constructor stub
- }
-
- @Override
- public Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Registrant[] registrants(int port) throws CadiException, LocatorException {
- // TODO Auto-generated method stub
- return null;
- }
-
- }
-
- @Before
- public void setUp() {
- outStream = new ByteArrayOutputStream();
- System.setOut(new PrintStream(outStream));
- }
-
- @After
- public void tearDown() {
- System.setOut(System.out);
- }
-
-
- @Test
- public void testStub() throws CadiException {
- BasicEnv bEnv = new BasicEnv();
- PropAccess prop = new PropAccess();
-
- prop.setProperty(Config.AAF_COMPONENT, "te.st:te.st");
- prop.setLogLevel(Level.DEBUG);
- absServiceStub = new AbsServiceStub(prop, bEnv);
-
- absServiceStarterStub = new AbsServiceStarterStub(absServiceStub);
- }
-
-// @Test
-// public void testStart() throws Exception {
-// absServiceStarterStub.env();
-// absServiceStarterStub.start();
-// }
-
+
+ ByteArrayOutputStream outStream;
+ AbsServiceStub absServiceStub;
+ AbsServiceStarterStub absServiceStarterStub;
+
+ private class AbsServiceStarterStub extends AbsServiceStarter {
+
+ public AbsServiceStarterStub(AbsService service) {
+ super(service);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void _start(RServlet rserv) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void _propertyAdjustment() {
+ // TODO Auto-generated method stub
+
+ }
+ }
+
+ private class AbsServiceStub extends AbsService {
+
+ public AbsServiceStub(Access access, BasicEnv env) throws CadiException {
+ super(access, env);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Registrant[] registrants(int port) throws CadiException, LocatorException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ }
+
+ @Before
+ public void setUp() {
+ outStream = new ByteArrayOutputStream();
+ System.setOut(new PrintStream(outStream));
+ }
+
+ @After
+ public void tearDown() {
+ System.setOut(System.out);
+ }
+
+
+ @Test
+ public void testStub() throws CadiException {
+ BasicEnv bEnv = new BasicEnv();
+ PropAccess prop = new PropAccess();
+
+ prop.setProperty(Config.AAF_COMPONENT, "te.st:te.st");
+ prop.setLogLevel(Level.DEBUG);
+ absServiceStub = new AbsServiceStub(prop, bEnv);
+
+ absServiceStarterStub = new AbsServiceStarterStub(absServiceStub);
+ }
+
+// @Test
+// public void testStart() throws Exception {
+// absServiceStarterStub.env();
+// absServiceStarterStub.start();
+// }
+
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_JettyServiceStarter.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_JettyServiceStarter.java
index 13bac174..ae7fd9d7 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_JettyServiceStarter.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_JettyServiceStarter.java
@@ -49,47 +49,47 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
public class JU_JettyServiceStarter {
- private PropAccess propAccess = new PropAccess();
- private JettyServiceStarter<AuthzEnv,AuthzTrans> jss;
- class TestService extends AbsService<AuthzEnv,AuthzTrans>{
+ private PropAccess propAccess = new PropAccess();
+ private JettyServiceStarter<AuthzEnv,AuthzTrans> jss;
+ class TestService extends AbsService<AuthzEnv,AuthzTrans>{
- public TestService(Access access, AuthzEnv env) throws CadiException {
- super(access, env);
- // TODO Auto-generated constructor stub
- }
+ public TestService(Access access, AuthzEnv env) throws CadiException {
+ super(access, env);
+ // TODO Auto-generated constructor stub
+ }
- @Override
- public Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException {
- // TODO Auto-generated method stub
- return null;
- }
+ @Override
+ public Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException {
+ // TODO Auto-generated method stub
+ return null;
+ }
- @Override
- public Registrant<AuthzEnv>[] registrants(int port) throws CadiException, LocatorException {
- // TODO Auto-generated method stub
- return null;
- }
+ @Override
+ public Registrant<AuthzEnv>[] registrants(int port) throws CadiException, LocatorException {
+ // TODO Auto-generated method stub
+ return null;
+ }
- }
- @SuppressWarnings("unchecked")
- @Before
- public void setUp() throws OrganizationException, CadiException {
- Access access = mock(Access.class);
-
- BasicEnv bEnv = mock(BasicEnv.class);
- Trans trans = mock(Trans.class); //TODO: Fix this once Gabe has services running to see correct output without mock
- //TestService testService = new TestService(access, bEnv);
- //jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(testService);
- }
-
-// @Test
-// public void netYetTested() {
-// fail("Tests not yet implemented");
-// }
-
- @Test
- public void testPropertyAdjustment() {
- //jss._propertyAdjustment();
- }
+ }
+ @SuppressWarnings("unchecked")
+ @Before
+ public void setUp() throws OrganizationException, CadiException {
+ Access access = mock(Access.class);
+
+ BasicEnv bEnv = mock(BasicEnv.class);
+ Trans trans = mock(Trans.class); //TODO: Fix this once Gabe has services running to see correct output without mock
+ //TestService testService = new TestService(access, bEnv);
+ //jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(testService);
+ }
+
+// @Test
+// public void netYetTested() {
+// fail("Tests not yet implemented");
+// }
+
+ @Test
+ public void testPropertyAdjustment() {
+ //jss._propertyAdjustment();
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/JU_Mask.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/JU_Mask.java
index e276f8db..5bc1b68d 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/JU_Mask.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/JU_Mask.java
@@ -34,39 +34,39 @@ import junit.framework.Assert;
public class JU_Mask {
- @Test
- public void test() throws Exception {
-// InetAddress ia = InetAddress.getLocalHost();
- InetAddress ia = InetAddress.getByName("192.168.0.0");
- NetMask mask = new NetMask(ia.getAddress());
- assertTrue(mask.isInNet(ia.getAddress()));
-
- mask = new NetMask("192.168.1/24");
- assertTrue(mask.isInNet("192.168.1.20"));
- assertTrue(mask.isInNet("192.168.1.255"));
- assertFalse(mask.isInNet("192.168.2.20"));
-
- mask = new NetMask("192.168.1/31");
- assertFalse(mask.isInNet("192.168.2.20"));
- assertFalse(mask.isInNet("192.168.1.20"));
- assertTrue(mask.isInNet("192.168.1.1"));
- assertFalse(mask.isInNet("192.168.1.2"));
+ @Test
+ public void test() throws Exception {
+// InetAddress ia = InetAddress.getLocalHost();
+ InetAddress ia = InetAddress.getByName("192.168.0.0");
+ NetMask mask = new NetMask(ia.getAddress());
+ assertTrue(mask.isInNet(ia.getAddress()));
+
+ mask = new NetMask("192.168.1/24");
+ assertTrue(mask.isInNet("192.168.1.20"));
+ assertTrue(mask.isInNet("192.168.1.255"));
+ assertFalse(mask.isInNet("192.168.2.20"));
+
+ mask = new NetMask("192.168.1/31");
+ assertFalse(mask.isInNet("192.168.2.20"));
+ assertFalse(mask.isInNet("192.168.1.20"));
+ assertTrue(mask.isInNet("192.168.1.1"));
+ assertFalse(mask.isInNet("192.168.1.2"));
- mask = new NetMask("192/8");
- assertTrue(mask.isInNet("192.168.1.1"));
- assertTrue(mask.isInNet("192.1.1.1"));
- assertFalse(mask.isInNet("193.168.1.1"));
-
- mask = new NetMask("/0");
- assertTrue(mask.isInNet("193.168.1.1"));
-
- String msg = "Should throw " + MaskFormatException.class.getSimpleName();
- try {
- mask = new NetMask("256.256.256.256");
- Assert.assertTrue(msg,false);
- } catch (MaskFormatException e) {
- Assert.assertTrue(msg,true);
- }
- }
+ mask = new NetMask("192/8");
+ assertTrue(mask.isInNet("192.168.1.1"));
+ assertTrue(mask.isInNet("192.1.1.1"));
+ assertFalse(mask.isInNet("193.168.1.1"));
+
+ mask = new NetMask("/0");
+ assertTrue(mask.isInNet("193.168.1.1"));
+
+ String msg = "Should throw " + MaskFormatException.class.getSimpleName();
+ try {
+ mask = new NetMask("256.256.256.256");
+ Assert.assertTrue(msg,false);
+ } catch (MaskFormatException e) {
+ Assert.assertTrue(msg,true);
+ }
+ }
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/validation/test/JU_Validator.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/validation/test/JU_Validator.java
index 11aaa424..20e8f72f 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/validation/test/JU_Validator.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/validation/test/JU_Validator.java
@@ -44,280 +44,280 @@ import junit.framework.Assert;
public class JU_Validator {
- Validator validator;
- String base = "\\x25\\x28\\x29\\x2C-\\x2E\\x30-\\x39\\x3D\\x40-\\x5A\\x5F\\x61-\\x7A";
-
- @Before
- public void setUp() {
- validator = new Validator();
- }
-
- @Test
- public void testNullOrBlank() {
- validator.nullOrBlank(null, "str");
- validator.nullOrBlank("test", "");
- validator.nullOrBlank("test", null);
- }
-
- @Test
- public void testIsNull() {
- Object o = new Object();
- validator.isNull(null, null);
- validator.isNull(null, o);
- }
-
- @Test
- public void testDescription() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
- Class c = validator.getClass();
- Class[] cArg = new Class[2];
- cArg[0] = String.class;
- cArg[1] = String.class; //Steps to test a protected method
- Method descriptionMethod = c.getDeclaredMethod("description", cArg);
- descriptionMethod.setAccessible(true);
- descriptionMethod.invoke(validator,"test", "test1");
- descriptionMethod.invoke(validator,null, null);
- descriptionMethod.invoke(validator,null, "[\\\\x25\\\\x28\\\\x29\\\\x2C-\\\\x2E\\\\x30-\\\\x39\\\\x3D\\\\x40-\\\\x5A\\\\x5F\\\\x61-\\\\x7A\\\\x20]+");
-
-
- }
-
- @Test
- public void testPermType() {
- Assert.assertNotNull(validator.permType("[\\\\w.-]+"));
- Assert.assertNotNull(validator.permType(null));
- Assert.assertNotNull(validator.permType(""));
- Assert.assertNotNull(validator.permType("aewfew"));
- }
-
- @Test
- public void testPermType1() {
- Assert.assertNotNull(validator.permType("[\\\\w.-]+",null));
- Assert.assertNotNull(validator.permType(null,null));
- Assert.assertNotNull(validator.permType("","test"));
- Assert.assertNotNull(validator.permType("aewfew","test"));
- }
-
- @Test
- public void testPermInstance() {
-
- String middle = "]+[\\\\*]*|\\\\*|(([:/]\\\\*)|([:/][!]{0,1}[";
- Assert.assertNotNull(validator.permInstance("[" + base + middle + base + "]+[\\\\*]*[:/]*))+"));
- Assert.assertNotNull(validator.permInstance(null));
- Assert.assertNotNull(validator.permInstance(""));
- Assert.assertNotNull(validator.permInstance("test"));
- }
-
- @Test
- public void testErr() {
- Assert.assertFalse(validator.err());
- validator.isNull("test", null);
- Assert.assertTrue(validator.err());
- }
-
- @Test
- public void testErrs() {
- validator.isNull("test", null);
- Assert.assertNotNull(validator.errs());
- }
-
- @Test
- public void testPermAction() {
- Assert.assertNotNull(validator.permAction("[" + base + "]+" + "|\\\\*"));
- Assert.assertNotNull(validator.permAction("test"));
- }
-
- @Test
- public void testRole() {
- Assert.assertNotNull(validator.role("[\\\\w.-]+"));
- Assert.assertNotNull(validator.role(null));
- Assert.assertNotNull(validator.role(""));
- Assert.assertNotNull(validator.role("aewfew"));
- }
-
- @Test
- public void testNs() {
- Assert.assertNotNull(validator.ns("[\\\\w.-]+"));
- Assert.assertNotNull(validator.ns(""));
- Assert.assertNotNull(validator.ns(".access"));
- }
-
- @Test
- public void testKey() {
- Assert.assertNotNull(validator.key("[\\\\w.-]+"));
- Assert.assertNotNull(validator.key(""));
- Assert.assertNotNull(validator.key(".access"));
- }
-
- @Test
- public void testValue() {
- Assert.assertNotNull(validator.value(base));
- Assert.assertNotNull(validator.value(""));
- Assert.assertNotNull(validator.value(".access"));
- }
-
- @Test
- public void testNotOK() {
- Result<?> test = mock(Result.class);
- validator.isNull("test", null);
- when(test.notOK()).thenReturn(true);
- Assert.assertNotNull(validator.notOK(null));
- Assert.assertNotNull(validator.notOK(test));
- }
-
- @Test
- public void testIntRange() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
- Class c = validator.getClass();
- Class[] cArg = new Class[4];
- cArg[0] = String.class;
- cArg[1] = int.class;
- cArg[2] = int.class;
- cArg[3] = int.class; //Steps to test a protected method
- Method intRangeMethod = c.getDeclaredMethod("intRange", cArg);
- intRangeMethod.setAccessible(true);
- intRangeMethod.invoke(validator,"Test",5,1,10);
- intRangeMethod.invoke(validator,"Test",1,5,10);
- intRangeMethod.invoke(validator,"Test",11,5,10);
- intRangeMethod.invoke(validator,"Test",5,6,4);
- }
-
- @Test
- public void testFloatRange() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
- Class c = validator.getClass();
- Class[] cArg = new Class[4];
- cArg[0] = String.class;
- cArg[1] = float.class;
- cArg[2] = float.class;
- cArg[3] = float.class; //Steps to test a protected method
- Method floatRangeMethod = c.getDeclaredMethod("floatRange", cArg);
- floatRangeMethod.setAccessible(true);
- floatRangeMethod.invoke(validator,"Test",5f,1f,10f);
- floatRangeMethod.invoke(validator,"Test",1f,5f,10f);
- floatRangeMethod.invoke(validator,"Test",11f,5f,10f);
- floatRangeMethod.invoke(validator,"Test",5f,6f,4f);
- }
-
- @Test
- public void test() {
- assertTrue(Validator.ACTION_CHARS.matcher("HowdyDoody").matches());
- assertFalse(Validator.ACTION_CHARS.matcher("Howd?yDoody").matches());
- assertTrue(Validator.ACTION_CHARS.matcher("_HowdyDoody").matches());
- assertTrue(Validator.INST_CHARS.matcher("HowdyDoody").matches());
- assertFalse(Validator.INST_CHARS.matcher("Howd?yDoody").matches());
- assertTrue(Validator.INST_CHARS.matcher("_HowdyDoody").matches());
-
- //
- assertTrue(Validator.ACTION_CHARS.matcher("*").matches());
- assertTrue(Validator.INST_CHARS.matcher("*").matches());
- assertFalse(Validator.ACTION_CHARS.matcher(":*").matches());
- assertTrue(Validator.INST_CHARS.matcher(":*").matches());
- assertFalse(Validator.ACTION_CHARS.matcher(":*:*").matches());
- assertTrue(Validator.INST_CHARS.matcher(":*:*").matches());
-
- assertFalse(Validator.ACTION_CHARS.matcher(":hello").matches());
- assertTrue(Validator.INST_CHARS.matcher(":hello").matches());
- assertFalse(Validator.INST_CHARS.matcher("hello:").matches());
- assertFalse(Validator.INST_CHARS.matcher("hello:d").matches());
-
- assertFalse(Validator.ACTION_CHARS.matcher(":hello:*").matches());
- assertTrue(Validator.INST_CHARS.matcher(":hello:*").matches());
- assertFalse(Validator.ACTION_CHARS.matcher(":hello:d*:*").matches());
- assertFalse(Validator.INST_CHARS.matcher(":hello:d*d:*").matches());
- assertTrue(Validator.INST_CHARS.matcher(":hello:d*:*").matches());
- assertFalse(Validator.ACTION_CHARS.matcher("HowdyDoody*").matches());
- assertFalse(Validator.INST_CHARS.matcher("Howdy*Doody").matches());
- assertTrue(Validator.INST_CHARS.matcher("HowdyDoody*").matches());
- assertFalse(Validator.ACTION_CHARS.matcher("*HowdyDoody").matches());
- assertFalse(Validator.INST_CHARS.matcher("*HowdyDoody").matches());
- assertFalse(Validator.ACTION_CHARS.matcher(":h*").matches());
- assertFalse(Validator.INST_CHARS.matcher(":h*h*").matches());
- assertTrue(Validator.INST_CHARS.matcher(":h*").matches());
- assertFalse(Validator.ACTION_CHARS.matcher(":h:h*:*").matches());
- assertTrue(Validator.INST_CHARS.matcher(":h:h*:*").matches());
- assertFalse(Validator.INST_CHARS.matcher(":h:h*h:*").matches());
- assertFalse(Validator.INST_CHARS.matcher(":h:h*h*:*").matches());
- assertFalse(Validator.ACTION_CHARS.matcher(":h:*:*h").matches());
- assertFalse(Validator.INST_CHARS.matcher(":h:*:*h").matches());
- assertTrue(Validator.INST_CHARS.matcher(":com.test.*:ns:*").matches());
-
-
- assertFalse(Validator.ACTION_CHARS.matcher("1234+235gd").matches());
- assertTrue(Validator.ACTION_CHARS.matcher("1234-235gd").matches());
- assertTrue(Validator.ACTION_CHARS.matcher("1234-23_5gd").matches());
- assertTrue(Validator.ACTION_CHARS.matcher("1234-235g,d").matches());
- assertTrue(Validator.ACTION_CHARS.matcher("1234-235gd(Version12)").matches());
- assertFalse(Validator.ACTION_CHARS.matcher("123#4-23@5g:d").matches());
- assertFalse(Validator.ACTION_CHARS.matcher("123#4-23@5g:d").matches());
- assertFalse(Validator.ACTION_CHARS.matcher("1234-23 5gd").matches());
- assertFalse(Validator.ACTION_CHARS.matcher("1234-235gd ").matches());
- assertFalse(Validator.ACTION_CHARS.matcher(" 1234-235gd").matches());
- assertFalse(Validator.ACTION_CHARS.matcher("").matches());
- assertFalse(Validator.ACTION_CHARS.matcher(" ").matches());
-
- // Allow % and = (Needed for Escaping & Base64 usages) jg
- assertTrue(Validator.ACTION_CHARS.matcher("1234%235g=d").matches());
- assertFalse(Validator.ACTION_CHARS.matcher(":1234%235g=d").matches());
- assertTrue(Validator.INST_CHARS.matcher("1234%235g=d").matches());
- assertTrue(Validator.INST_CHARS.matcher(":1234%235g=d").matches());
- assertTrue(Validator.INST_CHARS.matcher(":1234%235g=d:%20==").matches());
- assertTrue(Validator.INST_CHARS.matcher(":1234%235g=d:==%20:=%23").matches());
- assertTrue(Validator.INST_CHARS.matcher(":1234%235g=d:*:=%23").matches());
- assertTrue(Validator.INST_CHARS.matcher(":1234%235g=d:==%20:*").matches());
- assertTrue(Validator.INST_CHARS.matcher(":*:==%20:*").matches());
-
- // Allow / instead of : (more natural instance expression) jg
- assertFalse(Validator.INST_CHARS.matcher("1234/a").matches());
- assertTrue(Validator.INST_CHARS.matcher("/1234/a").matches());
- assertTrue(Validator.INST_CHARS.matcher("/1234/*/a/").matches());
- assertTrue(Validator.INST_CHARS.matcher("/1234//a").matches());
- assertFalse(Validator.ACTION_CHARS.matcher("1234/a").matches());
- assertFalse(Validator.ACTION_CHARS.matcher("/1234/*/a/").matches());
- assertFalse(Validator.ACTION_CHARS.matcher("1234//a").matches());
-
-
- assertFalse(Validator.INST_CHARS.matcher("1234+235gd").matches());
- assertTrue(Validator.INST_CHARS.matcher("1234-235gd").matches());
- assertTrue(Validator.INST_CHARS.matcher("1234-23_5gd").matches());
- assertTrue(Validator.INST_CHARS.matcher("1234-235g,d").matches());
- assertTrue(Validator.INST_CHARS.matcher("m1234@shb.dd.com").matches());
- assertTrue(Validator.INST_CHARS.matcher("1234-235gd(Version12)").matches());
- assertFalse(Validator.INST_CHARS.matcher("123#4-23@5g:d").matches());
- assertFalse(Validator.INST_CHARS.matcher("123#4-23@5g:d").matches());
- assertFalse(Validator.INST_CHARS.matcher("").matches());
-
-
- for( char c=0x20;c<0x7F;++c) {
- boolean b;
- switch(c) {
- case '?':
- case '|':
- case '*':
- continue; // test separately
- case '~':
- case ',':
- b = false;
- break;
- default:
- b=true;
- }
- }
-
- assertFalse(Validator.ID_CHARS.matcher("abc").matches());
- assertFalse(Validator.ID_CHARS.matcher("").matches());
- assertTrue(Validator.ID_CHARS.matcher("abc@att.com").matches());
- assertTrue(Validator.ID_CHARS.matcher("ab-me@att.com").matches());
- assertTrue(Validator.ID_CHARS.matcher("ab-me_.x@att._-com").matches());
-
- assertFalse(Validator.NAME_CHARS.matcher("ab-me_.x@att._-com").matches());
- assertTrue(Validator.NAME_CHARS.matcher("ab-me").matches());
- assertTrue(Validator.NAME_CHARS.matcher("ab-me_.xatt._-com").matches());
-
-
- // 7/22/2016
- assertTrue(Validator.INST_CHARS.matcher(
- "/!com.att.*/role/write").matches());
- assertTrue(Validator.INST_CHARS.matcher(
- ":!com.att.*:role:write").matches());
-
- }
+ Validator validator;
+ String base = "\\x25\\x28\\x29\\x2C-\\x2E\\x30-\\x39\\x3D\\x40-\\x5A\\x5F\\x61-\\x7A";
+
+ @Before
+ public void setUp() {
+ validator = new Validator();
+ }
+
+ @Test
+ public void testNullOrBlank() {
+ validator.nullOrBlank(null, "str");
+ validator.nullOrBlank("test", "");
+ validator.nullOrBlank("test", null);
+ }
+
+ @Test
+ public void testIsNull() {
+ Object o = new Object();
+ validator.isNull(null, null);
+ validator.isNull(null, o);
+ }
+
+ @Test
+ public void testDescription() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ Class c = validator.getClass();
+ Class[] cArg = new Class[2];
+ cArg[0] = String.class;
+ cArg[1] = String.class; //Steps to test a protected method
+ Method descriptionMethod = c.getDeclaredMethod("description", cArg);
+ descriptionMethod.setAccessible(true);
+ descriptionMethod.invoke(validator,"test", "test1");
+ descriptionMethod.invoke(validator,null, null);
+ descriptionMethod.invoke(validator,null, "[\\\\x25\\\\x28\\\\x29\\\\x2C-\\\\x2E\\\\x30-\\\\x39\\\\x3D\\\\x40-\\\\x5A\\\\x5F\\\\x61-\\\\x7A\\\\x20]+");
+
+
+ }
+
+ @Test
+ public void testPermType() {
+ Assert.assertNotNull(validator.permType("[\\\\w.-]+"));
+ Assert.assertNotNull(validator.permType(null));
+ Assert.assertNotNull(validator.permType(""));
+ Assert.assertNotNull(validator.permType("aewfew"));
+ }
+
+ @Test
+ public void testPermType1() {
+ Assert.assertNotNull(validator.permType("[\\\\w.-]+",null));
+ Assert.assertNotNull(validator.permType(null,null));
+ Assert.assertNotNull(validator.permType("","test"));
+ Assert.assertNotNull(validator.permType("aewfew","test"));
+ }
+
+ @Test
+ public void testPermInstance() {
+
+ String middle = "]+[\\\\*]*|\\\\*|(([:/]\\\\*)|([:/][!]{0,1}[";
+ Assert.assertNotNull(validator.permInstance("[" + base + middle + base + "]+[\\\\*]*[:/]*))+"));
+ Assert.assertNotNull(validator.permInstance(null));
+ Assert.assertNotNull(validator.permInstance(""));
+ Assert.assertNotNull(validator.permInstance("test"));
+ }
+
+ @Test
+ public void testErr() {
+ Assert.assertFalse(validator.err());
+ validator.isNull("test", null);
+ Assert.assertTrue(validator.err());
+ }
+
+ @Test
+ public void testErrs() {
+ validator.isNull("test", null);
+ Assert.assertNotNull(validator.errs());
+ }
+
+ @Test
+ public void testPermAction() {
+ Assert.assertNotNull(validator.permAction("[" + base + "]+" + "|\\\\*"));
+ Assert.assertNotNull(validator.permAction("test"));
+ }
+
+ @Test
+ public void testRole() {
+ Assert.assertNotNull(validator.role("[\\\\w.-]+"));
+ Assert.assertNotNull(validator.role(null));
+ Assert.assertNotNull(validator.role(""));
+ Assert.assertNotNull(validator.role("aewfew"));
+ }
+
+ @Test
+ public void testNs() {
+ Assert.assertNotNull(validator.ns("[\\\\w.-]+"));
+ Assert.assertNotNull(validator.ns(""));
+ Assert.assertNotNull(validator.ns(".access"));
+ }
+
+ @Test
+ public void testKey() {
+ Assert.assertNotNull(validator.key("[\\\\w.-]+"));
+ Assert.assertNotNull(validator.key(""));
+ Assert.assertNotNull(validator.key(".access"));
+ }
+
+ @Test
+ public void testValue() {
+ Assert.assertNotNull(validator.value(base));
+ Assert.assertNotNull(validator.value(""));
+ Assert.assertNotNull(validator.value(".access"));
+ }
+
+ @Test
+ public void testNotOK() {
+ Result<?> test = mock(Result.class);
+ validator.isNull("test", null);
+ when(test.notOK()).thenReturn(true);
+ Assert.assertNotNull(validator.notOK(null));
+ Assert.assertNotNull(validator.notOK(test));
+ }
+
+ @Test
+ public void testIntRange() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ Class c = validator.getClass();
+ Class[] cArg = new Class[4];
+ cArg[0] = String.class;
+ cArg[1] = int.class;
+ cArg[2] = int.class;
+ cArg[3] = int.class; //Steps to test a protected method
+ Method intRangeMethod = c.getDeclaredMethod("intRange", cArg);
+ intRangeMethod.setAccessible(true);
+ intRangeMethod.invoke(validator,"Test",5,1,10);
+ intRangeMethod.invoke(validator,"Test",1,5,10);
+ intRangeMethod.invoke(validator,"Test",11,5,10);
+ intRangeMethod.invoke(validator,"Test",5,6,4);
+ }
+
+ @Test
+ public void testFloatRange() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ Class c = validator.getClass();
+ Class[] cArg = new Class[4];
+ cArg[0] = String.class;
+ cArg[1] = float.class;
+ cArg[2] = float.class;
+ cArg[3] = float.class; //Steps to test a protected method
+ Method floatRangeMethod = c.getDeclaredMethod("floatRange", cArg);
+ floatRangeMethod.setAccessible(true);
+ floatRangeMethod.invoke(validator,"Test",5f,1f,10f);
+ floatRangeMethod.invoke(validator,"Test",1f,5f,10f);
+ floatRangeMethod.invoke(validator,"Test",11f,5f,10f);
+ floatRangeMethod.invoke(validator,"Test",5f,6f,4f);
+ }
+
+ @Test
+ public void test() {
+ assertTrue(Validator.ACTION_CHARS.matcher("HowdyDoody").matches());
+ assertFalse(Validator.ACTION_CHARS.matcher("Howd?yDoody").matches());
+ assertTrue(Validator.ACTION_CHARS.matcher("_HowdyDoody").matches());
+ assertTrue(Validator.INST_CHARS.matcher("HowdyDoody").matches());
+ assertFalse(Validator.INST_CHARS.matcher("Howd?yDoody").matches());
+ assertTrue(Validator.INST_CHARS.matcher("_HowdyDoody").matches());
+
+ //
+ assertTrue(Validator.ACTION_CHARS.matcher("*").matches());
+ assertTrue(Validator.INST_CHARS.matcher("*").matches());
+ assertFalse(Validator.ACTION_CHARS.matcher(":*").matches());
+ assertTrue(Validator.INST_CHARS.matcher(":*").matches());
+ assertFalse(Validator.ACTION_CHARS.matcher(":*:*").matches());
+ assertTrue(Validator.INST_CHARS.matcher(":*:*").matches());
+
+ assertFalse(Validator.ACTION_CHARS.matcher(":hello").matches());
+ assertTrue(Validator.INST_CHARS.matcher(":hello").matches());
+ assertFalse(Validator.INST_CHARS.matcher("hello:").matches());
+ assertFalse(Validator.INST_CHARS.matcher("hello:d").matches());
+
+ assertFalse(Validator.ACTION_CHARS.matcher(":hello:*").matches());
+ assertTrue(Validator.INST_CHARS.matcher(":hello:*").matches());
+ assertFalse(Validator.ACTION_CHARS.matcher(":hello:d*:*").matches());
+ assertFalse(Validator.INST_CHARS.matcher(":hello:d*d:*").matches());
+ assertTrue(Validator.INST_CHARS.matcher(":hello:d*:*").matches());
+ assertFalse(Validator.ACTION_CHARS.matcher("HowdyDoody*").matches());
+ assertFalse(Validator.INST_CHARS.matcher("Howdy*Doody").matches());
+ assertTrue(Validator.INST_CHARS.matcher("HowdyDoody*").matches());
+ assertFalse(Validator.ACTION_CHARS.matcher("*HowdyDoody").matches());
+ assertFalse(Validator.INST_CHARS.matcher("*HowdyDoody").matches());
+ assertFalse(Validator.ACTION_CHARS.matcher(":h*").matches());
+ assertFalse(Validator.INST_CHARS.matcher(":h*h*").matches());
+ assertTrue(Validator.INST_CHARS.matcher(":h*").matches());
+ assertFalse(Validator.ACTION_CHARS.matcher(":h:h*:*").matches());
+ assertTrue(Validator.INST_CHARS.matcher(":h:h*:*").matches());
+ assertFalse(Validator.INST_CHARS.matcher(":h:h*h:*").matches());
+ assertFalse(Validator.INST_CHARS.matcher(":h:h*h*:*").matches());
+ assertFalse(Validator.ACTION_CHARS.matcher(":h:*:*h").matches());
+ assertFalse(Validator.INST_CHARS.matcher(":h:*:*h").matches());
+ assertTrue(Validator.INST_CHARS.matcher(":com.test.*:ns:*").matches());
+
+
+ assertFalse(Validator.ACTION_CHARS.matcher("1234+235gd").matches());
+ assertTrue(Validator.ACTION_CHARS.matcher("1234-235gd").matches());
+ assertTrue(Validator.ACTION_CHARS.matcher("1234-23_5gd").matches());
+ assertTrue(Validator.ACTION_CHARS.matcher("1234-235g,d").matches());
+ assertTrue(Validator.ACTION_CHARS.matcher("1234-235gd(Version12)").matches());
+ assertFalse(Validator.ACTION_CHARS.matcher("123#4-23@5g:d").matches());
+ assertFalse(Validator.ACTION_CHARS.matcher("123#4-23@5g:d").matches());
+ assertFalse(Validator.ACTION_CHARS.matcher("1234-23 5gd").matches());
+ assertFalse(Validator.ACTION_CHARS.matcher("1234-235gd ").matches());
+ assertFalse(Validator.ACTION_CHARS.matcher(" 1234-235gd").matches());
+ assertFalse(Validator.ACTION_CHARS.matcher("").matches());
+ assertFalse(Validator.ACTION_CHARS.matcher(" ").matches());
+
+ // Allow % and = (Needed for Escaping & Base64 usages) jg
+ assertTrue(Validator.ACTION_CHARS.matcher("1234%235g=d").matches());
+ assertFalse(Validator.ACTION_CHARS.matcher(":1234%235g=d").matches());
+ assertTrue(Validator.INST_CHARS.matcher("1234%235g=d").matches());
+ assertTrue(Validator.INST_CHARS.matcher(":1234%235g=d").matches());
+ assertTrue(Validator.INST_CHARS.matcher(":1234%235g=d:%20==").matches());
+ assertTrue(Validator.INST_CHARS.matcher(":1234%235g=d:==%20:=%23").matches());
+ assertTrue(Validator.INST_CHARS.matcher(":1234%235g=d:*:=%23").matches());
+ assertTrue(Validator.INST_CHARS.matcher(":1234%235g=d:==%20:*").matches());
+ assertTrue(Validator.INST_CHARS.matcher(":*:==%20:*").matches());
+
+ // Allow / instead of : (more natural instance expression) jg
+ assertFalse(Validator.INST_CHARS.matcher("1234/a").matches());
+ assertTrue(Validator.INST_CHARS.matcher("/1234/a").matches());
+ assertTrue(Validator.INST_CHARS.matcher("/1234/*/a/").matches());
+ assertTrue(Validator.INST_CHARS.matcher("/1234//a").matches());
+ assertFalse(Validator.ACTION_CHARS.matcher("1234/a").matches());
+ assertFalse(Validator.ACTION_CHARS.matcher("/1234/*/a/").matches());
+ assertFalse(Validator.ACTION_CHARS.matcher("1234//a").matches());
+
+
+ assertFalse(Validator.INST_CHARS.matcher("1234+235gd").matches());
+ assertTrue(Validator.INST_CHARS.matcher("1234-235gd").matches());
+ assertTrue(Validator.INST_CHARS.matcher("1234-23_5gd").matches());
+ assertTrue(Validator.INST_CHARS.matcher("1234-235g,d").matches());
+ assertTrue(Validator.INST_CHARS.matcher("m1234@shb.dd.com").matches());
+ assertTrue(Validator.INST_CHARS.matcher("1234-235gd(Version12)").matches());
+ assertFalse(Validator.INST_CHARS.matcher("123#4-23@5g:d").matches());
+ assertFalse(Validator.INST_CHARS.matcher("123#4-23@5g:d").matches());
+ assertFalse(Validator.INST_CHARS.matcher("").matches());
+
+
+ for( char c=0x20;c<0x7F;++c) {
+ boolean b;
+ switch(c) {
+ case '?':
+ case '|':
+ case '*':
+ continue; // test separately
+ case '~':
+ case ',':
+ b = false;
+ break;
+ default:
+ b=true;
+ }
+ }
+
+ assertFalse(Validator.ID_CHARS.matcher("abc").matches());
+ assertFalse(Validator.ID_CHARS.matcher("").matches());
+ assertTrue(Validator.ID_CHARS.matcher("abc@att.com").matches());
+ assertTrue(Validator.ID_CHARS.matcher("ab-me@att.com").matches());
+ assertTrue(Validator.ID_CHARS.matcher("ab-me_.x@att._-com").matches());
+
+ assertFalse(Validator.NAME_CHARS.matcher("ab-me_.x@att._-com").matches());
+ assertTrue(Validator.NAME_CHARS.matcher("ab-me").matches());
+ assertTrue(Validator.NAME_CHARS.matcher("ab-me_.xatt._-com").matches());
+
+
+ // 7/22/2016
+ assertTrue(Validator.INST_CHARS.matcher(
+ "/!com.att.*/role/write").matches());
+ assertTrue(Validator.INST_CHARS.matcher(
+ ":!com.att.*:role:write").matches());
+
+ }
}