1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 12:03:16 +02:00

[264715] - fixed tests (applied patch)

This commit is contained in:
Alena Laskavaia 2009-02-18 21:55:30 +00:00
parent 586be423c5
commit 5d8b09046e
2 changed files with 26 additions and 12 deletions

View file

@ -43,8 +43,8 @@ public class ErrorParserFileMatchingTest extends TestCase {
private final static String testName = "FindMatchingFilesTest"; private final static String testName = "FindMatchingFilesTest";
// Default project gets created once then used by all test cases. // Default project gets created once then used by all test cases.
private final IProject fProject; private IProject fProject = null;
private final String mockErrorParserId; private String mockErrorParserId = null;
private ArrayList<ProblemMarkerInfo> errorList; private ArrayList<ProblemMarkerInfo> errorList;
private final IMarkerGenerator markerGenerator = new IMarkerGenerator() { private final IMarkerGenerator markerGenerator = new IMarkerGenerator() {
@ -77,20 +77,16 @@ public class ErrorParserFileMatchingTest extends TestCase {
*/ */
public ErrorParserFileMatchingTest(String name) { public ErrorParserFileMatchingTest(String name) {
super(name); super(name);
IProject project = null;
try {
project = ResourceHelper.createCDTProject(testName);
} catch (Exception e) {
Assert.fail(e.toString());
}
fProject = project;
Assert.assertNotNull(project);
mockErrorParserId = addErrorParserExtension("MockErrorParser", MockErrorParser.class);
} }
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
if (fProject==null) {
fProject = ResourceHelper.createCDTProject(testName);
Assert.assertNotNull(fProject);
mockErrorParserId = addErrorParserExtension("MockErrorParser", MockErrorParser.class);
}
errorList = new ArrayList<ProblemMarkerInfo>(); errorList = new ArrayList<ProblemMarkerInfo>();
} }
@ -114,6 +110,15 @@ public class ErrorParserFileMatchingTest extends TestCase {
junit.textui.TestRunner.run(suite()); junit.textui.TestRunner.run(suite());
} }
/**
* Adds Error Parser extension to the global repository.
* Note that this function will "pollute" the working environment and
* the error parser will be seen by other test cases as well.
*
* @param shortId - last portion of ID with which error parser will be added.
* @param cl - Error Parser class
* @return - full ID of the error parser (generated by the method).
*/
private static String addErrorParserExtension(String shortId, Class cl) { private static String addErrorParserExtension(String shortId, Class cl) {
String ext = "<plugin><extension id=\"" + shortId + "\" name=\"" + shortId String ext = "<plugin><extension id=\"" + shortId + "\" name=\"" + shortId
+ "\" point=\"org.eclipse.cdt.core.ErrorParser\">" + "<errorparser class=\"" + cl.getName() + "\"/>" + "\" point=\"org.eclipse.cdt.core.ErrorParser\">" + "<errorparser class=\"" + cl.getName() + "\"/>"

View file

@ -74,6 +74,7 @@ public class ErrorParserManagerTest extends TestCase {
* Example code test the packages in the project * Example code test the packages in the project
* "com.qnx.tools.ide.cdt.core" * "com.qnx.tools.ide.cdt.core"
*/ */
@Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
/*** /***
* The test of the tests assume that they have a working workspace * The test of the tests assume that they have a working workspace
@ -106,7 +107,14 @@ public class ErrorParserManagerTest extends TestCase {
} }
}; };
epManager = new ErrorParserManager(cProject.getProject(), markerGenerator, null); String[] errorParsersIds = {
"org.eclipse.cdt.core.MakeErrorParser",
"org.eclipse.cdt.core.GCCErrorParser",
"org.eclipse.cdt.core.GASErrorParser",
"org.eclipse.cdt.core.GLDErrorParser",
"org.eclipse.cdt.core.VCErrorParser",
};
epManager = new ErrorParserManager(cProject.getProject(), markerGenerator, errorParsersIds);
} }
@ -115,6 +123,7 @@ public class ErrorParserManagerTest extends TestCase {
* *
* Called after every test case method. * Called after every test case method.
*/ */
@Override
protected void tearDown() { protected void tearDown() {
// release resources here and clean-up // release resources here and clean-up
} }