removing old test, before renaming test2 into test ...
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1532435 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/test/LICENSE b/dependencymanager/test/LICENSE
deleted file mode 100644
index d645695..0000000
--- a/dependencymanager/test/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/dependencymanager/test/NOTICE b/dependencymanager/test/NOTICE
deleted file mode 100644
index cfc3633..0000000
--- a/dependencymanager/test/NOTICE
+++ /dev/null
@@ -1,26 +0,0 @@
-Apache Felix Dependency Manager
-Copyright 2009 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-This product includes software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2007).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2007).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/dependencymanager/test/pom.xml b/dependencymanager/test/pom.xml
deleted file mode 100644
index cfc3afc..0000000
--- a/dependencymanager/test/pom.xml
+++ /dev/null
@@ -1,134 +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/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.felix</groupId>
- <artifactId>felix-parent</artifactId>
- <version>1.2.0</version>
- <relativePath>../../pom/pom.xml</relativePath>
- </parent>
- <properties>
- <osgi.version>4.2.0</osgi.version>
- <pax.exam.version>1.2.0</pax.exam.version>
- </properties>
- <name>Apache Felix Dependency Manager Integration Tests</name>
- <artifactId>org.apache.felix.dependencymanager.test</artifactId>
- <version>3.0.1-SNAPSHOT</version>
- <dependencies>
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>org.apache.felix.dependencymanager</artifactId>
- <version>3.1.1-SNAPSHOT</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>org.apache.felix.dependencymanager.annotation</artifactId>
- <version>3.1.1-SNAPSHOT</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>org.apache.felix.dependencymanager.runtime</artifactId>
- <version>3.1.1-SNAPSHOT</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>org.apache.felix.dependencymanager.shell</artifactId>
- <version>3.0.2-SNAPSHOT</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>org.apache.felix.shell</artifactId>
- <version>1.4.2</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>${osgi.version}</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>${osgi.version}</version>
- </dependency>
- <dependency>
- <groupId>biz.aQute</groupId>
- <artifactId>bndlib</artifactId>
- <version>2.0.0.20130123-133441</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam</artifactId>
- <version>${pax.exam.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-container-default</artifactId>
- <version>${pax.exam.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit</artifactId>
- <version>${pax.exam.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.7</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- <useDefaultManifestFile>false</useDefaultManifestFile>
- <compilerArgument>-g</compilerArgument>
- <compilerVersion>1.5</compilerVersion>
- </configuration>
- <executions>
- <execution>
- <id>default-testCompile</id>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>maven-paxexam-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-config</id>
- <goals>
- <goal>generate-depends-file</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/sequencer/Sequencer.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/sequencer/Sequencer.java
deleted file mode 100644
index a4723e9..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/sequencer/Sequencer.java
+++ /dev/null
@@ -1,49 +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.felix.dm.test.bundle.annotation.sequencer;
-
-/**
- * Service used to ensure that steps happen in the expected order.
- */
-public interface Sequencer
-{
- /**
- * Proceed with the next step.
- */
- void step();
-
- /**
- * Crosses a given step.
- * @param step the step we are crossing
- */
- void step(int step);
-
- /**
- * Wait for a given step to occur.
- * @param nr the step we are waiting for
- * @param timeout max milliseconds to wait.
- */
- void waitForStep(int step, int timeout);
-
- /**
- * Saves a thrown exception that occurred in a different thread. You can only save one exception
- * at a time this way.
- */
- void throwable(Throwable throwable);
-}
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/Base.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/Base.java
deleted file mode 100644
index 101e163..0000000
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/Base.java
+++ /dev/null
@@ -1,195 +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.felix.dm.test;
-
-import java.io.File;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.net.URL;
-
-import org.junit.After;
-import org.junit.Before;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.FrameworkListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-
-/**
- * Base class for all test cases.
- */
-public class Base implements LogService, FrameworkListener {
- public static final String OSGI_SPEC_VERSION = "4.2.0";
- private final static int LOG_LEVEL = LogService.LOG_WARNING;
- private volatile boolean m_errorsLogged;
-
- /**
- * Register us as a LogService
- *
- * @param context
- */
- @Before
- public void startup(BundleContext context) {
- context.registerService(LogService.class.getName(), this, null);
- context.addFrameworkListener(this);
- }
-
- /**
- * Always cleanup our bundle location file (because pax seems to forget to
- * cleanup it)
- *
- * @param context
- */
-
- @After
- public void tearDown(BundleContext context) {
- // The following code forces the temporary bundle files (from /tmp/tb/*)
- // to be deleted when jvm exits
- // (this patch seems to be only required with pax examp 2.0.0)
-
- try {
- File f = new File(new URL(context.getBundle().getLocation()).getPath());
- f.deleteOnExit();
- } catch (Throwable t) {
- t.printStackTrace();
- }
- context.removeFrameworkListener(this);
- }
-
- /**
- * Suspend the current thread for a while.
- *
- * @param n
- * the number of milliseconds to wait for.
- */
- protected void sleep(int ms) {
- try {
- Thread.sleep(ms);
- } catch (InterruptedException e) {
- }
- }
-
- public void log(int level, String message) {
- checkError(level, null);
- if (LOG_LEVEL >= level) {
- System.out.println(getLevel(level) + " " + message);
- }
- }
-
- public void log(int level, String message, Throwable exception) {
- checkError(level, exception);
- if (LOG_LEVEL >= level) {
- StringBuilder sb = new StringBuilder();
- sb.append(getLevel(level) + " ");
- sb.append(message);
- parse(sb, exception);
- System.out.println(sb.toString());
- }
- }
-
- public void log(ServiceReference sr, int level, String message) {
- checkError(level, null);
- if (LOG_LEVEL >= level) {
- StringBuilder sb = new StringBuilder();
- sb.append(getLevel(level) + " ");
- sb.append(message);
- System.out.println(sb.toString());
- }
- }
-
- public void log(ServiceReference sr, int level, String message, Throwable exception) {
- checkError(level, exception);
- if (LOG_LEVEL >= level) {
- StringBuilder sb = new StringBuilder();
- sb.append(getLevel(level) + " ");
- sb.append(message);
- parse(sb, exception);
- System.out.println(sb.toString());
- }
- }
-
- protected boolean errorsLogged() {
- return m_errorsLogged;
- }
-
- private void parse(StringBuilder sb, Throwable t) {
- if (t != null) {
- sb.append(" - ");
- StringWriter buffer = new StringWriter();
- PrintWriter pw = new PrintWriter(buffer);
- t.printStackTrace(pw);
- sb.append(buffer.toString());
- m_errorsLogged = true;
- }
- }
-
- private String getLevel(int level) {
- switch (level) {
- case LogService.LOG_DEBUG:
- return "DEBUG";
- case LogService.LOG_ERROR:
- return "ERROR";
- case LogService.LOG_INFO:
- return "INFO";
- case LogService.LOG_WARNING:
- return "WARN";
- default:
- return "";
- }
- }
-
- private void checkError(int level, Throwable exception) {
- if (level >= LOG_ERROR) {
- m_errorsLogged = true;
- }
- if (exception != null) {
- m_errorsLogged = true;
- }
- }
-
- public void frameworkEvent(FrameworkEvent event) {
- int eventType = event.getType();
- String msg = getFrameworkEventMessage(eventType);
- int level = (eventType == FrameworkEvent.ERROR) ? LOG_ERROR : LOG_WARNING;
- if (msg != null) {
- log(level, msg, event.getThrowable());
- } else {
- log(level, "Unknown fwk event: " + event);
- }
- }
-
- private String getFrameworkEventMessage(int event) {
- switch (event) {
- case FrameworkEvent.ERROR:
- return "FrameworkEvent: ERROR";
- case FrameworkEvent.INFO:
- return "FrameworkEvent INFO";
- case FrameworkEvent.PACKAGES_REFRESHED:
- return "FrameworkEvent: PACKAGE REFRESHED";
- case FrameworkEvent.STARTED:
- return "FrameworkEvent: STARTED";
- case FrameworkEvent.STARTLEVEL_CHANGED:
- return "FrameworkEvent: STARTLEVEL CHANGED";
- case FrameworkEvent.WARNING:
- return "FrameworkEvent: WARNING";
- default:
- return null;
- }
- }
-}
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/BundleGenerator.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/BundleGenerator.java
deleted file mode 100644
index 1218a9a..0000000
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/BundleGenerator.java
+++ /dev/null
@@ -1,190 +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.felix.dm.test;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.net.URL;
-import java.util.Properties;
-
-import aQute.bnd.osgi.Analyzer;
-import aQute.bnd.osgi.Builder;
-import aQute.bnd.osgi.Jar;
-
-/**
- * Helper used to generate a bundle dynamically.
- */
-public class BundleGenerator
-{
- /**
- * The Bnd directives
- */
- private Properties _directives = new Properties();
-
- /**
- * The class loader used to get the classpath where to collect the bundle classes
- */
- private ClassLoader _classLoader = BundleGenerator.class.getClassLoader();
-
- /**
- * Sets a Bnd directive
- * @param attributeName the directive name (can start with a "-")
- * @param attributeValue the directive value
- * @return ourself
- */
- public BundleGenerator set(String attributeName, String attributeValue)
- {
- _directives.put(attributeName, attributeValue);
- return this;
- }
-
- /**
- * Sets a specific class loader, which will be used to get the classpath where to collect
- * the bundle classes. By default, the class loader used is the BundleGenerator class loader.
- * @param cl the class loader that will be used to get the bundle classpath
- * @return ourself
- */
- public BundleGenerator setClassLoader(ClassLoader cl)
- {
- _classLoader = cl;
- return this;
- }
-
- /**
- * Generates the output bundle
- * @return the bundle URL, as a String
- */
- public String build()
- {
- try
- {
- // Check if the system tmp dir exists
-
- File tmp = new File(System.getProperty("java.io.tmpdir"));
- if (!tmp.exists())
- {
- if (! tmp.mkdirs())
- {
- throw new IOException("Could not create temporary directory: " + tmp);
- }
- }
-
- // Deduce the classpath from Export-Package, or Private-Package headers.
-
- String pkg = _directives.getProperty("Export-Package");
- if (pkg == null)
- {
- pkg = _directives.getProperty("Private-Package");
- }
- if (pkg == null)
- {
- throw new IllegalArgumentException("You must either specify a Private-Package, or an Export-Package directive");
- }
-
- String classpath = getClassPath(pkg);
-
- // Create the bundle output file
-
- File output = File.createTempFile("DMTestBundle", ".jar");
- output.deleteOnExit();
-
- // Create the bnd directive file
-
- File directives = File.createTempFile("DMTestBnd", ".bnd");
- directives.deleteOnExit();
-
- // Write the directives into the bnd file.
-
- PrintWriter pw = new PrintWriter(new FileWriter(directives));
- try
- {
- for (Object key : _directives.keySet())
- {
- Object value = _directives.get(key);
- if (key.toString().startsWith("-"))
- {
- pw.println(key.toString() + " " + value.toString());
- }
- else
- {
- pw.println(key.toString() + ": " + value.toString());
- }
- }
- }
-
- finally
- {
- pw.close();
- }
-
- // Launch Bnd in order to generate our tiny test bundle.
-
- buildWithBnd(_directives, classpath, output);
-
- // Return the URL of the generated bundle, as a String.
-
- return output.toURI().toURL().toString();
- }
-
- catch (RuntimeException e)
- {
- throw e;
- }
-
- catch (Throwable t)
- {
- throw new RuntimeException("Unexpected exception while generating DM test bundle", t);
- }
- }
-
- /**
- * Invoke Bnd builder for generating the target tiny bundle.
- */
- private void buildWithBnd(Properties directives, String classpath, File output)
- throws Exception
- {
- Builder builder = new Builder();
- builder.setProperty(Analyzer.FAIL_OK, "true");
- builder.setProperties(directives);
- builder.setClasspath(new String[] { classpath });
- Jar jar = builder.build();
- jar.setName(output.getName());
- jar.write(output);
- builder.close();
- }
-
- /**
- * Gets the bundle classpath, where the bundle classes will be collected.
- * @param pkg either an exported package, or a private package.
- * @return the bundle classpath
- */
- private String getClassPath(String pkg)
- {
- String pkgPath = pkg.replaceAll("\\.", "/");
- URL pkgURL = _classLoader.getResource(pkgPath);
- if (pkgURL == null)
- {
- throw new IllegalArgumentException("Could not find package " + pkg + " in classpath");
- }
- int i = pkgURL.getPath().indexOf(pkgPath);
- return i == -1 ? pkgURL.getPath() : pkgURL.getPath().substring(0, i);
- }
-}
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/Ensure.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/Ensure.java
deleted file mode 100644
index 1e3b29d..0000000
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/Ensure.java
+++ /dev/null
@@ -1,167 +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.felix.dm.test;
-
-import java.io.PrintStream;
-
-import junit.framework.Assert;
-
-/**
- * Helper class to make sure that steps in a test happen in the correct order. Instantiate
- * this class and subsequently invoke <code>step(nr)</code> with steps starting at 1. You
- * can also have threads wait until you arrive at a certain step.
- */
-public class Ensure {
- private static final boolean DEBUG = true;
- private static long INSTANCE = 0;
- private static final int RESOLUTION = 100;
- private static PrintStream STREAM = System.out;
- int step = 0;
- private Throwable m_throwable;
-
- public Ensure() {
- if (DEBUG) {
- INSTANCE++;
- }
- }
-
- public void setStream(PrintStream output) {
- STREAM = output;
- }
-
- /**
- * Mark this point as step <code>nr</code>.
- *
- * @param nr the step we are in
- */
- public synchronized void step(int nr) {
- step++;
- Assert.assertEquals(nr, step);
- if (DEBUG) {
- String info = getLineInfo(3);
- STREAM.println("[Ensure " + INSTANCE + "] step " + step + " [" + currentThread() + "] " + info);
- }
- notifyAll();
- }
-
- private String getLineInfo(int depth) {
- StackTraceElement[] trace = Thread.currentThread().getStackTrace();
- String info = trace[depth].getClassName() + "." + trace[depth].getMethodName() + ":" + trace[depth].getLineNumber();
- return info;
- }
-
- /**
- * Mark this point as the next step.
- */
- public synchronized void step() {
- step++;
- if (DEBUG) {
- String info = getLineInfo(3);
- STREAM.println("[Ensure " + INSTANCE + "] next step " + step + " [" + currentThread() + "] " + info);
- }
- notifyAll();
- }
-
- /**
- * Wait until we arrive at least at step <code>nr</code> in the process, or fail if that
- * takes more than <code>timeout</code> milliseconds. If you invoke wait on a thread,
- * you are effectively assuming some other thread will invoke the <code>step(nr)</code>
- * method.
- *
- * @param nr the step to wait for
- * @param timeout the number of milliseconds to wait
- */
- public synchronized void waitForStep(int nr, int timeout) {
- final int initialTimeout = timeout;
- if (DEBUG) {
- String info = getLineInfo(3);
- STREAM.println("[Ensure " + INSTANCE + "] waiting for step " + nr + " [" + currentThread() + "] " + info);
- }
- while (step < nr && timeout > 0) {
- try {
- wait(RESOLUTION);
- timeout -= RESOLUTION;
- }
- catch (InterruptedException e) {}
- }
- if (step < nr) {
- throw new IllegalStateException("Timed out waiting for " + initialTimeout + " ms for step " + nr + ", we are still at step " + step);
- }
- if (DEBUG) {
- String info = getLineInfo(3);
- STREAM.println("[Ensure " + INSTANCE + "] arrived at step " + nr + " [" + currentThread() + "] " + info);
- }
- }
-
- private String currentThread() {
- Thread thread = Thread.currentThread();
- return thread.getId() + " " + thread.getName();
- }
-
- public static Runnable createRunnableStep(final Ensure ensure, final int nr) {
- return new Runnable() { public void run() { ensure.step(nr); }};
- }
-
- public synchronized void steps(Steps steps) {
- steps.next(this);
- }
-
- /**
- * Helper class for naming a list of step numbers. If used with the steps(Steps) method
- * you can define at which steps in time this point should be passed. That means you can
- * check methods that will get invoked multiple times during a test.
- */
- public static class Steps {
- private final int[] m_steps;
- private int m_stepIndex;
-
- /**
- * Create a list of steps and initialize the step counter to zero.
- */
- public Steps(int... steps) {
- m_steps = steps;
- m_stepIndex = 0;
- }
-
- /**
- * Ensure we're at the right step. Will throw an index out of bounds exception if we enter this step more often than defined.
- */
- public void next(Ensure ensure) {
- ensure.step(m_steps[m_stepIndex++]);
- }
- }
-
- /**
- * Saves a thrown exception that occurred in a different thread. You can only save one exception
- * at a time this way.
- */
- public synchronized void throwable(Throwable throwable) {
- m_throwable = throwable;
- }
-
- /**
- * Throws a <code>Throwable</code> if one occurred in a different thread and that thread saved it
- * using the <code>throwable()</code> method.
- */
- public synchronized void ensure() throws Throwable {
- if (m_throwable != null) {
- throw m_throwable;
- }
- }
-}
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/AnnotationBase.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/AnnotationBase.java
deleted file mode 100644
index a90b788..0000000
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/AnnotationBase.java
+++ /dev/null
@@ -1,121 +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.felix.dm.test.annotation;
-
-import java.util.Hashtable;
-
-import org.apache.felix.dm.Component;
-import org.apache.felix.dm.DependencyManager;
-import org.apache.felix.dm.test.Base;
-import org.apache.felix.dm.test.Ensure;
-import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-
-/**
- * Base class for all annotation junit test classes. The class implements a Sequencer interface,
- * which wraps an "Ensure" object. The Sequencer will be used directly by the tiny bundles, in order to
- * check if steps happen in the expected order.
- */
-public class AnnotationBase extends Base implements Sequencer
-{
- /**
- * Name of the system property telling if the DM runtime bundle must wait for the log service
- * availability before starting. By default, the log service is replaced by a NullObject
- * if it is not available.
- */
- public static String DMLOG_PROPERTY = "dm.runtime.log";
-
- /**
- * The object used to check if expected steps happen in the correct order.
- */
- protected Ensure m_ensure = new Ensure();
-
- /**
- * Helper method used to stop a given bundle.
- * @param symbolicName the symbolic name of the bundle to be stopped.
- * @param context the context used to lookup all installed bundles.
- */
- protected void stopBundle(String symbolicName, BundleContext context)
- {
- // Stop the test.annotation bundle
- boolean found = false;
- for (Bundle b : context.getBundles())
- {
- if (b.getSymbolicName().equals(symbolicName))
- {
- try
- {
- found = true;
- b.stop();
- }
- catch (BundleException e)
- {
- e.printStackTrace();
- }
- }
- }
- if (!found)
- {
- throw new IllegalStateException("bundle " + symbolicName + " not found");
- }
- }
-
- /**
- * Provide a Sequencer with a name service property.
- */
- protected Component makeSequencer(DependencyManager m, String name)
- {
- Hashtable props = new Hashtable();
- props.put("name", name);
- return m.createComponent().setImplementation(this).setInterface(Sequencer.class.getName(), props);
- }
-
- // ----------------------- Sequencer interface ------------------------------------------
-
- /**
- * Goes to the next step.
- */
- public void step()
- {
- m_ensure.step();
- }
-
- /**
- * Crosses a given step number.
- */
- public void step(int step)
- {
- m_ensure.step(step);
- }
-
- /**
- * Waits for a given step to happen.
- */
- public void waitForStep(int nr, int timeout)
- {
- m_ensure.waitForStep(nr, timeout);
- }
-
- public void throwable(Throwable throwable)
- {
- m_ensure.throwable(throwable);
- }
-}