예제 #1
0
  // 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);
  }
예제 #2
0
 // Specific dataset
 @Test
 public void list_datasets_4() {
   try {
     getDatasetDescription("does-not-exist");
   } catch (HttpException ex) {
     assertEquals(HttpSC.NOT_FOUND_404, ex.getResponseCode());
   }
 }
예제 #3
0
 @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);
 }
예제 #4
0
 @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());
   }
 }
예제 #5
0
 @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);
 }
예제 #6
0
  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());
    }
  }
예제 #7
0
 @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) {
   }
 }