Skip to content

Commit

Permalink
Rewrite smartimport test as plain JUnit test
Browse files Browse the repository at this point in the history
This removes RedDeer dependency which has been announced to drop from
simrel.
  • Loading branch information
akurtakov committed Sep 15, 2023
1 parent b033971 commit b01e2c4
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 519 deletions.
13 changes: 2 additions & 11 deletions ui/org.eclipse.pde.ui.tests.smartimport/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,14 @@ Export-Package: org.eclipse.ui.tests.smartimport
Require-Bundle: org.eclipse.core.resources,
org.eclipse.core.runtime,
org.eclipse.jface,
org.eclipse.reddeer.core;bundle-version="[3.0.0,5.0.0)",
org.eclipse.reddeer.common;bundle-version="[3.0.0,5.0.0)",
org.eclipse.reddeer.eclipse;bundle-version="[3.0.0,5.0.0)",
org.eclipse.reddeer.jface;bundle-version="[3.0.0,5.0.0)",
org.eclipse.reddeer.junit;bundle-version="[3.0.0,5.0.0)",
org.eclipse.reddeer.junit.extension;bundle-version="[3.0.0,5.0.0)",
org.eclipse.reddeer.swt;bundle-version="[3.0.0,5.0.0)",
org.eclipse.reddeer.workbench;bundle-version="[3.0.0,5.0.0)",
org.eclipse.reddeer.workbench.core;bundle-version="[3.0.0,5.0.0)",
org.eclipse.swt,
org.eclipse.ui.ide,
org.eclipse.jdt.ui,
org.eclipse.pde.ui
Bundle-ActivationPolicy: lazy
Eclipse-BundleShape: dir
Bundle-RequiredExecutionEnvironment: JavaSE-17
Automatic-Module-Name: org.eclipse.pde.ui.tests.smartimport
Import-Package: org.hamcrest,
org.junit,
Import-Package: org.junit,
org.junit.runner,
org.junit.runners
1 change: 0 additions & 1 deletion ui/org.eclipse.pde.ui.tests.smartimport/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ bin.includes = about.html,\
test.xml,\
META-INF/
src.includes = about.html
jars.compile.order = browser.jar
source.. = src/
2 changes: 1 addition & 1 deletion ui/org.eclipse.pde.ui.tests.smartimport/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<testSuite>org.eclipse.ui.tests.smartimport</testSuite>
<testClass>org.eclipse.ui.tests.smartimport.AllTests</testClass>
<!-- THE FOLLOWING LINE MUST NOT BE BROKEN BY AUTOFORMATTING -->
<argLine>${tycho.test.jvmArgs} ${platformSystemProperties} -Drd.logLevel=off</argLine>
<argLine>${tycho.test.jvmArgs} ${platformSystemProperties}</argLine>
<includes>
<include>**/*Test.class</include>
</includes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
******************************************************************************/
package org.eclipse.ui.tests.smartimport;

import org.eclipse.reddeer.junit.runner.RedDeerSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;

