You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2020/01/09 11:39:32 UTC
[sling-org-apache-sling-crankstart-launcher] branch master updated:
Deprecate this repository
This is an automated email from the ASF dual-hosted git repository.
bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
The following commit(s) were added to refs/heads/master by this push:
new 2ffc012 Deprecate this repository
2ffc012 is described below
commit 2ffc01270e0e42661087c0f5c22260c87c2ac6b3
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Jan 9 12:39:17 2020 +0100
Deprecate this repository
---
.asf.yaml | 7 +
CODE_OF_CONDUCT.md | 22 --
CONTRIBUTING.md | 24 --
Jenkinsfile | 20 --
LICENSE | 202 ----------------
README.md | 10 +-
pom.xml | 227 ------------------
.../sling/crankstart/junit/CrankstartSetup.java | 253 ---------------------
.../crankstart/launcher/ArtifactsVisitor.java | 67 ------
.../crankstart/launcher/BundlesInstaller.java | 106 ---------
.../sling/crankstart/launcher/Configurations.java | 145 ------------
.../sling/crankstart/launcher/FeatureFilter.java | 23 --
.../crankstart/launcher/FrameworkProperties.java | 62 -----
.../sling/crankstart/launcher/FrameworkSetup.java | 143 ------------
.../apache/sling/crankstart/launcher/Launcher.java | 222 ------------------
.../crankstart/launcher/LauncherListener.java | 37 ---
.../sling/crankstart/launcher/MavenResolver.java | 88 -------
.../crankstart/launcher/NestedModelsMerger.java | 89 --------
.../launcher/PropertiesVariableResolver.java | 48 ----
.../sling/crankstart/launcher/RunModeFilter.java | 51 -----
.../sling/crankstart/launcher/BasicLauncherIT.java | 216 ------------------
.../launcher/NestedModelsMergerTest.java | 61 -----
.../launcher/PreemptiveAuthInterceptor.java | 59 -----
.../sling/crankstart/launcher/RunModeAIT.java | 81 -------
.../sling/crankstart/launcher/RunModeBIT.java | 81 -------
.../org/apache/sling/crankstart/launcher/U.java | 118 ----------
src/test/resources/crankstart-model.txt | 39 ----
src/test/resources/provisioning-model/base.txt | 40 ----
.../provisioning-model/crankstart-tests.txt | 66 ------
.../provisioning-model/sling-extensions.txt | 26 ---
.../provisioning-model/start-level-99.txt | 24 --
src/test/resources/sling-launchpad.txt | 51 -----
32 files changed, 10 insertions(+), 2698 deletions(-)
diff --git a/.asf.yaml b/.asf.yaml
new file mode 100644
index 0000000..ce6f7d9
--- /dev/null
+++ b/.asf.yaml
@@ -0,0 +1,7 @@
+github:
+ description: "Apache Sling Crankstart Launcher (deprecated)"
+ homepage: "https://sling.apache.org/"
+ labels:
+ - java
+ - sling
+ - deprecated
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
deleted file mode 100644
index 0fa18e5..0000000
--- a/CODE_OF_CONDUCT.md
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF 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.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
-Apache Software Foundation Code of Conduct
-====
-
-Being an Apache project, Apache Sling adheres to the Apache Software Foundation's [Code of Conduct](https://www.apache.org/foundation/policies/conduct.html).
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
deleted file mode 100644
index ac82a1a..0000000
--- a/CONTRIBUTING.md
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF 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.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
-Contributing
-====
-
-Thanks for choosing to contribute!
-
-You will find all the necessary details about how you can do this at https://sling.apache.org/contributing.html.
diff --git a/Jenkinsfile b/Jenkinsfile
deleted file mode 100644
index f582519..0000000
--- a/Jenkinsfile
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.
- */
-
-slingOsgiBundleBuild()
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index d645695..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed 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.
diff --git a/README.md b/README.md
index 65bd578..b6968fc 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,7 @@
[<img src="https://sling.apache.org/res/logos/sling.png"/>](https://sling.apache.org)
- [![Build Status](https://builds.apache.org/buildStatus/icon?job=Sling/sling-org-apache-sling-crankstart-launcher/master)](https://builds.apache.org/job/Sling/job/sling-org-apache-sling-crankstart-launcher/job/master) [![Test Status](https://img.shields.io/jenkins/t/https/builds.apache.org/job/Sling/job/sling-org-apache-sling-crankstart-launcher/job/master.svg)](https://builds.apache.org/job/Sling/job/sling-org-apache-sling-crankstart-launcher/job/master/test_results_analyzer/) [![Maven [...]
+# Apache Sling Crankstart Launcher (deprecated)
-# Apache Sling Crankstart Launcher
+This module is **deprecated**, see the [OSGi Feature Model](https://sling.apache.org/documentation/development/feature-model.html) instead.
-This module is part of the [Apache Sling](https://sling.apache.org) project.
-
-This small and generic OSGi launcher starts a Sling instance (or anything else for that matter) by interpreting a Sling Provisioning Model at runtime.
-
-The Sling Provisioning Model syntax is described at [The Apache Sling Provisioning Model and Apache SlingStart](https://sling.apache.org/documentation/development/slingstart.html).
+For reference or potential bugfix releases use the [maintenance](./tree/maintenance) branch.
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index 9a3a1f3..0000000
--- a/pom.xml
+++ /dev/null
@@ -1,227 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.sling</groupId>
- <artifactId>sling</artifactId>
- <version>32</version>
- <relativePath />
- </parent>
-
- <artifactId>org.apache.sling.crankstart.launcher</artifactId>
- <packaging>jar</packaging>
- <version>1.9.9-SNAPSHOT</version>
-
- <name>Apache Sling Crankstart Launcher</name>
- <inceptionYear>2014</inceptionYear>
-
- <description>
- Sling launcher that gets artifacts defined in a Sling Provisioning
- Model at runtime, instead of embedding them in the launcher jar like
- the Sling Launchpad does.
- </description>
-
- <scm>
- <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git</connection>
- <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git</developerConnection>
- <url>http://sling.apache.org</url>
- </scm>
-
- <properties>
- <sling.java.version>6</sling.java.version>
- <pax.url.version>2.1.0</pax.url.version>
- <org.ops4j.pax.url.mvn.repositories/>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <mainClass>org.apache.sling.crankstart.launcher.Launcher</mainClass>
- <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
- </manifest>
- </archive>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>embed-dependencies</id>
- <goals>
- <goal>unpack-dependencies</goal>
- </goals>
- <configuration>
- <includeGroupIds>org.slf4j,org.ops4j.pax.url,org.apache.sling</includeGroupIds>
- <includeTypes>jar</includeTypes>
- <excludeTransitive>false</excludeTransitive>
- <outputDirectory>${project.build.directory}/classes</outputDirectory>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>false</overWriteSnapshots>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-clean-plugin</artifactId>
- <configuration>
- <filesets>
- <fileset>
- <directory>${basedir}</directory>
- <includes>
- <include>CRANKSTART</include>
- <include>felix-cache</include>
- <include>jackrabbit</include>
- <include>derby.log</include>
- </includes>
- </fileset>
- </filesets>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-failsafe-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>integration-test</goal>
- <goal>verify</goal>
- </goals>
- <configuration>
- <systemPropertyVariables>
- <org.ops4j.pax.url.mvn.repositories>${org.ops4j.pax.url.mvn.repositories}</org.ops4j.pax.url.mvn.repositories>
- </systemPropertyVariables>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>animal-sniffer-maven-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.2.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.framework</artifactId>
- <!-- This should be the same version as in crankstart-model.txt -->
- <version>5.0.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.7.6</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <version>1.7.6</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.provisioning.model</artifactId>
- <version>1.4.4</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.url</groupId>
- <artifactId>pax-url-aether</artifactId>
- <version>${pax.url.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.url</groupId>
- <artifactId>pax-url-commons</artifactId>
- <version>${pax.url.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.commons.testing</artifactId>
- <version>2.0.16</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.crankstart.test.model</artifactId>
- <type>txt</type>
- <!-- TODO should also be <classifier>slingfeature</classifier> -->
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.crankstart.test.services</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.tools</artifactId>
- <version>1.0.17-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>4.1</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.commons.johnzon</artifactId>
- <version>1.0.0</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
diff --git a/src/main/java/org/apache/sling/crankstart/junit/CrankstartSetup.java b/src/main/java/org/apache/sling/crankstart/junit/CrankstartSetup.java
deleted file mode 100644
index 05995e6..0000000
--- a/src/main/java/org/apache/sling/crankstart/junit/CrankstartSetup.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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 org.apache.sling.crankstart.junit;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.ServerSocket;
-import java.util.*;
-
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.sling.crankstart.launcher.Launcher;
-import org.apache.sling.crankstart.launcher.LauncherListener;
-import org.apache.sling.crankstart.launcher.PropertiesVariableResolver;
-import org.apache.sling.provisioning.model.ModelUtility.VariableResolver;
-import org.junit.rules.ExternalResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** JUnit Rule that starts a Crankstart instance, using a set of provisioning
- * models. See our integration tests for examples.
- */
-public class CrankstartSetup extends ExternalResource {
-
- private static final Logger log = LoggerFactory.getLogger(CrankstartSetup.class);
- private final int port = getAvailablePort();
- private final String storagePath = getOsgiStoragePath();
- private Thread crankstartThread;
- private final String baseUrl = "http://localhost:" + port;
- private final Properties replacementProps = new Properties();
-
- private static List<CrankstartSetup> toCleanup = new ArrayList<CrankstartSetup>();
- private static Thread shutdownHook;
-
- private VariableResolver variablesResolver = new PropertiesVariableResolver(replacementProps, Launcher.VARIABLE_OVERRIDE_PREFIX);
-
- private String [] classpathModelPaths;
- private boolean shutdown;
- private int bundlesStarted;
- private int bundlesFailed;
- private int totalBundles;
-
-
- @Override
- public String toString() {
- return getClass().getSimpleName() + ", port " + port + ", OSGi storage " + storagePath;
- }
-
- public CrankstartSetup() {
- synchronized (getClass()) {
- if(shutdownHook == null) {
- shutdownHook = new Thread(CrankstartSetup.class.getSimpleName() + " shutdown thread") {
- @Override
- public void run() {
- log.info("Starting cleanup");
- cleanup();
- log.info("Cleanup done");
- }
- };
- Runtime.getRuntime().addShutdownHook(shutdownHook);
- }
- }
- }
-
-
- public CrankstartSetup withModelResources(String ... classpathModelPaths) {
- this.classpathModelPaths = classpathModelPaths;
- return this;
- }
-
- private static int getAvailablePort() {
- int result = -1;
- ServerSocket s = null;
- try {
- try {
- s = new ServerSocket(0);
- result = s.getLocalPort();
- } finally {
- if(s != null) {
- s.close();
- }
- }
- } catch(Exception e) {
- throw new RuntimeException("getAvailablePort failed", e);
- }
- return result;
- }
-
- private static void mergeModelResource(Launcher launcher, String path) throws Exception {
- final InputStream is = CrankstartSetup.class.getResourceAsStream(path);
- assertNotNull("Expecting test resource to be found:" + path, is);
- final Reader input = new InputStreamReader(is);
- try {
- Launcher.mergeModel(launcher.getModel(), input, path);
- launcher.computeEffectiveModel();
- } finally {
- input.close();
- }
- }
-
- public String getBaseUrl() {
- return baseUrl;
- }
-
- public int getBundlesFailed() {
- return bundlesFailed;
- }
-
- public int getBundlesStarted() {
- return bundlesStarted;
- }
-
- public int getTotalBundles() {
- return totalBundles;
- }
-
- public boolean isShutdownComplete() {
- return shutdown;
- }
-
- private static void cleanup() {
- synchronized (toCleanup) {
- if(toCleanup.isEmpty()) {
- log.info("No Crankstart instances to cleanup");
- return;
- }
- log.info("Stopping {} running Crankstart instances...", toCleanup.size());
- for(CrankstartSetup s : toCleanup) {
- s.stopCrankstartInstance();
- }
- toCleanup.clear();
- }
- }
-
- @Override
- protected void before() throws Throwable {
- if(crankstartThread != null) {
- log.debug("Already running");
- return;
- }
-
- cleanup();
-
- log.info("Starting {}", this);
-
- // Add system properties which have the expected prefix
- for(Object o : System.getProperties().keySet()) {
- final String key = o.toString();
- if(key.startsWith(Launcher.VARIABLE_OVERRIDE_PREFIX)) {
- replacementProps.setProperty(key, System.getProperty(key));
- }
- }
-
- final HttpUriRequest get = new HttpGet(baseUrl);
- replacementProps.setProperty("crankstart.model.http.port", String.valueOf(port));
- replacementProps.setProperty("crankstart.model.osgi.storage.path", storagePath);
-
- try {
- new DefaultHttpClient().execute(get);
- fail("Expecting connection to " + port + " to fail before starting HTTP service");
- } catch(IOException expected) {
- }
- shutdown = false;
- bundlesStarted = 0;
- bundlesFailed = 0;
- totalBundles = 0;
- final Launcher launcher = new Launcher().withVariableResolver(variablesResolver).withListener(new LauncherListener() {
- @Override
- public void onStartup(int started, int failed, int totalBundles) {
- CrankstartSetup.this.bundlesStarted = started;
- CrankstartSetup.this.bundlesFailed = failed;
- CrankstartSetup.this.totalBundles = totalBundles;
- }
-
- @Override
- public void onShutdown() {
- shutdown = true;
- }
- });
- for(String path : classpathModelPaths) {
- mergeModelResource(launcher, path);
- }
- launcher.computeEffectiveModel();
-
- crankstartThread = new Thread() {
- public void run() {
- try {
- launcher.launch();
- } catch(InterruptedException e) {
- log.info("Launcher thread was interrupted, exiting");
- } catch(Exception e) {
- e.printStackTrace();
- fail("Launcher exception:" + e);
- }
- }
- };
- crankstartThread.setDaemon(true);
- crankstartThread.start();
-
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- stopCrankstartInstance();
- }
- });
- }
-
- private void stopCrankstartInstance() {
- log.info("Stopping {}", this);
- if(crankstartThread == null) {
- return;
- }
- crankstartThread.interrupt();
- try {
- crankstartThread.join();
- } catch(InterruptedException ignore) {
- }
- crankstartThread = null;
- }
-
- private static String getOsgiStoragePath() {
- final File tmpRoot = new File(System.getProperty("java.io.tmpdir"));
- final File tmpFolder = new File(tmpRoot, CrankstartSetup.class.getSimpleName() + "_" + UUID.randomUUID());
- if(!tmpFolder.mkdir()) {
- fail("Failed to create " + tmpFolder.getAbsolutePath());
- }
- tmpFolder.deleteOnExit();
- return tmpFolder.getAbsolutePath();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/ArtifactsVisitor.java b/src/main/java/org/apache/sling/crankstart/launcher/ArtifactsVisitor.java
deleted file mode 100644
index f3a41a9..0000000
--- a/src/main/java/org/apache/sling/crankstart/launcher/ArtifactsVisitor.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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 org.apache.sling.crankstart.launcher;
-
-import org.apache.sling.provisioning.model.Artifact;
-import org.apache.sling.provisioning.model.ArtifactGroup;
-import org.apache.sling.provisioning.model.Feature;
-import org.apache.sling.provisioning.model.Model;
-import org.apache.sling.provisioning.model.RunMode;
-
-/** Visit the Artifacts of a Model */
-public abstract class ArtifactsVisitor {
- protected final Model model;
-
- public ArtifactsVisitor(Model m) {
- model = m;
- }
-
- protected abstract void visitArtifact(Feature f, RunMode rm, ArtifactGroup g, Artifact a) throws Exception;
-
- public void visit() throws Exception {
- for(Feature f : model.getFeatures()) {
- if(!acceptFeature(f)) {
- continue;
- }
- for(RunMode rm : f.getRunModes()) {
- if(!acceptRunMode(rm)) {
- continue;
- }
- for(ArtifactGroup g : rm.getArtifactGroups()) {
- if(!acceptArtifactGroup(g)) {
- continue;
- }
- for(Artifact a : g) {
- visitArtifact(f, rm, g, a);
- }
- }
- }
- }
- }
-
- protected boolean acceptFeature(Feature f) {
- return true;
- }
-
- protected boolean acceptRunMode(RunMode rm) {
- return true;
- }
-
- protected boolean acceptArtifactGroup(ArtifactGroup g) {
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/BundlesInstaller.java b/src/main/java/org/apache/sling/crankstart/launcher/BundlesInstaller.java
deleted file mode 100644
index bf7b33b..0000000
--- a/src/main/java/org/apache/sling/crankstart/launcher/BundlesInstaller.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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 org.apache.sling.crankstart.launcher;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Arrays;
-
-import org.apache.sling.provisioning.model.Artifact;
-import org.apache.sling.provisioning.model.ArtifactGroup;
-import org.apache.sling.provisioning.model.Feature;
-import org.apache.sling.provisioning.model.Model;
-import org.apache.sling.provisioning.model.RunMode;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.startlevel.BundleStartLevel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** Install bundles from a provisioning model */
-public class BundlesInstaller {
- private final Logger log = LoggerFactory.getLogger(getClass());
- private final Model model;
- private final RunModeFilter rmFilter;
-
- public BundlesInstaller(Model m, RunModeFilter rmFilter) {
- model = m;
- this.rmFilter = rmFilter;
- }
-
- private boolean isBundle(Artifact a) {
- final String aType = a.getType();
- return "jar".equals(aType) || "war".equals(aType);
- }
-
- public void installBundles(final BundleContext ctx, final FeatureFilter filter) throws Exception {
-
- final ArtifactsVisitor v = new ArtifactsVisitor(model) {
-
- @Override
- protected void visitArtifact(Feature f, RunMode rm, ArtifactGroup g, Artifact a) throws Exception {
- if(isBundle(a)) {
- installBundle(ctx, a, g.getStartLevel());
- } else {
- log.info("Ignoring Artifact, not a bundle: {}", a);
- }
- }
-
- @Override
- protected boolean acceptFeature(Feature f) {
- final boolean accept = !filter.ignoreFeature(f);
- if(!accept) {
- log.info("Ignoring feature: {}", f.getName());
- }
- return accept;
- }
-
- @Override
- protected boolean acceptRunMode(RunMode rm) {
- final boolean accept = rmFilter.runModeActive(rm);
- if(!accept) {
- log.info("RunMode is not active, ignored: {}", Arrays.asList(rm.getNames()));
- }
- return accept;
- }
- };
-
- v.visit();
- }
-
- public void installBundle(BundleContext ctx, Artifact a, int startLevel) throws IOException, BundleException {
- final String bundleUrl = "mvn:" + a.getGroupId() + "/" + a.getArtifactId() + "/" + a.getVersion() + "/" + a.getType();
- final URL url = new URL(bundleUrl);
- final InputStream bundleStream = url.openStream();
- try {
- final Bundle b = ctx.installBundle(bundleUrl, url.openStream());
- if(startLevel > 0) {
- final BundleStartLevel bsl = (BundleStartLevel)b.adapt(BundleStartLevel.class);
- if(bsl == null) {
- log.warn("Bundle does not adapt to BundleStartLevel, cannot set start level: {}", bundleUrl);
- }
- bsl.setStartLevel(startLevel);
- }
-
- log.info("bundle installed at start level {}: {}", startLevel, bundleUrl);
- } finally {
- bundleStream.close();
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/Configurations.java b/src/main/java/org/apache/sling/crankstart/launcher/Configurations.java
deleted file mode 100644
index 6da4b45..0000000
--- a/src/main/java/org/apache/sling/crankstart/launcher/Configurations.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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 org.apache.sling.crankstart.launcher;
-
-import java.io.Closeable;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Arrays;
-import java.util.Dictionary;
-
-import org.apache.sling.provisioning.model.Configuration;
-import org.apache.sling.provisioning.model.Feature;
-import org.apache.sling.provisioning.model.Model;
-import org.apache.sling.provisioning.model.RunMode;
-import org.osgi.framework.BundleContext;
-import org.osgi.util.tracker.ServiceTracker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** Setup the OSGi configurations based on a provisioning model */
-public class Configurations implements Closeable {
- private final Logger log = LoggerFactory.getLogger(getClass());
- public static final String CONFIG_ADMIN_CLASS = "org.osgi.service.cm.ConfigurationAdmin";
- private final Model model;
- private final RunModeFilter rmFilter;
- private final ServiceTracker tracker;
- private ConfigAdminProxy proxy;
-
- /** We use reflection to talk to ConfigAdmin, to avoid classloader issues as
- * the service comes from inside the OSGi framework and we are outside of that.
- */
- private static class ConfigAdminProxy {
- private final Object svc;
-
- ConfigAdminProxy(Object configAdminService) {
- svc = configAdminService;
- }
-
- Object createFactoryConfiguration(String factoryPid)
- throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
- return svc.getClass()
- .getMethod("createFactoryConfiguration", String.class)
- .invoke(svc, factoryPid);
-
- }
-
- Object getConfiguration(String pid)
- throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
- return svc.getClass()
- .getMethod("getConfiguration", String.class)
- .invoke(svc, pid);
-
- }
-
- void setConfigBundleLocation(Object config, String location)
- throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
- config.getClass()
- .getMethod("setBundleLocation", String.class)
- .invoke(config, location);
- }
-
- void updateConfig(Object config, Dictionary<String, Object> properties)
- throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
- config.getClass()
- .getMethod("update", Dictionary.class)
- .invoke(config, properties);
- }
- }
-
- public Configurations(BundleContext ctx, Model m, RunModeFilter rmFilter) {
- model = m;
- this.rmFilter = rmFilter;
- tracker = new ServiceTracker(ctx, CONFIG_ADMIN_CLASS, null);
- tracker.open();
- }
-
- public void close() {
- tracker.close();
- }
-
- /** Activate our configurations if possible, and if not done already.
- * Can be called as many times as convenient, to make sure this happens
- * as early as possible.
- */
- public synchronized void maybeConfigure() {
- if(proxy != null) {
- log.debug("Configurations already activated, doing nothing");
- return;
- }
- final Object service = tracker.getService();
- if(service == null) {
- log.debug("ConfigurationAdmin service not yet available, doing nothing");
- return;
- }
-
- proxy = new ConfigAdminProxy(service);
- log.info("Activating configurations from provisioning model");
- for(Feature f : model.getFeatures()) {
- for(RunMode r : f.getRunModes()) {
- if(!rmFilter.runModeActive(r)) {
- log.info("RunMode is not active, ignored: {}", Arrays.asList(r.getNames()));
- continue;
- }
- for(Configuration c : r.getConfigurations()) {
- try {
- setConfig(c);
- } catch(Exception e) {
- log.warn("Failed to activate configuration " + c, e);
- }
- }
- }
- }
- }
-
- private void setConfig(Configuration c)
- throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
- final String factoryPid = c.getFactoryPid();
- String configSource = null;
- Object config = null;
- if(factoryPid != null) {
- config = proxy.createFactoryConfiguration(factoryPid);
- configSource = "factory PID " + factoryPid;
- } else {
- config = proxy.getConfiguration(c.getPid());
- configSource = "PID " + c.getPid();
- }
-
- proxy.setConfigBundleLocation(config, null);
- proxy.updateConfig(config, c.getProperties());
- log.info("Created and updated Configuration using [{}]: [{}]", configSource, config);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/FeatureFilter.java b/src/main/java/org/apache/sling/crankstart/launcher/FeatureFilter.java
deleted file mode 100644
index 02d6174..0000000
--- a/src/main/java/org/apache/sling/crankstart/launcher/FeatureFilter.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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 org.apache.sling.crankstart.launcher;
-
-import org.apache.sling.provisioning.model.Feature;
-
-public interface FeatureFilter {
- boolean ignoreFeature(Feature f);
-}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/FrameworkProperties.java b/src/main/java/org/apache/sling/crankstart/launcher/FrameworkProperties.java
deleted file mode 100644
index 5213be2..0000000
--- a/src/main/java/org/apache/sling/crankstart/launcher/FrameworkProperties.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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 org.apache.sling.crankstart.launcher;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.sling.provisioning.model.Feature;
-import org.apache.sling.provisioning.model.KeyValueMap;
-import org.apache.sling.provisioning.model.Model;
-import org.apache.sling.provisioning.model.RunMode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** Get OSGi framework properties from a provisioning model */
-public class FrameworkProperties {
- private final Logger log = LoggerFactory.getLogger(getClass());
- private final Model model;
- private Map<String, String> fprops;
-
- public static final String CRANKSTART_SYSPROP_OVERRIDE_PREFIX = "sling.crankstart.";
-
- public FrameworkProperties(Model m) {
- model = m;
- }
-
- public synchronized Map<String, String> getProperties(FeatureFilter filter) {
- if(fprops == null) {
- fprops = new HashMap<String, String>();
- for(Feature f : model.getFeatures()) {
- if(filter != null && filter.ignoreFeature(f)) {
- continue;
- }
- for(RunMode rm : f.getRunModes()) {
- final KeyValueMap<String> settings = rm.getSettings();
- if(settings.size() > 0) {
- log.info("Using settings from Feature {}, RunMode {} as framework properties", f.getName(), rm.getNames());
- for(Map.Entry<String, String> e : settings) {
- log.info("framework property set from provisioning model: {}={}", e.getKey(), e.getValue());
- fprops.put(e.getKey(), e.getValue());
- }
- }
- }
- }
- }
- return fprops;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/FrameworkSetup.java b/src/main/java/org/apache/sling/crankstart/launcher/FrameworkSetup.java
deleted file mode 100644
index 2d52b2e..0000000
--- a/src/main/java/org/apache/sling/crankstart/launcher/FrameworkSetup.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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 org.apache.sling.crankstart.launcher;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.Callable;
-
-import org.apache.sling.provisioning.model.Model;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.launch.Framework;
-import org.osgi.framework.launch.FrameworkFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** Setup the OSGi framework based on a provisioning model */
-@SuppressWarnings("serial")
-public class FrameworkSetup extends HashMap<String, Object> implements Callable<Object> {
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @SuppressWarnings("unchecked")
- private <T> T require(String key, Class<T> desiredType) throws IllegalStateException {
- final Object o = get(key);
- if(o == null) {
- throw new IllegalStateException("Missing required object:" + key);
- }
- if(!o.getClass().isAssignableFrom(desiredType)) {
- throw new ClassCastException("Object '" + key + "' is not a " + desiredType.getName());
- }
- return (T)o;
- }
-
- public Object call() throws Exception {
- final Model model = require(Launcher.MODEL_KEY, Model.class);
- final LauncherListener listener = (LauncherListener) get(Launcher.LISTENER_KEY);
-
- log.info("Setting OSGi framework properties");
- final Map<String, String> fprops = new FrameworkProperties(model).getProperties(null);
-
- log.info("Starting the OSGi framework");
- final FrameworkFactory factory = (FrameworkFactory)getClass().getClassLoader().loadClass("org.apache.felix.framework.FrameworkFactory").newInstance();
- final Framework framework = factory.newFramework(fprops);
- framework.start();
-
- final RunModeFilter rmFilter = new RunModeFilter();
-
- final Configurations cfg = new Configurations(framework.getBundleContext(), model, rmFilter);
- setShutdownHook(framework, new Closeable[] { cfg });
- log.info("OSGi framework started");
-
- log.info("Installing bundles from provisioning model");
- final BundlesInstaller bi = new BundlesInstaller(model, rmFilter);
- final BundleContext bc = framework.getBundleContext();
- bi.installBundles(bc, Launcher.NOT_CRANKSTART_FILTER);
- cfg.maybeConfigure();
-
- // TODO shall we gradually increase start levels like the launchpad does?? Reuse that DefaultStartupHandler code?
- final Bundle [] bundles = bc.getBundles();
- log.info("Starting all bundles ({} bundles installed)", bundles.length);
- int started = 0;
- int failed = 0;
- for(Bundle b : bundles) {
- if(isFragment(b)) {
- started++;
- } else {
- try {
- b.start();
- started++;
- } catch(BundleException be) {
- failed++;
- log.warn("Error starting bundle " + b.getSymbolicName(), be);
- }
- }
- cfg.maybeConfigure();
- }
-
- if(failed == 0) {
- log.info("All {} bundles started.", started);
- } else {
- log.info("{} bundles started, {} failed to start, total {}", started, failed, bundles.length);
- }
-
- log.info("OSGi setup done, waiting for framework to stop");
- if ( listener != null) {
- listener.onStartup(started, failed, bundles.length);
- }
- framework.waitForStop(0);
- if ( listener != null) {
- listener.onShutdown();
- }
-
- return null;
- }
-
- private boolean isFragment(Bundle b) {
- return b.getHeaders().get("Fragment-Host") != null;
- }
-
- private void setShutdownHook(final Framework osgiFramework, final Closeable ... toClose) {
- // Shutdown the framework when the JVM exits
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- if(osgiFramework != null && osgiFramework.getState() == Bundle.ACTIVE) {
- try {
- log.info("Stopping the OSGi framework");
- osgiFramework.stop();
- log.info("Waiting for the OSGi framework to exit");
- osgiFramework.waitForStop(0);
- log.info("OSGi framework stopped");
- } catch(Exception e) {
- log.error("Exception while stopping OSGi framework", e);
- } finally {
- for(Closeable c : toClose) {
- try {
- c.close();
- } catch(IOException ignore) {
- }
- }
- }
- }
- }
- });
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/Launcher.java b/src/main/java/org/apache/sling/crankstart/launcher/Launcher.java
deleted file mode 100644
index 3a0e043..0000000
--- a/src/main/java/org/apache/sling/crankstart/launcher/Launcher.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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 org.apache.sling.crankstart.launcher;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.concurrent.Callable;
-
-import org.apache.sling.provisioning.model.Artifact;
-import org.apache.sling.provisioning.model.ArtifactGroup;
-import org.apache.sling.provisioning.model.Feature;
-import org.apache.sling.provisioning.model.Model;
-import org.apache.sling.provisioning.model.ModelUtility;
-import org.apache.sling.provisioning.model.ModelUtility.VariableResolver;
-import org.apache.sling.provisioning.model.RunMode;
-import org.apache.sling.provisioning.model.io.ModelReader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** Launch an OSGi app instance using the Sling provisioning model */
-public class Launcher {
- private Model model = new Model();
- private static final Logger log = LoggerFactory.getLogger(Launcher.class);
-
- public static final String CRANKSTART_FEATURE = ":crankstart";
- public static final String MODEL_KEY = "model";
- public static final String LISTENER_KEY = "listener";
- public static final String FRAMEWORK_KEY = "framework";
-
- public static final String VARIABLE_OVERRIDE_PREFIX = "crankstart.model.";
-
- /** Default variable resolver using system properties */
- public static final VariableResolver DEFAULT_VARIABLE_RESOLVER =
- new PropertiesVariableResolver(System.getProperties(), VARIABLE_OVERRIDE_PREFIX) {
- @Override
- protected void onOverride(String variableName, String value, String propertyName) {
- log.info("Overriding model variable {}={} (from system property {})", variableName, value, propertyName);
- }
- };
-
- /** Allow for overriding model variables */
- private VariableResolver variableResolver;
-
- public static final FeatureFilter NOT_CRANKSTART_FILTER = new FeatureFilter() {
- @Override
- public boolean ignoreFeature(Feature f) {
- return Launcher.CRANKSTART_FEATURE.equals(f.getName());
- }
- };
-
- public static final FeatureFilter ONLY_CRANKSTART_FILTER = new FeatureFilter() {
- @Override
- public boolean ignoreFeature(Feature f) {
- return !Launcher.CRANKSTART_FEATURE.equals(f.getName());
- }
- };
- private LauncherListener listener;
-
- public Launcher(String ... args) throws Exception {
- MavenResolver.setup();
- withVariableResolver(null);
- withModelPaths(args);
- }
-
- /** Use the supplied VariableResolver. Defaults to DEFAULT_VARIABLE_RESOLVER if v
- * is null or if this is not called.
- */
- public Launcher withVariableResolver(VariableResolver v) {
- variableResolver = (v == null ? DEFAULT_VARIABLE_RESOLVER : v);
- return this;
- }
-
- public Launcher withListener(LauncherListener listener) {
- this.listener = listener;
- return this;
- }
-
- /** Add models from the supplied paths, can be either files or folders */
- public Launcher withModelPaths(String ... paths) throws Exception {
- // Find all files to read and sort the list, to be deterministic
- final SortedSet<File> toRead = new TreeSet<File>();
-
- for(String name : paths) {
- final File f = new File(name);
- if(f.isDirectory()) {
- final String [] list = f.list();
- for(String s : list) {
- toRead.add(new File(f, s));
- }
- } else {
- toRead.add(f);
- }
- }
-
- // Merge all model files
- for(File f : toRead) {
- mergeModel(f);
- }
-
- computeEffectiveModel();
- return this;
- }
-
- public void computeEffectiveModel() throws Exception {
- new NestedModelsMerger(model).visit();
- model = ModelUtility.getEffectiveModel(model, variableResolver);
- }
-
- public Model getModel() {
- return model;
- }
-
- /** Can be called before launch() to read and merge additional models.
- * @param r provisioning model to read, closed by this method after reading */
- public static void mergeModel(Model mergeInto, Reader r, String sourceInfo) throws IOException {
- log.info("Merging provisioning model {}", sourceInfo);
- try {
- final Model m = ModelReader.read(r, sourceInfo);
- ModelUtility.merge(mergeInto, m);
- } finally {
- r.close();
- }
- }
-
- /** Can be called before launch() to read and merge additional models */
- public void mergeModel(File f) throws IOException {
- mergeModel(model, new BufferedReader(new FileReader(f)), f.getAbsolutePath());
- }
-
- public void launch() throws Exception {
- // Setup initial classpath to launch the OSGi framework
- for(URL u : getClasspathURLs(model, CRANKSTART_FEATURE)) {
- addToClasspath(u);
- }
-
- // Need to load FrameworkSetup in this way to avoid any static references to OSGi classes in this class, as those are
- // not available yet when this class is loaded.
- final Callable<?> c = (Callable<?>) getClass().getClassLoader().loadClass("org.apache.sling.crankstart.launcher.FrameworkSetup").newInstance();
- @SuppressWarnings("unchecked") final Map<String, Object> cmap = (Map<String, Object>)c;
- cmap.put(MODEL_KEY, model);
- cmap.put(LISTENER_KEY, listener);
- c.call();
- }
-
- /** Slightly hacky way to add URLs to the system classloader,
- * based on http://stackoverflow.com/questions/60764/how-should-i-load-jars-dynamically-at-runtime
- */
- private void addToClasspath(URL u) throws IOException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
- final URLClassLoader sysLoader = (URLClassLoader)ClassLoader.getSystemClassLoader();
- final Method m = URLClassLoader.class.getDeclaredMethod("addURL",new Class[]{URL.class});
- m.setAccessible(true);
- m.invoke(sysLoader,new Object[]{ u });
- log.info("Added to classpath: {}", u);
- }
-
- /** Convert a Model feature to a set of URLs meant to setup
- * an URLClassLoader.
- */
- List<URL> getClasspathURLs(Model m, String featureName) throws MalformedURLException {
- final List<URL> result = new ArrayList<URL>();
-
- // Add all URLs from the special feature to our classpath
- final Feature f = m.getFeature(featureName);
- if(f == null) {
- log.warn("No {} feature found in provisioning model, nothing to add to our classpath", featureName);
- } else {
- for(RunMode rm : f.getRunModes()) {
- for(ArtifactGroup g : rm.getArtifactGroups()) {
- for(Artifact a : g) {
- final String url = MavenResolver.mvnUrl(a);
- try {
- result.add(new URL(url));
- } catch(MalformedURLException e) {
- final MalformedURLException up = new MalformedURLException("Invalid URL [" + url + "]");
- up.initCause(e);
- throw up;
- }
- }
- }
- }
- }
- return result;
- }
-
- public static void main(String [] args) throws Exception {
- if(args.length < 1) {
- System.err.println("Usage: " + Launcher.class.getSimpleName() + " provisioning-model [provisioning-model ...]");
- System.err.println("Where provisioning-model is either a Sling provisioning model file");
- System.err.println("or a folder that contains several of those.");
- System.exit(0);
- }
-
- new Launcher(args).launch();
- }
-}
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/LauncherListener.java b/src/main/java/org/apache/sling/crankstart/launcher/LauncherListener.java
deleted file mode 100644
index 055ebb6..0000000
--- a/src/main/java/org/apache/sling/crankstart/launcher/LauncherListener.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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 org.apache.sling.crankstart.launcher;
-
-/**
- * Listens to startup information from the launcher thread.
- */
-public interface LauncherListener {
-
- /**
- * Called when the launcher has finished loading all initial bundles reporting those that started and those that failed.
- * @param started the number started.
- * @param failed the number that failed.
- * @param length the total number of bundles.
- */
- void onStartup(int started, int failed, int length);
-
- /**
- * Called when the launcher thread begins to perform shutdown.
- */
- void onShutdown();
-}
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/MavenResolver.java b/src/main/java/org/apache/sling/crankstart/launcher/MavenResolver.java
deleted file mode 100644
index b7cedd3..0000000
--- a/src/main/java/org/apache/sling/crankstart/launcher/MavenResolver.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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 org.apache.sling.crankstart.launcher;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.sling.provisioning.model.Artifact;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** Resolve artifacts using Maven URLs - assumes Pax URL is installed */
-public class MavenResolver {
- public static final String SLINGFEATURE_ARTIFACT_TYPE = "slingfeature";
- public static final String SLINGSTART_ARTIFACT_TYPE = "slingstart";
- public static final String TXT_ARTIFACT_TYPE = "txt";
-
- private static final Logger log = LoggerFactory.getLogger(MavenResolver.class);
-
- @SuppressWarnings("serial")
- private static final Map <String, String> ARTIFACT_TYPES_MAP = new HashMap<String,String>() {
- {
- put(SLINGFEATURE_ARTIFACT_TYPE, TXT_ARTIFACT_TYPE);
- put(SLINGSTART_ARTIFACT_TYPE, TXT_ARTIFACT_TYPE);
- }
- };
-
- public static void setup() {
- // Enable pax URL for mvn: protocol
- System.setProperty( "java.protocol.handler.pkgs", "org.ops4j.pax.url" );
- }
-
- public static String mvnUrl(Artifact a) {
- final StringBuilder sb = new StringBuilder();
- sb
- .append("mvn:")
- .append(a.getGroupId())
- .append("/")
- .append(a.getArtifactId())
- .append("/")
- .append(a.getVersion());
-
- if(a.getType() != null) {
- sb.append("/").append(mapArtifactType(a.getType()));
- }
-
- if(a.getClassifier() != null) {
- sb.append("/").append(a.getClassifier());
- }
-
- return sb.toString();
- }
-
- /** Maven plugins can map artifact types to well-known
- * extensions during deployment - this implements the
- * same mapping.
- */
- public static String mapArtifactType(String artifactType) {
- final String mapped = ARTIFACT_TYPES_MAP.get(artifactType);
- if(mapped != null) {
- log.info("artifact type '{}' mapped to '{}' for resolution", artifactType, mapped);
- return mapped;
- }
- return artifactType;
- }
-
- public static InputStream resolve(Artifact a) throws MalformedURLException, IOException {
- return new URL(mvnUrl(a)).openStream();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/NestedModelsMerger.java b/src/main/java/org/apache/sling/crankstart/launcher/NestedModelsMerger.java
deleted file mode 100644
index 9d0987e..0000000
--- a/src/main/java/org/apache/sling/crankstart/launcher/NestedModelsMerger.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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 org.apache.sling.crankstart.launcher;
-
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.sling.provisioning.model.Artifact;
-import org.apache.sling.provisioning.model.ArtifactGroup;
-import org.apache.sling.provisioning.model.Feature;
-import org.apache.sling.provisioning.model.Model;
-import org.apache.sling.provisioning.model.RunMode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/** Merge nested models, provided by slingfeature/slingstart artifacts */
-public class NestedModelsMerger extends ArtifactsVisitor {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
- private List<Artifact> toMerge;
-
- public NestedModelsMerger(Model m) {
- super(m);
- }
-
- @Override
- public synchronized void visit() throws Exception {
- toMerge = new ArrayList<Artifact>();
- super.visit();
- log.info("{} nested models found in provisioning model", toMerge.size());
-
- for(Artifact a : toMerge) {
- log.info("Resolving and merging nested model {}", a);
- InputStream is = null;
- Reader r = null;
- try {
- is = MavenResolver.resolve(a);
- r = new InputStreamReader(is);
- Launcher.mergeModel(model, r, a.toString());
- } catch(Exception e) {
- log.error("Failed to read nested model " + a, e);
- } finally {
- if(r != null) {
- r.close();
- }
- if(is != null) {
- is.close();
- }
- }
- }
- }
-
- boolean isNestedModel(Artifact a) {
- final String aType = a.getType();
- final String classifier = a.getClassifier();
- final boolean result =
- MavenResolver.SLINGFEATURE_ARTIFACT_TYPE.equals(aType)
- || MavenResolver.SLINGFEATURE_ARTIFACT_TYPE.equals(classifier)
- || MavenResolver.SLINGSTART_ARTIFACT_TYPE.equals(aType)
- || MavenResolver.SLINGSTART_ARTIFACT_TYPE.equals(classifier);
- return result;
- }
-
- @Override
- protected void visitArtifact(Feature f, RunMode rm, ArtifactGroup g, Artifact a) throws Exception {
- if(isNestedModel(a)) {
- log.info("Artifact identified as a nested model , will be merged: {}", a);
- toMerge.add(a);
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/PropertiesVariableResolver.java b/src/main/java/org/apache/sling/crankstart/launcher/PropertiesVariableResolver.java
deleted file mode 100644
index b0d1437..0000000
--- a/src/main/java/org/apache/sling/crankstart/launcher/PropertiesVariableResolver.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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 org.apache.sling.crankstart.launcher;
-
-import java.util.Properties;
-
-import org.apache.sling.provisioning.model.Feature;
-import org.apache.sling.provisioning.model.ModelUtility.VariableResolver;
-
-/** VariableResolver that uses a Properties object */
-public class PropertiesVariableResolver implements VariableResolver {
- private final Properties props;
- private final String variableNamePrefix;
-
- public PropertiesVariableResolver(Properties props, String variableNamePrefix) {
- this.props = props;
- this.variableNamePrefix = variableNamePrefix;
- }
-
- @Override
- public String resolve(Feature f, String variableName) {
- final String propertyName = variableNamePrefix + variableName;
- final String value = props.getProperty(propertyName);
- if(value == null) {
- return f.getVariables().get(variableName);
- } else {
- onOverride(variableName, value, propertyName);
- return value;
- }
- }
-
- protected void onOverride(String variableName, String value, String propertyName) {
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/RunModeFilter.java b/src/main/java/org/apache/sling/crankstart/launcher/RunModeFilter.java
deleted file mode 100644
index bdd0a80..0000000
--- a/src/main/java/org/apache/sling/crankstart/launcher/RunModeFilter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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 org.apache.sling.crankstart.launcher;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.sling.provisioning.model.RunMode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RunModeFilter {
- private final Logger log = LoggerFactory.getLogger(getClass());
- private final List<String> activeRunModes;
- public static final String SLING_RUN_MODES = "sling.run.modes";
-
- RunModeFilter() {
- final String sysProp = System.getProperty(SLING_RUN_MODES, "");
- activeRunModes = new ArrayList<String>(Arrays.asList(sysProp.split(",")));
- log.info("Active run modes: {}", activeRunModes);
- }
-
- public boolean runModeActive(RunMode m) {
- // A RunMode is active if all its names are active
- final String [] names = m.getNames();
- if(names == null || names.length == 0) {
- return true;
- }
-
- boolean active = true;
- for(String name : names) {
- active &= activeRunModes.contains(name);
- }
- return active;
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/crankstart/launcher/BasicLauncherIT.java b/src/test/java/org/apache/sling/crankstart/launcher/BasicLauncherIT.java
deleted file mode 100644
index ce8d48f..0000000
--- a/src/test/java/org/apache/sling/crankstart/launcher/BasicLauncherIT.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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 org.apache.sling.crankstart.launcher;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.util.UUID;
-
-import javax.json.JsonArray;
-import javax.json.JsonObject;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.sling.commons.testing.junit.Retry;
-import org.apache.sling.commons.testing.junit.RetryRule;
-import org.apache.sling.crankstart.junit.CrankstartSetup;
-import org.apache.sling.testing.tools.osgi.WebconsoleClient;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-
-/** Basic tests of the launcher, verify that we
- * can start the Felix HTTP service and a few
- * other things.
- */
-public class BasicLauncherIT {
-
- @ClassRule
- public static CrankstartSetup C = new CrankstartSetup().withModelResources(U.DEFAULT_MODELS);
-
- private DefaultHttpClient client;
- private static WebconsoleClient osgiConsole;
- private static final String uniqueText = "Unique text for tests run " + UUID.randomUUID();
-
- // The Launcher.VARIABLE_OVERRIDE_PREFIX must be used for system properties that
- // are meant to provide values for the provisioning model
- private static final String PROP_UNIQUE_TEXT = Launcher.VARIABLE_OVERRIDE_PREFIX + "single.servlet.text";
-
- static {
- // BeforeClass would be too late for this as it's
- // the CrankstartSetup rule that needs this.
- System.setProperty(PROP_UNIQUE_TEXT, uniqueText);
- }
-
- @Rule
- public final RetryRule retryRule = new RetryRule();
-
- @BeforeClass
- public static void setupClass() throws Exception {
- osgiConsole = new WebconsoleClient(C.getBaseUrl(), U.ADMIN, U.ADMIN);
- }
-
- @Before
- public void setup() throws IOException {
- System.getProperties().remove(PROP_UNIQUE_TEXT);
- client = new DefaultHttpClient();
- }
-
- @Test
- @Retry(timeoutMsec=U.LONG_TIMEOUT_MSEC, intervalMsec=U.STD_INTERVAL)
- public void testHttpRoot() throws Exception {
- final HttpUriRequest get = new HttpGet(C.getBaseUrl());
- HttpResponse response = null;
- try {
- response = client.execute(get);
- assertEquals("Expecting page not found at " + get.getURI(), 404, response.getStatusLine().getStatusCode());
- } finally {
- U.closeConnection(response);
- }
- }
-
- @Test
- @Retry(timeoutMsec=U.LONG_TIMEOUT_MSEC, intervalMsec=U.STD_INTERVAL)
- public void testSingleConfigServlet() throws Exception {
- final HttpUriRequest get = new HttpGet(C.getBaseUrl() + "/single");
- HttpResponse response = null;
- try {
- response = client.execute(get);
- assertEquals("Expecting success for " + get.getURI(), 200, response.getStatusLine().getStatusCode());
- final String content = U.getContent(response);
- final String expected = "SingleConfigServlet:test content is " + uniqueText;
- assertEquals(expected, content);
- } finally {
- U.closeConnection(response);
- }
- }
-
- @Test
- @Retry(timeoutMsec=U.LONG_TIMEOUT_MSEC, intervalMsec=U.STD_INTERVAL)
- public void testConfigFactoryServlet() throws Exception {
- final String [] paths = { "/foo", "/bar/test" };
- for(String path : paths) {
- final HttpUriRequest get = new HttpGet(C.getBaseUrl() + path);
- HttpResponse response = null;
- try {
- response = client.execute(get);
- assertEquals("Expecting success for " + get.getURI(), 200, response.getStatusLine().getStatusCode());
- } finally {
- U.closeConnection(response);
- }
- }
- }
-
- @Test
- @Retry(timeoutMsec=U.LONG_TIMEOUT_MSEC, intervalMsec=U.STD_INTERVAL)
- public void testJUnitServlet() throws Exception {
- final String path = "/system/sling/junit";
- final HttpUriRequest get = new HttpGet(C.getBaseUrl() + path);
- HttpResponse response = null;
- try {
- response = client.execute(get);
- assertEquals("Expecting JUnit servlet to be installed via sling extension command, at " + get.getURI(), 200, response.getStatusLine().getStatusCode());
- } finally {
- U.closeConnection(response);
- }
- }
-
- @Test
- public void testAdditionalBundles() throws Exception {
- final String [] addBundles = {
- "org.apache.sling.commons.mime",
- "org.apache.sling.settings"
- };
-
- for(String name : addBundles) {
- try {
- osgiConsole.checkBundleInstalled(name, U.LONG_TIMEOUT_SECONDS);
- } catch(AssertionError ae) {
- fail("Expected bundle to be present:" + name);
- }
- }
- }
-
- @Test
- public void testBundlesFromNestedModel() throws Exception {
- final String [] addBundles = {
- "org.apache.sling.commons.threads",
- "org.apache.sling/org.apache.sling.discovery.api"
- };
-
- for(String name : addBundles) {
- try {
- osgiConsole.checkBundleInstalled(name, U.LONG_TIMEOUT_SECONDS);
- } catch(AssertionError ae) {
- fail("Expected bundle to be present:" + name);
- }
- }
- }
-
- @Test
- @Retry(timeoutMsec=U.LONG_TIMEOUT_MSEC, intervalMsec=U.STD_INTERVAL)
- public void testSpecificStartLevel() throws Exception {
- // This bundle should only be installed, as it's set to start level 99
- final String symbolicName = "org.apache.commons.collections";
-
- assertEquals("Expecting bundle " + symbolicName + " to be installed",
- "Installed",
- osgiConsole.getBundleState(symbolicName));
-
- // Start level is in the props array, with key="Start Level"
- final JsonObject status = U.getBundleData(C, client, symbolicName);
- final JsonArray props = status.getJsonArray("data").getJsonObject(0).getJsonArray("props");
- final String KEY = "key";
- final String SL = "Start Level";
- boolean found = false;
- for(int i=0; i < props.size(); i++) {
- final JsonObject o = props.getJsonObject(i);
- if(o.containsKey(KEY) && SL.equals(o.getString(KEY))) {
- found = true;
- assertEquals("Expecting the start level that's set in provisioning model", 99, o.getInt("value"));
- }
- }
- assertTrue("Expecting start level to be found in JSON output", found);
- }
-
- @Test
- @Retry(timeoutMsec=U.LONG_TIMEOUT_MSEC, intervalMsec=U.STD_INTERVAL)
- public void testEmptyConfig() throws Exception {
- U.setAdminCredentials(client);
- U.assertHttpGet(C, client,
- "/test/config/empty.config.should.work",
- "empty.config.should.work#service.pid=(String)empty.config.should.work##EOC#");
- }
-
- @Test
- @Retry(timeoutMsec=U.LONG_TIMEOUT_MSEC, intervalMsec=U.STD_INTERVAL)
- public void testFelixFormatConfig() throws Exception {
- U.setAdminCredentials(client);
- U.assertHttpGet(C, client,
- "/test/config/felix.format.test",
- "felix.format.test#array=(String[])[foo, bar.from.launcher.test]#mongouri=(String)mongodb://localhost:27017#service.pid=(String)felix.format.test#service.ranking.launcher.test=(Integer)54321##EOC#");
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/crankstart/launcher/NestedModelsMergerTest.java b/src/test/java/org/apache/sling/crankstart/launcher/NestedModelsMergerTest.java
deleted file mode 100644
index 005946b..0000000
--- a/src/test/java/org/apache/sling/crankstart/launcher/NestedModelsMergerTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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 org.apache.sling.crankstart.launcher;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.apache.sling.provisioning.model.Artifact;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(Parameterized.class)
-public class NestedModelsMergerTest {
- private final NestedModelsMerger merger = new NestedModelsMerger(null);
- private final Artifact testArtifact;
- private final boolean expectNestedModel;
-
- @Parameters(name="{0}/{1}")
- public static Collection<Object[]> data() {
- return Arrays.asList(new Object[][] {
- { "txt", "slingfeature", true },
- { "txt", "slingstart", true },
- { "slingfeature", null, true },
- { "slingstart", null, true },
- { "txt", null, false }
- });
- }
-
- public NestedModelsMergerTest(String aType, String classifier, boolean expectNestedModel) {
- testArtifact = new Artifact("GID", "AId", "VERSION", classifier, aType);
- this.expectNestedModel = expectNestedModel;
- }
-
- @Test
- public void testNestedModelOrNot() {
- if(expectNestedModel) {
- assertTrue("Expecting a nested model for " + testArtifact, merger.isNestedModel(testArtifact));
- } else {
- assertFalse("Not expecting a nested model for " + testArtifact, merger.isNestedModel(testArtifact));
- }
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/crankstart/launcher/PreemptiveAuthInterceptor.java b/src/test/java/org/apache/sling/crankstart/launcher/PreemptiveAuthInterceptor.java
deleted file mode 100644
index 03e9848..0000000
--- a/src/test/java/org/apache/sling/crankstart/launcher/PreemptiveAuthInterceptor.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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 org.apache.sling.crankstart.launcher;
-
-import java.io.IOException;
-
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.AuthState;
-import org.apache.http.auth.Credentials;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.protocol.ClientContext;
-import org.apache.http.impl.auth.BasicScheme;
-import org.apache.http.protocol.ExecutionContext;
-import org.apache.http.protocol.HttpContext;
-
-/** It's not like httpclient 4.1 makes this simple... */
-class PreemptiveAuthInterceptor implements HttpRequestInterceptor {
-
- public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
-
- AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
- CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(ClientContext.CREDS_PROVIDER);
- HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
-
- // If not auth scheme has been initialized yet
- if (authState.getAuthScheme() == null) {
- AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort());
-
- // Obtain credentials matching the target host
- Credentials creds = credsProvider.getCredentials(authScope);
-
- // If found, generate BasicScheme preemptively
- if (creds != null) {
- authState.setAuthScheme(new BasicScheme());
- authState.setCredentials(creds);
- }
- }
- }
-}
diff --git a/src/test/java/org/apache/sling/crankstart/launcher/RunModeAIT.java b/src/test/java/org/apache/sling/crankstart/launcher/RunModeAIT.java
deleted file mode 100644
index 198748a..0000000
--- a/src/test/java/org/apache/sling/crankstart/launcher/RunModeAIT.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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 org.apache.sling.crankstart.launcher;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.sling.commons.testing.junit.Retry;
-import org.apache.sling.commons.testing.junit.RetryRule;
-import org.apache.sling.crankstart.junit.CrankstartSetup;
-import org.apache.sling.testing.tools.osgi.WebconsoleClient;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-
-/** Test our run modes support */
-public class RunModeAIT {
-
- @ClassRule
- public static CrankstartSetup C = new CrankstartSetup().withModelResources(U.DEFAULT_MODELS);
-
- private WebconsoleClient osgiConsole;
- private DefaultHttpClient client;
- private static final String RUN_MODES = "foo,bar,A";
-
- @Rule
- public final RetryRule retryRule = new RetryRule();
-
- @BeforeClass
- public static void setupClass() throws Exception {
- System.setProperty(RunModeFilter.SLING_RUN_MODES, RUN_MODES);
- }
-
- @Before
- public void setup() throws IOException {
- osgiConsole = new WebconsoleClient(C.getBaseUrl(), U.ADMIN, U.ADMIN);
- client = new DefaultHttpClient();
- }
-
- @AfterClass
- public static void cleanupClass() {
- System.clearProperty(RunModeFilter.SLING_RUN_MODES);
- }
-
- @Test
- @Retry(timeoutMsec=U.LONG_TIMEOUT_MSEC, intervalMsec=U.STD_INTERVAL)
- public void testSlingApiVersionA() throws Exception {
- assertEquals("2.9.0", osgiConsole.getBundleVersion(U.SLING_API_BUNDLE));
- }
-
- @Test
- @Retry(timeoutMsec=U.LONG_TIMEOUT_MSEC, intervalMsec=U.STD_INTERVAL)
- public void testConfigA() throws Exception {
- U.setAdminCredentials(client);
- U.assertHttpGet(C, client,
- "/test/config/runmode.test",
- "runmode.test#mode=(String)This is A#service.pid=(String)runmode.test##EOC#");
- }
-
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/crankstart/launcher/RunModeBIT.java b/src/test/java/org/apache/sling/crankstart/launcher/RunModeBIT.java
deleted file mode 100644
index cdf62ce..0000000
--- a/src/test/java/org/apache/sling/crankstart/launcher/RunModeBIT.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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 org.apache.sling.crankstart.launcher;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.sling.commons.testing.junit.Retry;
-import org.apache.sling.commons.testing.junit.RetryRule;
-import org.apache.sling.crankstart.junit.CrankstartSetup;
-import org.apache.sling.testing.tools.osgi.WebconsoleClient;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-
-/** Test our run modes support */
-public class RunModeBIT {
-
- @ClassRule
- public static CrankstartSetup C = new CrankstartSetup().withModelResources(U.DEFAULT_MODELS);
-
- private WebconsoleClient osgiConsole;
- private DefaultHttpClient client;
- private static final String RUN_MODES = "bala,B,laika,another";
-
- @Rule
- public final RetryRule retryRule = new RetryRule();
-
- @BeforeClass
- public static void setupClass() throws Exception {
- System.setProperty(RunModeFilter.SLING_RUN_MODES, RUN_MODES);
- }
-
- @Before
- public void setup() throws IOException {
- osgiConsole = new WebconsoleClient(C.getBaseUrl(), U.ADMIN, U.ADMIN);
- client = new DefaultHttpClient();
- }
-
- @AfterClass
- public static void cleanupClass() {
- System.clearProperty(RunModeFilter.SLING_RUN_MODES);
- }
-
- @Test
- @Retry(timeoutMsec=U.LONG_TIMEOUT_MSEC, intervalMsec=U.STD_INTERVAL)
- public void testSlingApiVersionA() throws Exception {
- assertEquals("2.0.6", osgiConsole.getBundleVersion(U.SLING_API_BUNDLE));
- }
-
- @Test
- @Retry(timeoutMsec=U.LONG_TIMEOUT_MSEC, intervalMsec=U.STD_INTERVAL)
- public void testConfigA() throws Exception {
- U.setAdminCredentials(client);
- U.assertHttpGet(C, client,
- "/test/config/runmode.test",
- "runmode.test#mode=(String)That's B + another#service.pid=(String)runmode.test##EOC#");
- }
-
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/crankstart/launcher/U.java b/src/test/java/org/apache/sling/crankstart/launcher/U.java
deleted file mode 100644
index 1220813..0000000
--- a/src/test/java/org/apache/sling/crankstart/launcher/U.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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 org.apache.sling.crankstart.launcher;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
-import java.io.StringReader;
-
-import javax.json.Json;
-import javax.json.JsonException;
-import javax.json.JsonObject;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.util.EntityUtils;
-import org.apache.sling.crankstart.junit.CrankstartSetup;
-import org.apache.sling.testing.tools.http.RequestBuilder;
-import org.apache.sling.testing.tools.http.RequestExecutor;
-
-/** General testing utilities and constants */
-public class U {
-
- public static final String ADMIN = "admin";
- public static final int LONG_TIMEOUT_SECONDS = 10;
- public static final int LONG_TIMEOUT_MSEC = LONG_TIMEOUT_SECONDS * 1000;
- public static final int STD_INTERVAL = 250;
- public static final String SLING_API_BUNDLE = "org.apache.sling.api";
-
- static final String [] DEFAULT_MODELS = {
- "/crankstart-model.txt",
- "/provisioning-model/base.txt",
- "/provisioning-model/sling-extensions.txt",
- "/provisioning-model/start-level-99.txt",
- "/provisioning-model/crankstart-tests.txt"
- };
-
- static void setAdminCredentials(DefaultHttpClient c) {
- c.getCredentialsProvider().setCredentials(
- AuthScope.ANY,
- new UsernamePasswordCredentials(ADMIN, ADMIN));
- c.addRequestInterceptor(new PreemptiveAuthInterceptor(), 0);
- }
-
- static void closeConnection(HttpResponse r) throws IOException {
- if(r != null && r.getEntity() != null) {
- EntityUtils.consume(r.getEntity());
- }
- }
-
- /** Get JSON bundle data from webconsole */
- static JsonObject getBundleData(CrankstartSetup C, DefaultHttpClient client, String symbolicName)
- throws ClientProtocolException, IOException, JsonException {
- final RequestBuilder b = new RequestBuilder(C.getBaseUrl());
- final RequestExecutor e = new RequestExecutor(client);
- return Json.createReader(new StringReader((e.execute(
- b.buildGetRequest("/system/console/bundles/" + symbolicName + ".json")
- .withCredentials(U.ADMIN, U.ADMIN))
- ).assertStatus(200).getContent())).readObject();
- }
-
- public static String getContent(HttpResponse response) throws IOException{
-
- final HttpEntity e = response.getEntity();
- if(e == null) {
- throw new IOException("Response does not provide an Entity");
- }
-
- String encoding = "UTF-8";
- if(response.getEntity().getContentEncoding() != null) {
- encoding = response.getEntity().getContentEncoding().getValue();
- }
-
- try {
- return IOUtils.toString(e.getContent(), encoding);
- } finally {
- e.consumeContent();
- }
- }
-
- public static void assertHttpGet(CrankstartSetup C, DefaultHttpClient client, String path, String expectedContent) throws Exception {
- final HttpUriRequest get = new HttpGet(C.getBaseUrl() + path);
- HttpResponse response = null;
- try {
- response = client.execute(get);
- assertEquals("Expecting 200 response at " + path, 200, response.getStatusLine().getStatusCode());
- assertNotNull("Expecting response entity", response.getEntity());
- final String content = getContent(response);
- assertEquals(expectedContent, content);
- } finally {
- U.closeConnection(response);
- }
- }
-}
\ No newline at end of file
diff --git a/src/test/resources/crankstart-model.txt b/src/test/resources/crankstart-model.txt
deleted file mode 100644
index cd6bf12..0000000
--- a/src/test/resources/crankstart-model.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF 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.
-#
-
-# Test the crankstart launcher by setting up an HTTP
-# server with a few servlets that require specific OSGi configurations
-[feature name=:crankstart]
-
-[variables]
- felix.framework.version=5.0.0
- slf4j.version = 1.6.2
- http.port = 8080
- osgi.storage.path = CRANKSTART/felix
- osgi.start.level = 42
-
-[settings]
- org.osgi.service.http.port = ${http.port}
- org.osgi.framework.storage = ${osgi.storage.path}
- org.osgi.framework.startlevel.beginning = ${osgi.start.level}
-
-[artifacts]
- org.apache.felix/org.apache.felix.framework/${felix.framework.version}
- org.slf4j/slf4j-api/${slf4j.version}
- org.slf4j/slf4j-simple/${slf4j.version}
diff --git a/src/test/resources/provisioning-model/base.txt b/src/test/resources/provisioning-model/base.txt
deleted file mode 100644
index 8a53fad..0000000
--- a/src/test/resources/provisioning-model/base.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF 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.
-#
-# This is a feature description
-#
-# A feature consists of variables and run mode dependent artifacts.
-#
-
-# Test our Sling extension commands, that add a bundle via the Sling installer
-# (which requires commons.json and jcr-wrapper)
-[feature name=crankstart.test.base]
-
-[variables]
- felix.http.jetty.version=2.2.0
-
-[artifacts]
- org.apache.felix/org.apache.felix.http.jetty/${felix.http.jetty.version}
- org.apache.felix/org.apache.felix.eventadmin/1.3.2
- org.apache.felix/org.apache.felix.scr/1.8.2
- org.apache.felix/org.apache.felix.metatype/1.0.10
- org.apache.sling/org.apache.sling.commons.osgi/2.2.0
- org.apache.sling/org.apache.sling.commons.log/2.1.2
- org.apache.felix/org.apache.felix.configadmin/1.6.0
- org.apache.felix/org.apache.felix.webconsole/4.3.4
- commons-fileupload/commons-fileupload/1.3.2
diff --git a/src/test/resources/provisioning-model/crankstart-tests.txt b/src/test/resources/provisioning-model/crankstart-tests.txt
deleted file mode 100644
index 281158d..0000000
--- a/src/test/resources/provisioning-model/crankstart-tests.txt
+++ /dev/null
@@ -1,66 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF 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.
-#
-
-[feature name=crankstart.tests]
-
-[variables]
-single.servlet.text = this can be overridden, see BasicLauncherIT
-
-[artifacts]
- org.apache.sling/org.apache.sling.crankstart.test.services/1.9.9-SNAPSHOT
- org.apache.sling/org.apache.sling.junit.core/1.0.10
- org.apache.sling/org.apache.sling.commons.mime/2.1.8
- org.apache.sling/org.apache.sling.settings/1.3.6
-
- # Test a nested model file
- org.apache.sling/org.apache.sling.crankstart.test.model/1.9.9-SNAPSHOT/slingfeature
-
-[artifacts runModes=A]
- org.apache.sling/org.apache.sling.api/2.9.0
-
-[configurations runModes=A]
- runmode.test
- mode="This is A"
-
-[artifacts runModes=B]
- org.apache.sling/org.apache.sling.api/2.0.6
-
-[configurations runModes=B,another]
- runmode.test
- mode="That's B + another"
-
-[configurations]
- org.apache.sling.crankstart.testservices.SingleConfigServlet
- path="/single"
- message="test content is ${single.servlet.text}"
-
- org.apache.sling.crankstart.testservices.ConfigFactoryServlet-foo
- path="/foo"
- message="Not used"
-
- org.apache.sling.crankstart.testservices.ConfigFactoryServlet-bar.test
- path="/bar/test"
- message="Not used"
-
- felix.format.test
- mongouri="mongodb://localhost:27017"
- service.ranking.launcher.test=I"54321"
- array=["foo","bar.from.launcher.test"]
-
- empty.config.should.work
diff --git a/src/test/resources/provisioning-model/sling-extensions.txt b/src/test/resources/provisioning-model/sling-extensions.txt
deleted file mode 100644
index a9e5275..0000000
--- a/src/test/resources/provisioning-model/sling-extensions.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF 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.
-#
-
-[feature name=sling.extensions]
-
-[artifacts]
- org.apache.sling/org.apache.sling.installer.core/3.5.0
- org.apache.sling/org.apache.sling.commons.json/2.0.6
- org.apache.sling/org.apache.sling.jcr.jcr-wrapper/2.0.0
- commons-io/commons-io/2.4
diff --git a/src/test/resources/provisioning-model/start-level-99.txt b/src/test/resources/provisioning-model/start-level-99.txt
deleted file mode 100644
index 922a2de..0000000
--- a/src/test/resources/provisioning-model/start-level-99.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF 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.
-#
-# Add a bundle at a start level higher that our framework's to verify
-# that it is installed but not active
-[feature name=startlevel99]
-
-[artifacts startLevel=99]
- commons-collections/commons-collections/3.2.1
diff --git a/src/test/resources/sling-launchpad.txt b/src/test/resources/sling-launchpad.txt
deleted file mode 100644
index 230b981..0000000
--- a/src/test/resources/sling-launchpad.txt
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF 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.
-#
-
-# Start the Sling Launchpad including whatever is required to
-# run the Sling integration tests.
-
-[feature name=sling.launchpad]
-
-[settings]
- org.apache.sling.commons.log.julenabled=true
-
-[artifacts]
- # artifacts that are usually provided by the Sling launchpad
- org.apache.sling/org.apache.sling.launchpad.api/1.1.0
-
- # The launchpad itself
- org.apache.sling/org.apache.sling.launchpad/8/txt/slingfeature
-
-# TODO remove those once nested test-bundles model works
-[artifacts startLevel=2]
- org.apache.sling/org.apache.sling.servlets.compat/1.0.2
- org.apache.sling/org.apache.sling.junit.core/1.0.10
- org.apache.sling/org.apache.sling.junit.remote/1.0.10
- org.apache.sling/org.apache.sling.junit.scriptable/1.0.10
- org.apache.sling/org.apache.sling.launchpad.test-fragment/2.0.8
- org.apache.sling/org.apache.sling.launchpad.test-services-war/2.0.8/war
- org.apache.sling/org.apache.sling.launchpad.test-services/2.0.10
-
-[configurations]
- integrationTestsConfig
- message="This test config should be loaded at startup"
-
- org.apache.sling.servlets.resolver.SlingServletResolver
- # Set the servlet resolver's cache size to zero for testing
- servletresolver.cacheSize=I"0"