Package com.google.appengine.datanucleus.test.jpa

Examples of com.google.appengine.datanucleus.test.jpa.HasBytesJPA


  private static final SerializationStrategy SS =
      SerializationManager.DEFAULT_SERIALIZATION_STRATEGY;

  public void testInsert() throws EntityNotFoundException {
    HasBytesJPA pojo = new HasBytesJPA();

    pojo.setPrimBytes("prim bytes".getBytes());
    pojo.setBytes(PrimitiveArrays.asList("bytes".getBytes()).toArray(new Byte[5]));
    pojo.setByteList(PrimitiveArrays.asList("byte list".getBytes()));
    pojo.setByteSet(new HashSet<Byte>(PrimitiveArrays.asList("byte set".getBytes())));
    pojo.setByteCollection(PrimitiveArrays.asList("byte collection".getBytes()));
    pojo.setOnePrimByte(Integer.valueOf(1).byteValue());
    pojo.setOneByte(Integer.valueOf(2).byteValue());
    pojo.setShortBlob(new ShortBlob("short blob".getBytes()));
    pojo.setSerializedPrimBytes("serialized prim bytes".getBytes());
    pojo.setSerializedBytes(PrimitiveArrays.asList("serialized bytes".getBytes()).toArray(new Byte[5]));
    pojo.setSerializedByteList(PrimitiveArrays.asList("serialized byte list".getBytes()));
    pojo.setSerializedByteSet(new HashSet<Byte>(PrimitiveArrays.asList("serialized byte set".getBytes())));

    beginTxn();
    em.persist(pojo);
    commitTxn();

    Entity e = ds.get(KeyFactory.createKey(HasBytesJPA.class.getSimpleName(), pojo.getId()));
    assertEquals(new ShortBlob("prim bytes".getBytes()), e.getProperty("primBytes"));
    assertEquals(new ShortBlob("bytes".getBytes()), e.getProperty("bytes"));
    assertEquals(new ShortBlob("byte list".getBytes()), e.getProperty("byteList"));
    assertEquals(new HashSet<Byte>(PrimitiveArrays.asList("byte set".getBytes())),
                 new HashSet<Byte>(PrimitiveArrays.asList(
View Full Code Here


    e.setProperty("serializedByteSet", SS.serialize(new HashSet<Byte>(PrimitiveArrays.asList("serialized byte set".getBytes()))));

    ds.put(e);

    beginTxn();
    HasBytesJPA pojo = em.find(HasBytesJPA.class, e.getKey());
    assertTrue(Arrays.equals("prim bytes".getBytes(), pojo.getPrimBytes()));
    assertEquals(PrimitiveArrays.asList("bytes".getBytes()), Arrays.asList(pojo.getBytes()));
    assertEquals(PrimitiveArrays.asList("byte list".getBytes()), pojo.getByteList());
    assertEquals(new HashSet<Byte>(PrimitiveArrays.asList("byte set".getBytes())), pojo.getByteSet());
    assertEquals(PrimitiveArrays.asList("byte collection".getBytes()), pojo.getByteCollection());
    assertEquals(Integer.valueOf(1).byteValue(), pojo.getOnePrimByte());
    assertEquals(Integer.valueOf(2).byteValue(), pojo.getOneByte().byteValue());
    assertEquals(new ShortBlob("short blob".getBytes()), pojo.getShortBlob());
    assertEquals(new Blob("serialized prim bytes".getBytes()), new Blob(pojo.getSerializedPrimBytes()));
    assertEquals(new Blob("serialized bytes".getBytes()),
                 new Blob(PrimitiveArrays.toByteArray(Arrays.asList(pojo.getSerializedBytes()))));
    assertEquals(PrimitiveArrays.asList("serialized byte list".getBytes()),
                 pojo.getSerializedByteList());
    assertEquals(new HashSet<Byte>(PrimitiveArrays.asList("serialized byte set".getBytes())),
                 pojo.getSerializedByteSet());
    commitTxn();
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.datanucleus.test.jpa.HasBytesJPA

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.