Package org.infinispan.protostream.domain

Examples of org.infinispan.protostream.domain.Account


      String description = reader.readString("description");
      long creationDate = reader.readLong("creationDate");
      Account.Limits limits = reader.readObject("limits", Account.Limits.class);
      List<byte[]> blurb = reader.readCollection("blurb", new ArrayList<byte[]>(), byte[].class);

      Account account = new Account();
      account.setId(id);
      account.setDescription(description);
      account.setCreationDate(new Date(creationDate));
      account.setLimits(limits);
      account.setBlurb(blurb);
      return account;
   }
View Full Code Here


   @Test
   public void testMarshallAccount() throws Exception {
      SerializationContext ctx = createContext();

      Account account = new Account();
      account.setId(1);
      account.setDescription("test account");
      Date creationDate = new Date();
      account.setCreationDate(creationDate);
      List<byte[]> blurb = new ArrayList<byte[]>();
      blurb.add(new byte[0]);
      blurb.add(new byte[]{1, 2, 3});
      account.setBlurb(blurb);

      byte[] bytes = ProtobufUtil.toByteArray(ctx, account);

      Account decoded = ProtobufUtil.fromByteArray(ctx, bytes, Account.class);

      assertEquals(1, decoded.getId());
      assertEquals("test account", decoded.getDescription());
      assertEquals(creationDate, decoded.getCreationDate());

      assertNotNull(decoded.getBlurb());
      assertEquals(2, decoded.getBlurb().size());
      assertEquals(0, decoded.getBlurb().get(0).length);
      assertEquals(3, decoded.getBlurb().get(1).length);
      assertArrayEquals(new byte[]{1, 2, 3}, decoded.getBlurb().get(1));
   }
View Full Code Here

   @Test
   public void testMarshallAccount() throws Exception {
      SerializationContext ctx = createContext();

      Account account = new Account();
      account.setId(1);
      account.setDescription("test account");
      Date creationDate = new Date();
      account.setCreationDate(creationDate);
      List<byte[]> blurb = new ArrayList<byte[]>();
      blurb.add(new byte[0]);
      blurb.add(new byte[]{1, 2, 3});
      account.setBlurb(blurb);

      byte[] bytes = ProtobufUtil.toByteArray(ctx, account);

      Account decoded = ProtobufUtil.fromByteArray(ctx, bytes, Account.class);

      assertEquals(1, decoded.getId());
      assertEquals("test account", decoded.getDescription());
      assertEquals(creationDate, decoded.getCreationDate());

      assertNotNull(decoded.getBlurb());
      assertEquals(2, decoded.getBlurb().size());
      assertEquals(0, decoded.getBlurb().get(0).length);
      assertEquals(3, decoded.getBlurb().get(1).length);
      assertArrayEquals(new byte[]{1, 2, 3}, decoded.getBlurb().get(1));
   }
View Full Code Here

TOP

Related Classes of org.infinispan.protostream.domain.Account

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.