Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add byte array to new file for deserializer test #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void init() {

@Test
void When_deserialize_Expect_ValidChsDeltaObject() throws IOException {
byte[] data = encodedData;
byte[] data = testHelper.createByteArray();

ChsDelta deserializedObject = deserializer.deserialize("", data);

Expand All @@ -45,31 +45,4 @@ void When_deserializeFails_throwsNonRetryableError() {
byte[] data = "Invalid message".getBytes();
assertThrows(NonRetryableErrorException.class, () -> deserializer.deserialize("", data));
}

private byte [] encodedData = {-16, 9, 123, 10, 32, 32, 32, 32, 34, 112, 115, 99, 95, 115, 116, 97, 116, 101, 109,
101, 110, 116, 115, 34, 58, 32, 91, 10, 32, 32, 32, 32, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 34, 99, 111, 109, 112, 97, 110, 121, 95, 110, 117, 109, 98, 101, 114, 34, 58, 32, 34, 48, 56,
54, 57, 52, 56, 54, 48, 34, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 34, 112, 115, 99, 95, 115,
116, 97, 116, 101, 109, 101, 110, 116, 95, 105, 100, 34, 58, 32, 34, 51, 48, 48, 48, 48, 48, 48, 48, 48, 50,
34, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 34, 115, 116, 97, 116, 101, 109, 101, 110, 116,
34, 58, 32, 34, 80, 83, 67, 95, 72, 65, 83, 95, 70, 65, 73, 76, 69, 68, 95, 84, 79, 95, 67, 79, 78, 70, 73,
82, 77, 95, 67, 72, 65, 78, 71, 69, 68, 95, 68, 69, 84, 65, 73, 76, 83, 34, 44, 10, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 34, 115, 117, 98, 109, 105, 116, 116, 101, 100, 95, 111, 110, 34, 58, 32, 34, 50, 48,
49, 54, 48, 51, 49, 52, 34, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 34, 99, 101, 97, 115, 101,
100, 95, 111, 110, 34, 58, 32, 34, 50, 48, 50, 51, 48, 49, 50, 55, 34, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 34, 108, 105, 110, 107, 101, 100, 95, 112, 115, 99, 34, 58, 32, 123, 10, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 34, 110, 111, 116, 105, 102, 105, 99, 97, 116, 105, 111, 110, 95,
105, 100, 34, 58, 32, 34, 51, 48, 48, 53, 48, 49, 49, 57, 52, 52, 34, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 34, 112, 115, 99, 95, 107, 105, 110, 100, 34, 58, 32, 34, 105, 110, 100, 105,
118, 105, 100, 117, 97, 108, 34, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 34,
116, 105, 116, 108, 101, 34, 58, 32, 34, 77, 114, 34, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 34, 115, 117, 114, 110, 97, 109, 101, 34, 58, 32, 34, 67, 111, 110, 103, 114, 101, 115, 115,
112, 101, 114, 115, 111, 110, 108, 105, 113, 117, 111, 114, 34, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 34, 102, 111, 114, 101, 110, 97, 109, 101, 34, 58, 32, 34, 70, 97, 120, 114, 105,
118, 117, 108, 101, 116, 34, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 125, 10, 32, 32, 32, 32, 32,
32, 32, 32, 125, 10, 32, 32, 32, 32, 93, 44, 10, 32, 32, 32, 32, 34, 67, 114, 101, 97, 116, 101, 100, 84, 105,
109, 101, 34, 58, 32, 34, 49, 52, 45, 68, 69, 67, 45, 50, 50, 32, 49, 49, 46, 53, 49, 46, 52, 52, 46, 48, 48,
48, 48, 48, 48, 34, 44, 10, 32, 32, 32, 32, 34, 100, 101, 108, 116, 97, 95, 97, 116, 34, 58, 32, 34, 50, 48,
50, 51, 48, 55, 50, 51, 48, 57, 51, 52, 51, 53, 54, 54, 49, 53, 57, 51, 34, 10, 125, 0, 56, 77, 108, 104, 104,
105, 76, 77, 105, 82, 90, 108, 109, 50, 115, 119, 75, 89, 104, 51, 73, 88, 76, 57, 69, 117, 113, 120, 48, 0};
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ public Message<ChsDelta> createInvalidChsDeltaMessage() {
return buildMessage("This is some invalid data");
}

public byte[] createByteArray() throws IOException {
InputStreamReader exampleArray = new InputStreamReader(
ClassLoader.getSystemClassLoader().getResourceAsStream("serialized-bytes-array.txt"));
String[] byteString = FileCopyUtils.copyToString(exampleArray).split(",");
byte[] bytes = new byte[byteString.length];
for(int i = 0 ; i < bytes.length ; ++i) {
bytes[i] = Byte.parseByte(byteString[i]);
}
return bytes;
}

private ChsDelta buildDelta(String data) {
return ChsDelta.newBuilder()
.setData(data)
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/serialized-bytes-array.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-16,9,123,10,32,32,32,32,34,112,115,99,95,115,116,97,116,101,109,101,110,116,115,34,58,32,91,10,32,32,32,32,32,32,32,32,123,10,32,32,32,32,32,32,32,32,32,32,32,32,34,99,111,109,112,97,110,121,95,110,117,109,98,101,114,34,58,32,34,48,56,54,57,52,56,54,48,34,44,10,32,32,32,32,32,32,32,32,32,32,32,32,34,112,115,99,95,115,116,97,116,101,109,101,110,116,95,105,100,34,58,32,34,51,48,48,48,48,48,48,48,48,50,34,44,10,32,32,32,32,32,32,32,32,32,32,32,32,34,115,116,97,116,101,109,101,110,116,34,58,32,34,80,83,67,95,72,65,83,95,70,65,73,76,69,68,95,84,79,95,67,79,78,70,73,82,77,95,67,72,65,78,71,69,68,95,68,69,84,65,73,76,83,34,44,10,32,32,32,32,32,32,32,32,32,32,32,32,34,115,117,98,109,105,116,116,101,100,95,111,110,34,58,32,34,50,48,49,54,48,51,49,52,34,44,10,32,32,32,32,32,32,32,32,32,32,32,32,34,99,101,97,115,101,100,95,111,110,34,58,32,34,50,48,50,51,48,49,50,55,34,44,10,32,32,32,32,32,32,32,32,32,32,32,32,34,108,105,110,107,101,100,95,112,115,99,34,58,32,123,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,34,110,111,116,105,102,105,99,97,116,105,111,110,95,105,100,34,58,32,34,51,48,48,53,48,49,49,57,52,52,34,44,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,34,112,115,99,95,107,105,110,100,34,58,32,34,105,110,100,105,118,105,100,117,97,108,34,44,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,34,116,105,116,108,101,34,58,32,34,77,114,34,44,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,34,115,117,114,110,97,109,101,34,58,32,34,67,111,110,103,114,101,115,115,112,101,114,115,111,110,108,105,113,117,111,114,34,44,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,34,102,111,114,101,110,97,109,101,34,58,32,34,70,97,120,114,105,118,117,108,101,116,34,10,32,32,32,32,32,32,32,32,32,32,32,32,125,10,32,32,32,32,32,32,32,32,125,10,32,32,32,32,93,44,10,32,32,32,32,34,67,114,101,97,116,101,100,84,105,109,101,34,58,32,34,49,52,45,68,69,67,45,50,50,32,49,49,46,53,49,46,52,52,46,48,48,48,48,48,48,34,44,10,32,32,32,32,34,100,101,108,116,97,95,97,116,34,58,32,34,50,48,50,51,48,55,50,51,48,57,51,52,51,53,54,54,49,53,57,51,34,10,125,0,56,77,108,104,104,105,76,77,105,82,90,108,109,50,115,119,75,89,104,51,73,88,76,57,69,117,113,120,48,0