Search in sources :

Example 1 with Header

use of software.amazon.awssdk.crt.eventstream.Header in project aws-crt-java by awslabs.

the class EventStreamHeaderTest method testIntHeaderSerialization.

@Test
public void testIntHeaderSerialization() {
    Header header = Header.createHeader("testHeader", 123456789);
    ByteBuffer serializedBuffer = ByteBuffer.allocate(1024);
    header.writeToByteBuffer(serializedBuffer);
    serializedBuffer.position(0);
    Header deserializedHeader = Header.fromByteBuffer(serializedBuffer);
    assertEquals(header, deserializedHeader);
}
Also used : Header(software.amazon.awssdk.crt.eventstream.Header) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 2 with Header

use of software.amazon.awssdk.crt.eventstream.Header in project aws-crt-java by awslabs.

the class EventStreamHeaderTest method testDateHeaderSerialization.

@Test
public void testDateHeaderSerialization() {
    Date headerValue = new Date();
    Header header = Header.createHeader("testHeader", headerValue);
    ByteBuffer serializedBuffer = ByteBuffer.allocate(1024);
    header.writeToByteBuffer(serializedBuffer);
    serializedBuffer.position(0);
    Header deserializedHeader = Header.fromByteBuffer(serializedBuffer);
    assertEquals(header, deserializedHeader);
}
Also used : Header(software.amazon.awssdk.crt.eventstream.Header) ByteBuffer(java.nio.ByteBuffer) Date(java.util.Date) Test(org.junit.Test)

Example 3 with Header

use of software.amazon.awssdk.crt.eventstream.Header in project aws-crt-java by awslabs.

the class EventStreamHeaderTest method testByteHeader.

@Test
public void testByteHeader() {
    Header byteHeader = Header.createHeader("testHeader", (byte) 127);
    assertEquals(127, byteHeader.getValueAsByte());
    assertEquals("testHeader", byteHeader.getName());
    assertEquals(HeaderType.Byte, byteHeader.getHeaderType());
}
Also used : Header(software.amazon.awssdk.crt.eventstream.Header) Test(org.junit.Test)

Example 4 with Header

use of software.amazon.awssdk.crt.eventstream.Header in project aws-crt-java by awslabs.

the class EventStreamHeaderTest method testShortHeader.

@Test
public void testShortHeader() {
    Header shortHeader = Header.createHeader("testHeader", (short) 8001);
    assertEquals(8001, shortHeader.getValueAsShort());
    assertEquals("testHeader", shortHeader.getName());
    assertEquals(HeaderType.Int16, shortHeader.getHeaderType());
}
Also used : Header(software.amazon.awssdk.crt.eventstream.Header) Test(org.junit.Test)

Example 5 with Header

use of software.amazon.awssdk.crt.eventstream.Header in project aws-crt-java by awslabs.

the class EventStreamHeaderTest method testLongHeaderSerialization.

@Test
public void testLongHeaderSerialization() {
    Header header = Header.createHeader("testHeader", (long) Integer.MAX_VALUE + 1);
    ByteBuffer serializedBuffer = ByteBuffer.allocate(1024);
    header.writeToByteBuffer(serializedBuffer);
    serializedBuffer.position(0);
    Header deserializedHeader = Header.fromByteBuffer(serializedBuffer);
    assertEquals(header, deserializedHeader);
}
Also used : Header(software.amazon.awssdk.crt.eventstream.Header) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

Header (software.amazon.awssdk.crt.eventstream.Header)30 Test (org.junit.Test)19 ByteBuffer (java.nio.ByteBuffer)9 EventLoopGroup (software.amazon.awssdk.crt.io.EventLoopGroup)6 SocketOptions (software.amazon.awssdk.crt.io.SocketOptions)6 LinkedList (java.util.LinkedList)5 ExecutionException (java.util.concurrent.ExecutionException)5 Test (org.junit.jupiter.api.Test)5 ClientBootstrap (software.amazon.awssdk.crt.io.ClientBootstrap)5 HostResolver (software.amazon.awssdk.crt.io.HostResolver)5 TestIpcServiceHandler (software.amazon.awssdk.eventstreamrpc.test.TestIpcServiceHandler)5 ArrayList (java.util.ArrayList)4 TimeoutException (java.util.concurrent.TimeoutException)4 List (java.util.List)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 MessageType (software.amazon.awssdk.crt.eventstream.MessageType)3 Date (java.util.Date)2 UUID (java.util.UUID)2 ServerConnectionContinuationHandler (software.amazon.awssdk.crt.eventstream.ServerConnectionContinuationHandler)2 Configuration (com.aws.greengrass.config.Configuration)1