Author: rob.stryker(a)jboss.com
Date: 2012-01-24 01:44:13 -0500 (Tue, 24 Jan 2012)
New Revision: 38070
Added:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/.settings/.api_filters
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/ZippedFilterTest.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/LocalZippedPublisherUtil.java
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/META-INF/MANIFEST.MF
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/ASArchivesIntegrationTestSuite.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockPublishMethod.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/PublishingFilterTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java
Log:
https://issues.jboss.org/browse/JBIDE-10642 - more test cases
Added: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/.settings/.api_filters
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/.settings/.api_filters
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/.settings/.api_filters 2012-01-24
06:44:13 UTC (rev 38070)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="no"?>
+<component id="org.jboss.ide.eclipse.archives.webtools"
version="2">
+ <resource
path="src/org/jboss/ide/eclipse/archives/webtools/modules/LocalZippedPublisherUtil.java"
type="org.jboss.ide.eclipse.archives.webtools.modules.LocalZippedPublisherUtil">
+ <filter id="338792546">
+ <message_arguments>
+ <message_argument
value="org.jboss.ide.eclipse.archives.webtools.modules.LocalZippedPublisherUtil"/>
+ <message_argument value="publishChanges(IServer,
IModuleResourceDelta[], File)"/>
+ </message_arguments>
+ </filter>
+ </resource>
+</component>
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/LocalZippedPublisherUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/LocalZippedPublisherUtil.java 2012-01-24
03:21:51 UTC (rev 38069)
+++
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/LocalZippedPublisherUtil.java 2012-01-24
06:44:13 UTC (rev 38070)
@@ -38,6 +38,7 @@
import org.jboss.ide.eclipse.as.core.Messages;
import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
+import org.jboss.ide.eclipse.as.core.publishers.patterns.IModulePathFilter;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
@@ -248,7 +249,10 @@
TrueZipUtil.createArchive(path);
de.schlichtherle.io.File root = TrueZipUtil.getFile(path,
TrueZipUtil.getJarArchiveDetector());
IModuleResource[] resources = getResources(module);
- IStatus[] copyResults = copy(root, resources);
+ DeployableServerBehavior beh = ServerConverter.getDeployableServerBehavior(server);
+ IModulePathFilter filter = beh.getPathFilter(module);
+ IModuleResource[] resources2 = filter == null ? resources :
filter.getFilteredMembers();
+ IStatus[] copyResults = copy(root, resources2);
results.addAll(Arrays.asList(copyResults));
IModule[] children = server.getChildModules(module, new NullProgressMonitor());
@@ -277,10 +281,17 @@
IPath path = getOutputFilePath(module);
de.schlichtherle.io.File root = TrueZipUtil.getFile(path,
TrueZipUtil.getJarArchiveDetector());
IModuleResourceDelta[] deltas = ((Server)server).getPublishedResourceDelta(module);
- return publishChanges(server, deltas, root);
+ DeployableServerBehavior beh = ServerConverter.getDeployableServerBehavior(server);
+ IModulePathFilter filter = beh.getPathFilter(module);
+
+ return publishChanges(server, deltas, root, filter);
}
- protected IStatus[] publishChanges(IServer server, IModuleResourceDelta[] deltas,
de.schlichtherle.io.File root) {
+ /**
+ * @since 2.3
+ */
+ protected IStatus[] publishChanges(IServer server, IModuleResourceDelta[] deltas,
+ de.schlichtherle.io.File root, IModulePathFilter filter) {
ArrayList<IStatus> results = new ArrayList<IStatus>();
if( deltas == null || deltas.length == 0 )
return new IStatus[]{};
@@ -290,11 +301,15 @@
dKind = deltas[i].getKind();
resource = deltas[i].getModuleResource();
if( dKind == IModuleResourceDelta.ADDED ) {
- results.addAll(Arrays.asList(copy(root, new IModuleResource[]{resource})));
+ if( filter != null && filter.shouldInclude(resource)) {
+ results.addAll(Arrays.asList(copy(root, new IModuleResource[]{resource})));
+ }
} else if( dKind == IModuleResourceDelta.CHANGED ) {
- if( resource instanceof IModuleFile )
- results.addAll(Arrays.asList(copy(root, new IModuleResource[]{resource})));
- results.addAll(Arrays.asList(publishChanges(server, deltas[i].getAffectedChildren(),
root)));
+ if( filter != null && filter.shouldInclude(resource)) {
+ if( resource instanceof IModuleFile )
+ results.addAll(Arrays.asList(copy(root, new IModuleResource[]{resource})));
+ results.addAll(Arrays.asList(publishChanges(server, deltas[i].getAffectedChildren(),
root, filter)));
+ }
} else if( dKind == IModuleResourceDelta.REMOVED) {
de.schlichtherle.io.File f = getFileInArchive(root,
resource.getModuleRelativePath().append(
@@ -304,7 +319,7 @@
results.add(generateDeleteFailedStatus(f));
hasBeenChanged = true;
} else if( dKind == IModuleResourceDelta.NO_CHANGE ) {
- results.addAll(Arrays.asList(publishChanges(server, deltas[i].getAffectedChildren(),
root)));
+ results.addAll(Arrays.asList(publishChanges(server, deltas[i].getAffectedChildren(),
root, filter)));
}
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/META-INF/MANIFEST.MF
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/META-INF/MANIFEST.MF 2012-01-24
03:21:51 UTC (rev 38069)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/META-INF/MANIFEST.MF 2012-01-24
06:44:13 UTC (rev 38070)
@@ -24,6 +24,7 @@
org.jboss.ide.eclipse.as.test;bundle-version="2.2.0",
org.eclipse.wst.common.frameworks;bundle-version="1.2.100",
org.eclipse.jst.common.project.facet.core;bundle-version="1.4.200",
- org.eclipse.wst.common.project.facet.core;bundle-version="1.4.200"
+ org.eclipse.wst.common.project.facet.core;bundle-version="1.4.200",
+ org.eclipse.wst.common.modulecore;bundle-version="1.2.103"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.jboss.ide.eclipse.as.archives.integration.test
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/ASArchivesIntegrationTestSuite.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/ASArchivesIntegrationTestSuite.java 2012-01-24
03:21:51 UTC (rev 38069)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/ASArchivesIntegrationTestSuite.java 2012-01-24
06:44:13 UTC (rev 38070)
@@ -31,6 +31,7 @@
suite.addTestSuite(BuildDeployTest.class);
suite.addTestSuite(SingleFileZippedDeploymentIntegrationTest.class);
suite.addTestSuite(JSTEarWithNestedWebProjectIncrementalPublish.class);
+ suite.addTestSuite(ZippedFilterTest.class);
return suite;
}
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/ZippedFilterTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/ZippedFilterTest.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/ZippedFilterTest.java 2012-01-24
06:44:13 UTC (rev 38070)
@@ -0,0 +1,129 @@
+package org.jboss.ide.eclipse.as.archives.integration.test;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+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.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.eclipse.wst.server.core.internal.ServerPreferences;
+import org.eclipse.wst.server.core.model.IModuleFile;
+import org.eclipse.wst.server.core.model.IModuleResource;
+import org.eclipse.wst.server.core.model.ModuleDelegate;
+import org.jboss.ide.eclipse.as.core.publishers.patterns.IModulePathFilter;
+import org.jboss.ide.eclipse.as.core.publishers.patterns.PublishFilterDirectoryScanner;
+import org.jboss.ide.eclipse.as.core.server.internal.DelegatingServerBehavior;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.test.ASTest;
+import org.jboss.ide.eclipse.as.test.publishing.v2.Mock2BehaviourDelegate;
+import org.jboss.ide.eclipse.as.test.publishing.v2.MockPublishMethod;
+import org.jboss.ide.eclipse.as.test.publishing.v2.PublishFilterDirectoryScannerTest;
+import org.jboss.ide.eclipse.as.test.util.IOUtil;
+import org.jboss.ide.eclipse.as.test.util.ServerRuntimeUtils;
+import org.jboss.ide.eclipse.as.test.util.wtp.JavaEEFacetConstants;
+import org.jboss.ide.eclipse.as.test.util.wtp.OperationTestCase;
+import org.jboss.ide.eclipse.as.test.util.wtp.ProjectCreationUtil;
+import org.jboss.ide.eclipse.as.test.util.wtp.ProjectUtility;
+
+public class ZippedFilterTest extends TestCase {
+ public void tearDown() throws Exception {
+ ServerRuntimeUtils.deleteAllServers();
+ ServerRuntimeUtils.deleteAllRuntimes();
+ ProjectUtility.deleteAllProjects();
+ ASTest.clearStateLocation();
+ }
+
+ private IProject createProject(String name) throws Exception {
+ IDataModel dm = ProjectCreationUtil.getWebDataModel("module1", null, null,
+ "myContent", null, JavaEEFacetConstants.WEB_25, false);
+ OperationTestCase.runAndVerify(dm);
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
+ IFile f = p.getFile(new Path("myContent/includeme.txt"));
+ IOUtil.setContents(f, "includeMe");
+ IFile f2 = p.getFile(new Path("myContent/DONTincludeme.txt"));
+ IOUtil.setContents(f2, "leave me out");
+ return p;
+ }
+
+ public void testServerIntegration() throws CoreException, IOException, Exception {
+ IServer server =
ServerRuntimeUtils.createMockServerWithRuntime(IJBossToolingConstants.SERVER_AS_60,
+ "name1", "default");
+ server = ServerRuntimeUtils.useMock2PublishMethod(server);
+ server = ServerRuntimeUtils.setZipped(server, true);
+ IProject project = createProject("module1");
+ MockPublishMethod.reset();
+
+ ServerPreferences.getInstance().setAutoPublishing(false);
+ IModule mod = ServerUtil.getModule(project);
+ server = ServerRuntimeUtils.addModule(server, mod);
+ ModuleDelegate md = (ModuleDelegate)mod.loadAdapter(ModuleDelegate.class, null);
+
+ DelegatingServerBehavior beh =
(DelegatingServerBehavior)server.loadAdapter(DelegatingServerBehavior.class, null);
+ Mock2BehaviourDelegate del = (Mock2BehaviourDelegate)beh.getDelegate();
+ del.setUseSuperclassBehaviour(true);
+ IModulePathFilter filter = del.getPathFilter(new IModule[]{mod});
+ IModuleResource[] originalMembers = md.members();
+ IModuleResource[] filteredMembers = filter == null ? originalMembers :
filter.getFilteredMembers();
+ int oCount = PublishFilterDirectoryScannerTest.countAllResources(originalMembers);
+ int fCount = PublishFilterDirectoryScannerTest.countAllResources(filteredMembers);
+ assertEquals(oCount, fCount);
+
+ IVirtualComponent vc = ComponentCore.createComponent(mod.getProject());
+
+ vc.setMetaProperty("component.inclusion.patterns", "**/*");
+ vc.setMetaProperty("component.exclusion.patterns", "**/*.txt");
+
+ filter = del.getPathFilter(new IModule[]{mod});
+ originalMembers = md.members();
+ filteredMembers = filter.getFilteredMembers();
+ oCount = PublishFilterDirectoryScannerTest.countAllResources(originalMembers);
+ fCount = PublishFilterDirectoryScannerTest.countAllResources(filteredMembers);
+ assertEquals(oCount, fCount+2);
+
+ vc.setMetaProperty("component.inclusion.patterns", "**/*");
+ vc.setMetaProperty("component.exclusion.patterns", "**/DON*");
+
+ filter = del.getPathFilter(new IModule[]{mod});
+ originalMembers = md.members();
+ filteredMembers = filter.getFilteredMembers();
+ oCount = PublishFilterDirectoryScannerTest.countAllResources(originalMembers);
+ fCount = PublishFilterDirectoryScannerTest.countAllResources(filteredMembers);
+ assertEquals(oCount, fCount+1);
+
+
+ IModuleResource r = PublishFilterDirectoryScanner.findResource(originalMembers, null,
+ new Path("DONTincludeme.txt"));
+ assertNotNull(r);
+ assertFalse(filter.shouldInclude(r));
+ r = PublishFilterDirectoryScanner.findResource(originalMembers, null,
+ new Path("includeme.txt"));
+ assertNotNull(r);
+ assertTrue(filter.shouldInclude(r));
+
+ MockPublishMethod.reset();
+ server.publish(IServer.PUBLISH_FULL, new NullProgressMonitor());
+
+ IModuleFile[] copied = MockPublishMethod.getChangedFiles();
+ assertTrue(copied.length == 1);
+ IModuleFile f1 = copied[0];
+ File f2 = (File)f1.getAdapter(File.class);
+
+ IPath unzip3 = ASTest.getDefault().getStateLocation().append("unzip3");
+ IOUtil.unzipFile(new Path(f2.getAbsolutePath()),unzip3);
+ assertEquals(IOUtil.countAllResources(unzip3.toFile()), fCount+1);
+
+ }
+
+}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockPublishMethod.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockPublishMethod.java 2012-01-24
03:21:51 UTC (rev 38069)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockPublishMethod.java 2012-01-24
06:44:13 UTC (rev 38070)
@@ -30,7 +30,8 @@
public static final String MOCK_ROOT = "mockRoot";
public static ArrayList<IPath> changed = new ArrayList<IPath>();
public static ArrayList<IPath> removed = new ArrayList<IPath>();
-
+ public static ArrayList<IModuleFile> copiedFiles = new
ArrayList<IModuleFile>();
+
public IPublishCopyCallbackHandler getCallbackHandler(IPath path,
IServer server) {
return new MockCopyCallbackHandler(path);
@@ -46,11 +47,15 @@
public static void reset() {
changed.clear();
removed.clear();
+ copiedFiles.clear();
}
public static IPath[] getRemoved() {
return (IPath[]) removed.toArray(new IPath[removed.size()]);
}
-
+ public static IModuleFile[] getChangedFiles() {
+ return copiedFiles.toArray(new IModuleFile[copiedFiles.size()]);
+ }
+
public static IPath[] getChanged() {
return (IPath[]) changed.toArray(new IPath[changed.size()]);
}
@@ -97,6 +102,7 @@
IPath path2 = root.append(path);
if( !changed.contains(path2.makeRelative()))
changed.add(path2.makeRelative());
+ copiedFiles.add(mf);
return new IStatus[]{};
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/PublishingFilterTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/PublishingFilterTest.java 2012-01-24
03:21:51 UTC (rev 38069)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/PublishingFilterTest.java 2012-01-24
06:44:13 UTC (rev 38070)
@@ -1,6 +1,7 @@
package org.jboss.ide.eclipse.as.test.publishing.v2;
import java.io.IOException;
+import java.util.ArrayList;
import junit.framework.TestCase;
@@ -8,6 +9,8 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
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.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
@@ -89,7 +92,6 @@
"name1", "default");
server = ServerRuntimeUtils.useMock2PublishMethod(server);
IProject project = createProject("module1");
- MockPublishMethod.reset();
ServerPreferences.getInstance().setAutoPublishing(false);
IModule mod = ServerUtil.getModule(project);
@@ -101,7 +103,7 @@
del.setUseSuperclassBehaviour(true);
IModulePathFilter filter = del.getPathFilter(new IModule[]{mod});
IModuleResource[] originalMembers = md.members();
- IModuleResource[] filteredMembers = filter.getFilteredMembers();
+ IModuleResource[] filteredMembers = filter == null ? originalMembers :
filter.getFilteredMembers();
int oCount = PublishFilterDirectoryScannerTest.countAllResources(originalMembers);
int fCount = PublishFilterDirectoryScannerTest.countAllResources(filteredMembers);
assertEquals(oCount, fCount);
@@ -137,5 +139,13 @@
new Path("includeme.txt"));
assertNotNull(r);
assertTrue(filter.shouldInclude(r));
+
+ // Test the actual publish
+ MockPublishMethod.reset();
+ server.publish(IServer.PUBLISH_FULL, new NullProgressMonitor());
+ ArrayList<IPath> changed = MockPublishMethod.changed;
+ assertEquals(changed.size(),fCount+1); // addition of 'root'
+
+
}
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java 2012-01-24
03:21:51 UTC (rev 38069)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java 2012-01-24
06:44:13 UTC (rev 38070)
@@ -80,7 +80,7 @@
return 1;
File[] children = root.listFiles();
for( int i = 0; i < children.length; i++ )
- count += countFiles(children[i]);
+ count += countAllResources(children[i]);
return 1 + count;
}