// Path: src/main/java/com/siemens/ct/exi/main/helpers/DefaultSchemaIdResolver.java
// public class DefaultSchemaIdResolver implements SchemaIdResolver {
// 
// 	// protected GrammarFactory gf;
// 
// 	public DefaultSchemaIdResolver() {
// 
// 	}
// 
// 	protected GrammarFactory getGrammarFactory() {
// 		return GrammarFactory.newInstance();
// 		// if (gf == null) {
// 		// gf = GrammarFactory.newInstance();
// 		// }
// 		// return gf;
// 	}
// 
// 	public Grammars resolveSchemaId(String schemaId) throws EXIException {
// 		if (schemaId == null) {
// 			return getGrammarFactory().createSchemaLessGrammars();
// 		} else if ("".equals(schemaId)) {
// 			return getGrammarFactory().createXSDTypesOnlyGrammars();
// 		} else {
// 			// interpret schemaId as location
// 			try {
// 				return getGrammarFactory().createGrammars(schemaId);
// 			} catch (Exception e) {
// 				throw new EXIException(this.getClass().getName()
// 						+ " failed to retrieve schemaId == " + schemaId, e);
// 			}
// 		}
// 	}
// 
// }


import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.namespace.QName;
import junit.framework.TestCase;
import com.siemens.ct.exi.core.CodingMode;
import com.siemens.ct.exi.core.Constants;
import com.siemens.ct.exi.core.EXIFactory;
import com.siemens.ct.exi.core.EncodingOptions;
import com.siemens.ct.exi.core.FidelityOptions;
import com.siemens.ct.exi.core.SchemaIdResolver;
import com.siemens.ct.exi.core.coder.EXIHeaderDecoder;
import com.siemens.ct.exi.core.coder.EXIHeaderEncoder;
import com.siemens.ct.exi.core.exceptions.EXIException;
import com.siemens.ct.exi.core.grammars.Grammars;
import com.siemens.ct.exi.core.helpers.DefaultEXIFactory;
import com.siemens.ct.exi.core.io.channel.BitDecoderChannel;
import com.siemens.ct.exi.core.io.channel.BitEncoderChannel;
import com.siemens.ct.exi.core.io.channel.DecoderChannel;
import com.siemens.ct.exi.core.io.channel.EncoderChannel;
import com.siemens.ct.exi.grammars.GrammarFactory;
import com.siemens.ct.exi.main.helpers.DefaultSchemaIdResolver;

			fail("No Valid Cookie");
		} catch (Exception e) {
			// no valid cookie
		}
	}

	protected void _testOptions(EXIFactory test) throws EXIException,
			IOException {
		_testOptions(test, null);
	}

	protected void _testOptions(EXIFactory test, EXIFactory noOptionsFactory)
			throws EXIException, IOException {
		EXIHeaderEncoder headerEncoder = new EXIHeaderEncoder();

		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		EncoderChannel encoderChannel = new BitEncoderChannel(baos);

		headerEncoder.writeEXIOptions(test, encoderChannel);
		encoderChannel.flush();

		DecoderChannel decoderChannel = new BitDecoderChannel(
				new ByteArrayInputStream(baos.toByteArray()));

		EXIHeaderDecoder headerDecoder = new EXIHeaderDecoder();
		if (noOptionsFactory == null) {
			noOptionsFactory = DefaultEXIFactory.newInstance();
		}
		if (noOptionsFactory.getSchemaIdResolver() == null) {
			// set default schemaId resolver

// Path: src/main/java/com/siemens/ct/exi/main/helpers/DefaultSchemaIdResolver.java
// public class DefaultSchemaIdResolver implements SchemaIdResolver {
// 
// 	// protected GrammarFactory gf;
// 
// 	public DefaultSchemaIdResolver() {
// 
// 	}
// 
// 	protected GrammarFactory getGrammarFactory() {
// 		return GrammarFactory.newInstance();
// 		// if (gf == null) {
// 		// gf = GrammarFactory.newInstance();
// 		// }
// 		// return gf;
// 	}
// 
// 	public Grammars resolveSchemaId(String schemaId) throws EXIException {
// 		if (schemaId == null) {
// 			return getGrammarFactory().createSchemaLessGrammars();
// 		} else if ("".equals(schemaId)) {
// 			return getGrammarFactory().createXSDTypesOnlyGrammars();
// 		} else {
// 			// interpret schemaId as location
// 			try {
// 				return getGrammarFactory().createGrammars(schemaId);
// 			} catch (Exception e) {
// 				throw new EXIException(this.getClass().getName()
// 						+ " failed to retrieve schemaId == " + schemaId, e);
// 			}
// 		}
// 	}
// 
// }


// Path: src/test/java/com/siemens/ct/exi/main/core/EXIHeaderTestCase.java
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.namespace.QName;
import junit.framework.TestCase;
import com.siemens.ct.exi.core.CodingMode;
import com.siemens.ct.exi.core.Constants;
import com.siemens.ct.exi.core.EXIFactory;
import com.siemens.ct.exi.core.EncodingOptions;
import com.siemens.ct.exi.core.FidelityOptions;
import com.siemens.ct.exi.core.SchemaIdResolver;
import com.siemens.ct.exi.core.coder.EXIHeaderDecoder;
import com.siemens.ct.exi.core.coder.EXIHeaderEncoder;
import com.siemens.ct.exi.core.exceptions.EXIException;
import com.siemens.ct.exi.core.grammars.Grammars;
import com.siemens.ct.exi.core.helpers.DefaultEXIFactory;
import com.siemens.ct.exi.core.io.channel.BitDecoderChannel;
import com.siemens.ct.exi.core.io.channel.BitEncoderChannel;
import com.siemens.ct.exi.core.io.channel.DecoderChannel;
import com.siemens.ct.exi.core.io.channel.EncoderChannel;
import com.siemens.ct.exi.grammars.GrammarFactory;
import com.siemens.ct.exi.main.helpers.DefaultSchemaIdResolver;

			fail("No Valid Cookie");
		} catch (Exception e) {
			// no valid cookie
		}
	}

	protected void _testOptions(EXIFactory test) throws EXIException,
			IOException {
		_testOptions(test, null);
	}

	protected void _testOptions(EXIFactory test, EXIFactory noOptionsFactory)
			throws EXIException, IOException {
		EXIHeaderEncoder headerEncoder = new EXIHeaderEncoder();

		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		EncoderChannel encoderChannel = new BitEncoderChannel(baos);

		headerEncoder.writeEXIOptions(test, encoderChannel);
		encoderChannel.flush();

		DecoderChannel decoderChannel = new BitDecoderChannel(
				new ByteArrayInputStream(baos.toByteArray()));

		EXIHeaderDecoder headerDecoder = new EXIHeaderDecoder();
		if (noOptionsFactory == null) {
			noOptionsFactory = DefaultEXIFactory.newInstance();
		}
		if (noOptionsFactory.getSchemaIdResolver() == null) {
			// set default schemaId resolver

			noOptionsFactory.setSchemaIdResolver(new DefaultSchemaIdResolver());
