Skip to content

Commit 7eb606a

Browse files
committed
---
yaml --- r: 7273 b: refs/heads/tswast-patch-1 c: 17c6eba h: refs/heads/master i: 7271: d9d1745
1 parent 00d6f29 commit 7eb606a

3 files changed

Lines changed: 20 additions & 44 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: dd0b186dbbaa92a81486a478dbda1528695eb394
60+
refs/heads/tswast-patch-1: 17c6eba167e3f5d9867ae3e452f044208fb138b1
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/gcloud-java-compute/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@
3434
</exclusion>
3535
</exclusions>
3636
</dependency>
37+
<dependency>
38+
<groupId>${project.groupId}</groupId>
39+
<artifactId>gcloud-java-core</artifactId>
40+
<version>${project.version}</version>
41+
<type>test-jar</type>
42+
<scope>test</scope>
43+
</dependency>
3744
<dependency>
3845
<groupId>junit</groupId>
3946
<artifactId>junit</artifactId>

branches/tswast-patch-1/gcloud-java-compute/src/test/java/com/google/cloud/compute/SerializationTest.java

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616

1717
package com.google.cloud.compute;
1818

19-
import static org.junit.Assert.assertEquals;
20-
import static org.junit.Assert.assertNotSame;
21-
2219
import com.google.cloud.AuthCredentials;
20+
import com.google.cloud.BaseSerializationTest;
21+
import com.google.cloud.Restorable;
2322
import com.google.cloud.RetryParams;
2423
import com.google.cloud.compute.AttachedDisk.CreateDiskConfiguration;
2524
import com.google.cloud.compute.AttachedDisk.PersistentDiskConfiguration;
@@ -28,17 +27,10 @@
2827
import com.google.common.collect.ImmutableList;
2928
import com.google.common.collect.ImmutableMap;
3029

31-
import org.junit.Test;
32-
33-
import java.io.ByteArrayInputStream;
34-
import java.io.ByteArrayOutputStream;
35-
import java.io.IOException;
36-
import java.io.ObjectInputStream;
37-
import java.io.ObjectOutputStream;
3830
import java.io.Serializable;
3931
import java.util.List;
4032

41-
public class SerializationTest {
33+
public class SerializationTest extends BaseSerializationTest {
4234

4335
private static final Compute COMPUTE = ComputeOptions.builder().projectId("p").build().service();
4436
private static final Long CREATION_TIMESTAMP = 1453293540000L;
@@ -269,27 +261,18 @@ public class SerializationTest {
269261
private static final Compute.InstanceAggregatedListOption INSTANCE_AGGREGATED_LIST_OPTION =
270262
Compute.InstanceAggregatedListOption.filter(INSTANCE_FILTER);
271263

272-
@Test
273-
public void testServiceOptions() throws Exception {
264+
@Override
265+
protected Serializable[] serializableObjects() {
274266
ComputeOptions options = ComputeOptions.builder()
275267
.projectId("p1")
276268
.authCredentials(AuthCredentials.createForAppEngine())
277269
.build();
278-
ComputeOptions serializedCopy = serializeAndDeserialize(options);
279-
assertEquals(options, serializedCopy);
280-
281-
options = options.toBuilder()
270+
ComputeOptions otherOptions = options.toBuilder()
282271
.projectId("p2")
283272
.retryParams(RetryParams.defaultInstance())
284273
.authCredentials(null)
285274
.build();
286-
serializedCopy = serializeAndDeserialize(options);
287-
assertEquals(options, serializedCopy);
288-
}
289-
290-
@Test
291-
public void testModelAndRequests() throws Exception {
292-
Serializable[] objects = {DISK_TYPE_ID, DISK_TYPE, MACHINE_TYPE_ID, MACHINE_TYPE, REGION_ID,
275+
return new Serializable[]{DISK_TYPE_ID, DISK_TYPE, MACHINE_TYPE_ID, MACHINE_TYPE, REGION_ID,
293276
REGION, ZONE_ID, ZONE, LICENSE_ID, LICENSE, DEPRECATION_STATUS, GLOBAL_OPERATION_ID,
294277
REGION_OPERATION_ID, ZONE_OPERATION_ID, GLOBAL_OPERATION, REGION_OPERATION, ZONE_OPERATION,
295278
INSTANCE_ID, REGION_FORWARDING_RULE_ID, GLOBAL_FORWARDING_RULE_ID, GLOBAL_ADDRESS_ID,
@@ -311,26 +294,12 @@ public void testModelAndRequests() throws Exception {
311294
IMAGE_LIST_OPTION, DISK_OPTION, DISK_FILTER, DISK_LIST_OPTION, DISK_AGGREGATED_LIST_OPTION,
312295
SUBNETWORK_OPTION, SUBNETWORK_FILTER, SUBNETWORK_LIST_OPTION,
313296
SUBNETWORK_AGGREGATED_LIST_OPTION, NETWORK_OPTION, NETWORK_FILTER, NETWORK_LIST_OPTION,
314-
INSTANCE_OPTION, INSTANCE_FILTER, INSTANCE_LIST_OPTION, INSTANCE_AGGREGATED_LIST_OPTION};
315-
for (Serializable obj : objects) {
316-
Object copy = serializeAndDeserialize(obj);
317-
assertEquals(obj, obj);
318-
assertEquals(obj, copy);
319-
assertNotSame(obj, copy);
320-
assertEquals(copy, copy);
321-
}
297+
INSTANCE_OPTION, INSTANCE_FILTER, INSTANCE_LIST_OPTION, INSTANCE_AGGREGATED_LIST_OPTION,
298+
options, otherOptions};
322299
}
323300

324-
@SuppressWarnings("unchecked")
325-
private <T> T serializeAndDeserialize(T obj)
326-
throws IOException, ClassNotFoundException {
327-
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
328-
try (ObjectOutputStream output = new ObjectOutputStream(bytes)) {
329-
output.writeObject(obj);
330-
}
331-
try (ObjectInputStream input =
332-
new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()))) {
333-
return (T) input.readObject();
334-
}
301+
@Override
302+
protected Restorable<?>[] restorableObjects() {
303+
return null;
335304
}
336305
}

0 commit comments

Comments
 (0)