Strabon
changeset 1164:42caaa72ddf8
added test for store operation of sparql endpoint client
author | Kallirroi Dogani <kallirroi@di.uoa.gr> |
---|---|
date | Fri May 10 14:40:32 2013 +0300 (2013-05-10) |
parents | 2be7757ab6b7 |
children | 8f33dfbb8c50 |
files | endpoint-client/src/test/java/eu/earthobservatory/org/StrabonEndpoint/client/TestSPARQLEndpointStoreWithStrabon.java |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/endpoint-client/src/test/java/eu/earthobservatory/org/StrabonEndpoint/client/TestSPARQLEndpointStoreWithStrabon.java Fri May 10 14:40:32 2013 +0300 1.3 @@ -0,0 +1,87 @@ 1.4 +/** 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.8 + * 1.9 + * Copyright (C) 2013, Pyravlos Team 1.10 + * 1.11 + * http://www.strabon.di.uoa.gr/ 1.12 + */ 1.13 +package eu.earthobservatory.org.StrabonEndpoint.client; 1.14 + 1.15 +import static org.junit.Assert.assertTrue; 1.16 + 1.17 +import java.io.IOException; 1.18 +import java.net.MalformedURLException; 1.19 +import java.net.URL; 1.20 +import java.util.Vector; 1.21 + 1.22 +import org.junit.Before; 1.23 +import org.junit.Test; 1.24 +import org.openrdf.query.resultio.TupleQueryResultFormat; 1.25 +import org.openrdf.query.resultio.stSPARQLQueryResultFormat; 1.26 +import org.openrdf.rio.RDFFormat; 1.27 + 1.28 +/** 1.29 + * @author Kallirroi Dogani <kallirroi@di.uoa.gr> 1.30 + * 1.31 + */ 1.32 +public class TestSPARQLEndpointStoreWithStrabon { 1.33 + 1.34 + private SPARQLEndpoint endpoint; 1.35 + private String query; 1.36 + private Vector<stSPARQLQueryResultFormat> formats = new Vector<stSPARQLQueryResultFormat>(); 1.37 + private URL data; 1.38 + 1.39 + @Before 1.40 + public void init() { 1.41 + // initialize endpoint 1.42 + endpoint = new SPARQLEndpoint("luna.di.uoa.gr", 8080, "endpoint/Store"); 1.43 + 1.44 + // set url data 1.45 + try { 1.46 + data = new URL("http://luna.di.uoa.gr:8080/strabon-endpoint-gwt/mapontology/map.nt"); 1.47 + } catch (MalformedURLException e) { 1.48 + // TODO Auto-generated catch block 1.49 + e.printStackTrace(); 1.50 + } 1.51 + 1.52 + endpoint.setUser("endpoint"); 1.53 + endpoint.setPassword("3ndpo1nt"); 1.54 + 1.55 + // initialized formats 1.56 + for (TupleQueryResultFormat format : stSPARQLQueryResultFormat.values()) { 1.57 + if (format instanceof stSPARQLQueryResultFormat) { 1.58 + formats.add((stSPARQLQueryResultFormat) format); 1.59 + } 1.60 + } 1.61 + 1.62 + } 1.63 + 1.64 + /** 1.65 + * Test method for {@link eu.earthobservatory.org.StrabonEndpoint.client.SPARQLEndpoint#query(java.lang.String, org.openrdf.query.resultio.stSPARQLQueryResultFormat)}. 1.66 + * @throws IOException 1.67 + */ 1.68 + @Test 1.69 + public void testStoreFromUrl() throws IOException { 1.70 + 1.71 + Boolean response = endpoint.store(data, RDFFormat.NTRIPLES , null); 1.72 + 1.73 + if (response != true) 1.74 + System.err.println("Error"); 1.75 + 1.76 + 1.77 + assertTrue(response == true); 1.78 + 1.79 + } 1.80 + 1.81 + /** 1.82 + * Test method for testing that method {@link eu.earthobservatory.org.StrabonEndpoint.client.SPARQLEndpoint#query(java.lang.String, org.openrdf.query.resultio.stSPARQLQueryResultFormat)}. 1.83 + * returns an IOException when it should do so. 1.84 + */ 1.85 + @Test(expected= IOException.class) 1.86 + public void testIOException() throws Exception { 1.87 + SPARQLEndpoint ep = new SPARQLEndpoint("blabla.dgr", 80, "bla"); 1.88 + ep.query(query, formats.get(0)); 1.89 + } 1.90 +} 1.91 \ No newline at end of file