Skip to content

Commit 28dc4e1

Browse files
More tests and test support
1 parent 3da36d9 commit 28dc4e1

15 files changed

+2495
-3
lines changed

pom.xml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
<properties>
3333
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
34+
<sqlite4java.version>1.0.392</sqlite4java.version>
3435
</properties>
3536

3637
<dependencyManagement>
@@ -51,6 +52,11 @@
5152
<artifactId>aws-java-sdk-dynamodb</artifactId>
5253
</dependency>
5354

55+
<dependency>
56+
<groupId>com.amazonaws</groupId>
57+
<artifactId>aws-java-sdk-kms</artifactId>
58+
</dependency>
59+
5460
<dependency>
5561
<groupId>junit</groupId>
5662
<artifactId>junit</artifactId>
@@ -71,6 +77,21 @@
7177
<version>1.10.5.1</version>
7278
<scope>test</scope>
7379
</dependency>
80+
81+
<dependency>
82+
<groupId>com.almworks.sqlite4java</groupId>
83+
<artifactId>sqlite4java</artifactId>
84+
<version>${sqlite4java.version}</version>
85+
<scope>test</scope>
86+
</dependency>
87+
88+
<dependency>
89+
<groupId>com.almworks.sqlite4java</groupId>
90+
<artifactId>libsqlite4java-linux-amd64</artifactId>
91+
<type>so</type>
92+
<version>${sqlite4java.version}</version>
93+
<scope>test</scope>
94+
</dependency>
7495
</dependencies>
7596

7697
<!--Custom repository:-->
@@ -104,6 +125,53 @@
104125
<maxmemory>1024m</maxmemory>
105126
</configuration>
106127
</plugin>
128+
129+
<plugin>
130+
<groupId>org.apache.maven.plugins</groupId>
131+
<artifactId>maven-dependency-plugin</artifactId>
132+
<executions>
133+
<execution>
134+
<id>copy</id>
135+
<phase>compile</phase>
136+
<goals>
137+
<goal>copy</goal>
138+
</goals>
139+
<configuration>
140+
<artifactItems>
141+
<artifactItem>
142+
<groupId>com.almworks.sqlite4java</groupId>
143+
<artifactId>libsqlite4java-linux-amd64</artifactId>
144+
<version>${sqlite4java.version}</version>
145+
<type>so</type>
146+
<overWrite>true</overWrite>
147+
<outputDirectory>${project.build.directory}/test-lib</outputDirectory>
148+
</artifactItem>
149+
</artifactItems>
150+
</configuration>
151+
</execution>
152+
</executions>
153+
</plugin>
154+
155+
<plugin>
156+
<groupId>org.apache.maven.plugins</groupId>
157+
<artifactId>maven-surefire-plugin</artifactId>
158+
<version>2.19.1</version>
159+
<configuration>
160+
<includes>
161+
<include>**/Test*.java</include>
162+
<include>**/*Test.java</include>
163+
<include>**/*TestCase.java</include>
164+
<include>**/*Tests.java</include>
165+
<include>**/*TestCases.java</include>
166+
</includes>
167+
<systemProperties>
168+
<property>
169+
<name>sqlite4java.library.path</name>
170+
<value>${project.build.directory}/test-lib</value>
171+
</property>
172+
</systemProperties>
173+
</configuration>
174+
</plugin>
107175
</plugins>
108176
</build>
109177

src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/TransformerHolisticTests.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import com.amazonaws.services.dynamodbv2.model.CreateTableRequest;
5252
import com.amazonaws.services.dynamodbv2.model.KeySchemaElement;
5353
import com.amazonaws.services.dynamodbv2.model.KeyType;
54+
import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput;
5455
import com.amazonaws.services.dynamodbv2.model.PutItemRequest;
5556
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType;
5657
import com.amazonaws.services.dynamodbv2.model.ScanRequest;
@@ -250,7 +251,8 @@ public void setUp() {
250251

251252
client.createTable(new CreateTableRequest().withTableName("TableName")
252253
.withAttributeDefinitions(attrDef)
253-
.withKeySchema(keySchema));
254+
.withKeySchema(keySchema)
255+
.withProvisionedThroughput(new ProvisionedThroughput(100L, 100L)));
254256

255257
attrDef = new ArrayList<AttributeDefinition>();
256258
attrDef.add(new AttributeDefinition().withAttributeName("hashKey").withAttributeType(ScalarAttributeType.S));
@@ -259,7 +261,8 @@ public void setUp() {
259261

260262
client.createTable(new CreateTableRequest().withTableName("HashKeyOnly")
261263
.withAttributeDefinitions(attrDef)
262-
.withKeySchema(keySchema));
264+
.withKeySchema(keySchema)
265+
.withProvisionedThroughput(new ProvisionedThroughput(100L, 100L)));
263266

264267
attrDef = new ArrayList<AttributeDefinition>();
265268
attrDef.add(new AttributeDefinition().withAttributeName("hashKey").withAttributeType(ScalarAttributeType.B));
@@ -271,7 +274,8 @@ public void setUp() {
271274

272275
client.createTable(new CreateTableRequest().withTableName("DeterministicTable")
273276
.withAttributeDefinitions(attrDef)
274-
.withKeySchema(keySchema));
277+
.withKeySchema(keySchema)
278+
.withProvisionedThroughput(new ProvisionedThroughput(100L, 100L)));
275279
}
276280

