// Path: segment/src/main/java/net/loomchild/segment/util/Util.java
// public static Reader getReader(InputStream inputStream) {
// 	try {
// 		Reader reader = new InputStreamReader(inputStream, "utf-8");
// 		return reader;
// 	} catch (UnsupportedEncodingException e) {
// 		throw new IORuntimeException(e);
// 	}
// }
// 
// Path: segment/src/main/java/net/loomchild/segment/util/Util.java
// public static InputStream getResourceStream(String name) {
// 	InputStream inputStream = Util.class.getClassLoader()
// 			.getResourceAsStream(name);
// 	if (inputStream == null) {
// 		throw new ResourceNotFoundException(name);
// 	}
// 	return inputStream;
// }
// 
// Path: segment/src/main/java/net/loomchild/segment/util/Util.java
// public static Templates getTemplates(Reader reader) {
// 	try {
// 		TransformerFactory factory = TransformerFactory.newInstance();
// 		Source source = new StreamSource(reader);
// 		Templates templates;
// 		templates = factory.newTemplates(source);
// 		return templates;
// 	} catch (TransformerConfigurationException e) {
// 		throw new XmlException("Error creating XSLT templates.", e);
// 	}
// }
// 
// Path: segment/src/main/java/net/loomchild/segment/util/Util.java
// public static void transform(Templates templates, Schema schema,
// 		Reader reader, Writer writer, Map<String, Object> parameterMap) {
// 	try {
// 		Source source = getSource(reader, schema);
// 		Result result = new StreamResult(writer);
// 		Transformer transformer = templates.newTransformer();
// 		transformer.setErrorListener(new TransformationErrorListener());
// 		for (Map.Entry<String, Object> entry : parameterMap.entrySet()) {
// 			transformer.setParameter(entry.getKey(), entry.getValue());
// 		}
// 		transformer.transform(source, result);
// 	} catch (TransformerConfigurationException e) {
// 		throw new XmlException("Error creating XSLT transformer.", e);
// 	} catch (TransformerException e) {
// 		throw new XmlException("XSLT transformer error.", e);
// 	}
// }
// 
// Path: segment/src/main/java/net/loomchild/segment/srx/SrxTransformer.java
// public interface SrxTransformer {
// 
// 	/**
// 	 * Transform given SRX document to newest supported version and write it to
// 	 * given writer.
// 	 * 
// 	 * @param reader reader containing SRX document
// 	 * @param writer writer to write transformed SRX document
// 	 * @param parameterMap map containing transformation parameters
// 	 */
// 	public void transform(Reader reader, Writer writer,
// 			Map<String, Object> parameterMap);
// 
// 	/**
// 	 * Transform given SRX document and return Reader containing newest
// 	 * supported version.
// 	 * 
// 	 * @param reader reader containing SRX document
// 	 * @param parameterMap map containing transformation parameters
// 	 * @return reader containing SRX document in newest supported version
// 	 */
// 	public Reader transform(Reader reader, Map<String, Object> parameterMap);
// 
// }
// 
// Path: segment/src/main/java/net/loomchild/segment/util/IORuntimeException.java
// public class IORuntimeException extends RuntimeException {
// 
// 	private static final long serialVersionUID = -6587044052300876023L;
// 
// 	public IORuntimeException(IOException exception) {
// 		super(exception);
// 	}
// 
// 	public void rethrow() throws IOException {
// 		throw (IOException) getCause();
// 	}
// 
// }


import static net.loomchild.segment.util.Util.getReader;
import static net.loomchild.segment.util.Util.getResourceStream;
import static net.loomchild.segment.util.Util.getTemplates;
import static net.loomchild.segment.util.Util.transform;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
import javax.xml.transform.Templates;
import junit.framework.TestCase;
import net.loomchild.segment.srx.SrxTransformer;
import net.loomchild.segment.util.IORuntimeException;
package net.loomchild.segment.srx.io;





public class SrxTransformersTest extends TestCase {

	public static final String SRX_1_DOCUMENT_NAME = "net/loomchild/segment/res/test/example1.srx";

	public static final String SRX_2_DOCUMENT_NAME = "net/loomchild/segment/res/test/example2.srx";

