Skip to content

Commit

Permalink
Remove long time not needed ICU4J references in tests
Browse files Browse the repository at this point in the history
These are not referenced at all thus simply deleted.
  • Loading branch information
akurtakov committed Oct 25, 2024
1 parent 3b49502 commit e232ae2
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import static org.junit.Assert.assertEquals;

import java.lang.reflect.Constructor;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.Format;
Expand Down Expand Up @@ -127,16 +126,6 @@ public void testConvertBigIntegerToString() throws Exception {
assertEquals(expected, result);
}

Class<?> icuBigDecimal = null;
Constructor<?> icuBigDecimalCtr = null;
{
try {
icuBigDecimal = Class.forName("com.ibm.icu.math.BigDecimal");
icuBigDecimalCtr = icuBigDecimal.getConstructor(BigInteger.class, int.class);
}
catch(ClassNotFoundException | NoSuchMethodException e) {}
}

@Test
public void testConvertBigDecimalToString() throws Exception {
NumberToStringConverter converter = NumberToStringConverter.fromBigDecimal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThrows;

import java.lang.reflect.Constructor;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.Format;
Expand Down Expand Up @@ -83,16 +82,6 @@ public void testConvertsToBigInteger() throws Exception {
assertEquals(input, result);
}

Class<?> icuBigDecimal = null;
Constructor<?> icuBigDecimalCtr = null;
{
try {
icuBigDecimal = Class.forName("com.ibm.icu.math.BigDecimal");
icuBigDecimalCtr = icuBigDecimal.getConstructor(BigInteger.class, int.class);
}
catch(ClassNotFoundException | NoSuchMethodException e) {}
}

@Test
public void testConvertsToBigDecimal() throws Exception {
StringToNumberConverter<BigDecimal> converter = StringToNumberConverter.toBigDecimal(numberFormat);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

package org.eclipse.core.tests.internal.databinding.conversion;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

Expand Down Expand Up @@ -152,49 +151,7 @@ public void testRanges() throws Exception {
assertFalse("invalid BigDecimal min", assertValid(bigDecimalMin));
assertFalse("invalid BigDecimal max", assertValid(bigDecimalMax));

/**
* The ICU4J plugin's NumberFormat will return it's own BigDecimal
* implementation, com.ibm.icu.math.BigDecimal. The issue this causes is
* that we can't reference this class as it's not part of the
* replacement plugin. So in order to ensure that we handle Number's
* that are not part of the JDK stub a number implemenation and ensure
* that the double representation of this number is used.
*/
class MyNumber extends Number {
double value;
int count;

MyNumber(double value) {
this.value = value;
}

private static final long serialVersionUID = 1L;

@Override
public double doubleValue() {
count++;
return value;
}

@Override
public float floatValue() {
return 0;
}

@Override
public int intValue() {
return 0;
}

@Override
public long longValue() {
return 0;
}
}

MyNumber number = new MyNumber(1);
assertEquals(0, number.count);
Number number = BigDecimal.valueOf((double) 1);
assertTrue(StringToNumberParser.inIntegerRange(number));
assertTrue("double value retrieved", number.count > 0);
}
}

0 comments on commit e232ae2

Please sign in to comment.