package com.github.jsonldjava.impl;

import static org.junit.Assert.*;

import java.io.StringWriter;

import org.junit.Test;

import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.Resource;

public class JenaJSONWriterTest {
    
    static {
        JenaJSONLDWriter.registerWithJena();
    }
    
    @Test
    public void write() throws Exception {
        Model model = ModelFactory.createDefaultModel();
        Resource resource = model.createResource("http://example.com/test");
        Property property = model.createProperty("http://example.com/value");
        model.add(resource, property, "Test");
        
        StringWriter writer = new StringWriter();
        model.write(writer, "JSON-LD");
        
        String json = writer.toString();
//        System.out.println(json);
        assertTrue(json.contains("@id"));
        assertTrue(json.contains("http://example.com/test"));
        assertTrue(json.contains("http://example.com/value"));
        assertTrue(json.contains("Test"));
    }
    
}

@@ -65,9 +65,62 @@
 ert.
-*
+assertFalse;%0Aimport static org.junit.Assert.assertTrue
 ;%0A%0Ai
@@ -172,16 +172,62 @@
 .Test;%0A%0A
+import com.github.jsonldjava.jena.JenaJSONLD;%0A
 import c
@@ -444,16 +444,18 @@
 tatic %7B%0A
+//
         
@@ -487,24 +487,52 @@
 WithJena();%0A
+        JenaJSONLD.init(); %0A
     %7D%0A    %0A 
@@ -991,18 +991,16 @@
 ring();%0A
-//
         
@@ -1025,16 +1025,16 @@
 (json);%0A
+
         
@@ -1125,24 +1125,24 @@
 om/test%22));%0A
-
         asse
@@ -1246,10 +1246,854 @@
  %7D%0A    %0A
+    @Test%0A    public void writeWithBase() throws Exception %7B%0A        Model model = ModelFactory.createDefaultModel();%0A        Resource resource = model.createResource(%22http://example.com/test%22);%0A        Property property = model.createProperty(%22http://example.com/value%22);%0A        model.add(resource, property, %22Test%22);%0A        %0A        StringWriter writer = new StringWriter();%0A        model.write(writer, %22JSON-LD%22, %22http://example.com/%22);%0A        %0A        String json = writer.toString();%0A        System.out.println(json);%0A        assertTrue(json.contains(%22@id%22));%0A        assertFalse(json.contains(%22http://example.com/test%22));%0A        assertTrue(json.contains(%22%5C%22test%5C%22%22));%0A        assertFalse(json.contains(%22http://example.com/value%22));%0A        assertTrue(json.contains(%22%5C%22value%5C%22%22));%0A        assertTrue(json.contains(%22Test%22));%0A    %7D%0A    %0A
 %7D%0A

Test against RIOT writers - also test with base