1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fixed up the test suites to use getInstallURL and

asLocalURL to find the location of the test plugins.
This commit is contained in:
Doug Schaefer 2004-02-13 20:23:31 +00:00
parent 1300bda0b8
commit c7241a4d1a
14 changed files with 64 additions and 55 deletions

View file

@ -664,18 +664,19 @@ import org.eclipse.core.runtime.Platform;
} }
private IFile importFile(String fileName, String resourceLocation)throws Exception{ private IFile importFile(String fileName, String resourceLocation)throws Exception{
String testCaseName = this.getName(); String testCaseName = this.getName();
//Obtain file handle
//Obtain file handle file = testProject.getProject().getFile(fileName);
file = testProject.getProject().getFile(fileName); String pluginRoot = Platform.asLocalURL(
String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile(); Platform.getPlugin("org.eclipse.cdt.core.tests")
//Create file input stream .getDescriptor().getInstallURL()).getFile();
monitor = new NullProgressMonitor(); //Create file input stream
if (!file.exists()){ monitor = new NullProgressMonitor();
file.create(new FileInputStream(pluginRoot + resourceLocation),false,monitor); if (!file.exists()) {
} file.create(new FileInputStream(pluginRoot + resourceLocation),
fileDoc = new IFileDocument(file); false, monitor);
}
return file; fileDoc = new IFileDocument(file);
return file;
} }
} }

View file

