Sorry for double posting but I might add that with this code I get the 
following Exception:

java.lang.RuntimeException: org.apache.jena.riot.RiotException: [line: 1, col: 
7 ] Element or attribute do not match QName production: 
QName::=(NCName':')?NCName. 
        at 
org.aksw.deer.enrichments.DereferencingEnrichmentOperator.queryResourceModel(DereferencingEnrichmentOperator.java:231)

And when I change 

    ModelFactory.createDefaultModel().read(conn.getInputStream(), null)

to

    ModelFactory.createDefaultModel().read(conn.getInputStream(), null, 
"TURTLE")

but leave

    conn.setRequestProperty("Accept", "application/rdf+xml")

unchanged, it works as expected.

Using curl I see that Fuseki indeed delivers TURTLE:

$ curl -H "Accept: application/rdf+xml" http://localhost:32537/birch
<http://localhost:32537/birch> <http://localhost:32537/brinellHardness> 
"27"^^<http://www.w3.org/2001/XMLSchema#int> .

I am on Jena 3.9.0.

Hope thats enough information.

Best,
Kevin

> On 14. Jan 2019, at 16:29, Kevin Dreßler <kvndrs...@gmail.com> wrote:
> 
> This is the method where I do the request and which I effectively want to 
> test:
> 
>  private Model queryResourceModel(Resource o) {
>    URL url;
>    URLConnection conn;
>    Model result = ModelFactory.createDefaultModel();   
>    try {
>      url = new URL(o.getURI());
>    } catch (MalformedURLException e) {
>      e.printStackTrace();
>      return result;
>    }
>    try {
>      conn = url.openConnection();
>      conn.setRequestProperty("Accept", "application/rdf+xml");
>      conn.setRequestProperty("Accept-Language", "en");
>      return ModelFactory.createDefaultModel()
>        .read(conn.getInputStream(), null);
>    } catch (ConnectException e) {
>      if (e.getMessage().contains("refused")) {
>        throw new RuntimeException(e);
>      }
>    } catch (Exception e) {
>      throw new RuntimeException(e);
>    }
>    return result;
>  }
> 
> 
>> On 14. Jan 2019, at 15:09, ajs6f <aj...@apache.org> wrote:
>> 
>> Please show the code you are actually using to make requests.
>> 
>> ajs6f
>> 
>>> On Jan 14, 2019, at 9:06 AM, Kevin Dreßler <kvndrs...@gmail.com> wrote:
>>> 
>>> Hello, 
>>> 
>>> for unit testing I need to mock up a HTTP server delivering RDF/XML per 
>>> content negotiation (Accept: application/rdf+xml). For a HTTP request on 
>>> http://myEndpoint:myPort/test with the "Accept" header set as above it 
>>> should output DESCRIBE(http://myEndpoint:myPort/test) as RDF/XML, so 
>>> basically I want to mimic DBpedia. Is there a way to do this with a minimal 
>>> amount of configuration inside my tests using FUSEKI 2?
>>> Right now I am using the following code but I get the output only as TURTLE.
>>> 
>>>  String EX = "http://localhost:32537/";;
>>> 
>>>  Model lookup = ModelFactory.createDefaultModel();
>>>  lookup.add(lookup.createResource(EX + "birch"),
>>>    lookup.createProperty(EX + "brinellHardness"),
>>>    lookup.createTypedLiteral(27));
>>> 
>>>  FusekiServer server = FusekiServer.create()
>>>    .add("/birch", DatasetFactory.create(lookup))
>>>    .port(32537)
>>>    .build();
>>>  server.start();
>>> 
>>> Thanks in advance,
>>> Kevin
>> 
> 

Reply via email to