org.eclipse.ui.wizards.datatransfer.ProjectConfigurator Java Examples
The following examples show how to use
org.eclipse.ui.wizards.datatransfer.ProjectConfigurator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImportTest.java From thym with Eclipse Public License 1.0 | 4 votes |
@Test public void test() throws Exception { ReadableByteChannel channel = null; try { channel = Channels.newChannel(new URL("https://github.com/apache/cordova-app-hello-world/archive/master.zip").openStream()); //$NON-NLS-1$ } catch (IOException ex) { Assume.assumeNoException("This test require ability to connect to Internet", ex); //$NON-NLS-1$ } File outputFile = File.createTempFile("cordova-app-hello-world", ".zip"); //$NON-NLS-1$ //$NON-NLS-2$ FileOutputStream fos = new FileOutputStream(outputFile); fos.getChannel().transferFrom(channel, 0, Long.MAX_VALUE); channel.close(); fos.close(); Expand expand = new Expand(); expand.setSrc(outputFile); File outputDirectory = Files.createTempDirectory("cordova-app-hello-world").toFile(); //$NON-NLS-1$ expand.setDest(outputDirectory); expand.execute(); outputFile.delete(); Set<IProject> newProjects = null; SmartImportJob job = new SmartImportJob(outputDirectory, Collections.EMPTY_SET, true, true); try { Map<File, List<ProjectConfigurator>> proposals = job.getImportProposals(new NullProgressMonitor()); Assert.assertEquals("Expected only 1 project to import", 1, proposals.size()); //$NON-NLS-1$ boolean thymConfiguratorFound = false; for (ProjectConfigurator configurator : proposals.values().iterator().next()) { if (configurator instanceof CordovaProjectConfigurator) { thymConfiguratorFound = true; } } Assert.assertTrue("Cordova configurator not found while checking directory", thymConfiguratorFound); //$NON-NLS-1$ // accept proposals job.setDirectoriesToImport(proposals.keySet()); IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot(); Set<IProject> beforeImport = new HashSet<>(Arrays.asList(wsRoot.getProjects())); job.run(new NullProgressMonitor()); job.join(); newProjects = new HashSet<>(Arrays.asList(wsRoot.getProjects())); newProjects.removeAll(beforeImport); Assert.assertEquals("Expected only 1 new project", 1, newProjects.size()); //$NON-NLS-1$ IProject newProject = newProjects.iterator().next(); boolean startsWith = newProject.getLocation().toFile().getAbsolutePath().startsWith(outputDirectory.toPath().toRealPath().toAbsolutePath().toString()); Assert.assertTrue(startsWith); HybridProject hybridProject = HybridProject.getHybridProject(newProject); Assert.assertNotNull("Project not configured as hybrid", hybridProject); //$NON-NLS-1$ } finally { if (newProjects != null) { for (IProject project : newProjects) { project.delete(true, true, new NullProgressMonitor()); } } } }