use of java.io.Serializable in project jersey by jersey.
the class ReadWriteLockDataStoreTest method testSaveEntity.
@Test
public void testSaveEntity() {
String id = "1";
CombinedFeed feed = new CombinedFeed.CombinedFeedBuilder(id, "http://localhost").title("title").description("description").refreshPeriod(5L).build();
observer.save(feed);
replayAll();
Serializable previousEntity = testedClass.put(id, feed);
verifyAll();
assertNull(previousEntity);
}
use of java.io.Serializable in project deeplearning4j by deeplearning4j.
the class TestStorageMetaData method testStorageMetaData.
@Test
public void testStorageMetaData() {
Serializable extraMeta = "ExtraMetaData";
long timeStamp = 123456;
StorageMetaData m = new SbeStorageMetaData(timeStamp, "sessionID", "typeID", "workerID", "org.some.class.InitType", "org.some.class.UpdateType", extraMeta);
byte[] bytes = m.encode();
StorageMetaData m2 = new SbeStorageMetaData();
m2.decode(bytes);
assertEquals(m, m2);
assertArrayEquals(bytes, m2.encode());
//Sanity check: null values
m = new SbeStorageMetaData(0, null, null, null, null, (String) null);
bytes = m.encode();
m2 = new SbeStorageMetaData();
m2.decode(bytes);
//In practice, we don't want these things to ever be null anyway...
assertNullOrZeroLength(m2.getSessionID());
assertNullOrZeroLength(m2.getTypeID());
assertNullOrZeroLength(m2.getWorkerID());
assertNullOrZeroLength(m2.getInitTypeClass());
assertNullOrZeroLength(m2.getUpdateTypeClass());
assertArrayEquals(bytes, m2.encode());
}
use of java.io.Serializable in project neo4j by neo4j.
the class ProposerStateTest method proposer_promiseShouldCarryOnPayloadToPhase2Timeout.
@SuppressWarnings("unchecked")
@Test
public void proposer_promiseShouldCarryOnPayloadToPhase2Timeout() throws Throwable {
// GIVEN
String instanceId = "1";
Serializable payload = "myPayload";
PaxosInstance instance = new PaxosInstance(mock(PaxosInstanceStore.class), new org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(instanceId));
instance.propose(1, asList(create("http://some-guy")));
// don't blame me for making it package access.
instance.value_2 = payload;
ProposerContext context = mock(ProposerContext.class);
when(context.getPaxosInstance(any(org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId.class))).thenReturn(instance);
when(context.getMinimumQuorumSize(anyList())).thenReturn(1);
TrackingMessageHolder outgoing = new TrackingMessageHolder();
Message<ProposerMessage> message = to(promise, create("http://something"), new ProposerMessage.PromiseState(1, payload)).setHeader(INSTANCE, instanceId);
// WHEN
ProposerState.proposer.handle(context, message, outgoing);
// THEN
verify(context).setTimeout(eq(new org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(instanceId)), argThat(new MessageArgumentMatcher<>().withPayload(payload)));
}
use of java.io.Serializable in project neo4j by neo4j.
the class ProposerStateTest method proposer_rejectAcceptShouldCarryOnPayload.
@Test
public void proposer_rejectAcceptShouldCarryOnPayload() throws Throwable {
// GIVEN
String instanceId = "1";
PaxosInstance instance = new PaxosInstance(mock(PaxosInstanceStore.class), new org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(instanceId));
Serializable payload = "myPayload";
instance.propose(1, asList(create("http://some-guy")));
instance.ready(payload, true);
instance.pending();
ProposerContext context = mock(ProposerContext.class);
when(context.getLog(any(Class.class))).thenReturn(NullLog.getInstance());
when(context.getPaxosInstance(any(org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId.class))).thenReturn(instance);
when(context.getMyId()).thenReturn(new org.neo4j.cluster.InstanceId(parseInt(instanceId)));
TrackingMessageHolder outgoing = new TrackingMessageHolder();
Message<ProposerMessage> message = to(rejectAccept, create("http://something"), new ProposerMessage.RejectAcceptState()).setHeader(INSTANCE, instanceId);
// WHEN
ProposerState.proposer.handle(context, message, outgoing);
// THEN
verify(context).setTimeout(eq(new org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(instanceId)), argThat(new MessageArgumentMatcher<>().withPayload(payload)));
}
use of java.io.Serializable in project jodd by oblac.
the class InvReplTest method testReplacement.
@Test
public void testReplacement() throws IllegalAccessException, InstantiationException, NoSuchMethodException, IOException {
InvokeProxetta proxetta = initProxetta();
String className = One.class.getCanonicalName();
byte[] klazz = proxetta.builder(One.class).create();
//FileUtil.writeBytes("/Users/igor/OneClone.class", klazz);
FastByteArrayOutputStream fbaos = new FastByteArrayOutputStream();
// PrintStream out = System.out;
System.setOut(new PrintStream(fbaos));
One one = (One) ClassLoaderUtil.defineClass((new StringBuilder()).append(className).append(JoddProxetta.invokeProxyClassNameSuffix).toString(), klazz).newInstance();
// clone ctor calls super ctor,
assertEquals("one ctor!one ctor!", fbaos.toString());
fbaos.reset();
one.example1();
assertEquals("REPLACED VIRTUAL! jodd.proxetta.inv.Two * one!173>overriden sub", fbaos.toString());
fbaos.reset();
one.example2();
assertEquals("REPLACED STATIC! one * jodd/proxetta/inv/Two * example2 * void example2() * jodd.proxetta.inv.One * jodd.proxetta.inv.One$$Clonetou!15013static: 4", fbaos.toString());
fbaos.reset();
one.example3();
assertEquals("state = REPLACED ctor!", fbaos.toString());
fbaos.reset();
assertEquals("jodd.proxetta.inv.One$$Clonetou", one.getClass().getName());
assertTrue(one instanceof Serializable);
Annotation[] anns = one.getClass().getAnnotations();
assertEquals(3, anns.length);
Method ms = one.getClass().getMethod("example1");
anns = ms.getAnnotations();
assertEquals(1, anns.length);
}
Aggregations