use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.
the class ReadTest method test_02_CreateField.
/**
*
*/
@Test
public void test_02_CreateField() {
try {
westyEntry = clientCommands.guidCreate(masterGuid, "westy" + RandomString.randomString(12));
samEntry = clientCommands.guidCreate(masterGuid, "sam" + RandomString.randomString(12));
} catch (ClientException | IOException e) {
Utils.failWithStackTrace("Exception when we were not expecting it: " + e);
}
try {
// remove default read acces for this test
clientCommands.aclRemove(AclAccessType.READ_WHITELIST, westyEntry, GNSProtocol.ENTIRE_RECORD.toString(), GNSProtocol.ALL_GUIDS.toString());
clientCommands.fieldCreateOneElementList(westyEntry.getGuid(), "environment", "work", westyEntry);
clientCommands.fieldCreateOneElementList(westyEntry.getGuid(), "ssn", "000-00-0000", westyEntry);
clientCommands.fieldCreateOneElementList(westyEntry.getGuid(), "password", "666flapJack", westyEntry);
clientCommands.fieldCreateOneElementList(westyEntry.getGuid(), "address", "100 Hinkledinkle Drive", westyEntry);
// read my own field
Assert.assertEquals("work", clientCommands.fieldReadArrayFirstElement(westyEntry.getGuid(), "environment", westyEntry));
// read another field
Assert.assertEquals("000-00-0000", clientCommands.fieldReadArrayFirstElement(westyEntry.getGuid(), "ssn", westyEntry));
// read another field
Assert.assertEquals("666flapJack", clientCommands.fieldReadArrayFirstElement(westyEntry.getGuid(), "password", westyEntry));
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 during read of westy's environment by sam: " + e);
}
} catch (ClientException | IOException e) {
Utils.failWithStackTrace("Exception when we were not expecting it: " + e);
}
}
use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.
the class SelectGeoTest method test_30_GeoSpatialSelectSelectWithin.
/**
*
*/
@Test
public void test_30_GeoSpatialSelectSelectWithin() {
try {
JSONArray rect = new JSONArray();
JSONArray upperLeft = new JSONArray();
upperLeft.put(1.0);
upperLeft.put(1.0);
JSONArray lowerRight = new JSONArray();
lowerRight.put(-1.0);
lowerRight.put(-1.0);
rect.put(upperLeft);
rect.put(lowerRight);
JSONArray result = clientCommands.selectWithin(GNSProtocol.LOCATION_FIELD_NAME.toString(), rect);
// best we can do should be at least 5, but possibly more objects in results
Assert.assertThat(result.length(), Matchers.greaterThanOrEqualTo(5));
} catch (JSONException | ClientException | IOException e) {
Utils.failWithStackTrace("Exception executing selectWithin: " + e);
}
}
use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.
the class SecureCommandTest method test_06_SecureRetrieveACL.
/**
*
*/
@Test
public void test_06_SecureRetrieveACL() {
try {
JSONArray expected = new JSONArray(new ArrayList<>(Arrays.asList(GNSProtocol.EVERYONE.toString())));
JSONArray actual = client.execute(GNSCommand.aclGetSecure(AclAccessType.READ_WHITELIST, accountGuid, GNSProtocol.ENTIRE_RECORD.toString())).getResultJSONArray();
JSONAssert.assertEquals(expected, actual, false);
} catch (ClientException | IOException | JSONException e) {
Utils.failWithStackTrace("Exception while retrieving account record acl: ", e);
}
}
use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.
the class SelectSingleTest method test_03_BasicSelect.
/**
*
*/
@Test
public void test_03_BasicSelect() {
try {
JSONArray result = clientCommands.select(masterGuid, "cats", "fred");
// best we can do since there will be one, but possibly more objects in results
Assert.assertThat(result.length(), Matchers.greaterThanOrEqualTo(1));
} catch (ClientException | IOException e) {
Utils.failWithStackTrace("Exception when we were not expecting it: " + e);
}
}
use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.
the class SingleRemoveGuidTest method test_01_RemoveGuidUsingAccount.
/**
*
*/
@Test
public void test_01_RemoveGuidUsingAccount() {
String testGuidName = "testGUID" + RandomString.randomString(12);
GuidEntry testGuid = null;
try {
testGuid = clientCommands.guidCreate(masterGuid, testGuidName);
} catch (ClientException | IOException e) {
Utils.failWithStackTrace("Exception while creating testGuid: " + e);
}
if (testGuid != null) {
try {
clientCommands.guidRemove(masterGuid, testGuid.getGuid());
} catch (ClientException | IOException e) {
Utils.failWithStackTrace("Exception while removing testGuid: " + e);
}
try {
clientCommands.lookupGuidRecord(testGuid.getGuid());
Utils.failWithStackTrace("Lookup testGuid should have throw an exception.");
} catch (ClientException e) {
} catch (IOException e) {
Utils.failWithStackTrace("Exception while doing Lookup testGuid: " + e);
}
}
}
Aggregations