Package thrift.test

Examples of thrift.test.Bonk


    assertFalse(hm.equals(hmCopy2));
  }

  public void testCompareTo() throws Exception {
    Bonk bonk1 = new Bonk();
    Bonk bonk2 = new Bonk();

    // Compare empty thrift objects.
    assertEquals(0, bonk1.compareTo(bonk2));

    bonk1.setMessage("m");

    // Compare one thrift object with a filled in field and another without it.
    assertTrue(bonk1.compareTo(bonk2) > 0);
    assertTrue(bonk2.compareTo(bonk1) < 0);

    // Compare both have filled-in fields.
    bonk2.setMessage("z");
    assertTrue(bonk1.compareTo(bonk2) < 0);
    assertTrue(bonk2.compareTo(bonk1) > 0);

    // Compare bonk1 has a field filled in that bonk2 doesn't.
    bonk1.setType(123);
    assertTrue(bonk1.compareTo(bonk2) > 0);
    assertTrue(bonk2.compareTo(bonk1) < 0);

    // Compare bonk1 and bonk2 equal.
    bonk2.setType(123);
    bonk2.setMessage("m");
    assertEquals(0, bonk1.compareTo(bonk2));
  }
View Full Code Here


    assertFalse(hm.equals(hmCopy2));
  }

  public void testCompareTo() throws Exception {
    Bonk bonk1 = new Bonk();
    Bonk bonk2 = new Bonk();

    // Compare empty thrift objects.
    assertEquals(0, bonk1.compareTo(bonk2));

    bonk1.setMessage("m");

    // Compare one thrift object with a filled in field and another without it.
    assertTrue(bonk1.compareTo(bonk2) > 0);
    assertTrue(bonk2.compareTo(bonk1) < 0);

    // Compare both have filled-in fields.
    bonk2.setMessage("z");
    assertTrue(bonk1.compareTo(bonk2) < 0);
    assertTrue(bonk2.compareTo(bonk1) > 0);

    // Compare bonk1 has a field filled in that bonk2 doesn't.
    bonk1.setType(123);
    assertTrue(bonk1.compareTo(bonk2) > 0);
    assertTrue(bonk2.compareTo(bonk1) < 0);

    // Compare bonk1 and bonk2 equal.
    bonk2.setType(123);
    bonk2.setMessage("m");
    assertEquals(0, bonk1.compareTo(bonk2));
  }
View Full Code Here

    assertFalse(hm.equals(hmCopy2));
  }

  public void testCompareTo() throws Exception {
    Bonk bonk1 = new Bonk();
    Bonk bonk2 = new Bonk();

    // Compare empty thrift objects.
    assertEquals(0, bonk1.compareTo(bonk2));

    bonk1.setMessage("m");

    // Compare one thrift object with a filled in field and another without it.
    assertTrue(bonk1.compareTo(bonk2) > 0);
    assertTrue(bonk2.compareTo(bonk1) < 0);

    // Compare both have filled-in fields.
    bonk2.setMessage("z");
    assertTrue(bonk1.compareTo(bonk2) < 0);
    assertTrue(bonk2.compareTo(bonk1) > 0);

    // Compare bonk1 has a field filled in that bonk2 doesn't.
    bonk1.setType(123);
    assertTrue(bonk1.compareTo(bonk2) > 0);
    assertTrue(bonk2.compareTo(bonk1) < 0);

    // Compare bonk1 and bonk2 equal.
    bonk2.setType(123);
    bonk2.setMessage("m");
    assertEquals(0, bonk1.compareTo(bonk2));
  }
View Full Code Here

    // Struct header, Integer.MAX_VALUE length, and only one real
    // byte of data
    byte [] bytes = {24, -1, -1, -1, -17, 49};
    TDeserializer deser = new TDeserializer(new TCompactProtocol
              .Factory(1000));
    Bonk bonk = new Bonk();
    try {
  deser.deserialize(bonk, bytes);
    } catch (TException e) {
  // Ignore as we are only checking for OOM in the failure case
    }
