summaryrefslogtreecommitdiffstats
path: root/authz-core/src/test/java
diff options
context:
space:
mode:
authorsg481n <sg481n@att.com>2017-08-03 17:27:34 -0400
committersg481n <sg481n@att.com>2017-08-03 17:27:34 -0400
commit43854a9e3310ff7a92257d16c4fc0a8321eaec68 (patch)
tree46af936c5da4f9c60d7d63dade5c61a8fd5ef9f4 /authz-core/src/test/java
parentf691a8b8dfc9eea4c6b3bfa45ea60f07ad347e69 (diff)
 [AAF-21] Initial code import
Change-Id: I63d7d499bbd46f500b5f5a4db966166f613f327a Signed-off-by: sg481n <sg481n@att.com>
Diffstat (limited to 'authz-core/src/test/java')
-rw-r--r--authz-core/src/test/java/com/att/authz/common/JU_Define.java64
-rw-r--r--authz-core/src/test/java/com/att/authz/env/JU_AuthzEnv.java70
-rw-r--r--authz-core/src/test/java/com/att/authz/env/JU_AuthzTransFilter.java81
-rw-r--r--authz-core/src/test/java/com/att/authz/env/JU_AuthzTransImpl.java74
-rw-r--r--authz-core/src/test/java/com/att/authz/env/JU_AuthzTransOnlyFilter.java50
-rw-r--r--authz-core/src/test/java/com/att/authz/env/JU_NullTrans.java47
-rw-r--r--authz-core/src/test/java/com/att/authz/layer/JU_Result.java54
-rw-r--r--authz-core/src/test/java/com/att/authz/local/JU_DataFile.java69
-rw-r--r--authz-core/src/test/java/com/att/authz/local/JU_TextIndex.java52
-rw-r--r--authz-core/src/test/java/com/att/authz/org/JU_OrganizationException.java49
-rw-r--r--authz-core/src/test/java/com/att/authz/org/JU_OrganizationFactory.java64
-rw-r--r--authz-core/src/test/java/com/att/cssa/rserv/JU_CachingFileAccess.java50
-rw-r--r--authz-core/src/test/java/com/att/cssa/rserv/JU_CodeSetter.java68
-rw-r--r--authz-core/src/test/java/com/att/cssa/rserv/JU_Pair.java46
-rw-r--r--authz-core/src/test/java/com/att/cssa/rserv/JU_Routes.java70
-rw-r--r--authz-core/src/test/java/com/att/cssa/rserv/JU_TypedCode.java52
-rw-r--r--authz-core/src/test/java/com/att/cssa/rserv/JU_Version.java58
-rw-r--r--authz-core/src/test/java/com/att/cssa/rserv/test/JU_BetterMatch.java167
-rw-r--r--authz-core/src/test/java/com/att/cssa/rserv/test/JU_Content.java133
19 files changed, 1318 insertions, 0 deletions
diff --git a/authz-core/src/test/java/com/att/authz/common/JU_Define.java b/authz-core/src/test/java/com/att/authz/common/JU_Define.java
new file mode 100644
index 00000000..af0cd267
--- /dev/null
+++ b/authz-core/src/test/java/com/att/authz/common/JU_Define.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aai
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * Copyright © 2017 Amdocs
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package com.att.authz.common;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.att.cadi.CadiException;
+import com.att.cadi.config.Config;
+import com.att.inno.env.Env;
+
+@RunWith(PowerMockRunner.class)
+public class JU_Define {
+ Define define;
+ public static String ROOT_NS="NS.Not.Set";
+ public static String ROOT_COMPANY=ROOT_NS;
+
+ @Mock
+ Env envMock;
+
+
+ @Before
+ public void setUp(){
+ define = new Define();
+ }
+
+ @Test
+ public void testSet() throws CadiException {
+ PowerMockito.when(envMock.getProperty(Config.AAF_ROOT_NS)).thenReturn("aaf_root_ns");
+ PowerMockito.when(envMock.getProperty(Config.AAF_ROOT_COMPANY)).thenReturn("aaf_root_company");
+ //PowerMockito.when(envMock.init().log()).thenReturn(null);
+ //PowerMockito.doNothing().doThrow(new CadiException()).when(envMock).init().log(Matchers.anyString());
+ define.set(envMock);
+ }
+
+}
diff --git a/authz-core/src/test/java/com/att/authz/env/JU_AuthzEnv.java b/authz-core/src/test/java/com/att/authz/env/JU_AuthzEnv.java
new file mode 100644
index 00000000..bda84f0b
--- /dev/null
+++ b/authz-core/src/test/java/com/att/authz/env/JU_AuthzEnv.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aai
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * Copyright © 2017 Amdocs
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package com.att.authz.env;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.att.cadi.Access.Level;
+
+@RunWith(PowerMockRunner.class)
+public class JU_AuthzEnv {
+ private static final com.att.cadi.Access.Level DEBUG = null;
+ AuthzEnv authzEnv;
+ enum Level {DEBUG, INFO, AUDIT, INIT, WARN, ERROR};
+
+ @Before
+ public void setUp(){
+ authzEnv = new AuthzEnv();
+ }
+
+ @Test
+ public void testTransRate() {
+ Long Result = authzEnv.transRate();
+ System.out.println("value of result " +Result); //Expected 300000
+ assertNotNull(Result);
+ }
+
+ @Test(expected = IOException.class)
+ public void testDecryptException() throws IOException{
+ String encrypted = null;
+ authzEnv.decrypt(encrypted, true);
+ }
+
+ @Test
+ public void testDecrypt() throws IOException{
+ String encrypted = "encrypted";
+ String Result = authzEnv.decrypt(encrypted, true);
+ System.out.println("value of res " +Result);
+ assertEquals("encrypted",Result);
+ }
+
+}
diff --git a/authz-core/src/test/java/com/att/authz/env/JU_AuthzTransFilter.java b/authz-core/src/test/java/com/att/authz/env/JU_AuthzTransFilter.java
new file mode 100644
index 00000000..c00ff684
--- /dev/null
+++ b/authz-core/src/test/java/com/att/authz/env/JU_AuthzTransFilter.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aai
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * Copyright © 2017 Amdocs
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package com.att.authz.env;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.att.cadi.CadiException;
+import com.att.cadi.Connector;
+import com.att.cadi.TrustChecker;
+
+@RunWith(PowerMockRunner.class)
+public class JU_AuthzTransFilter {
+AuthzTransFilter authzTransFilter;
+@Mock
+AuthzEnv authzEnvMock;
+@Mock
+Connector connectorMock;
+@Mock
+TrustChecker trustCheckerMock;
+@Mock
+AuthzTrans authzTransMock;
+Object additionalTafLurs;
+
+ @Before
+ public void setUp(){
+ try {
+ authzTransFilter = new AuthzTransFilter(authzEnvMock, connectorMock, trustCheckerMock, additionalTafLurs);
+ } catch (CadiException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void test()
+ {
+ //authzTransFilter.newTrans();
+ assertTrue(true);
+ }
+
+ @Test
+ public void testTallyHo(){
+ PowerMockito.when(authzTransMock.info().isLoggable()).thenReturn(true);
+ //if(trans.info().isLoggable())
+ authzTransFilter.tallyHo(authzTransMock);
+
+ }
+
+
+// AuthzTrans at = env.newTrans();
+// at.setLur(getLur());
+// return at
+}
diff --git a/authz-core/src/test/java/com/att/authz/env/JU_AuthzTransImpl.java b/authz-core/src/test/java/com/att/authz/env/JU_AuthzTransImpl.java
new file mode 100644
index 00000000..f9a934e0
--- /dev/null
+++ b/authz-core/src/test/java/com/att/authz/env/JU_AuthzTransImpl.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aai
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * Copyright © 2017 Amdocs
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package com.att.authz.env;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.att.authz.org.Organization;
+import com.att.authz.org.OrganizationFactory;
+import com.att.inno.env.LogTarget;
+
+@RunWith(PowerMockRunner.class)
+public class JU_AuthzTransImpl {
+
+ AuthzTransImpl authzTransImpl;
+ @Mock
+ AuthzEnv authzEnvMock;
+
+ private Organization org=null;
+
+ @Before
+ public void setUp(){
+ authzTransImpl = new AuthzTransImpl(authzEnvMock);
+
+ }
+
+ @Test
+ public void testOrg(){
+ Organization result=null;
+ result = authzTransImpl.org();
+ System.out.println("value of Organization " + result);
+ //assertTrue(true);
+ }
+
+ @Mock
+ LogTarget logTargetMock;
+
+ @Test
+ public void testLogAuditTrail(){
+
+ PowerMockito.when(logTargetMock.isLoggable()).thenReturn(false);
+ authzTransImpl.logAuditTrail(logTargetMock);
+
+ assertTrue(true);
+ }
+
+}
diff --git a/authz-core/src/test/java/com/att/authz/env/JU_AuthzTransOnlyFilter.java b/authz-core/src/test/java/com/att/authz/env/JU_AuthzTransOnlyFilter.java
new file mode 100644
index 00000000..640fbdca
--- /dev/null
+++ b/authz-core/src/test/java/com/att/authz/env/JU_AuthzTransOnlyFilter.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aai
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * Copyright © 2017 Amdocs
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package com.att.authz.env;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class JU_AuthzTransOnlyFilter {
+ AuthzTransOnlyFilter authzTransOnlyFilter;
+ @Mock
+ AuthzEnv authzEnvMock;
+
+ @Before
+ public void setUp(){
+ authzTransOnlyFilter = new AuthzTransOnlyFilter(authzEnvMock);
+ }
+
+ @Test
+ public void test() {
+ assertTrue(true);
+ }
+
+}
diff --git a/authz-core/src/test/java/com/att/authz/env/JU_NullTrans.java b/authz-core/src/test/java/com/att/authz/env/JU_NullTrans.java
new file mode 100644
index 00000000..7853a205
--- /dev/null
+++ b/authz-core/src/test/java/com/att/authz/env/JU_NullTrans.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aai
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * Copyright © 2017 Amdocs
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package com.att.authz.env;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class JU_NullTrans {
+ NullTrans nullTrans;
+
+ @Before
+ public void setUp(){
+ nullTrans = new NullTrans();
+ }
+
+ @Test
+ public void test() {
+ assertTrue(true);
+ }
+
+}
diff --git a/authz-core/src/test/java/com/att/authz/layer/JU_Result.java b/authz-core/src/test/java/com/att/authz/layer/JU_Result.java
new file mode 100644
index 00000000..8bebfa7d
--- /dev/null
+++ b/authz-core/src/test/java/com/att/authz/layer/JU_Result.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aai
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * Copyright © 2017 Amdocs
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package com.att.authz.layer;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+
+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 = new Result(result, status, details, variables);
+ }
+
+ @Test
+ public void testPartialContent() {
+ Result Res = result.partialContent(true);
+ System.out.println("Res" +Res);
+ assertEquals(details,Res.toString());
+
+ }
+
+}
diff --git a/authz-core/src/test/java/com/att/authz/local/JU_DataFile.java b/authz-core/src/test/java/com/att/authz/local/JU_DataFile.java
new file mode 100644
index 00000000..27c7ad60
--- /dev/null
+++ b/authz-core/src/test/java/com/att/authz/local/JU_DataFile.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aai
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * Copyright © 2017 Amdocs
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package com.att.authz.local;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.AfterClass;
+import org.junit.Test;
+
+import com.att.authz.local.DataFile;
+import com.att.authz.local.DataFile.Token;
+import com.att.authz.local.DataFile.Token.Field;
+
+public class JU_DataFile {
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ @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<String>();
+ 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);
+ }
+ }
+
+}
diff --git a/authz-core/src/test/java/com/att/authz/local/JU_TextIndex.java b/authz-core/src/test/java/com/att/authz/local/JU_TextIndex.java
new file mode 100644
index 00000000..be0746bd
--- /dev/null
+++ b/authz-core/src/test/java/com/att/authz/local/JU_TextIndex.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aai
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * Copyright © 2017 Amdocs
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package com.att.authz.local;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class JU_TextIndex {
+ TextIndex textIndex;
+ @Mock
+ File file;
+
+ @Before
+ public void setUp(){
+ textIndex = new TextIndex(file);
+ }
+
+ @Test
+ public void test() {
+ assertTrue(true);
+ }
+
+}
diff --git a/authz-core/src/test/java/com/att/authz/org/JU_OrganizationException.java b/authz-core/src/test/java/com/att/authz/org/JU_OrganizationException.java
new file mode 100644
index 00000000..91a54126
--- /dev/null
+++ b/authz-core/src/test/java/com/att/authz/org/JU_OrganizationException.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aai
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * Copyright © 2017 Amdocs
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package com.att.authz.org;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+public class JU_OrganizationException {
+
+ OrganizationException organizationException;
+
+ @Before
+ public void setUp(){
+ organizationException = new OrganizationException();
+ }
+
+
+ @Test
+ public void test() {
+ assertTrue(true);
+ }
+
+}
diff --git a/authz-core/src/test/java/com/att/authz/org/JU_OrganizationFactory.java b/authz-core/src/test/java/com/att/authz/org/JU_OrganizationFactory.java
new file mode 100644
index 00000000..75f2a52a
--- /dev/null
+++ b/authz-core/src/test/java/com/att/authz/org/JU_OrganizationFactory.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aai
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * Copyright © 2017 Amdocs
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package com.att.authz.org;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.att.authz.env.AuthzEnv;
+import com.att.inno.env.APIException;
+
+@RunWith(PowerMockRunner.class)
+public class JU_OrganizationFactory {
+ private static final String ORG_SLOT = null;
+ OrganizationFactory organizationFactory;
+ @Mock
+ AuthzEnv authzEnvMock;
+ String orgClass="orgclass";
+ String orgNS="orgns";
+ @Before
+ public void setUp(){
+ organizationFactory = new OrganizationFactory();
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = APIException.class)
+ public void testSetDefaultOrg() throws APIException {
+ //PowerMockito.when(authzEnvMock.slot(ORG_SLOT)).thenReturn("ORG_SLOT");
+ organizationFactory.setDefaultOrg(authzEnvMock, orgClass);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = OrganizationException.class)
+ public void testObtain() throws OrganizationException{
+ PowerMockito.when(authzEnvMock.getProperty("Organization."+orgNS)).thenReturn("notnull");
+ organizationFactory.obtain(authzEnvMock, orgNS);
+ }
+}
diff --git a/authz-core/src/test/java/com/att/cssa/rserv/JU_CachingFileAccess.java b/authz-core/src/test/java/com/att/cssa/rserv/JU_CachingFileAccess.java
new file mode 100644
index 00000000..3716b19d
--- /dev/null
+++ b/authz-core/src/test/java/com/att/cssa/rserv/JU_CachingFileAccess.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aai
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * Copyright © 2017 Amdocs
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package com.att.cssa.rserv;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+
+@RunWith(PowerMockRunner.class)
+public class JU_CachingFileAccess {
+ CachingFileAccess cachingFileAccess;
+
+
+ @Before
+ public void setUp(){
+ cachingFileAccess = new CachingFileAccess(null, null);
+
+ }
+
+ @Test
+ public void test() {
+ assertTrue(true);
+ }
+
+}
diff --git a/authz-core/src/test/java/com/att/cssa/rserv/JU_CodeSetter.java b/authz-core/src/test/java/com/att/cssa/rserv/JU_CodeSetter.java
new file mode 100644
index 00000000..d6405c2d
--- /dev/null
+++ b/authz-core/src/test/java/com/att/cssa/rserv/JU_CodeSetter.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aai
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * Copyright © 2017 Amdocs
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package com.att.cssa.rserv;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.att.inno.env.Trans;
+
+@RunWith(PowerMockRunner.class)
+public class JU_CodeSetter {
+ CodeSetter codeSetter;
+ @Mock
+ Trans transMock;
+ @Mock
+ HttpServletRequest reqMock;
+ @Mock
+ HttpServletResponse respMock;
+
+ @Before
+ public void setUp(){
+ codeSetter = new CodeSetter(transMock, reqMock, respMock);
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Mock
+ Route routeMock;
+
+ @Test
+ public void testMatches() throws IOException, ServletException{
+ boolean result = codeSetter.matches(routeMock);
+ System.out.println("value of res " + codeSetter.matches(routeMock));
+ assertFalse(result);
+ }
+
+}
diff --git a/authz-core/src/test/java/com/att/cssa/rserv/JU_Pair.java b/authz-core/src/test/java/com/att/cssa/rserv/JU_Pair.java
new file mode 100644
index 00000000..5cc362f8
--- /dev/null
+++ b/authz-core/src/test/java/com/att/cssa/rserv/JU_Pair.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aai
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * Copyright © 2017 Amdocs
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package com.att.cssa.rserv;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class JU_Pair {
+ Pair pair;
+ Object x;
+ Object y;
+
+ @Before
+ public void setUp(){
+ pair = new Pair(x, y);
+ }
+
+ @Test
+ public void test() {
+ assertTrue(true);
+ }
+
+}
diff --git a/authz-core/src/test/java/com/att/cssa/rserv/JU_Routes.java b/authz-core/src/test/java/com/att/cssa/rserv/JU_Routes.java
new file mode 100644
index 00000000..67328f6e
--- /dev/null
+++ b/authz-core/src/test/java/com/att/cssa/rserv/JU_Routes.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aai
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * Copyright © 2017 Amdocs
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package com.att.cssa.rserv;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.att.inno.env.Trans;
+
+@RunWith(PowerMockRunner.class)
+public class JU_Routes {
+ Routes routes;
+ @Mock
+ HttpServletRequest reqMock;
+ CodeSetter<Trans> codeSetterMock;
+ Route<Trans> routeObj;
+
+ @Before
+ public void setUp(){
+ routes = new Routes();
+ }
+
+ @Test
+ public void testRouteReport(){
+ List listVal = routes.routeReport();
+ System.out.println("value of Listval " +listVal);
+ assertNotNull(listVal);
+
+ }
+
+ @Test
+ public void testDerive() throws IOException, ServletException{
+ routeObj = routes.derive(reqMock, codeSetterMock);
+ System.out.println("value of routeObj" +routeObj);
+ }
+
+
+}
diff --git a/authz-core/src/test/java/com/att/cssa/rserv/JU_TypedCode.java b/authz-core/src/test/java/com/att/cssa/rserv/JU_TypedCode.java
new file mode 100644
index 00000000..76d5553e
--- /dev/null
+++ b/authz-core/src/test/java/com/att/cssa/rserv/JU_TypedCode.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aai
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * Copyright © 2017 Amdocs
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package com.att.cssa.rserv;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+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);
+ }
+
+
+}
diff --git a/authz-core/src/test/java/com/att/cssa/rserv/JU_Version.java b/authz-core/src/test/java/com/att/cssa/rserv/JU_Version.java
new file mode 100644
index 00000000..47ea35be
--- /dev/null
+++ b/authz-core/src/test/java/com/att/cssa/rserv/JU_Version.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aai
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * Copyright © 2017 Amdocs
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package com.att.cssa.rserv;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+public class JU_Version {
+ Version version;
+
+
+ @Before
+ public void setUp(){
+ version = new Version("String");
+ }
+
+ @Test
+ public void testEquals(){
+ boolean val = version.equals(version);
+ System.out.println("value of val " +val);
+ assertTrue(val);
+ }
+
+ @Test
+ public void testToString(){
+ String strVal = version.toString();
+ System.out.println("value of strVal " +strVal);
+ assertNotNull(strVal);
+ }
+}
diff --git a/authz-core/src/test/java/com/att/cssa/rserv/test/JU_BetterMatch.java b/authz-core/src/test/java/com/att/cssa/rserv/test/JU_BetterMatch.java
new file mode 100644
index 00000000..5a825917
--- /dev/null
+++ b/authz-core/src/test/java/com/att/cssa/rserv/test/JU_BetterMatch.java
@@ -0,0 +1,167 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aai
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * Copyright © 2017 Amdocs
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package com.att.cssa.rserv.test;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.att.cssa.rserv.Match;
+import com.att.inno.env.Env;
+import com.att.inno.env.TimeTaken;
+import com.att.inno.env.Trans;
+import com.att.inno.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");
+
+ 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("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"));
+
+ }
+
+}
diff --git a/authz-core/src/test/java/com/att/cssa/rserv/test/JU_Content.java b/authz-core/src/test/java/com/att/cssa/rserv/test/JU_Content.java
new file mode 100644
index 00000000..dd2a33e1
--- /dev/null
+++ b/authz-core/src/test/java/com/att/cssa/rserv/test/JU_Content.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aai
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * Copyright © 2017 Amdocs
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package com.att.cssa.rserv.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.Test;
+
+import com.att.cssa.rserv.HttpCode;
+import com.att.cssa.rserv.TypedCode;
+import com.att.inno.env.TransJAXB;
+import com.att.inno.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) {
+ }
+ }
+ };
+
+ 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);
+ }
+ }
+
+}