|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.9.0) E52944-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.ide.test.IdeFixture
oracle.jdeveloper.test.JDevFixture
public class JDevFixture
A test fixture for unit tests that require a JDeveloper-specific IDE environment. It extends IdeFixture
and configuration and basic usage are the same, except that getJDevFixture()
replaces IdeFixture.getIdeFixture()
. JDevFixture
adds support for creating, managing, and verifying the source content typical of JDeveloper projects. In particular, it offers createSourceFile*
methods, analogous to the createFile*
methods of IdeFixture
, that create files relative to project source paths.
An example test method that can appear in a vanilla JUnit test case:
public TestJDevFixture extends junit.framework.TestCase
{
private JDevFixture fixture = JDevFixture.getJDevFixture();
public void testJava ()
{
fixture.start(TestJDevFixture.class, "ImplicitJava");
Project project = fixture.createJDevProject();
JavaSourceNode node = (JavaSourceNode) fixture.createSourceFile("j.java", project, "public class j {}");
assertFalse(node.isOpen());
JavaManager manager = JavaManager.getJavaManager(project);
assertNotNull(manager.getFile(node.getURL()));
assertNotNull(manager.getSourceClass("j"));
}
}
The general orientation is towards tests involving files in project source paths. It seems like supporting content sets more generally makes sense, but it hasn't been done yet.
Constructor Summary | |
---|---|
JDevFixture() Creates a test fixture with the JDeveloper Java Edition product id and a shrouded extension of ".java-data" for ".java" . |
Method Summary | |
---|---|
void |
assertEquals(java.net.URL expectedRootURL, Project actualProject) Asserts that the expected contents of a project recursively equal the actual contents of the project. |
void |
assertEqualsRelative(java.lang.String expectedPath, Project actualProject) Asserts that the expected contents of a directory recursively equal the actual contents of the directory. |
Project |
createJDevProject() Creates or opens a project named "project.jpr" in the work directory with no source path entries and an output directory. |
Project |
createJDevProject(java.lang.String path) Creates or opens a project in the work directory with no source path entries and an output directory. |
Project |
createJDevProject(java.lang.String path, int sourcePathCount) Creates or opens a project in the work directory with source path entries and an output directory. |
Project |
createJDevProject(java.lang.String path, java.net.URL contentsURL) Creates or opens a project in the work directory with source path contents and an output directory. |
protected Project |
createJDevProjectNoSave(java.lang.String path, int sourcePathCount) Creates or opens a project in the work directory with source path entries and an output directory. |
Project |
createJDevProjectRelative(java.lang.String path, java.lang.String contentsPath) Creates or opens a project in the work directory with source path contents from a relative path and an output directory. |
protected Project |
createProject(java.net.URL url) |
java.net.URL |
createSourceDirectory(java.lang.String path, Project project, int entry) Creates a directory under a source path entry of a project. |
Node |
createSourceFile(java.lang.String path, Project project) Creates an empty file under the first project source path entry from a string. |
Node |
createSourceFile(java.lang.String path, Project project, int entry) Creates an empty file under a project source path entry from a string. |
Node |
createSourceFile(java.lang.String path, Project project, int entry, java.lang.String contents) Creates a file under a project source path entry from a string. |
Node |
createSourceFile(java.lang.String path, Project project, int entry, java.net.URL contentsURL) Creates a file under a project source path entry from a URL. |
Node |
createSourceFile(java.lang.String path, Project project, java.lang.String contents) Creates a file under the first project source path entry from a string. |
Node |
createSourceFile(java.lang.String path, Project project, java.net.URL contentsURL) Creates a file under the first project source path entry from a URL. |
Node |
createSourceFileRelative(java.lang.String path, Project project, int entry, java.lang.String contentsPath) Creates a file under a project source path entry with contents from a relative path. |
Node |
createSourceFileRelative(java.lang.String path, Project project, java.lang.String contentsPath) Creates a file under the first project source path entry from a relative path. |
java.net.URL |
createSourcePathEntry(int entry, Project project) Creates a source path entry in a project. |
static JDevFixture |
getJDevFixture() Gets the singleton JDeveloper fixture. |
Node |
getNode(java.lang.String path, Project project, int entry) Gets a node created in a project by this fixture. |
java.net.URL |
getSourcePathEntry(Project project, int entry) Gets the URL of a source path entry of a project. |
java.lang.String |
translateSourcePathToWorkPath(java.lang.String path, Project project, int entry) Translates a path relative to a project source path entry to a path relative to the work directory. |
Project |
updateJDevProject(Project project, java.net.URL contentsURL) Updates a project with the files located at the given contentsURL. |
Project |
updateJDevProjectRelative(Project project, java.lang.String contentsPath) Updates a project with the files located at the given relative contentsPath. |
Methods inherited from class oracle.ide.test.IdeFixture |
---|
addNode, addProjectToWorkspace, addShroudedExtension, assertEquals, assertEquals, assertEqualsFromResource, copyFiles, createContext, createContext, createContext, createDirectory, createFile, createFile, createFile, createFileRelative, createFiles, createFilesRelative, createProject, createProjectNoSave, createWorkspace, createWorkspace, delete, deleteChildren, dropNodes, errors, getChildren, getDataDirectory, getDataReader, getDataText, getDataUrl, getIdeFixture, getInstallationDirectory, getLocalTestClassDataDirectory, getLocalTestDataDirectory, getNode, getNode, getProductId, getTestClass, getTestClassDirectory, getTestDataDirectory, getTestName, getWorkDirectory, isStarted, isVerbose, output, removeShroudedExtension, resolveUrl, saveAll, setActive, setDataDirectory, setVerbose, setWorkDirectory, shroudExtension, start, start, start, startIde, unlockArchiveUrl, unshroudExtension, verbose |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JDevFixture()
".java-data"
for ".java"
.Method Detail |
---|
public static JDevFixture getJDevFixture()
public Node getNode(java.lang.String path, Project project, int entry)
IdeFixture.getNode(String path)
works equally well.path
- ` the path, relative to the project source path entry, of the node.project
- the project containing the source path entry.entry
- the index of the source path entry in the project.public java.net.URL getSourcePathEntry(Project project, int entry)
project
- The Project containing the source path entry.entry
- The index in the source path of the source path entry.public java.lang.String translateSourcePathToWorkPath(java.lang.String path, Project project, int entry)
path
- The path, relative to the source path root, to translate.project
- The Project containing the source path entry.entry
- The index in the source path of the source path entry.protected Project createProject(java.net.URL url)
createProject
in class oracle.ide.test.IdeFixture
public Project createJDevProject()
The output directory is created in the project directory, with a name formed by appending "-classes" to the simple name (e.g., "project-classes").
public Project createJDevProject(java.lang.String path)
The output directory is created in the project directory, with a name formed by appending "-classes" to the simple name (e.g., "project-classes").
path
- The path, relative to the work directory, of the project. If null, "project.jpr" is used.public Project createJDevProject(java.lang.String path, int sourcePathCount)
The source path entries are created in the directory containing the project file, with a name formed by appending "-src" and the entry index to the simple name (e.g., "project-src0"). The output directory is also created in the project directory, with a name formed by appending "-classes" to the simple name (e.g., "project-classes").
path
- The path, relative to the work directory, of the project. If null, "project.jpr" is used.sourcePathCount
- The number of source path entries to create.public Project createJDevProject(java.lang.String path, java.net.URL contentsURL)
The source path of the project is set to the top level directories copied into the project directory from the content directory or zip file. The output directory is also created in the project directory, with a name formed by appending "-classes" to the simple name (e.g., "project-classes").
path
- The path, relative to the work directory, of the project. If null, "project.jpr" is used.contentsURL
- URL of the directory, zip file, or tip file containing the initial source path contents of the project.public Project updateJDevProject(Project project, java.net.URL contentsURL)
project
- The project to update.contentsURL
- URL of the directory, zip file, or tip file containing the initial source path contents of the project.public Project createJDevProjectRelative(java.lang.String path, java.lang.String contentsPath)
The source path of the project is set to the top level directories copied into the project directory from the content directory or zip file. The output directory is also created in the project directory, with a name formed by appending "-classes" to the simple name (e.g., "project-classes"). Creates a set of files file under the work directory from a relative path.
path
- Path, relative to the work directory, of the project to create. If null, "project.jpr" is used.contentsPath
- Path, relative to the test class
, test data directory
, or data directory
of the directory, zip file, or tip file containing the initial source path contents of the project.public Project updateJDevProjectRelative(Project project, java.lang.String contentsPath)
project
- The project to update.contentsPath
- URL of the directory, zip file, or tip file containing the initial source path contents of the project.protected Project createJDevProjectNoSave(java.lang.String path, int sourcePathCount)
The source path entries are created in the directory containing the project file, with a name formed by appending "-src" and the entry index to the simple name (e.g., "project-src0"). The output directory is also created in the project directory, with a name formed by appending "-classes" to the simple name (e.g., "project-classes").
path
- The path, relative to the work directory, of the project. If null, "project.jpr" is used.sourcePathCount
- The number of source path entries to create.public java.net.URL createSourcePathEntry(int entry, Project project)
public java.net.URL createSourceDirectory(java.lang.String path, Project project, int entry)
path
- The path, relative to the project source path entry, of the directory to create.project
- The Project to which to add the created directory. If null, createJDevProject()
(null, null)
is used.entry
- The index of the source path entry to which to add the created directory.public Node createSourceFile(java.lang.String path, Project project)
path
- The path, relative to the first project source path entry, of the file to create.project
- The Project to which to add the created file. If null, createJDevProject()
(null, null)
is used.public Node createSourceFile(java.lang.String path, Project project, java.lang.String contents)
path
- The path, relative to the first project source path entry, of the file to create.project
- The Project to which to add the created file. If null, createJDevProject()
(null, null)
is used.contents
- A string containing the initial file contents.public Node createSourceFile(java.lang.String path, Project project, int entry)
path
- The path, relative to the specified project source path entry, of the file to create.project
- The Project
to which to add the created file, or null to use createJDevProject()
(null, null)
.entry
- The index of the source path entry to which to add the created file.public Node createSourceFile(java.lang.String path, Project project, int entry, java.lang.String contents)
path
- The path, relative to the specified project source path entry, of the file to create.project
- The Project
to which to add the created file, or null to use createJDevProject()
(null, null)
.entry
- The index of the source path entry to which to add the created file.contents
- A string containing the initial file contents.public Node createSourceFile(java.lang.String path, Project project, java.net.URL contentsURL)
path
- The path, relative to the first project source path entry, of the file to create.project
- The Project
to which to add the created file, or null to use createJDevProject()
(null, null)
.contentsURL
- URL of the file containing the initial file contents.public Node createSourceFile(java.lang.String path, Project project, int entry, java.net.URL contentsURL)
path
- The path, relative to the specified project source path entry, of the file to create.project
- The Project
to which to add the created file, or null to use createJDevProject()
(null, null)
.entry
- The index of the source path entry to which to add the created file.contentsURL
- URL of the file containing the initial file contents.public Node createSourceFileRelative(java.lang.String path, Project project, java.lang.String contentsPath)
path
- The path, relative to the project source path, of the file to create.project
- The Project
to which to add the created file, or null to use createJDevProject()
(null, null)
.contentsPath
- Path, relative to the test class
, test data directory
, or data directory
of the file providing the initial contents of the file.public Node createSourceFileRelative(java.lang.String path, Project project, int entry, java.lang.String contentsPath)
path
- The path, relative to the specified project source path entry, of the file to create.project
- The Project
to which to add the created file, or null to use createJDevProject()
(null, null)
.entry
- The index of the source path entry to which to add the created file.contentsPath
- Path, relative to the test class
, test data directory
, or data directory
of the file providing the initial contents of the file.public void assertEquals(java.net.URL expectedRootURL, Project actualProject)
expectedRootURL
- URL of the directory, zip file, or tip file containing the expected contents.actualProject
- The project containing the actual results.public void assertEqualsRelative(java.lang.String expectedPath, Project actualProject)
expectedPath
- Path, relative to the test class
, test data directory
, or data directory
of the directory, zip file, or tip file containing the expected source path contents of the project.actualProject
- The project containing the actual content.
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.9.0) E52944-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |