Package com.sun.sgs.impl.sharedutil

Examples of com.sun.sgs.impl.sharedutil.MessageBuffer


  }
    }

    public void testPutString() {
  String s = "Supercalafragilisticexpalidocious";
  MessageBuffer buf = new MessageBuffer(MessageBuffer.getSize(s));
  buf.putString(s);
  buf.rewind();
  String newString = buf.getString();
  System.err.println("newString: " + newString);
  if (!s.equals(newString)) {
      fail("Expected: " + s + ", got: " + newString);
  }
    }
View Full Code Here


    }

    public void testPutStringAndInt() {
  String s = "zowie!";
  int x = 1024;
  MessageBuffer buf = new MessageBuffer(MessageBuffer.getSize(s) + 4);
  buf.putString(s);
  buf.putInt(x);
  buf.rewind();
  String newString = buf.getString();
  System.err.println("newString: " + newString);
  int newX = buf.getInt();
  System.err.println("newX: " + newX);
  if (!s.equals(newString)) {
      fail("Expected string: " + s + ", got: " + newString);
  }
  if (x != newX) {
      fail("Expected int: " + x + ", got: " + newX);
  }
  if (buf.position() != buf.limit()) {
      fail("limit not equal to position; limit: " + buf.limit() +
     ", position: " + buf.position());
  }
    }
View Full Code Here

  }
    }

    public void testPutStringGetUTF8() {
  String s = "The quick brown fox jumps over the lazy dog.";
  MessageBuffer buf = new MessageBuffer(MessageBuffer.getSize(s));
  buf.putString(s);
  buf.rewind();
  short utfLen = buf.getShort();
  byte[] utfBytes = buf.getBytes(utfLen);
  String newString;
  try {
      newString = new String(utfBytes, "UTF-8");
  } catch (Exception e) {
      throw new RuntimeException(e);
View Full Code Here

      utfBytes = s.getBytes("UTF-8");
  } catch (Exception e) {
      throw new RuntimeException(e);
  }
  int utfLen = utfBytes.length;
  MessageBuffer buf = new MessageBuffer(2 + utfLen);
  buf.putShort(utfLen).
      putBytes(utfBytes);
  buf.rewind();
  String newString = buf.getString();
  System.err.println("newString: " + newString);
  if (!s.equals(newString)) {
      fail("Expected: " + s + ", got: " + newString);
  }
    }
View Full Code Here

TOP

Related Classes of com.sun.sgs.impl.sharedutil.MessageBuffer

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.