Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlena Laskavaia2011-03-19 13:20:56 -0400
committerAlena Laskavaia2011-03-19 13:20:56 -0400
commit899b6159ac95b3155cac268b959bc605663a8d58 (patch)
treeac11e085e93dab2064c921091b0784ff625ed00a
parent4975d5a2c721b0f35116b7c404c5e3b91d14ad6e (diff)
downloadorg.eclipse.cdt-899b6159ac95b3155cac268b959bc605663a8d58.tar.gz
org.eclipse.cdt-899b6159ac95b3155cac268b959bc605663a8d58.tar.xz
org.eclipse.cdt-899b6159ac95b3155cac268b959bc605663a8d58.zip
added convinience method to use outside of the package
-rw-r--r--codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CheckerTestCase.java7
-rw-r--r--codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanTestCase.java13
2 files changed, 17 insertions, 3 deletions
diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CheckerTestCase.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CheckerTestCase.java
index 0ce02c3d22..e135de07b7 100644
--- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CheckerTestCase.java
+++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CheckerTestCase.java
@@ -28,7 +28,12 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
/**
- * @author Alena Laskavaia
+ * Base class for tests. If you want to use outside of this plugin, you need
+ * to override {@link #getPlugin()} method and maybe {@link #getSourcePrefix()}
+ * method to get source directory for the tests,
+ * default is "src". To make it read comment from java class, you need to
+ * include this source directory (with test java files) into the build bundle.
+ *
*/
@SuppressWarnings("nls")
public class CheckerTestCase extends CodanTestCase {
diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanTestCase.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanTestCase.java
index c4301c907a..120883430a 100644
--- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanTestCase.java
+++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanTestCase.java
@@ -34,6 +34,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Plugin;
/**
* TODO: add description
@@ -171,14 +172,22 @@ public class CodanTestCase extends BaseTestCase {
protected StringBuffer[] getContents(int sections) {
try {
- CodanCoreTestActivator plugin = CodanCoreTestActivator.getDefault();
- return TestSourceReader.getContentsForTest(plugin.getBundle(), "src", getClass(), getName(), sections);
+ return TestSourceReader.getContentsForTest(getPlugin().getBundle(), getSourcePrefix(), getClass(), getName(), sections);
} catch (IOException e) {
fail(e.getMessage());
return null;
}
}
+ protected String getSourcePrefix() {
+ return "src";
+ }
+
+ protected Plugin getPlugin() {
+ CodanCoreTestActivator plugin = CodanCoreTestActivator.getDefault();
+ return plugin;
+ }
+
public File loadcode(String code, boolean cpp) {
String fileKey = "@file:";
int indf = code.indexOf(fileKey);

Back to the top