Skip to content

Commit 1a35b69

Browse files
committed
Try to figure out travis error
1 parent 96cb886 commit 1a35b69

File tree

1 file changed

+38
-19
lines changed

1 file changed

+38
-19
lines changed

gcloud-java-core/src/test/java/com/google/cloud/GrpcServiceOptionsTest.java

+38-19
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@
3131
@RunWith(JUnit4.class)
3232
public class GrpcServiceOptionsTest {
3333

34-
private static final TestGrpcServiceOptions OPTIONS = TestGrpcServiceOptions.builder()
35-
.initialTimeout(1234)
36-
.timeoutMultiplier(1.6)
37-
.maxTimeout(5678)
38-
.build();
39-
private static final TestGrpcServiceOptions DEFAULT_OPTIONS =
40-
TestGrpcServiceOptions.builder().build();
41-
private static final TestGrpcServiceOptions OPTIONS_COPY = OPTIONS.toBuilder().build();
42-
4334
private interface TestService extends Service<TestGrpcServiceOptions> {}
4435

4536
private static class TestServiceImpl
@@ -137,12 +128,20 @@ public int hashCode() {
137128

138129
@Test
139130
public void testBuilder() {
140-
assertEquals(1234, OPTIONS.initialTimeout());
141-
assertEquals(1.6, OPTIONS.timeoutMultiplier(), 0.0);
142-
assertEquals(5678, OPTIONS.maxTimeout());
143-
assertEquals(20000, DEFAULT_OPTIONS.initialTimeout());
144-
assertEquals(1.5, DEFAULT_OPTIONS.timeoutMultiplier(), 0.0);
145-
assertEquals(100000, DEFAULT_OPTIONS.maxTimeout());
131+
TestGrpcServiceOptions options = TestGrpcServiceOptions.builder()
132+
.initialTimeout(1234)
133+
.timeoutMultiplier(1.6)
134+
.maxTimeout(5678)
135+
.build();
136+
TestGrpcServiceOptions defaultOptions =
137+
TestGrpcServiceOptions.builder().build();
138+
TestGrpcServiceOptions optionsCopy = options.toBuilder().build();
139+
assertEquals(1234, options.initialTimeout());
140+
assertEquals(1.6, options.timeoutMultiplier(), 0.0);
141+
assertEquals(5678, options.maxTimeout());
142+
assertEquals(20000, defaultOptions.initialTimeout());
143+
assertEquals(1.5, defaultOptions.timeoutMultiplier(), 0.0);
144+
assertEquals(100000, defaultOptions.maxTimeout());
146145
}
147146

148147
@Test
@@ -181,13 +180,33 @@ public void testBuilderInvalidMaxTimeout() {
181180

182181
@Test
183182
public void testBaseEquals() {
184-
assertEquals(OPTIONS, OPTIONS_COPY);
185-
assertNotEquals(DEFAULT_OPTIONS, OPTIONS);
183+
try {
184+
TestGrpcServiceOptions options = TestGrpcServiceOptions.builder()
185+
.initialTimeout(1234)
186+
.timeoutMultiplier(1.6)
187+
.maxTimeout(5678)
188+
.build();
189+
TestGrpcServiceOptions defaultOptions =
190+
TestGrpcServiceOptions.builder().build();
191+
TestGrpcServiceOptions optionsCopy = options.toBuilder().build();
192+
assertEquals(options, optionsCopy);
193+
assertNotEquals(defaultOptions, options);
194+
} catch (Exception ex) {
195+
ex.printStackTrace();
196+
}
186197
}
187198

188199
@Test
189200
public void testBaseHashCode() {
190-
assertEquals(OPTIONS.hashCode(), OPTIONS_COPY.hashCode());
191-
assertNotEquals(DEFAULT_OPTIONS.hashCode(), OPTIONS.hashCode());
201+
TestGrpcServiceOptions options = TestGrpcServiceOptions.builder()
202+
.initialTimeout(1234)
203+
.timeoutMultiplier(1.6)
204+
.maxTimeout(5678)
205+
.build();
206+
TestGrpcServiceOptions defaultOptions =
207+
TestGrpcServiceOptions.builder().build();
208+
TestGrpcServiceOptions optionsCopy = options.toBuilder().build();
209+
assertEquals(options.hashCode(), optionsCopy.hashCode());
210+
assertNotEquals(defaultOptions.hashCode(), options.hashCode());
192211
}
193212
}

0 commit comments

Comments
 (0)