config = new SmooksResourceConfiguration();
config.setResource(EDIReader.class.getName());
// Set the mapping config on the resource config...
config.setParameter(EDIReader.MODEL_CONFIG_KEY, TEST_XML_MAPPING_XML_URI);
DOMParser parser;
// Create 1st parser using the config, and run a parse through it...
parser = new DOMParser(smooks.createExecutionContext(), config);
parser.parse(new StreamSource(new ByteArrayInputStream(input)));
// Check make sure the parsed and validated model was cached...
Hashtable mappingTable = EDIReader.getMappingTable(smooks.getApplicationContext());
assertNotNull("No mapping table in context!", mappingTable);
EdifactModel mappingModel_request1 = (EdifactModel) mappingTable.get(config);
assertNotNull("No mapping model in mapping table!", mappingModel_request1);
// Create 2nd parser using the same config, and run a parse through it...
parser = new DOMParser(smooks.createExecutionContext(), config);
parser.parse(new StreamSource(new ByteArrayInputStream(input)));
// Make sure the cached model was used on the 2nd parse...
assertEquals("Not the same model instance => cache not working properly!", mappingModel_request1, (EdifactModel) mappingTable.get(config));
}