-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unify and clean-up pde.ui.tests and make their activator obsolete
Remove unused code and unify and modernize remaining code.
- Loading branch information
1 parent
f8afe21
commit 442aed7
Showing
19 changed files
with
214 additions
and
482 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,10 @@ | |
*******************************************************************************/ | ||
package org.eclipse.pde.ui.tests; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assume.assumeTrue; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.lang.StackWalker.Option; | ||
|
@@ -27,16 +29,19 @@ | |
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.zip.ZipEntry; | ||
import java.util.zip.ZipInputStream; | ||
|
||
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; | ||
import org.eclipse.core.runtime.ICoreRunnable; | ||
import org.eclipse.core.runtime.IStatus; | ||
import org.eclipse.core.runtime.ILog; | ||
import org.eclipse.core.runtime.NullProgressMonitor; | ||
import org.eclipse.core.runtime.Platform; | ||
import org.eclipse.core.runtime.Status; | ||
import org.eclipse.core.runtime.URIUtil; | ||
import org.eclipse.core.runtime.jobs.Job; | ||
import org.eclipse.jface.dialogs.ErrorDialog; | ||
|
@@ -75,18 +80,18 @@ public void setUp() throws Exception { | |
MessageDialog.AUTOMATED_MODE = true; | ||
ErrorDialog.AUTOMATED_MODE = true; | ||
FreezeMonitor.expectCompletionInAMinute(); | ||
TestUtils.log(IStatus.INFO, name.getMethodName(), "setUp"); | ||
ILog.get().log(Status.info("[" + name.getMethodName() + "] " + "setUp")); | ||
assertWelcomeScreenClosed(); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
TestUtils.log(IStatus.INFO, name.getMethodName(), "tearDown"); | ||
ILog.get().log(Status.info("[" + name.getMethodName() + "] " + "tearDown")); | ||
// Close any editors we opened | ||
IWorkbenchWindow[] workbenchPages = PlatformUI.getWorkbench().getWorkbenchWindows(); | ||
for (IWorkbenchWindow workbenchPage : workbenchPages) { | ||
IWorkbenchPage page = workbenchPage.getActivePage(); | ||
if (page != null){ | ||
if (page != null) { | ||
page.closeAllEditors(false); | ||
} | ||
} | ||
|
@@ -107,7 +112,7 @@ public void tearDown() throws Exception { | |
} else { | ||
error.addSuppressed(e); | ||
} | ||
PDETestsPlugin.getDefault().getLog().error(message, e); | ||
ILog.get().error(message, e); | ||
} | ||
} | ||
TestUtils.waitForJobs(name.getMethodName(), 10, 10000); | ||
|
@@ -210,4 +215,52 @@ public static void copyFromThisBundleInto(String rootPath, Path targetRoot) | |
} | ||
} | ||
} | ||
|
||
public static Path getThisBundlesStateLocation() { | ||
Class<?> caller = STACK_WALKER.getCallerClass(); | ||
Bundle bundle = FrameworkUtil.getBundle(caller); | ||
return Platform.getStateLocation(bundle).toPath(); | ||
} | ||
|
||
/** | ||
* Unzips the given archive to the specified location. | ||
* | ||
* @param location | ||
Check warning on line 228 in ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/PDETestCase.java Jenkins - eclipse-pde / JavaDocJavaDoc @param
|
||
* path in the local file system | ||
* @param archivePath | ||
* path to archive relative to the test plug-in | ||
* @throws IOException | ||
*/ | ||
public static Path doUnZip(Path targetDirectory, String archivePath) throws IOException { | ||
URL zipURL = FrameworkUtil.getBundle(PDETestCase.class).getEntry(archivePath); | ||
assertNotNull("Zip file not found at path " + archivePath, zipURL); | ||
try (ZipInputStream zipStream = new ZipInputStream(zipURL.openStream())) { | ||
for (ZipEntry entry = zipStream.getNextEntry(); entry != null; entry = zipStream.getNextEntry()) { | ||
if (!entry.isDirectory()) { | ||
java.nio.file.Path file = targetDirectory.resolve(entry.getName()); | ||
Files.createDirectories(file.getParent()); | ||
Files.copy(zipStream, file, StandardCopyOption.REPLACE_EXISTING); | ||
} | ||
} | ||
return targetDirectory; | ||
} | ||
} | ||
|
||
/** | ||
* Recursively deletes the directory and files within. | ||
* | ||
* @param dir | ||
* directory to delete | ||
*/ | ||
public static void delete(File dir) { | ||
File[] files = dir.listFiles(); | ||
for (File file : files) { | ||
if (file.isDirectory()) { | ||
delete(file); | ||
} else { | ||
file.delete(); | ||
} | ||
} | ||
dir.delete(); | ||
} | ||
} |
43 changes: 0 additions & 43 deletions
43
ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/PDETestsPlugin.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.