本文整理汇总了Java中org.jboss.marshalling.Marshalling.createByteOutput方法的典型用法代码示例。如果您正苦于以下问题:Java Marshalling.createByteOutput方法的具体用法?Java Marshalling.createByteOutput怎么用?Java Marshalling.createByteOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.marshalling.Marshalling
的用法示例。
在下文中一共展示了Marshalling.createByteOutput方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEqualBuffer
import org.jboss.marshalling.Marshalling; //导入方法依赖的package包/类
@Test
public void testEqualBuffer() throws Exception {
final byte[] content = "1234567890".getBytes(StandardCharsets.UTF_8);
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
final ByteOutput byteOutput = new ChunkyByteOutput(Marshalling.createByteOutput(byteArrayOutputStream), 10);
byteOutput.write(content);
byteOutput.flush();
final byte[] chunked = byteArrayOutputStream.toByteArray();
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(chunked);
final ByteInput byteInput = new ChunkyByteInput(Marshalling.createByteInput(byteArrayInputStream));
byte[] result = new byte[content.length];
byteInput.read(result);
byteInput.close();
Assert.assertArrayEquals(content, result);
Assert.assertEquals(-1, byteInput.read());
}
示例2: testMultiChunk
import org.jboss.marshalling.Marshalling; //导入方法依赖的package包/类
@Test
public void testMultiChunk() throws Exception {
final byte[] content = "12345678901234567890123456789012345678901234567890".getBytes(StandardCharsets.UTF_8);
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
final ByteOutput byteOutput = new ChunkyByteOutput(Marshalling.createByteOutput(byteArrayOutputStream), 10);
byteOutput.write(content);
byteOutput.flush();
final byte[] chunked = byteArrayOutputStream.toByteArray();
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(chunked);
final ByteInput byteInput = new ChunkyByteInput(Marshalling.createByteInput(byteArrayInputStream));
byte[] result = new byte[content.length];
byteInput.read(result);
byteInput.close();
Assert.assertArrayEquals(content, result);
Assert.assertEquals(-1, byteInput.read());
}
示例3: testRemainingBytes
import org.jboss.marshalling.Marshalling; //导入方法依赖的package包/类
@Test
public void testRemainingBytes() throws Exception {
final byte[] content = "1234567890123456789012345678901234567890123".getBytes(StandardCharsets.UTF_8);
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
final ByteOutput byteOutput = new ChunkyByteOutput(Marshalling.createByteOutput(byteArrayOutputStream), 10);
byteOutput.write(content);
byteOutput.flush();
final byte[] chunked = byteArrayOutputStream.toByteArray();
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(chunked);
final ByteInput byteInput = new ChunkyByteInput(Marshalling.createByteInput(byteArrayInputStream));
byte[] result = new byte[content.length];
byteInput.read(result);
byteInput.close();
Assert.assertArrayEquals(content, result);
Assert.assertEquals(-1, byteInput.read());
}
示例4: testIncompleteRead
import org.jboss.marshalling.Marshalling; //导入方法依赖的package包/类
@Test
public void testIncompleteRead() throws Exception {
final byte[] content = "1234567890123456789012345678901234567890123".getBytes(StandardCharsets.UTF_8);
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
final ByteOutput byteOutput = new ChunkyByteOutput(Marshalling.createByteOutput(byteArrayOutputStream), 10);
byteOutput.write(content);
byteOutput.flush();
final byte[] chunked = byteArrayOutputStream.toByteArray();
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(chunked);
final ByteInput byteInput = new ChunkyByteInput(Marshalling.createByteInput(byteArrayInputStream));
int readLength = content.length - 15;
byte[] result = new byte[readLength];
byteInput.read(result);
byteInput.close();
byte[] expected = new byte[readLength];
System.arraycopy(content, 0, expected, 0, readLength);
Assert.assertArrayEquals(expected, result);
Assert.assertEquals(-1, byteInput.read());
}
示例5: testOffsetRead
import org.jboss.marshalling.Marshalling; //导入方法依赖的package包/类
@Test
public void testOffsetRead() throws Exception {
final byte[] content = "1234567890123456789012345678901234567890123".getBytes(StandardCharsets.UTF_8);
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
final ByteOutput byteOutput = new ChunkyByteOutput(Marshalling.createByteOutput(byteArrayOutputStream), 10);
byteOutput.write(content);
byteOutput.flush();
final byte[] chunked = byteArrayOutputStream.toByteArray();
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(chunked);
final ByteInput byteInput = new ChunkyByteInput(Marshalling.createByteInput(byteArrayInputStream));
int readLength = 5;
byte[] result = new byte[content.length];
byteInput.read(result, content.length - 6, readLength);
byteInput.close();
byte[] expected = new byte[content.length];
System.arraycopy(content, 0, expected, content.length - 6, readLength);
Assert.assertArrayEquals(expected, result);
Assert.assertEquals(-1, byteInput.read());
}
示例6: SimpleByteDataOutput
import org.jboss.marshalling.Marshalling; //导入方法依赖的package包/类
public SimpleByteDataOutput(final OutputStream outputStream) {
this.output = new SimpleDataOutput(Marshalling.createByteOutput(outputStream));
}