277281
@Test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except
5+
* in compliance with the License. A copy of the License is located at
6+
*
7+
* http://aws.amazon.com/apache2.0
8+
*
9+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
package com.amazonaws.services.dynamodbv2.mapper.encryption;
14+
15+
import java.util.Set;
16+
17+
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;
18+
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
19+
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
20+
21+
/**
22+
* Test domain class with byte[] attribute, byte[] set and a string key
23+
*/
24+
@DynamoDBTable(tableName = "aws-java-sdk-util-crypto")
25+
public class BinaryAttributeByteArrayTestClass {
26+
27+
private String key;
28+
private byte[] binaryAttribute;
29+
private Set<byte[]> binarySetAttribute;
30+
31+
@DynamoDBHashKey(attributeName = "key")
32+
public String getKey() {
33+
return key;
34+
}
35+
36+
public void setKey(String key) {
37+
this.key = key;
38+
}
39+
40+
@DynamoDBAttribute(attributeName = "binaryAttribute")
41+
public byte[] getBinaryAttribute() {
42+
return binaryAttribute;
43+
}
44+
45+
public void setBinaryAttribute(byte[] binaryAttribute) {
46+
this.binaryAttribute = binaryAttribute;
47+
}
48+
49+
@DynamoDBAttribute(attributeName = "binarySetAttribute")
50+
public Set<byte[]> getBinarySetAttribute() {
51+
return binarySetAttribute;
52+
}
53+
54+
public void setBinarySetAttribute(Set<byte[]> binarySetAttribute) {
55+
this.binarySetAttribute = binarySetAttribute;
56+
}
57+
58+
@Override
59+
public int hashCode() {
60+
final int prime = 31;
61+
int result = 1;
62+
result = prime * result + ((key == null) ? 0 : key.hashCode());
63+
result = prime * result + ((binaryAttribute == null) ? 0 : binaryAttribute.hashCode());
64+
result = prime * result + ((binarySetAttribute == null) ? 0 : binarySetAttribute.hashCode());
65+
return result;
66+
}
67+
68+
@Override
69+
public boolean equals(Object obj) {
70+
if ( this == obj )
71+
return true;
72+
if ( obj == null )
73+
return false;
74+
if ( getClass() != obj.getClass() )
75+
return false;
76+
BinaryAttributeByteArrayTestClass other = (BinaryAttributeByteArrayTestClass) obj;
77+
if ( key == null ) {
78+
if ( other.key != null )
79+
return false;
80+
} else if ( !key.equals(other.key) )
81+
return false;
82+
if ( binaryAttribute == null ) {
83+
if ( other.binaryAttribute != null )
84+
return false;
85+
} else if ( !binaryAttribute.equals(other.binaryAttribute) )
86+
return false;
87+
if ( binarySetAttribute == null ) {
88+
if ( other.binarySetAttribute != null )
89+
return false;
90+
} else if ( !binarySetAttribute.equals(other.binarySetAttribute) )
91+
return false;
92+
return true;
93+
}
94+
95+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except
5+
* in compliance with the License. A copy of the License is located at
6+
*
7+
* http://aws.amazon.com/apache2.0
8+
*
9+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
package com.amazonaws.services.dynamodbv2.mapper.encryption;
14+
15+
import java.nio.ByteBuffer;
16+
import java.util.Set;
17+
18+
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;
19+
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
20+
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
21+
22+
/**
23+
* Test domain class with byteBuffer attribute, byteBuffer set and a string key
24+
*/
25+
@DynamoDBTable(tableName = "aws-java-sdk-util-crypto")
26+
public class BinaryAttributeByteBufferTestClass {
27+
28+
private String key;
29+
private ByteBuffer binaryAttribute;
30+
private Set<ByteBuffer> binarySetAttribute;
31+
32+
@DynamoDBHashKey(attributeName = "key")
33+
public String getKey() {
34+
return key;
35+
}
36+
37+
public void setKey(String key) {
38+
this.key = key;
39+
}
40+
41+
@DynamoDBAttribute(attributeName = "binaryAttribute")
42+
public ByteBuffer getBinaryAttribute() {
43+
return binaryAttribute;
44+
}
45+
46+
public void setBinaryAttribute(ByteBuffer binaryAttribute) {
47+
this.binaryAttribute = binaryAttribute;
48+
}
49+
50+
@DynamoDBAttribute(attributeName = "binarySetAttribute")
51+
public Set<ByteBuffer> getBinarySetAttribute() {
52+
return binarySetAttribute;
53+
}
54+
55+
public void setBinarySetAttribute(Set<ByteBuffer> binarySetAttribute) {
56+
this.binarySetAttribute = binarySetAttribute;
57+
}
58+
59+
@Override
60+
public int hashCode() {
61+
final int prime = 31;
62+
int result = 1;
63+
result = prime * result + ((key == null) ? 0 : key.hashCode());
64+
result = prime * result + ((binaryAttribute == null) ? 0 : binaryAttribute.hashCode());
65+
result = prime * result + ((binarySetAttribute == null) ? 0 : binarySetAttribute.hashCode());
66+
return result;
67+
}
68+
69+
@Override
70+
public boolean equals(Object obj) {
71+
if ( this == obj )
72+
return true;
73+
if ( obj == null )
74+
return false;
75+
if ( getClass() != obj.getClass() )
76+
return false;
77+
BinaryAttributeByteBufferTestClass other = (BinaryAttributeByteBufferTestClass) obj;
78+
if ( key == null ) {
79+
if ( other.key != null )
80+
return false;
81+
} else if ( !key.equals(other.key) )
82+
return false;
83+
if ( binaryAttribute == null ) {
84+
if ( other.binaryAttribute != null )
85+
return false;
86+
} else if ( !binaryAttribute.equals(other.binaryAttribute) )
87+
return false;
88+
if ( binarySetAttribute == null ) {
89+
if ( other.binarySetAttribute != null )
90+
return false;
91+
} else if ( !binarySetAttribute.equals(other.binarySetAttribute) )
92+
return false;
93+
return true;
94+
}
95+
96+
}

0 commit comments

Comments
 (0)