Skip to content

Commit

Permalink
Provide a test for netty#6548 using the OSGi test suite
Browse files Browse the repository at this point in the history
Motiviation:

The OSGi Test suite runs without access to sun.misc.Unsafe, and so is a good place to put a test to avoid regressing netty#6548.

Modification:

Added a test-case that failed before netty#7432.

Result:

Test for fix included.
  • Loading branch information
timothyjward authored and normanmaurer committed Nov 27, 2017
1 parent 65cacc9 commit 460d125
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@
package io.netty.osgitests;

import static org.junit.Assert.assertFalse;
import static org.ops4j.pax.exam.CoreOptions.frameworkProperty;
import static org.ops4j.pax.exam.CoreOptions.junitBundles;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
import static org.osgi.framework.Constants.FRAMEWORK_BOOTDELEGATION;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
Expand All @@ -38,6 +40,7 @@
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import io.netty.util.internal.PlatformDependent;

@RunWith(PaxExam.class)
public class OsgiBundleTest {
Expand Down Expand Up @@ -86,6 +89,8 @@ public class OsgiBundleTest {
public final Option[] config() {
final Collection<Option> options = new ArrayList<Option>();

// Avoid boot delegating sun.misc which would fail testCanLoadPlatformDependent()
options.add(frameworkProperty(FRAMEWORK_BOOTDELEGATION).value("com.sun.*"));
options.add(systemProperty("pax.exam.osgi.unresolved.fail").value("true"));
options.addAll(Arrays.asList(junitBundles()));

Expand All @@ -104,4 +109,9 @@ public void testResolvedBundles() {
// No-op, as we just want the bundles to be resolved. Just check if we tested something
assertFalse("At least one bundle needs to be tested", BUNDLES.isEmpty());
}

@Test
public void testCanLoadPlatformDependent() {
assertFalse(PlatformDependent.hasUnsafe());
}
}

0 comments on commit 460d125

Please sign in to comment.