use of org.codice.ddf.transformer.xml.streaming.lib.SaxEventHandlerDelegate in project ddf by codice.
the class XmlInputTransformerTest method testNormalTransform.
/*
Tests a base XmlInputTransformer, CONTENT_TYPE is null because it is not in the base xmlToMetacard mapping
*/
@Test
public void testNormalTransform() throws FileNotFoundException, CatalogTransformerException {
inputStream = new FileInputStream("src/test/resources/metacard2.xml");
saxEventHandlerFactory = new XmlSaxEventHandlerFactoryImpl();
saxEventHandler = saxEventHandlerFactory.getNewSaxEventHandler();
assertThat(saxEventHandler.getSupportedAttributeDescriptors().size(), is(greaterThan(0)));
GMLHandler gh = new GMLHandler(new GeometryFactory(), (ErrorHandler) null);
gmlHandler = new GmlHandler(gh, gml3ToWkt);
assertThat(gmlHandler.getSupportedAttributeDescriptors().size(), is(greaterThan(0)));
saxEventHandlerDelegate = new SaxEventHandlerDelegate(Arrays.asList(saxEventHandler, gmlHandler));
Metacard metacard = saxEventHandlerDelegate.read(inputStream).getMetacard(null);
assertThat(metacard.getAttribute(Metacard.TITLE).getValues().size(), is(1));
assertThat(metacard.getAttribute(Metacard.TITLE).getValues().get(0), is("Title!"));
assertThat(metacard.getAttribute(Metacard.DESCRIPTION).getValues().size(), is(1));
assertThat(metacard.getAttribute(Metacard.DESCRIPTION).getValues().get(0), is("Description!"));
assertThat(metacard.getAttribute(Metacard.POINT_OF_CONTACT).getValues().size(), is(1));
assertThat(metacard.getAttribute(Metacard.POINT_OF_CONTACT).getValues().get(0), is("POC!"));
assertThat(metacard.getAttribute(Metacard.RESOURCE_URI).getValues().size(), is(1));
assertThat(metacard.getAttribute(Metacard.RESOURCE_URI).getValues().get(0), is("foobar"));
assertThat(metacard.getAttribute(Metacard.CONTENT_TYPE), is(nullValue()));
assertThat(metacard.getAttribute(Metacard.GEOGRAPHY).getValues().size(), is(1));
assertThat(metacard.getAttribute(Metacard.GEOGRAPHY).getValues().get(0), is("POINT (100 200)"));
}
Aggregations