	public static final String STYLESHEET = "net/loomchild/segment/res/xml/strip-space.xsl";

// Path: segment/src/main/java/net/loomchild/segment/util/Util.java
// public static Reader getReader(InputStream inputStream) {
// 	try {
// 		Reader reader = new InputStreamReader(inputStream, "utf-8");
// 		return reader;
// 	} catch (UnsupportedEncodingException e) {
// 		throw new IORuntimeException(e);
// 	}
// }
// 
// Path: segment/src/main/java/net/loomchild/segment/util/Util.java
// public static InputStream getResourceStream(String name) {
// 	InputStream inputStream = Util.class.getClassLoader()
// 			.getResourceAsStream(name);
// 	if (inputStream == null) {
// 		throw new ResourceNotFoundException(name);
// 	}
// 	return inputStream;
// }
// 
// Path: segment/src/main/java/net/loomchild/segment/util/Util.java
// public static Templates getTemplates(Reader reader) {
// 	try {
// 		TransformerFactory factory = TransformerFactory.newInstance();
// 		Source source = new StreamSource(reader);
// 		Templates templates;
// 		templates = factory.newTemplates(source);
// 		return templates;
// 	} catch (TransformerConfigurationException e) {
// 		throw new XmlException("Error creating XSLT templates.", e);
// 	}
// }
// 
// Path: segment/src/main/java/net/loomchild/segment/util/Util.java
// public static void transform(Templates templates, Schema schema,
// 		Reader reader, Writer writer, Map<String, Object> parameterMap) {
// 	try {
// 		Source source = getSource(reader, schema);
// 		Result result = new StreamResult(writer);
// 		Transformer transformer = templates.newTransformer();
// 		transformer.setErrorListener(new TransformationErrorListener());
// 		for (Map.Entry<String, Object> entry : parameterMap.entrySet()) {
// 			transformer.setParameter(entry.getKey(), entry.getValue());
// 		}
// 		transformer.transform(source, result);
// 	} catch (TransformerConfigurationException e) {
// 		throw new XmlException("Error creating XSLT transformer.", e);
// 	} catch (TransformerException e) {
// 		throw new XmlException("XSLT transformer error.", e);
// 	}
// }
// 
// Path: segment/src/main/java/net/loomchild/segment/srx/SrxTransformer.java
// public interface SrxTransformer {
// 
// 	/**
// 	 * Transform given SRX document to newest supported version and write it to
// 	 * given writer.
// 	 * 
// 	 * @param reader reader containing SRX document
// 	 * @param writer writer to write transformed SRX document
// 	 * @param parameterMap map containing transformation parameters
// 	 */
// 	public void transform(Reader reader, Writer writer,
// 			Map<String, Object> parameterMap);
// 
// 	/**
// 	 * Transform given SRX document and return Reader containing newest
// 	 * supported version.
// 	 * 
// 	 * @param reader reader containing SRX document
// 	 * @param parameterMap map containing transformation parameters
// 	 * @return reader containing SRX document in newest supported version
// 	 */
// 	public Reader transform(Reader reader, Map<String, Object> parameterMap);
// 
// }
// 
// Path: segment/src/main/java/net/loomchild/segment/util/IORuntimeException.java
// public class IORuntimeException extends RuntimeException {
// 
// 	private static final long serialVersionUID = -6587044052300876023L;
// 
// 	public IORuntimeException(IOException exception) {
// 		super(exception);
// 	}
// 
// 	public void rethrow() throws IOException {
// 		throw (IOException) getCause();
// 	}
// 
// }


// Path: segment/src/test/java/net/loomchild/segment/srx/io/SrxTransformersTest.java
import static net.loomchild.segment.util.Util.getReader;
import static net.loomchild.segment.util.Util.getResourceStream;
import static net.loomchild.segment.util.Util.getTemplates;
import static net.loomchild.segment.util.Util.transform;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
import javax.xml.transform.Templates;
import junit.framework.TestCase;
import net.loomchild.segment.srx.SrxTransformer;
import net.loomchild.segment.util.IORuntimeException;

package net.loomchild.segment.srx.io;





public class SrxTransformersTest extends TestCase {

	public static final String SRX_1_DOCUMENT_NAME = "net/loomchild/segment/res/test/example1.srx";

	public static final String SRX_2_DOCUMENT_NAME = "net/loomchild/segment/res/test/example2.srx";

	public static final String STYLESHEET = "net/loomchild/segment/res/xml/strip-space.xsl";

	private static final Templates templates = getTemplates(getReader(getResourceStream(STYLESHEET)));