Package org.jboss.util.stream

Examples of org.jboss.util.stream.MarshalledValueOutputStream


      startLoader(false, null);

      /* Empty state. */
      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
      loader.loadEntireState(os);
      cache.getMarshaller().objectToObjectStream(StateTransferManager.STREAMING_DELIMITER_NODE, os);
      os.close();

      ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
      MarshalledValueInputStream is = new MarshalledValueInputStream(bais);
      loader.storeEntireState(is);
      is.close();

      baos = new ByteArrayOutputStream(1024);
      os = new MarshalledValueOutputStream(baos);
      loader.loadEntireState(os);
      cache.getMarshaller().objectToObjectStream(StateTransferManager.STREAMING_DELIMITER_NODE, os);
      os.close();

      bais = new ByteArrayInputStream(baos.toByteArray());
      is = new MarshalledValueInputStream(bais);
      loader.storeEntireState(is);
      is.close();

      baos = new ByteArrayOutputStream(1024);
      os = new MarshalledValueOutputStream(baos);
      loader.loadEntireState(os);
      cache.getMarshaller().objectToObjectStream(StateTransferManager.STREAMING_DELIMITER_NODE, os);
      os.close();

      assertEquals(null, loader.get(FQN));

      /* Use a complex object to ensure that the class catalog is used. */
      Complex c1 = new Complex();
      Complex c2 = new Complex(c1);

      /* Add objects. */
      loader.put(FQN, 1, c1);
      loader.put(FQN, 2, c2);
      assertEquals(c1, loader.get(FQN).get(1));
      assertEquals(c2, loader.get(FQN).get(2));
      assertEquals(2, loader.get(FQN).size());

      /* Save state. */
      baos = new ByteArrayOutputStream(1024);
      os = new MarshalledValueOutputStream(baos);
      loader.loadEntireState(os);
      cache.getMarshaller().objectToObjectStream(StateTransferManager.STREAMING_DELIMITER_NODE, os);
      assertTrue(baos.size() > STREAM_HEADER_LENGTH);
      os.close();

      byte[] savedState = baos.toByteArray();

      /* Clear state. */
      baos = new ByteArrayOutputStream(1024);
      os = new MarshalledValueOutputStream(baos);
      cache.getMarshaller().objectToObjectStream(StateTransferManager.STREAMING_DELIMITER_NODE, os);
      os.close();
      bais = new ByteArrayInputStream(baos.toByteArray());
      is = new MarshalledValueInputStream(bais);
      loader.storeEntireState(is);
      is.close();

View Full Code Here


   {

      loader.remove(Fqn.fromString("/"));

      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
      loader.loadEntireState(os);
      os.close();
      int num = baos.size();

      Object txnKey = new Object();
      List<Modification> mods = createUpdates();
      loader.prepare(txnKey, mods, false);
      loader.rollback(txnKey);

      baos = new ByteArrayOutputStream(1024);
      os = new MarshalledValueOutputStream(baos);
      loader.loadEntireState(os);
      os.close();

      assertEquals(num, baos.size());
   }
View Full Code Here

      assertEquals(c2, loader.get(FQN).get(2));
      assertEquals(2, loader.get(FQN).size());

      /* Save state. */
      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
      loader.loadEntireState(os);
      cache.getMarshaller().objectToObjectStream(StateTransferManager.STREAMING_DELIMITER_NODE, os);
      os.close();
      assertTrue(baos.size() > 0);

      byte[] savedState = baos.toByteArray();

      /* Restore state. */
 
View Full Code Here

      loader.remove(Fqn.fromString("/"));
      int num;
      try
      {
         ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
         MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
         loader.loadEntireState(os);
         num = baos.size();
      }
      catch (UnsupportedOperationException ex)
      {
         log.info("caught unsupported operation exception that's okay: ", ex);
         return;
      }

      Object txnKey = new Object();
      List<Modification> mods = createUpdates();
      loader.prepare(txnKey, mods, false);
      loader.rollback(txnKey);
      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
      loader.loadEntireState(os);
      assertEquals(num, baos.size());
   }
View Full Code Here

      loader.remove(Fqn.fromString("/"));
      int num = 0;
      try
      {
         ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
         MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
         loader.loadEntireState(os);
         num = baos.size();
      }
      catch (UnsupportedOperationException ex)
      {
         System.out.println("caught unsupported operation exception that's okay: " + ex);
         return;
      }

      Object txnKey = new Object();
      List<Modification> mods = createUpdates();
      loader.prepare(txnKey, mods, false);
      loader.rollback(txnKey);
      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
      loader.loadEntireState(os);
      assertEquals(num, baos.size());
   }
View Full Code Here

      assertEquals(2, loader.get(FQN).size());

      // Save state
      byte[] state;
      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
      try
      {
         loader.loadEntireState(os);
      }
      catch (UnsupportedOperationException ex)
      {
         System.out.println("caught unsupported operation exception (this is expected): " + ex);
      }
      finally
      {
         cache.getMarshaller().objectToObjectStream(StateTransferManager.STREAMING_DELIMITER_NODE, os);
         os.close();
         assertTrue(baos.size() > 0);
         state = baos.toByteArray();
      }

      /* Restore state. */
 
View Full Code Here

      assertEquals(c4, loader.get(SUBTREE_FQN).get(2));
      assertEquals(2, loader.get(SUBTREE_FQN).size());

      /* Save state. */
      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
      loader.loadState(SUBTREE_FQN, os);
      cache.getMarshaller().objectToObjectStream(StateTransferManager.STREAMING_DELIMITER_NODE, os);
      os.close();
      assertTrue(baos.size() > 0);
      loader.remove(SUBTREE_FQN);

      /* Restore state. */

 
View Full Code Here

      assertEquals(c4, loader.get(SUBTREE_FQN).get(2));
      assertEquals(2, loader.get(SUBTREE_FQN).size());

      /* Save state. */
      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
      loader.loadState(FQN, os);
      cache.getMarshaller().objectToObjectStream(StateTransferManager.STREAMING_DELIMITER_NODE, os);
      os.close();
      assertTrue(baos.size() > 0);

      /* Restore state. */
      ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
      MarshalledValueInputStream is = new MarshalledValueInputStream(bais);
View Full Code Here

      hm.put(null, null);
      hm.put("y", "z");
      MapCopy<String, String> mc = new MapCopy<String, String>(hm);
      assertEquals(hm, mc);
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      ObjectOutputStream oos = new MarshalledValueOutputStream(os);
      oos.writeObject(mc);
      ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
      ObjectInputStream ois = new MarshalledValueInputStream(is);
      Object o = ois.readObject();
      assertEquals(hm, o);
   }
View Full Code Here

     * @return serialized form of the object
     */
    public static byte[] objectToByteBuffer(Object obj) throws Exception
    {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        MarshalledValueOutputStream out = new MarshalledValueOutputStream(baos);
        out.writeObject(obj);
        out.close();
        return baos.toByteArray();
    }
View Full Code Here

TOP

Related Classes of org.jboss.util.stream.MarshalledValueOutputStream

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.