Esempio n. 1
0
  private void verifyViewCreation() {
    // replace works for new view
    doCreateView(temporaryCreateView, true);

    // replace works for existing view
    doCreateView(temporaryCreateView, true);

    // create fails for existing view
    try {
      doCreateView(temporaryCreateView, false);
      fail("create existing should fail");
    } catch (ViewAlreadyExistsException e) {
      assertEquals(e.getViewName(), temporaryCreateView);
    }

    // drop works when view exists
    metadata.dropView(SESSION, temporaryCreateView);
    assertEquals(metadata.getViews(SESSION, temporaryCreateView.toSchemaTablePrefix()).size(), 0);
    assertFalse(
        metadata
            .listViews(SESSION, temporaryCreateView.getSchemaName())
            .contains(temporaryCreateView));

    // drop fails when view does not exist
    try {
      metadata.dropView(SESSION, temporaryCreateView);
      fail("drop non-existing should fail");
    } catch (ViewNotFoundException e) {
      assertEquals(e.getViewName(), temporaryCreateView);
    }

    // create works for new view
    doCreateView(temporaryCreateView, false);
  }
Esempio n. 2
0
 @Test
 public void testViewCreation() {
   try {
     verifyViewCreation();
   } finally {
     try {
       metadata.dropView(SESSION, temporaryCreateView);
     } catch (RuntimeException e) {
       Logger.get(getClass()).warn(e, "Failed to drop view: %s", temporaryCreateView);
     }
   }
 }