Search in sources :

Example 36 with ClientException

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

the class HttpClientTest method test_972_Http_SelectPass.

/**
   *
   */
@Test
public void test_972_Http_SelectPass() {
    try {
        JSONArray result = httpClient.selectQuery(masterGuid, buildQuery(createIndexTestField, AREA_EXTENT));
        for (int i = 0; i < result.length(); i++) {
            System.out.println(result.get(i).toString());
        }
        // best we can do should be at least 5, but possibly more objects in results
        Assert.assertThat(result.length(), Matchers.greaterThanOrEqualTo(1));
    } catch (JSONException | IOException | ClientException e) {
        Utils.failWithStackTrace("Exception executing second selectNear: ", e);
    }
}
Also used : JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) IOException(java.io.IOException) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) Test(org.junit.Test) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest)

Example 37 with ClientException

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

the class HttpClientTest method test_934_ReadDeep.

/**
   *
   */
@Test
public void test_934_ReadDeep() {
    try {
        String actual = httpClient.fieldRead(httpOneEntry.getGuid(), "flapjack.sally.right", httpOneEntry);
        Assert.assertEquals("seven", actual);
    } catch (IOException | ClientException e) {
        Utils.failWithStackTrace("Exception while reading \"flapjack.sally.right\": ", e);
    }
}
Also used : RandomString(edu.umass.cs.gnscommon.utils.RandomString) IOException(java.io.IOException) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) Test(org.junit.Test) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest)

Example 38 with ClientException

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

the class HttpClientTest method test_980_Http_GroupCreate.

/**
   *
   */
@Test
public void test_980_Http_GroupCreate() {
    String mygroupName = "mygroup" + RandomString.randomString(12);
    try {
        try {
            httpClient.lookupGuid(mygroupName);
            Utils.failWithStackTrace(mygroupName + " entity should not exist");
        } catch (ClientException e) {
        }
        guidToDeleteEntry = httpClient.guidCreate(masterGuid, "deleteMe" + RandomString.randomString(12));
        mygroupEntry = httpClient.guidCreate(masterGuid, mygroupName);
    } catch (IOException | ClientException | NoSuchAlgorithmException e) {
        Utils.failWithStackTrace("Exception while creating guids: ", e);
    }
}
Also used : RandomString(edu.umass.cs.gnscommon.utils.RandomString) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Test(org.junit.Test) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest)

Example 39 with ClientException

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

the class HttpClientTest method test_913_Http_CheckFieldsFail.

/**
   *
   */
@Test
public void test_913_Http_CheckFieldsFail() {
    try {
        try {
            String result = httpClient.fieldRead(httpOneEntry.getGuid(), "environment", httpTwoEntry);
            Utils.failWithStackTrace("Result of read of httpOneEntry's environment by httpTwoEntry is " + result + " which is wrong because it should have been rejected.");
        } catch (ClientException e) {
        } catch (IOException e) {
            Utils.failWithStackTrace("Exception during read of westy's environment by sam: ", e);
        }
    } catch (Exception e) {
        Utils.failWithStackTrace("Exception in Http_CheckFieldsFail: ", e);
    }
}
Also used : RandomString(edu.umass.cs.gnscommon.utils.RandomString) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) IOException(java.io.IOException) JSONException(org.json.JSONException) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Test(org.junit.Test) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest)

Example 40 with ClientException

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

the class SecureCommandTest method test_15_SecureRead.

/**
   * Remove the account.
   */
@Test
public void test_15_SecureRead() {
    GuidEntry masterGuid = GuidUtils.getGUIDKeys(globalAccountName);
    try {
        client.execute(GNSCommand.guidCreate(masterGuid, "whatever"));
        GuidEntry testGuid = GuidUtils.lookupGuidEntryFromDatabase(client, "whatever");
        client.execute(GNSCommand.fieldUpdate(testGuid, "fred", "value"));
        JSONObject actual = client.execute(GNSCommand.readSecure(testGuid.getGuid())).getResultJSONObject();
        JSONAssert.assertEquals(new JSONObject().put("fred", "value"), actual, JSONCompareMode.STRICT);
        client.execute(GNSCommand.guidRemove(masterGuid, testGuid.getGuid()));
    } catch (ClientException | IOException | JSONException e) {
        Utils.failWithStackTrace("Exception while removing 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) GuidEntry(edu.umass.cs.gnsclient.client.util.GuidEntry) 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