summaryrefslogtreecommitdiffstats
path: root/auth/auth-cass/src/test/java/org
diff options
context:
space:
mode:
authorSai Gandham <sg481n@att.com>2019-05-24 08:46:22 -0500
committerSai Gandham <sg481n@att.com>2019-05-24 08:46:31 -0500
commita47bd51641efcb84e19d68a6383f0947df826636 (patch)
tree6e643466f49d2450e6cc98ac49e980ddfb7e4ca9 /auth/auth-cass/src/test/java/org
parentaab276e679f221b37fc6be37e5dd0ffd72ffc406 (diff)
more junits to auth cass module
Issue-ID: AAF-111 Change-Id: I7a1d2fd1568c9270174133e266d9590fe769dc7e Signed-off-by: Sai Gandham <sg481n@att.com>
Diffstat (limited to 'auth/auth-cass/src/test/java/org')
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLocator.java197
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLur.java243
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectLocatorCreator.java88
3 files changed, 447 insertions, 81 deletions
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLocator.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLocator.java
index 2801d433..01d4b9a2 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLocator.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLocator.java
@@ -61,95 +61,130 @@ public class JU_DirectAAFLocator {
AuthzTrans trans;
@Mock
- Access access;
+ PropAccess access;
@Before
public void setUp() throws Exception {
initMocks(this);
}
-//
-// @Test
-// public void testConstructorExcpetion() {
-// Mockito.doReturn(access).when(env).access();
-// Mockito.doReturn("20").when(access).getProperty(Config.CADI_LATITUDE,null);
-// Mockito.doReturn("20").when(access).getProperty(Config.CADI_LONGITUDE,null);
-// try {
-// DirectAAFLocator aafLocatorObj=new DirectAAFLocator(env, ldao,"test","test");
-// } catch (LocatorException e) {
-//// System.out.println(e.getMessage());
-// assertEquals("Invalid Version String: test", e.getMessage());
-// }
-// }
-//
+
+ @Test
+ public void testConstructorVersionExcpetion() {
+ Mockito.doReturn(access).when(env).access();
+ Mockito.doReturn("20").when(access).getProperty(Config.CADI_LATITUDE,null);
+ Mockito.doReturn("20").when(access).getProperty(Config.CADI_LONGITUDE,null);
+ Mockito.doReturn("20").when(access).getProperty(Config.AAF_LOCATOR_CONTAINER,"");
+ try {
+ DirectAAFLocator aafLocatorObj=new DirectAAFLocator(env, ldao,"test","test");
+ } catch (LocatorException e) {
+// System.out.println(e.getMessage());
+ assertEquals("Invalid Version String: test", e.getMessage());
+ }
+ try {
+ DirectAAFLocator aafLocatorObj=new DirectAAFLocator(env, ldao,"test","20.test");
+ } catch (LocatorException e) {
+// System.out.println(e.getMessage());
+ assertEquals("Invalid Version String: 20.test", e.getMessage());
+ }try {
+ DirectAAFLocator aafLocatorObj=new DirectAAFLocator(env, ldao,"test","20.20.test");
+ } catch (LocatorException e) {
+// System.out.println(e.getMessage());
+ assertEquals("Invalid Version String: 20.20.test", e.getMessage());
+ }try {
+ DirectAAFLocator aafLocatorObj=new DirectAAFLocator(env, ldao,"test","20.20.20.test");
+ } catch (LocatorException e) {
+// System.out.println(e.getMessage());
+ assertEquals("Invalid Version String: 20.20.20.test", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testConstructorExcpetion() {
+ Mockito.doReturn(access).when(env).access();
+ Mockito.doReturn("20").when(access).getProperty(Config.CADI_LATITUDE,null);
+ Mockito.doReturn("20").when(access).getProperty(Config.CADI_LONGITUDE,null);
+ Mockito.doReturn("20").when(access).getProperty(Config.AAF_LOCATOR_CONTAINER,"");
+ Mockito.doReturn("20").when(access).getProperty(Config.AAF_LOCATOR_APP_NS,"AAF_NS");
+ try {
+ DirectAAFLocator aafLocatorObj=new DirectAAFLocator(env, ldao,"test",null);
+ } catch (LocatorException e) {
+// System.out.println(e.getMessage());
+ }
+ }
+
// NOTE: These mocks to not well represent the DirectAAFLocator Class.
@Test
public void testConstructorUriExcpetion() {
- Assert.assertTrue(true);
+ Mockito.doReturn(access).when(env).access();
+ Mockito.doReturn("20").when(access).getProperty(Config.CADI_LATITUDE,null);
+ Mockito.doReturn("20").when(access).getProperty(Config.CADI_LONGITUDE,null);
+ Mockito.doReturn("20").when(access).getProperty(Config.AAF_LOCATOR_CONTAINER,"");
+ Mockito.doReturn("20 30").when(access).getProperty(Config.AAF_URL,null);
+ try {
+ DirectAAFLocator aafLocatorObj=new DirectAAFLocator(env, ldao,"test","192.0.0.1");
+ } catch (LocatorException e) {
+// System.out.println(e.getMessage());
+ assertTrue(e.getMessage().contains("Illegal character in path at index 2:"));
+ }
}
-// PropAccess access = Mockito.mock(PropAccess.class);
-// Mockito.doReturn(access).when(env).access();
-// Mockito.doReturn("20").when(access).getProperty(Config.CADI_LATITUDE,null);
-// Mockito.doReturn("20").when(access).getProperty(Config.CADI_LONGITUDE,null);
-// try {
-// DirectAAFLocator aafLocatorObj=new DirectAAFLocator(env, ldao," test","3.2");
-// } catch (LocatorException e) {
-//// System.out.println(e.getMessage());
-// assertTrue(e.getMessage().contains("Illegal character in path at index"));
-// }
-// }
-// @Test
-// public void testRefresh() {
-//
-// DirectAAFLocator aafLocatorObj=null;
-// PropAccess access = Mockito.mock(PropAccess.class);
-// Mockito.doReturn(access).when(env).access();
-// Mockito.doReturn(trans).when(env).newTransNoAvg();
-// Mockito.doReturn("20").when(access).getProperty(Config.CADI_LATITUDE,null);
-// Mockito.doReturn("20").when(access).getProperty(Config.CADI_LONGITUDE,null);
-// try {
-// aafLocatorObj = new DirectAAFLocator(env, ldao,"test","30.20.30.30");
-// } catch (LocatorException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-// Result<List<Data>> retVal1 = new Result<List<Data>>(null,0,"",new String[0]);
-//
-// Data data= new Data();
-// data.major=30;
-// data.minor=30;
-// data.patch=30;
-// data.pkg=30;
-// retVal1.value = new ArrayList<Data>();
-// retVal1.value.add(data);
-//
-// Mockito.doReturn(retVal1).when(ldao).readByName(trans,"test");
-// boolean retVal = aafLocatorObj.refresh();
-//// System.out.println(retVal);
-// assertTrue(retVal);
-// }
-//
-// @Test
-// public void testRefreshNOK() {
-//
-// DirectAAFLocator aafLocatorObj=null;
-// PropAccess access = Mockito.mock(PropAccess.class);
-// Mockito.doReturn(access).when(env).access();
-// Mockito.doReturn(trans).when(env).newTransNoAvg();
-// Mockito.doReturn("20").when(access).getProperty(Config.CADI_LATITUDE,null);
-// Mockito.doReturn("20").when(access).getProperty(Config.CADI_LONGITUDE,null);
-// try {
-// aafLocatorObj = new DirectAAFLocator(env, ldao,"test","30.20.30.30");
-// } catch (LocatorException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-// Result<List<Data>> retVal1 = new Result<List<Data>>(null,1,"",new String[0]);
-//
-// Mockito.doReturn(retVal1).when(ldao).readByName(trans,"test");
-// boolean retVal = aafLocatorObj.refresh();
-//// System.out.println(retVal);
-// assertFalse(retVal);
-// }
-//
+
+ @Test
+ public void testRefresh() {
+
+ DirectAAFLocator aafLocatorObj=null;
+ PropAccess access = Mockito.mock(PropAccess.class);
+ Mockito.doReturn(access).when(env).access();
+ Mockito.doReturn(trans).when(env).newTransNoAvg();
+ Mockito.doReturn("20").when(access).getProperty(Config.CADI_LATITUDE,null);
+ Mockito.doReturn("20").when(access).getProperty(Config.CADI_LONGITUDE,null);
+ Mockito.doReturn("20").when(access).getProperty(Config.AAF_LOCATOR_CONTAINER,"");
+ Mockito.doReturn("http://aafurl.com").when(access).getProperty(Config.AAF_URL,null);
+ try {
+ aafLocatorObj = new DirectAAFLocator(env, ldao,"test","30.20.30.30");
+ } catch (LocatorException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ Result<List<Data>> retVal1 = new Result<List<Data>>(null,0,"",new Object[0]);
+
+ Data data= new Data();
+ data.major=30;
+ data.minor=30;
+ data.patch=30;
+ data.pkg=30;
+ retVal1.value = new ArrayList<Data>();
+ retVal1.value.add(data);
+
+ Mockito.doReturn(retVal1).when(ldao).readByName(trans,"test");
+ boolean retVal = aafLocatorObj.refresh();
+// System.out.println(retVal);
+ assertTrue(retVal);
+ }
+
+ @Test
+ public void testRefreshNOK() {
+
+ DirectAAFLocator aafLocatorObj=null;
+ PropAccess access = Mockito.mock(PropAccess.class);
+ Mockito.doReturn(access).when(env).access();
+ Mockito.doReturn(trans).when(env).newTransNoAvg();
+ Mockito.doReturn("20").when(access).getProperty(Config.CADI_LATITUDE,null);
+ Mockito.doReturn("20").when(access).getProperty(Config.CADI_LONGITUDE,null);
+ Mockito.doReturn("20").when(access).getProperty(Config.AAF_LOCATOR_CONTAINER,"");
+ Mockito.doReturn("http://aafurl.com").when(access).getProperty(Config.AAF_URL,null);
+ try {
+ aafLocatorObj = new DirectAAFLocator(env, ldao,"test","30.20.30.30");
+ } catch (LocatorException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ Result<List<Data>> retVal1 = new Result<List<Data>>(null,1,"",new String[0]);
+
+ Mockito.doReturn(retVal1).when(ldao).readByName(trans,"test");
+ boolean retVal = aafLocatorObj.refresh();
+// System.out.println(retVal);
+ assertFalse(retVal);
+ }
+
} \ No newline at end of file
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLur.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLur.java
new file mode 100644
index 00000000..05077438
--- /dev/null
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLur.java
@@ -0,0 +1,243 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ *
+ */
+package org.onap.aaf.auth.direct.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.aaf.auth.dao.cass.NsSplit;
+import org.onap.aaf.auth.dao.cass.PermDAO;
+import org.onap.aaf.auth.dao.cass.PermDAO.Data;
+import org.onap.aaf.auth.dao.hl.Question;
+import org.onap.aaf.auth.direct.DirectAAFLur;
+import org.onap.aaf.auth.direct.DirectAAFLur.PermPermission;
+import org.onap.aaf.auth.env.AuthzEnv;
+import org.onap.aaf.auth.env.AuthzTrans;
+import org.onap.aaf.auth.env.AuthzTransImpl;
+import org.onap.aaf.auth.env.NullTrans;
+import org.onap.aaf.auth.layer.Result;
+import org.onap.aaf.cadi.Permission;
+import org.onap.aaf.cadi.aaf.AAFPermission;
+import org.onap.aaf.cadi.lur.LocalPermission;
+import org.onap.aaf.misc.env.LogTarget;
+import org.onap.aaf.misc.env.Trans;
+
+@RunWith(MockitoJUnitRunner.class)
+public class JU_DirectAAFLur {
+
+ @Mock
+ AuthzEnv env;
+
+ @Mock
+ Question question;
+
+ @Mock
+ Principal bait;
+
+ @Mock
+ Permission pond;
+
+ @Mock
+ AuthzTrans trans;
+
+ @Before
+ public void setUp() throws Exception {
+ initMocks(this);
+ Mockito.when(env.newTransNoAvg()).thenReturn(trans);
+ Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).error();
+ }
+
+ public void testFish() {
+ DirectAAFLur aafLurObj = new DirectAAFLur(env, question);
+
+ List<PermDAO.Data> rsVal = new ArrayList<PermDAO.Data>();
+ Result<List<Data>> rs = new Result<List<Data>>(rsVal,0,"test",new Object[0]);
+ Mockito.when(question.getPermsByUser(env.newTransNoAvg(), bait.getName(), false)).thenReturn(rs);
+ aafLurObj.fish(bait, pond);
+ }
+
+ @Test
+ public void testFishSecondMtd() {
+ DirectAAFLur aafLurObj = new DirectAAFLur(env, question);
+
+ List<PermDAO.Data> rsVal = new ArrayList<PermDAO.Data>();
+ PermDAO.Data pd = new PermDAO.Data();
+ pd.ns = "ns";
+ pd.type = "name";
+ pd.instance = null;
+ rsVal.add(pd);
+ pd = new PermDAO.Data();
+ pd.ns = "ns";
+ pd.type = "name";
+ pd.instance = "instance";
+ pd.action = null;
+ rsVal.add(pd);
+
+ pd = new PermDAO.Data();
+ pd.ns = "ns";
+ pd.type = "name";
+ pd.instance = "instance1";
+ rsVal.add(pd);
+ pd = new PermDAO.Data();
+ pd.ns = "ns1";
+ pd.type = "name";
+ rsVal.add(pd);
+ pd = new PermDAO.Data();
+ pd.ns = "ns";
+ pd.type = "name1";
+ rsVal.add(pd);
+
+ pd = new PermDAO.Data();
+ pd.ns = "ns";
+ pd.type = "name";
+ pd.instance = "instance";
+ pd.action = "action";
+ rsVal.add(pd);
+
+ pond = new DirectAAFLur.PermPermission("ns", "name", "instance", "action");
+
+ Result<List<Data>> rs = new Result<List<Data>>(rsVal,0,"test",new Object[0]);
+ Mockito.when(question.getPermsByUser(env.newTransNoAvg(), bait.getName(), false)).thenReturn(rs);
+ aafLurObj.fish(bait, pond);
+
+ pond = new AAFPermission("ns", "name", "instance", "action");
+
+ Mockito.when(question.getPermsByUser(env.newTransNoAvg(), bait.getName(), false)).thenReturn(rs);
+ aafLurObj.fish(bait, pond);
+
+ rs = new Result<List<Data>>(rsVal,1,"test",new Object[0]);
+ Mockito.when(question.getPermsByUser(env.newTransNoAvg(), bait.getName(), false)).thenReturn(rs);
+ aafLurObj.fish(bait, pond);
+ rs = new Result<List<Data>>(rsVal,4,"test",new Object[0]);
+ Mockito.when(question.getPermsByUser(env.newTransNoAvg(), bait.getName(), false)).thenReturn(rs);
+ aafLurObj.fish(bait, pond);
+ rs = new Result<List<Data>>(rsVal,25,"test",new Object[0]);
+ Mockito.when(question.getPermsByUser(env.newTransNoAvg(), bait.getName(), false)).thenReturn(rs);
+ aafLurObj.fish(bait, pond);
+ }
+
+ @Test
+ public void testFishAll() {
+ Mockito.doReturn(Mockito.mock(LogTarget.class)).when(env).error();
+ DirectAAFLur aafLurObj = new DirectAAFLur(env, question);
+
+ List<PermDAO.Data> rsVal = new ArrayList<PermDAO.Data>();
+ PermDAO.Data pd = new PermDAO.Data();
+ pd.ns = "ns";
+ pd.type = "name";
+ pd.instance = null;
+ rsVal.add(pd);
+
+ pond = new DirectAAFLur.PermPermission("ns", "name", "instance", "action");
+ List<Permission> permissions = new ArrayList<>();
+ permissions.add(pond);
+
+ Result<List<Data>> rs = new Result<List<Data>>(rsVal,0,"test",new Object[0]);
+ Mockito.when(question.getPermsByUser(env.newTrans(), bait.getName(), false)).thenReturn(rs);
+ aafLurObj.fishAll(bait, permissions);
+ assertTrue(permissions.size() == 2);
+
+ rs = new Result<List<Data>>(rsVal,1,"test",new Object[0]);
+ Mockito.when(question.getPermsByUser(env.newTrans(), bait.getName(), false)).thenReturn(rs);
+ aafLurObj.fishAll(bait, permissions);
+ }
+
+ @Test
+ public void testDestroy() {
+ DirectAAFLur aafLurObj = new DirectAAFLur(env, question);
+ aafLurObj.destroy();
+ }
+
+ @Test
+ public void testHandlesExclusively() {
+ DirectAAFLur aafLurObj = new DirectAAFLur(env, question);
+ pond = new DirectAAFLur.PermPermission("ns", "name", "instance", "action");
+ assertFalse(aafLurObj.handlesExclusively(pond));
+ }
+
+ @Test
+ public void testToString() {
+ DirectAAFLur aafLurObj = new DirectAAFLur(env, question);
+ assertTrue(aafLurObj.toString().contains("DirectAAFLur is enabled"));
+ }
+
+ @Test
+ public void testHandles() {
+ DirectAAFLur aafLurObj = new DirectAAFLur(env, question);
+ assertTrue(aafLurObj.handles(null));
+ }
+
+ @Test
+ public void testCreatePerm() {
+ DirectAAFLur aafLurObj = new DirectAAFLur(env, question);
+ Permission retVal = aafLurObj.createPerm("test");
+ assertTrue(retVal instanceof LocalPermission);
+
+ NsSplit nss = new NsSplit("test", "test");
+ Result<NsSplit> rs = new Result<NsSplit>(nss,0,"test",new Object[0]);
+ Mockito.when(question.deriveNsSplit(NullTrans.singleton() , "test")).thenReturn(rs);
+ retVal = aafLurObj.createPerm("test|1|2");
+ assertTrue(retVal instanceof PermPermission);
+
+ rs = new Result<NsSplit>(null,1,"test",new Object[0]);
+ Mockito.when(question.deriveNsSplit(NullTrans.singleton() , "test")).thenReturn(rs);
+ retVal = aafLurObj.createPerm("test|1|2");
+ assertTrue(retVal instanceof LocalPermission);
+ }
+
+ @Test
+ public void testClear() {
+ AuthzTransImpl trans = Mockito.mock(AuthzTransImpl.class);
+ Mockito.when(env.newTrans()).thenReturn(trans);
+ DirectAAFLur aafLurObj = new DirectAAFLur(env, question);
+ StringBuilder sb = new StringBuilder();
+ Mockito.when(trans.auditTrail(0, sb)).thenReturn(Mockito.mock(Trans.Metric.class));
+ aafLurObj.clear(bait, sb);
+ }
+
+ @Test
+ public void testPermPermission() {
+ AuthzTransImpl trans = Mockito.mock(AuthzTransImpl.class);
+ NsSplit nss = new NsSplit("test", "test");
+ Result<NsSplit> rs = new Result<NsSplit>(nss,0,"test",new Object[0]);
+ Mockito.when(question.deriveNsSplit(trans , "test")).thenReturn(rs);
+ PermPermission pp = new PermPermission(trans, question, "test|test|test|test");
+
+ assertTrue("test".equalsIgnoreCase(pp.getKey()));
+ assertTrue("AAFLUR".equalsIgnoreCase(pp.permType()));
+
+ assertFalse(pp.match(null));
+
+ pond = new AAFPermission("null.test", "name", "instance", "action");
+ pp.match(pond);
+ }
+}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectLocatorCreator.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectLocatorCreator.java
new file mode 100644
index 00000000..c2b8597b
--- /dev/null
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectLocatorCreator.java
@@ -0,0 +1,88 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ *
+ */
+package org.onap.aaf.auth.direct.test;
+
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.aaf.auth.dao.cass.LocateDAO;
+import org.onap.aaf.auth.direct.DirectLocatorCreator;
+import org.onap.aaf.auth.env.AuthzEnv;
+import org.onap.aaf.cadi.LocatorException;
+import org.onap.aaf.cadi.PropAccess;
+import org.onap.aaf.cadi.config.Config;
+
+@RunWith(MockitoJUnitRunner.class)
+public class JU_DirectLocatorCreator {
+
+ @Mock
+ AuthzEnv env;
+
+ @Mock
+ LocateDAO locateDAO;
+
+ @Mock
+ PropAccess access;
+
+ @Before
+ public void setUp() throws Exception {
+ initMocks(this);
+ }
+
+ @Test
+ public void testCreate() {
+ Mockito.doReturn(access).when(env).access();
+ Mockito.doReturn("20").when(access).getProperty(Config.CADI_LATITUDE,null);
+ Mockito.doReturn("20").when(access).getProperty(Config.CADI_LONGITUDE,null);
+ Mockito.doReturn("20").when(access).getProperty(Config.AAF_LOCATOR_CONTAINER,"");
+ Mockito.doReturn("http://aafurl.com").when(access).getProperty(Config.AAF_URL,null);
+ DirectLocatorCreator directLocObj = new DirectLocatorCreator(env, locateDAO);
+ try {
+ directLocObj.create("test", "30.20.30.20");
+ } catch (LocatorException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ directLocObj.setSelf("30.20.30.10", 8080);
+ try {
+ directLocObj.create("test", "30.20.30.20");
+ } catch (LocatorException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testSetSelf() {
+ Mockito.doReturn(access).when(env).access();
+ Mockito.doReturn("20").when(access).getProperty(Config.CADI_LATITUDE,null);
+ Mockito.doReturn("20").when(access).getProperty(Config.CADI_LONGITUDE,null);
+ Mockito.doReturn("20").when(access).getProperty(Config.AAF_LOCATOR_CONTAINER,"");
+ Mockito.doReturn("http://aafurl.com").when(access).getProperty(Config.AAF_URL,null);
+ DirectLocatorCreator directLocObj = new DirectLocatorCreator(env, locateDAO);
+ directLocObj.setSelf("30.20.30.10", 8080);
+ }
+}