diff --git a/core/src/test/java/io/grpc/ChannelImplTest.java b/core/src/test/java/io/grpc/ChannelImplTest.java index 17503c5681..352cc9be29 100644 --- a/core/src/test/java/io/grpc/ChannelImplTest.java +++ b/core/src/test/java/io/grpc/ChannelImplTest.java @@ -31,6 +31,7 @@ package io.grpc; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; @@ -87,6 +88,28 @@ public class ChannelImplTest { executor.shutdownNow(); } + @Test + public void timeoutTest() { + ChannelImpl.TimeoutMarshaller marshaller = + new ChannelImpl.TimeoutMarshaller(); + assertEquals("1000u", marshaller.toAsciiString(1000L)); + assertEquals(1000L, (long) marshaller.parseAsciiString("1000u")); + + assertEquals("100000m", marshaller.toAsciiString(100000000L)); + assertEquals(100000000L, (long) marshaller.parseAsciiString("100000m")); + + assertEquals("100000S", marshaller.toAsciiString(100000000000L)); + assertEquals(100000000000L, (long) marshaller.parseAsciiString("100000S")); + + // 1,666,667 * 60 has 9 digits + assertEquals("1666666M", marshaller.toAsciiString(100000000000000L)); + assertEquals(60000000000000L, (long) marshaller.parseAsciiString("1000000M")); + + // 1,666,667 * 60 has 9 digits + assertEquals("1666666H", marshaller.toAsciiString(6000000000000000L)); + assertEquals(3600000000000000L, (long) marshaller.parseAsciiString("1000000H")); + } + @Test public void shutdownWithNoTransportsEverCreated() { verifyNoMoreInteractions(mockTransportFactory); diff --git a/core/src/test/java/io/grpc/MetadataTest.java b/core/src/test/java/io/grpc/MetadataTest.java index 82c301c06d..347de50b8f 100644 --- a/core/src/test/java/io/grpc/MetadataTest.java +++ b/core/src/test/java/io/grpc/MetadataTest.java @@ -145,28 +145,6 @@ public class MetadataTest { roundTripInteger(0x87654321); } - @Test - public void timeoutTest() { - ChannelImpl.TimeoutMarshaller marshaller = - new ChannelImpl.TimeoutMarshaller(); - assertEquals("1000u", marshaller.toAsciiString(1000L)); - assertEquals(1000L, (long) marshaller.parseAsciiString("1000u")); - - assertEquals("100000m", marshaller.toAsciiString(100000000L)); - assertEquals(100000000L, (long) marshaller.parseAsciiString("100000m")); - - assertEquals("100000S", marshaller.toAsciiString(100000000000L)); - assertEquals(100000000000L, (long) marshaller.parseAsciiString("100000S")); - - // 1,666,667 * 60 has 9 digits - assertEquals("1666666M", marshaller.toAsciiString(100000000000000L)); - assertEquals(60000000000000L, (long) marshaller.parseAsciiString("1000000M")); - - // 1,666,667 * 60 has 9 digits - assertEquals("1666666H", marshaller.toAsciiString(6000000000000000L)); - assertEquals(3600000000000000L, (long) marshaller.parseAsciiString("1000000H")); - } - private void roundTripInteger(Integer i) { assertEquals(i, Metadata.INTEGER_MARSHALLER.parseAsciiString( Metadata.INTEGER_MARSHALLER.toAsciiString(i)));