Package org.apache.avro.util

Examples of org.apache.avro.util.Utf8


    Transceiver transceiver = new NettyTransceiver(new InetSocketAddress(
        serverPort));
    Mail proxy = (Mail) SpecificRequestor.getClient(Mail.class, transceiver);

    Message msg = new Message();
    msg.to = new Utf8("wife");
    msg.from = new Utf8("husband");
    msg.body = new Utf8("I love you!");

    try {
      CharSequence result = proxy.send(msg);
      System.out.println("Result: " + result);
      Assert.assertEquals(
View Full Code Here


public class TestNettyServer {

  public static class MailImpl implements Mail {
    // in this simple example just return details of the message
    public CharSequence send(Message message) {
      return new Utf8("Sent message to [" + message.to.toString() + "] from ["
          + message.from.toString() + "] with body [" + message.body.toString()
          + "]");
    }
View Full Code Here

    check("\"boolean\"", Boolean.FALSE, Boolean.TRUE);
  }

  @Test
  public void testString() throws Exception {
    check("\"string\"", new Utf8(""), new Utf8("a"));
    check("\"string\"", new Utf8("a"), new Utf8("b"));
    check("\"string\"", new Utf8("a"), new Utf8("ab"));
    check("\"string\"", new Utf8("ab"), new Utf8("b"));
  }
View Full Code Here

          new GenericData.Fixed(new byte[]{(byte)'b'}));
  }

  @Test
  public void testUnion() throws Exception {
    check("[\"string\", \"long\"]", new Utf8("a"), new Utf8("b"), false);
    check("[\"string\", \"long\"]", new Long(1), new Long(2), false);
    check("[\"string\", \"long\"]", new Utf8("a"), new Long(1), false);
  }
View Full Code Here

  @Test
  public void testSpecificRecord() throws Exception {
    TestRecord s1 = new TestRecord();
    TestRecord s2 = new TestRecord();
    s1.name = new Utf8("foo");
    s1.kind = Kind.BAZ;
    s1.hash = new MD5();
    s1.hash.bytes(new byte[] {0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5});
    s2.name = new Utf8("bar");
    s2.kind = Kind.BAR;
    s2.hash = new MD5();
    s2.hash.bytes(new byte[] {0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,6});
    Schema schema = SpecificData.get().getSchema(TestRecord.class);
View Full Code Here

    proxy = (Simple)SpecificRequestor.getClient(Simple.class, client);
  }

  @Test
  public void testHello() throws IOException {
    CharSequence response = proxy.hello(new Utf8("bob"));
    assertEquals(new Utf8("goodbye"), response);
  }
View Full Code Here

  }

  @Test
  public void testEcho() throws IOException {
    TestRecord record = new TestRecord();
    record.name = new Utf8("foo");
    record.kind = Kind.BAR;
    record.hash = new MD5();
    System.arraycopy(new byte[]{0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5}, 0,
                     record.hash.bytes(), 0, 16);
    TestRecord echoed = proxy.echo(record);
View Full Code Here

  @Test
  public void testOneWay() throws IOException {
    ackCount = 0;
    proxy.ack();
    proxy.hello(new Utf8("foo"));                 // intermix normal req
    proxy.ack();
    try { Thread.sleep(100); } catch (InterruptedException e) {}
    assertEquals(2, ackCount);
  }
View Full Code Here

  private static boolean throwUndeclaredError;

  public static class TestImpl implements Simple {
    public CharSequence hello(CharSequence greeting) {
      return new Utf8("goodbye");
    }
View Full Code Here

    public TestRecord echo(TestRecord record) { return record; }
    public ByteBuffer echoBytes(ByteBuffer data) { return data; }
    public Void error() throws AvroRemoteException {
      if (throwUndeclaredError) throw new RuntimeException("foo");
      TestError error = new TestError();
      error.message = new Utf8("an error");
      throw error;
    }
View Full Code Here

TOP

Related Classes of org.apache.avro.util.Utf8

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.