コード例 #1
0
ファイル: TraverserUtilTest.java プロジェクト: azusa/s2util
  /** @throws Exception */
  @Test
  public void testFromRootPackage_JarFile() throws Exception {
    Traverser[] traversers = TraversalUtil.getTraversers("junit.textui");
    assertThat(traversers, is(notNullValue()));
    assertThat(traversers.length, is(1));

    Traverser traverser = traversers[0];
    assertThat(traverser instanceof JarFileTraverser, is(true));

    assertThat(traverser.isExistClass("TestRunner"), is(true));
    assertThat(traverser.isExistClass("DummyTest"), is(not(true)));

    final Set<String> set = new HashSet<String>();
    traverser.forEach(
        new ClassHandler() {
          @Override
          public void processClass(String packageName, String shortClassName) {
            set.add(ClassUtil.concatName(packageName, shortClassName));
          }
        });
    assertThat(set.size(), is(2));
    assertThat(set.contains(ResultPrinter.class.getName()), is(true));
    assertThat(set.contains(TestRunner.class.getName()), is(true));
    assertThat(set.contains(junit.extensions.TestDecorator.class.getName()), is(not(true)));
  }
コード例 #2
0
ファイル: TraverserUtilTest.java プロジェクト: azusa/s2util
  /** @throws Exception */
  @Test
  public void testFromRootPackage_FileSystem() throws Exception {
    Traverser[] traversers = TraversalUtil.getTraversers("org.seasar.util.io.xxx");
    assertThat(traversers, is(notNullValue()));
    assertThat(traversers.length, is(1));

    Traverser traverser = traversers[0];
    assertThat(traverser instanceof FileSystemTraverser, is(true));

    assertThat(traverser.isExistClass("DummyTest"), is(true));
    assertThat(traverser.isExistClass("TestCase"), is(not(true)));

    final Set<String> set = new HashSet<String>();
    traverser.forEach(
        new ClassHandler() {
          @Override
          public void processClass(String packageName, String shortClassName) {
            set.add(ClassUtil.concatName(packageName, shortClassName));
          }
        });
    assertThat(set.size() > 0, is(true));
    assertThat(set.contains(DummyTest.class.getName()), is(true));
    assertThat(set.contains(TraverserUtilTest.class.getName()), is(not(true)));
    assertThat(set.contains(TestCase.class.getName()), is(not(true)));
  }