View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.commons.compress.osgi;
20  
21  import static org.ops4j.pax.exam.CoreOptions.bundle;
22  import static org.ops4j.pax.exam.CoreOptions.composite;
23  import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
24  import static org.ops4j.pax.exam.CoreOptions.systemProperty;
25  
26  import java.util.Arrays;
27  
28  import org.junit.jupiter.api.Assertions;
29  import org.ops4j.pax.exam.Option;
30  import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
31  
32  
33  final class Configurations {
34  
35      /**
36       * @return The maven bundle for Apache commons-codec
37       */
38      private static MavenArtifactProvisionOption getCommonsCodec() {
39          return mavenBundle().groupId("commons-codec").artifactId("commons-codec").version("1.16.0");
40      }
41  
42      public static Option[] getConfigWithoutCommonsCodec() {
43          final Option[] defaultConfig = getDefaultConfig();
44          final Option[] result = Arrays.stream(defaultConfig)
45                  .filter(o -> !getCommonsCodec().equals(o))
46                  .toArray(Option[]::new);
47          Assertions.assertTrue(result.length < defaultConfig.length, "Expected to have removed an option.");
48          return result;
49      }
50  
51      public static Option[] getDefaultConfig() {
52          return new Option[]{systemProperty("pax.exam.osgi.unresolved.fail").value("true"),
53                  systemProperty("org.ops4j.pax.url.mvn.useFallbackRepositories").value("false"),
54                  systemProperty("org.ops4j.pax.url.mvn.repositories").value("https://repo.maven.apache.org/maven2"),
55                  mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.scr").version("2.0.14"),
56                  mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.configadmin").version("1.8.16"),
57                  getCommonsCodec(),
58                  mavenBundle().groupId("commons-io").artifactId("commons-io").version("2.15.1"),
59                  composite(systemProperty("pax.exam.invoker").value("junit"), bundle("link:classpath:META-INF/links/org.ops4j.pax.tipi.junit.link"),
60                          bundle("link:classpath:META-INF/links/org.ops4j.pax.exam.invoker.junit.link"),
61                          mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.hamcrest").version("1.3_1")),
62                  bundle("reference:file:target/classes/").start()};
63      }
64  
65      private Configurations() {
66  
67      }
68  }