@Test public void testSettingContextAsObjectExpectedByJsonldAPI() {

    String ns = "http://www.a.com/foo/";
    Model m = simpleModel(ns);
    m.setNsPrefix("ex", ns);
    String s1 = toString(m, RDFFormat.JSONLD_COMPACT_FLAT, null);
    // there's a prefix in m, and we find it in the output
    String prefixStringInResult = "\"ex\":\"" + ns + "\"";
    assertTrue(s1.contains(prefixStringInResult));
    Model m1 = parse(s1);
    // the context used in this case, as it would automatically be created as none is set
    // it includes one prefix
    Object ctx = JsonLDWriter.createJsonldContext(m.getGraph());
    // remove the prefix from m
    m.removeNsPrefix("ex");
    String s2 = toString(m, RDFFormat.JSONLD_COMPACT_PRETTY, null);
    // model wo prefix -> no more prefix string in result:
    assertFalse(s2.contains(prefixStringInResult));
    // the model wo prefix, output as jsonld using a context that defines the prefix
    Context jenaCtx = new Context();
    jenaCtx.set(JsonLDWriter.JSONLD_CONTEXT, ctx);
    String s3 = toString(m, RDFFormat.JSONLD_COMPACT_FLAT, jenaCtx);
    assertTrue(s3.length() == s1.length());
    assertTrue(s3.contains(prefixStringInResult));
    Model m3 = parse(s3);
    assertTrue(m3.isIsomorphicWith(m));
    assertTrue(m3.isIsomorphicWith(m1));
}