diff --git a/build/birt-packages/birt-runtime-test/src/test/java/org/eclipse/birt/sdk/BaseTestTemplate.java b/build/birt-packages/birt-runtime-test/src/test/java/org/eclipse/birt/sdk/BaseTestTemplate.java
index 0a77ad2da25..e856d40e3ec 100644
--- a/build/birt-packages/birt-runtime-test/src/test/java/org/eclipse/birt/sdk/BaseTestTemplate.java
+++ b/build/birt-packages/birt-runtime-test/src/test/java/org/eclipse/birt/sdk/BaseTestTemplate.java
@@ -13,6 +13,9 @@
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.net.URL;
@@ -23,8 +26,13 @@
import java.util.LinkedHashSet;
import java.util.Set;
+import javax.xml.parsers.DocumentBuilderFactory;
+
import org.junit.Assert;
import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
/**
*
@@ -79,6 +87,43 @@ public void testChart() throws Exception {
new String(Files.readAllBytes(Paths.get(output)), StandardCharsets.UTF_8).contains("image/svg+xml"));
}
+ @Test
+ public void testAxisEncoding() throws Exception {
+ Class> encoderFactoryClass = getClass("org.apache.axis",
+ "org.apache.axis.components.encoding.XMLEncoderFactory");
+ Method getEncoderMethod = encoderFactoryClass.getMethod("getEncoder", String.class);
+ Object encoder = getEncoderMethod.invoke(null, "UTF-8");
+
+ String originalValue = "\ud800\udc00\uD83D\uDC7D";
+ int codePointCount = originalValue.codePointCount(0, originalValue.length());
+ Assert.assertEquals("The string represents two code points", 2, codePointCount);
+
+ StringWriter writer = new StringWriter();
+ getEncoderMethod.getReturnType().getMethod("writeEncoded", Writer.class, String.class).invoke(encoder, writer,
+ originalValue);
+
+ // An incorrect encoding would produce this:
+ //
+ //
+ // The parser would fail as follows:
+ // Character reference "" is an invalid XML character.
+ //
+ String encodedValue = writer.toString();
+
+ Assert.assertEquals("The two unicode code points should be encoded as two entities", "𐀀👽",
+ encodedValue);
+
+ String xml = new String("\n");
+
+ Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder()
+ .parse(new InputSource(new StringReader(xml)));
+ Element element = document.getDocumentElement();
+ String decodedValue = element.getAttribute("value");
+
+ Assert.assertEquals("Parser XML with the entities should decode to the original value.", originalValue,
+ decodedValue);
+ }
+
protected File[] listJars(String folder) {
return new File(folder).listFiles(new FilenameFilter() {
@Override
@@ -108,7 +153,11 @@ protected ClassLoader createClassLoader(String... roots) throws IOException {
return new URLClassLoader(urls.toArray(new URL[urls.size()]));
}
- public abstract int run(String[] args) throws Exception;
+ protected abstract Class> getClass(String bundle, String className) throws Exception;
+
+ public int run(String[] args) throws Exception {
+ return run(getClass("org.eclipse.birt.report.engine", "org.eclipse.birt.report.engine.api.ReportRunner"), args);
+ }
protected int run(Class> mainClass, String[] args) throws Exception {
Constructor> constructor = mainClass.getConstructor(String[].class);
diff --git a/build/birt-packages/birt-runtime-test/src/test/java/org/eclipse/birt/sdk/RuntimeOSGiTest.java b/build/birt-packages/birt-runtime-test/src/test/java/org/eclipse/birt/sdk/RuntimeOSGiTest.java
index c75d4084d85..63f411cf44b 100644
--- a/build/birt-packages/birt-runtime-test/src/test/java/org/eclipse/birt/sdk/RuntimeOSGiTest.java
+++ b/build/birt-packages/birt-runtime-test/src/test/java/org/eclipse/birt/sdk/RuntimeOSGiTest.java
@@ -19,7 +19,9 @@
@SuppressWarnings("javadoc")
public class RuntimeOSGiTest extends BaseTestTemplate {
- public int run(String[] args) throws Exception {
+
+ @Override
+ protected Class> getClass(String bundle, String className) throws Exception {
System.setProperty("BIRT_HOME",
new File("./target/birt-runtime-osgi/ReportEngine/platform/").getAbsolutePath());
@@ -43,14 +45,14 @@ public int run(String[] args) throws Exception {
// Get the org.eclipse.birt.report.engine bundle from the launcher.
Method getBundleMethod = launcher.getClass().getDeclaredMethod("getBundle", String.class);
getBundleMethod.setAccessible(true);
- Object birtReportEngineBundle = getBundleMethod.invoke(launcher, "org.eclipse.birt.report.engine");
+ Object birtReportEngineBundle = getBundleMethod.invoke(launcher, bundle);
// Load the org.eclipse.birt.report.engine.api.ReportRunner class from the
// bundle to ensure we have loaded the instance class from the actual OSGi
// runtime..c
Method loadClassMethod = birtReportEngineBundle.getClass().getMethod("loadClass", String.class);
- Class> mainClass = (Class>) loadClassMethod.invoke(birtReportEngineBundle,
- "org.eclipse.birt.report.engine.api.ReportRunner");
- return run(mainClass, args);
+ Class> mainClass = (Class>) loadClassMethod.invoke(birtReportEngineBundle, className);
+ return mainClass;
}
+
}
diff --git a/build/birt-packages/birt-runtime-test/src/test/java/org/eclipse/birt/sdk/RuntimeTest.java b/build/birt-packages/birt-runtime-test/src/test/java/org/eclipse/birt/sdk/RuntimeTest.java
index 279ccdf6a8c..5cf999077b8 100644
--- a/build/birt-packages/birt-runtime-test/src/test/java/org/eclipse/birt/sdk/RuntimeTest.java
+++ b/build/birt-packages/birt-runtime-test/src/test/java/org/eclipse/birt/sdk/RuntimeTest.java
@@ -17,11 +17,10 @@
public class RuntimeTest extends BaseTestTemplate {
@Override
- public int run(String[] args) throws Exception {
+ protected Class> getClass(String bundle, String className) throws Exception {
System.clearProperty("BIRT_HOME");
ClassLoader loader = createClassLoader("./target/birt-runtime/ReportEngine/lib"); //$NON-NLS-1$
- Class> mainClass = loader.loadClass("org.eclipse.birt.report.engine.api.ReportRunner"); //$NON-NLS-1$
-
- return run(mainClass, args);
+ Class> mainClass = loader.loadClass(className); // $NON-NLS-1$
+ return mainClass;
}
}
diff --git a/features/org.eclipse.birt.engine.runtime/feature.xml b/features/org.eclipse.birt.engine.runtime/feature.xml
index 68cd75217dd..5665d6fce3f 100644
--- a/features/org.eclipse.birt.engine.runtime/feature.xml
+++ b/features/org.eclipse.birt.engine.runtime/feature.xml
@@ -38,10 +38,6 @@
-
-
-
-
@@ -263,9 +259,11 @@
version="0.0.0"/>
-
+
diff --git a/features/org.eclipse.birt.osgi.runtime/feature.xml b/features/org.eclipse.birt.osgi.runtime/feature.xml
index a37e09bcfa8..13d3695e57b 100644
--- a/features/org.eclipse.birt.osgi.runtime/feature.xml
+++ b/features/org.eclipse.birt.osgi.runtime/feature.xml
@@ -82,10 +82,6 @@
id="org.eclipse.birt.report.model"
version="0.0.0"/>
-
-
@@ -130,6 +126,10 @@
id="org.eclipse.birt.chart.device.extension"
version="0.0.0"/>
+
+
@@ -250,6 +250,10 @@
id="org.eclipse.birt.report.engine.emitter.pptx"
version="0.0.0"/>
+
+
diff --git a/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/utility/AxisEncodingTest.java b/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/utility/AxisEncodingTest.java
new file mode 100644
index 00000000000..4cfd161dbb8
--- /dev/null
+++ b/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/utility/AxisEncodingTest.java
@@ -0,0 +1,62 @@
+/*************************************************************************************
+ * Copyright (c) 2024 Eclipse contributors and others.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * https://www.eclipse.org/legal/epl-2.0/.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ ************************************************************************************/
+
+package org.eclipse.birt.report.viewer.utility;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axis.components.encoding.XMLEncoder;
+import org.apache.axis.components.encoding.XMLEncoderFactory;
+import org.eclipse.birt.report.viewer.util.BaseTestCase;
+import org.junit.Assert;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+
+@SuppressWarnings("javadoc")
+public class AxisEncodingTest extends BaseTestCase {
+
+ public void testEncoding() throws Exception {
+
+ XMLEncoder encoder = XMLEncoderFactory.getEncoder(XMLEncoderFactory.ENCODING_UTF_8);
+ // encoder = new org.apache.axis.components.encoding.DefaultXMLEncoder("UTF-8");
+
+ String originalValue = "\ud800\udc00\uD83D\uDC7D";
+ int codePointCount = originalValue.codePointCount(0, originalValue.length());
+ Assert.assertEquals("The string represents two code points", 2, codePointCount);
+
+ StringWriter writer = new StringWriter();
+ encoder.writeEncoded(writer, originalValue);
+
+ // An incorrect encoding would produce this:
+ //
+ //
+ // The parser would fail as follows:
+ // Character reference "" is an invalid XML character.
+ //
+ String encodedValue = writer.toString();
+ Assert.assertEquals("The two unicode code points should be encoded as two entities", "𐀀👽",
+ encodedValue);
+
+ String xml = new String("\n");
+
+ Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder()
+ .parse(new InputSource(new StringReader(xml)));
+ Element element = document.getDocumentElement();
+ String decodedValue = element.getAttribute("value");
+
+ Assert.assertEquals("Parser XML with the entities should decode to the original value.", originalValue,
+ decodedValue);
+ }
+}