View Full Code Here

  }

  public void testOOMDenialOfService() throws Exception {
    TDeserializer deser = new TDeserializer(new TBinaryProtocol
              .Factory(false, false, 1000));
    Bonk bonk = new Bonk();
    try {
      // Invalid read length specified here. Would cause an OOM
      // without the limit on the read length
      deser.deserialize(bonk, new byte[]{11, 0, 1, 127, -1, -1, -1});
    } catch (TException e) {
View Full Code Here

    assertFalse(hm.equals(hmCopy2));
  }

  public void testCompareTo() throws Exception {
    Bonk bonk1 = new Bonk();
    Bonk bonk2 = new Bonk();

    // Compare empty thrift objects.
    assertEquals(0, bonk1.compareTo(bonk2));

    bonk1.setMessage("m");

    // Compare one thrift object with a filled in field and another without it.
    assertTrue(bonk1.compareTo(bonk2) > 0);
    assertTrue(bonk2.compareTo(bonk1) < 0);

    // Compare both have filled-in fields.
    bonk2.setMessage("z");
    assertTrue(bonk1.compareTo(bonk2) < 0);
    assertTrue(bonk2.compareTo(bonk1) > 0);

    // Compare bonk1 has a field filled in that bonk2 doesn't.
    bonk1.setType(123);
    assertTrue(bonk1.compareTo(bonk2) > 0);
    assertTrue(bonk2.compareTo(bonk1) < 0);

    // Compare bonk1 and bonk2 equal.
    bonk2.setType(123);
    bonk2.setMessage("m");
    assertEquals(0, bonk1.compareTo(bonk2));
  }
View Full Code Here

    assertFalse(hm.equals(hmCopy2));
  }

  public void testCompareTo() throws Exception {
    Bonk bonk1 = new Bonk();
    Bonk bonk2 = new Bonk();

    // Compare empty thrift objects.
    assertEquals(0, bonk1.compareTo(bonk2));

    bonk1.setMessage("m");

    // Compare one thrift object with a filled in field and another without it.
    assertTrue(bonk1.compareTo(bonk2) > 0);
    assertTrue(bonk2.compareTo(bonk1) < 0);

    // Compare both have filled-in fields.
    bonk2.setMessage("z");
    assertTrue(bonk1.compareTo(bonk2) < 0);
    assertTrue(bonk2.compareTo(bonk1) > 0);

    // Compare bonk1 has a field filled in that bonk2 doesn't.
    bonk1.setType(123);
    assertTrue(bonk1.compareTo(bonk2) > 0);
    assertTrue(bonk2.compareTo(bonk1) < 0);

    // Compare bonk1 and bonk2 equal.
    bonk2.setType(123);
    bonk2.setMessage("m");
    assertEquals(0, bonk1.compareTo(bonk2));
  }
