Package com.sun.sgs.impl.sharedutil

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


      System.err.println(e);
  }
    }

    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


  }
    }

    public void testPutChars() {
  String s = "The quick brown fox jumps over the lazy dog.";
  MessageBuffer buf = new MessageBuffer(s.length() * 2);
  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]);
  }
  System.err.println();
  if (!(s.equals(new String(charArray)))) {
      fail("strings don't match");
View Full Code Here

      fail("strings don't match");
  }
    }

    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

      fail("Expected short " + value1 + ", got " + value2);
  }
    }

    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

            fail("Expected short " + value1 + ", got " + value2);
        }
    }

    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);
        }
       
        // 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

        }
        System.err.println("ushort " + value1 + " != " + value2);
    }

    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

            fail("Expected int " + value1 + ", got " + value2);
        }
    }

    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

            fail("Expected int " + value1 + ", got " + value2);
        }
    }

    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

            fail("Expected long " + value1 + ", got " + value2);
        }
    }

    public void testPutLongSignedBytes() {
        MessageBuffer buf = new MessageBuffer(8);
        long value1 = 0x01f203f4f506f708L;
        buf.putLong(value1);
        buf.rewind();
        long value2 = buf.getLong();
        if (value1 != value2) {
            fail("Expected long " + value1 + ", got " + value2);
        }
    }
View Full Code Here

  int size = 100;
  byte[] bytes = new byte[size];
  for (int i = 0; i < bytes.length; i++) {
      bytes[i] = (byte) i;
  }
  MessageBuffer buf = new MessageBuffer(size);
  buf.putBytes(bytes);
  buf.rewind();
  for (int i = 0; i < bytes.length; i++) {
      if (buf.getByte() != bytes[i]) {
    fail("Expected byte " + bytes[i]);
      }
  }
  buf.rewind();
  byte[] moreBytes = buf.getBytes(bytes.length);
  if (moreBytes.length != bytes.length) {
      fail("Mismatched size; expected " + bytes.length +
     ", got " + moreBytes.length);
  }
  for (int i = 0; i < bytes.length; i++) {
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.