Skip to content

Commit

Permalink
Text addon tests no longer depend on network connectivity
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Apr 11, 2014
1 parent ee7706e commit d0e4984
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package org.jboss.forge.addon.text.highlight.scanner;

import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand All @@ -27,21 +24,12 @@ public abstract class AbstractScannerTestCase
Encoder.Factory.registrer(ASSERT_ENCODER, AssertEncoder.class);
}

public static String OUTPUT = "target/examples";
public static String BASE_URL = "https://raw.github.com/rubychan/coderay-scanner-tests/master/";
public static String OUTPUT = "src/test/resources/examples";
public static Pattern MATCH_DATA = Pattern.compile("(.*)\\..*\\..*");

protected String fetch(String type, String example) throws Exception
{
Path sourcePath = Paths.get(OUTPUT, type, example);
if (!Files.exists(sourcePath))
{
sourcePath.getParent().toFile().mkdirs();
URL source = new URL(BASE_URL + type + "/" + example);
System.out.println("Fetching " + source);
Files.write(sourcePath, asByteArray(new BufferedInputStream(source.openStream())), StandardOpenOption.WRITE,
StandardOpenOption.CREATE);
}
return new String(Files.readAllBytes(sourcePath));
}

Expand Down
1 change: 1 addition & 0 deletions text/src/test/resources/examples
Submodule examples added at 6eaf61

0 comments on commit d0e4984

Please sign in to comment.