Search in sources :

Example 36 with Serializable

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);
}
Also used : Serializable(java.io.Serializable) CombinedFeed(org.glassfish.jersey.examples.feedcombiner.model.CombinedFeed) Test(org.junit.Test)

Example 37 with Serializable

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());
}
Also used : StorageMetaData(org.deeplearning4j.api.storage.StorageMetaData) SbeStorageMetaData(org.deeplearning4j.ui.storage.impl.SbeStorageMetaData) Serializable(java.io.Serializable) SbeStorageMetaData(org.deeplearning4j.ui.storage.impl.SbeStorageMetaData) Test(org.junit.Test)

Example 38 with Serializable

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)));
}
Also used : Serializable(java.io.Serializable) TrackingMessageHolder(org.neo4j.cluster.com.message.TrackingMessageHolder) Test(org.junit.Test)

Example 39 with Serializable

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)));
}
Also used : Serializable(java.io.Serializable) TrackingMessageHolder(org.neo4j.cluster.com.message.TrackingMessageHolder) Test(org.junit.Test)

Example 40 with Serializable

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);
}
Also used : PrintStream(java.io.PrintStream) Serializable(java.io.Serializable) FastByteArrayOutputStream(jodd.io.FastByteArrayOutputStream) Method(java.lang.reflect.Method) InvokeProxetta(jodd.proxetta.impl.InvokeProxetta) Annotation(java.lang.annotation.Annotation) Test(org.junit.Test)

Aggregations

Serializable (java.io.Serializable)3100 Test (org.junit.Test)906 HashMap (java.util.HashMap)789 ArrayList (java.util.ArrayList)420 Map (java.util.Map)370 List (java.util.List)208 QName (org.alfresco.service.namespace.QName)197 IOException (java.io.IOException)174 Metacard (ddf.catalog.data.Metacard)145 NodeRef (org.alfresco.service.cmr.repository.NodeRef)135 LinkedHashMap (java.util.LinkedHashMap)128 HashSet (java.util.HashSet)122 Date (java.util.Date)114 ByteArrayInputStream (java.io.ByteArrayInputStream)82 ParserContext (org.mvel2.ParserContext)82 Set (java.util.Set)80 File (java.io.File)75 ObjectInputStream (java.io.ObjectInputStream)65 Session (org.hibernate.Session)65 URI (java.net.URI)64