fixed testcase for creating mongodb in account 57/20357/2
authorJung Seungho <shonest.jung@samsung.com>
Wed, 24 May 2017 08:16:16 +0000 (17:16 +0900)
committerJee Hyeok Kim <jihyeok13.kim@samsung.com>
Wed, 24 May 2017 08:41:14 +0000 (08:41 +0000)
Change-Id: Ic391d7315225d04fd39a414d1400c2b8f5d24178
Signed-off-by: Jung Seungho <shonest.jung@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/20357
Reviewed-by: Jee Hyeok Kim <jihyeok13.kim@samsung.com>
Tested-by: Jee Hyeok Kim <jihyeok13.kim@samsung.com>
cloud/account/src/main/java/org/iotivity/cloud/accountserver/db/MongoDB.java
cloud/account/src/test/java/org/iotivity/cloud/accountserver/resources/account/AccountResourceTest.java
cloud/account/src/test/java/org/iotivity/cloud/accountserver/resources/account/session/SessionResourceTest.java
cloud/account/src/test/java/org/iotivity/cloud/accountserver/resources/account/tokenrefresh/TokenRefreshResourceTest.java
cloud/account/src/test/java/org/iotivity/cloud/accountserver/resources/acl/group/GroupAclManagerTest.java
cloud/account/src/test/java/org/iotivity/cloud/accountserver/resources/acl/group/GroupBrokerTest.java
cloud/account/src/test/java/org/iotivity/cloud/accountserver/resources/acl/group/GroupResourceTest.java
cloud/account/src/test/java/org/iotivity/cloud/accountserver/resources/acl/id/AclIdResourceTest.java
cloud/account/src/test/java/org/iotivity/cloud/accountserver/resources/acl/invite/InviteResourceTest.java
cloud/account/src/test/java/org/iotivity/cloud/accountserver/resources/acl/verify/AclVerifyResourceTest.java

index 69862e8..83dfb78 100644 (file)
@@ -21,7 +21,6 @@
  */
 package org.iotivity.cloud.accountserver.db;
 
