use of edu.umass.cs.utils.Repeat in project GNS by MobilityFirst.
the class ContextServiceTest method test_620_contextServiceTest.
/**
* Test to check context service triggers.
*/
// these two attributes right now are supported by CS
@Test
@Repeat(times = REPEAT)
public void test_620_contextServiceTest() {
// run it only when CS is enabled
// to check if context service is enabled.
boolean enableContextService = Config.getGlobalBoolean(GNSConfig.GNSC.ENABLE_CNS);
String csIPPort = Config.getGlobalString(GNSConfig.GNSC.CNS_NODE_ADDRESS);
if (enableContextService) {
try {
JSONObject attrValJSON = new JSONObject();
attrValJSON.put("geoLocationCurrentLat", 42.466);
attrValJSON.put("geoLocationCurrentLong", -72.58);
clientCommands.update(masterGuid, attrValJSON);
// just wait for 2 sec before sending search
Thread.sleep(1000);
String[] parsed = csIPPort.split(":");
String csIP = parsed[0];
int csPort = Integer.parseInt(parsed[1]);
ContextServiceClient csClient = new ContextServiceClient(csIP, csPort, false, PrivacySchemes.NO_PRIVACY);
// context service query format
String query = "geoLocationCurrentLat >= 40 " + "AND geoLocationCurrentLat <= 50 AND " + "geoLocationCurrentLong >= -80 AND " + "geoLocationCurrentLong <= -70";
JSONArray resultArray = new JSONArray();
// third argument is arbitrary expiry time, not used now
int resultSize = csClient.sendSearchQuery(query, resultArray, 300000);
Assert.assertThat(resultSize, Matchers.greaterThanOrEqualTo(1));
} catch (Exception e) {
Utils.failWithStackTrace("Exception during contextServiceTest: ", e);
}
}
}
use of edu.umass.cs.utils.Repeat in project GNS by MobilityFirst.
the class CreateUpdateRemoveRepeatTest method test_001_CreateAndUpdate.
/**
* @throws Exception
*/
@Test
@Repeat(times = REPEAT)
public void test_001_CreateAndUpdate() throws Exception {
// CHECKED FOR VALIDITY
String alias = "testGUID" + RandomString.randomString(12);
String createdGUID = client.execute(GNSCommand.guidCreate(masterGuid, alias)).getResultString();
GuidEntry createdGUIDEntry = GuidUtils.getGUIDKeys(alias);
Assert.assertEquals(alias, createdGUIDEntry.entityName);
Assert.assertEquals(createdGUID, GuidUtils.getGUIDKeys(alias).guid);
String key = "key1", value = "value1";
client.execute(GNSCommand.update(createdGUID, new JSONObject().put(key, value), createdGUIDEntry));
Assert.assertEquals(value, client.execute(GNSCommand.fieldRead(createdGUIDEntry, key)).getResultMap().get(key));
client.execute(GNSCommand.guidRemove(masterGuid, createdGUID));
}
use of edu.umass.cs.utils.Repeat in project GNS by MobilityFirst.
the class ServerIntegrationTest method test_001_CreateAndUpdate.
/**
* @throws Exception
*/
@Test
@Repeat(times = REPEAT * 10)
public void test_001_CreateAndUpdate() throws Exception {
// CHECKED FOR VALIDITY
String alias = "testGUID" + RandomString.randomString(12);
String createdGUID = client.execute(GNSCommand.guidCreate(masterGuid, alias)).getResultString();
GuidEntry createdGUIDEntry = GuidUtils.getGUIDKeys(alias);
String key = "key1", value = "value1";
client.execute(GNSCommand.update(createdGUID, new JSONObject().put(key, value), createdGUIDEntry));
Assert.assertEquals(value, client.execute(GNSCommand.fieldRead(createdGUIDEntry, key)).getResultMap().get(key));
}
use of edu.umass.cs.utils.Repeat in project GNS by MobilityFirst.
the class ServerIntegrationTest method test_620_contextServiceTest.
/**
* Test to check context service triggers.
*/
// these two attributes right now are supported by CS
@Test
@Repeat(times = REPEAT)
public void test_620_contextServiceTest() {
// run it only when CS is enabled
// to check if context service is enabled.
boolean enableContextService = Config.getGlobalBoolean(GNSConfig.GNSC.ENABLE_CNS);
String csIPPort = Config.getGlobalString(GNSConfig.GNSC.CNS_NODE_ADDRESS);
if (enableContextService) {
try {
JSONObject attrValJSON = new JSONObject();
attrValJSON.put("geoLocationCurrentLat", 42.466);
attrValJSON.put("geoLocationCurrentLong", -72.58);
clientCommands.update(masterGuid, attrValJSON);
// just wait for 2 sec before sending search
Thread.sleep(1000);
String[] parsed = csIPPort.split(":");
String csIP = parsed[0];
int csPort = Integer.parseInt(parsed[1]);
ContextServiceClient csClient = new ContextServiceClient(csIP, csPort, false, PrivacySchemes.NO_PRIVACY);
// context service query format
String query = "geoLocationCurrentLat >= 40 " + "AND geoLocationCurrentLat <= 50 AND " + "geoLocationCurrentLong >= -80 AND " + "geoLocationCurrentLong <= -70";
JSONArray resultArray = new JSONArray();
// third argument is arbitrary expiry time, not used now
int resultSize = csClient.sendSearchQuery(query, resultArray, 300000);
Assert.assertThat(resultSize, Matchers.greaterThanOrEqualTo(1));
} catch (Exception e) {
failWithStackTrace("Exception during contextServiceTest: ", e);
}
}
}
use of edu.umass.cs.utils.Repeat in project GNS by MobilityFirst.
the class ServerIntegrationTest method test_117_ACLTest_Single_Field.
/**
* Runs the set of ACL tests for checking single field access as an independent unit.
*
* @throws Exception
* @throws JSONException
*/
@Test
@Repeat(times = REPEAT * 10)
public void test_117_ACLTest_Single_Field() throws JSONException, Exception {
final String TEST_FIELD_NAME = "testField";
String testFieldName = TEST_FIELD_NAME + RandomString.randomString(6);
test_101_ACLCreateField(masterGuid, testFieldName);
test_120_CreateAcl(testFieldName);
test_121_CheckAcl(testFieldName);
test_122_DeleteAcl(testFieldName);
test_123_CheckAclGone(testFieldName);
}
Aggregations