Author: rob.stryker(a)jboss.com
Date: 2008-03-27 22:11:47 -0400 (Thu, 27 Mar 2008)
New Revision: 7166
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/truezip-6.6.jar
trunk/core/tests/org.jboss.ide.eclipse.archives.test/inputs/projects/basicwebproject/.classpath
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelTest.java
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelTruezipBridgeTest.java
Removed:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/truezip-6.jar
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/.classpath
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/META-INF/MANIFEST.MF
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/build.properties
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelException.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchive.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ArchivesTestSuite.java
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelCreationTest.java
Log:
Updated truezip to 6.6 for more threadsafe fun.
More unit tests. yay.
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/.classpath
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/.classpath 2008-03-27 22:56:39
UTC (rev 7165)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/.classpath 2008-03-28 02:11:47
UTC (rev 7166)
@@ -3,12 +3,12 @@
<classpathentry kind="src" path="src/main"/>
<classpathentry kind="src" path="src/xml"/>
<classpathentry kind="src" path="src/eclipse"/>
+ <classpathentry exported="true" kind="lib"
path="lib/truezip-6.6.jar"
sourcepath="/home/rob/Desktop/truezip-6-src.zip"/>
<classpathentry exported="true" kind="lib"
path="lib/jboss-common-core-2.2.1.GA.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/jboss-common-logging-log4j-2.0.4.GA.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/jboss-common-logging-spi-2.0.4.GA.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/xercesImpl-2.9.1.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/concurrent-1.3.4.jar"/>
- <classpathentry exported="true" kind="lib"
path="lib/truezip-6.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/jboss-xml-binding.jar"
sourcepath="/home/rob/code/xb/target/jboss-xml-binding-sources.jar"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/META-INF/MANIFEST.MF 2008-03-27
22:56:39 UTC (rev 7165)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/META-INF/MANIFEST.MF 2008-03-28
02:11:47 UTC (rev 7166)
@@ -16,13 +16,13 @@
Eclipse-LazyStart: true
Bundle-ClassPath: archivescore.jar,
archivescore-eclipse.jar,
- lib/truezip-6.jar,
lib/concurrent-1.3.4.jar,
lib/jboss-xml-binding.jar,
lib/xercesImpl-2.9.1.jar,
lib/jboss-common-logging-log4j-2.0.4.GA.jar,
lib/jboss-common-logging-spi-2.0.4.GA.jar,
- lib/jboss-common-core-2.2.1.GA.jar
+ lib/jboss-common-core-2.2.1.GA.jar,
+ lib/truezip-6.6.jar
Export-Package:
de.schlichtherle.io;x-friends:="org.jboss.ide.eclipse.archives.test",
org.jboss.ide.eclipse.archives.core,
org.jboss.ide.eclipse.archives.core.ant,
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/build.properties
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/build.properties 2008-03-27
22:56:39 UTC (rev 7165)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/build.properties 2008-03-28
02:11:47 UTC (rev 7166)
@@ -6,12 +6,12 @@
log4j.xml,\
archivescore-eclipse.jar,\
lib/jboss-xml-binding.jar,\
- lib/truezip-6.jar,\
lib/concurrent-1.3.4.jar,\
lib/xercesImpl-2.9.1.jar,\
lib/jboss-common-logging-log4j-2.0.4.GA.jar,\
lib/jboss-common-logging-spi-2.0.4.GA.jar,\
- lib/jboss-common-core-2.2.1.GA.jar
+ lib/jboss-common-core-2.2.1.GA.jar,\
+ lib/truezip-6.6.jar
source.archivescore.jar = src/main/,\
src/xml/
src.includes = LICENSE-truezip.txt,\
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/truezip-6.6.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/truezip-6.6.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/truezip-6.jar
===================================================================
(Binary files differ)
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelException.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelException.java 2008-03-27
22:56:39 UTC (rev 7165)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelException.java 2008-03-28
02:11:47 UTC (rev 7166)
@@ -25,7 +25,7 @@
* @author rob.stryker <rob.stryker(a)redhat.com>
*
*/
-public class ArchivesModelException extends Exception {
+public class ArchivesModelException extends RuntimeException {
private Exception parent;
public ArchivesModelException(String message) {
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchive.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchive.java 2008-03-27
22:56:39 UTC (rev 7165)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchive.java 2008-03-28
02:11:47 UTC (rev 7166)
@@ -58,7 +58,9 @@
public boolean isExploded();
/**
- * @return Whether or not this package is a "top-level" package aka, not a
child of another folder or package
+ * @return Whether or not this package is a "top-level" package
+ * aka, not a child of another folder or package
+ * IOW: The parent must be null or a model node
*/
public boolean isTopLevel();
@@ -77,15 +79,21 @@
public IPath getArchiveFilePath();
/**
- * The absolute raw file system path to the
- * destination (containing folder) of this archive
+ * If top level:
+ * The absolute raw file system path to the
+ * destination (containing folder) of this archive
+ * Else
+ * The empty path
* @return An IPath to this package's destination folder
*/
public IPath getGlobalDestinationPath();
/**
- * A path representing the string from the delegate
- * May be work-space relative or global
+ * If top level:
+ * A path representing the string from the delegate
+ * May be work-space relative or global
+ * Else
+ * The empty path
* @return
*/
public IPath getDestinationPath();
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java 2008-03-27
22:56:39 UTC (rev 7165)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java 2008-03-28
02:11:47 UTC (rev 7166)
@@ -31,7 +31,6 @@
import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor;
import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
import org.jboss.ide.eclipse.archives.core.model.INamedContainerArchiveNode;
import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackage;
@@ -73,8 +72,10 @@
* @see IArchive#getDestinationPath()
*/
public IPath getGlobalDestinationPath () {
- if (packageDelegate.getToDir() == null ||
packageDelegate.getToDir().equals("."))
- return getProjectPath() == null ? null : getProjectPath();
+ if (!isTopLevel() || packageDelegate.getToDir() == null ||
packageDelegate.getToDir().equals(""))
+ return Path.EMPTY;
+ if( packageDelegate.getToDir().equals("."))
+ return getProjectPath() == null ? Path.EMPTY : getProjectPath();
if (isDestinationInWorkspace()) {
return ModelUtil.workspacePathToAbsolutePath(new Path(packageDelegate.getToDir()));
@@ -83,7 +84,9 @@
}
public IPath getDestinationPath() {
- return packageDelegate.getToDir() == null ? null : new
Path(packageDelegate.getToDir());
+ if( !isTopLevel() )
+ return Path.EMPTY;
+ return packageDelegate.getToDir() == null ? Path.EMPTY : new
Path(packageDelegate.getToDir());
}
/*
@@ -175,7 +178,8 @@
* @see IArchive#isTopLevel()
*/
public boolean isTopLevel() {
- return (packageDelegate.getParent() instanceof XbPackages);
+ return (packageDelegate.getParent() == null ||
+ packageDelegate.getParent() instanceof XbPackages);
}
/*
Added:
trunk/core/tests/org.jboss.ide.eclipse.archives.test/inputs/projects/basicwebproject/.classpath
===================================================================
---
trunk/core/tests/org.jboss.ide.eclipse.archives.test/inputs/projects/basicwebproject/.classpath
(rev 0)
+++
trunk/core/tests/org.jboss.ide.eclipse.archives.test/inputs/projects/basicwebproject/.classpath 2008-03-28
02:11:47 UTC (rev 7166)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con"
path="org.eclipse.jst.j2ee.internal.web.container"/>
+ <classpathentry kind="output" path="build/classes"/>
+</classpath>
Modified:
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ArchivesTestSuite.java
===================================================================
---
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ArchivesTestSuite.java 2008-03-27
22:56:39 UTC (rev 7165)
+++
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ArchivesTestSuite.java 2008-03-28
02:11:47 UTC (rev 7166)
@@ -5,6 +5,7 @@
import org.jboss.ide.eclipse.archives.test.core.ArchivesCoreTest;
import org.jboss.ide.eclipse.archives.test.model.ModelCreationTest;
+import org.jboss.ide.eclipse.archives.test.model.ModelTruezipBridgeTest;
import org.jboss.ide.eclipse.archives.test.model.ModelUtilTest;
import org.jboss.ide.eclipse.archives.test.model.XBMarshallTest;
import org.jboss.ide.eclipse.archives.test.model.XBUnmarshallTest;
@@ -19,6 +20,7 @@
suite.addTestSuite(TruezipUtilTest.class);
suite.addTestSuite(ModelUtilTest.class);
suite.addTestSuite(ModelCreationTest.class);
+ suite.addTestSuite(ModelTruezipBridgeTest.class);
return suite;
}
Modified:
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelCreationTest.java
===================================================================
---
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelCreationTest.java 2008-03-27
22:56:39 UTC (rev 7165)
+++
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelCreationTest.java 2008-03-28
02:11:47 UTC (rev 7166)
@@ -21,15 +21,12 @@
*/
package org.jboss.ide.eclipse.archives.test.model;
-import junit.framework.TestCase;
-
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
-import org.jboss.ide.eclipse.archives.core.model.ArchiveNodeFactory;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
@@ -50,7 +47,7 @@
* @author rob.stryker <rob.stryker(a)redhat.com>
*
*/
-public class ModelCreationTest extends TestCase {
+public class ModelCreationTest extends ModelTest {
protected IPath project = new Path("test").append("project");
TempArchiveModelListener modelListener = createListener();
protected void setUp() throws Exception {
@@ -501,7 +498,7 @@
return;
} finally {
try {
- proj.delete(false, true, null);
+ proj.delete(true, true, null);
} catch( CoreException ce ) {fail();}
}
}
@@ -519,54 +516,22 @@
}
return;
}
-// public void testDeltas() {
-// try {
-// ArchiveModelNode model = createModelNode();
-// model.clearDelta();
-// IArchiveFolder folder = ArchiveNodeFactory.createFolder();
-// folder.setName("testFolder");
-// model.addChild(folder);
-// IArchiveNodeDelta delta = model.getDelta();
-// assertEquals(IArchiveNodeDelta.CHILD_ADDED, delta.getKind());
-// } catch( ArchivesModelException ame ) {
-// fail(ame.getMessage());
-// }
-// }
-
-
-
-
- /*
- * Utility methods
- */
- protected IArchiveFolder createFolder(String name) {
- IArchiveFolder folder = ArchiveNodeFactory.createFolder();
- folder.setName(name);
- return folder;
+
+
+
+ protected TempArchiveModelListener createListener() {
+ return new TempArchiveModelListener();
}
- protected IArchiveFileSet createFileSet(String includes, String path) {
- IArchiveFileSet fs = ArchiveNodeFactory.createFileset();
- fs.setIncludesPattern(includes);
- fs.setSourcePath(new Path(path));
- return fs;
+ protected class TempArchiveModelListener implements IArchiveModelListener {
+ private IArchiveNodeDelta delta;
+ public void modelChanged(IArchiveNodeDelta delta) {
+ this.delta = delta;
+ }
+ public IArchiveNodeDelta getDelta() { return delta; }
+ public void clearDelta() { delta = null; }
}
- protected IArchiveAction createAction() {
- IArchiveAction action = ArchiveNodeFactory.createAction();
- action.setTime(IArchiveAction.POST_BUILD);
- action.setType("ant");
- return action;
- }
-
- protected IArchive createArchive(String name, String dest) {
- IArchive archive = ArchiveNodeFactory.createArchive();
- archive.setName(name);
- archive.setDestinationPath(new Path(dest));
- return archive;
- }
-
-
protected ArchiveModelNode createModelNode() {
try {
XbPackages packs = new XbPackages();
@@ -609,6 +574,7 @@
return null;
}
+
protected ArchiveModelNode getModel(XbPackages packs) {
IArchiveModel model = new ArchivesModel();
model.addModelListener(modelListener);
@@ -616,16 +582,4 @@
return node;
}
- protected TempArchiveModelListener createListener() {
- return new TempArchiveModelListener();
- }
-
- protected class TempArchiveModelListener implements IArchiveModelListener {
- private IArchiveNodeDelta delta;
- public void modelChanged(IArchiveNodeDelta delta) {
- this.delta = delta;
- }
- public IArchiveNodeDelta getDelta() { return delta; }
- public void clearDelta() { delta = null; }
- }
}
Added:
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelTest.java
===================================================================
---
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelTest.java
(rev 0)
+++
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelTest.java 2008-03-28
02:11:47 UTC (rev 7166)
@@ -0,0 +1,67 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.test.model;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.Path;
+import org.jboss.ide.eclipse.archives.core.model.ArchiveNodeFactory;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveAction;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
+
+/**
+ * @author rob.stryker <rob.stryker(a)redhat.com>
+ *
+ */
+public abstract class ModelTest extends TestCase {
+ /*
+ * Utility methods
+ */
+ protected IArchiveFolder createFolder(String name) {
+ IArchiveFolder folder = ArchiveNodeFactory.createFolder();
+ folder.setName(name);
+ return folder;
+ }
+
+ protected IArchiveFileSet createFileSet(String includes, String path) {
+ IArchiveFileSet fs = ArchiveNodeFactory.createFileset();
+ fs.setIncludesPattern(includes);
+ fs.setSourcePath(new Path(path));
+ return fs;
+ }
+
+ protected IArchiveAction createAction() {
+ IArchiveAction action = ArchiveNodeFactory.createAction();
+ action.setTime(IArchiveAction.POST_BUILD);
+ action.setType("ant");
+ return action;
+ }
+
+ protected IArchive createArchive(String name, String dest) {
+ IArchive archive = ArchiveNodeFactory.createArchive();
+ archive.setName(name);
+ archive.setDestinationPath(new Path(dest));
+ return archive;
+ }
+}
Added:
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelTruezipBridgeTest.java
===================================================================
---
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelTruezipBridgeTest.java
(rev 0)
+++
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelTruezipBridgeTest.java 2008-03-28
02:11:47 UTC (rev 7166)
@@ -0,0 +1,161 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.test.model;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
+
+import junit.framework.AssertionFailedError;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.util.internal.ModelTruezipBridge;
+import org.jboss.ide.eclipse.archives.core.util.internal.TrueZipUtil;
+import org.jboss.ide.eclipse.archives.test.ArchivesTest;
+import org.jboss.tools.test.util.ResourcesUtils;
+import org.osgi.framework.Bundle;
+
+/**
+ * This class will test the individual portions
+ * of the build process.
+ *
+ * @author rob.stryker <rob.stryker(a)redhat.com>
+ */
+public class ModelTruezipBridgeTest extends ModelTest {
+ IProject proj = null;
+ private Bundle bundle;
+ private IPath bundlePath;
+ private IPath outputs;
+ protected void setUp() throws Exception {
+ if( bundlePath == null ) {
+ try {
+ bundle = ArchivesTest.getDefault().getBundle();
+ URL bundleURL = FileLocator.toFileURL(bundle.getEntry(""));
+ bundlePath = new Path(bundleURL.getFile());
+ outputs = bundlePath.append("output");
+ } catch( IOException ioe) {
+ fail("Failed to set up " + getClass().getName());
+ }
+ }
+
+ proj = ResourcesUtils.importProject("org.jboss.ide.eclipse.archives.test",
"/inputs/projects/GenericProject");
+ proj.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ }
+ protected void tearDown() throws Exception {
+ proj.delete(true,true,null);
+ File out = outputs.toFile();
+ File[] children = out.listFiles();
+ for( int i = 0; i < children.length; i++ ) {
+ TrueZipUtil.deleteAll(new Path(children[i].toString()));
+ }
+ }
+
+ public void testCreateFileOutsideWorkspace() {
+ // exploded
+ IArchive exploded = createArchive("exploded.war", outputs.toString());
+ exploded.setInWorkspace(false);
+ exploded.setExploded(true);
+ ModelTruezipBridge.createFile(exploded);
+ File explodedF = outputs.append("exploded.war").toFile();
+ assertTrue(explodedF.exists());
+ assertTrue(explodedF.isDirectory());
+
+ // zipped
+ IArchive zipped = createArchive("zipped.war", outputs.toString());
+ zipped.setInWorkspace(false);
+ zipped.setExploded(false);
+ ModelTruezipBridge.createFile(zipped);
+ File zipF = outputs.append("zipped.war").toFile();
+ assertTrue(zipF.exists());
+ assertFalse(zipF.isDirectory());
+
+ // exploded inside exploded
+ IArchive explodedInExploded = createArchive("explodedInExploded.jar",
"");
+ explodedInExploded.setExploded(true);
+ exploded.addChild(explodedInExploded);
+ ModelTruezipBridge.createFile(explodedInExploded);
+ File eIeF =
exploded.getGlobalDestinationPath().append("exploded.war").append("explodedInExploded.jar").toFile();
+ assertTrue(eIeF.exists());
+
+ // zip inside exploded
+ IArchive ZipInExploded = createArchive("zipInExploded.jar", "");
+ ZipInExploded.setExploded(false);
+ exploded.addChild(ZipInExploded);
+ ModelTruezipBridge.createFile(ZipInExploded);
+ File zIeF =
exploded.getGlobalDestinationPath().append("exploded.war").append("zipInExploded.jar").toFile();
+ assertTrue(zIeF.exists());
+ assertFalse(zIeF.isDirectory());
+
+
+ // exploded inside zip
+ IArchive explodedInZip = createArchive("ExplodedInZip.jar", "");
+ explodedInZip.setExploded(true);
+ zipped.addChild(explodedInZip);
+ ModelTruezipBridge.createFile(explodedInZip);
+ try {
+ assertEquals(1, countEntries(zipF));
+ } catch( AssertionFailedError re ) {
+ System.out.println("gah");
+ }
+ // zip inside zip
+ IArchive zipInZip = createArchive("zipInZip.jar", "");
+ zipInZip.setExploded(false);
+ zipped.addChild(zipInZip);
+ ModelTruezipBridge.createFile(zipInZip);
+ assertEquals(2, countEntries(zipF));
+ }
+
+ protected int countEntries(File zipF) {
+
+ ZipFile zf = null;
+ try {
+ zf = new ZipFile(zipF);
+ } catch (ZipException e) {
+ fail();
+ } catch (IOException e) {
+ fail();
+ }
+
+ int count = 0;
+ Enumeration entries = zf.entries();
+ while(entries.hasMoreElements()) {
+ entries.nextElement();
+ count++;
+ }
+ try {
+ zf.close();
+ } catch( IOException ioe) {
+ fail();
+ }
+ return count;
+ }
+
+}