*/
@Test
public void testNXCM4852()
throws Exception
{
final Repository repository = getRepositoryRegistry().getRepository("inhouse");
final ResourceStoreRequest request =
new ResourceStoreRequest("/activemq/activemq-core/1.2/activemq-core-1.2.jar", true);
try {
repository.storeItem(request, new FilterInputStream(new ByteArrayInputStream(
"123456789012345678901234567890".getBytes()))
{
@Override
public int read()
throws IOException
{
int result = super.read();
if (result == -1) {
throw new EOFException("Foo");
}
else {
return result;
}
}
@Override
public int read(final byte[] b, final int off, final int len)
throws IOException
{
int result = super.read(b, off, len);
if (result == -1) {
throw new EOFException("Foo");
}
return result;
}
}, null);
fail("We expected a LocalStorageEofException to be thrown");
}
catch (LocalStorageEOFException e) {
// good, we expected this
}
finally {
// now we have to ensure no remnant files exists
assertThat(repository.getLocalStorage().containsItem(repository, request), is(false));
// no tmp files should exists either
assertThat(
repository.getLocalStorage().listItems(repository, new ResourceStoreRequest("/.nexus/tmp")),
is(empty()));
}
}