use of org.apache.mesos.state.Variable in project jesos by groupon.
the class AbstractTestState method testExpungeNonExistentValue.
@Test
public void testExpungeNonExistentValue() throws Exception {
final State state = getState();
final Variable empty = state.fetch("does-not-exist").get();
assertNotNull(empty);
assertTrue(empty.value().length == 0);
final boolean expunged = state.expunge(empty).get();
assertFalse(expunged);
}
use of org.apache.mesos.state.Variable in project jesos by groupon.
the class AbstractTestState method testSetAndGet.
@Test
public void testSetAndGet() throws Exception {
final State state = getState();
final byte[] value = "The quick brown fox jumps over the lazy dog.".getBytes(StandardCharsets.UTF_8);
final Variable var = state.fetch("someValue").get();
assertTrue(var.value().length == 0);
final Variable newVar = var.mutate(value);
final JVariable storedVar = (JVariable) state.store(newVar).get();
assertNotNull(storedVar);
final JVariable retrievedVar = (JVariable) state.fetch("someValue").get();
assertNotNull(retrievedVar);
assertArrayEquals(newVar.value(), retrievedVar.value());
assertArrayEquals(storedVar.value(), retrievedVar.value());
assertEquals(storedVar.getName(), retrievedVar.getName());
assertEquals(storedVar.getUuid(), retrievedVar.getUuid());
}
use of org.apache.mesos.state.Variable in project jesos by groupon.
the class TestJVariable method testMutate.
@Test
public void testMutate() {
final String name = "test-name";
final byte[] value = "The quick brown fox jumps over the lazy dog.".getBytes(StandardCharsets.UTF_8);
final byte[] newValue = "Ich esse Autos zum Abendbrot und mache Kopfsprung ins Sandbecken. Gruen. Rot. Pferderennen.".getBytes(StandardCharsets.UTF_8);
final JVariable v = new JVariable(name, value);
final Variable w = v.mutate(newValue);
assertEquals(JVariable.class, w.getClass());
assertArrayEquals(newValue, w.value());
assertEquals(name, v.getName());
assertArrayEquals(value, v.value());
final JVariable v2 = (JVariable) w;
assertEquals(v.getName(), v2.getName());
assertEquals(v.getUuid(), v2.getUuid());
}
Aggregations