ICU-12588 completed six TODO tasks flagged during JUnit migration.

X-SVN-Rev: 40160
This commit is contained in:
Norbert Runge 2017-06-08 18:45:18 +00:00
parent e05c15a02c
commit d1103a457b
8 changed files with 29 additions and 458 deletions

View File

@ -2146,54 +2146,6 @@ public class TestCharset extends TestFmwk {
}
}
// TODO(junit): orphan method
public void convertAllTest(ByteBuffer bSource, CharBuffer uSource) throws Exception {
String encoding = "UTF-16";
CharsetDecoder decoder = null;
CharsetEncoder encoder = null;
try {
CharsetProviderICU provider = new CharsetProviderICU();
Charset charset = provider.charsetForName(encoding);
decoder = charset.newDecoder();
encoder = charset.newEncoder();
} catch(MissingResourceException ex) {
warnln("Could not load charset data: " + encoding);
return;
}
{
try {
decoder.reset();
ByteBuffer mySource = bSource.duplicate();
CharBuffer myTarget = decoder.decode(mySource);
if (!equals(myTarget, uSource)) {
errln(
"--Test convertAll() "
+ encoding
+ " to Unicode --FAILED");
}
} catch (Exception e) {
//e.printStackTrace();
errln(e.getMessage());
}
}
{
try {
encoder.reset();
CharBuffer mySource = CharBuffer.wrap(uSource);
ByteBuffer myTarget = encoder.encode(mySource);
if (!equals(myTarget, bSource)) {
errln(
"--Test convertAll() "
+ encoding
+ " to Unicode --FAILED");
}
} catch (Exception e) {
//e.printStackTrace();
errln("encoder.encode() failed "+ e.getMessage()+" "+e.toString());
}
}
}
//TODO
/*

View File

@ -1155,15 +1155,13 @@ public class DateTimeGeneratorTest extends TestFmwk {
/* Tests the constructor
* public VariableField(String string)
*/
//TODO(junit) why is this "unused"
@SuppressWarnings("unused")
@Test
public void TestVariableField_String(){
String[] cases = {"d","mm","aa"};
String[] invalid = {null,"","dummy"};
for(int i=0; i<cases.length; i++){
try{
VariableField vf = new VariableField(cases[i]);
new VariableField(cases[i]);
} catch(Exception e){
errln("VariableField constructor was not suppose to return " +
"an exception when created when passing " + cases[i]);
@ -1171,7 +1169,7 @@ public class DateTimeGeneratorTest extends TestFmwk {
}
for(int i=0; i<invalid.length; i++){
try{
VariableField vf = new VariableField(invalid[i]);
new VariableField(invalid[i]);
errln("VariableField constructor was suppose to return " +
"an exception when created when passing " + invalid[i]);
} catch(Exception e){}

View File

@ -866,7 +866,6 @@ public class CurrencyTest extends TestFmwk {
Currency currency = Currency.getInstance(ULocale.JAPAN);
// It appears as though this always returns 0 irrespective of the currency or usage.
double roundingIncrement = currency.getRoundingIncrement(Currency.CurrencyUsage.CASH);
// TODO: replace the JUnit import with TestFmwk assertEquals.
assertEquals("Rounding increment not zero", 0.0, roundingIncrement, 0.0);
}

View File

@ -114,13 +114,11 @@ public class ICUServiceThreadTest extends TestFmwk
//private final String name;
protected ICUService service;
private final long delay;
protected final TestLog log;
public TestThread(String name, ICUService service, long delay, TestLog log) {
public TestThread(String name, ICUService service, long delay) {
//this.name = name + " ";
this.service = service;
this.delay = delay;
this.log = new DelegatingLog(log);
this.setDaemon(true);
}
@ -188,14 +186,13 @@ public class ICUServiceThreadTest extends TestFmwk
}
static class RegisterFactoryThread extends TestThread {
RegisterFactoryThread(String name, ICUService service, long delay, TestLog log) {
super("REG " + name, service, delay, log);
RegisterFactoryThread(String name, ICUService service, long delay) {
super("REG " + name, service, delay);
}
protected void iterate() {
Factory f = new TestFactory(getCLV());
service.registerFactory(f);
//log.logln(f.toString());
TestFmwk.logln(f.toString());
}
}
@ -204,8 +201,8 @@ public class ICUServiceThreadTest extends TestFmwk
private Random r;
List factories;
UnregisterFactoryThread(String name, ICUService service, long delay, TestLog log) {
super("UNREG " + name, service, delay, log);
UnregisterFactoryThread(String name, ICUService service, long delay) {
super("UNREG " + name, service, delay);
r = new Random();
factories = service.factories();
@ -219,7 +216,6 @@ public class ICUServiceThreadTest extends TestFmwk
int n = r.nextInt(s);
Factory f = (Factory)factories.remove(n);
boolean success = service.unregisterFactory(f);
//log.logln("factory: " + f + (success ? " succeeded." : " *** failed."));
TestFmwk.logln("factory: " + f + (success ? " succeeded." : " *** failed."));
}
}
@ -229,8 +225,8 @@ public class ICUServiceThreadTest extends TestFmwk
Factory[] factories;
int n;
UnregisterFactoryListThread(String name, ICUService service, long delay, Factory[] factories, TestLog log) {
super("UNREG " + name, service, delay, log);
UnregisterFactoryListThread(String name, ICUService service, long delay, Factory[] factories) {
super("UNREG " + name, service, delay);
this.factories = factories;
}
@ -239,7 +235,6 @@ public class ICUServiceThreadTest extends TestFmwk
if (n < factories.length) {
Factory f = factories[n++];
boolean success = service.unregisterFactory(f);
//log.logln("factory: " + f + (success ? " succeeded." : " *** failed."));
TestFmwk.logln("factory: " + f + (success ? " succeeded." : " *** failed."));
}
}
@ -247,8 +242,8 @@ public class ICUServiceThreadTest extends TestFmwk
static class GetVisibleThread extends TestThread {
GetVisibleThread(String name, ICUService service, long delay, TestLog log) {
super("VIS " + name, service, delay, log);
GetVisibleThread(String name, ICUService service, long delay) {
super("VIS " + name, service, delay);
}
protected void iterate() {
@ -258,7 +253,6 @@ public class ICUServiceThreadTest extends TestFmwk
while (--n >= 0 && iter.hasNext()) {
String id = (String)iter.next();
Object result = service.get(id);
//log.logln("iter: " + n + " id: " + id + " result: " + result);
TestFmwk.logln("iter: " + n + " id: " + id + " result: " + result);
}
}
@ -267,8 +261,8 @@ public class ICUServiceThreadTest extends TestFmwk
static class GetDisplayThread extends TestThread {
ULocale locale;
GetDisplayThread(String name, ICUService service, long delay, ULocale locale, TestLog log) {
super("DIS " + name, service, delay, log);
GetDisplayThread(String name, ICUService service, long delay, ULocale locale) {
super("DIS " + name, service, delay);
this.locale = locale;
}
@ -287,12 +281,7 @@ public class ICUServiceThreadTest extends TestFmwk
// below on IBM JRE5 for AIX 64bit. For some reason, converting
// int to String out of this statement resolves the issue.
//log.logln(" iter: " + n +
String num = Integer.toString(n);
// log.logln(" iter: " + num +
// " dname: " + dname +
// " id: " + id +
// " result: " + result);
TestFmwk.logln(" iter: " + num +
" dname: " + dname +
" id: " + id +
@ -304,8 +293,8 @@ public class ICUServiceThreadTest extends TestFmwk
static class GetThread extends TestThread {
private String[] actualID;
GetThread(String name, ICUService service, long delay, TestLog log) {
super("GET " + name, service, delay, log);
GetThread(String name, ICUService service, long delay) {
super("GET " + name, service, delay);
actualID = new String[1];
}
@ -314,7 +303,6 @@ public class ICUServiceThreadTest extends TestFmwk
String id = getCLV();
Object o = service.get(id, actualID);
if (o != null) {
//log.logln(" id: " + id + " actual: " + actualID[0] + " result: " + o);
TestFmwk.logln(" id: " + id + " actual: " + actualID[0] + " result: " + o);
}
}
@ -324,8 +312,8 @@ public class ICUServiceThreadTest extends TestFmwk
private final String[] list;
private int n;
GetListThread(String name, ICUService service, long delay, String[] list, TestLog log) {
super("GETL " + name, service, delay, log);
GetListThread(String name, ICUService service, long delay, String[] list) {
super("GETL " + name, service, delay);
this.list = list;
}
@ -336,7 +324,6 @@ public class ICUServiceThreadTest extends TestFmwk
}
String id = list[n];
Object o = service.get(id);
//log.logln(" id: " + id + " result: " + o);
TestFmwk.logln(" id: " + id + " result: " + o);
}
}
@ -376,7 +363,7 @@ public class ICUServiceThreadTest extends TestFmwk
@Test
public void Test00_ConcurrentGet() {
for(int i = 0; i < 10; ++i) {
new GetThread("[" + Integer.toString(i) + "]", stableService(), 0, this).start();
new GetThread("[" + Integer.toString(i) + "]", stableService(), 0).start();
}
runThreads();
if (PRINTSTATS) System.out.println(stableService.stats());
@ -386,7 +373,7 @@ public class ICUServiceThreadTest extends TestFmwk
@Test
public void Test01_ConcurrentGetVisible() {
for(int i = 0; i < 10; ++i) {
new GetVisibleThread("[" + Integer.toString(i) + "]", stableService(), 0, this).start();
new GetVisibleThread("[" + Integer.toString(i) + "]", stableService(), 0).start();
}
runThreads();
if (PRINTSTATS) System.out.println(stableService.stats());
@ -403,8 +390,7 @@ public class ICUServiceThreadTest extends TestFmwk
new GetDisplayThread("[" + locale + "]",
stableService(),
0,
new ULocale(locale),
this).start();
new ULocale(locale)).start();
}
runThreads();
if (PRINTSTATS) System.out.println(stableService.stats());
@ -416,10 +402,10 @@ public class ICUServiceThreadTest extends TestFmwk
ICUService service = new ICULocaleService();
if (PRINTSTATS) service.stats(); // Enable the stats collection
for (int i = 0; i < 5; ++i) {
new RegisterFactoryThread("[" + i + "]", service, 0, this).start();
new RegisterFactoryThread("[" + i + "]", service, 0).start();
}
for (int i = 0; i < 5; ++i) {
new UnregisterFactoryThread("[" + i + "]", service, 0, this).start();
new UnregisterFactoryThread("[" + i + "]", service, 0).start();
}
runThreads();
if (PRINTSTATS) System.out.println(service.stats());
@ -441,8 +427,8 @@ public class ICUServiceThreadTest extends TestFmwk
};
Arrays.sort(factories, comp);
new GetThread("", service, 0, this).start();
new UnregisterFactoryListThread("", service, 3, factories, this).start();
new GetThread("", service, 0).start();
new UnregisterFactoryListThread("", service, 3, factories).start();
runThreads(2000);
if (PRINTSTATS) System.out.println(service.stats());
@ -459,13 +445,13 @@ public class ICUServiceThreadTest extends TestFmwk
ICUService service = new ICULocaleService();
if (PRINTSTATS) service.stats(); // Enable the stats collection
new RegisterFactoryThread("", service, 500, this).start();
new RegisterFactoryThread("", service, 500).start();
for(int i = 0; i < 15; ++i) {
new GetThread("[" + Integer.toString(i) + "]", service, 0, this).start();
new GetThread("[" + Integer.toString(i) + "]", service, 0).start();
}
new GetVisibleThread("", service, 50, this).start();
new GetVisibleThread("", service, 50).start();
String[] localeNames = {
"en", "de"
@ -475,11 +461,10 @@ public class ICUServiceThreadTest extends TestFmwk
new GetDisplayThread("[" + locale + "]",
stableService(),
500,
new ULocale(locale),
this).start();
new ULocale(locale)).start();
}
new UnregisterFactoryThread("", service, 500, this).start();
new UnregisterFactoryThread("", service, 500).start();
// yoweee!!!
runThreads(9500);

View File

@ -15,7 +15,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.junit.Ignore;
import org.junit.Test;
import com.ibm.icu.dev.test.TestFmwk;
@ -201,8 +200,6 @@ public class TestLocaleValidity extends TestFmwk {
}
}
// TODO(junit): turned off for failure - need to investigate
@Ignore
@Test
public void testMissing() {
String[][] tests = {

View File

@ -112,26 +112,6 @@ public abstract class AbstractTestLog implements TestLog {
*/
//public abstract void msg(String message, int level, boolean incCount, boolean newln);
/**
* Not sure if this class is useful. This lets you log without first testing
* if logging is enabled. The Delegating log will either silently ignore the
* message, if the delegate is null, or forward it to the delegate.
*/
public static final class DelegatingLog extends AbstractTestLog {
private TestLog delegate;
public DelegatingLog(TestLog delegate) {
this.delegate = delegate;
}
public void msg(String message, int level, boolean incCount, boolean newln) {
if (delegate != null) {
// TODO(junit): figure out what to do with this message call
TestFmwk.msg(message, level, incCount, newln);
//delegate.msg(message, level, incCount, newln);
}
}
}
public boolean isDateAtLeast(int year, int month, int day){
Date now = new Date();
Calendar c = new GregorianCalendar(year, month, day);

View File

@ -1,168 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html#License
/**
*******************************************************************************
* Copyright (C) 2001-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.dev.test.sample;
// TODO(junit) : turned off
public class ModuleTestSample /*extends ModuleTest*/ {
ModuleTestSample(){
//super("com/ibm/icu/dev/data/testdata/", "Test");
}
// standard loop, settings and cases
// public void Test01() {
// while (nextSettings()) {
// logln("--------");
// logln("String: " + settings.getString("aString"));
// if (settings.isDefined("anInt")) {
// logln("Int: " + settings.getInt("anInt"));
// }
// logln("Boolean: " + settings.getBoolean("aBoolean"));
//
// while (nextCase()) {
// logln(" ----");
// logln(" StringArray: " + printArray(testcase.getStringArray("aStringArray")));
// logln(" IntArray: " + printArray(testcase.getIntArray("anIntArray")));
// logln(" BooleanArray: " + printArray(testcase.getBooleanArray("aBooleanArray")));
// }
// }
// }
//
// // loop with just cases
// public void Test02() {
// while (nextCase()) {
// logln("----");
// logln("String: " + testcase.getString("aString"));
// logln("Int: " + testcase.getInt("anInt"));
// logln("Boolean: " + testcase.getBoolean("aBoolean"));
// }
// }
// no cases, just uses info for test
public void Test03() {
// DataMap info = testInfo();
// if (info != null) {
//// logln(info.getString(TestDataModule.DESCRIPTION)); // standard
// logln(info.getString("Extra")); // test-specific
// }
// return;
}
// no data, ModuleTest should not allow this to execute by default
public void Test04() {
// errln("Test04 should not execute!");
}
// special override of validateMethod allows Test05
// to execute even though it has no data in the module
// protected boolean validateMethod(String methodName) {
// return methodName.equals("Test05") ? true : super.validateMethod(methodName);
// }
// no data, but override of validateMethod allows it to execute
public void Test05() {
// logln("Test05 executed.");
}
// // The test data contains an error in the third case. When getInt("Data") is
// // executed the error is logged and iteration stops.
// public void Test06() {
// while (nextCase()) {
// logln("----");
// logln("isGood: " + testcase.getString("IsGood"));
// logln(" Data: " + testcase.getInt("Data"));
// }
// }
//
// // The test using the data reports an error, which also automatically stops iteration.
// public void Test07() {
// while (nextSettings()) {
// int value = settings.getInt("Value");
// while (nextCase()) {
// int factor = testcase.getInt("Factor");
// float result = (float)value / factor;
// if (result != (int)result) {
// errln("the number '" + factor + "' is not a factor of the number '" + value + "'");
// } else {
// logln("'" + factor + "' is a factor of '" + value + "'");
// }
// }
// }
// }
// // The number of data elements is incorrect
// public void Test08() {
// while (nextCase()) {
// int one = testcase.getInt("One");
// int two = testcase.getInt("Two");
// int three = testcase.getInt("Three");
// logln("got: " + one + ", " + two + ", " + three);
// }
// }
//
// public void Test09() {
// while (nextCase()) {
// int radix = testcase.getInt("Radix");
// int[] pow = testcase.getIntArray("Power");
// int[] val = testcase.getIntArray("Value");
// logln("radix: " + radix + " pow: " + printArray(pow) + " val: " + printArray(val));
// for (int i = 0; i < pow.length; ++i) {
// if (val[i] != (int)Math.pow(radix, pow[i])) {
// errln("radix: " + radix + " to power " + pow[i] + " != " + val[i]);
// break;
// }
// }
// }
// }
// utility print functions to display the data from the resource
String printArray(String[] a) {
StringBuffer buf = new StringBuffer("String[] {");
for (int i = 0; i < a.length; ++i) {
if (i != 0) {
buf.append(",");
}
buf.append(" " + a[i]);
}
buf.append(" }");
return buf.toString();
}
String printArray(int[] a) {
StringBuffer buf = new StringBuffer("int[] {");
for (int i = 0; i < a.length; ++i) {
if (i != 0) {
buf.append(",");
}
buf.append(" " + a[i]);
}
buf.append(" }");
return buf.toString();
}
String printArray(boolean[] a) {
StringBuffer buf = new StringBuffer("boolean[] {");
for (int i = 0; i < a.length; ++i) {
if (i != 0) {
buf.append(",");
}
buf.append(" " + a[i]);
}
buf.append(" }");
return buf.toString();
}
/* (non-Javadoc)
* @see com.ibm.icu.dev.test.ModuleTest#processModules()
*/
protected void processModules() {
// TODO Auto-generated method stub
}
}

View File

@ -1,172 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html#License
/**
*******************************************************************************
* Copyright (C) 2001-2004, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.dev.test.sample;
import java.util.ListResourceBundle;
/**
* This is sample data for ModuleTestSample, which is an illustration
* of a subclass of ModuleTest. This data is in a format which
* is understood by ResourceModule, which for simplicity expects
* all data, including numeric and boolean data, to be represented
* by Strings.
*/
public class ModuleTestSampleData extends ListResourceBundle {
public Object[][] getContents() {
return contents;
}
Object[][] contents = {
{ "Info", new Object[][] {
{ "Description", "This is a sample test module that illustrates ModuleTest " +
"and uses data formatted for ResourceModule." },
{ "Headers", new String[] {
"aStringArray", "anIntArray", "aBooleanArray"
}},
}},
{ "TestData", new Object[][] {
{ "Test01", new Object[][] {
{ "Info", new Object[][] {
{ "Description", "A typical test using both settings and cases." },
{ "Long_Description", "It does not defined its own headers, but instead " +
"uses the default headers defined for the module. " +
"There are two sets of settings and three cases." },
}},
{ "Settings", new Object[] {
new Object[][]
{{ "aString", "this is a string" },
{ "anInt", "43" },
{ "aBoolean", "false" }},
new Object[][]
{{ "aString", "this is another string" },
{ "aBoolean", "true" }}
}},
{ "Cases", new Object[] {
new Object[] {
new String[] { "one", "two", "three" },
new String[] { "24", "48", "72" },
new String[] { "true", "false", "true" }
},
new Object[] {
new String[] { "four", "five", "six" },
new String[] { "-1", "-5", "-10" },
new String[] { "true", "false", "false" }
},
new Object[] {
new String[] { "bagel", "peanuts", "carrot" },
new String[] { "0", "00001", "10101" },
new String[] { "false", "false", "False" }
},
}}
}},
{ "Test02", new Object[][] {
{ "Info", new Object[][] {
{ "Description", "A typical test that uses cases but not settings." },
{ "Long_Description", "It defines its own headers." },
{ "Headers", new String[] {
"aString", "anInt", "aBoolean"
}},
}},
{ "Cases", new Object[] {
new Object[] { "Superstring", "42", "true" },
new Object[] { "Underdog", "12", "false" },
new Object[] { "ScoobyDoo", "7", "TrUe" }
}}
}},
{ "Test03", new Object[][] {
{ "Info", new Object[][] {
{ "Description", "A typical test that uses just the info, no cases or settings." },
{ "Extra", "This is some extra information." }
}},
}},
// no Test04 data
// Test04 should cause an exception to be thrown since ModuleTestSample does not
// specify that it is ok for it to have no data.
// no Test05 data
// Test05 should just log this fact, since ModuleTestSample indicates that it is
// ok for Test05 to have no data in its override of validateMethod.
{ "Test06", new Object[][] {
{ "Info", new Object[][] {
{ "Description", "A test that has bad data." },
{ "Long_Description", "This illustrates how a data error will automatically " +
"terminate the settings and cases loop." },
{ "Headers", new String[] {
"IsGood", "Data",
}},
}},
{ "Cases", new Object[] {
new Object[] { "Good", "23" },
new Object[] { "Good", "-123" },
new Object[] { "Bad", "Whoops" },
new Object[] { "Not Executed", "35" },
}},
}},
{ "Test07", new Object[][] {
{ "Info", new Object[][] {
{ "Description", "A test that fails with a certain combination of settings and case." },
{ "Long_Description", "This illustrates how a test error will automatically " +
"terminate the settings and cases loop. Settings data is values, the case " +
"data is factors. The third factor is not a factor of the second value. " +
"The test will log an error, which will automatically stop the loop." },
{ "Headers", new String[] {
"Factor",
}},
}},
{ "Settings" , new Object[] {
new Object[][] {{ "Value", "210" }},
new Object[][] {{ "Value", "420" }},
new Object[][] {{ "Value", "42" }},
new Object[][] {{ "Value", "Not reached." }}
}},
{ "Cases", new Object[] {
new Object[] { "2" },
new Object[] { "3" },
new Object[] { "5" },
new Object[] { "7" },
}},
}},
{ "Test08", new Object[][] {
{ "Info", new Object[][] {
{ "Description", "A test with data missing from a test case." },
{ "Headers", new String[] {
"One", "Two", "Three"
}},
}},
{ "Cases", new Object[] {
new Object[] { "1", "2", "3" },
new Object[] { "4", "5" }, // too short
new Object[] { "6", "7", "8" },
}},
}},
{ "Test09", new Object[][] {
{ "Info", new Object[][] {
{ "Description", "A test with data stored as int arrays instead of strings" },
{ "Headers", new String[] {
"Radix", "Power", "Value"
}},
}},
{ "Cases", new Object[] {
new Object[] { "2", new int[] { 1, 2, 3 }, new int[] { 2, 4, 8 }},
new Object[] { "3", new int[] { 3, 4, 5 }, new int[] { 27, 81, 243 }},
new Object[] { "2", new int[] { 0, 8, 16, 24 }, new int[] { 1, 256, 65536, 65536 * 256 }},
}},
}},
}},
};
}