Examples of Utf8


Examples of org.apache.avro.util.Utf8

  private static boolean throwUndeclaredError;

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

Examples of org.apache.avro.util.Utf8

    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

Examples of org.apache.avro.util.Utf8

    newDecoderWithNoData().readBytes(null);
  }
 
  @Test(expected=EOFException.class)
  public void testEOFString() throws IOException {
    newDecoderWithNoData().readString(new Utf8("a"));
  }
View Full Code Here

Examples of org.apache.avro.util.Utf8

        break;
      case 'S':
        {
          extractInt(cs);
          String s = (String) values[p++];
          vw.writeString(new Utf8(s));
          break;
        }
      case 'K':
      {
        extractInt(cs);
View Full Code Here

Examples of org.apache.avro.util.Utf8

        if (level == skipLevel) {
          vi.skipString();
          p++;
        } else {
          String s = (String) values[p++];
          assertEquals(new Utf8(s), vi.readString(null));
        }
        break;
      case 'K':
        extractInt(cs);
        if (level == skipLevel) {
          vi.skipString();
          p++;
        } else {
          String s = (String) values[p++];
          assertEquals(new Utf8(s), vi.readString(null));
        }
        break;
      case 'b':
        extractInt(cs);
        if (level == skipLevel) {
View Full Code Here

Examples of org.apache.avro.util.Utf8

    default: throw new RuntimeException("Unknown type: "+schema);
    }
  }

  private static Utf8 randomUtf8(Random rand, int maxLength) {
    Utf8 utf8 = new Utf8().setLength(rand.nextInt(maxLength));
    for (int i = 0; i < utf8.getLength(); i++) {
      utf8.getBytes()[i] = (byte)('a'+rand.nextInt('z'-'a'));
    }
    return utf8;
  }
View Full Code Here

Examples of org.apache.avro.util.Utf8

    @Test
    public void testZeroInjection() throws IOException
    {
        org.apache.cassandra.avro.CfDef cd = new org.apache.cassandra.avro.CfDef();
        // populate only fields that must be non-null.
        cd.keyspace = new Utf8("Lest Ks");
        cd.name = new Utf8("Mest Cf");
       
        org.apache.cassandra.avro.CfDef cd2 = SerDeUtils.deserializeWithSchema(SerDeUtils.serializeWithSchema(cd), new org.apache.cassandra.avro.CfDef());
        assert cd.equals(cd2);
        // make sure some of the fields didn't get unexpected zeros put in during [de]serialize operations.
        assert cd.min_compaction_threshold == null;
View Full Code Here

Examples of org.apache.avro.util.Utf8

  @Test
  public void testHello() throws IOException {
    GenericRecord params =
      new GenericData.Record(PROTOCOL.getMessages().get("hello").getRequest());
    params.put("greeting", new Utf8("bob"));
    Utf8 response = (Utf8)requestor.request("hello", params);
    assertEquals(new Utf8("goodbye"), response);
  }
View Full Code Here

Examples of org.apache.avro.util.Utf8

  @Test
  public void testEcho() throws IOException {
    GenericRecord record =
      new GenericData.Record(PROTOCOL.getType("TestRecord"));
    record.put("name", new Utf8("foo"));
    record.put("kind", new GenericData.EnumSymbol("BAR"));
    record.put("hash", new GenericData.Fixed
               (new byte[]{0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5}));
    GenericRecord params =
      new GenericData.Record(PROTOCOL.getMessages().get("echo").getRequest());
View Full Code Here

Examples of org.apache.avro.util.Utf8

      = new SocketTransceiver(new InetSocketAddress(server.getPort()));
    try {
      GenericRequestor r = new GenericRequestor(protocol, t);
      GenericRecord params = new GenericData.Record(message.getRequest());
      params.put("extra", Boolean.TRUE);
      params.put("greeting", new Utf8("bob"));
      Utf8 response = (Utf8)r.request("hello", params);
      assertEquals(new Utf8("goodbye"), response);
    } finally {
      t.close();
    }
  }
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.