Skip to content

Commit

Permalink
Using classloader to load test resources
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Apr 14, 2014
1 parent 54194c1 commit 3092143
Showing 1 changed file with 4 additions and 6 deletions.
Expand Up @@ -4,16 +4,14 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.jboss.forge.addon.text.highlight.Encoder;
import org.jboss.forge.addon.text.highlight.Scanner;
import org.jboss.forge.addon.text.highlight.Syntax;
import org.jboss.forge.addon.text.highlight.encoder.AssertEncoder;
import org.jboss.forge.furnace.util.Streams;
import org.junit.Assert;

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

public static String OUTPUT = "src/test/resources/examples";
public static String OUTPUT = "examples/";
public static Pattern MATCH_DATA = Pattern.compile("(.*)\\..*\\..*");

protected String fetch(String type, String example) throws Exception
{
Path sourcePath = Paths.get(OUTPUT, type, example);
return new String(Files.readAllBytes(sourcePath), DEFAULT_CHARSET);
InputStream is = getClass().getClassLoader().getResourceAsStream(OUTPUT + type + "/" + example);
return Streams.toString(is, DEFAULT_CHARSET);
}

private String expectedName(String example)
Expand Down

0 comments on commit 3092143

Please sign in to comment.