use of ddf.catalog.data.impl.BinaryContentImpl in project ddf by codice.
the class GeoJsonMetacardTransformer method transform.
@Override
public BinaryContent transform(Metacard metacard, Map<String, Serializable> arguments) throws CatalogTransformerException {
JSONObject rootObject = convertToJSON(metacard);
String jsonText = JSONValue.toJSONString(rootObject);
return new BinaryContentImpl(new ByteArrayInputStream(jsonText.getBytes(StandardCharsets.UTF_8)), DEFAULT_MIME_TYPE);
}
use of ddf.catalog.data.impl.BinaryContentImpl in project ddf by codice.
the class BinaryContentImplTest method testBinaryContentImplNullMimeType.
@Test
public void testBinaryContentImplNullMimeType() {
InputStream is;
try {
is = new FileInputStream(content);
BinaryContentImpl bci = new BinaryContentImpl(is, null);
assertEquals(null, bci.getMimeType());
} catch (IOException e) {
LOGGER.error("IO Failure", e);
new Failure(null, e);
}
}
use of ddf.catalog.data.impl.BinaryContentImpl in project ddf by codice.
the class BinaryContentImplTest method testBinaryContentImpl.
@Test
public void testBinaryContentImpl() {
InputStream is;
try {
is = new FileInputStream(content);
BinaryContentImpl bci = new BinaryContentImpl(is, mimeType);
bci.setSize(content.length());
// assertEquals(is, bci.getInputStream());
assertEquals(mimeType, bci.getMimeType());
assertEquals(content.length(), bci.getSize());
assertNotNull(bci.toString());
} catch (IOException e) {
LOGGER.error("IO Failure", e);
new Failure(null, e);
}
}
use of ddf.catalog.data.impl.BinaryContentImpl in project ddf by codice.
the class BinaryContentImplTest method testBinaryContentImplNegativeSize.
@Test
public void testBinaryContentImplNegativeSize() {
InputStream is;
try {
is = new FileInputStream(content);
BinaryContentImpl bci = new BinaryContentImpl(is, mimeType);
bci.setSize(-20L);
assertEquals(-1, bci.getSize());
} catch (IOException e) {
LOGGER.error("IO Failure", e);
new Failure(null, e);
}
}
use of ddf.catalog.data.impl.BinaryContentImpl in project ddf by codice.
the class BinaryContentImplTest method testBinaryContentImplByteArrayNotNull.
@Test
public void testBinaryContentImplByteArrayNotNull() {
InputStream is;
try {
is = new FileInputStream(content);
BinaryContentImpl bci = new BinaryContentImpl(is, mimeType);
byte[] contents = bci.getByteArray();
assertNotNull(contents);
} catch (IOException e) {
LOGGER.error("IO Failure", e);
new Failure(null, e);
}
}
Aggregations