Several changes in the junit4osgi subproject (copy preparation)
Add LICENCE and NOTICE files
Add licence header
Format the code
The groupId is now org.apache.felix
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@722135 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/LICENSE b/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/LICENSE
@@ -0,0 +1,202 @@
+
+ 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/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/NOTICE b/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/NOTICE
new file mode 100644
index 0000000..34f9403
--- /dev/null
+++ b/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/NOTICE
@@ -0,0 +1,17 @@
+Apache Felix iPOJO junit4osgi Maven Plugin
+Copyright 2008 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.
+
+II. Used Software
+
+This product uses software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+III. License Summary
+- Apache License 2.0
diff --git a/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/pom.xml b/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/pom.xml
index a1798d6..729d27d 100644
--- a/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/pom.xml
+++ b/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/pom.xml
@@ -19,7 +19,7 @@
<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>
- <groupId>org.apache.felix.ipojo.junit4osgi</groupId>
+ <groupId>org.apache.felix</groupId>
<artifactId>maven-junit4osgi-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>1.1.0-SNAPSHOT</version>
@@ -73,9 +73,35 @@
<scope>runtime</scope>
</dependency>
<dependency>
- <groupId>ipojo.examples</groupId>
+ <groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>rat-maven-plugin</artifactId>
+ <configuration>
+ <excludeSubProjects>false</excludeSubProjects>
+ <useEclipseDefaultExcludes>true</useEclipseDefaultExcludes>
+ <useMavenDefaultExcludes>true</useMavenDefaultExcludes>
+ <excludes>
+ <param>doc/*</param>
+ <param>maven-eclipse.xml</param>
+ <param>.checkstyle</param>
+ <param>.externalToolBuilders/*</param>
+ </excludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <configLocation>http://felix.apache.org/ipojo/dev/checkstyle_ipojo.xml</configLocation>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
diff --git a/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/Installer.java b/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/Installer.java
index a7a8078..d98b48a 100644
--- a/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/Installer.java
+++ b/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/Installer.java
@@ -1,4 +1,4 @@
-/*
+/*
* 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
@@ -6,9 +6,9 @@
* 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
@@ -41,37 +41,37 @@
/**
* The list of artifact containing bundles for the junit4osgi framework.
*/
- private List artifacts;
+ private List m_artifacts;
/**
* The current maven project.
*/
- private MavenProject project;
+ private MavenProject m_project;
/**
- * Flag enabling/disbling the deployment of the current
+ * Flag enabling/disabling the deployment of the current
* project artifact.
*/
- private boolean deployCurrent;
+ private boolean m_deployCurrent;
/**
* List of bundle URLs to install.
*/
- private List bundles;
+ private List m_bundles;
/**
- * Creates a Installer
+ * Creates a Installer.
* @param artifacts the list of artifact containing bundles for the junit4osgi framework.
* @param bundles the list of bundle URLs to install
* @param project the current maven project
* @param deployCurrentArtifact flag enabling/disabling the deployment of the current project artifact
*/
public Installer(List artifacts, List bundles, MavenProject project, boolean deployCurrentArtifact) {
- this.artifacts = artifacts;
- this.project = project;
- deployCurrent = deployCurrentArtifact;
- this.bundles = bundles;
+ this.m_artifacts = artifacts;
+ this.m_project = project;
+ m_deployCurrent = deployCurrentArtifact;
+ this.m_bundles = bundles;
}
/**
@@ -109,11 +109,12 @@
/**
* Installs and Starts required bundles.
+ * @param context the bundle context used to deploy bundles.
* @throws BundleException when a bundle cannot be installed or started correctly
*/
private void deployBundles(BundleContext context) throws BundleException {
- for (int i = 0; i < bundles.size(); i++) {
- URL url = (URL) bundles.get(i);
+ for (int i = 0; i < m_bundles.size(); i++) {
+ URL url = (URL) m_bundles.get(i);
Bundle bundle = context.installBundle(url.toString());
bundle.start();
}
@@ -126,8 +127,8 @@
* be found.
*/
private URL getUrlByArtifactId(String id) {
- for (int i = 0; i < artifacts.size(); i++) {
- Artifact artifact = (Artifact) artifacts.get(i);
+ for (int i = 0; i < m_artifacts.size(); i++) {
+ Artifact artifact = (Artifact) m_artifacts.get(i);
if (artifact.getArtifactId().equals(id)) {
try {
return artifact.getFile().toURL();
@@ -145,12 +146,12 @@
* @throws BundleException when the bundle cannot be installed or started correctly.
*/
private void deployProjectArtifact(BundleContext context)
- throws BundleException {
- if (!deployCurrent) {
+ throws BundleException {
+ if (!m_deployCurrent) {
return;
}
- File file = project.getArtifact().getFile();
+ File file = m_project.getArtifact().getFile();
if (file.exists()) {
URL url = null;
try {
@@ -193,4 +194,4 @@
// Do nothing.
}
-}
\ No newline at end of file
+}
diff --git a/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/Junit4osgiPlugin.java b/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/Junit4osgiPlugin.java
index 6af90e8..ce1f378 100644
--- a/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/Junit4osgiPlugin.java
+++ b/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/Junit4osgiPlugin.java
@@ -1,4 +1,4 @@
-/*
+/*
* 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
@@ -6,9 +6,9 @@
* 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
@@ -16,21 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.felix.ipojo.junit4osgi.plugin;/*
-
- *
- * 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.
- */
+package org.apache.felix.ipojo.junit4osgi.plugin;
import java.io.File;
import java.io.PrintStream;
@@ -81,68 +67,98 @@
* @required
* @readonly
*/
- private MavenProject project;
+ private MavenProject m_project;
- /** @parameter expression="${plugin.artifacts}" */
- private java.util.List pluginArtifacts;
+ /**
+ * Dependencies of the current plugin.
+ * @parameter expression="${plugin.artifacts}"
+ */
+ private java.util.List m_pluginArtifacts;
/**
* Base directory where all reports are written to.
*
* @parameter expression="${project.build.directory}/junit4osgi-reports"
*/
- private File reportsDirectory;
+ private File m_reportsDirectory;
/**
* Base directory where all reports are written to.
*
* @parameter expression="${project.build.directory}"
*/
- private File targetDir;
+ private File m_targetDir;
/**
- * Must the current artifact be deployed?.
+ * Must the current artifact be deployed?
*
* @parameter expression="${deployProjectArtifact}" default-value="false"
*/
- private boolean deployProjectArtifact;
+ private boolean m_deployProjectArtifact;
/**
- * Required bundles
+ * Required bundles.
*
* @parameter expression="${bundles}"
*/
- private ArrayList bundles;
-
- int total;
- int totalFailures;
- int totalErrors;
-
- List errors = new ArrayList();
- List failures = new ArrayList();
- List results = new ArrayList();
+ private ArrayList m_bundles;
/**
- * Log Service exposed by the plugin framework.
+ * Number of executed test case.
*/
- private LogServiceImpl logService;
+ private int m_total;
+
+ /**
+ * Number of failing test case.
+ */
+ private int m_totalFailures;
+
+ /**
+ * Number of test case in error .
+ */
+ private int m_totalErrors;
+
+ /**
+ * Test results in error.
+ */
+ private List m_errors = new ArrayList();
+
+ /**
+ * Failing test results.
+ */
+ private List m_failures = new ArrayList();
+
+ /**
+ * Test results.
+ */
+ private List m_results = new ArrayList();
+
+ /**
+ * Log Service exposed by the plug-in framework.
+ */
+ private LogServiceImpl m_logService;
+ /**
+ * Executes the plug-in.
+ * @throws MojoFailureException when the test execution failed.
+ * @see org.apache.maven.plugin.AbstractMojo#execute()
+ */
public void execute() throws MojoFailureException {
List bundles = parseBundleList();
bundles.addAll(getTestBundle());
List activators = new ArrayList();
- logService = new LogServiceImpl();
- activators.add(logService);
- activators.add(new Installer(pluginArtifacts, bundles, project, deployProjectArtifact));
+ m_logService = new LogServiceImpl();
+ activators.add(m_logService);
+ activators.add(new Installer(m_pluginArtifacts, bundles, m_project, m_deployProjectArtifact));
Map map = new HashMap();
map.put("felix.systembundle.activators", activators);
map.put("org.osgi.framework.storage.clean", "onFirstInit");
map.put("ipojo.log.level", "WARNING");
map.put("org.osgi.framework.bootdelegation", "junit.framework, org.osgi.service.log");
- map.put("org.osgi.framework.storage", targetDir.getAbsolutePath() + "/felix-cache");
+ map.put("org.osgi.framework.storage", m_targetDir.getAbsolutePath() + "/felix-cache");
System.out.println("");
@@ -170,19 +186,30 @@
getLog().error(e);
}
- if (totalErrors > 0 || totalFailures > 0) {
- throw new MojoFailureException("There are test failures. \n\n" +
- "Please refer to " + reportsDirectory.getAbsolutePath() +
- " for the individual test results.");
+ if (m_totalErrors > 0 || m_totalFailures > 0) {
+ throw new MojoFailureException("There are test failures. \n\n"
+ + "Please refer to " + m_reportsDirectory.getAbsolutePath()
+ + " for the individual test results.");
}
}
+ /**
+ * Waits for stability:
+ * <ul>
+ * <li>all bundles are activated
+ * <li>service count is stable
+ * </ul>
+ * If the stability can't be reached after a specified time,
+ * the method throws a {@link MojoFailureException}.
+ * @param context the bundle context
+ * @throws MojoFailureException when the stability can't be reach after a several attempts.
+ */
private void waitForStability(BundleContext context) throws MojoFailureException {
// Wait for bundle initialization.
boolean bundleStability = getBundleStability(context);
int count = 0;
- while(!bundleStability && count < 500) {
+ while (!bundleStability && count < 500) {
try {
Thread.sleep(5);
} catch (InterruptedException e) {
@@ -200,15 +227,16 @@
boolean serviceStability = false;
count = 0;
- int count1 = 0, count2 = 0;
- while(! serviceStability && count < 500) {
+ int count1 = 0;
+ int count2 = 0;
+ while (! serviceStability && count < 500) {
try {
ServiceReference[] refs = context.getServiceReferences(null, null);
count1 = refs.length;
Thread.sleep(500);
refs = context.getServiceReferences(null, null);
count2 = refs.length;
- serviceStability = (count1 == count2);
+ serviceStability = count1 == count2;
} catch (Exception e) {
getLog().error(e);
serviceStability = false;
@@ -225,6 +253,11 @@
}
+ /**
+ * Are bundle stables.
+ * @param bc the bundle context
+ * @return <code>true</code> if every bundles are activated.
+ */
private boolean getBundleStability(BundleContext bc) {
boolean stability = true;
Bundle[] bundles = bc.getBundles();
@@ -234,30 +267,39 @@
return stability;
}
+ /**
+ * Computes the URL list of bundles to install from
+ * the <code>bundles</code> parameter.
+ * @return the list of url of bundles to install.
+ */
private List parseBundleList() {
List toDeploy = new ArrayList();
- if (bundles == null) {
+ if (m_bundles == null) {
return toDeploy;
}
- for (int i = 0; i < bundles.size(); i++) {
- String bundle = (String) bundles.get(i);
+ for (int i = 0; i < m_bundles.size(); i++) {
+ String bundle = (String) m_bundles.get(i);
try {
URL url = new URL(bundle);
toDeploy.add(url);
} catch (MalformedURLException e) {
- // Not a valid url,
- getLog().error(bundle + " is not a valid url, bundle ignored");
-
+ // Not a valid url,
+ getLog().error(bundle + " is not a valid url, bundle ignored");
}
}
return toDeploy;
}
+ /**
+ * Computes the URL list of bundles to install from
+ * <code>test</code> scoped dependencies.
+ * @return the list of url of bundles to install.
+ */
private List getTestBundle() {
List toDeploy = new ArrayList();
- Set dependencies = project.getDependencyArtifacts();
+ Set dependencies = m_project.getDependencyArtifacts();
for (Iterator artifactIterator = dependencies.iterator(); artifactIterator.hasNext();) {
Artifact artifact = (Artifact) artifactIterator.next();
if (Artifact.SCOPE_TEST.equals(artifact.getScope())) { // Select scope=test.
@@ -275,6 +317,12 @@
return toDeploy;
}
+ /**
+ * Waits until the {@link OSGiJunitRunner} service
+ * is published.
+ * @param bc the bundle context
+ * @return the {@link OSGiJunitRunner} service object.
+ */
private Object waitForRunnerService(BundleContext bc) {
ServiceReference ref = bc.getServiceReference(org.apache.felix.ipojo.junit4osgi.OSGiJunitRunner.class.getName());
int count = 0;
@@ -293,6 +341,11 @@
return null;
}
+ /**
+ * Executes tests by using reflection.
+ * @param runner the {@link OSGiJunitRunner} service object
+ * @param bc the bundle context
+ */
private void invokeRun(Object runner, BundleContext bc) {
Method getTest;
@@ -301,39 +354,45 @@
List tests = (List) getTest.invoke(runner, new Object[0]);
Method run = getRunMethod(runner);
for (int i = 0; i < tests.size(); i++) {
- executeTest(runner, (Test) tests.get(i),run, bc);
+ executeTest(runner, (Test) tests.get(i), run, bc);
}
System.out.println("\nResults :");
- if (failures.size() > 0) {
+ if (m_failures.size() > 0) {
System.out.println("\nFailed tests:");
- for (int i = 0; i < failures.size(); i++) {
- TestResult tr = (TestResult) failures.get(i);
+ for (int i = 0; i < m_failures.size(); i++) {
+ TestResult tr = (TestResult) m_failures.get(i);
Enumeration e = tr.failures();
- while(e.hasMoreElements()) {
+ while (e.hasMoreElements()) {
TestFailure tf = (TestFailure) e.nextElement();
System.out.println(" " + tf.toString());
}
}
}
- if (failures.size() > 0) {
+ if (m_failures.size() > 0) {
System.out.println("\nTests in error:");
- for (int i = 0; i < errors.size(); i++) {
- TestResult tr = (TestResult) errors.get(i);
+ for (int i = 0; i < m_errors.size(); i++) {
+ TestResult tr = (TestResult) m_errors.get(i);
Enumeration e = tr.errors();
- while(e.hasMoreElements()) {
+ while (e.hasMoreElements()) {
TestFailure tf = (TestFailure) e.nextElement();
System.out.println(" " + tf.toString());
}
}
}
- System.out.println("\nTests run: " + total + ", Failures: " + totalFailures + ", Errors:" + totalErrors + "\n");
+ System.out.println("\nTests run: " + m_total + ", Failures: " + m_totalFailures + ", Errors:" + m_totalErrors + "\n");
} catch (Exception e) {
getLog().error(e);
}
}
+ /**
+ * Gets the {@link OSGiJunitRunner#run(long)} method from the
+ * {@link OSGiJunitRunner} service object.
+ * @param runner the {@link OSGiJunitRunner} service object.
+ * @return the Method object for the <code>run</code> method.
+ */
private Method getRunMethod(Object runner) {
Method[] methods = runner.getClass().getMethods();
for (int i = 0; i < methods.length; i++) {
@@ -347,6 +406,14 @@
return null;
}
+ /**
+ * Computes the name of the given test.
+ * This method calls the {@link TestCase#getName()}
+ * method by reflection. If no success, invokes the
+ * {@link Object#toString()} method.
+ * @param test the test object.
+ * @return the name of the given test.
+ */
private String getTestName(Object test) {
try {
Method getName = test.getClass().getMethod("getName", new Class[0]);
@@ -362,43 +429,69 @@
}
- private void executeTest(Object runner, Test test, Method run, BundleContext bc) {
+ /**
+ * Executes the given test.
+ * @param runner the {@link OSGiJunitRunner} service object
+ * @param test the test to run
+ * @param run the {@link OSGiJunitRunner#run(long)} method
+ * @param bc the bundle context
+ */
+ private void executeTest(Object runner, Test test, Method run,
+ BundleContext bc) {
try {
- XMLReport report = new XMLReport();
- String name = getTestName(test);
- System.out.println("Running " + name);
+ XMLReport report = new XMLReport();
+ String name = getTestName(test);
+ System.out.println("Running " + name);
- TestResult tr = new TestResult();
- tr.addListener(new ResultListener(report));
- test.run(tr);
- results.add(tr);
-
- if (tr.wasSuccessful()) {
- System.out.println("Tests run: " + tr.runCount() + ", Failures: " + tr.failureCount() + ", Errors: " + tr.errorCount() + ", Time elapsed: " + report.elapsedTimeAsString(report.endTime - report.endTime) + " sec");
- } else {
- System.out.println("Tests run: " + tr.runCount() + ", Failures: " + tr.failureCount() + ", Errors: " + tr.errorCount() + ", Time elapsed: " + report.elapsedTimeAsString(report.endTime - report.endTime) + " sec <<< FAILURE!");
- if (tr.errorCount() > 0) {
- errors.add(tr);
+ TestResult tr = new TestResult();
+ tr.addListener(new ResultListener(report));
+ test.run(tr);
+ m_results.add(tr);
+
+ if (tr.wasSuccessful()) {
+ System.out.println("Tests run: "
+ + tr.runCount()
+ + ", Failures: "
+ + tr.failureCount()
+ + ", Errors: "
+ + tr.errorCount()
+ + ", Time elapsed: "
+ + report.elapsedTimeAsString(report.m_endTime
+ - report.m_endTime) + " sec");
+ } else {
+ System.out.println("Tests run: "
+ + tr.runCount()
+ + ", Failures: "
+ + tr.failureCount()
+ + ", Errors: "
+ + tr.errorCount()
+ + ", Time elapsed: "
+ + report.elapsedTimeAsString(report.m_endTime
+ - report.m_endTime) + " sec <<< FAILURE!");
+ if (tr.errorCount() > 0) {
+ m_errors.add(tr);
+ }
+ if (tr.failureCount() > 0) {
+ m_failures.add(tr);
+ }
}
- if (tr.failureCount() > 0) {
- failures.add(tr);
- }
- }
-
- total += tr.runCount();
- totalFailures += tr.failureCount();
- totalErrors += tr.errorCount();
-
- report.generateReport(test, tr, reportsDirectory, bc);
-
+
+ m_total += tr.runCount();
+ m_totalFailures += tr.failureCount();
+ m_totalErrors += tr.errorCount();
+
+ report.generateReport(test, tr, m_reportsDirectory, bc);
+
} catch (Exception e) {
getLog().error(e);
}
-
-
-
+
}
+ /**
+ * Prints the bundle list.
+ * @param bc the bundle context.
+ */
public void dumpBundles(BundleContext bc) {
getLog().info("Bundles:");
Bundle[] bundles = bc.getBundles();
@@ -408,51 +501,99 @@
}
public LogServiceImpl getLogService() {
- return logService;
+ return m_logService;
}
private class ResultListener implements TestListener {
- private XMLReport report;
- private boolean abort;
+ /**
+ * The XML Report.
+ */
+ private XMLReport m_report;
- private PrintStream outBackup = System.out;
- private PrintStream errBackup = System.err;
+ /**
+ * Check if the test has failed or thrown an
+ * error.
+ */
+ private boolean m_abort;
- private StringOutputStream out = new StringOutputStream();
- private StringOutputStream err = new StringOutputStream();;
+ /**
+ * Backup of the {@link System#out} stream.
+ */
+ private PrintStream m_outBackup = System.out;
+ /**
+ * Backup of the {@link System#err} stream.
+ */
+ private PrintStream m_errBackup = System.err;
+
+ /**
+ * The output stream used during the test execution.
+ */
+ private StringOutputStream m_out = new StringOutputStream();
+
+ /**
+ * The error stream used during the test execution.
+ */
+ private StringOutputStream m_err = new StringOutputStream();;
+
+ /**
+ * Creates a ResultListener.
+ * @param report the XML report
+ */
public ResultListener(XMLReport report) {
- this.report = report;
+ this.m_report = report;
}
+ /**
+ * An error occurs during the test execution.
+ * @param test the test in error
+ * @param throwable the thrown error
+ * @see junit.framework.TestListener#addError(junit.framework.Test, java.lang.Throwable)
+ */
public void addError(Test test, Throwable throwable) {
- report.testError(test, throwable, out.toString(), err.toString(), getLogService().getLoggedMessages());
- abort = true;
+ m_report.testError(test, throwable, m_out.toString(), m_err.toString(), getLogService().getLoggedMessages());
+ m_abort = true;
}
+ /**
+ * An failure occurs during the test execution.
+ * @param test the failing test
+ * @param assertionfailederror the failure
+ * @see junit.framework.TestListener#addFailure(junit.framework.Test, junit.framework.AssertionFailedError)
+ */
public void addFailure(Test test,
AssertionFailedError assertionfailederror) {
- report.testFailed(test, assertionfailederror, out.toString(), err.toString(), getLogService().getLoggedMessages());
- abort = true;
+ m_report.testFailed(test, assertionfailederror, m_out.toString(), m_err.toString(), getLogService().getLoggedMessages());
+ m_abort = true;
}
+ /**
+ * The test ends.
+ * @param test the test
+ * @see junit.framework.TestListener#endTest(junit.framework.Test)
+ */
public void endTest(Test test) {
- if (!abort) {
- report.testSucceeded(test);
- }
- System.setErr(errBackup);
- System.setOut(outBackup);
- getLogService().reset();
+ if (!m_abort) {
+ m_report.testSucceeded(test);
+ }
+ System.setErr(m_errBackup);
+ System.setOut(m_outBackup);
+ getLogService().reset();
}
+ /**
+ * The test starts.
+ * @param test the test
+ * @see junit.framework.TestListener#startTest(junit.framework.Test)
+ */
public void startTest(Test test) {
- abort = false;
- report.testStarting();
- System.setErr(new PrintStream(err));
- System.setOut(new PrintStream(out));
+ m_abort = false;
+ m_report.testStarting();
+ System.setErr(new PrintStream(m_err));
+ System.setOut(new PrintStream(m_out));
getLogService().enableOutputStream();
}
diff --git a/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/Report.java b/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/Report.java
index cbb8905..16ab48b 100644
--- a/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/Report.java
+++ b/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/Report.java
@@ -1,4 +1,4 @@
-/*
+/*
* 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
@@ -6,9 +6,9 @@
* 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
@@ -37,57 +37,57 @@
public class Report {
/**
- * Number of ran tests.
+ * New line constant.
*/
- protected int completedCount;
+ protected static final String NL = System.getProperty("line.separator");
/**
- * Number of errors
+ * Number of ran tests.
*/
- protected int errorsCount;
+ protected int m_completedCount;
+
+ /**
+ * Number of errors.
+ */
+ protected int m_errorsCount;
/**
- * Number of failures
+ * Number of failures.
*/
- protected int failuresCount;
+ protected int m_failuresCount;
/**
- * Failing tests.
- */
- private List failureSources = new ArrayList();
-
- /**
- * Tests in error
- */
- private List errorSources = new ArrayList();
-
- /**
* Time at the beginning of the test execution.
*/
- protected long startTime;
+ protected long m_startTime;
/**
* Time at the end of the test execution.
*/
- protected long endTime;
+ protected long m_endTime;
/**
+ * Failing tests.
+ */
+ private List m_failureSources = new ArrayList();
+
+ /**
+ * Tests in error.
+ */
+ private List m_errorSources = new ArrayList();
+
+ /**
* Double format.
*/
- private NumberFormat numberFormat = NumberFormat.getInstance( Locale.US );
+ private NumberFormat m_numberFormat = NumberFormat.getInstance(Locale.US);
/**
- * New line constant.
- */
- protected static final String NL = System.getProperty( "line.separator" );
-
- /**
* Gets failing tests.
* @return the list of failing tests.
*/
public List getFailureSources() {
- return this.failureSources;
+ return this.m_failureSources;
}
/**
@@ -95,14 +95,14 @@
* @return the list of test throwing unexpected exceptions
*/
public List getErrorSources() {
- return this.errorSources;
+ return this.m_errorSources;
}
/**
* Callback called when a test starts.
*/
public void testStarting() {
- startTime = System.currentTimeMillis();
+ m_startTime = System.currentTimeMillis();
}
/**
@@ -117,8 +117,8 @@
* @param test the test in error.
*/
public void testError(Test test) {
- ++errorsCount;
- errorSources.add(test.toString());
+ ++m_errorsCount;
+ m_errorSources.add(test.toString());
endTest();
}
@@ -127,8 +127,8 @@
* @param test the failing test.
*/
public void testFailed(Test test) {
- ++failuresCount;
- failureSources.add(test.toString());
+ ++m_failuresCount;
+ m_failureSources.add(test.toString());
endTest();
}
@@ -137,41 +137,41 @@
* This method handles common action when a test ends.
*/
private void endTest() {
- ++completedCount;
+ ++m_completedCount;
- endTime = System.currentTimeMillis();
+ m_endTime = System.currentTimeMillis();
- if (startTime == 0) {
- startTime = endTime;
+ if (m_startTime == 0) {
+ m_startTime = m_endTime;
}
}
public int getNumErrors() {
- return errorsCount;
+ return m_errorsCount;
}
public int getNumFailures() {
- return failuresCount;
+ return m_failuresCount;
}
public int getNumTests() {
- return completedCount;
+ return m_completedCount;
}
/**
* Reset the report.
*/
public void reset() {
- errorsCount = 0;
+ m_errorsCount = 0;
- failuresCount = 0;
+ m_failuresCount = 0;
- completedCount = 0;
+ m_completedCount = 0;
- this.failureSources = new ArrayList();
+ this.m_failureSources = new ArrayList();
- this.errorSources = new ArrayList();
+ this.m_errorSources = new ArrayList();
}
@@ -182,13 +182,14 @@
* @return the String displaying the elapsed time
*/
protected String elapsedTimeAsString(long runTime) {
- return numberFormat.format((double) runTime / 1000);
+ return m_numberFormat.format((double) runTime / 1000);
}
/**
- * Returns the stacktrace as String.
- * @param report ReportEntry object.
- * @return stacktrace as string.
+ * Returns the stack trace as String.
+ * @param test the test
+ * @param e the exception
+ * @return stack trace as string.
*/
protected String getStackTrace(Test test, Throwable e) {
diff --git a/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/StringOutputStream.java b/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/StringOutputStream.java
index 60186cf..fa0a1f7 100644
--- a/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/StringOutputStream.java
+++ b/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/StringOutputStream.java
@@ -1,3 +1,21 @@
+/*
+ * 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.ipojo.junit4osgi.plugin;
import java.io.OutputStream;
@@ -6,6 +24,7 @@
/**
* Provides an OutputStream to an internal String. Internally converts bytes to
* a Strings and stores them in an internal StringBuffer.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
public class StringOutputStream extends OutputStream implements Serializable {
@@ -17,14 +36,14 @@
/**
* The internal destination StringBuffer.
*/
- protected StringBuffer buf = null;
+ protected StringBuffer m_buffer = null;
/**
* Creates new StringOutputStream, makes a new internal StringBuffer.
*/
public StringOutputStream() {
super();
- buf = new StringBuffer();
+ m_buffer = new StringBuffer();
}
/**
@@ -34,14 +53,14 @@
* @return returns the content of the internal StringBuffer
*/
public String toString() {
- return buf.toString();
+ return m_buffer.toString();
}
/**
* Sets the internal StringBuffer to null.
*/
public void close() {
- buf = null;
+ m_buffer = null;
}
@@ -62,7 +81,7 @@
bytes[i] = b[off];
off++;
}
- buf.append(toCharArray(bytes));
+ m_buffer.append(toCharArray(bytes));
}
/**
@@ -71,7 +90,7 @@
* @param b the byte as an int to add
*/
public void write(int b) {
- buf.append((char) b);
+ m_buffer.append((char) b);
}
/**
@@ -80,11 +99,14 @@
* @param s the String to add
*/
public void write(String s) {
- buf.append(s);
+ m_buffer.append(s);
}
/**
* Converts byte array to char array.
+ * @param barr input byte array
+ * @return the char array corresponding to the
+ * given byte array
*/
public static char[] toCharArray(byte[] barr) {
if (barr == null) {
diff --git a/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/XMLReport.java b/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/XMLReport.java
index 6d3a722..88e72ec 100644
--- a/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/XMLReport.java
+++ b/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/XMLReport.java
@@ -1,4 +1,4 @@
-/*
+/*
* 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
@@ -6,9 +6,9 @@
* 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
@@ -51,7 +51,7 @@
/**
* List of results.
*/
- private List results = new ArrayList();
+ private List m_results = new ArrayList();
/**
* A test ends successfully.
@@ -60,17 +60,20 @@
public void testSucceeded(Test test) {
super.testSucceeded();
- long runTime = this.endTime - this.startTime;
+ long runTime = this.m_endTime - this.m_startTime;
Xpp3Dom testCase = createTestElement(test, runTime);
- results.add(testCase);
+ m_results.add(testCase);
}
/**
* A test throws an unexpected errors.
* @param test the test in error
* @param e the thrown exception
+ * @param out the output messages printed during the test execution
+ * @param err the error messages printed during the test execution
+ * @param log the messages logged during the test execution
*/
public void testError(Test test, Throwable e, String out, String err, String log) {
super.testError(test);
@@ -82,6 +85,9 @@
* A test fails.
* @param test the failing test
* @param e the thrown failure
+ * @param out the output messages printed during the test execution
+ * @param err the error messages printed during the test execution
+ * @param log the messages logged during the test execution
*/
public void testFailed(Test test, Throwable e, String out, String err, String log) {
super.testFailed(test);
@@ -94,10 +100,13 @@
* @param test the test
* @param e the thrown error
* @param name type of failure ("error" or "failure")
+ * @param out the output messages printed during the test execution
+ * @param err the error messages printed during the test execution
+ * @param log the messages logged during the test execution
*/
private void writeTestProblems(Test test, Throwable e, String name, String out, String err, String log) {
- long runTime = endTime - startTime;
+ long runTime = m_endTime - m_startTime;
Xpp3Dom testCase = createTestElement(test, runTime);
@@ -115,8 +124,8 @@
element.setAttribute("message", message);
element.setAttribute("type",
- (stackTrace.indexOf(":") > -1 ? stackTrace.substring(0,
- stackTrace.indexOf(":")) : stackTrace));
+ stackTrace.indexOf(":") > -1 ? stackTrace.substring(0,
+ stackTrace.indexOf(":")) : stackTrace);
} else {
element.setAttribute("type", new StringTokenizer(stackTrace)
.nextToken());
@@ -127,13 +136,13 @@
element.setValue(stackTrace);
}
- addOutputStreamElement( out, "system-out", testCase );
+ addOutputStreamElement(out, "system-out", testCase);
- addOutputStreamElement( err, "system-err", testCase );
-
- addOutputStreamElement( log, "log-service", testCase );
+ addOutputStreamElement(err, "system-err", testCase);
- results.add(testCase);
+ addOutputStreamElement(log, "log-service", testCase);
+
+ m_results.add(testCase);
}
/**
@@ -146,7 +155,7 @@
*/
public void generateReport(Test test, TestResult tr, File reportsDirectory,
BundleContext bc) throws Exception {
- long runTime = this.endTime - this.startTime;
+ long runTime = this.m_endTime - this.m_startTime;
Xpp3Dom testSuite = createTestSuiteElement(test, runTime);
@@ -158,7 +167,7 @@
testSuite.setAttribute("failures", String.valueOf(tr.failureCount()));
- for (Iterator i = results.iterator(); i.hasNext();) {
+ for (Iterator i = m_results.iterator(); i.hasNext();) {
Xpp3Dom testcase = (Xpp3Dom) i.next();
testSuite.addChild(testcase);
}
@@ -183,9 +192,7 @@
throw new Exception("Unable to use UTF-8 encoding", e);
} catch (FileNotFoundException e) {
throw new Exception("Unable to create file: " + e.getMessage(), e);
- }
-
- finally {
+ } finally {
IOUtil.close(writer);
}
}
@@ -231,7 +238,7 @@
}
/**
- * Creates an XML element
+ * Creates an XML element.
* @param element the parent element
* @param name the name of the element to create
* @return the resulting XML tree.
@@ -294,6 +301,8 @@
case Bundle.UNINSTALLED:
state = "UNINSTALLED";
break;
+ default:
+ break;
}
Xpp3Dom bundle = createElement(buns, "bundle");
bundle.setAttribute("symbolic-name", sn);
@@ -302,6 +311,13 @@
}
+ /**
+ * Adds messages written during the test execution in the
+ * XML tree.
+ * @param stdOut the messages
+ * @param name the name of the stream (out, error, log)
+ * @param testCase the XML tree
+ */
private void addOutputStreamElement(String stdOut, String name,
Xpp3Dom testCase) {
if (stdOut != null && stdOut.trim().length() > 0) {
diff --git a/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/log/LogServiceImpl.java b/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/log/LogServiceImpl.java
index aaa6fe0..bb795ac 100644
--- a/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/log/LogServiceImpl.java
+++ b/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/log/LogServiceImpl.java
@@ -1,4 +1,4 @@
-/*
+/*
* 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
@@ -6,9 +6,9 @@
* 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
@@ -35,25 +35,25 @@
/**
* Default output stream (not collected).
*/
- private StringOutputStream defaultStream;
+ private StringOutputStream m_defaultStream;
/**
* Collected output stream.
*/
- private StringOutputStream outputStream;
+ private StringOutputStream m_outputStream;
/**
* Creates the log service object.
*/
public LogServiceImpl() {
- defaultStream = new StringOutputStream();
+ m_defaultStream = new StringOutputStream();
}
/**
* Enables the log messages collection.
*/
public void enableOutputStream() {
- outputStream = new StringOutputStream();
+ m_outputStream = new StringOutputStream();
}
/**
@@ -61,14 +61,14 @@
* @return the String containing the logged messages.
*/
public String getLoggedMessages() {
- return outputStream.toString();
+ return m_outputStream.toString();
}
/**
* Re-initializes the collected message list.
*/
public void reset() {
- outputStream = null;
+ m_outputStream = null;
}
/**
@@ -138,6 +138,8 @@
case LogService.LOG_WARNING:
message = "[WARNING] " + msg;
break;
+ default:
+ break;
}
if (exception != null) {
@@ -152,10 +154,10 @@
* @param log the message
*/
public void write(String log) {
- if (outputStream != null) {
- outputStream.write(log);
+ if (m_outputStream != null) {
+ m_outputStream.write(log);
} else {
- defaultStream.write(log);
+ m_defaultStream.write(log);
}
}