コード例 #1
0
  private void compareBinaryFolder(String path, boolean res) throws BrutException, IOException {

    String tmp = "";
    if (res) {
      tmp = File.separatorChar + "res" + File.separatorChar;
    }

    Files.walkFileTree(
        Paths.get(sTestOrigDir.toPath() + tmp + path),
        new SimpleFileVisitor<Path>() {

          @Override
          public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
              throws IOException {

            // hacky fix - load test by changing name of control
            File control = file.toFile();
            File test = new File(file.toString().replace("testapp-orig", "testapp-new"));

            if (test.isFile()) {
              if (control.hashCode() != test.hashCode()) {
                sResult = false;
                return FileVisitResult.TERMINATE;
              }
            } else {
              sResult = false;
              return FileVisitResult.TERMINATE;
            }
            return FileVisitResult.CONTINUE;
          }
        });
  }
コード例 #2
0
  @Test
  @SuppressWarnings("unchecked")
  public void parse_object() throws IOException {
    List<Object> members =
        (List<Object>) parser.parse(resources.sourceFile(Paths.get("_data", "members.yml")));

    assertThat(members).hasSize(3);
    assertThat((Map<String, Object>) members.get(0))
        .containsExactly(entry("name", "Tom Preston-Werner"), entry("github", "mojombo"));
  }
コード例 #3
0
  @Test
  public void extension() {
    assertThat(Resources.extension(Paths.get("file.txt"))).isEqualTo(".txt");
    assertThat(Resources.extension(Paths.get("file.css.map"))).isEqualTo(".map");
    assertThat(Resources.extension(Paths.get(".dotfile.ext"))).isEqualTo(".ext");

    assertThat(Resources.extension(Paths.get("file"))).isEmpty();
    assertThat(Resources.extension(Paths.get(".dotfile"))).isEmpty();
    assertThat(Resources.extension(Paths.get("."))).isEmpty();
  }
コード例 #4
0
  @Before
  public void setUp() {

    try {
      final Method m = MiniProjet.class.getDeclaredMethod("loadConfigFile", Path.class);
      m.setAccessible(true);
      m.invoke(null, Paths.get(MiniProjet.FOLDER, MiniProjet.CONFIG));

    } catch (IllegalAccessException
        | IllegalArgumentException
        | InvocationTargetException
        | NoSuchMethodException
        | SecurityException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
コード例 #5
0
  @BeforeClass
  public static void findDependencies() throws Exception {
    Path path = Paths.get("target/classes");
    Archive archive = new Archive(path, ClassFileReader.newInstance(path)) {};
    Finder finder = Dependencies.getClassDependencyFinder();

    archive
        .reader()
        .getClassFiles()
        .forEach(
            classFile ->
                StreamSupport.stream(finder.findDependencies(classFile).spliterator(), false)
                    .filter(dependency -> !isAnnotation(dependency))
                    .filter(dependency -> !self(dependency))
                    .forEach(
                        dependency ->
                            packageDependencies
                                .computeIfAbsent(
                                    dependency.getOrigin().getPackageName(), key -> new TreeSet<>())
                                .add(dependency.getTarget().getPackageName())));
  }
コード例 #6
0
 @Test
 public void exists() {
   assertThat(Resources.exists(Paths.get("index.html"))).isTrue();
   assertThat(Resources.exists(Paths.get("js"))).isFalse();
 }