use of java.beans.XMLEncoder in project ddf by codice.
the class SolrProviderExtensibleMetacards method queryInteger.
@Test
public void queryInteger() throws UnsupportedQueryException {
Query query = new QueryImpl(getFilterBuilder().attribute(intField).greaterThan().number(intFieldValue - 1));
QueryRequest request = new QueryRequestImpl(query);
SourceResponse response = provider.query(request);
assertEquals(1, response.getResults().size());
Metacard resultMetacard = response.getResults().get(0).getMetacard();
assertThat(resultMetacard.getAttribute(Metacard.ID), notNullValue());
assertThat(resultMetacard.getAttribute(doubleField).getValue(), equalTo(doubleFieldValue));
assertThat(resultMetacard.getAttribute(intField).getValue(), equalTo(intFieldValue));
assertThat(resultMetacard.getAttribute(floatField).getValue(), equalTo(floatFieldValue));
assertThat(resultMetacard.getAttribute(longField).getValue(), equalTo(longFieldValue));
assertThat(resultMetacard.getAttribute(byteField).getValue(), equalTo(byteFieldValue));
assertThat(resultMetacard.getAttribute(booleanField).getValue(), equalTo(true));
assertThat(resultMetacard.getAttribute(dateField).getValue(), equalTo(dateFieldValue));
assertThat(resultMetacard.getAttribute(geoField).getValue(), equalTo(geoFieldValue));
assertThat(resultMetacard.getAttribute(shortField).getValue(), equalTo(shortFieldValue));
assertThat(resultMetacard.getAttribute(objectField).getValue(), instanceOf(BevelBorder.class));
/*
* Going to use the XMLEncoder. If it writes out the objects the same way in xml, then they
* are the same.
*/
ByteArrayOutputStream beveledBytesStreamFromSolr = new ByteArrayOutputStream();
XMLEncoder solrXMLEncoder = new XMLEncoder(new BufferedOutputStream(beveledBytesStreamFromSolr));
solrXMLEncoder.writeObject((resultMetacard.getAttribute(objectField).getValue()));
solrXMLEncoder.close();
ByteArrayOutputStream beveledBytesStreamOriginal = new ByteArrayOutputStream();
XMLEncoder currendEncoder = new XMLEncoder(new BufferedOutputStream(beveledBytesStreamOriginal));
currendEncoder.writeObject(objectFieldValue);
currendEncoder.close();
assertThat(beveledBytesStreamFromSolr.toByteArray(), equalTo(beveledBytesStreamOriginal.toByteArray()));
}
Aggregations