@RunWith(RedDeerSuite.class)
@RunWith(Suite.class)
@SuiteClasses({
PlainJavaProjectTest.class,
PlainEclipseProjectTest.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,55 +14,32 @@
package org.eclipse.ui.tests.smartimport;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.tests.smartimport.plugins.ImportedProject;
import org.eclipse.ui.tests.smartimport.plugins.ProjectProposal;

public class EclipseJavaProjectTest extends ProjectTestTemplate {

private static final String JAVA_ECLIPSE_PROJECT = "JavaEclipseProject";

@Override
File getProjectPath() {
return new File("target/resources/JavaEclipseProject");
}

@Override
List<ProjectProposal> getExpectedProposals() {
ArrayList<ProjectProposal> returnList = new ArrayList<>();
ProjectProposal projectProposal = new ProjectProposal("JavaEclipseProject");
projectProposal.addImportAs("Eclipse project");
returnList.add(projectProposal);
return returnList;
}

@Override
List<ImportedProject> getExpectedImportedProjects() {
ArrayList<ImportedProject> returnList = new ArrayList<>();
ImportedProject project = new ImportedProject("JavaEclipseProject", "");
project.addImportedAs("Eclipse project");
returnList.add(project);
return returnList;
void checkImportedProject() throws CoreException {
IProject project = getProject();
String[] natureIds = project.getDescription().getNatureIds();
assertEquals("Project should have exactly 1 nature", 1, natureIds.length);
assertEquals("Project should have java nature", "org.eclipse.jdt.core.javanature", natureIds[0]);
}


@Override
void checkImportedProject() {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("JavaEclipseProject");
String[] natureIds = {};
try {
natureIds = project.getDescription().getNatureIds();
} catch (CoreException e) {
e.printStackTrace();
fail();
}
assertEquals("Project should have exactly 1 nature", 1, natureIds.length);
assertEquals("Project should have java nature", "org.eclipse.jdt.core.javanature", natureIds[0]);
IProject getProject() {
return ResourcesPlugin.getWorkspace().getRoot().getProject(JAVA_ECLIPSE_PROJECT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,12 @@
package org.eclipse.ui.tests.smartimport;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.tests.smartimport.plugins.ImportedProject;
import org.eclipse.ui.tests.smartimport.plugins.ProjectProposal;

public class FeatureProjectTest extends ProjectTestTemplate {

Expand All @@ -36,34 +31,16 @@ File getProjectPath() {
}

@Override
List<ProjectProposal> getExpectedProposals() {
ArrayList<ProjectProposal> returnList = new ArrayList<>();
ProjectProposal projectProposal = new ProjectProposal(PROJECT_NAME);
returnList.add(projectProposal);
return returnList;
}

@Override
List<ImportedProject> getExpectedImportedProjects() {
ArrayList<ImportedProject> returnList = new ArrayList<>();
ImportedProject project = new ImportedProject(PROJECT_NAME, "");
project.addImportedAs("Eclipse Feature");
returnList.add(project);
return returnList;
void checkImportedProject() throws CoreException {
IProject project = getProject();
String[] natureIds = project.getDescription().getNatureIds();
assertEquals("Project should have exactly 1 nature", 1, natureIds.length);
assertEquals("Project should have feature nature", "org.eclipse.pde.FeatureNature", natureIds[0]);
}

@Override
void checkImportedProject() {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
String[] natureIds = {};
try {
natureIds = project.getDescription().getNatureIds();
} catch (CoreException e) {
e.printStackTrace();
fail();
}
assertEquals("Project should have exactly 1 nature", 1, natureIds.length);
assertEquals("Project should have feature nature", "org.eclipse.pde.FeatureNature", natureIds[0]);
IProject getProject() {
return ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,53 +14,31 @@
package org.eclipse.ui.tests.smartimport;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.tests.smartimport.plugins.ImportedProject;
import org.eclipse.ui.tests.smartimport.plugins.ProjectProposal;

public class PlainEclipseProjectTest extends ProjectTestTemplate {

private static final String PLAIN_ECLIPSE_PROJECT = "PlainEclipseProject";

@Override
File getProjectPath() {
return new File("target/resources/PlainEclipseProject");
}

@Override
List<ProjectProposal> getExpectedProposals() {
ArrayList<ProjectProposal> returnList = new ArrayList<>();
ProjectProposal projectProposal = new ProjectProposal("PlainEclipseProject");
projectProposal.addImportAs("Eclipse project");
returnList.add(projectProposal);
return returnList;
IProject getProject() {
return ResourcesPlugin.getWorkspace().getRoot().getProject(PLAIN_ECLIPSE_PROJECT);
}

@Override
List<ImportedProject> getExpectedImportedProjects() {
ArrayList<ImportedProject> returnList = new ArrayList<>();
ImportedProject project = new ImportedProject("PlainEclipseProject", "");
project.addImportedAs("Eclipse project");
returnList.add(project);
return returnList;
void checkImportedProject() throws CoreException {
IProject project = getProject();
String[] natureIds = project.getDescription().getNatureIds();
assertEquals("This project should not have any nature", 0, natureIds.length);
}

@Override
void checkImportedProject() {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("PlainEclipseProject");
try {
String[] natureIds = project.getDescription().getNatureIds();
assertEquals("This project should not have any nature", 0, natureIds.length);
} catch (CoreException e) {
e.printStackTrace();
fail();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,53 +14,33 @@
package org.eclipse.ui.tests.smartimport;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.tests.smartimport.plugins.ImportedProject;
import org.eclipse.ui.tests.smartimport.plugins.ProjectProposal;

public class PlainJavaProjectTest extends ProjectTestTemplate {

private static final String PLAIN_JAVA_PROJECT = "PlainJavaProject";

@Override
public File getProjectPath() {
return new File("target/resources/PlainJavaProject");
}

@Override
List<ProjectProposal> getExpectedProposals() {
ArrayList<ProjectProposal> returnList = new ArrayList<>();
ProjectProposal projectProposal = new ProjectProposal("PlainJavaProject");
returnList.add(projectProposal);
return returnList;
}

@Override
List<ImportedProject> getExpectedImportedProjects() {
ArrayList<ImportedProject> returnList = new ArrayList<>();
ImportedProject project = new ImportedProject("PlainJavaProject", "");
project.addImportedAs("Java");
returnList.add(project);
return returnList;
void checkImportedProject() throws CoreException {
IProject project = getProject();
String[] natureIds = project.getDescription().getNatureIds();
assertEquals("Project should have exactly 1 nature", 1, natureIds.length);
assertEquals("Project should have java nature", "org.eclipse.jdt.core.javanature", natureIds[0]);
}

@Override
void checkImportedProject() {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("PlainJavaProject");
String[] natureIds = {};
try {
natureIds = project.getDescription().getNatureIds();
} catch (CoreException e) {
e.printStackTrace();
fail();
}
assertEquals("Project should have exactly 1 nature", 1, natureIds.length);
assertEquals("Project should have java nature", "org.eclipse.jdt.core.javanature", natureIds[0]);
IProject getProject() {
return ResourcesPlugin.getWorkspace().getRoot().getProject(PLAIN_JAVA_PROJECT);
}
}
Loading

0 comments on commit b01e2c4

Please sign in to comment.