Skip to content

Instantly share code, notes, and snippets.

@oschrenk
Created October 11, 2012 08:03
Show Gist options
  • Save oschrenk/3870891 to your computer and use it in GitHub Desktop.
Save oschrenk/3870891 to your computer and use it in GitHub Desktop.
Testing with JUnit/Maven
import static org.junit.Assert.*;
import java.io.File;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import com.google.common.base.CharMatcher;
import com.google.common.base.Charsets;
import com.google.common.io.Files;
public class JsonEqivalenceTest {
/** The Constant JSON_PATH. */
private static final String JSON_PATH="/path/to/file.json";
@Test
public void testEqivalence() throws IOException {
final File inputFile=new File(this.getClass().getResource(JSON_PATH).getFile());
final String input=CharMatcher.WHITESPACE.removeFrom(Files.toString(inputFile, Charsets.UTF_8));
parse(inputFile);
final String output=CharMatcher.WHITESPACE.removeFrom(gson.toJson(action));
assertEquals(input, output);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment