Author: bdelacretaz
Date: Thu Apr 30 13:51:15 2009
New Revision: 770225
URL: http://svn.apache.org/viewvc?rev=770225&view=rev
Log:
SLING-946 - more defensive BundleCloner to try and isolate the problem
Modified:
incubator/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/util/BundleCloner.java
Modified:
incubator/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/util/BundleCloner.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/util/BundleCloner.java?rev=770225&r1=770224&r2=770225&view=diff
==============================================================================
---
incubator/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/util/BundleCloner.java
(original)
+++
incubator/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/util/BundleCloner.java
Thu Apr 30 13:51:15 2009
@@ -18,6 +18,7 @@
import java.io.File;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.OutputStream;
import java.util.Properties;
@@ -33,16 +34,33 @@
public void cloneBundle(File bundle, File output, String name, String
symbolicName) throws Exception {
int options = 0;
+ if(!bundle.exists()) {
+ throw new IOException("Bundle to clone not found: " +
bundle.getAbsolutePath());
+ }
+
+ final File parent = output.getParentFile();
+ parent.mkdirs();
+ if(!parent.isDirectory()) {
+ throw new IOException("Unable to create output directory " +
parent.getAbsolutePath());
+ }
+
Properties props = new Properties();
props.put("Bundle-Name", name);
props.put("Bundle-SymbolicName", symbolicName);
File properties =
File.createTempFile(getClass().getSimpleName(), "properties");
- final OutputStream out = new FileOutputStream(properties);
+ OutputStream out = new FileOutputStream(properties);
File classpath[] = null;
try {
props.store(out, getClass().getSimpleName());
+ out.close();
+ out = null;
bnd.doWrap(properties, bundle, output, classpath,
options, null);
+ if(!output.exists()) {
+ throw new IOException(
+ "Output file not found after calling bnd.doWrap
("
+ + output.getAbsolutePath() + ")");
+ }
} finally {
if(out != null) {
out.close();