Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 29617 Details for
Bug 96704
[Import/Export] Import doesn't import empty directories
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch for ImportExistingTests.java
test-96704.txt (text/plain), 13.21 KB, created by
Karice McIntyre
on 2005-11-09 12:00:50 EST
(
hide
)
Description:
patch for ImportExistingTests.java
Filename:
MIME Type:
Creator:
Karice McIntyre
Created:
2005-11-09 12:00:50 EST
Size:
13.21 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.tests >Index: Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExistingTest.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExistingTest.java,v >retrieving revision 1.8 >diff -u -r1.8 ImportExistingTest.java >--- Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExistingTest.java 7 Nov 2005 17:21:15 -0000 1.8 >+++ Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExistingTest.java 9 Nov 2005 16:55:56 -0000 >@@ -20,10 +20,9 @@ > import java.util.HashSet; > import java.util.zip.ZipFile; > >-import junit.framework.TestSuite; >- > import org.eclipse.core.resources.IFolder; > import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.IWorkspaceRoot; > import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.CoreException; >@@ -50,19 +49,23 @@ > import org.eclipse.ui.tests.util.FileUtil; > > public class ImportExistingTest extends DataTransferTestCase { >- public static TestSuite suite() { >- return new TestSuite(ImportExistingTest.class); >- } >- > private static final String PLUGIN_ID = "org.eclipse.ui.tests"; > private static final String DATA_PATH_PREFIX = "data/org.eclipse.datatransferArchives/"; > private static final String WS_DATA_PREFIX = "data/workspaces"; > private static final String WS_DATA_LOCATION = "importExistingFromDirTest"; >+ private static final String ARCHIVE_HELLOWORLD = "helloworld"; >+ private static final String ARCHIVE_FILE_WITH_EMPTY_FOLDER = "EmptyFolderInArchive"; > > private static final String[] ARCHIVE_FILE_LIST = new String[] { > "HelloWorld.java", "HelloWorld.class", ".project", ".classpath" }; >+ >+ private static final String[] ARCHIVE_FILE_EMPTY_FOLDER_LIST = new String[]{ >+ "empty", "folder" }; >+ > private String dataLocation = null; > >+ private boolean originalRefreshSetting; >+ > public ImportExistingTest(String testName) { > super(testName); > } >@@ -71,6 +74,14 @@ > return DialogCheck.getShell(); > } > >+ protected void doSetUp() throws Exception { >+ super.doSetUp(); >+ originalRefreshSetting = ResourcesPlugin.getPlugin() >+ .getPluginPreferences().getBoolean(ResourcesPlugin.PREF_AUTO_REFRESH); >+ ResourcesPlugin.getPlugin() >+ .getPluginPreferences().setValue(ResourcesPlugin.PREF_AUTO_REFRESH, true); >+ } >+ > protected void doTearDown() throws Exception { > super.doTearDown(); > IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot(); >@@ -86,18 +97,22 @@ > } > } > dataLocation = null; // reset for next test >+ >+ ResourcesPlugin.getPlugin() >+ .getPluginPreferences().setValue(ResourcesPlugin.PREF_AUTO_REFRESH, >+ originalRefreshSetting); > } > > public void testFindSingleZip() { > try { >- URL helloworld = Platform.asLocalURL(Platform.find(TestPlugin.getDefault().getBundle(), >- new Path(DATA_PATH_PREFIX+"helloworld.zip"))); >+ URL archiveFile = Platform.asLocalURL(Platform.find(TestPlugin.getDefault().getBundle(), >+ new Path(DATA_PATH_PREFIX + ARCHIVE_HELLOWORLD + ".zip"))); > WizardProjectsImportPage wpip = getNewWizard(); > HashSet projects = new HashSet(); > projects.add("HelloWorld"); > > wpip.getProjectFromDirectoryRadio().setSelection((false)); //We want the other one selected >- wpip.updateProjectsList(helloworld.getPath()); >+ wpip.updateProjectsList(archiveFile.getPath()); > > ProjectRecord[] selectedProjects= wpip.getValidProjects(); > ArrayList projectNames = new ArrayList(); >@@ -113,14 +128,14 @@ > > public void testFindSingleTar() { > try { >- URL helloworld = Platform.asLocalURL(Platform.find(TestPlugin.getDefault().getBundle(), >- new Path(DATA_PATH_PREFIX+"helloworld.tar"))); >+ URL archiveFile = Platform.asLocalURL(Platform.find(TestPlugin.getDefault().getBundle(), >+ new Path(DATA_PATH_PREFIX + ARCHIVE_HELLOWORLD + ".tar"))); > WizardProjectsImportPage wpip = getNewWizard(); > HashSet projects = new HashSet(); > projects.add("HelloWorld"); > > wpip.getProjectFromDirectoryRadio().setSelection((false)); //We want the other one selected >- wpip.updateProjectsList(helloworld.getPath()); >+ wpip.updateProjectsList(archiveFile.getPath()); > > ProjectRecord[] selectedProjects= wpip.getValidProjects(); > ArrayList projectNames = new ArrayList(); >@@ -196,14 +211,14 @@ > IProject[] workspaceProjects = root.getProjects(); > for (int i = 0; i < workspaceProjects.length; i++) > FileUtil.deleteProject(workspaceProjects[i]); >- URL helloworld = Platform.asLocalURL(Platform.find(TestPlugin.getDefault().getBundle(), >- new Path(DATA_PATH_PREFIX+"helloworld.zip"))); >+ URL archiveFile = Platform.asLocalURL(Platform.find(TestPlugin.getDefault().getBundle(), >+ new Path(DATA_PATH_PREFIX + ARCHIVE_HELLOWORLD + ".zip"))); > WizardProjectsImportPage wpip = getNewWizard(); > HashSet projects = new HashSet(); > projects.add("HelloWorld"); > > wpip.getProjectFromDirectoryRadio().setSelection((false)); //We want the other one selected >- wpip.updateProjectsList(helloworld.getPath()); >+ wpip.updateProjectsList(archiveFile.getPath()); > > ProjectRecord[] selectedProjects= wpip.getValidProjects(); > ArrayList projectNames = new ArrayList(); >@@ -225,7 +240,7 @@ > if (helloFolder.exists()) > fail("Project was imported as a folder into itself"); > >- verifyProjectInWorkspace(true, workspaceProjects[0], ARCHIVE_FILE_LIST); >+ verifyProjectInWorkspace(true, workspaceProjects[0], ARCHIVE_FILE_LIST, true); > > } catch (IOException e) { > fail(e.toString()); >@@ -235,6 +250,51 @@ > > } > >+ public void testImportZipWithEmptyFolder(){ >+ try { >+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >+ >+ IProject[] workspaceProjects = root.getProjects(); >+ for (int i = 0; i < workspaceProjects.length; i++) >+ FileUtil.deleteProject(workspaceProjects[i]); >+ URL archiveFile = Platform.asLocalURL(Platform.find(TestPlugin.getDefault().getBundle(), >+ new Path(DATA_PATH_PREFIX + ARCHIVE_FILE_WITH_EMPTY_FOLDER + ".zip"))); >+ WizardProjectsImportPage wpip = getNewWizard(); >+ HashSet projects = new HashSet(); >+ projects.add("A"); >+ >+ wpip.getProjectFromDirectoryRadio().setSelection((false)); //We want the other one selected >+ wpip.updateProjectsList(archiveFile.getPath()); >+ >+ ProjectRecord[] selectedProjects= wpip.getValidProjects(); >+ ArrayList projectNames = new ArrayList(); >+ for (int i = 0; i < selectedProjects.length; i++) { >+ projectNames.add(selectedProjects[i].getProjectName()); >+ } >+ >+ assertTrue("Not all projects were found correctly in zip", projectNames.containsAll(projects)); >+ >+ CheckboxTreeViewer projectsList= wpip.getProjectsList(); >+ projectsList.setCheckedElements(selectedProjects); >+ wpip.createProjects(); // Try importing all the projects we found >+ >+ // "HelloWorld" should be the only project in the workspace >+ workspaceProjects = root.getProjects(); >+ if (workspaceProjects.length != 1) >+ fail("Incorrect Number of projects imported"); >+ IFolder helloFolder = workspaceProjects[0].getFolder("HelloWorld"); >+ if (helloFolder.exists()) >+ fail("Project was imported as a folder into itself"); >+ >+ verifyProjectInWorkspace(true, workspaceProjects[0], ARCHIVE_FILE_EMPTY_FOLDER_LIST, false); >+ >+ } catch (IOException e) { >+ fail(e.toString()); >+ } catch (CoreException e) { >+ fail(e.toString()); >+ } >+ } >+ > public void testImportSingleTar() { > try { > IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >@@ -242,14 +302,14 @@ > IProject[] workspaceProjects = root.getProjects(); > for (int i = 0; i < workspaceProjects.length; i++) > FileUtil.deleteProject(workspaceProjects[i]); >- URL helloworld = Platform.asLocalURL(Platform.find(TestPlugin.getDefault().getBundle(), >- new Path(DATA_PATH_PREFIX+"helloworld.tar"))); >+ URL archiveFile = Platform.asLocalURL(Platform.find(TestPlugin.getDefault().getBundle(), >+ new Path(DATA_PATH_PREFIX + ARCHIVE_HELLOWORLD + ".tar"))); > WizardProjectsImportPage wpip = getNewWizard(); > HashSet projects = new HashSet(); > projects.add("HelloWorld"); > > wpip.getProjectFromDirectoryRadio().setSelection((false)); //We want the other one selected >- wpip.updateProjectsList(helloworld.getPath()); >+ wpip.updateProjectsList(archiveFile.getPath()); > > ProjectRecord[] selectedProjects= wpip.getValidProjects(); > ArrayList projectNames = new ArrayList(); >@@ -271,7 +331,53 @@ > if (helloFolder.exists()) > fail("Project was imported as a folder into itself"); > >- verifyProjectInWorkspace(true, workspaceProjects[0], ARCHIVE_FILE_LIST); >+ verifyProjectInWorkspace(true, workspaceProjects[0], ARCHIVE_FILE_LIST, true); >+ >+ } catch (IOException e) { >+ fail(e.toString()); >+ } catch (CoreException e) { >+ fail(e.toString()); >+ } >+ >+ } >+ >+ public void testImportTarWithEmptyFolder(){ >+ try { >+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >+ >+ IProject[] workspaceProjects = root.getProjects(); >+ for (int i = 0; i < workspaceProjects.length; i++) >+ FileUtil.deleteProject(workspaceProjects[i]); >+ URL archiveFile = Platform.asLocalURL(Platform.find(TestPlugin.getDefault().getBundle(), >+ new Path(DATA_PATH_PREFIX + ARCHIVE_FILE_WITH_EMPTY_FOLDER + ".tar"))); >+ WizardProjectsImportPage wpip = getNewWizard(); >+ HashSet projects = new HashSet(); >+ projects.add("A"); >+ >+ wpip.getProjectFromDirectoryRadio().setSelection((false)); //We want the other one selected >+ wpip.updateProjectsList(archiveFile.getPath()); >+ >+ ProjectRecord[] selectedProjects= wpip.getValidProjects(); >+ ArrayList projectNames = new ArrayList(); >+ for (int i = 0; i < selectedProjects.length; i++) { >+ projectNames.add(selectedProjects[i].getProjectName()); >+ } >+ >+ assertTrue("Not all projects were found correctly in tar", projectNames.containsAll(projects)); >+ >+ CheckboxTreeViewer projectsList= wpip.getProjectsList(); >+ projectsList.setCheckedElements(selectedProjects); >+ wpip.createProjects(); // Try importing all the projects we found >+ >+ // "HelloWorld" should be the only project in the workspace >+ workspaceProjects = root.getProjects(); >+ if (workspaceProjects.length != 1) >+ fail("Incorrect Number of projects imported"); >+ IFolder helloFolder = workspaceProjects[0].getFolder("A"); >+ if (helloFolder.exists()) >+ fail("Project was imported as a folder into itself"); >+ >+ verifyProjectInWorkspace(true, workspaceProjects[0], ARCHIVE_FILE_EMPTY_FOLDER_LIST, false); > > } catch (IOException e) { > fail(e.toString()); >@@ -319,7 +425,7 @@ > if (helloFolder.exists()) > fail("Project was imported as a folder into itself"); > >- verifyProjectInWorkspace(false, workspaceProjects[0], fileList); >+ verifyProjectInWorkspace(false, workspaceProjects[0], fileList, true); > > } catch (IOException e) { > fail(e.toString()); >@@ -370,7 +476,7 @@ > if (helloFolder.exists()) > fail("Project was imported as a folder into itself"); > >- verifyProjectInWorkspace(true, workspaceProjects[0], fileList); >+ verifyProjectInWorkspace(true, workspaceProjects[0], fileList, true); > > } catch (IOException e) { > fail(e.toString()); >@@ -421,7 +527,7 @@ > if (helloFolder.exists()) > fail("Project was imported as a folder into itself"); > >- verifyProjectInWorkspace(true, workspaceProjects[0], fileList); >+ verifyProjectInWorkspace(true, workspaceProjects[0], fileList, true); > > // delete project but not contents > workspaceProjects[0].delete(false, true, null); >@@ -461,7 +567,7 @@ > if (helloFolder.exists()) > fail("Project was imported as a folder into itself"); > >- verifyProjectInWorkspace(true, workspaceProjects[0], fileList); >+ verifyProjectInWorkspace(true, workspaceProjects[0], fileList, true); > > } catch (IOException e) { > fail(e.toString()); >@@ -496,9 +602,9 @@ > * @param inWorkspace > * @param project > */ >- private void verifyProjectInWorkspace(final boolean inWorkspace, final IProject project, String[] fileList){ >+ private void verifyProjectInWorkspace(final boolean inWorkspace, final IProject project, String[] fileList, boolean isListFiles){ > try { >- Platform.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, new NullProgressMonitor()); >+ Platform.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, new NullProgressMonitor()); > } catch (OperationCanceledException e) { > fail(e.getLocalizedMessage()); > } catch (InterruptedException e) { >@@ -518,8 +624,10 @@ > } > // make sure the files in the project were imported > for (int i = 0; i < fileList.length; i++){ >+ IResource res = isListFiles ? (IResource)project.getFile(fileList[i]) >+ : (IResource)project.getFolder(fileList[i]); > assertTrue("Files were not imported", >- project.getFile(fileList[i]).exists()); >+ res.exists()); > } > > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 96704
:
21912
|
26870
|
29613
|
29615
| 29617