import thrift.test.TestUnionMinusStringField;
public class TestTUnion extends TestCase {
public void testBasic() throws Exception {
TestUnion union = new TestUnion();
assertFalse(union.isSet());
assertFalse(union.isSetI32_field());
assertNull(union.getFieldValue());
union = new TestUnion(TestUnion._Fields.I32_FIELD, 25);
assertEquals(Integer.valueOf(25), union.getFieldValue());
assertEquals(Integer.valueOf(25), union.getFieldValue(TestUnion._Fields.I32_FIELD));
assertTrue(union.isSetI32_field());
try {
union.getFieldValue(TestUnion._Fields.STRING_FIELD);
fail("should have thrown an exception");
} catch (IllegalArgumentException e) {
// cool!
}
union = new TestUnion();
// should not throw an exception here
union.hashCode();
union.setI32_field(1);
assertEquals(1, union.getI32_field());
union.hashCode();
assertFalse(union.isSetString_field());
try {
union.getString_field();
fail("should have thrown an exception");
} catch (Exception e) {
// sweet
}
union = TestUnion.i32_field(1);
assertFalse(union.equals((TestUnion)null));
union = TestUnion.enum_field(SomeEnum.ONE);
union.hashCode();
union = new TestUnion();
// should not throw an exception
union.toString();
}