Completed test migration to junit4, easymock updated to version 3.2

Change-Id: I6381045b3dae7133cc3589c5dd20ed977118a83d
This commit is contained in:
alex.ryazantsev
2013-11-07 22:29:27 +04:00
committed by Shawn Pearce
parent c8cffc8e92
commit d215908bae
46 changed files with 486 additions and 123 deletions

View File

@@ -14,11 +14,15 @@
package com.google.gerrit.server.util;
import junit.framework.TestCase;
import org.junit.Test;
import java.util.HashSet;
public class IdGeneratorTest extends TestCase {
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class IdGeneratorTest {
@Test
public void test1234() {
final HashSet<Integer> seen = new HashSet<Integer>();
for (int i = 0; i < 1 << 16; i++) {
@@ -32,6 +36,7 @@ public class IdGeneratorTest extends TestCase {
assertEquals(0x0b966b11, IdGenerator.unmix(IdGenerator.mix(0x0b966b11)));
}
@Test
public void testFormat() {
assertEquals("0000000f", IdGenerator.format(0xf));
assertEquals("801234ab", IdGenerator.format(0x801234ab));

View File

@@ -20,8 +20,12 @@ import static com.google.gerrit.server.util.SocketUtil.parse;
import static com.google.gerrit.server.util.SocketUtil.resolve;
import static java.net.InetAddress.getByName;
import static java.net.InetSocketAddress.createUnresolved;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import junit.framework.TestCase;
import org.junit.Test;
import java.net.Inet4Address;
import java.net.Inet6Address;
@@ -29,7 +33,8 @@ import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
public class SocketUtilTest extends TestCase {
public class SocketUtilTest {
@Test
public void testIsIPv6() throws UnknownHostException {
final InetAddress ipv6 = getByName("1:2:3:4:5:6:7:8");
assertTrue(ipv6 instanceof Inet6Address);
@@ -40,12 +45,14 @@ public class SocketUtilTest extends TestCase {
assertFalse(isIPv6(ipv4));
}
@Test
public void testHostname() {
assertEquals("*", hostname(new InetSocketAddress(80)));
assertEquals("localhost", hostname(new InetSocketAddress("localhost", 80)));
assertEquals("foo", hostname(createUnresolved("foo", 80)));
}
@Test
public void testFormat() throws UnknownHostException {
assertEquals("*:1234", SocketUtil.format(new InetSocketAddress(1234), 80));
assertEquals("*", SocketUtil.format(new InetSocketAddress(80), 80));
@@ -64,6 +71,7 @@ public class SocketUtilTest extends TestCase {
SocketUtil. format(new InetSocketAddress("localhost", 80), 80));
}
@Test
public void testParse() {
assertEquals(new InetSocketAddress(1234), parse("*:1234", 80));
assertEquals(new InetSocketAddress(80), parse("*", 80));
@@ -100,6 +108,7 @@ public class SocketUtilTest extends TestCase {
}
}
@Test
public void testResolve() throws UnknownHostException {
assertEquals(new InetSocketAddress(1234), resolve("*:1234", 80));
assertEquals(new InetSocketAddress(80), resolve("*", 80));