use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.
the class ServerIntegrationTest method test_030_RemoveCreatedSansAccountInfo.
/**
* Removes a guid not using an account guid.
*
* @throws IOException
* @throws ClientException
* @throws NoSuchAlgorithmException
*/
@Test
public void test_030_RemoveCreatedSansAccountInfo() throws NoSuchAlgorithmException, ClientException, IOException {
//CHECKED FOR VALIDITY
String testGuidName = "testGUID" + RandomString.randomString(12);
String testGUID = client.execute(GNSCommand.guidCreate(masterGuid, testGuidName)).getResultString();
client.execute(GNSCommand.guidRemove(GuidUtils.getGUIDKeys(testGuidName)));
try {
// clientCommands.lookupGuidRecord(testGuid.getGuid());
client.execute(GNSCommand.lookupGUID(testGUID));
failWithStackTrace("Lookup testGuid should have throw an exception.");
} catch (ClientException e) {
// expected
}
}
use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.
the class ServerIntegrationTest method test_262_UnsignedReadFailAgain.
/**
* Insures that we still can't read the non-world-readable field without a guid.
*
* @param unsignedReadTestGuid
* @param unreadAbleReadFieldName
*/
public void test_262_UnsignedReadFailAgain(GuidEntry unsignedReadTestGuid, String unreadAbleReadFieldName) {
try {
try {
String result = clientCommands.fieldRead(unsignedReadTestGuid.getGuid(), unreadAbleReadFieldName, null);
failWithStackTrace("Result of read of test guid's " + unreadAbleReadFieldName + " in " + unsignedReadTestGuid.entityName + " as world readable was " + result + " which is wrong because it should have been rejected in UnsignedRead.");
} catch (ClientException e) {
}
} catch (Exception e) {
failWithStackTrace("Exception while testing for denied unsigned access in UnsignedRead: ", e);
}
}
use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.
the class ServerIntegrationTest method test_139_ACLNotReadOtherGuidFieldTest.
/**
*
* @param westyEntry
* @param samEntry
*/
public void test_139_ACLNotReadOtherGuidFieldTest(GuidEntry westyEntry, GuidEntry samEntry) {
//CHECKED FOR VALIDITY
try {
try {
String result = clientCommands.fieldRead(westyEntry.getGuid(), "environment", samEntry);
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 (Exception e) {
failWithStackTrace("Exception while reading fields in ACLNotReadOtherGuidFieldTest: ", e);
}
}
use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.
the class ServerIntegrationTest method test_200_SubstituteList.
/**
* Tests different DB substitute list methods.
*/
@Test
@Repeat(times = REPEAT)
public void test_200_SubstituteList() {
//CHECKED FOR VALIDITY
String testSubstituteListGuid = "testSubstituteListGUID" + RandomString.randomString(12);
String field = "people";
GuidEntry testEntry = null;
try {
// Utils.clearTestGuids(client);
// System.out.println("cleared old GUIDs");
testEntry = clientCommands.guidCreate(masterGuid, testSubstituteListGuid);
System.out.print(testEntry + " ");
} catch (Exception e) {
failWithStackTrace("Exception during init: ", e);
}
try {
clientCommands.fieldAppendOrCreateList(testEntry.getGuid(), field, new JSONArray(Arrays.asList("Frank", "Joe", "Sally", "Rita")), testEntry);
} catch (IOException | ClientException e) {
failWithStackTrace("Exception during create: ", e);
}
try {
HashSet<String> expected = new HashSet<>(Arrays.asList("Frank", "Joe", "Sally", "Rita"));
HashSet<String> actual = JSONUtils.JSONArrayToHashSet(clientCommands.fieldReadArray(testEntry.getGuid(), field, testEntry));
Assert.assertEquals(expected, actual);
} catch (Exception e) {
failWithStackTrace("Exception when we were not expecting it: ", e);
}
try {
clientCommands.fieldSubstitute(testEntry.getGuid(), field, new JSONArray(Arrays.asList("BillyBob", "Hank")), new JSONArray(Arrays.asList("Frank", "Joe")), testEntry);
} catch (IOException | ClientException e) {
failWithStackTrace("Exception during substitute: ", e);
}
try {
HashSet<String> expected = new HashSet<>(Arrays.asList("BillyBob", "Hank", "Sally", "Rita"));
HashSet<String> actual = JSONUtils.JSONArrayToHashSet(clientCommands.fieldReadArray(testEntry.getGuid(), field, testEntry));
Assert.assertEquals(expected, actual);
} catch (Exception e) {
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 ServerIntegrationTest method test_330_QuerySelectWithReader.
/**
* Tests that selectQuery works with a reader.
*/
@Test
public void test_330_QuerySelectWithReader() {
String fieldName = "testQuery";
try {
for (int cnt = 0; cnt < 5; cnt++) {
GuidEntry testEntry = clientCommands.guidCreate(masterGuid, "queryTest-" + RandomString.randomString(12));
// Remove default all fields / all guids ACL;
clientCommands.aclRemove(AclAccessType.READ_WHITELIST, testEntry, GNSProtocol.ENTIRE_RECORD.toString(), GNSProtocol.ALL_GUIDS.toString());
// save them so we can delete them later
CREATED_GUIDS.add(testEntry);
JSONArray array = new JSONArray(Arrays.asList(25));
clientCommands.fieldReplaceOrCreateList(testEntry.getGuid(), fieldName, array, testEntry);
}
} catch (ClientException | IOException e) {
failWithStackTrace("Exception while trying to create the guids: ", e);
}
try {
//See comment under the method header for test_320_GeoSpatialSelect
waitSettle(SELECT_WAIT);
String query = "~" + fieldName + " : ($gt: 0)";
JSONArray result = clientCommands.selectQuery(masterGuid, query);
// for (int i = 0; i < result.length(); i++) {
// System.out.print("guid: " + 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(5));
} catch (ClientException | IOException e) {
failWithStackTrace("Exception executing selectQuery: ", e);
}
try {
for (GuidEntry guid : CREATED_GUIDS) {
clientCommands.guidRemove(masterGuid, guid.getGuid());
}
CREATED_GUIDS.clear();
} catch (ClientException | IOException e) {
failWithStackTrace("Exception during cleanup: " + e);
}
}
Aggregations