Example #1
0
 // @Test
 public void jarCopy() throws URISyntaxException, IOException {
   CrawlerUtils.copyDirectoryInJar(
       getClass().getResource("/JSearch-1.0-SHADED.jar").getFile(),
       "/META-INF/",
       new File("/tmp/test"));
   CrawlerUtils.copyFileInJar(
       getClass().getResource("/JSearch-1.0-SHADED.jar").getFile(),
       "/com/qwefgh90/io/jsearch/JSearch.class",
       new File("/tmp/test"));
 }
Example #2
0
  @Test
  public void pathUtilTest() throws IOException {

    LOG.info(Files.isDirectory(Paths.get("/tmp/test")) == true ? "True " : "False");
    LOG.info(Files.exists(Paths.get("/tmp/test")) == true ? "True " : "False");
    LOG.info(Files.isWritable(Paths.get("/tmp/test").getParent()) == true ? "True " : "False");

    try {
      LOG.info(CrawlerUtils.getResourcePath("config"));
      LOG.info(CrawlerUtils.getResourcePath(""));
      LOG.info(CrawlerUtils.getCurrentBuildPath());
    } catch (Exception e) {
      LOG.debug(e.toString());
    }
  }
Example #3
0
  // @Test
  public void hashCompare() throws Exception {
    String hash1 =
        CrawlerUtils.extractFileHashSHA256(getClass().getResource("/abcd.pdf").getFile());
    String hash2 =
        CrawlerUtils.extractFileHashSHA256(getClass().getResource("/abcd2.pdf").getFile());
    String hash3 =
        CrawlerUtils.extractFileHashSHA256(getClass().getResource("/qwer.pptx").getFile());
    String hash4 =
        CrawlerUtils.extractFileHashSHA256(getClass().getResource("/qwer2.pptx").getFile());

    assertTrue(hash1.equals(hash2));
    assertTrue(hash1.equals(hash1));
    assertTrue(hash3.equals(hash3));
    assertTrue(hash3.equals(hash4));
    assertFalse(hash1.equals(hash3));
  }
Example #4
0
 @Test
 public void iso88599TOeuckr() throws IOException {
   Stream<Path> s = Files.list(new File(CrawlerUtils.getResourcePath("convert")).toPath());
   Iterator<Path> iter = s.iterator();
   while (iter.hasNext()) {
     Path p = iter.next();
     LOG.info(
         new String(p.getFileName().toString().getBytes("ISO-8859-1"), Charset.forName("euc-kr")));
     String newName =
         new String(p.getFileName().toString().getBytes("ISO-8859-1"), Charset.forName("euc-kr"));
     p.toFile().renameTo(p.getParent().resolve(newName).toFile());
   }
   s.close();
   LOG.info(
       new String(
           "/tmp/firefox-downloads/hello".getBytes("ISO-8859-1"), Charset.forName("euc-kr")));
 }
Example #5
0
 // @Test
 public void resourceName() {
   LOG.info(CrawlerUtils.getResourcePath("abcd.pdf"));
   LOG.info(CrawlerUtils.getResourcePath("/abcd.pdf"));
   assertTrue(
       CrawlerUtils.getResourcePath("abcd.pdf").equals(CrawlerUtils.getResourcePath("/abcd.pdf")));
 }