Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-03

oracle.jdeveloper.test
Class JDevFixture

java.lang.Object
  extended by oracle.ide.test.IdeFixture
      extended by oracle.jdeveloper.test.JDevFixture
All Implemented Interfaces:
oracle.ide.boot.IdeInvoker

public class JDevFixture
extends oracle.ide.test.IdeFixture

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.
 boolean saveAll()
          Save all the dirty nodes.
 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.
 
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, errors, getDataDirectory, getDataReader, getDataText, getDataUrl, getIdeFixture, getInstallationDirectory, getLocalTestDataDirectory, getNode, getNode, getProductId, getTestClass, getTestClassDirectory, getTestDataDirectory, getTestName, getUserDirectory, getWorkDirectory, isStarted, isVerbose, output, removeShroudedExtension, resolveUrl, setActive, setDataDirectory, setInstallationDirectory, setUserDirectory, setVerbose, setWorkDirectory, shroudExtension, start, start, start, startIde, unlockArchiveUrl, unshroudExtension
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDevFixture

public JDevFixture()
Creates a test fixture with the JDeveloper Java Edition product id and a shrouded extension of ".java-data" for ".java".

Method Detail

getJDevFixture

public static JDevFixture getJDevFixture()
Gets the singleton JDeveloper fixture.


getNode

public Node getNode(java.lang.String path,
                    Project project,
                    int entry)
Gets a node created in a project by this fixture. In the absence of multiple nodes with the same path relative to their respective source path entries, IdeFixture.getNode(String path) works equally well.

Parameters:
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.

getSourcePathEntry

public java.net.URL getSourcePathEntry(Project project,
                                       int entry)
Gets the URL of a source path entry of a project.

Parameters:
project - The Project containing the source path entry.
entry - The index in the source path of the source path entry.

translateSourcePathToWorkPath

public 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.

Parameters:
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.

createProject

protected Project createProject(java.net.URL url)
Overrides:
createProject in class oracle.ide.test.IdeFixture

createJDevProject

public Project createJDevProject()
Creates or opens a project named "project.jpr" in the work directory with no source path entries and an output directory.

The output directory is created in the project directory, with a name formed by appending "-classes" to the simple name (e.g., "project-classes").


createJDevProject

public Project createJDevProject(java.lang.String path)
Creates or opens a project in the work directory with no source path entries and an output directory.

The output directory is created in the project directory, with a name formed by appending "-classes" to the simple name (e.g., "project-classes").

Parameters:
path - The path, relative to the work directory, of the project. If null, "project.jpr" is used.

createJDevProject

public 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.

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").

Parameters:
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.

createJDevProject

public 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.

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").

Parameters:
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.
Returns:
the created Project.

createJDevProjectRelative

public 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.

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.

Parameters:
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.

createJDevProjectNoSave

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.

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").

Parameters:
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.

createSourcePathEntry

public java.net.URL createSourcePathEntry(int entry,
                                          Project project)
Creates a source path entry in a project.


createSourceDirectory

public java.net.URL createSourceDirectory(java.lang.String path,
                                          Project project,
                                          int entry)
Creates a directory under a source path entry of a project.

Parameters:
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.

createSourceFile

public Node createSourceFile(java.lang.String path,
                             Project project)
Creates an empty file under the first project source path entry from a string.

Parameters:
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.

createSourceFile

public 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.

Parameters:
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.

createSourceFile

public Node createSourceFile(java.lang.String path,
                             Project project,
                             int entry)
Creates an empty file under a project source path entry from a string.

Parameters:
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.

createSourceFile

public 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.

Parameters:
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.

createSourceFile

public 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.

Parameters:
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.

createSourceFile

public 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.

Parameters:
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.

createSourceFileRelative

public 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.

Parameters:
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.

createSourceFileRelative

public 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.

Parameters:
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.

saveAll

public boolean saveAll()
Save all the dirty nodes. This code has been copied from SaveAllCommand which cannot be used because UI dependencies.

Returns:
false if at least one node could not be saved.

assertEquals

public void assertEquals(java.net.URL expectedRootURL,
                         Project actualProject)
Asserts that the expected contents of a project recursively equal the actual contents of the project. Effectively, this recursively comparese each directory immediately under the expected root directory against a the directory of the same name in the project directory. Extra files and directories in the project directory do not cause a failure.

Parameters:
expectedRootURL - URL of the directory, zip file, or tip file containing the expected contents.
actualProject - The project containing the actual results.

assertEqualsRelative

public void assertEqualsRelative(java.lang.String expectedPath,
                                 Project actualProject)
Asserts that the expected contents of a directory recursively equal the actual contents of the directory. Effectively, this recursively comparese each directory immediately under the expected root directory against a the directory of the same name in the project directory. Extra files and directories in the project directory do not cause a failure.

Parameters:
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)

E13403-03

Copyright © 1997, 2009, Oracle. All rights reserved.