예제 #1
0
  public void testValidate_Failure() {
    Definition def = new Definition(user, DataForTests.invalid_definition);
    try {
      assertEquals(
          "Definition string not set correctly", def.get(), DataForTests.invalid_definition);
    } catch (EInvalidData e1) {
      fail("EInvalidData: " + e1.getMessage());
    }

    try {
      def.validate();
      fail("Expected ECompileFailed exception was not thrown");
    } catch (EInvalidData e) {
      fail("InvalidData: " + e.getMessage());
    } catch (ECompileFailed e) {
      // This is what we should get
    } catch (EAccessDenied e) {
      fail("AccessDenied: " + e.getMessage());
    }
  }
예제 #2
0
  public void testValidate_SuccessThenFailure() {
    Definition def = new Definition(user, DataForTests.definition);
    try {
      assertEquals("Definition string not set correctly", def.get(), DataForTests.definition);
    } catch (EInvalidData e1) {
      fail("EInvalidData: " + e1.getMessage());
    }

    try {
      def.validate();

      // We should now have a hash
      assertEquals("Hash is not correct", def.getHash(), DataForTests.definition_hash);
    } catch (EInvalidData e) {
      fail("InvalidData: " + e.getMessage());
    } catch (ECompileFailed e) {
      fail("CompileFailed: " + e.getMessage());
    } catch (EAccessDenied e) {
      fail("AccessDenied: " + e.getMessage());
    }

    // Now set the invalid definition in that same object
    def.set(DataForTests.invalid_definition);
    try {
      assertEquals(
          "Definition string not set correctly", def.get(), DataForTests.invalid_definition);
    } catch (EInvalidData e1) {
      fail("EInvalidData: " + e1.getMessage());
    }

    try {
      def.compile();
      fail("CompileFailed exception expected, but not thrown");
    } catch (EInvalidData e) {
      fail("InvalidData: " + e.getMessage());
    } catch (ECompileFailed e) {
      // This is what we should get
    } catch (EAccessDenied e) {
      fail("AccessDenied: " + e.getMessage());
    }
  }
예제 #3
0
  public void testValidate_Success() {
    Definition def = new Definition(user, DataForTests.definition);
    try {
      assertEquals("Definition string not set correctly", def.get(), DataForTests.definition);
    } catch (EInvalidData e1) {
      fail("EInvalidData: " + e1.getMessage());
    }

    try {
      def.validate();

      // We should now have a hash
      assertEquals("Incorrect hash", def.getHash(), DataForTests.definition_hash);
    } catch (EInvalidData e) {
      fail("InvalidData: " + e.getMessage());
    } catch (ECompileFailed e) {
      fail("CompileFailed: " + e.getMessage());
    } catch (EAccessDenied e) {
      fail("AccessDenied: " + e.getMessage());
    }
  }