// test non-existent blob operations on a closed connection
runTests(new Action() {
public void run(Transaction txn) throws Exception {
final BlobStoreConnection con = store.openConnection(txn, null);
final Blob b = getBlob(con, id1, false);
for (int idx = 0; idx < 3; idx++) {
con.close();
assertTrue(con.isClosed());
assertEquals(b.getConnection(), con);
assertEquals(b.getId(), id1);
if (isOutputSupp) {
shouldFail(new ERunnable() {
@Override
public void erun() throws Exception {
b.openOutputStream(-1, true);
}
}, IllegalStateException.class, null);
}
shouldFail(new ERunnable() {
@Override
public void erun() throws Exception {
b.exists();
}
}, IllegalStateException.class, null);
}
}
});
// test existing blob operations on a closed connection
runTests(new Action() {
public void run(Transaction txn) throws Exception {
final BlobStoreConnection con = store.openConnection(txn, null);
final Blob b = getBlob(con, id1, false);
final Blob b2 = getBlob(con, id2, false);
createBlob(con, b, "foo");
for (int idx = 0; idx < 3; idx++) {
con.close();
assertTrue(con.isClosed());
assertEquals(b.getConnection(), con);
assertEquals(b.getId(), id1);
shouldFail(new ERunnable() {
@Override
public void erun() throws Exception {
b.openInputStream();
}
}, IllegalStateException.class, null);
if (isOutputSupp) {
shouldFail(new ERunnable() {
@Override
public void erun() throws Exception {
b.openOutputStream(-1, true);
}
}, IllegalStateException.class, null);
}
shouldFail(new ERunnable() {
@Override
public void erun() throws Exception {
b.getSize();
}
}, IllegalStateException.class, null);
shouldFail(new ERunnable() {
@Override
public void erun() throws Exception {
b.exists();
}
}, IllegalStateException.class, null);
if (isDeleteSupp) {
shouldFail(new ERunnable() {
@Override
public void erun() throws Exception {
b.delete();
}
}, IllegalStateException.class, null);
}
if (isMoveToSupp) {
shouldFail(new ERunnable() {
@Override
public void erun() throws Exception {
b.moveTo(b2.getId(), null);
}
}, IllegalStateException.class, null);
}
}
}