@ -35,7 +35,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform;
/** /**
* @author bgheorgh * @author bgheorgh
@ -129,17 +129,20 @@ public class IndexManagerTests extends TestCase {
return cPrj.getProject(); return cPrj.getProject();
} }
private IFile importFile(String fileName, String resourceLocation)throws Exception{ private IFile importFile(String fileName, String resourceLocation)throws Exception {
//Obtain file handle //Obtain file handle
file = testProject.getProject().getFile(fileName); file = testProject.getProject().getFile(fileName);
String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile(); String pluginRoot = Platform.asLocalURL(
//Create file input stream Platform.getPlugin("org.eclipse.cdt.core.tests")
monitor = new NullProgressMonitor(); .getDescriptor().getInstallURL()).getFile();
if (!file.exists()){ //Create file input stream
file.create(new FileInputStream(pluginRoot + resourceLocation),false,monitor); monitor = new NullProgressMonitor();
} if (!file.exists()) {
fileDoc = new IFileDocument(file); file.create(new FileInputStream(pluginRoot + resourceLocation),
return file; false, monitor);
}
fileDoc = new IFileDocument(file);
return file;
} }
/* /*

View file

@ -25,6 +25,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
@ -73,13 +74,13 @@ public class ArchiveTests 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"
*/ */
protected void setUp() throws CoreException,FileNotFoundException { protected void setUp() throws Exception {
/*** /***
* Setup the various files, paths and projects that are needed by the * Setup the various files, paths and projects that are needed by the
* tests * tests
*/ */
String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile(); String pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL()).getFile();
testProject=CProjectHelper.createCProject("filetest", "none"); testProject=CProjectHelper.createCProject("filetest", "none");
if (testProject==null) if (testProject==null)
fail("Unable to create project"); fail("Unable to create project");

View file

@ -26,6 +26,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
@ -63,7 +64,7 @@ public class BinaryTests 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"
*/ */
protected void setUp() throws CoreException,FileNotFoundException { protected void setUp() throws Exception {
String pluginRoot; String pluginRoot;
/*** /***
* The tests assume that they have a working workspace * The tests assume that they have a working workspace
@ -98,7 +99,7 @@ public class BinaryTests extends TestCase {
if (testProject==null) if (testProject==null)
fail("Unable to create project"); fail("Unable to create project");
pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile(); pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL()).getFile();
cfile = testProject.getProject().getFile("exetest.c"); cfile = testProject.getProject().getFile("exetest.c");
if (!cfile.exists()) { if (!cfile.exists()) {

View file

@ -45,7 +45,7 @@ import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform;
public class CModelElementsTests extends TestCase { public class CModelElementsTests extends TestCase {
private ICProject fCProject; private ICProject fCProject;
@ -62,9 +62,10 @@ public class CModelElementsTests extends TestCase {
super(name); super(name);
} }
protected void setUp() { protected void setUp() throws Exception {
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile(); String pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL())
.getFile();
fCProject= CProjectHelper.createCCProject("TestProject1", "bin"); fCProject= CProjectHelper.createCCProject("TestProject1", "bin");
headerFile = fCProject.getProject().getFile("CModelElementsTest.h"); headerFile = fCProject.getProject().getFile("CModelElementsTest.h");

View file

@ -26,6 +26,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
/** /**
@ -58,7 +59,7 @@ public class CModelTests 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"
*/ */
protected void setUp() throws CoreException { 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
* and workspace root object to use to create projects/files in, * and workspace root object to use to create projects/files in,
@ -72,7 +73,7 @@ public class CModelTests extends TestCase {
fail("Workspace was not setup"); fail("Workspace was not setup");
if (root==null) if (root==null)
fail("Workspace root was not setup"); fail("Workspace root was not setup");
pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile(); pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL()).getFile();
desc=workspace.getDescription(); desc=workspace.getDescription();
desc.setAutoBuilding(false); desc.setAutoBuilding(false);
workspace.setDescription(desc); workspace.setDescription(desc);

View file

@ -37,7 +37,7 @@ import org.eclipse.cdt.testplugin.TestPluginLauncher;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform;
/** /**
* Class for testing the C Element Delta Builder. * Class for testing the C Element Delta Builder.
@ -64,9 +64,9 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
super(name); super(name);
} }
protected void setUp() { protected void setUp() throws Exception {
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile(); String pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL()).getFile();
fCProject= CProjectHelper.createCCProject("TestProject1", "bin"); fCProject= CProjectHelper.createCCProject("TestProject1", "bin");
//Path filePath = new Path(ResourcesPlugin.getWorkspace().getRoot().getLocation().toString()+ fCProject.getPath().toString()+ "/WorkingCopyTest.h"); //Path filePath = new Path(ResourcesPlugin.getWorkspace().getRoot().getLocation().toString()+ fCProject.getPath().toString()+ "/WorkingCopyTest.h");

View file

@ -17,7 +17,7 @@ import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform;
/** /**
* @author bnicolle * @author bnicolle
@ -54,9 +54,9 @@ public abstract class IntegratedCModelTest extends TestCase {
*/ */
abstract public String getSourcefileResource(); abstract public String getSourcefileResource();
public void setUp() { public void setUp() throws Exception {
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile(); String pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL()).getFile();
fCProject= CProjectHelper.createCCProject("TestProject1", "bin"); fCProject= CProjectHelper.createCCProject("TestProject1", "bin");

View file

@ -26,6 +26,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
/** /**
* @author jcamelon * @author jcamelon
@ -71,7 +72,7 @@ public class TranslationUnitBaseTest 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"
*/ */
protected void setUp() throws CoreException, FileNotFoundException protected void setUp() throws Exception
{ {
/*** /***
* The rest of the tests assume that they have a working workspace * The rest of the tests assume that they have a working workspace
@ -79,7 +80,7 @@ public class TranslationUnitBaseTest extends TestCase
* so we need to get them setup first. * so we need to get them setup first.
*/ */
IWorkspaceDescription desc; IWorkspaceDescription desc;
String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile(); String pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL()).getFile();
workspace= ResourcesPlugin.getWorkspace(); workspace= ResourcesPlugin.getWorkspace();
root= workspace.getRoot(); root= workspace.getRoot();
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();

View file

@ -28,7 +28,7 @@ import org.eclipse.cdt.testplugin.TestPluginLauncher;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform;
/** /**
* Contains unit test cases for Working Copies. Run using JUnit Plugin Test * Contains unit test cases for Working Copies. Run using JUnit Plugin Test
@ -54,9 +54,9 @@ public class WorkingCopyTests extends TestCase {
super(name); super(name);
} }
protected void setUp() { protected void setUp() throws Exception {
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile(); String pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL()).getFile();
fCProject= CProjectHelper.createCCProject("TestProject1", "bin"); fCProject= CProjectHelper.createCCProject("TestProject1", "bin");
//Path filePath = new Path(ResourcesPlugin.getWorkspace().getRoot().getLocation().toString()+ fCProject.getPath().toString()+ "/WorkingCopyTest.h"); //Path filePath = new Path(ResourcesPlugin.getWorkspace().getRoot().getLocation().toString()+ fCProject.getPath().toString()+ "/WorkingCopyTest.h");

View file

@ -34,7 +34,7 @@ import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform;
/** /**
* @author aniefer * @author aniefer
@ -106,10 +106,10 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
return cPrj.getProject(); return cPrj.getProject();
} }
private void importFile(String fileName, String resourceLocation)throws Exception{ private void importFile(String fileName, String resourceLocation) throws Exception{
//Obtain file handle //Obtain file handle
file = testProject.getProject().getFile(fileName); file = testProject.getProject().getFile(fileName);
String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile(); String pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL()).getFile();
//Create file input stream //Create file input stream
if (!file.exists()){ if (!file.exists()){

View file

@ -30,7 +30,7 @@ import org.eclipse.cdt.internal.core.search.matching.MatchLocator;
import org.eclipse.cdt.internal.core.search.matching.NamespaceDeclarationPattern; import org.eclipse.cdt.internal.core.search.matching.NamespaceDeclarationPattern;
import org.eclipse.cdt.internal.core.search.matching.OrPattern; import org.eclipse.cdt.internal.core.search.matching.OrPattern;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform;
/** /**
* @author aniefer * @author aniefer
@ -317,8 +317,8 @@ public class OtherPatternTests extends BaseSearchTest {
assertEquals( matches.size(), 2 ); assertEquals( matches.size(), 2 );
} }
public void testNoResourceSearching(){ public void testNoResourceSearching() throws Exception {
String pluginRoot = org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile(); String pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL()).getFile();
String path = pluginRoot + "resources/search/include.h"; String path = pluginRoot + "resources/search/include.h";
ICSearchPattern pattern = SearchEngine.createSearchPattern( "Head", CLASS, REFERENCES, true ); ICSearchPattern pattern = SearchEngine.createSearchPattern( "Head", CLASS, REFERENCES, true );

View file

@ -24,7 +24,7 @@ import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.core.parser.ScannerInfo;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform;
/** /**
* @author jcamelon * @author jcamelon
@ -51,7 +51,7 @@ public class ParseTestOnSearchFiles extends TestCase
} }
protected void setUp() throws Exception { protected void setUp() throws Exception {
pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile(); pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL()).getFile();
name = pluginRoot+ "resources/search/classDecl.cpp"; name = pluginRoot+ "resources/search/classDecl.cpp";
fileIn = new FileInputStream(name); fileIn = new FileInputStream(name);
} }

View file

@ -38,7 +38,7 @@ import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.text.Document; import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.contentassist.ICompletionProposal;
@ -75,7 +75,7 @@ public abstract class CompletionProposalsBaseTest extends TestCase{
protected void setUp() throws Exception { protected void setUp() throws Exception {
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin(pluginName).find(new Path("/")).getFile(); String pluginRoot = Platform.asLocalURL(Platform.getPlugin(pluginName).getDescriptor().getInstallURL()).getFile();
fCProject= CProjectHelper.createCProject(projectName, projectType); fCProject= CProjectHelper.createCProject(projectName, projectType);
fHeaderFile = fCProject.getProject().getFile(getHeaderFileName()); fHeaderFile = fCProject.getProject().getFile(getHeaderFileName());