@Test public void testOpenStream() throws IOException { ClassPath classPath = new ClassPath(); final Collection<TargetElement> targets = classPath.findTargets("testsql/", Pattern.compile("test1_20111101\\.sql")); Assert.assertEquals(1, targets.size()); final TargetElement element = targets.iterator().next(); InputStream resourceStream = element.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(resourceStream)); Assert.assertEquals("Dummy content", reader.readLine()); }
@Test public void testSearch() { ClassPath classPath = new ClassPath(); final Collection<TargetElement> targets = classPath.findTargets("testsql/", Pattern.compile(".+\\.sql")); Assert.assertEquals(2, targets.size()); for (TargetElement element : targets) { if ((!element.getName().equals("test1_20111101.sql")) && (!element.getName().equals("test2_20111102.sql"))) { Assert.fail(String.format("Invalid target found %s", element.getName())); } } }