Skip to content

Commit

Permalink
Always use TestHelper to load fixture.
Browse files Browse the repository at this point in the history
  • Loading branch information
Weltraumschaf committed May 29, 2012
1 parent e4df7bd commit b04d5f0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
5 changes: 2 additions & 3 deletions java/src/test/java/de/weltraumschaf/ebnf/TestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.nio.charset.Charset;

/**
* Helper class to read fixture files.
*
* @author Sven Strittmatter <weltraumschaf@googlemail.com>
*/
Expand All @@ -31,9 +32,7 @@ public final class TestHelper {
private static final TestHelper INSTANCE = new TestHelper();


private TestHelper() {

}
private TestHelper() { }

public static TestHelper helper() {
return INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package de.weltraumschaf.ebnf.ast.builder;

import static de.weltraumschaf.ebnf.TestHelper.helper;
import static de.weltraumschaf.ebnf.ast.builder.SyntaxBuilder.syntax;
import de.weltraumschaf.ebnf.ast.nodes.Syntax;
import de.weltraumschaf.ebnf.ast.visitor.Xml;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import org.apache.commons.io.FileUtils;
import static org.junit.Assert.assertEquals;
import org.junit.Test;

Expand Down Expand Up @@ -75,8 +73,7 @@ public class SyntaxBuilderTest {
.end()
.build();

final URL resource = getClass().getResource("/de/weltraumschaf/ebnf/ast/visitor/syntax.xml");
final String xml = FileUtils.readFileToString(new File(resource.toURI()));
final String xml = helper().createStringFromFixture("ast/visitor/syntax.xml");
final Xml visitor = new Xml();
syntax.accept(visitor);
assertEquals(xml, visitor.getXmlString());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package de.weltraumschaf.ebnf.ast.visitor;

import com.google.common.collect.Maps;
import static de.weltraumschaf.ebnf.TestHelper.helper;
import static de.weltraumschaf.ebnf.ast.builder.SyntaxBuilder.syntax;
import de.weltraumschaf.ebnf.ast.nodes.Loop;
import de.weltraumschaf.ebnf.ast.nodes.Syntax;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import static org.junit.Assert.assertEquals;
import org.junit.Test;

Expand Down Expand Up @@ -125,8 +123,7 @@ public class XmlTest {
visitor = new Xml();
syntax.accept(visitor);

final URL resource = getClass().getResource("/de/weltraumschaf/ebnf/ast/visitor/syntax.xml");
final String xml = FileUtils.readFileToString(new File(resource.toURI()));
final String xml = helper().createStringFromFixture("ast/visitor/syntax.xml");
assertEquals(xml, visitor.getXmlString());
}

Expand Down

0 comments on commit b04d5f0

Please sign in to comment.