Package thrift.test

Examples of thrift.test.Insanity


    bonk2.setMessage("m");
    assertEquals(0, bonk1.compareTo(bonk2));
  }

  public void testCompareToWithDataStructures() {
    Insanity insanity1 = new Insanity();
    Insanity insanity2 = new Insanity();

    // Both empty.
    expectEquals(insanity1, insanity2);

    insanity1.setUserMap(new HashMap<Numberz, Long>());
    // insanity1.map = {}, insanity2.map = null
    expectGreaterThan(insanity1, insanity2);

    // insanity1.map = {2:1}, insanity2.map = null
    insanity1.getUserMap().put(Numberz.TWO, 1l);
    expectGreaterThan(insanity1, insanity2);

    // insanity1.map = {2:1}, insanity2.map = {}
    insanity2.setUserMap(new HashMap<Numberz, Long>());
    expectGreaterThan(insanity1, insanity2);

    // insanity1.map = {2:1}, insanity2.map = {2:2}
    insanity2.getUserMap().put(Numberz.TWO, 2l);
    expectLessThan(insanity1, insanity2);

    // insanity1.map = {2:1, 3:5}, insanity2.map = {2:2}
    insanity1.getUserMap().put(Numberz.THREE, 5l);
    expectGreaterThan(insanity1, insanity2);

    // insanity1.map = {2:1, 3:5}, insanity2.map = {2:1, 4:5}
    insanity2.getUserMap().put(Numberz.TWO, 1l);
    insanity2.getUserMap().put(Numberz.FIVE, 5l);
    expectLessThan(insanity1, insanity2);
  }
View Full Code Here


    bonk2.setMessage("m");
    assertEquals(0, bonk1.compareTo(bonk2));
  }

  public void testCompareToWithDataStructures() {
    Insanity insanity1 = new Insanity();
    Insanity insanity2 = new Insanity();

    // Both empty.
    expectEquals(insanity1, insanity2);

    insanity1.setUserMap(new HashMap<Numberz, Long>());
    // insanity1.map = {}, insanity2.map = null
    expectGreaterThan(insanity1, insanity2);

    // insanity1.map = {2:1}, insanity2.map = null
    insanity1.getUserMap().put(Numberz.TWO, 1l);
    expectGreaterThan(insanity1, insanity2);

    // insanity1.map = {2:1}, insanity2.map = {}
    insanity2.setUserMap(new HashMap<Numberz, Long>());
    expectGreaterThan(insanity1, insanity2);

    // insanity1.map = {2:1}, insanity2.map = {2:2}
    insanity2.getUserMap().put(Numberz.TWO, 2l);
    expectLessThan(insanity1, insanity2);

    // insanity1.map = {2:1, 3:5}, insanity2.map = {2:2}
    insanity1.getUserMap().put(Numberz.THREE, 5l);
    expectGreaterThan(insanity1, insanity2);

    // insanity1.map = {2:1, 3:5}, insanity2.map = {2:1, 4:5}
    insanity2.getUserMap().put(Numberz.TWO, 1l);
    insanity2.getUserMap().put(Numberz.FIVE, 5l);
    expectLessThan(insanity1, insanity2);
  }
View Full Code Here

      goodbye.string_thing = "Goodbye4";
      goodbye.byte_thing = (byte)4;
      goodbye.i32_thing = 4;
      goodbye.i64_thing = (long)4;
 
      Insanity crazy = new Insanity();
      crazy.userMap = new HashMap<Numberz, Long>();
      crazy.xtructs = new ArrayList<Xtruct>();
 
      crazy.userMap.put(Numberz.EIGHT, (long)8);
      crazy.xtructs.add(goodbye);
 
      Insanity looney = new Insanity();
      crazy.userMap.put(Numberz.FIVE, (long)5);
      crazy.xtructs.add(hello);
 
      HashMap<Numberz,Insanity> first_map = new HashMap<Numberz, Insanity>();
      HashMap<Numberz,Insanity> second_map = new HashMap<Numberz, Insanity>();;
