@Override public Void call() throws Exception { try { final Graph actual = asGraph(m_repo .prepareGraphQuery(queryStr)); assertTrue(!actual.isEmpty()); return null; } catch (Exception e) { log.warn("Call failure", e); errorCount.incrementAndGet(); throw e; } }
@Test public void testGraphSerialization() throws Exception { testCon.add(bob, name, nameBob); testCon.add(alice, name, nameAlice); Graph graph; RepositoryResult<Statement> statements = testCon.getStatements(null, null, null, true); try { graph = new LinkedHashModel(Iterations.asList(statements)); } finally { statements.close(); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); out.writeObject(graph); out.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream in = new ObjectInputStream(bais); Graph deserializedGraph = (Graph)in.readObject(); in.close(); assertThat(deserializedGraph.isEmpty(), is(equalTo(false))); for (Statement st : deserializedGraph) { assertThat(graph, hasItem(st)); assertThat(testCon.hasStatement(st, true), is(equalTo(true))); } }
@Override public Void call() throws Exception { try { final Graph actual = asGraph(m_repo .prepareGraphQuery(queryStr)); assertTrue(!actual.isEmpty()); return null; } catch (Exception e) { log.warn("Call failure", e); errorCount.incrementAndGet(); throw e; } }
public void testGraphSerialization() throws Exception { testCon.add(bob, name, nameBob); testCon.add(alice, name, nameAlice); Graph graph; RepositoryResult<Statement> statements = testCon.getStatements(null, null, null, true); try { graph = new GraphImpl(vf, statements.asList()); } finally { statements.close(); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); out.writeObject(graph); out.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream in = new ObjectInputStream(bais); Graph deserializedGraph = (Graph)in.readObject(); in.close(); assertFalse(deserializedGraph.isEmpty()); for (Statement st : deserializedGraph) { assertTrue(graph.contains(st)); assertTrue(testCon.hasStatement(st, true)); } }
@Test public void testGraphSerialization() throws Exception { testCon.add(bob, name, nameBob); testCon.add(alice, name, nameAlice); Graph graph; RepositoryResult<Statement> statements = testCon.getStatements(null, null, null, true); try { graph = new LinkedHashModel(Iterations.asList(statements)); } finally { statements.close(); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); out.writeObject(graph); out.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream in = new ObjectInputStream(bais); Graph deserializedGraph = (Graph)in.readObject(); in.close(); assertThat(deserializedGraph.isEmpty(), is(equalTo(false))); for (Statement st : deserializedGraph) { assertThat(graph, hasItem(st)); assertThat(testCon.hasStatement(st, true), is(equalTo(true))); } }