diff --git a/tools/java/common/test/com/google/i18n/phonenumbers/MetadataFilterCoverageTest.java b/tools/java/common/test/com/google/i18n/phonenumbers/MetadataFilterCoverageTest.java index deb6e84de..01a14e5bf 100644 --- a/tools/java/common/test/com/google/i18n/phonenumbers/MetadataFilterCoverageTest.java +++ b/tools/java/common/test/com/google/i18n/phonenumbers/MetadataFilterCoverageTest.java @@ -16,24 +16,18 @@ package com.google.i18n.phonenumbers; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.Charset; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import junit.framework.TestCase; /** * Tests to ensure that the {@link MetadataFilter} logic over excludable fields cover all applicable * fields. */ -@RunWith(JUnit4.class) -public final class MetadataFilterCoverageTest { +public final class MetadataFilterCoverageTest extends TestCase { private static final String CODE; static { @@ -52,7 +46,6 @@ public final class MetadataFilterCoverageTest { } } - @Test public void testCoverageOfExcludableParentFields() { for (String field : MetadataFilter.excludableParentFields) { String capitalized = Character.toUpperCase(field.charAt(0)) + field.substring(1); @@ -66,7 +59,6 @@ public final class MetadataFilterCoverageTest { MetadataFilter.excludableParentFields.size()); } - @Test public void testCoverageOfExcludableChildFields() { for (String field : MetadataFilter.excludableChildFields) { String capitalized = Character.toUpperCase(field.charAt(0)) + field.substring(1); @@ -79,7 +71,6 @@ public final class MetadataFilterCoverageTest { MetadataFilter.excludableChildFields.size()); } - @Test public void testCoverageOfExcludableChildlessFields() { for (String field : MetadataFilter.excludableChildlessFields) { String capitalized = Character.toUpperCase(field.charAt(0)) + field.substring(1); diff --git a/tools/java/common/test/com/google/i18n/phonenumbers/MetadataFilterTest.java b/tools/java/common/test/com/google/i18n/phonenumbers/MetadataFilterTest.java index 4ffaef5fc..2d47fd696 100644 --- a/tools/java/common/test/com/google/i18n/phonenumbers/MetadataFilterTest.java +++ b/tools/java/common/test/com/google/i18n/phonenumbers/MetadataFilterTest.java @@ -16,26 +16,18 @@ package com.google.i18n.phonenumbers; -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 com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata; import com.google.i18n.phonenumbers.Phonemetadata.PhoneNumberDesc; import java.util.Arrays; import java.util.List; import java.util.TreeMap; import java.util.TreeSet; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import junit.framework.TestCase; /** * Unit tests for {@link MetadataFilter}. */ -@RunWith(JUnit4.class) -public class MetadataFilterTest { +public class MetadataFilterTest extends TestCase { private static final String ID = "AM"; private static final int COUNTRY_CODE = 374; private static final String INTERNATIONAL_PREFIX = "0[01]"; @@ -48,7 +40,6 @@ public class MetadataFilterTest { // If this behavior changes then consider whether the change in the blacklist is intended, or you // should change the special build configuration. Also look into any change in the size of the // build. - @Test public void testForLiteBuild() { TreeMap> blacklist = new TreeMap>(); blacklist.put("fixedLine", new TreeSet(Arrays.asList("exampleNumber"))); @@ -74,7 +65,6 @@ public class MetadataFilterTest { // If this behavior changes then consider whether the change in the blacklist is intended, or you // should change the special build configuration. Also look into any change in the size of the // build. - @Test public void testForSpecialBuild() { TreeMap> blacklist = new TreeMap>(); blacklist.put("fixedLine", new TreeSet(MetadataFilter.excludableChildFields)); @@ -104,13 +94,11 @@ public class MetadataFilterTest { assertEquals(MetadataFilter.forSpecialBuild(), new MetadataFilter(blacklist)); } - @Test public void testEmptyFilter() { assertEquals(MetadataFilter.emptyFilter(), new MetadataFilter(new TreeMap>())); } - @Test public void testParseFieldMapFromString_parentAsGroup() { TreeMap> fieldMap = new TreeMap>(); fieldMap.put("fixedLine", new TreeSet(Arrays.asList( @@ -119,7 +107,6 @@ public class MetadataFilterTest { assertEquals(MetadataFilter.parseFieldMapFromString("fixedLine"), fieldMap); } - @Test public void testParseFieldMapFromString_childAsGroup() { TreeMap> fieldMap = new TreeMap>(); fieldMap.put("fixedLine", new TreeSet(Arrays.asList("exampleNumber"))); @@ -141,7 +128,6 @@ public class MetadataFilterTest { assertEquals(MetadataFilter.parseFieldMapFromString("exampleNumber"), fieldMap); } - @Test public void testParseFieldMapFromString_childlessFieldAsGroup() { TreeMap> fieldMap = new TreeMap>(); fieldMap.put("nationalPrefix", new TreeSet()); @@ -149,7 +135,6 @@ public class MetadataFilterTest { assertEquals(MetadataFilter.parseFieldMapFromString("nationalPrefix"), fieldMap); } - @Test public void testParseFieldMapFromString_parentWithOneChildAsGroup() { TreeMap> fieldMap = new TreeMap>(); fieldMap.put("fixedLine", new TreeSet(Arrays.asList("exampleNumber"))); @@ -157,7 +142,6 @@ public class MetadataFilterTest { assertEquals(MetadataFilter.parseFieldMapFromString("fixedLine(exampleNumber)"), fieldMap); } - @Test public void testParseFieldMapFromString_parentWithTwoChildrenAsGroup() { TreeMap> fieldMap = new TreeMap>(); fieldMap.put("fixedLine", new TreeSet(Arrays.asList( @@ -168,7 +152,6 @@ public class MetadataFilterTest { fieldMap); } - @Test public void testParseFieldMapFromString_mixOfGroups() { TreeMap> fieldMap = new TreeMap>(); fieldMap.put("uan", new TreeSet(Arrays.asList( @@ -205,7 +188,6 @@ public class MetadataFilterTest { // sets of excludable fields, but their shortest representation changes as those sets change, as // do their semantics; therefore we allow currently longer expressions, and we allow explicit // listing of children, even if these are currently all the children. - @Test public void testParseFieldMapFromString_equivalentExpressions() { // Listing all excludable parent fields is equivalent to listing all excludable child fields. assertEquals( @@ -319,7 +301,6 @@ public class MetadataFilterTest { + ":noInternationalDialling")); } - @Test public void testParseFieldMapFromString_RuntimeExceptionCases() { // Null input. try { @@ -736,7 +717,6 @@ public class MetadataFilterTest { } } - @Test public void testComputeComplement_allAndNothing() { TreeMap> map1 = new TreeMap>(); map1.put("fixedLine", new TreeSet(MetadataFilter.excludableChildFields)); @@ -770,7 +750,6 @@ public class MetadataFilterTest { assertEquals(MetadataFilter.computeComplement(map2), map1); } - @Test public void testComputeComplement_inBetween() { TreeMap> map1 = new TreeMap>(); map1.put("fixedLine", new TreeSet(MetadataFilter.excludableChildFields)); @@ -810,7 +789,6 @@ public class MetadataFilterTest { assertEquals(MetadataFilter.computeComplement(map2), map1); } - @Test public void testShouldDrop() { TreeMap> blacklist = new TreeMap>(); blacklist.put("fixedLine", new TreeSet(MetadataFilter.excludableChildFields)); @@ -863,7 +841,6 @@ public class MetadataFilterTest { // Test that a fake PhoneMetadata filtered for liteBuild ends up clearing exactly the expected // fields. The lite build is used to clear example_number fields from all PhoneNumberDescs. - @Test public void testFilterMetadata_liteBuild() { PhoneMetadata.Builder metadata = getFakeArmeniaPhoneMetadata(); @@ -893,7 +870,6 @@ public class MetadataFilterTest { // Test that a fake PhoneMetadata filtered for specialBuild ends up clearing exactly the expected // fields. The special build is used to clear PhoneNumberDescs other than general_desc and mobile, // and non-PhoneNumberDesc PhoneMetadata fields that aren't needed for parsing. - @Test public void testFilterMetadata_specialBuild() { PhoneMetadata.Builder metadata = getFakeArmeniaPhoneMetadata(); @@ -930,7 +906,6 @@ public class MetadataFilterTest { } // Test that filtering a fake PhoneMetadata with the empty MetadataFilter results in no change. - @Test public void testFilterMetadata_emptyFilter() { PhoneMetadata.Builder metadata = getFakeArmeniaPhoneMetadata(); @@ -956,7 +931,6 @@ public class MetadataFilterTest { assertEquals(metadata.getTollFree().getExampleNumber(), EXAMPLE_NUMBER); } - @Test public void testIntegrityOfFieldSets() { TreeSet union = new TreeSet(); union.addAll(MetadataFilter.excludableParentFields);