View Full Code Here

    assertEquals(i64, -34359738368L);
  }

  // todo: add assertions
  private void testInsanity(ThriftTest.Client testClient) throws TException {
    Insanity insane;
 
    insane = new Insanity();
    insane.userMap = new HashMap<Numberz, Long>();
    insane.userMap.put(Numberz.FIVE, (long)5000);
    Xtruct truck = new Xtruct();
    truck.string_thing = "Truck";
    truck.byte_thing = (byte)8;
    truck.i32_thing = 8;
    truck.i64_thing = 8;
    insane.xtructs = new ArrayList<Xtruct>();
    insane.xtructs.add(truck);
    System.out.print("testInsanity()");
    Map<Long,Map<Numberz,Insanity>> whoa =
      testClient.testInsanity(insane);
    System.out.print(" = {");
    for (long key : whoa.keySet()) {
      Map<Numberz,Insanity> val = whoa.get(key);
      System.out.print(key + " => {");
 
      for (Numberz k2 : val.keySet()) {
        Insanity v2 = val.get(k2);
        System.out.print(k2 + " => {");
        Map<Numberz, Long> userMap = v2.userMap;
        System.out.print("{");
        if (userMap != null) {
          for (Numberz k3 : userMap.keySet()) {
View Full Code Here

    ThriftTest.Client testClient =
      new ThriftTest.Client(prot);
    //rohan
    ClientEventHandler handler = new ClientEventHandler();
    testClient.addEventHandler(handler);
    Insanity insane = new Insanity();

    /**
     * CONNECT TEST
     */
    transport.open();
View Full Code Here

      goodbye.string_thing = "Goodbye4";
      goodbye.byte_thing = (byte)4;
      goodbye.i32_thing = 4;
      goodbye.i64_thing = (long)4;

      Insanity crazy = new Insanity();
      crazy.userMap = new HashMap<Integer, Long>();
      crazy.xtructs = new ArrayList<Xtruct>();

      crazy.userMap.put(Numberz.EIGHT, (long)8);
      crazy.xtructs.add(goodbye);

      Insanity looney = new Insanity();
      crazy.userMap.put(Numberz.FIVE, (long)5);
      crazy.xtructs.add(hello);

      HashMap<Integer,Insanity> first_map = new HashMap<Integer, Insanity>();
      HashMap<Integer,Insanity> second_map = new HashMap<Integer, Insanity>();;
View Full Code Here

  public void testClient(TTransport transport, TProtocol prot)
      throws TException {
    ThriftTest.Client testClient =
      new ThriftTest.Client(prot);
    Insanity insane = new Insanity();

    /**
     * CONNECT TEST
     */
    transport.open();

    long start = System.nanoTime();

    /**
     * VOID TEST
     */
    testClient.testVoid();

    /**
     * STRING TEST
     */
    String s = testClient.testString("Test");

    /**
     * IDENTITY TEST
     */
    if (prot instanceof THeaderProtocol) {
      assertEquals(identity,
                   ((THeaderTransport)prot.getTransport()).getPeerIdentity());
    }

    /**
     * BYTE TEST
     */
    byte i8 = testClient.testByte((byte)1);

    /**
     * I32 TEST
     */
    int i32 = testClient.testI32(-1);

    /**
     * I64 TEST
     */
    long i64 = testClient.testI64(-34359738368L);

    /**
     * DOUBLE TEST
     */
    double t = 5.325098235;
    double dub = testClient.testDouble(t);
    assertEquals(t, dub);

    /**
     * STRUCT TEST
     */
    Xtruct out = new Xtruct();
    out.string_thing = "Zero";
    out.byte_thing = (byte) 1;
    out.i32_thing = -3;
    out.i64_thing = -5;
    Xtruct in = testClient.testStruct(out);
    assertEquals(out, in);

    /**
     * NESTED STRUCT TEST
     */
    Xtruct2 out2 = new Xtruct2();
    out2.byte_thing = (short)1;
    out2.struct_thing = out;
    out2.i32_thing = 5;
    Xtruct2 in2 = testClient.testNest(out2);
    in = in2.struct_thing;
    assertEquals(out2, in2);

    /**
     * MAP TEST
     */
    Map<Integer,Integer> mapout = new HashMap<Integer,Integer>();
    for (int i = 0; i < 5; ++i) {
      mapout.put(i, i - 10);
    }
    Map<Integer,Integer> mapin = testClient.testMap(mapout);
    assertEquals(mapout, mapin);

    /**
     * SET TEST
     */
    Set<Integer> setout = new HashSet<Integer>();
    for (int i = -2; i < 3; ++i) {
      setout.add(i);
    }
    Set<Integer> setin = testClient.testSet(setout);
    assertEquals(setout, setin);

    /**
     * LIST TEST
     */
    List<Integer> listout = new ArrayList<Integer>();
    for (int i = -2; i < 3; ++i) {
      listout.add(i);
    }
    List<Integer> listin = testClient.testList(listout);
    assertEquals(listout, listin);

    /**
     * ENUM TEST
     */
    int ret = testClient.testEnum(Numberz.ONE);

    ret = testClient.testEnum(Numberz.TWO);

    ret = testClient.testEnum(Numberz.THREE);

    ret = testClient.testEnum(Numberz.FIVE);

    ret = testClient.testEnum(Numberz.EIGHT);

    /**
     * TYPEDEF TEST
     */
    long uid = testClient.testTypedef(309858235082523L);

    /**
     * NESTED MAP TEST
     */
    Map<Integer,Map<Integer,Integer>> mm =
      testClient.testMapMap(1);

    /**
     * INSANITY TEST
     */
    insane = new Insanity();
    insane.userMap = new HashMap<Integer, Long>();
    insane.userMap.put(Numberz.FIVE, (long)5000);
    Xtruct truck = new Xtruct();
    truck.string_thing = "Truck";
    truck.byte_thing = (byte)8;
    truck.i32_thing = 8;
    truck.i64_thing = 8;
    insane.xtructs = new ArrayList<Xtruct>();
    insane.xtructs.add(truck);
    Map<Long,Map<Integer,Insanity>> whoa =
      testClient.testInsanity(insane);
    for (long key : whoa.keySet()) {
      Map<Integer,Insanity> val = whoa.get(key);

      for (int k2 : val.keySet()) {
        Insanity v2 = val.get(k2);
        Map<Integer, Long> userMap = v2.userMap;
        if (userMap != null) {
          for (int k3 : userMap.keySet()) {
          }
        }
View Full Code Here

      goodbye.string_thing = "Goodbye4";
      goodbye.byte_thing = (byte)4;
      goodbye.i32_thing = 4;
      goodbye.i64_thing = (long)4;

      Insanity crazy = new Insanity();
      crazy.userMap = new HashMap<Integer, Long>();
      crazy.xtructs = new ArrayList<Xtruct>();

      crazy.userMap.put(Numberz.EIGHT, (long)8);
      crazy.xtructs.add(goodbye);

      Insanity looney = new Insanity();
      crazy.userMap.put(Numberz.FIVE, (long)5);
      crazy.xtructs.add(hello);

      HashMap<Integer,Insanity> first_map = new HashMap<Integer, Insanity>();
      HashMap<Integer,Insanity> second_map = new HashMap<Integer, Insanity>();;
View Full Code Here

      goodbye.string_thing = "Goodbye4";
      goodbye.byte_thing = (byte)4;
      goodbye.i32_thing = 4;
      goodbye.i64_thing = (long)4;

      Insanity crazy = new Insanity();
      crazy.userMap = new HashMap<Integer, Long>();
      crazy.xtructs = new ArrayList<Xtruct>();

      crazy.userMap.put(Numberz.EIGHT, (long)8);
      crazy.xtructs.add(goodbye);

      Insanity looney = new Insanity();
      crazy.userMap.put(Numberz.FIVE, (long)5);
      crazy.xtructs.add(hello);

      HashMap<Integer,Insanity> first_map = new HashMap<Integer, Insanity>();
      HashMap<Integer,Insanity> second_map = new HashMap<Integer, Insanity>();;
View Full Code Here

      goodbye.string_thing = "Goodbye4";
      goodbye.byte_thing = (byte)4;
      goodbye.i32_thing = 4;
      goodbye.i64_thing = (long)4;
 
      Insanity crazy = new Insanity();
      crazy.userMap = new HashMap<Numberz, Long>();
      crazy.userMap.put(Numberz.EIGHT, (long)8);
      crazy.userMap.put(Numberz.FIVE, (long)5);
      crazy.xtructs = new ArrayList<Xtruct>();
      crazy.xtructs.add(goodbye);
      crazy.xtructs.add(hello);
 
      HashMap<Numberz,Insanity> first_map = new HashMap<Numberz, Insanity>();
      HashMap<Numberz,Insanity> second_map = new HashMap<Numberz, Insanity>();;
 
      first_map.put(Numberz.TWO, crazy);
      first_map.put(Numberz.THREE, crazy);
 
      Insanity looney = new Insanity();
      second_map.put(Numberz.SIX, looney);
 
      Map<Long,Map<Numberz,Insanity>> insane =
        new HashMap<Long, Map<Numberz,Insanity>>();
      insane.put((long)1, first_map);
View Full Code Here

TOP

Related Classes of thrift.test.Insanity

Copyright © 2018 www.massapicom. 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.