|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | +package org.apache.felix.http.jetty.it; |
| 18 | + |
| 19 | +import static org.junit.Assert.assertEquals; |
| 20 | +import static org.junit.Assert.assertNotNull; |
| 21 | +import static org.junit.Assert.assertTrue; |
| 22 | +import static org.ops4j.pax.exam.CoreOptions.bundle; |
| 23 | +import static org.ops4j.pax.exam.CoreOptions.mavenBundle; |
| 24 | + |
| 25 | +import java.io.File; |
| 26 | +import java.io.IOException; |
| 27 | +import java.util.Optional; |
| 28 | +import java.util.stream.Stream; |
| 29 | + |
| 30 | +import javax.inject.Inject; |
| 31 | + |
| 32 | +import org.junit.Test; |
| 33 | +import org.junit.runner.RunWith; |
| 34 | +import org.ops4j.pax.exam.Option; |
| 35 | +import org.ops4j.pax.exam.junit.PaxExam; |
| 36 | +import org.ops4j.pax.exam.options.UrlProvisionOption; |
| 37 | +import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; |
| 38 | +import org.ops4j.pax.exam.spi.reactors.PerClass; |
| 39 | +import org.osgi.framework.Bundle; |
| 40 | +import org.osgi.framework.BundleContext; |
| 41 | + |
| 42 | +/** |
| 43 | + * |
| 44 | + */ |
| 45 | +@RunWith(PaxExam.class) |
| 46 | +@ExamReactorStrategy(PerClass.class) |
| 47 | +public class LightClassifierIT extends AbstractJettyTestSupport { |
| 48 | + |
| 49 | + @Inject |
| 50 | + protected BundleContext bundleContext; |
| 51 | + |
| 52 | + @Override |
| 53 | + protected Option[] additionalOptions() throws IOException { |
| 54 | + String jettyVersion = System.getProperty("jetty.version", "12.0.8"); |
| 55 | + return new Option[] { |
| 56 | + spifly(), |
| 57 | + |
| 58 | + // Minimum additional jetty dependency bundles |
| 59 | + mavenBundle().groupId("org.slf4j").artifactId("slf4j-api").version("2.0.13"), |
| 60 | + mavenBundle().groupId("org.slf4j").artifactId("slf4j-simple").version("2.0.13"), |
| 61 | + mavenBundle().groupId("commons-io").artifactId("commons-io").version("2.16.1"), |
| 62 | + mavenBundle().groupId("commons-fileupload").artifactId("commons-fileupload").version("1.5"), |
| 63 | + mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-alpn-java-server").version(jettyVersion), |
| 64 | + mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-alpn-server").version(jettyVersion), |
| 65 | + mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-http").version(jettyVersion), |
| 66 | + mavenBundle().groupId("org.eclipse.jetty.http2").artifactId("jetty-http2-common").version(jettyVersion), |
| 67 | + mavenBundle().groupId("org.eclipse.jetty.http2").artifactId("jetty-http2-hpack").version(jettyVersion), |
| 68 | + mavenBundle().groupId("org.eclipse.jetty.http2").artifactId("jetty-http2-server").version(jettyVersion), |
| 69 | + mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-io").version(jettyVersion), |
| 70 | + mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-jmx").version(jettyVersion), |
| 71 | + mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-security").version(jettyVersion), |
| 72 | + mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-server").version(jettyVersion), |
| 73 | + mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-session").version(jettyVersion), |
| 74 | + mavenBundle().groupId("org.eclipse.jetty.ee10").artifactId("jetty-ee10-servlet").version(jettyVersion), |
| 75 | + mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-util").version(jettyVersion), |
| 76 | + |
| 77 | + // additional dependencies to verify FELIX-6700 |
| 78 | + mavenBundle().groupId("org.owasp.encoder").artifactId("encoder").version("1.2.3"), |
| 79 | + mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.inventory").version("2.0.0"), |
| 80 | + mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.webconsole").version("5.0.2") |
| 81 | + }; |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * Override to use the "light" classifier variant of the test bundle |
| 86 | + */ |
| 87 | + @Override |
| 88 | + protected UrlProvisionOption testBundle(String systemProperty) { |
| 89 | + String pathname = System.getProperty(systemProperty); |
| 90 | + pathname = pathname.replace(".jar", "-light.jar"); |
| 91 | + final File file = new File(pathname); |
| 92 | + return bundle(file.toURI().toString()); |
| 93 | + } |
| 94 | + |
| 95 | + /** |
| 96 | + * Verify FELIX-6700 by checking that the webconsole bundle was resolved and active |
| 97 | + */ |
| 98 | + @Test |
| 99 | + public void testWebConsoleBundleIsActive() throws Exception { |
| 100 | + assertNotNull(bundleContext); |
| 101 | + Optional<Bundle> first = Stream.of(bundleContext.getBundles()) |
| 102 | + .filter(b -> "org.apache.felix.webconsole".equals(b.getSymbolicName())) |
| 103 | + .findFirst(); |
| 104 | + assertTrue(first.isPresent()); |
| 105 | + assertEquals(Bundle.ACTIVE, first.get().getState()); |
| 106 | + } |
| 107 | + |
| 108 | +} |
0 commit comments