Package com.sun.sgs.impl.sharedutil

Examples of com.sun.sgs.impl.sharedutil.MessageBuffer.rewind()


  int capacity = 10;
  MessageBuffer buf1 = new MessageBuffer(capacity);
  for (byte b = 0; b < capacity; b++) {
      buf1.putByte(b);
  }
  buf1.rewind();
  for (byte b = 0; b < capacity; b++) {
      byte b2 = buf1.getByte();
      if (b != b2) {
    fail("Mismatched bytes; b:"+ b + ", b2:" + b2);
      }
View Full Code Here


    }

    public void testPutChar() {
  MessageBuffer buf = new MessageBuffer(2);
  buf.putChar('x');
  buf.rewind();
  char c = buf.getChar();
  if (c != 'x') {
      fail("Expected char 'x', got " + c);
  }
    }
View Full Code Here

  for (char c : s.toCharArray()) {
      buf.putChar(c);
      System.err.print(c);
  }
  System.err.println("\nlimit: " + buf.limit());
  buf.rewind();
  char[] charArray = new char[s.length()];
  for (int i = 0; i < s.length(); i++) {
      charArray[i] = buf.getChar();
      System.err.print(charArray[i]);
  }
View Full Code Here

    public void testPutShort() {
  MessageBuffer buf = new MessageBuffer(2);
  short value1 = 53;
  buf.putShort(value1);
  buf.rewind();
  short value2 = buf.getShort();
  if (value1 != value2) {
      fail("Expected short " + value1 + ", got " + value2);
  }
    }
View Full Code Here

    public void testPutShortSignedBytes() {
        MessageBuffer buf = new MessageBuffer(2);
        short value1 = 0x10ff;
        buf.putShort(value1);
        buf.rewind();
        short value2 = buf.getShort();
        if (value1 != value2) {
            fail("Expected short " + value1 + ", got " + value2);
        }
    }
View Full Code Here

    public void testGetUnsignedShort() {
        MessageBuffer buf = new MessageBuffer(2);
        int value1 = 64000;
        buf.putShort(value1);
        buf.rewind();
        int value2 = buf.getUnsignedShort();
        if (value1 != value2) {
            fail("Expected unsigned short " + value1 + ", got " + value2);
        }
       
View Full Code Here

        if (value1 != value2) {
            fail("Expected unsigned short " + value1 + ", got " + value2);
        }
       
        // test that signed getShort is different
        buf.rewind();
        value2 = buf.getShort();
        if (value1 == value2) {
            fail("Expected unequal, but got " + value2);
        }
        System.err.println("ushort " + value1 + " != " + value2);
View Full Code Here

    public void testPutInt() {
        MessageBuffer buf = new MessageBuffer(4);
        int value1 = 0x01020304;
        buf.putInt(value1);
        buf.rewind();
        int value2 = buf.getInt();
        if (value1 != value2) {
            fail("Expected int " + value1 + ", got " + value2);
        }
    }
View Full Code Here

    public void testPutIntSignedBytes() {
        MessageBuffer buf = new MessageBuffer(4);
        int value1 = 0x01ff02fe;
        buf.putInt(value1);
        buf.rewind();
        int value2 = buf.getInt();
        if (value1 != value2) {
            fail("Expected int " + value1 + ", got " + value2);
        }
    }
View Full Code Here

    public void testPutLong() {
        MessageBuffer buf = new MessageBuffer(8);
        long value1 = 0x0102030405060708L;
        buf.putLong(value1);
        buf.rewind();
        long value2 = buf.getLong();
        if (value1 != value2) {
            fail("Expected long " + value1 + ", got " + value2);
        }
    }
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.