Skip to content

Commit 31801f5

Browse files
committed
---
yaml --- r: 2909 b: refs/heads/dns-alpha c: 5c3fc94 h: refs/heads/master i: 2907: 2e1c355
1 parent 72b6f03 commit 31801f5

3 files changed

Lines changed: 26 additions & 33 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ refs/tags/v0.0.10: 207ebd2a3472fddee69fe1298eb90429e3306efd
1111
refs/tags/v0.0.11: ffbfba48a6426ff63c08ff2117e58681f251fbf2
1212
refs/tags/v0.0.12: 2fd8066e891fb3dfea69b65f6bf6461db79342b9
1313
refs/heads/compute-alpha: b1274b5bdf4eea955f3588b56378a5ae4ba59cef
14-
refs/heads/dns-alpha: 9ac6a82059026c95c2c0307816d2448b17514a4d
14+
refs/heads/dns-alpha: 5c3fc94f60391db0c32b6d8055101c0abb9bd0e9

branches/dns-alpha/gcloud-java-dns/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
</exclusion>
4141
</exclusions>
4242
</dependency>
43+
<dependency>
44+
<groupId>${project.groupId}</groupId>
45+
<artifactId>gcloud-java-core</artifactId>
46+
<version>${project.version}</version>
47+
<type>test-jar</type>
48+
<scope>test</scope>
49+
</dependency>
4350
<dependency>
4451
<groupId>junit</groupId>
4552
<artifactId>junit</artifactId>

branches/dns-alpha/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,17 @@
1616

1717
package com.google.gcloud.dns;
1818

19-
import static org.junit.Assert.assertEquals;
20-
import static org.junit.Assert.assertNotSame;
21-
2219
import com.google.common.collect.ImmutableList;
20+
import com.google.gcloud.AuthCredentials;
21+
import com.google.gcloud.BaseSerializationTest;
22+
import com.google.gcloud.Restorable;
2323
import com.google.gcloud.RetryParams;
2424

25-
import org.junit.Test;
26-
27-
import java.io.ByteArrayInputStream;
28-
import java.io.ByteArrayOutputStream;
29-
import java.io.IOException;
30-
import java.io.ObjectInputStream;
31-
import java.io.ObjectOutputStream;
3225
import java.io.Serializable;
3326
import java.math.BigInteger;
3427
import java.util.concurrent.TimeUnit;
3528

36-
public class SerializationTest {
29+
public class SerializationTest extends BaseSerializationTest {
3730

3831
private static final ZoneInfo FULL_ZONE_INFO = Zone.of("some zone name", "www.example.com",
3932
"some descriptions").toBuilder()
@@ -86,31 +79,24 @@ public class SerializationTest {
8679
.startTimeMillis(132L)
8780
.build();
8881

89-
@Test
90-
public void testModelAndRequests() throws Exception {
91-
Serializable[] objects = {FULL_ZONE_INFO, PARTIAL_ZONE_INFO, ZONE_LIST_OPTION,
82+
@Override
83+
protected Serializable[] serializableObjects() {
84+
DnsOptions options = DnsOptions.builder()
85+
.authCredentials(AuthCredentials.createForAppEngine())
86+
.projectId("id1")
87+
.build();
88+
DnsOptions otherOptions = options.toBuilder()
89+
.authCredentials(null)
90+
.build();
91+
return new Serializable[]{FULL_ZONE_INFO, PARTIAL_ZONE_INFO, ZONE_LIST_OPTION,
9292
DNS_REOCRD_LIST_OPTION, CHANGE_REQUEST_LIST_OPTION, ZONE_OPTION, CHANGE_REQUEST_OPTION,
9393
PROJECT_OPTION, PARTIAL_PROJECT_INFO, FULL_PROJECT_INFO, OPTIONS, FULL_ZONE, PARTIAL_ZONE,
9494
OPTIONS, CHANGE_REQUEST_PARTIAL, DNS_RECORD_PARTIAL, DNS_RECORD_COMPLETE,
95-
CHANGE_REQUEST_COMPLETE};
96-
for (Serializable obj : objects) {
97-
Object copy = serializeAndDeserialize(obj);
98-
assertEquals(obj, obj);
99-
assertEquals(obj, copy);
100-
assertNotSame(obj, copy);
101-
assertEquals(copy, copy);
102-
}
95+
CHANGE_REQUEST_COMPLETE, options, otherOptions};
10396
}
10497

105-
@SuppressWarnings("unchecked")
106-
private <T> T serializeAndDeserialize(T obj) throws IOException, ClassNotFoundException {
107-
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
108-
try (ObjectOutputStream output = new ObjectOutputStream(bytes)) {
109-
output.writeObject(obj);
110-
}
111-
try (ObjectInputStream input =
112-
new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()))) {
113-
return (T) input.readObject();
114-
}
98+
@Override
99+
protected Restorable<?>[] restorableObjects() {
100+
return new Restorable<?>[0];
115101
}
116102
}

0 commit comments

Comments
 (0)