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);
});
}
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"));
}
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"));
}
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;
}
}
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());
}
Aggregations