Ejemplo n.º 1
0
  /** @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)));
  }
Ejemplo n.º 2
0
  /** @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)));
  }
Ejemplo n.º 3
0
  /** @throws Exception */
  @Test
  public void testFromDir_FileSystem() throws Exception {
    Traverser traverser = TraversalUtil.getTraverser("org/seasar/util/io/xxx");
    assertThat(traverser, is(notNullValue()));
    assertThat(traverser instanceof FileSystemTraverser, is(true));

    final List<String> list = new ArrayList<String>();
    traverser.forEach(
        new ResourceHandler() {
          @Override
          public void processResource(String path, InputStream is) {
            list.add(path);
          }
        });
    assertThat(list.size(), is(1));
    assertThat((list.get(0)).endsWith("DummyTest.class"), is(true));
  }
Ejemplo n.º 4
0
  /** @throws Exception */
  @Test
  public void testFromDir_JarFile() throws Exception {
    Traverser traverser = TraversalUtil.getTraverser("junit/textui");
    assertThat(traverser, is(notNullValue()));
    assertThat(traverser instanceof JarFileTraverser, is(true));

    final List<String> list = new ArrayList<String>();
    traverser.forEach(
        new ResourceHandler() {
          @Override
          public void processResource(String path, InputStream is) {
            list.add(path);
          }
        });
    assertThat(list.size(), is(2));
    assertThat(list.get(0), is("junit/textui/ResultPrinter.class"));
    assertThat(list.get(1), is("junit/textui/TestRunner.class"));
  }
Ejemplo n.º 5
0
  /** @throws Exception */
  @Test
  public void testFromClass_JarFile() throws Exception {
    Traverser traverser = TraversalUtil.getTraverser(TestCase.class);
    assertThat(traverser, is(notNullValue()));
    assertThat(traverser instanceof JarFileTraverser, is(true));

    assertThat(traverser.isExistClass(TestCase.class.getName()), is(true));
    assertThat(traverser.isExistClass(DummyTest.class.getName()), 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(TestCase.class.getName()), is(true));
    assertThat(set.contains(DummyTest.class.getName()), is(not(true)));
  }