Examples of TestUnion


Examples of com.twitter.elephantbird.thrift.test.TestUnion

    assertTrue( // the order of elements in map could vary because of HashMap
        tupleString.equals("(bob,jenkins)-{MOBILE=650-555-5555, WORK=415-555-5555, HOME=408-555-5555}") ||
        tupleString.equals("(bob,jenkins)-{MOBILE=650-555-5555, HOME=408-555-5555, WORK=415-555-5555}"));

    // Test Union:
    TestUnion unionInt = new TestUnion();
    unionInt.setI32Type(10);
    assertEquals(",10,,,", toTuple(type, unionInt).toDelimitedString(","));

    TestUnion unionStr = new TestUnion();
    unionStr.setI32Type(-1); // is overridden below.
    unionStr.setStringType("abcd");
    assertEquals("abcd,,,,", toTuple(type, unionStr).toDelimitedString(","));
  }
View Full Code Here

Examples of org.jacorb.test.notification.TestUnion

            "$.value <= 1", "$.value > 1", "$.value >= 1", "$.value == 1", "$.value + 1",
            "$.value - 1", "$.value * 1", "$.value / 1", "$.value ~ $.x" };

    private void setUpTestUnion(Person person)
    {
        TestUnion _t1, _t2, _t3, _t4, _t5, _t;

        _t = new TestUnion();
        _t.default_person(person);

        _t1 = new TestUnion();
        _t1.long_(100);

        _t2 = new TestUnion();
        _t2.string_("String");

        _t3 = new TestUnion();
        _t3.named_value_(new NamedValue("this is the name", "this is the value"));

        _t4 = new TestUnion();
        _t4.person_(person);

        _t5 = new TestUnion();
        NamedValue[] lonv = new NamedValue[1];
        lonv[0] = new NamedValue("name", "value");
        _t5.named_value_array(lonv);

        testUnion_ = getORB().create_any();
View Full Code Here

Examples of org.jacorb.test.notification.TestUnion

            "$.value <= 1", "$.value > 1", "$.value >= 1", "$.value == 1", "$.value + 1",
            "$.value - 1", "$.value * 1", "$.value / 1", "$.value ~ $.x" };

    private void setUpTestUnion(Person person)
    {
        TestUnion _t1, _t2, _t3, _t4, _t5, _t;

        _t = new TestUnion();
        _t.default_person(person);

        _t1 = new TestUnion();
        _t1.long_(100);

        _t2 = new TestUnion();
        _t2.string_("String");

        _t3 = new TestUnion();
        _t3.named_value_(new NamedValue("this is the name", "this is the value"));

        _t4 = new TestUnion();
        _t4.person_(person);

        _t5 = new TestUnion();
        NamedValue[] lonv = new NamedValue[1];
        lonv[0] = new NamedValue("name", "value");
        _t5.named_value_array(lonv);

        testUnion_ = getORB().create_any();
View Full Code Here

Examples of org.jacorb.test.notification.TestUnion

            "$.value <= 1", "$.value > 1", "$.value >= 1", "$.value == 1", "$.value + 1",
            "$.value - 1", "$.value * 1", "$.value / 1", "$.value ~ $.x" };

    private void setUpTestUnion(Person person)
    {
        TestUnion _t1, _t2, _t3, _t4, _t5, _t;

        _t = new TestUnion();
        _t.default_person(person);

        _t1 = new TestUnion();
        _t1.long_(100);

        _t2 = new TestUnion();
        _t2.string_("String");

        _t3 = new TestUnion();
        _t3.named_value_(new NamedValue("this is the name", "this is the value"));

        _t4 = new TestUnion();
        _t4.person_(person);

        _t5 = new TestUnion();
        NamedValue[] lonv = new NamedValue[1];
        lonv[0] = new NamedValue("name", "value");
        _t5.named_value_array(lonv);

        testUnion_ = getORB().create_any();
View Full Code Here

Examples of thrift.test.TestUnion

import thrift.test.TestUnionMinusStringField;

public class TestTUnion extends TestCase {

  public void testBasic() throws Exception {
    TestUnion union = new TestUnion();

    assertFalse(union.isSet());
    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));
 
    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();

    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();
  }
View Full Code Here

Examples of thrift.test.TestUnion

    cu = ComparableUnion.binary_field(ByteBuffer.wrap(new byte[]{1}));

    assertTrue(cu.compareTo(cu2) < 0);
    assertTrue(cu2.compareTo(cu) > 0);
   
    TestUnion union1 = new TestUnion(TestUnion._Fields.STRUCT_LIST, new ArrayList<RandomStuff>());
    TestUnion union2 = new TestUnion(TestUnion._Fields.STRUCT_LIST, new ArrayList<RandomStuff>());
    assertTrue(union1.compareTo(union2) == 0);

    TestUnion union3 = new TestUnion(TestUnion._Fields.I32_SET, new HashSet<Integer>());
    Set<Integer> i32_set = new HashSet<Integer>();
    i32_set.add(1);
    TestUnion union4 = new TestUnion(TestUnion._Fields.I32_SET, i32_set);
    assertTrue(union3.compareTo(union4) < 0);

    Map<Integer, Integer> i32_map = new HashMap<Integer, Integer>();
    i32_map.put(1,1);
    TestUnion union5 = new TestUnion(TestUnion._Fields.I32_MAP, i32_map);
    TestUnion union6 = new TestUnion(TestUnion._Fields.I32_MAP, new HashMap<Integer, Integer>());
    assertTrue(union5.compareTo(union6) > 0);
  }
View Full Code Here

Examples of thrift.test.TestUnion

    TestUnion union6 = new TestUnion(TestUnion._Fields.I32_MAP, new HashMap<Integer, Integer>());
    assertTrue(union5.compareTo(union6) > 0);
  }

  public void testEquality() throws Exception {
    TestUnion union = new TestUnion(TestUnion._Fields.I32_FIELD, 25);

    TestUnion otherUnion = new TestUnion(TestUnion._Fields.STRING_FIELD, "blah!!!");

    assertFalse(union.equals(otherUnion));

    otherUnion = new TestUnion(TestUnion._Fields.I32_FIELD, 400);

    assertFalse(union.equals(otherUnion));

    otherUnion = new TestUnion(TestUnion._Fields.OTHER_I32_FIELD, 25);

    assertFalse(union.equals(otherUnion));
  }
View Full Code Here

Examples of thrift.test.TestUnion

    assertFalse(union.equals(otherUnion));
  }

  public void testSerialization() throws Exception {
    TestUnion union = new TestUnion(TestUnion._Fields.I32_FIELD, 25);

    TMemoryBuffer buf = new TMemoryBuffer(0);
    TProtocol proto = new TBinaryProtocol(buf);

    union.write(proto);

    TestUnion u2 = new TestUnion();

    u2.read(proto);

    assertEquals(u2, union);

    StructWithAUnion swau = new StructWithAUnion(u2);
View Full Code Here

Examples of thrift.test.TestUnion

    swau.write(proto);
    new Empty().read(proto);
  }

  public void testSkip() throws Exception {
    TestUnion tu = TestUnion.string_field("string");
    byte[] tuSerialized = new TSerializer().serialize(tu);
    TestUnionMinusStringField tums = new TestUnionMinusStringField();
    new TDeserializer().deserialize(tums, tuSerialized);
    assertNull(tums.getSetField());
    assertNull(tums.getFieldValue());
View Full Code Here

Examples of thrift.test.TestUnion

  public void testJavaSerializable() throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
   
    TestUnion tu = TestUnion.string_field("string");

    // Serialize tu the Java way...
    oos.writeObject(tu);
    byte[] serialized = baos.toByteArray();

    // Attempt to deserialize it
    ByteArrayInputStream bais = new ByteArrayInputStream(serialized);
    ObjectInputStream ois = new ObjectInputStream(bais);
    TestUnion tu2 = (TestUnion) ois.readObject();

    assertEquals(tu, tu2);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.