2015-02-14 13:37:01 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2015 The Netty Project
|
|
|
|
*
|
|
|
|
* The Netty Project licenses this file to you under the Apache License,
|
|
|
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at:
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package io.netty.osgitests;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertFalse;
|
2017-11-27 15:20:17 +01:00
|
|
|
import static org.ops4j.pax.exam.CoreOptions.frameworkProperty;
|
2015-02-14 13:37:01 +01:00
|
|
|
import static org.ops4j.pax.exam.CoreOptions.junitBundles;
|
|
|
|
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
|
2019-03-18 09:27:43 +01:00
|
|
|
import static org.ops4j.pax.exam.CoreOptions.url;
|
2017-11-27 15:20:17 +01:00
|
|
|
import static org.osgi.framework.Constants.FRAMEWORK_BOOTDELEGATION;
|
2015-02-14 13:37:01 +01:00
|
|
|
|
|
|
|
import java.io.File;
|
2019-03-18 09:27:43 +01:00
|
|
|
import java.io.FilenameFilter;
|
2015-02-14 13:37:01 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
import org.ops4j.pax.exam.Configuration;
|
|
|
|
import org.ops4j.pax.exam.Option;
|
|
|
|
import org.ops4j.pax.exam.junit.PaxExam;
|
2017-11-27 15:20:17 +01:00
|
|
|
import io.netty.util.internal.PlatformDependent;
|
2015-02-14 13:37:01 +01:00
|
|
|
|
|
|
|
@RunWith(PaxExam.class)
|
|
|
|
public class OsgiBundleTest {
|
2019-03-18 09:27:43 +01:00
|
|
|
private static final Collection<String> LINKS;
|
2015-02-14 13:37:01 +01:00
|
|
|
|
|
|
|
static {
|
2019-03-18 09:27:43 +01:00
|
|
|
final Set<String> links = new HashSet<String>();
|
2015-02-14 13:37:01 +01:00
|
|
|
|
2019-03-18 09:27:43 +01:00
|
|
|
final File directory = new File("target/generated-test-resources/alta/");
|
|
|
|
File[] files = directory.listFiles(new FilenameFilter() {
|
|
|
|
@Override
|
|
|
|
public boolean accept(File dir, String name) {
|
|
|
|
return (name.startsWith("io.netty") || name.startsWith("com.barchart.udt")) && name.endsWith(".link");
|
2015-02-14 13:37:01 +01:00
|
|
|
}
|
2019-03-18 09:27:43 +01:00
|
|
|
});
|
|
|
|
if (files == null) {
|
|
|
|
throw new IllegalStateException(directory + " is not found or is not a directory");
|
2015-02-14 13:37:01 +01:00
|
|
|
}
|
2019-03-18 09:27:43 +01:00
|
|
|
for (File f: files) {
|
|
|
|
links.add(f.getName());
|
|
|
|
}
|
|
|
|
LINKS = links;
|
2015-02-14 13:37:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
public final Option[] config() {
|
2019-01-22 16:07:26 +01:00
|
|
|
final Collection<Option> options = new ArrayList<>();
|
2015-02-14 13:37:01 +01:00
|
|
|
|
2017-11-27 15:20:17 +01:00
|
|
|
// Avoid boot delegating sun.misc which would fail testCanLoadPlatformDependent()
|
|
|
|
options.add(frameworkProperty(FRAMEWORK_BOOTDELEGATION).value("com.sun.*"));
|
2015-02-14 13:37:01 +01:00
|
|
|
options.add(systemProperty("pax.exam.osgi.unresolved.fail").value("true"));
|
2019-03-18 09:27:43 +01:00
|
|
|
options.add(junitBundles());
|
2015-02-14 13:37:01 +01:00
|
|
|
|
2019-03-18 09:27:43 +01:00
|
|
|
for (String link : LINKS) {
|
|
|
|
options.add(url("link:classpath:" + link));
|
2015-02-14 13:37:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return options.toArray(new Option[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testResolvedBundles() {
|
|
|
|
// No-op, as we just want the bundles to be resolved. Just check if we tested something
|
2019-03-18 09:27:43 +01:00
|
|
|
assertFalse("At least one bundle needs to be tested", LINKS.isEmpty());
|
2015-02-14 13:37:01 +01:00
|
|
|
}
|
2017-11-27 15:20:17 +01:00
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testCanLoadPlatformDependent() {
|
2019-03-18 09:27:43 +01:00
|
|
|
assertFalse(PlatformDependent.addressSize() == 0);
|
2017-11-27 15:20:17 +01:00
|
|
|
}
|
2015-02-14 13:37:01 +01:00
|
|
|
}
|