-
Notifications
You must be signed in to change notification settings - Fork 389
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test org.eclipse.birt.axis.utility.UTF8Encoder is used and is correct
- Include org.eclipse.birt.axis.overlay in the org.eclipse.birt.engine.runtime feature. - Test both runtimes that they use the overlay correctly. - Reconcile the difference between the features org.eclipse.birt.osgi.runtime and org.eclipse.birt.engine.runtime. - Remove org.eclipse.birt.resources because it only provides cheatsheet content for in the IDE. - Add org.eclipse.birt.chart.device.pdf and org.eclipse.birt.report.engine.emitter.prototype.excel.
- Loading branch information
Showing
6 changed files
with
134 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...irt.report.viewer.tests/test/org/eclipse/birt/report/viewer/utility/AxisEncodingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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("<?xml version='1.0' encoding='UTF-8'?>\n<document value='" + encodedValue + "'/>"); | ||
|
||
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); | ||
} | ||
} |