use of ddf.catalog.transformer.xml.XmlResponseQueueTransformer in project ddf by codice.
the class TestXmlResponseQueueTransformer method setup.
@Before
public void setup() throws MimeTypeParseException {
parser = new XmlParser();
PrintWriterProvider printWriterProvider = new PrintWriterProviderImpl();
MetacardMarshaller metacardMarshaller = new MetacardMarshallerImpl(parser, printWriterProvider);
mimeType = getMimeType();
transformer = new XmlResponseQueueTransformer(parser, FJP, printWriterProvider, metacardMarshaller, mimeType);
}
use of ddf.catalog.transformer.xml.XmlResponseQueueTransformer in project ddf by codice.
the class TestXmlResponseQueueTransformer method testCompareSerialToFork.
@Test
public void testCompareSerialToFork() throws IOException, CatalogTransformerException, MimeTypeParseException {
SourceResponse response = givenSourceResponse(new MetacardStub("source1", "id1"), new MetacardStub("source2", "id2"), new MetacardStub("source3", "id3"), new MetacardStub("source4", "id4"));
PrintWriterProvider pwp = new PrintWriterProviderImpl();
MetacardMarshaller mcm = new MetacardMarshallerImpl(parser, pwp);
XmlResponseQueueTransformer serialXform = new XmlResponseQueueTransformer(parser, FJP, pwp, mcm, getMimeType());
serialXform.setThreshold(2);
XmlResponseQueueTransformer forkXForm = new XmlResponseQueueTransformer(parser, FJP, pwp, mcm, getMimeType());
forkXForm.setThreshold(10);
BinaryContent serialBc = serialXform.transform(response, null);
BinaryContent forkBc = forkXForm.transform(response, null);
String serialOutput = new String(serialBc.getByteArray());
String forkOutput = new String(forkBc.getByteArray());
// There are expected whitespace differences between the outputs.
// This is an overly aggressive conversion; a better test would be to unmarshal the
// xml metacards back into Metacard instances and compare equality.
assertEquals(serialOutput.replaceAll("\\s", ""), forkOutput.replaceAll("\\s", ""));
}
use of ddf.catalog.transformer.xml.XmlResponseQueueTransformer in project ddf by codice.
the class TestXmlResponseQueueTransformer method testMimeTypeInitException.
@Test(expected = ExceptionInInitializerError.class)
public void testMimeTypeInitException() throws IOException, CatalogTransformerException, XmlPullParserException, MimeTypeParseException {
SourceResponse response = givenSourceResponse(new MetacardStub("source1", "id1"));
PrintWriterProvider pwp = new PrintWriterProviderImpl();
MetacardMarshaller mockMetacardMarshaller = mock(MetacardMarshaller.class);
MimeType mockMimeType = mock(MimeType.class);
doThrow(new MimeTypeParseException("")).when(mockMimeType).setSubType(anyString());
XmlResponseQueueTransformer xrqt = new XmlResponseQueueTransformer(parser, FJP, pwp, mockMetacardMarshaller, mockMimeType);
xrqt.setThreshold(2);
BinaryContent bc = xrqt.transform(response, null);
// then exception
}
use of ddf.catalog.transformer.xml.XmlResponseQueueTransformer in project ddf by codice.
the class TestXmlResponseQueueTransformer method testMetacardMarshallThrowsXmlPullParserException.
@Test(expected = CatalogTransformerException.class)
public void testMetacardMarshallThrowsXmlPullParserException() throws IOException, CatalogTransformerException, XmlPullParserException, MimeTypeParseException {
SourceResponse response = givenSourceResponse(new MetacardStub("source1", "id1"));
PrintWriterProvider pwp = new PrintWriterProviderImpl();
MetacardMarshaller mockMetacardMarshaller = mock(MetacardMarshaller.class);
when(mockMetacardMarshaller.marshal(any(Metacard.class), any(Map.class))).thenThrow(new XmlPullParserException(""));
XmlResponseQueueTransformer xrqt = new XmlResponseQueueTransformer(parser, FJP, pwp, mockMetacardMarshaller, getMimeType());
xrqt.setThreshold(2);
BinaryContent bc = xrqt.transform(response, null);
// then exception
}
Aggregations