Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2016-01-06 22:28:24 +0000
committerThomas Watson2016-01-07 15:55:45 +0000
commitaf0b69f307193a1140cb14056b1d6e3e2008fc65 (patch)
tree1cd877f7c994886e83765eaf6a792455f61a0254 /bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
parente1aa6950b8be7c9e76b2df623d09eb8e25d1ef97 (diff)
downloadrt.equinox.framework-af0b69f307193a1140cb14056b1d6e3e2008fc65.tar.gz
rt.equinox.framework-af0b69f307193a1140cb14056b1d6e3e2008fc65.tar.xz
rt.equinox.framework-af0b69f307193a1140cb14056b1d6e3e2008fc65.zip
Bug 485300 - Bundle manifest with double byte UTF chars are parsed
incorrectly with line continuations Change-Id: I5f3c9a13db35683aa98820f990e8614acbc8b2ca Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Diffstat (limited to 'bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java')
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
index a45d0825d..c13f2f9e6 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
@@ -10,9 +10,13 @@
*******************************************************************************/
package org.eclipse.osgi.tests.container;
+import static java.util.jar.Attributes.Name.MANIFEST_VERSION;
+
import java.io.*;
import java.util.*;
import java.util.concurrent.*;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
import org.eclipse.osgi.container.*;
import org.eclipse.osgi.container.Module.StartOptions;
import org.eclipse.osgi.container.Module.State;
@@ -26,6 +30,7 @@ import org.eclipse.osgi.report.resolution.ResolutionReport;
import org.eclipse.osgi.tests.container.dummys.*;
import org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase.DummyContainerEvent;
import org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase.DummyModuleEvent;
+import org.eclipse.osgi.util.ManifestElement;
import org.junit.Assert;
import org.junit.Test;
import org.osgi.framework.*;
@@ -2076,6 +2081,44 @@ public class TestModuleContainer extends AbstractTest {
}
@Test
+ public void testUTF8LineContinuation() throws BundleException, IOException {
+ DummyContainerAdaptor adaptor = createDummyAdaptor();
+ ModuleContainer container = adaptor.getContainer();
+ String utfString = "a.with.é.multibyte";
+ while (utfString.getBytes("UTF8").length < 500) {
+ Map<String, String> manifest = getUTFManifest(utfString);
+ Module testModule = installDummyModule(manifest, manifest.get(Constants.BUNDLE_SYMBOLICNAME), container);
+ Assert.assertEquals("Wrong bns for the bundle.", utfString, testModule.getCurrentRevision().getSymbolicName());
+
+ ModuleCapability exportPackage = testModule.getCurrentRevision().getModuleCapabilities(PackageNamespace.PACKAGE_NAMESPACE).get(0);
+ ModuleRequirement importPackage = testModule.getCurrentRevision().getModuleRequirements(PackageNamespace.PACKAGE_NAMESPACE).get(0);
+
+ String actualPackageName = (String) exportPackage.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE);
+ Assert.assertEquals("Wrong exported package name.", utfString, actualPackageName);
+
+ Assert.assertTrue("import does not match export: " + importPackage, importPackage.matches(exportPackage));
+
+ utfString = "a" + utfString;
+ }
+ }
+
+ private static Map<String, String> getUTFManifest(String packageName) throws IOException, BundleException {
+ // using manifest class to force a split line right in the middle of a double byte UTF-8 character
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ {
+ Manifest m = new Manifest();
+ Attributes a = m.getMainAttributes();
+ a.put(MANIFEST_VERSION, "1.0");
+ a.putValue(Constants.BUNDLE_MANIFESTVERSION, "2");
+ a.putValue(Constants.BUNDLE_SYMBOLICNAME, packageName);
+ a.putValue(Constants.EXPORT_PACKAGE, packageName);
+ a.putValue(Constants.IMPORT_PACKAGE, packageName);
+ m.write(out);
+ }
+ return ManifestElement.parseBundleManifest(new ByteArrayInputStream(out.toByteArray()), null);
+ }
+
+ @Test
public void testBug483849() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();

Back to the top