View Full Code Here

      ooe.double_precision = Math.PI;
      ooe.some_characters  = "JSON THIS! \"\1";
      ooe.zomg_unicode     = new String(kUnicodeBytes, "UTF-8");


      Nesting n = new Nesting(new Bonk(), new OneOfEach());
      n.my_ooe.integer16 = 16;
      n.my_ooe.integer32 = 32;
      n.my_ooe.integer64 = 64;
      n.my_ooe.double_precision = (Math.sqrt(5)+1)/2;
      n.my_ooe.some_characters  = ":R (me going \"rrrr\")";
      n.my_ooe.zomg_unicode     = new String(kUnicodeBytes, "UTF-8");
      n.my_bonk.type    = 31337;
      n.my_bonk.message = "I am a bonk... xor!";

      HolyMoley hm = new HolyMoley();

      hm.big = new ArrayList<OneOfEach>();
      hm.big.add(ooe);
      hm.big.add(n.my_ooe);
      hm.big.get(0).a_bite = (byte)0x22;
      hm.big.get(1).a_bite = (byte)0x23;

      hm.contain = new HashSet<List<String>>();
      ArrayList<String> stage1 = new ArrayList<String>(2);
      stage1.add("and a one");
      stage1.add("and a two");
      hm.contain.add(stage1);
      stage1 = new ArrayList<String>(3);
      stage1.add("then a one, two");
      stage1.add("three!");
      stage1.add("FOUR!!");
      hm.contain.add(stage1);
      stage1 = new ArrayList<String>(0);
      hm.contain.add(stage1);

      ArrayList<Bonk> stage2 = new ArrayList<Bonk>();
      hm.bonks = new HashMap<String, List<Bonk>>();
      hm.bonks.put("nothing", stage2);
      Bonk b = new Bonk();
      b.type = 1;
      b.message = "Wait.";
      stage2.add(b);
      b = new Bonk();
      b.type = 2;
      b.message = "What?";
      stage2.add(b);
      stage2 = new ArrayList<Bonk>();
      hm.bonks.put("something", stage2);
      b = new Bonk();
      b.type = 3;
      b.message = "quoth";
      b = new Bonk();
      b.type = 4;
      b.message = "the raven";
      b = new Bonk();
      b.type = 5;
      b.message = "nevermore";
      hm.bonks.put("poe", stage2);

      TMemoryBuffer buffer = new TMemoryBuffer(1024);
View Full Code Here

    n.my_ooe.some_characters  = ":R (me going \"rrrr\")";
    n.my_ooe.zomg_unicode     = "\u04c0\u216e\u039d\u0020\u041d\u03bf\u217f"+
                                "\u043e\u0261\u0433\u0430\u03c1\u210e\u0020"+
                                "\u0391\u0074\u0074\u03b1\u217d\u03ba\u01c3"+
                                "\u203c";
    n.my_bonk = new Bonk();
    n.my_bonk.type    = 31337;
    n.my_bonk.message = "I am a bonk... xor!";

    HolyMoley hm = new HolyMoley();
    hm.big = new ArrayList<OneOfEach>();
    hm.contain = new HashSet<List<String>>();
    hm.bonks = new HashMap<String,List<Bonk>>();

    hm.big.add((OneOfEach)deepCopy(ooe));
    hm.big.add((OneOfEach)deepCopy(n.my_ooe));
    hm.big.get(0).a_bite = 0x22;
    hm.big.get(1).a_bite = 0x33;

    List<String> stage1 = new ArrayList<String>();
    stage1.add("and a one");
    stage1.add("and a two");
    hm.contain.add(stage1);
    stage1 = new ArrayList<String>();
    stage1.add("then a one, two");
    stage1.add("three!");
    stage1.add("FOUR!!");
    hm.contain.add(stage1);
    stage1 = new ArrayList<String>();
    hm.contain.add(stage1);

    List<Bonk> stage2 = new ArrayList<Bonk>();
    hm.bonks.put("nothing", stage2);
    stage2.add(new Bonk());
    stage2.get(0).type = 1;
    stage2.get(0).message = "Wait.";
    stage2.add(new Bonk());
    stage2.get(1).type = 2;
    stage2.get(1).message = "What?";
    hm.bonks.put("something", stage2);
    stage2 = new ArrayList<Bonk>();
    stage2.add(new Bonk());
    stage2.get(0).type = 3;
    stage2.get(0).message = "quoth";
    stage2.add(new Bonk());
    stage2.get(1).type = 4;
    stage2.get(1).message = "the raven";
    stage2.add(new Bonk());
    stage2.get(2).type = 5;
    stage2.get(2).message = "nevermore";
    hm.bonks.put("poe", stage2);

    OneOfEach ooe2 = new OneOfEach();
View Full Code Here

TOP

Related Classes of thrift.test.Bonk

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.