Skip to content

Commit

Permalink
Move only remaining test from pde.ui.tests.smartimport into pde.ui.tests
Browse files Browse the repository at this point in the history
And delete the now empty o.e.pde.ui.tests.smartimport.
  • Loading branch information
HannesWell committed Sep 18, 2023
1 parent 2ec4948 commit ec3cb35
Show file tree
Hide file tree
Showing 25 changed files with 52 additions and 555 deletions.
11 changes: 0 additions & 11 deletions ui/org.eclipse.pde.ui.tests.smartimport/.classpath

This file was deleted.

4 changes: 0 additions & 4 deletions ui/org.eclipse.pde.ui.tests.smartimport/.options

This file was deleted.

28 changes: 0 additions & 28 deletions ui/org.eclipse.pde.ui.tests.smartimport/.project

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

24 changes: 0 additions & 24 deletions ui/org.eclipse.pde.ui.tests.smartimport/META-INF/MANIFEST.MF

This file was deleted.

3 changes: 0 additions & 3 deletions ui/org.eclipse.pde.ui.tests.smartimport/META-INF/p2.inf

This file was deleted.

22 changes: 0 additions & 22 deletions ui/org.eclipse.pde.ui.tests.smartimport/about.html

This file was deleted.

19 changes: 0 additions & 19 deletions ui/org.eclipse.pde.ui.tests.smartimport/build.properties

This file was deleted.

49 changes: 0 additions & 49 deletions ui/org.eclipse.pde.ui.tests.smartimport/test.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.eclipse.pde.ui.tests.target.AllTargetTests;
import org.eclipse.pde.ui.tests.views.log.AllLogViewTests;
import org.eclipse.pde.ui.tests.wizards.AllNewProjectTests;
import org.eclipse.ui.tests.smartimport.ProjectSmartImportTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
Expand Down Expand Up @@ -62,7 +63,8 @@
DynamicPluginProjectReferencesTest.class, //
ClasspathResolutionTest.class, //
BundleErrorReporterTest.class, //
AllPDECoreTests.class //
AllPDECoreTests.class, //
ProjectSmartImportTest.class, //
})
public class AllPDETests {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;

import java.io.IOException;
import java.io.InputStream;
import java.lang.StackWalker.Option;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.Collections;
import java.util.List;

import org.eclipse.core.resources.IProject;
Expand All @@ -29,6 +36,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
Expand All @@ -46,6 +54,8 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;

/**
* Provides a default {@link #tearDown()} implementation to delete all
Expand All @@ -54,6 +64,8 @@
*/
public abstract class PDETestCase {

private static final StackWalker STACK_WALKER = StackWalker.getInstance(Option.RETAIN_CLASS_REFERENCE);

private static boolean welcomeClosed;
@Rule
public TestName name = new TestName();
Expand Down Expand Up @@ -149,4 +161,37 @@ public static void assumeRunningInStandaloneEclipseSDK() {
throw new IllegalStateException(e);
}
}

/**
* Copies the content of the specified directory from the callers bundle to
* the specified specified target directory and restores the relative
* structure within the given directory.
* <p>
* This method works for bundles in directory and jar shape and is therefore
* suitable for tests that run in Eclipse I-builds too (where the
* Test-Plugins are executed as jars).
* </p>
*
* @param rootPath
* the path of the directory to copy from this bundle
* @param targetRoot
* the target directory
*/
public static void copyFromThisBundleInto(String rootPath, Path targetRoot)
throws IOException, URISyntaxException {
Class<?> caller = STACK_WALKER.getCallerClass();
Bundle bundle = FrameworkUtil.getBundle(caller);
URI rootEntry = bundle.getEntry(rootPath).toURI();
List<URL> entries = Collections.list(bundle.findEntries(rootPath, null, true));
for (URL entry : entries) {
String relativePath = URIUtil.makeRelative(entry.toURI(), rootEntry).toString();
if (!relativePath.endsWith("/")) {
Path targetPath = targetRoot.resolve(relativePath);
Files.createDirectories(targetPath.getParent());
try (InputStream is = entry.openStream()) {
Files.copy(is, targetPath, StandardCopyOption.REPLACE_EXISTING);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.assertj.core.api.Condition;
import org.eclipse.core.resources.IMarker;
Expand All @@ -34,6 +33,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.pde.ui.tests.PDETestCase;
import org.eclipse.pde.ui.tests.util.ProjectUtils;
import org.junit.After;
import org.junit.BeforeClass;
Expand All @@ -46,7 +46,7 @@
import org.junit.runners.Parameterized.Parameters;

@RunWith(Parameterized.class)
public class ProjectTestTemplate {
public class ProjectSmartImportTest {

@Parameters(name = "{0}")
public static Object[][] projects() {
Expand All @@ -69,15 +69,8 @@ public static Object[][] projects() {
@BeforeClass
public static void setupClass() throws Exception {
// Copy imported projects to temp-directory to not pollute this project
Path source = Path.of("resources").toRealPath();
Path target = workingDirectory.getRoot().toPath();
try (Stream<Path> files = Files.walk(source).filter(Files::isRegularFile)) {
for (Path file : (Iterable<Path>) files::iterator) {
Path targetFile = target.resolve(source.relativize(file));
Files.createDirectories(targetFile.getParent());
Files.copy(file, targetFile);
}
}
// and have it unzipped for I-build tests
PDETestCase.copyFromThisBundleInto("tests/smartImport", workingDirectory.getRoot().toPath());
Files.writeString(getErrorLogFile(), ""); // empty error log
ProjectUtils.deleteAllWorkspaceProjects();
}
Expand All @@ -93,7 +86,6 @@ private static Path getErrorLogFile() {
}

@Test
@SuppressWarnings("restriction")
public void testImport() throws CoreException, InterruptedException {
File projectPath = new File(workingDirectory.getRoot(), projectName);

Expand Down
1 change: 0 additions & 1 deletion ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<module>org.eclipse.pde.ui</module>
<module>org.eclipse.pde.ui.templates</module>
<module>org.eclipse.pde.ui.tests</module>
<module>org.eclipse.pde.ui.tests.smartimport</module>
<module>org.eclipse.pde.spy.core</module>
<module>org.eclipse.pde.spy.bundle</module>
<module>org.eclipse.pde.spy.event</module>
Expand Down

0 comments on commit ec3cb35

Please sign in to comment.