Search in sources :

Example 81 with ClientException

use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.

the class AclAllFieldsSuperuser method test_144_ACLCreateSuperUser.

/**
   *
   */
@Test
public void test_144_ACLCreateSuperUser() {
    String superUserName = "superuser" + RandomString.randomString(12);
    try {
        try {
            clientCommands.lookupGuid(superUserName);
            Utils.failWithStackTrace(superUserName + " entity should not exist");
        } catch (ClientException e) {
        }
        superuserEntry = clientCommands.guidCreate(masterGuid, superUserName);
        try {
            Assert.assertEquals(superuserEntry.getGuid(), clientCommands.lookupGuid(superUserName));
        } catch (ClientException e) {
        }
    } catch (IOException | ClientException e) {
        Utils.failWithStackTrace("Exception when we were not expecting it in ACLALLFields: ", e);
    }
}
Also used : RandomString(edu.umass.cs.gnscommon.utils.RandomString) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) IOException(java.io.IOException) Test(org.junit.Test) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest)

Example 82 with ClientException

use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.

the class CreateGuidBatchTestWithPublicKeys method test_03_CheckBatch.

/**
   *
   */
@Test
public void test_03_CheckBatch() {
    try {
        JSONObject accountRecord = clientCommands.lookupAccountRecord(batchAccountGuid.getGuid());
        Assert.assertEquals(numberTocreate, accountRecord.getInt("guidCnt"));
    } catch (JSONException | ClientException | IOException e) {
        Utils.failWithStackTrace("Exception while fetching account record: " + e);
    }
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) IOException(java.io.IOException) Test(org.junit.Test) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest)

Example 83 with ClientException

use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.

the class CreateGuidTest method test_01_CreateEntity.

/**
   *
   */
@Test
public void test_01_CreateEntity() {
    String alias = "testGUID" + RandomString.randomString(12);
    GuidEntry guidEntry = null;
    try {
        guidEntry = clientCommands.guidCreate(masterGuid, alias);
    } catch (ClientException | IOException e) {
        Utils.failWithStackTrace("Exception while creating guid: " + e);
    }
    Assert.assertNotNull(guidEntry);
    Assert.assertEquals(alias, guidEntry.getEntityName());
    try {
        clientCommands.guidRemove(masterGuid, guidEntry.getGuid());
    } catch (ClientException | IOException e) {
        Utils.failWithStackTrace("Exception while creating guid: " + e);
    }
}
Also used : RandomString(edu.umass.cs.gnscommon.utils.RandomString) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) IOException(java.io.IOException) GuidEntry(edu.umass.cs.gnsclient.client.util.GuidEntry) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest) Test(org.junit.Test)

Example 84 with ClientException

use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.

the class CreateIndexTest method test_03_SelectPass.

/**
   *
   */
@Test
public void test_03_SelectPass() {
    try {
        JSONArray result = clientCommands.selectQuery(masterGuid, buildQuery(testField, AREA_EXTENT));
        for (int i = 0; i < result.length(); i++) {
            System.out.println(result.get(i).toString());
        }
        Assert.assertThat(result.length(), greaterThanOrEqualTo(1));
    } catch (JSONException | ClientException | IOException e) {
        Utils.failWithStackTrace("Exception executing second selectNear: " + e);
    }
}
Also used : JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) IOException(java.io.IOException) Test(org.junit.Test) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest)

Example 85 with ClientException

use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.

the class AclTest method test_106_ACLNotReadOtherGuidFieldTest.

/**
   *
   */
@Test
public void test_106_ACLNotReadOtherGuidFieldTest() {
    try {
        try {
            String result = clientCommands.fieldReadArrayFirstElement(westyEntry.getGuid(), "environment", samEntry);
            Utils.failWithStackTrace("Result of read of westy's environment by sam is " + result + " which is wrong because it should have been rejected.");
        } catch (ClientException e) {
        }
    } catch (IOException e) {
        Utils.failWithStackTrace("Exception while reading fields in ACLNotReadOtherGuidFieldTest: " + e);
    }
}
Also used : RandomString(edu.umass.cs.gnscommon.utils.RandomString) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) IOException(java.io.IOException) Test(org.junit.Test) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest)

Aggregations

ClientException (edu.umass.cs.gnscommon.exceptions.client.ClientException)239 IOException (java.io.IOException)215 Test (org.junit.Test)134 JSONException (org.json.JSONException)126 DefaultGNSTest (edu.umass.cs.gnsserver.utils.DefaultGNSTest)125 RandomString (edu.umass.cs.gnscommon.utils.RandomString)113 JSONArray (org.json.JSONArray)74 GuidEntry (edu.umass.cs.gnsclient.client.util.GuidEntry)71 JSONObject (org.json.JSONObject)59 GNSClientCommands (edu.umass.cs.gnsclient.client.GNSClientCommands)40 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)37 StringTokenizer (java.util.StringTokenizer)30 EncryptionException (edu.umass.cs.gnscommon.exceptions.client.EncryptionException)23 BasicGuidEntry (edu.umass.cs.gnsclient.client.util.BasicGuidEntry)20 FieldNotFoundException (edu.umass.cs.gnscommon.exceptions.client.FieldNotFoundException)19 FileNotFoundException (java.io.FileNotFoundException)18 InternalRequestException (edu.umass.cs.gnscommon.exceptions.server.InternalRequestException)15 ResponseCode (edu.umass.cs.gnscommon.ResponseCode)13 InvalidKeySpecException (java.security.spec.InvalidKeySpecException)13 InvalidKeyException (java.security.InvalidKeyException)12