use of java.io.NotActiveException in project robovm by robovm.
the class Test method test_registerValidation.
public void test_registerValidation() throws Exception {
// Regression Test for Harmony-2402
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new ObjectOutputStream(baos);
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
try {
ois.registerValidation(null, 256);
fail("NotActiveException should be thrown");
} catch (NotActiveException nae) {
// expected
}
// Regression Test for Harmony-3916
baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(new RegisterValidationClass());
oos.close();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream fis = new ObjectInputStream(bais);
// should not throw NotActiveException
fis.readObject();
}
use of java.io.NotActiveException in project robovm by robovm.
the class Test method test_defaultReadObject.
/**
* java.io.ObjectInputStream#defaultReadObject()
*/
public void test_defaultReadObject() throws Exception {
// SM. This method may as well be private, as if called directly it
// throws an exception.
String s = "HelloWorld";
oos.writeObject(s);
oos.close();
ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
try {
ois.defaultReadObject();
fail("NotActiveException expected");
} catch (NotActiveException e) {
// Desired behavior
} finally {
ois.close();
}
}
use of java.io.NotActiveException in project robovm by robovm.
the class OldObjectOutputStreamTest method test_putFields.
public void test_putFields() throws Exception {
/*
* "SerializableTestHelper" is an object created for these tests with
* two fields (Strings) and simple implementations of readObject and
* writeObject which simply read and write the first field but not the
* second one.
*/
SerializableTestHelper sth;
try {
oos.putFields();
fail("Test 1: NotActiveException expected.");
} catch (NotActiveException e) {
// Expected.
}
oos.writeObject(new SerializableTestHelper("Gabba", "Jabba"));
oos.flush();
ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
sth = (SerializableTestHelper) (ois.readObject());
assertEquals("Test 2: readFields or writeFields failed; first field not set.", "Gabba", sth.getText1());
assertNull("Test 3: readFields or writeFields failed; second field should not have been set.", sth.getText2());
}
use of java.io.NotActiveException in project jPOS by jpos.
the class TransactionManagerTest method testCommit4.
@Test
public void testCommit4() throws Throwable {
LogEvent evt = new LogEvent("testTransactionManagerTag");
transactionManager.commit(1, 100L, new NotActiveException("testTransactionManagerParam1"), members, true, evt, null);
assertEquals("(ArrayList) members.size()", 0, members.size());
}
use of java.io.NotActiveException in project jPOS by jpos.
the class TransactionManagerTest method testPrepare10.
@Test
public void testPrepare10() throws Throwable {
HasEntry hasEntry = new HasEntry();
AbstractList<TransactionParticipant> arrayList = new ArrayList();
arrayList.add(new Debug());
int result = transactionManager.prepare(1, 100L, new NotActiveException("testTransactionManagerParam1"), members, arrayList.iterator(), members.add(hasEntry), null, null);
assertEquals("(ArrayList) members.size()", 2, members.size());
assertSame("(ArrayList) members.get(0)", hasEntry, members.get(0));
assertEquals("result", 0, result);
}
Aggregations