Move timeout marshaller tests to ChannelImplTest

Now that ChannelImplTest exists, it makes more sense for them to be
there, since the implementation is in ChannelImpl.
This commit is contained in:
Eric Anderson 2015-06-18 17:18:45 -07:00
parent 45da9c5766
commit a479c9116a
2 changed files with 23 additions and 22 deletions

View File

@ -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);

View File

@ -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)));