Search in sources :

Example 26 with Serializable

use of java.io.Serializable in project hibernate-orm by hibernate.

the class ReadWriteTest method testQueryCacheInvalidation.

@Test
public void testQueryCacheInvalidation() throws Exception {
    Statistics stats = sessionFactory().getStatistics();
    stats.clear();
    SecondLevelCacheStatistics slcs = stats.getSecondLevelCacheStatistics(Item.class.getName());
    sessionFactory().getCache().evictEntityRegion(Item.class.getName());
    TIME_SERVICE.advance(1);
    assertEquals(0, slcs.getPutCount());
    assertEquals(0, slcs.getElementCountInMemory());
    assertEquals(0, slcs.getEntries().size());
    ByRef<Long> idRef = new ByRef<>(null);
    withTxSession(s -> {
        Item item = new Item();
        item.setName("widget");
        item.setDescription("A really top-quality, full-featured widget.");
        s.persist(item);
        idRef.set(item.getId());
    });
    assertEquals(1, slcs.getPutCount());
    assertEquals(1, slcs.getElementCountInMemory());
    assertEquals(1, slcs.getEntries().size());
    withTxSession(s -> {
        Item item = s.get(Item.class, idRef.get());
        assertEquals(slcs.getHitCount(), 1);
        assertEquals(slcs.getMissCount(), 0);
        item.setDescription("A bog standard item");
    });
    assertEquals(slcs.getPutCount(), 2);
    CacheEntry entry = (CacheEntry) slcs.getEntries().get(idRef.get());
    Serializable[] ser = entry.getDisassembledState();
    assertTrue(ser[0].equals("widget"));
    assertTrue(ser[1].equals("A bog standard item"));
    withTxSession(s -> {
        Item item = s.load(Item.class, idRef.get());
        s.delete(item);
    });
}
Also used : VersionedItem(org.hibernate.test.cache.infinispan.functional.entities.VersionedItem) Item(org.hibernate.test.cache.infinispan.functional.entities.Item) OtherItem(org.hibernate.test.cache.infinispan.functional.entities.OtherItem) Serializable(java.io.Serializable) ByRef(org.infinispan.commons.util.ByRef) SecondLevelCacheStatistics(org.hibernate.stat.SecondLevelCacheStatistics) CacheEntry(org.hibernate.cache.spi.entry.CacheEntry) Statistics(org.hibernate.stat.Statistics) SecondLevelCacheStatistics(org.hibernate.stat.SecondLevelCacheStatistics) Test(org.junit.Test)

Example 27 with Serializable

use of java.io.Serializable in project neo4j by neo4j.

the class AppsIT method canDisableWelcomeMessage.

@Test
public void canDisableWelcomeMessage() throws Exception {
    Map<String, Serializable> values = genericMap("quiet", "true");
    final CollectingOutput out = new CollectingOutput();
    ShellClient client = new SameJvmClient(values, shellServer, out);
    client.shutdown();
    final String outString = out.asString();
    assertEquals("Shows welcome message: " + outString, false, outString.contains("Welcome to the Neo4j Shell! Enter 'help' for a list of commands"));
}
Also used : SameJvmClient(org.neo4j.shell.impl.SameJvmClient) Serializable(java.io.Serializable) CollectingOutput(org.neo4j.shell.impl.CollectingOutput) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 28 with Serializable

use of java.io.Serializable in project neo4j by neo4j.

the class AppsIT method doesShowWelcomeMessage.

@Test
public void doesShowWelcomeMessage() throws Exception {
    Map<String, Serializable> values = genericMap();
    final CollectingOutput out = new CollectingOutput();
    ShellClient client = new SameJvmClient(values, shellServer, out);
    client.shutdown();
    final String outString = out.asString();
    assertEquals("Shows welcome message: " + outString, true, outString.contains("Welcome to the Neo4j Shell! Enter 'help' for a list of commands"));
}
Also used : SameJvmClient(org.neo4j.shell.impl.SameJvmClient) Serializable(java.io.Serializable) CollectingOutput(org.neo4j.shell.impl.CollectingOutput) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 29 with Serializable

use of java.io.Serializable in project neo4j by neo4j.

the class AbstractShellIT method getCurrentNode.

protected Node getCurrentNode() throws RemoteException, ShellException {
    Serializable current = shellServer.interpretVariable(shellClient.getId(), Variables.CURRENT_KEY);
    int nodeId = parseInt(current.toString().substring(1));
    try (Transaction tx = db.beginTx()) {
        Node nodeById = db.getNodeById(nodeId);
        tx.success();
        return nodeById;
    }
}
Also used : Serializable(java.io.Serializable) Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node)

Example 30 with Serializable

use of java.io.Serializable in project neo4j by neo4j.

the class AppsIT method canTerminateAnActiveCommand.

@Test
public void canTerminateAnActiveCommand() throws Exception {
    TransactionStats txStats = db.getDependencyResolver().resolveDependency(TransactionStats.class);
    assertEquals(0, txStats.getNumberOfActiveTransactions());
    Serializable clientId = shellClient.getId();
    Future<?> result = ForkJoinPool.commonPool().submit(() -> {
        try {
            while (txStats.getNumberOfActiveTransactions() == 0) {
                Thread.sleep(10);
            }
            assertEquals(1, txStats.getNumberOfActiveTransactions());
            shellServer.terminate(clientId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    });
    executeCommandExpectingException("FOREACH(i IN range(0, " + Integer.MAX_VALUE + ") | CREATE ());", "has been terminated");
    assertNull(result.get());
}
Also used : Serializable(java.io.Serializable) TransactionStats(org.neo4j.kernel.impl.transaction.TransactionStats) NodeStillHasRelationshipsException(org.neo4j.cypher.NodeStillHasRelationshipsException) IOException(java.io.IOException) RemoteException(java.rmi.RemoteException) 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