@Test public void testIsWriteable() { assertTrue( "Should be able to serialize this!", testProvider.isWriteable( RdfStream.class, null, null, MediaType.valueOf("application/rdf+xml"))); assertFalse( "Should not be able to serialize this!", testProvider.isWriteable( RdfStreamProviderTest.class, null, null, MediaType.valueOf("application/rdf+xml"))); assertFalse( "Should not be able to serialize this!", testProvider.isWriteable(RdfStream.class, null, null, MediaType.valueOf("text/html"))); }
@Before public void setUp() throws RepositoryException { initMocks(this); testProvider.registerMimeTypes(); when(mockSession.getWorkspace()).thenReturn(mockWorkspace); when(mockWorkspace.getNamespaceRegistry()).thenReturn(mockNamespaceRegistry); when(mockNamespaceRegistry.getPrefixes()).thenReturn(new String[] {}); }
@Test public void testWriteTo() throws WebApplicationException, IllegalArgumentException, IOException { final Triple t = create(createURI("info:test"), createURI("property:test"), createURI("info:test")); final RdfStream rdfStream = new RdfStream(t).session(mockSession); byte[] result; try (ByteArrayOutputStream entityStream = new ByteArrayOutputStream(); ) { testProvider.writeTo( rdfStream, RdfStream.class, null, null, MediaType.valueOf("application/rdf+xml"), null, entityStream); result = entityStream.toByteArray(); } final Model postSerialization = createDefaultModel().read(new ByteArrayInputStream(result), null); assertTrue( "Didn't find our triple!", postSerialization.contains(postSerialization.asStatement(t))); }
@Test public void testGetSize() { assertEquals(-1, testProvider.getSize(null, null, null, null, null)); }