예제 #1
0
 // Check all iterators for correct size counts
 private void checkSizes(int expectedSize) {
   assertEquals("size()", _nbhm.size(), expectedSize);
   Collection<String> vals = _nbhm.values();
   checkSizes("values()", vals.size(), vals.iterator(), expectedSize);
   Set<String> keys = _nbhm.keySet();
   checkSizes("keySet()", keys.size(), keys.iterator(), expectedSize);
   Set<Entry<String, String>> ents = _nbhm.entrySet();
   checkSizes("entrySet()", ents.size(), ents.iterator(), expectedSize);
 }
예제 #2
0
  @Test(expected = ConstraintViolationException.class)
  public void testExceptionThrow() {
    Collection<Validator> validators = null;

    validators = new HashSet<>();
    validators.add(new PatternValidator("^[a-zA-Z]+://"));
    validators.add(new LengthValidator(255));
    new GroupValidator(validators).validate("tajo", true);

    fail();
  }
예제 #3
0
  @Test
  public void testGroupValidator() {
    String httpUrl = "http://tajo.apache.org";
    Collection<Validator> validators = null;

    validators = new HashSet<>();
    validators.add(new PatternValidator("^[a-zA-Z]+://"));
    validators.add(new LengthValidator(255));
    assertThat(new GroupValidator(validators).validate(httpUrl).size(), is(0));
    assertThat(new GroupValidator(validators).validate("tajo").size(), is(1));
    assertThat(
        new GroupValidator(validators).validate("tajo"),
        hasItem(hasAClass(equalTo(PatternValidator.class))));

    validators = new HashSet<>();
    validators.add(new PatternValidator("^[a-zA-Z]+://"));
    validators.add(new LengthValidator(7));
    assertThat(new GroupValidator(validators).validate(httpUrl).size(), is(1));
    assertThat(
        new GroupValidator(validators).validate(httpUrl),
        hasItem(hasAClass(equalTo(LengthValidator.class))));
  }