Author: rob.stryker(a)jboss.com
Date: 2010-10-11 03:23:07 -0400 (Mon, 11 Oct 2010)
New Revision: 25704
Added:
trunk/archives/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/projects/InnerZipResourceTimestampTest.java
Modified:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/TrueZipUtil.java
trunk/archives/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ArchivesTestSuite.java
trunk/archives/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelTest.java
Log:
JBIDE-7199 - timestamp error for nested zipped resources
Modified:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/TrueZipUtil.java
===================================================================
---
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/TrueZipUtil.java 2010-10-11
04:30:35 UTC (rev 25703)
+++
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/TrueZipUtil.java 2010-10-11
07:23:07 UTC (rev 25704)
@@ -57,7 +57,7 @@
public static boolean copyFile(String source, de.schlichtherle.io.File file) {
file.getParentFile().mkdirs();
- boolean b = new de.schlichtherle.io.File(source).copyAllTo(file);
+ boolean b = new de.schlichtherle.io.File(source).archiveCopyAllTo(file);
return b && updateParentTimestamps(file);
}
@@ -143,7 +143,7 @@
}
public static boolean updateParentTimestamps(de.schlichtherle.io.File file) {
long time = System.currentTimeMillis();
- de.schlichtherle.io.File parent = file.getEnclArchive();
+ de.schlichtherle.io.File parent = file;
boolean b = true;
while( parent != null ) {
b &= parent.setLastModified(time);
Modified:
trunk/archives/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ArchivesTestSuite.java
===================================================================
---
trunk/archives/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ArchivesTestSuite.java 2010-10-11
04:30:35 UTC (rev 25703)
+++
trunk/archives/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ArchivesTestSuite.java 2010-10-11
07:23:07 UTC (rev 25704)
@@ -22,6 +22,7 @@
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;
+import org.jboss.ide.eclipse.archives.test.projects.InnerZipResourceTimestampTest;
import org.jboss.ide.eclipse.archives.test.projects.JBIDE1406Test;
import org.jboss.ide.eclipse.archives.test.projects.JBIDE2099Test;
import org.jboss.ide.eclipse.archives.test.projects.JBIDE2296Test;
@@ -52,8 +53,8 @@
suite.addTestSuite(JBIDE2311Test.class);
suite.addTestSuite(JBIDE2315Test.class);
suite.addTestSuite(JBIDE2439Test.class);
+ suite.addTestSuite(InnerZipResourceTimestampTest.class);
-
// UI
suite.addTestSuite(BuildActionTest.class);
return suite;
Modified:
trunk/archives/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelTest.java
===================================================================
---
trunk/archives/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelTest.java 2010-10-11
04:30:35 UTC (rev 25703)
+++
trunk/archives/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelTest.java 2010-10-11
07:23:07 UTC (rev 25704)
@@ -27,39 +27,32 @@
*
*/
public abstract class ModelTest extends TestCase {
- protected static IArchiveNodeFactory getFactory() {
+ public static IArchiveNodeFactory getFactory() {
return ArchivesCore.getInstance().getNodeFactory();
}
/*
* Utility methods
*/
- protected IArchiveFolder createFolder(String name) {
+ public static IArchiveFolder createFolder(String name) {
IArchiveFolder folder = getFactory().createFolder();
folder.setName(name);
return folder;
}
- protected IArchiveStandardFileSet createFileSet(String includes, String path) {
+ public static IArchiveStandardFileSet createFileSet(String includes, String path) {
IArchiveStandardFileSet fs = getFactory().createFileset();
fs.setIncludesPattern(includes);
fs.setRawSourcePath( path );
return fs;
}
- protected IArchiveFileSet createLibFileSet(String name) {
+ public static IArchiveFileSet createLibFileSet(String name) {
ArchiveLibFileSetImpl lfsi = LibFileSetNodeProvider.createLibFileset();
lfsi.setId(name);
return lfsi;
}
-
-// protected IArchiveAction createAction() {
-// IArchiveAction action = ArchiveNodeFactory.createAction();
-// action.setTime(IArchiveAction.POST_BUILD);
-// action.setType("ant");
-// return action;
-// }
- protected IArchive createArchive(String name, String dest) {
+ public static IArchive createArchive(String name, String dest) {
IArchive archive = getFactory().createArchive();
archive.setName(name);
archive.setDestinationPath(new Path(dest));
Added:
trunk/archives/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/projects/InnerZipResourceTimestampTest.java
===================================================================
---
trunk/archives/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/projects/InnerZipResourceTimestampTest.java
(rev 0)
+++
trunk/archives/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/projects/InnerZipResourceTimestampTest.java 2010-10-11
07:23:07 UTC (rev 25704)
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.archives.test.projects;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFolder;
+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.util.internal.TrueZipUtil;
+import org.jboss.ide.eclipse.archives.test.ArchivesTest;
+import org.jboss.tools.test.util.ResourcesUtils;
+import org.osgi.framework.Bundle;
+
+import de.schlichtherle.io.File;
+
+/**
+ * This class tests first and foremost
+ * the presence of a ${archives_current_project}
+ * extension to allow the currently building
+ * project to be agnostic
+ *
+ * During this JIRA, workspace paths became conscious of
+ * their absolute / relative status and are now interpreted
+ * differently according to their status.
+ * @author rob
+ *
+ */
+public class InnerZipResourceTimestampTest extends TestCase {
+ private long startTime;
+ private Bundle bundle;
+ private final String projName = "InnerZipProj";
+ private IProject project;
+ IPath projLocation;
+ private IFolder outputDir, libDir;
+ protected void setUp() throws Exception {
+ startTime = new Date().getTime();
+ bundle = ArchivesTest.getDefault().getBundle();
+ project = ResourcesUtils.createEclipseProject(projName, new NullProgressMonitor());
+ projLocation = project.getLocation(); // for debugging
+ assertTrue(project.exists());
+ project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ outputDir = project.getFolder("output");
+ outputDir.create(true, true, new NullProgressMonitor());
+ assertTrue(outputDir.exists());
+ libDir = project.getFolder("libs");
+ libDir.create(true, true, new NullProgressMonitor());
+ assertTrue(libDir.exists());
+ }
+
+ protected java.io.File findSomeJar() {
+ try {
+ URL bundleURL = FileLocator.toFileURL(bundle.getEntry(""));
+ IPath bundlePath = new Path(bundleURL.getFile());
+ return bundlePath.append("libs").append("some.jar").toFile();
+ } catch(IOException ioe){}
+ return null;
+ }
+
+
+ protected void tearDown() throws Exception {
+ ResourcesUtils.deleteProject(projName);
+ }
+
+ public void testInnerZipTimestamps() {
+ // test the original
+ java.io.File someJar = findSomeJar();
+ File file = TrueZipUtil.getFile(new
Path(someJar.getAbsolutePath()).append("META-INF").append("MANIFEST.MF"));
+ long last = file.lastModified();
+ assertTrue(last < startTime);
+
+ try {
+ boolean copyVal = TrueZipUtil.copyFile(someJar.getAbsolutePath(),
libDir.getLocation().append("some.jar"));
+ TrueZipUtil.umount();
+ IPath workspaceJarPath = libDir.getLocation().append("some.jar");
+ long workspaceJarLastModified = workspaceJarPath.toFile().lastModified();
+ assertTrue(workspaceJarLastModified > startTime);
+ File workspaceFile =
TrueZipUtil.getFile(workspaceJarPath.append("META-INF").append("MANIFEST.MF"));
+ long workspaceResourceMod = workspaceFile.lastModified();
+ assertTrue(workspaceResourceMod < startTime);
+ } catch(IOException ioe) {
+ } finally {}
+ }
+}