use of org.eclipse.wst.server.core.model.IModuleFolder in project webtools.servertools by eclipse.
the class PublishUtilTestCase method test03PreserveFiles.
public void test03PreserveFiles() throws Exception {
// Publish all resources except the B resources, preserving them them rather than delete them
IModuleResource[] resources = getModuleResources();
IModuleResource[] resources2 = getModuleResources2();
IPath dest = getDestination();
assertNotNull(dest);
IStatus[] result = PublishUtil.publishSmart(resources2, dest, getPreservePaths(), null);
assertNotNull(result);
assertTrue(getResultMessage(result), result.length == 0);
// Verify "A" files are unchanged and "B" files have not been deleted
String contents = getContents(dest.append(resources[0].getModuleRelativePath()));
assertEquals("rootFileA contents", contents);
contents = getContents(dest.append(resources[1].getModuleRelativePath()));
assertEquals("rootFileB contents 2", contents);
IModuleFolder mf = (IModuleFolder) resources[2];
contents = getContents(dest.append(mf.members()[0].getModuleRelativePath()));
assertEquals("folderAFileA contents", contents);
contents = getContents(dest.append(mf.members()[1].getModuleRelativePath()));
assertEquals("folderAFileB contents 2", contents);
mf = (IModuleFolder) resources[3];
contents = getContents(dest.append(mf.members()[0].getModuleRelativePath()));
assertEquals("folderBFileA contents", contents);
contents = getContents(dest.append(mf.members()[1].getModuleRelativePath()));
assertEquals("folderBFileB contents 2", contents);
}
use of org.eclipse.wst.server.core.model.IModuleFolder in project webtools.servertools by eclipse.
the class PublishUtilTestCase method test01FullCopy.
public void test01FullCopy() throws Exception {
// wait to ensure time stamps differ
Thread.sleep(1000);
IProject project = getTestProject();
// Modify all file contents and time stamps
IFile rootFileA = project.getFile("rootFileA.txt");
setFileContents(rootFileA, "rootFileA contents 2", true);
IFile rootFileB = project.getFile("rootFileB.txt");
setFileContents(rootFileB, "rootFileB contents 2", true);
IFile folderAFileA = project.getFile("FolderA/folderAFileA.txt");
setFileContents(folderAFileA, "folderAFileA contents 2", true);
IFile folderAFileB = project.getFile("FolderA/folderAFileB.txt");
setFileContents(folderAFileB, "folderAFileB contents 2", true);
IFile folderBFileA = project.getFile("FolderB/folderBFileA.txt");
setFileContents(folderBFileA, "folderBFileA contents 2", true);
IFile folderBFileB = project.getFile("FolderB/folderBFileB.txt");
setFileContents(folderBFileB, "folderBFileB contents 2", true);
// Publish all resources
IPath dest = getDestination();
assertNotNull(dest);
IModuleResource[] resources = getModuleResources();
IStatus[] result = PublishUtil.publishSmart(resources, dest, null, null);
assertNotNull(result);
assertTrue(getResultMessage(result), result.length == 0);
// Verify all files were copied
String contents = getContents(dest.append(resources[0].getModuleRelativePath()));
assertEquals("rootFileA contents 2", contents);
contents = getContents(dest.append(resources[1].getModuleRelativePath()));
assertEquals("rootFileB contents 2", contents);
IModuleFolder mf = (IModuleFolder) resources[2];
contents = getContents(dest.append(mf.members()[0].getModuleRelativePath()));
assertEquals("folderAFileA contents 2", contents);
contents = getContents(dest.append(mf.members()[1].getModuleRelativePath()));
assertEquals("folderAFileB contents 2", contents);
mf = (IModuleFolder) resources[3];
contents = getContents(dest.append(mf.members()[0].getModuleRelativePath()));
assertEquals("folderBFileA contents 2", contents);
contents = getContents(dest.append(mf.members()[1].getModuleRelativePath()));
assertEquals("folderBFileB contents 2", contents);
}
use of org.eclipse.wst.server.core.model.IModuleFolder in project webtools.sourceediting by eclipse.
the class ComponentDeployable method getExistingModuleResource.
/**
* Check the current cache to see if we already have an existing module resource for
* the given path.
* @param aList
* @param path
* @return an existing moduleResource from the cached result
*/
protected IModuleResource getExistingModuleResource(List aList, IPath path) {
// If the list is empty, return null
if (aList == null || aList.isEmpty() || path == null)
return null;
// Otherwise recursively check to see if given resource matches current resource or if it is a child
String[] pathSegments = path.segments();
IModuleResource moduleResource = null;
if (pathSegments.length == 0)
return null;
for (Iterator iter = aList.iterator(); iter.hasNext(); ) {
moduleResource = (IModuleResource) iter.next();
String[] moduleSegments = moduleResource.getModuleRelativePath().segments();
// then we have a match and we return the existing moduleResource
if (pathSegments[pathSegments.length - 1].equals(moduleResource.getName()) && (moduleSegments.length + 1) == pathSegments.length && startsWith(moduleSegments, pathSegments))
return moduleResource;
// but only check if the beginning segments are a match
if (moduleResource instanceof IModuleFolder && startsWith(moduleSegments, pathSegments) && pathSegments.length > moduleSegments.length && moduleResource.getName().equals(pathSegments[moduleSegments.length > 0 ? moduleSegments.length : 0]))
if (((IModuleFolder) moduleResource).members() != null)
return getExistingModuleResource(Arrays.asList(((IModuleFolder) moduleResource).members()), path);
}
return null;
}
use of org.eclipse.wst.server.core.model.IModuleFolder in project webtools.servertools by eclipse.
the class PublishUtilTestCase method test02PartialCopy.
public void test02PartialCopy() throws Exception {
// wait to ensure time stamps differ
Thread.sleep(1000);
IProject project = getTestProject();
// Modify all file contents, but not the time stamps on the "B" files
IFile rootFileA = project.getFile("rootFileA.txt");
setFileContents(rootFileA, "rootFileA contents", true);
IFile rootFileB = project.getFile("rootFileB.txt");
setFileContents(rootFileB, "rootFileB contents", false);
IFile folderAFileA = project.getFile("FolderA/folderAFileA.txt");
setFileContents(folderAFileA, "folderAFileA contents", true);
IFile folderAFileB = project.getFile("FolderA/folderAFileB.txt");
setFileContents(folderAFileB, "folderAFileB contents", false);
IFile folderBFileA = project.getFile("FolderB/folderBFileA.txt");
setFileContents(folderBFileA, "folderBFileA contents", true);
IFile folderBFileB = project.getFile("FolderB/folderBFileB.txt");
setFileContents(folderBFileB, "folderBFileB contents", false);
// Publish all resources
IPath dest = getDestination();
assertNotNull(dest);
IModuleResource[] resources = getModuleResources();
IStatus[] result = PublishUtil.publishSmart(resources, dest, null, null);
assertNotNull(result);
assertTrue(getResultMessage(result), result.length == 0);
// Verify the "A" files were copied, but not the "B" files since the time stamps didn't change
String contents = getContents(dest.append(resources[0].getModuleRelativePath()));
assertEquals("rootFileA contents", contents);
contents = getContents(dest.append(resources[1].getModuleRelativePath()));
assertEquals("rootFileB contents 2", contents);
IModuleFolder mf = (IModuleFolder) resources[2];
contents = getContents(dest.append(mf.members()[0].getModuleRelativePath()));
assertEquals("folderAFileA contents", contents);
contents = getContents(dest.append(mf.members()[1].getModuleRelativePath()));
assertEquals("folderAFileB contents 2", contents);
mf = (IModuleFolder) resources[3];
contents = getContents(dest.append(mf.members()[0].getModuleRelativePath()));
assertEquals("folderBFileA contents", contents);
contents = getContents(dest.append(mf.members()[1].getModuleRelativePath()));
assertEquals("folderBFileB contents 2", contents);
}
use of org.eclipse.wst.server.core.model.IModuleFolder in project webtools.servertools by eclipse.
the class PublishUtilTestCase method test05DeleteFiles.
public void test05DeleteFiles() throws Exception {
// Publish all resources except the "B" files and "B" folder and don't preserve them
IModuleResource[] resources = getModuleResources();
IModuleResource[] resources2 = getModuleResources2();
IModuleResource[] resources3 = new IModuleResource[2];
System.arraycopy(resources2, 0, resources3, 0, 2);
IPath dest = getDestination();
assertNotNull(dest);
IStatus[] result = PublishUtil.publishSmart(resources3, dest, null, null);
assertNotNull(result);
assertTrue(getResultMessage(result), result.length == 0);
IPath[] paths = getPreservePaths();
// Verify "A" files are unchanged and "B" files and "B" folder have been deleted
String contents = getContents(dest.append(resources[0].getModuleRelativePath()));
assertEquals("rootFileA contents", contents);
assertFalse(dest.append(paths[0]).toFile().exists());
IModuleFolder mf = (IModuleFolder) resources[2];
contents = getContents(dest.append(mf.members()[0].getModuleRelativePath()));
assertEquals("folderAFileA contents", contents);
assertFalse(dest.append(paths[1]).toFile().exists());
mf = (IModuleFolder) resources[3];
assertFalse(dest.append(mf.getModuleRelativePath()).toFile().exists());
}
Aggregations