Skip to content

Commit 2d81b8a

Browse files
committed
---
yaml --- r: 4665 b: refs/heads/logging-alpha c: 5c3fc94 h: refs/heads/master i: 4663: 4aad9a6
1 parent 791ae53 commit 2d81b8a

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
@@ -12,7 +12,7 @@ refs/heads/compute-alpha: 969cba2627f1d53d352cc4a5ffe0879dacf65e6c
1212
refs/heads/dns-alpha: 2f90e7e338349287ace33375896907af0f032ca1
1313
refs/heads/dns-alpha-batch: 17442b07867021b85d0452f5f3eda29a3413288f
1414
refs/heads/gcs-nio: 283aeaf15efdcf3621eb6859f05e55ad7764375d
15-
refs/heads/logging-alpha: 9ac6a82059026c95c2c0307816d2448b17514a4d
15+
refs/heads/logging-alpha: 5c3fc94f60391db0c32b6d8055101c0abb9bd0e9
1616
refs/tags/v0.1.0: a615317f7424ed58621b1f65d5c4d8cbbe8a6ed8
1717
refs/tags/v0.1.1: 7a7f6985fe465e9dd6a075af55493f42b4933be0
1818
refs/tags/v0.1.2: 3eb3fe866ba22487686048f45d927b8c8638ea3f

branches/logging-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/logging-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)