Skip to content

Commit aaa5dd2

Browse files
committed
Replace com.ibm.icu dependency with org.eclipse.ant.core in expression
tests The ExpressionTestsPluginUnloading test was using com.ibm.icu bundle for testing plugin loading/unloading and classloader isolation. This change replaces it with org.eclipse.ant.core bundle to support removal of com.ibm.icu from the platform. Changes: - Replace fake com.ibm.icu.text.DecimalFormat with org.eclipse.ant.core.AntRunner - Update test to use org.eclipse.ant.core bundle instead of com.ibm.icu - Adjust instanceof checks to match new bundle's class interfaces - org.eclipse.ant.core is a suitable replacement as it can be safely stopped/restarted without affecting test execution
1 parent 66f6070 commit aaa5dd2

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

runtime/tests/org.eclipse.core.expressions.tests/src/com/ibm/icu/text/DecimalFormat.java renamed to runtime/tests/org.eclipse.core.expressions.tests/src/org/eclipse/ant/core/AntRunner.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2013, 2015 IBM Corporation and others.
2+
* Copyright (c) 2024 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,19 +11,25 @@
1111
* Contributors:
1212
* IBM Corporation - initial API and implementation
1313
*******************************************************************************/
14-
package com.ibm.icu.text;
14+
package org.eclipse.ant.core;
15+
16+
import java.io.Serializable;
1517

1618
/**
1719
* Used by the
1820
* {@link org.eclipse.core.internal.expressions.tests.ExpressionTestsPluginUnloading}
1921
* test.
2022
* <p>
21-
* <strong>Note:</strong> This class uses the 'com.ibm.icu.text' namespace for
22-
* test purposes only and does not copy or implement anything from ICU.
23+
* <strong>Note:</strong> This class uses the 'org.eclipse.ant.core' namespace
24+
* for test purposes only and does not copy or implement anything from the real
25+
* AntRunner class.
2326
* </p>
2427
*/
25-
public class DecimalFormat implements Runnable {
28+
public class AntRunner implements Runnable, Serializable {
29+
private static final long serialVersionUID = 1L;
30+
2631
@Override
2732
public void run() {
33+
// Empty implementation for testing
2834
}
2935
}

runtime/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/ExpressionTestsPluginUnloading.java

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@
3333
/**
3434
* Tests for cache used in {@link Expressions#isInstanceOf(Object, String)}.
3535
* <p>
36-
* <b>WARNING:</b> These tests start, stop, and re-start the <code>com.ibm.icu</code> bundle.
36+
* <b>WARNING:</b> These tests start, stop, and re-start the <code>org.eclipse.ant.core</code> bundle.
3737
* Don't include these in another test suite!
3838
*/
3939
@SuppressWarnings("restriction")
4040
@TestMethodOrder(MethodOrderer.MethodName.class)
4141
public class ExpressionTestsPluginUnloading {
4242

43+
private static final String ANT_CORE_BUNDLE_ID = "org.eclipse.ant.core";
44+
private static final String ANT_RUNNER_CLASS_NAME = "org.eclipse.ant.core.AntRunner";
45+
4346
private String name;
4447

4548
@BeforeEach
@@ -49,13 +52,13 @@ public void setupTestName(TestInfo testInfo) {
4952

5053
@Test
5154
public void test01PluginStopping() throws Exception {
52-
Bundle bundle= getBundle("com.ibm.icu");
55+
Bundle bundle= getBundle(ANT_CORE_BUNDLE_ID);
5356
bundle.start();
5457
int state = bundle.getState();
5558
assertThat(state).withFailMessage("Unexpected bundle state: " + stateToString(state) + " for bundle " + bundle)
5659
.isEqualTo(Bundle.ACTIVE);
5760

58-
doTestInstanceofICUDecimalFormat(bundle);
61+
doTestInstanceofAntRunner(bundle);
5962
assertThat(bundle.getState()).as("Instanceof with bundle-local class should load extra bundle")
6063
.isEqualTo(state);
6164

@@ -69,26 +72,26 @@ public void test01PluginStopping() throws Exception {
6972
.withFailMessage("Unexpected bundle state: " + stateToString(state) + " for bundle " + bundle)
7073
.isEqualTo(Bundle.ACTIVE);
7174

72-
doTestInstanceofICUDecimalFormat(bundle);
75+
doTestInstanceofAntRunner(bundle);
7376
}
7477

7578
@Test
7679
public void test02MultipleClassloaders() throws Exception {
7780
Bundle expr= getBundle("org.eclipse.core.expressions.tests");
78-
Bundle icu= getBundle("com.ibm.icu");
81+
Bundle ant= getBundle(ANT_CORE_BUNDLE_ID);
7982

80-
Class<?> exprClass = expr.loadClass("com.ibm.icu.text.DecimalFormat");
81-
Class<?> icuClass = icu.loadClass("com.ibm.icu.text.DecimalFormat");
82-
assertThat(exprClass).isNotSameAs(icuClass);
83+
Class<?> exprClass = expr.loadClass(ANT_RUNNER_CLASS_NAME);
84+
Class<?> antClass = ant.loadClass(ANT_RUNNER_CLASS_NAME);
85+
assertThat(exprClass).isNotSameAs(antClass);
8386

8487
Object exprObj = exprClass.getDeclaredConstructor().newInstance();
85-
Object icuObj = icuClass.getDeclaredConstructor().newInstance();
88+
Object antObj = antClass.getDeclaredConstructor().newInstance();
8689

8790
assertInstanceOf(exprObj, "java.lang.Runnable", "java.lang.String");
88-
assertInstanceOf(exprObj, "java.lang.Object", "java.io.Serializable");
91+
assertInstanceOf(exprObj, "java.io.Serializable", "org.eclipse.equinox.app.IApplication");
8992

90-
assertInstanceOf(icuObj, "java.io.Serializable", "java.lang.String");
91-
assertInstanceOf(icuObj, "java.text.Format", "java.lang.Runnable");
93+
assertInstanceOf(antObj, "org.eclipse.equinox.app.IApplication", "java.lang.Runnable");
94+
assertInstanceOf(antObj, "java.lang.Object", "java.io.Serializable");
9295
}
9396

9497
static String stateToString(int state) {
@@ -125,10 +128,10 @@ private void assertInstanceOf(Object obj, String isInstance, String isNotInstanc
125128
}
126129
}
127130

128-
private void doTestInstanceofICUDecimalFormat(Bundle bundle) throws Exception {
129-
Class<?> clazz = bundle.loadClass("com.ibm.icu.text.DecimalFormat");
130-
Object decimalFormat = clazz.getDeclaredConstructor().newInstance();
131-
assertInstanceOf(decimalFormat, "com.ibm.icu.text.DecimalFormat", "java.text.NumberFormat");
131+
private void doTestInstanceofAntRunner(Bundle bundle) throws Exception {
132+
Class<?> clazz = bundle.loadClass(ANT_RUNNER_CLASS_NAME);
133+
Object antRunner = clazz.getDeclaredConstructor().newInstance();
134+
assertInstanceOf(antRunner, ANT_RUNNER_CLASS_NAME, "java.lang.Runnable");
132135
}
133136

134137
private static Bundle getBundle(String bundleName) {

0 commit comments

Comments
 (0)