-import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -50,19 +49,6 @@ public class MongoDB {
     private MongoClient   mongoClient = null;
     private MongoDatabase db          = null;
 
-    /**
-     * API creating MongoClient and initializing MongoDatabase
-     *
-     * @param dbname
-     *            database name to create MongoDatabase
-     * @throws Exception
-     */
-    public MongoDB(String dbname) throws Exception {
-        mongoClient = new MongoClient(InetAddress.getLocalHost().getHostAddress());
-        mongoClient.dropDatabase(dbname);
-        db = mongoClient.getDatabase(dbname);
-    }
-
     /**
      * API creating MongoClient and initializing MongoDatabase
      *
index 43ec371..6fbc4f8 100644 (file)
@@ -112,7 +112,7 @@ public class AccountResourceTest {
 
     @After
     public void resetAccountDatabase() throws Exception {
-        MongoDB mongoDB = new MongoDB(Constants.DB_NAME);
+        MongoDB mongoDB = new MongoDB("127.0.0.1", Constants.DB_NAME);
         mongoDB.createTable(Constants.USER_TABLE);
         mongoDB.createTable(Constants.TOKEN_TABLE);
         mongoDB.createTable(Constants.GROUP_TABLE);
index 5224f76..affb5b9 100644 (file)
@@ -106,7 +106,7 @@ public class SessionResourceTest {
 
     @After
     public void resetAccountDatabase() throws Exception {
-        MongoDB mongoDB = new MongoDB(Constants.DB_NAME);
+        MongoDB mongoDB = new MongoDB("127.0.0.1", Constants.DB_NAME);
         mongoDB.createTable(Constants.USER_TABLE);
         mongoDB.createTable(Constants.TOKEN_TABLE);
         mongoDB.createTable(Constants.GROUP_TABLE);
@@ -362,7 +362,7 @@ public class SessionResourceTest {
     }
 
     private void resetDB() throws Exception {
-        MongoDB mongoDB = new MongoDB(Constants.DB_NAME);
+        MongoDB mongoDB = new MongoDB("127.0.0.1", Constants.DB_NAME);
         mongoDB.deleteTable(Constants.GROUP_TABLE);
         mongoDB.createTable(Constants.GROUP_TABLE);
         mongoDB.deleteTable(Constants.USER_TABLE);
index 2d1df31..f9e0f35 100644 (file)
@@ -64,7 +64,7 @@ public class TokenRefreshResourceTest {
 
     @After
     public void resetAccountDatabase() throws Exception {
-        MongoDB mongoDB = new MongoDB(Constants.DB_NAME);
+        MongoDB mongoDB = new MongoDB("127.0.0.1", Constants.DB_NAME);
         mongoDB.createTable(Constants.USER_TABLE);
         mongoDB.createTable(Constants.TOKEN_TABLE);
         mongoDB.createTable(Constants.GROUP_TABLE);
index abc52cc..bf66e30 100644 (file)
@@ -83,7 +83,7 @@ public class GroupAclManagerTest {
         AclResource.getInstance().deleteAcl((String) AclResource.getInstance()
                 .getAclid(mDi2).get(Constants.KEYFIELD_ACLID));
 
-        MongoDB mongoDB = new MongoDB(Constants.DB_NAME);
+        MongoDB mongoDB = new MongoDB("127.0.0.1", Constants.DB_NAME);
         mongoDB.deleteTable(Constants.GROUP_TABLE);
         mongoDB.createTable(Constants.GROUP_TABLE);
         mongoDB.deleteTable(Constants.ACL_TABLE);
index 72e2cf5..9ae1935 100644 (file)
@@ -78,7 +78,7 @@ public class GroupBrokerTest {
 
     @After
     public void resetAccountDatabase() throws Exception {
-        MongoDB mongoDB = new MongoDB(Constants.DB_NAME);
+        MongoDB mongoDB = new MongoDB("127.0.0.1", Constants.DB_NAME);
         mongoDB.createTable(Constants.USER_TABLE);
         mongoDB.createTable(Constants.TOKEN_TABLE);
         mongoDB.createTable(Constants.GROUP_TABLE);
@@ -189,7 +189,7 @@ public class GroupBrokerTest {
     }
 
     private void resetDB() throws Exception {
-        MongoDB mongoDB = new MongoDB(Constants.DB_NAME);
+        MongoDB mongoDB = new MongoDB("127.0.0.1", Constants.DB_NAME);
         mongoDB.deleteTable(Constants.GROUP_TABLE);
         mongoDB.createTable(Constants.GROUP_TABLE);
         mongoDB.deleteTable(Constants.USER_TABLE);
index 325a498..06304b1 100644 (file)
@@ -108,7 +108,7 @@ public class GroupResourceTest {
 
     @After
     public void resetAccountDatabase() throws Exception {
-        MongoDB mongoDB = new MongoDB(Constants.DB_NAME);
+        MongoDB mongoDB = new MongoDB("127.0.0.1", Constants.DB_NAME);
         mongoDB.deleteTable(Constants.USER_TABLE);
         mongoDB.createTable(Constants.USER_TABLE);
         mongoDB.deleteTable(Constants.TOKEN_TABLE);
@@ -824,7 +824,7 @@ public class GroupResourceTest {
     }
 
     public void resetDB() throws Exception {
-        MongoDB mongoDB = new MongoDB(Constants.DB_NAME);
+        MongoDB mongoDB = new MongoDB("127.0.0.1", Constants.DB_NAME);
         mongoDB.deleteTable(Constants.GROUP_TABLE);
         mongoDB.createTable(Constants.GROUP_TABLE);
         mongoDB.deleteTable(Constants.USER_TABLE);
index 0f0d203..70f835f 100644 (file)
@@ -53,24 +53,26 @@ import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 
 public class AclIdResourceTest {
-    private static final String ACL_ID_URI = Constants.ACL_ID_FULL_URI;
-    final CountDownLatch mLatch = new CountDownLatch(1);
-    private final String mDeviceUuid = "9cfbeb8e-5a1e-4d1c-9d01-2ae6fdb";
-    private final String mOwnerUuid = "123e4567-e89b-12d3-a456-4266554";
-    private final String mSubjectUuid = "72616E64-5069-6E44-6576-5575696";
-    private final int mSubjectType = 0;
-    private final int mPermission = 6;
-    private final int mSubjectTypeUpdate = 1;
-    private final int mPermissionUpdate = 7;
-    private final String mResourceUri = "/a/light/0";
-    private final String mResourceType = "core.light";
-    private final String mResourceIf = "oic.if.baseline";
-    private String mAceId = "a0001";
-    private String mAclId = "987e6543-e21b-12d3-a456-4266554";
-    private CoapDevice mMockDevice = Mockito.mock(CoapDevice.class);
-    private Cbor<HashMap<String, Object>> mCbor = new Cbor<>();
-    private IResponse mResponse = null;
-    private AclResource mAclResource = new AclResource();
+    private static final String           ACL_ID_URI         = Constants.ACL_ID_FULL_URI;
+    final CountDownLatch                  mLatch             = new CountDownLatch(
+            1);
+    private final String                  mDeviceUuid        = "9cfbeb8e-5a1e-4d1c-9d01-2ae6fdb";
+    private final String                  mOwnerUuid         = "123e4567-e89b-12d3-a456-4266554";
+    private final String                  mSubjectUuid       = "72616E64-5069-6E44-6576-5575696";
+    private final int                     mSubjectType       = 0;
+    private final int                     mPermission        = 6;
+    private final int                     mSubjectTypeUpdate = 1;
+    private final int                     mPermissionUpdate  = 7;
+    private final String                  mResourceUri       = "/a/light/0";
+    private final String                  mResourceType      = "core.light";
+    private final String                  mResourceIf        = "oic.if.baseline";
+    private String                        mAceId             = "a0001";
+    private String                        mAclId             = "987e6543-e21b-12d3-a456-4266554";
+    private CoapDevice                    mMockDevice        = Mockito
+            .mock(CoapDevice.class);
+    private Cbor<HashMap<String, Object>> mCbor              = new Cbor<>();
+    private IResponse                     mResponse          = null;
+    private AclResource                   mAclResource       = new AclResource();
 
     @Before
     public void setUp() throws Exception {
@@ -79,14 +81,18 @@ public class AclIdResourceTest {
         resetDB();
         Mockito.doAnswer(new Answer<Object>() {
             @Override
-            public CoapResponse answer(InvocationOnMock invocation) throws Throwable {
+            public CoapResponse answer(InvocationOnMock invocation)
+                    throws Throwable {
                 Object[] args = invocation.getArguments();
                 CoapResponse resp = (CoapResponse) args[0];
-                System.out.println("\t----------payload : " + resp.getPayloadString());
+                System.out.println(
+                        "\t----------payload : " + resp.getPayloadString());
                 System.out.println("\t---------method : " + resp.getStatus());
                 mResponse = resp;
                 if (mAclId == null) {
-                    HashMap<String, Object> payloadData = mCbor.parsePayloadFromCbor(resp.getPayload(), HashMap.class);
+                    HashMap<String, Object> payloadData = mCbor
+                            .parsePayloadFromCbor(resp.getPayload(),
+                                    HashMap.class);
                     if (payloadData.containsKey("aclid")) {
                         mAclId = (String) payloadData.get("aclid");
                     }
@@ -99,7 +105,7 @@ public class AclIdResourceTest {
 
     @After
     public void resetAccountDatabase() throws Exception {
-        MongoDB mongoDB = new MongoDB(Constants.DB_NAME);
+        MongoDB mongoDB = new MongoDB("127.0.0.1", Constants.DB_NAME);
         mongoDB.createTable(Constants.USER_TABLE);
         mongoDB.createTable(Constants.ACL_TABLE);
         mongoDB.createTable(Constants.TOKEN_TABLE);
@@ -184,7 +190,8 @@ public class AclIdResourceTest {
         assertTrue(mLatch.await(2L, SECONDS));
     }
 
-    private void createAclId(CoapDevice device, String di, String oid) throws Exception {
+    private void createAclId(CoapDevice device, String di, String oid)
+            throws Exception {
         System.out.println("-----Create Acl Id");
         IRequest request = null;
         request = createAclIdRequest(oid, di);
@@ -212,21 +219,24 @@ public class AclIdResourceTest {
         mAclResource.onDefaultRequestReceived(device, request);
     }
 
-    private void addIndividualAce(CoapDevice device, String aclId) throws Exception {
+    private void addIndividualAce(CoapDevice device, String aclId)
+            throws Exception {
         System.out.println("-----Add Individual Ace");
         IRequest request = null;
         request = addIndividualAceRequest(aclId);
         mAclResource.onDefaultRequestReceived(device, request);
     }
 
-    private void updateIndividualAce(CoapDevice device, String aclId, String aceId) throws Exception {
+    private void updateIndividualAce(CoapDevice device, String aclId,
+            String aceId) throws Exception {
         System.out.println("-----Update Individual Acl Ace");
         IRequest request = null;
         request = updateIndividualAceRequest(aclId, aceId);
         mAclResource.onDefaultRequestReceived(device, request);
     }
 
-    private void deleteIndividualAclAce(CoapDevice device, String aclId, String aceId) throws Exception {
+    private void deleteIndividualAclAce(CoapDevice device, String aclId,
+            String aceId) throws Exception {
         System.out.println("-----Delete Individual Acl Ace");
         IRequest request = null;
         request = deleteIndividualAclAceRequest(aclId, aceId);
@@ -235,27 +245,32 @@ public class AclIdResourceTest {
 
     private IRequest getAclIdRequest(String deviceUuid) {
         IRequest request = null;
-        request = MessageBuilder.createRequest(RequestMethod.GET, ACL_ID_URI, "di=" + deviceUuid);
+        request = MessageBuilder.createRequest(RequestMethod.GET, ACL_ID_URI,
+                "di=" + deviceUuid);
         ((CoapRequest) request).setObserve(Observe.SUBSCRIBE);
         return request;
     }
 
     private IRequest createAclIdRequest(String oid, String di) {
         IRequest request = null;
-        String uriQuery = Constants.REQ_OWNER_ID + "=" + oid + ";" + Constants.REQ_DEVICE_ID + "=" + di;
-        request = MessageBuilder.createRequest(RequestMethod.PUT, ACL_ID_URI, uriQuery);
+        String uriQuery = Constants.REQ_OWNER_ID + "=" + oid + ";"
+                + Constants.REQ_DEVICE_ID + "=" + di;
+        request = MessageBuilder.createRequest(RequestMethod.PUT, ACL_ID_URI,
+                uriQuery);
         return request;
     }
 
     private IRequest deleteAclIdRequest(String aclId) {
         IRequest request = null;
-        request = MessageBuilder.createRequest(RequestMethod.DELETE, ACL_ID_URI, "aclid=" + aclId);
+        request = MessageBuilder.createRequest(RequestMethod.DELETE, ACL_ID_URI,
+                "aclid=" + aclId);
         return request;
     }
 
     private IRequest getIndividualAclRequest(String aclId) {
         IRequest request = null;
-        request = MessageBuilder.createRequest(RequestMethod.GET, ACL_ID_URI + "/" + aclId, null);
+        request = MessageBuilder.createRequest(RequestMethod.GET,
+                ACL_ID_URI + "/" + aclId, null);
         ((CoapRequest) request).setObserve(Observe.NOTHING);
         return request;
     }
@@ -283,8 +298,9 @@ public class AclIdResourceTest {
         HashMap<String, Object> payload = new HashMap<>();
         payload.put(Constants.REQ_ACL_LIST, Arrays.asList(acelist));
 
-        return MessageBuilder.createRequest(RequestMethod.POST, ACL_ID_URI + "/" + aclId, null,
-                ContentFormat.APPLICATION_CBOR, mCbor.encodingPayloadToCbor(payload));
+        return MessageBuilder.createRequest(RequestMethod.POST,
+                ACL_ID_URI + "/" + aclId, null, ContentFormat.APPLICATION_CBOR,
+                mCbor.encodingPayloadToCbor(payload));
     }
 
     private IRequest updateIndividualAceRequest(String aclId, String aceId) {
@@ -310,18 +326,22 @@ public class AclIdResourceTest {
         HashMap<String, Object> payload = new HashMap<>();
         payload.put(Constants.REQ_ACL_LIST, Arrays.asList(acelist));
 
-        return MessageBuilder.createRequest(RequestMethod.POST, ACL_ID_URI + "/" + aclId, "aceid=" + aceId,
-                ContentFormat.APPLICATION_CBOR, mCbor.encodingPayloadToCbor(payload));
+        return MessageBuilder.createRequest(RequestMethod.POST,
+                ACL_ID_URI + "/" + aclId, "aceid=" + aceId,
+                ContentFormat.APPLICATION_CBOR,
+                mCbor.encodingPayloadToCbor(payload));
     }
 
     private IRequest deleteIndividualAclAceRequest(String aclId, String aceId) {
         IRequest request = null;
-        request = MessageBuilder.createRequest(RequestMethod.DELETE, ACL_ID_URI + "/" + aclId, "aceid=" + aceId);
+        request = MessageBuilder.createRequest(RequestMethod.DELETE,
+                ACL_ID_URI + "/" + aclId, "aceid=" + aceId);
         return request;
     }
 
     private void hashmapGetAclId(IResponse response, String propertyName) {
-        HashMap<String, Object> payloadData = mCbor.parsePayloadFromCbor(response.getPayload(), HashMap.class);
+        HashMap<String, Object> payloadData = mCbor
+                .parsePayloadFromCbor(response.getPayload(), HashMap.class);
         if (payloadData.containsKey(propertyName)) {
 
             mAclId = (String) payloadData.get(propertyName);
@@ -330,16 +350,19 @@ public class AclIdResourceTest {
     }
 
     private void hashmapGetAceId(IResponse response, String propertyName) {
-        HashMap<String, Object> payloadData = mCbor.parsePayloadFromCbor(response.getPayload(), HashMap.class);
+        HashMap<String, Object> payloadData = mCbor
+                .parsePayloadFromCbor(response.getPayload(), HashMap.class);
         if (payloadData.containsKey("aclist")) {
-            List<HashMap<String, Object>> aclist = (List<HashMap<String, Object>>) payloadData.get("aclist");
+            List<HashMap<String, Object>> aclist = (List<HashMap<String, Object>>) payloadData
+                    .get("aclist");
             mAceId = (String) aclist.get(0).get(propertyName);
             System.out.println("hashmapGetAceId getace " + mAceId);
         }
     }
 
     private boolean hashmapCheck(IResponse response, String propertyName) {
-        HashMap<String, Object> payloadData = mCbor.parsePayloadFromCbor(response.getPayload(), HashMap.class);
+        HashMap<String, Object> payloadData = mCbor
+                .parsePayloadFromCbor(response.getPayload(), HashMap.class);
         if (payloadData.containsKey(propertyName)) {
             return true;
         } else {
@@ -347,7 +370,8 @@ public class AclIdResourceTest {
         }
     }
 
-    private boolean methodCheck(IResponse response, ResponseStatus responseStatus) {
+    private boolean methodCheck(IResponse response,
+            ResponseStatus responseStatus) {
         if (responseStatus == response.getStatus()) {
             return true;
         } else {
@@ -362,7 +386,7 @@ public class AclIdResourceTest {
     }
 
     public void resetDB() throws Exception {
-        MongoDB mongoDB = new MongoDB(Constants.DB_NAME);
+        MongoDB mongoDB = new MongoDB("127.0.0.1", Constants.DB_NAME);
         mongoDB.deleteTable(Constants.GROUP_TABLE);
         mongoDB.createTable(Constants.GROUP_TABLE);
         mongoDB.deleteTable(Constants.ACL_TABLE);
index faa4cc1..080bddd 100644 (file)
@@ -85,7 +85,7 @@ public class InviteResourceTest {
         mResponse = null;
 
         // reset data base
-        MongoDB mongoDB = new MongoDB(Constants.DB_NAME);
+        MongoDB mongoDB = new MongoDB("127.0.0.1", Constants.DB_NAME);
         mongoDB.deleteTable(Constants.INVITE_TABLE);
         mongoDB.createTable(Constants.INVITE_TABLE);
 
index acdcae3..820c777 100644 (file)
@@ -34,7 +34,6 @@ import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.db.MongoDB;
 import org.iotivity.cloud.accountserver.resources.acl.id.AclResource;
 import org.iotivity.cloud.base.device.CoapDevice;
-
 import org.iotivity.cloud.base.protocols.IRequest;
 import org.iotivity.cloud.base.protocols.IResponse;
 import org.iotivity.cloud.base.protocols.MessageBuilder;
@@ -54,24 +53,26 @@ import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 
 public class AclVerifyResourceTest {
-    private static final String ACL_ID_URI = Constants.ACL_ID_FULL_URI;
-    private static final String ACL_VERIFY_URI = Constants.ACL_VERIFY_FULL_URI;
-    final CountDownLatch mLatch = new CountDownLatch(1);
-    private final String mDeviceUuid = "9cfbeb8e-5a1e-4d1c-9d01-2ae6fdb";
-    private final String mOwnerUuid = "123e4567-e89b-12d3-a456-4266554";
-    private final String mSubjectUuid = "72616E64-5069-6E44-6576-5575696";
-    private final String mRmType = "POST";
-    private final int mSubjectType = 1;
-    private final int mPermission = 7;
-    private final String mResourceUri = "/a/light/0";
-    private final String mResourceType = "core.light";
-    private final String mResourceIf = "oic.if.baseline";
-    private String mAclId = "987e6543-e21b-12d3-a456-4266554";
-    private CoapDevice mMockDevice = Mockito.mock(CoapDevice.class);
-    private Cbor<HashMap<String, Object>> mCbor = new Cbor<>();
-    private IResponse mResponse = null;
-    private AclVerifyResource mAclVerifyResource = new AclVerifyResource();
-    private AclResource mAclResource = new AclResource();
+    private static final String           ACL_ID_URI         = Constants.ACL_ID_FULL_URI;
+    private static final String           ACL_VERIFY_URI     = Constants.ACL_VERIFY_FULL_URI;
+    final CountDownLatch                  mLatch             = new CountDownLatch(
+            1);
+    private final String                  mDeviceUuid        = "9cfbeb8e-5a1e-4d1c-9d01-2ae6fdb";
+    private final String                  mOwnerUuid         = "123e4567-e89b-12d3-a456-4266554";
+    private final String                  mSubjectUuid       = "72616E64-5069-6E44-6576-5575696";
+    private final String                  mRmType            = "POST";
+    private final int                     mSubjectType       = 1;
+    private final int                     mPermission        = 7;
+    private final String                  mResourceUri       = "/a/light/0";
+    private final String                  mResourceType      = "core.light";
+    private final String                  mResourceIf        = "oic.if.baseline";
+    private String                        mAclId             = "987e6543-e21b-12d3-a456-4266554";
+    private CoapDevice                    mMockDevice        = Mockito
+            .mock(CoapDevice.class);
+    private Cbor<HashMap<String, Object>> mCbor              = new Cbor<>();
+    private IResponse                     mResponse          = null;
+    private AclVerifyResource             mAclVerifyResource = new AclVerifyResource();
+    private AclResource                   mAclResource       = new AclResource();
 
     @Before
     public void setUp() throws Exception {
@@ -80,14 +81,18 @@ public class AclVerifyResourceTest {
         resetDB();
         Mockito.doAnswer(new Answer<Object>() {
             @Override
-            public CoapResponse answer(InvocationOnMock invocation) throws Throwable {
+            public CoapResponse answer(InvocationOnMock invocation)
+                    throws Throwable {
                 Object[] args = invocation.getArguments();
                 CoapResponse resp = (CoapResponse) args[0];
-                System.out.println("\t----------payload : " + resp.getPayloadString());
+                System.out.println(
+                        "\t----------payload : " + resp.getPayloadString());
                 System.out.println("\t---------method : " + resp.getStatus());
                 mResponse = resp;
                 if (mAclId == null) {
-                    HashMap<String, Object> payloadData = mCbor.parsePayloadFromCbor(resp.getPayload(), HashMap.class);
+                    HashMap<String, Object> payloadData = mCbor
+                            .parsePayloadFromCbor(resp.getPayload(),
+                                    HashMap.class);
                     if (payloadData.containsKey("aclid")) {
                         mAclId = (String) payloadData.get("aclid");
                     }
@@ -100,7 +105,7 @@ public class AclVerifyResourceTest {
 
     @After
     public void resetAccountDatabase() throws Exception {
-        MongoDB mongoDB = new MongoDB(Constants.DB_NAME);
+        MongoDB mongoDB = new MongoDB("127.0.0.1", Constants.DB_NAME);
         mongoDB.createTable(Constants.USER_TABLE);
         mongoDB.createTable(Constants.ACL_TABLE);
         mongoDB.createTable(Constants.TOKEN_TABLE);
@@ -113,13 +118,15 @@ public class AclVerifyResourceTest {
         createAclId(mMockDevice, mDeviceUuid, mOwnerUuid);
         hashmapGetAclId(mResponse, "aclid");
         addIndividualAce(mMockDevice, mAclId);
-        verifyAcl(mMockDevice, mSubjectUuid, mDeviceUuid, mRmType, mResourceUri);
+        verifyAcl(mMockDevice, mSubjectUuid, mDeviceUuid, mRmType,
+                mResourceUri);
         assertTrue(methodCheck(mResponse, ResponseStatus.CONTENT));
         assertTrue(hashmapCheck(mResponse, "gp"));
         assertTrue(mLatch.await(2L, SECONDS));
     }
 
-    private void createAclId(CoapDevice device, String di, String oid) throws Exception {
+    private void createAclId(CoapDevice device, String di, String oid)
+            throws Exception {
         System.out.println("-----Create Acl Id");
         IRequest request = null;
         request = createAclIdRequest(oid, di);
@@ -128,12 +135,15 @@ public class AclVerifyResourceTest {
 
     private IRequest createAclIdRequest(String oid, String di) {
         IRequest request = null;
-        String uriQuery = Constants.REQ_OWNER_ID + "=" + oid + ";" + Constants.REQ_DEVICE_ID + "=" + di;
-        request = MessageBuilder.createRequest(RequestMethod.PUT, ACL_ID_URI, uriQuery);
+        String uriQuery = Constants.REQ_OWNER_ID + "=" + oid + ";"
+                + Constants.REQ_DEVICE_ID + "=" + di;
+        request = MessageBuilder.createRequest(RequestMethod.PUT, ACL_ID_URI,
+                uriQuery);
         return request;
     }
 
-    private void addIndividualAce(CoapDevice device, String aclId) throws Exception {
+    private void addIndividualAce(CoapDevice device, String aclId)
+            throws Exception {
         System.out.println("-----Add Individual Ace");
         IRequest request = null;
         request = addIndividualAceRequest(aclId);
@@ -163,28 +173,34 @@ public class AclVerifyResourceTest {
         HashMap<String, Object> payload = new HashMap<>();
         payload.put(Constants.REQ_ACL_LIST, Arrays.asList(acelist));
 
-        return MessageBuilder.createRequest(RequestMethod.POST, ACL_ID_URI + "/" + aclId, null,
-                ContentFormat.APPLICATION_CBOR, mCbor.encodingPayloadToCbor(payload));
+        return MessageBuilder.createRequest(RequestMethod.POST,
+                ACL_ID_URI + "/" + aclId, null, ContentFormat.APPLICATION_CBOR,
+                mCbor.encodingPayloadToCbor(payload));
     }
 
-    private void verifyAcl(CoapDevice device, String subjectUuid, String di, String rm, String uri) throws Exception {
+    private void verifyAcl(CoapDevice device, String subjectUuid, String di,
+            String rm, String uri) throws Exception {
         System.out.println("-----Verify Acl");
         IRequest request = null;
         request = verifyAclRequest(subjectUuid, di, rm, uri);
         mAclVerifyResource.onDefaultRequestReceived(device, request);
     }
 
-    private IRequest verifyAclRequest(String subjectUuid, String di, String rm, String uri) {
+    private IRequest verifyAclRequest(String subjectUuid, String di, String rm,
+            String uri) {
         IRequest request = null;
-        String queryUrl = "sid=" + subjectUuid + ";di=" + di + ";rm=" + rm + ";uri=" + uri;
+        String queryUrl = "sid=" + subjectUuid + ";di=" + di + ";rm=" + rm
+                + ";uri=" + uri;
         System.out.println(queryUrl);
-        request = MessageBuilder.createRequest(RequestMethod.GET, ACL_VERIFY_URI, queryUrl);
+        request = MessageBuilder.createRequest(RequestMethod.GET,
+                ACL_VERIFY_URI, queryUrl);
         ((CoapRequest) request).setObserve(Observe.SUBSCRIBE);
         return request;
     }
 
     private void hashmapGetAclId(IResponse response, String propertyName) {
-        HashMap<String, Object> payloadData = mCbor.parsePayloadFromCbor(response.getPayload(), HashMap.class);
+        HashMap<String, Object> payloadData = mCbor
+                .parsePayloadFromCbor(response.getPayload(), HashMap.class);
         if (payloadData.containsKey(propertyName)) {
 
             mAclId = (String) payloadData.get(propertyName);
@@ -193,7 +209,8 @@ public class AclVerifyResourceTest {
     }
 
     private boolean hashmapCheck(IResponse response, String propertyName) {
-        HashMap<String, Object> payloadData = mCbor.parsePayloadFromCbor(response.getPayload(), HashMap.class);
+        HashMap<String, Object> payloadData = mCbor
+                .parsePayloadFromCbor(response.getPayload(), HashMap.class);
         if (payloadData.containsKey(propertyName)) {
             return true;
         } else {
@@ -201,7 +218,8 @@ public class AclVerifyResourceTest {
         }
     }
 
-    private boolean methodCheck(IResponse response, ResponseStatus responseStatus) {
+    private boolean methodCheck(IResponse response,
+            ResponseStatus responseStatus) {
         if (responseStatus == response.getStatus()) {
             return true;
         } else {
@@ -216,7 +234,7 @@ public class AclVerifyResourceTest {
     }
 
     public void resetDB() throws Exception {
-        MongoDB mongoDB = new MongoDB(Constants.DB_NAME);
+        MongoDB mongoDB = new MongoDB("127.0.0.1", Constants.DB_NAME);
         mongoDB.deleteTable(Constants.GROUP_TABLE);
         mongoDB.createTable(Constants.GROUP_TABLE);
         mongoDB.deleteTable(Constants.ACL_TABLE);