// Try to add twice @Test public void add_delete_dataset_2() { checkNotThere(dsTest); File f = new File("testing/config-ds-1.ttl"); { org.apache.http.entity.ContentType ct = org.apache.http.entity.ContentType.parse( WebContent.contentTypeTurtle + "; charset=" + WebContent.charsetUTF8); HttpEntity e = new FileEntity(f, ct); execHttpPost(ServerTest.urlRoot + "$/" + opDatasets, e); } // Check exists. checkExists(dsTest); try { org.apache.http.entity.ContentType ct = org.apache.http.entity.ContentType.parse( WebContent.contentTypeTurtle + "; charset=" + WebContent.charsetUTF8); HttpEntity e = new FileEntity(f, ct); execHttpPost(ServerTest.urlRoot + "$/" + opDatasets, e); } catch (HttpException ex) { assertEquals(HttpSC.CONFLICT_409, ex.getResponseCode()); } // Check exists. checkExists(dsTest); deleteDataset(dsTest); }
// Specific dataset @Test public void list_datasets_4() { try { getDatasetDescription("does-not-exist"); } catch (HttpException ex) { assertEquals(HttpSC.NOT_FOUND_404, ex.getResponseCode()); } }
@Test public void state_3() { addTestDataset(); try { execHttpPost(ServerTest.urlRoot + "$/" + opDatasets + "/DoesNotExist?state=offline", null); } catch (HttpException ex) { assertEquals(HttpSC.NOT_FOUND_404, ex.getResponseCode()); } deleteDataset(dsTest); }
@Test public void delete_dataset_1() { String name = "NoSuchDataset"; try { execHttpDelete(ServerTest.urlRoot + "$/" + opDatasets + "/" + name); fail("delete did not cause an Http Exception"); } catch (HttpException ex) { assertEquals(HttpSC.NOT_FOUND_404, ex.getResponseCode()); } }
@Test public void stats_3() { addTestDataset(); try { JsonValue v = execGetJSON(urlRoot + "$/" + opStats + "/DoesNotExist"); checkJsonStatsAll(v); } catch (HttpException ex) { assertEquals(HttpSC.NOT_FOUND_404, ex.getResponseCode()); } deleteDataset(dsTest); }
private static void checkNotThere(String name) { if (name.startsWith("/")) name = name.substring(1); // Check gone exists. try { adminPing(name); } catch (HttpException ex) { assertEquals(HttpSC.NOT_FOUND_404, ex.getResponseCode()); } try { askPing(name); } catch (HttpException ex) { assertEquals(HttpSC.NOT_FOUND_404, ex.getResponseCode()); } }
@Test public void task_2() { String x = "NoSuchTask"; String url = urlRoot + "$/tasks/" + x; try { httpGetJson(url); } catch (HttpException ex) { assertEquals(404, ex.getResponseCode()); } try { checkInTasks(x); fail("No failure!"); } catch (AssertionError ex) { } }