Reduce SuiteOfTestCases children.
MyDebugTest had no real tests. The rest were not using any of the
implementations and are fine as JUnit 4 POJO.
Change-Id: If15da0e87a39136708f70a4d74ee09f944704ba3
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/ddp/CoreDDPTests.java b/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/ddp/CoreDDPTests.java
index 65628ce..e1667de 100644
--- a/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/ddp/CoreDDPTests.java
+++ b/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/ddp/CoreDDPTests.java
@@ -8,6 +8,9 @@
*******************************************************************************/
package org.eclipse.dltk.core.tests.ddp;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@@ -16,7 +19,6 @@
import org.eclipse.dltk.ast.expressions.Expression;
import org.eclipse.dltk.ast.expressions.NumericLiteral;
import org.eclipse.dltk.ast.references.SimpleReference;
-import org.eclipse.dltk.core.tests.model.SuiteOfTestCases;
import org.eclipse.dltk.ti.DefaultTypeInferencer;
import org.eclipse.dltk.ti.GoalState;
import org.eclipse.dltk.ti.IGoalEvaluatorFactory;
@@ -25,18 +27,9 @@
import org.eclipse.dltk.ti.goals.GoalEvaluator;
import org.eclipse.dltk.ti.goals.IGoal;
import org.eclipse.dltk.ti.types.IEvaluatedType;
+import org.junit.Test;
-import junit.framework.Test;
-
-public class CoreDDPTests extends SuiteOfTestCases {
-
- public CoreDDPTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new Suite(CoreDDPTests.class);
- }
+public class CoreDDPTests {
private static final class FixedAnswerGoalEvaluator extends GoalEvaluator {
private final IEvaluatedType answer;
@@ -138,6 +131,7 @@
}
+ @Test
public void testSimple() throws Exception {
// y = 2; x = y; x?
final Expression x = new SimpleReference(0, 0, "x");
@@ -168,6 +162,7 @@
assertTrue(answer instanceof MyNum);
}
+ @Test
public void testCycles() throws Exception {
final Expression x = new SimpleReference(0, 0, "x");
final Expression y = new SimpleReference(0, 0, "y");
diff --git a/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/launching/EnvironmentResolverTests.java b/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/launching/EnvironmentResolverTests.java
index ccd1d89..1daf910 100644
--- a/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/launching/EnvironmentResolverTests.java
+++ b/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/launching/EnvironmentResolverTests.java
@@ -1,19 +1,18 @@
package org.eclipse.dltk.core.tests.launching;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
import java.util.HashMap;
import java.util.Map;
-import org.eclipse.dltk.core.tests.model.SuiteOfTestCases;
import org.eclipse.dltk.internal.launching.EnvironmentResolver;
import org.eclipse.dltk.launching.EnvironmentVariable;
+import org.junit.Test;
-import junit.framework.Test;
-
-public class EnvironmentResolverTests extends SuiteOfTestCases {
- public EnvironmentResolverTests(String name) {
- super(name);
- }
-
+public class EnvironmentResolverTests {
+ @Test
public void testEnvironmentResolve001() {
Map<String, String> env = new HashMap<>();
EnvironmentVariable[] vars = new EnvironmentVariable[] { mk("A", "a") };
@@ -22,6 +21,7 @@
test(resolve, "A", "a");
}
+ @Test
public void testEnvironmentResolve002() {
Map<String, String> env = new HashMap<>();
EnvironmentVariable[] vars = new EnvironmentVariable[] { mk("A", "a"),
@@ -33,6 +33,7 @@
test(resolve, "B", "a$Ac");
}
+ @Test
public void testEnvironmentResolve002a() {
Map<String, String> env = new HashMap<>();
EnvironmentVariable[] vars = new EnvironmentVariable[] { mk("A", "a"),
@@ -43,6 +44,7 @@
test(resolve, "B", "aa:c");
}
+ @Test
public void testEnvironmentResolve003() {
Map<String, String> env = new HashMap<>();
EnvironmentVariable[] vars = new EnvironmentVariable[] {
@@ -54,6 +56,7 @@
test(resolve, "ATS_EASY", "/Develop/cisco/ats5.0.0/ats_easy");
}
+ @Test
public void testEnvironmentResolve004() {
Map<String, String> env = new HashMap<>();
env.put("PATH", "/bin:/usr/bin");
@@ -64,6 +67,7 @@
test(resolve, "PATH", "/sbin:/bin:/usr/bin");
}
+ @Test
public void testEnvironmentResolve005() {
Map<String, String> env = new HashMap<>();
env.put("PATH", "/bin:/usr/bin");
@@ -80,6 +84,7 @@
test(resolve, "a4", "A4A3A2A1");
}
+ @Test
public void testEnvironmentResolve006() {
Map<String, String> env = new HashMap<>();
env.put("PATH", "/bin:/usr/bin");
@@ -92,6 +97,7 @@
assertEquals(resolve.length, 0);
}
+ @Test
public void testEnvironmentResolve007() {
Map<String, String> env = new HashMap<>();
env.put("PATH", "/bin:/usr/bin");
@@ -104,6 +110,7 @@
test(resolve, "a2", "a2");
}
+ @Test
public void testEnvironmentResolve008() {
Map<String, String> env = new HashMap<>();
env.put("PATH", "/bin:/usr/bin");
@@ -116,6 +123,7 @@
test(resolve, "a2", "alla{/sbii/bin/:/bin:/usr/bin}");
}
+ @Test
public void testEnvironmentResolve008a() {
Map<String, String> env = new HashMap<>();
EnvironmentVariable[] vars = new EnvironmentVariable[] {
@@ -148,8 +156,4 @@
}
fail("Not found " + environmentVariable.toString());
}
-
- public static Test suite() {
- return new Suite(EnvironmentResolverTests.class);
- }
}
diff --git a/core/tests/org.eclipse.dltk.debug.tests/src/org/eclipse/dltk/debug/tests/MyDebugTests.java b/core/tests/org.eclipse.dltk.debug.tests/src/org/eclipse/dltk/debug/tests/MyDebugTests.java
deleted file mode 100644
index 8d176e2..0000000
--- a/core/tests/org.eclipse.dltk.debug.tests/src/org/eclipse/dltk/debug/tests/MyDebugTests.java
+++ /dev/null
@@ -1,221 +0,0 @@
-package org.eclipse.dltk.debug.tests;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URL;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.dltk.core.DLTKCore;
-import org.eclipse.dltk.core.IScriptProject;
-import org.eclipse.dltk.core.tests.model.SuiteOfTestCases;
-
-public class MyDebugTests extends SuiteOfTestCases {
- private static class FileHelper {
- public static byte[] readFile(java.io.File file) throws java.io.IOException {
- int fileLength = (int) file.length();
- byte[] fileBytes = new byte[fileLength];
- try (FileInputStream stream = new java.io.FileInputStream(file)) {
- int bytesRead = 0;
- int lastReadSize = 0;
- while ((lastReadSize != -1) && (bytesRead != fileLength)) {
- lastReadSize = stream.read(fileBytes, bytesRead, fileLength - bytesRead);
- bytesRead += lastReadSize;
- }
- }
- return fileBytes;
- }
-
- /**
- * Copy the given source directory (and all its contents) to the given
- * target directory.
- */
- public static void copyDirectory(File source, File target) throws IOException {
- if (!target.exists()) {
- target.mkdirs();
- }
- File[] files = source.listFiles();
- if (files == null)
- return;
- for (int i = 0; i < files.length; i++) {
- File sourceChild = files[i];
- String name = sourceChild.getName();
- if (name.equals("CVS"))
- continue;
- File targetChild = new File(target, name);
- if (sourceChild.isDirectory()) {
- copyDirectory(sourceChild, targetChild);
- } else {
- copyFile(sourceChild, targetChild);
- }
- }
- }
-
- /**
- * Copy file from src (path to the original file) to dest (path to the
- * destination file).
- */
- public static void copyFile(File source, File target) throws IOException {
- // read source bytes
- byte[] srcBytes = readFile(source);
-
- // write bytes to dest
- try (FileOutputStream out = new FileOutputStream(target)) {
- out.write(srcBytes);
- }
- }
- }
-
- public MyDebugTests(String name) {
- super(name);
- // TODO Auto-generated constructor stub
- }
-
- // Helper methods
- protected IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- protected IWorkspaceRoot getWorkspaceRoot() {
- return getWorkspace().getRoot();
- }
-
- protected IProject getProject(String project) {
- return getWorkspaceRoot().getProject(project);
- }
-
- // Create project
- protected IProject createProject(final String projectName) throws CoreException {
- final IProject project = getProject(projectName);
- IWorkspaceRunnable create = monitor -> {
- project.create(null);
- project.open(null);
- };
- getWorkspace().run(create, null);
- return project;
- }
-
- protected File getPluginDirectoryPath() {
- try {
- URL url = Activator.getDefault().getBundle().getEntry("/");
- return new File(FileLocator.toFileURL(url).getFile());
- } catch (IOException e) {
- e.printStackTrace();
- }
- return null;
- }
-
- public File getSourceWorkspacePath() {
- return new File(getPluginDirectoryPath(), "workspace");
- }
-
- protected IProject createProjectWithContent(final String projectName) throws CoreException, IOException {
- final File source = getSourceWorkspacePath();
- final File target = getWorkspaceRoot().getLocation().toFile();
- FileHelper.copyDirectory(new File(source, projectName), new File(target, projectName));
-
- return createProject(projectName);
- }
-
- protected IScriptProject createScriptProject(final String projectName, final String[] natureIds)
- throws CoreException {
- final IScriptProject[] result = new IScriptProject[1];
-
- IWorkspaceRunnable create = monitor -> {
- final IProject project = createProject(projectName);
-
- // Natures
- IProjectDescription description = project.getDescription();
- description.setNatureIds(natureIds);
- project.setDescription(description, null);
-
- // Script project
- result[0] = DLTKCore.create(project);
- };
-
- getWorkspace().run(create, null);
-
- return result[0];
- }
-
- // protected IScriptProject createScriptProject(final String projectName,
- // final String[] natures, final String[] sourceFolders,
- // final String[] projects) throws CoreException {
- // final IScriptProject[] result = new IScriptProject[1];
- //
- // IWorkspaceRunnable create = new IWorkspaceRunnable() {
- // public void run(IProgressMonitor monitor) throws CoreException {
- // final IProject project = createProject(projectName);
- //
- // // Natures
- // IProjectDescription description = project.getDescription();
- // description.setNatureIds(natures);
- // project.setDescription(description, null);
- //
- // // Buildpath entries
- // IPath projectPath = project.getFullPath();
- // int sourceLength = sourceFolders == null ? 0
- // : sourceFolders.length;
- // int projectLength = projects == null ? 0 : projects.length;
- //
- // IBuildpathEntry[] entries = new IBuildpathEntry[sourceLength
- // + projectLength];
- // for (int i = 0; i < sourceLength; i++) {
- // IPath sourcePath = new Path(sourceFolders[i]);
- // int segmentCount = sourcePath.segmentCount();
- // if (segmentCount > 0) {
- // // create folder and its parents
- // IContainer container = project;
- // for (int j = 0; j < segmentCount; j++) {
- // IFolder folder = container.getFolder(new Path(
- // sourcePath.segment(j)));
- // if (!folder.exists()) {
- // folder.create(true, true, null);
- // }
- // container = folder;
- // }
- // }
- // // create source entry
- // entries[i] = DLTKCore.newSourceEntry(projectPath
- // .append(sourcePath));
- // }
- // for (int i = 0; i < projectLength; i++) {
- // // accessible files
- // IPath[] accessibleFiles;
- // accessibleFiles = new IPath[0];
- //
- // // non accessible files
- // IPath[] nonAccessibleFiles;
- // nonAccessibleFiles = new IPath[0];
- //
- // entries[sourceLength + i] = DLTKCore.newProjectEntry(
- // new Path(projects[i]), BuildpathEntry
- // .getAccessRules(accessibleFiles,
- // nonAccessibleFiles), true,
- // new IBuildpathAttribute[0], false);
- // }
- // // set buildpath and output location
- // IScriptProject scriptProject = DLTKCore.create(project);
- // scriptProject.setRawBuildpath(entries, null);
- //
- // result[0] = scriptProject;
- // }
- // };
- // getWorkspace().run(create, null);
- // return result[0];
- // }
-
- // protected IScriptProject setUpScriptProject(final String projectName)
- // throws CoreException, IOException {
- // final IProject project = setUpProject(projectName);
- // return DLTKCore.create(project);
- // }
-}