package org.sbolstandard.core2;

import static org.junit.Assert.assertTrue;

import java.io.IOException;
import java.io.InputStream;

/**
 * This test compares a generated SBOLDocument to a "golden" file read from disk. 
 * @author Tramy Nguyen
 * @author Chris Myers
 *
 */
public class SBOLReaderTest extends SBOLAbstractTests
{
	@Override
	public void runTest(final String fileName, final SBOLDocument expected, boolean compliant) throws SBOLValidationException, IOException, SBOLConversionException 
	{
		InputStream resourceAsStream = SBOLReaderTest.class.getResourceAsStream(fileName);
		if (resourceAsStream == null)
			resourceAsStream = SBOLReaderTest.class.getResourceAsStream("/" + fileName);

		assert resourceAsStream != null : "Failed to find test resource '" + fileName + "'";
		SBOLReader.setCompliant(compliant);
		
		SBOLDocument actual;
		if (compliant) {
			SBOLReader.setURIPrefix("http://www.async.ece.utah.edu");
			SBOLReader.setVersion("");
		}
		else SBOLReader.unsetURIPrefix();

//		if(fileType.equals("rdf"))
//			actual = SBOLReader.read(resourceAsStream);
//		else if (fileType.equals("json"))
//			actual = SBOLReader.read(resourceAsStream,SBOLDocument.JSON);
//		else if (fileType.equals("turtle"))
//			actual = SBOLReader.read(resourceAsStream,SBOLDocument.TURTLE);
//		else
		actual = SBOLReader.read(resourceAsStream);
		if (!actual.equals(expected)) {
			SBOLValidate.compareDocuments("actual", actual, "expected", expected);
			for (String error : SBOLValidate.getErrors()) {
				System.out.println(error);
			}
			
		}
		assertTrue(actual.equals(expected));
	}

}

@@ -1379,24 +1379,84 @@
 xpected)) %7B%0A
+%09%09%09System.out.println(%22Differences found for %22 + fileName);%0A
 %09%09%09SBOLValid

Add filename to error message