use of edu.umass.cs.gnsclient.client.util.GuidEntry in project GNS by MobilityFirst.
the class ServerIntegrationTest method test_020_RemoveCreated.
/**
* Removes a guid.
*
* @throws IOException
* @throws ClientException
* @throws NoSuchAlgorithmException
*/
@Test
public void test_020_RemoveCreated() throws NoSuchAlgorithmException, ClientException, IOException {
// CHECKED FOR VALIDITY
String testGuidName = "testGUID" + RandomString.randomString(12);
GuidEntry testGuid;
testGuid = clientCommands.guidCreate(masterGuid, testGuidName);
clientCommands.guidRemove(masterGuid, testGuid.getGuid());
try {
clientCommands.lookupGuidRecord(testGuid.getGuid());
failWithStackTrace("Lookup testGuid should have throw an exception.");
} catch (ClientException e) {
// expected
}
}
use of edu.umass.cs.gnsclient.client.util.GuidEntry in project GNS by MobilityFirst.
the class ServerIntegrationTest method test_124_ACLTests_OtherUser.
/**
* Runs a set of ACL tests checking if others can read or not ACLS set by another.
*
* @throws Exception
* @throws JSONException
*/
@Test
public void test_124_ACLTests_OtherUser() throws JSONException, Exception {
GuidEntry westyEntry = GuidUtils.lookupOrCreateGuid(clientCommands, masterGuid, "westy124" + RandomString.randomString(6));
GuidEntry samEntry = GuidUtils.lookupOrCreateGuid(clientCommands, masterGuid, "sam124" + RandomString.randomString(6));
test_131_ACLRemoveAllFields(westyEntry, samEntry);
test_132_ACLCreateFields(westyEntry);
test_135_ACLMaybeAddAllFieldsForMaster(westyEntry);
test_136_ACLMasterReadAllFields(westyEntry);
test_137_ACLReadMyFields(westyEntry);
test_138_ACLNotReadOtherGuidAllFieldsTest(westyEntry, samEntry);
test_139_ACLNotReadOtherGuidFieldTest(westyEntry, samEntry);
test_140_AddACLTest(westyEntry, samEntry);
test_141_CheckACLTest(westyEntry, samEntry);
test_150_ACLCreateDeeperField(westyEntry);
test_151_ACLAddDeeperFieldACL(westyEntry);
test_152_ACLCheckDeeperFieldACLExists(westyEntry);
test_153_ACLReadDeeperFieldSelf(westyEntry);
test_154_ACLReadDeeperFieldOtherFail(westyEntry, samEntry);
test_156_ACLReadShallowFieldOtherFail(westyEntry, samEntry);
test_157_AddAllRecordACL(westyEntry);
test_158_ACLReadDeeperFieldOtherFail(westyEntry, samEntry);
}
use of edu.umass.cs.gnsclient.client.util.GuidEntry in project GNS by MobilityFirst.
the class ServerIntegrationTest method test_041_FieldTests.
/**
* Runs the Field tests as one independent unit.
*
* @throws Exception
*/
@Test
public void test_041_FieldTests() throws Exception {
GuidEntry subGuidEntry = test_050_CreateSubGuid();
test_060_FieldNotFoundException(subGuidEntry);
test_070_FieldExistsFalse(subGuidEntry);
test_080_CreateFieldForFieldExists(subGuidEntry);
test_090_FieldExistsTrue(subGuidEntry);
}
use of edu.umass.cs.gnsclient.client.util.GuidEntry in project GNS by MobilityFirst.
the class ServerIntegrationTest method test_410_JSONUpdate.
/**
* Tests update using JSON.
*
* @return GuidEntry created
* @throws Exception
*/
public GuidEntry test_410_JSONUpdate() throws Exception {
//CHECKED FOR VALIDITY
GuidEntry westyEntry = clientCommands.guidCreate(masterGuid, "westy410" + RandomString.randomString(12));
//System.out.print("Created: " + westyEntry);
try {
JSONObject json = new JSONObject();
json.put("name", "frank");
json.put("occupation", "busboy");
json.put("location", "work");
json.put("friends", new ArrayList<>(Arrays.asList("Joe", "Sam", "Billy")));
JSONObject subJson = new JSONObject();
subJson.put("einy", "floop");
subJson.put("meiny", "bloop");
json.put("gibberish", subJson);
clientCommands.update(westyEntry, json);
} catch (JSONException | IOException | ClientException e) {
failWithStackTrace("Exception while updating JSON: ", e);
}
try {
JSONObject expected = new JSONObject();
expected.put("name", "frank");
expected.put("occupation", "busboy");
expected.put("location", "work");
expected.put("friends", new ArrayList<>(Arrays.asList("Joe", "Sam", "Billy")));
JSONObject subJson = new JSONObject();
subJson.put("einy", "floop");
subJson.put("meiny", "bloop");
expected.put("gibberish", subJson);
JSONObject actual = clientCommands.read(westyEntry);
JSONAssert.assertEquals(expected, actual, JSONCompareMode.NON_EXTENSIBLE);
//System.out.println(actual);
} catch (Exception e) {
failWithStackTrace("Exception while reading JSON: ", e);
}
try {
JSONObject json = new JSONObject();
json.put("occupation", "rocket scientist");
clientCommands.update(westyEntry, json);
} catch (JSONException | IOException | ClientException e) {
failWithStackTrace("Exception while changing \"occupation\" to \"rocket scientist\": ", e);
}
try {
JSONObject expected = new JSONObject();
expected.put("name", "frank");
expected.put("occupation", "rocket scientist");
expected.put("location", "work");
expected.put("friends", new ArrayList<>(Arrays.asList("Joe", "Sam", "Billy")));
JSONObject subJson = new JSONObject();
subJson.put("einy", "floop");
subJson.put("meiny", "bloop");
expected.put("gibberish", subJson);
JSONObject actual = clientCommands.read(westyEntry);
JSONAssert.assertEquals(expected, actual, JSONCompareMode.NON_EXTENSIBLE);
//System.out.println(actual);
} catch (Exception e) {
failWithStackTrace("Exception while reading change of \"occupation\" to \"rocket scientist\": ", e);
}
try {
JSONObject json = new JSONObject();
json.put("ip address", "127.0.0.1");
clientCommands.update(westyEntry, json);
} catch (JSONException | IOException | ClientException e) {
failWithStackTrace("Exception while adding field \"ip address\" with value \"127.0.0.1\": ", e);
}
try {
JSONObject expected = new JSONObject();
expected.put("name", "frank");
expected.put("occupation", "rocket scientist");
expected.put("location", "work");
expected.put("ip address", "127.0.0.1");
expected.put("friends", new ArrayList<>(Arrays.asList("Joe", "Sam", "Billy")));
JSONObject subJson = new JSONObject();
subJson.put("einy", "floop");
subJson.put("meiny", "bloop");
expected.put("gibberish", subJson);
JSONObject actual = clientCommands.read(westyEntry);
JSONAssert.assertEquals(expected, actual, JSONCompareMode.NON_EXTENSIBLE);
//System.out.println(actual);
} catch (Exception e) {
failWithStackTrace("Exception while reading JSON: ", e);
}
try {
clientCommands.fieldRemove(westyEntry.getGuid(), "gibberish", westyEntry);
} catch (IOException | ClientException e) {
failWithStackTrace("Exception during remove field \"gibberish\": ", e);
}
try {
JSONObject expected = new JSONObject();
expected.put("name", "frank");
expected.put("occupation", "rocket scientist");
expected.put("location", "work");
expected.put("ip address", "127.0.0.1");
expected.put("friends", new ArrayList<>(Arrays.asList("Joe", "Sam", "Billy")));
JSONObject actual = clientCommands.read(westyEntry);
JSONAssert.assertEquals(expected, actual, JSONCompareMode.NON_EXTENSIBLE);
//System.out.println(actual);
} catch (Exception e) {
failWithStackTrace("Exception while reading JSON: ", e);
}
return westyEntry;
}
use of edu.umass.cs.gnsclient.client.util.GuidEntry in project GNS by MobilityFirst.
the class BatchCreateTest method test_500_Batch_Tests.
/**
* The test set for testing batch creates. The test will create batches
* of size 2, 4, 8,..., 128.
*
* @throws Exception
*/
@Test
// Fixme: put this back at 7 once removal is faster.
@Repeat(times = 5)
public void test_500_Batch_Tests() throws Exception {
GuidEntry accountGuidForBatch = test_510_CreateBatchAccountGuid();
test_511_CreateBatch(accountGuidForBatch);
test_512_CheckBatch(accountGuidForBatch);
numberToCreate *= 2;
client.execute(GNSCommand.accountGuidRemove(accountGuidForBatch));
}
Aggregations