use of org.junit.runner.notification.Failure in project ddf by codice.
the class BinaryContentImplTest method testByteArraysEqual.
@Test
public void testByteArraysEqual() {
byte[] bytes = "Hello World".getBytes();
InputStream is;
try {
is = new ByteArrayInputStream(bytes);
BinaryContentImpl bci = new BinaryContentImpl(is, mimeType);
byte[] contents = bci.getByteArray();
assertArrayEquals(bytes, contents);
InputStream newIs = bci.getInputStream();
byte[] inputStreamByteArray = IOUtils.toByteArray(newIs);
assertArrayEquals(bytes, inputStreamByteArray);
} catch (IOException e) {
LOGGER.error(IO_FAILURE, e);
new Failure(null, e);
}
}
use of org.junit.runner.notification.Failure in project ddf by codice.
the class BinaryContentImplTest method testBinaryContentImplSizeNotSet.
@Test
public void testBinaryContentImplSizeNotSet() {
InputStream is;
try {
is = new FileInputStream(content);
BinaryContentImpl bci = new BinaryContentImpl(is, mimeType);
assertEquals(BinaryContentImpl.UNKNOWN_SIZE, bci.getSize());
} catch (IOException e) {
LOGGER.error(IO_FAILURE, e);
new Failure(null, e);
}
}
use of org.junit.runner.notification.Failure 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 org.junit.runner.notification.Failure 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 org.junit.runner.notification.Failure in project ddf by codice.
the class BinaryContentImplTest method setUp.
@Before
public void setUp() {
content = new File("src/test/resources/data/i4ce.png");
MimetypesFileTypeMap mimeMapper = new MimetypesFileTypeMap();
try {
mimeType = new MimeType(mimeMapper.getContentType(content));
} catch (MimeTypeParseException e) {
LOGGER.error("Mime parser Failure", e);
new Failure(null, e);
}
}
Aggregations