mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 08:58:38 +01:00
Switch DynamoDB to AWSv2.
Switch from using com.amazonaws.services.dynamodbv2 to using software.amazon.awssdk.services.dynamodb for all current DynamoDB uses.
This commit is contained in:
committed by
gram-signal
parent
cbd9681e3e
commit
c545cff1b3
@@ -12,7 +12,6 @@ import java.io.InputStreamReader;
|
||||
import java.net.Inet4Address;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Optional;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2013-2021 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.whispersystems.textsecuregcm.util;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class AttributeValuesTest {
|
||||
@Test
|
||||
void testUUIDRoundTrip() {
|
||||
UUID orig = UUID.randomUUID();
|
||||
AttributeValue av = AttributeValues.fromUUID(orig);
|
||||
UUID returned = AttributeValues.getUUID(Map.of("foo", av), "foo", null);
|
||||
assertEquals(orig, returned);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLongRoundTrip() {
|
||||
long orig = 12345;
|
||||
AttributeValue av = AttributeValues.fromLong(orig);
|
||||
long returned = AttributeValues.getLong(Map.of("foo", av), "foo", -1);
|
||||
assertEquals(orig, returned);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIntRoundTrip() {
|
||||
int orig = 12345;
|
||||
AttributeValue av = AttributeValues.fromInt(orig);
|
||||
int returned = AttributeValues.getInt(Map.of("foo", av), "foo", -1);
|
||||
assertEquals(orig, returned);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testByteBuffer() {
|
||||
byte[] bytes = {1, 2, 3};
|
||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||
AttributeValue av = AttributeValues.fromByteBuffer(bb);
|
||||
byte[] returned = av.b().asByteArray();
|
||||
assertArrayEquals(bytes, returned);
|
||||
returned = AttributeValues.getByteArray(Map.of("foo", av), "foo", null);
|
||||
assertArrayEquals(bytes, returned);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testByteBuffer2() {
|
||||
final ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[8]);
|
||||
byteBuffer.putLong(123);
|
||||
assertEquals(byteBuffer.remaining(), 0);
|
||||
AttributeValue av = AttributeValues.fromByteBuffer(byteBuffer.flip());
|
||||
assertArrayEquals(new byte[]{0, 0, 0, 0, 0, 0, 0, 123}, AttributeValues.getByteArray(Map.of("foo", av), "foo", null));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user