From fef33690b9c5b85c608f5466aeede64a8c18b9b7 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Tue, 30 Aug 2016 10:25:50 -0500 Subject: Bug 492890 - Must escape values in a Bundle-NativeCode header when they have special filter characters Change-Id: Ia10e30ac0090f92297196d1ace0ba19c5b454ee5 Signed-off-by: Thomas Watson --- bundles/org.eclipse.osgi.tests/.classpath | 1 + bundles/org.eclipse.osgi.tests/build.properties | 6 +++- .../bundles_src/nativetest.f/META-INF/MANIFEST.MF | 8 +++++ .../nativetest.f/libs/test1/nativecode.txt | 1 + .../tests/bundles/PlatformAdminBundleTests.java | 34 +++++++++++++++++++++- .../osgi/tests/container/TestModuleContainer.java | 2 +- 6 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 bundles/org.eclipse.osgi.tests/bundles_src/nativetest.f/META-INF/MANIFEST.MF create mode 100644 bundles/org.eclipse.osgi.tests/bundles_src/nativetest.f/libs/test1/nativecode.txt (limited to 'bundles/org.eclipse.osgi.tests') diff --git a/bundles/org.eclipse.osgi.tests/.classpath b/bundles/org.eclipse.osgi.tests/.classpath index 41bd4f9ad..47d870ee3 100644 --- a/bundles/org.eclipse.osgi.tests/.classpath +++ b/bundles/org.eclipse.osgi.tests/.classpath @@ -42,6 +42,7 @@ + diff --git a/bundles/org.eclipse.osgi.tests/build.properties b/bundles/org.eclipse.osgi.tests/build.properties index 8676259ad..219cffe7a 100644 --- a/bundles/org.eclipse.osgi.tests/build.properties +++ b/bundles/org.eclipse.osgi.tests/build.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2011 IBM Corporation and others. +# Copyright (c) 2000, 2016 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at @@ -95,6 +95,8 @@ source.bundle_tests/nativetest.d.jar = bundles_src/nativetest.d/ manifest.bundle_tests/nativetest.d.jar = META-INF/MANIFEST.MF source.bundle_tests/nativetest.e.jar = bundles_src/nativetest.e/ manifest.bundle_tests/nativetest.e.jar = META-INF/MANIFEST.MF +source.bundle_tests/nativetest.f.jar = bundles_src/nativetest.f/ +manifest.bundle_tests/nativetest.f.jar = META-INF/MANIFEST.MF source.bundle_tests/host.multiple.exports.jar = bundles_src/host.multiple.exports/ manifest.bundle_tests/host.multiple.exports.jar = META-INF/MANIFEST.MF source.bundle_tests/frag.multiple.exports.jar = bundles_src/frag.multiple.exports/ @@ -315,6 +317,8 @@ jars.compile.order = bundle_tests/ext.framework.b.jar,\ bundle_tests/nativetest.b2.jar,\ bundle_tests/nativetest.c.jar,\ bundle_tests/nativetest.d.jar,\ + bundle_tests/nativetest.e.jar,\ + bundle_tests/nativetest.f.jar,\ bundle_tests/host.multiple.exports.jar,\ bundle_tests/frag.multiple.exports.jar,\ bundle_tests/client1.multiple.exports.jar,\ diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/nativetest.f/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/nativetest.f/META-INF/MANIFEST.MF new file mode 100644 index 000000000..16a108930 --- /dev/null +++ b/bundles/org.eclipse.osgi.tests/bundles_src/nativetest.f/META-INF/MANIFEST.MF @@ -0,0 +1,8 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: NativeBundle Plug-in +Bundle-SymbolicName: nativetest.f +Bundle-Version: 1.0.0 +Bundle-Localization: plugin +Bundle-NativeCode: + libs/test1/nativecode.txt; osname="Windows NT (unknown)", * diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/nativetest.f/libs/test1/nativecode.txt b/bundles/org.eclipse.osgi.tests/bundles_src/nativetest.f/libs/test1/nativecode.txt new file mode 100644 index 000000000..8c4e7bb10 --- /dev/null +++ b/bundles/org.eclipse.osgi.tests/bundles_src/nativetest.f/libs/test1/nativecode.txt @@ -0,0 +1 @@ +libs.test1 diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PlatformAdminBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PlatformAdminBundleTests.java index c4860a2ca..c7f4dde32 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PlatformAdminBundleTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PlatformAdminBundleTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2014 IBM Corporation and others. + * Copyright (c) 2007, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,6 +11,9 @@ package org.eclipse.osgi.tests.bundles; import java.util.Arrays; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.osgi.service.resolver.*; @@ -131,4 +134,33 @@ public class PlatformAdminBundleTests extends AbstractBundleTests { r3Installer.shutdown(); } } + + public void testNativeCodeFilterWithSpecialChars() throws BundleException, InterruptedException { + final AtomicReference error = new AtomicReference(); + final CountDownLatch errorCnt = new CountDownLatch(1); + FrameworkListener errorListener = new FrameworkListener() { + + @Override + public void frameworkEvent(FrameworkEvent event) { + if (event.getType() == FrameworkEvent.ERROR) { + error.set(event); + errorCnt.countDown(); + } + } + }; + getContext().addFrameworkListener(errorListener); + try { + PlatformAdmin pa = installer.getPlatformAdmin(); + State systemState = pa.getState(false); + // just making sure the system state is fully created first + assertNotNull(systemState.getBundle(0)); + Bundle nativeTestF = installer.installBundle("nativetest.f"); + nativeTestF.start(); + // expecting no errors + errorCnt.await(5, TimeUnit.SECONDS); + assertNull("Found an error: " + error.get(), error.get()); + } finally { + getContext().removeFrameworkListener(errorListener); + } + } } 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 1fb980cd1..fe24f2384 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 @@ -2101,7 +2101,7 @@ public class TestModuleContainer extends AbstractTest { } @Test - public void testNativeWithFitlerChars() throws BundleException, IOException { + public void testNativeWithFilterChars() throws BundleException, IOException { DummyContainerAdaptor adaptor = createDummyAdaptor(); ModuleContainer container = adaptor.getContainer(); -- cgit v1.2.3