/** Setup a testing server, using the given Jetty {@link SecurityHandler} for authentication. */ public static void setupServer(boolean updateable, SecurityHandler sh, DatasetGraph dsg) { dsgTesting = dsg; server = FusekiServer.create() .add(datasetPath(), dsgTesting) .setPort(port()) .setSecurityHandler(sh) .build() .start(); }
public static void ctlBeforeTestSuite() { if ( serverScope == SUITE ) { setPoolingHttpClient() ; allocServer(); } }
/*package*/ static void teardownServer() { if ( server != null ) { server.stop() ; server = null ; } }
public void cfg_bad_ct_not_enabkled_here() { FusekiServer server = FusekiServer.create() .setPort(port) .registerOperation(newOp, "app/special", customHandler) .add("/ds", DatasetGraphFactory.createTxnMem(), true) // Unregistered. .addOperation("/ds", endpointName, newOp) .build(); testServer(server, false, false); }
@Test public void embedded_08() { DatasetGraph dsg = dataset() ; int port = FusekiLib.choosePort() ; FusekiServer server = FusekiServer.create() .setPort(port) .parseConfigFile(DIR+"config.ttl") .build() ; server.start() ; try { query("http://localhost:"+port+"/FuTest", "SELECT * {}", x->{}) ; } finally { server.stop() ; } }
@Test(expected=FusekiConfigException.class) public void cfg_bad_02() { FusekiServer.create() .setPort(port) //.registerOperation(newOp, null, customHandler) .add("/ds", DatasetGraphFactory.createTxnMem(), true) // Unregistered. .addOperation("/ds", endpointName, newOp); //.build(); }
@Test(expected=FusekiConfigException.class) public void cfg_bad_01() { FusekiServer.create() .setPort(port) .registerOperation(newOp, null, customHandler) .addOperation("/UNKNOWN", endpointName, newOp); //.build(); }
/** * Clean up after each test by resetting the Fuseki dataset */ public static void ctlAfterTest() { if ( serverScope == TEST ) { freeServer(); resetDefaultHttpClient() ; } else resetServer(); }
public static void ctlAfterTestSuite() { if ( serverScope == SUITE ) { freeServer(); resetDefaultHttpClient() ; } }
public static final String serviceUpdate() { return "http://localhost:"+port()+datasetPath()+"/update" ; } public static final String serviceQuery() { return "http://localhost:"+port()+datasetPath()+"/query" ; }
@Override protected void doPut(HttpAction action) { notSupported(action); }
/** Create a Jetty {@link SecurityHandler} for basic authentication, one user/password/role. */ public static SecurityHandler makeSimpleSecurityHandler(String pathSpec, String user, String password) { return makeSimpleSecurityHandler(pathSpec, null, user, password, "FusekiTestRole"); }
@Test public void cfg_builder_noCT() { FusekiServer server = FusekiServer.create() .setPort(port) .registerOperation(newOp, null, customHandler) .add("/ds", DatasetGraphFactory.createTxnMem(), true) .addOperation("/ds", endpointName, newOp) .build(); testServer(server, true, false); }
/** Shutdown the server.*/ public static void teardownServer() { if ( server != null ) { server.stop() ; server = null ; dsgTesting = null; } }
/** * Setup for the tests by allocating a Fuseki instance to work with */ public static void ctlBeforeClass() { if ( serverScope == CLASS ) { setPoolingHttpClient() ; allocServer(); } }
/** * Clean up after tests by de-allocating the Fuseki instance */ public static void ctlAfterClass() { if ( serverScope == CLASS ) { freeServer(); resetDefaultHttpClient() ; } }
@Override protected void doOptions(HttpAction action) { notSupported(action); }
@Test public void cfg_builder_CT() { FusekiServer server = FusekiServer.create() .setPort(port) .registerOperation(newOp, contentType, customHandler) .add("/ds", DatasetGraphFactory.createTxnMem(), true) .addOperation("/ds", endpointName, newOp) .build(); testServer(server, true, true); }
/** * Placeholder. */ public static void ctlBeforeTest() { if ( serverScope == TEST ) { setPoolingHttpClient() ; allocServer(); } }