|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.softevo.ample.AmpleLauncher
public class AmpleLauncher
Control class for the instrumentation and launching the instrumented code.
Nested Class Summary | |
---|---|
private class |
AmpleLauncher.SysOutMonitor
A ProgressMonitor that simply logs to System.out |
private class |
AmpleLauncher.TestListenerFaker
A fake class that is used to convince the remote JUnit-Runner of Eclipse that everything is okay. |
Field Summary | |
---|---|
private InstrumentationConfiguration |
config
The instrumentation configuration to be used. |
private org.eclipse.debug.core.ILaunchConfiguration |
launchConfiguration
The launchh configuration used to execute the virtual machine for running the tests. |
private java.util.ArrayList |
outputLocations
Project's output directories stored as full path names. |
private java.io.File |
pluginDir
Project-specific working area for the Ample plugin. |
private org.eclipse.jdt.core.IJavaProject |
project
Java project targeted by the JUnits tests and analysed by Ample. |
private java.util.ArrayList |
requiredJars
External JAR files required by the project stored as full path names. |
Constructor Summary | |
---|---|
AmpleLauncher(org.eclipse.jdt.core.IJavaProject project,
InstrumentationConfiguration config,
org.eclipse.debug.core.ILaunchConfiguration launchConfiguration)
Initializes a new instance of AmpleLauncher . |
Method Summary | |
---|---|
private void |
addJUnitJars(java.util.ArrayList jarsList)
Adds to the given list the full names of the two JAR files that enable JUnit support in Eclipse. |
void |
cleanWorkingDir()
Clears the contents of Ample's working directory. |
protected void |
copyAmpleRuntimeClasses(java.lang.String sourceDirectory)
This method copies all runtime classes needed for the execution of AMPLE. |
void |
copyClassFiles()
Copies all the output files of the targeted project into the working directory. |
private void |
copyDirectoryRecursively(java.io.File sourceDirectory,
java.io.File targetDirectory)
|
private static void |
copyFile(java.io.File file,
java.io.File targetDir)
Copies a specified file to a given location. |
protected void |
copyFromJar(java.lang.String sourceDirectory)
This method is currently not used. |
private java.util.HashMap |
createClassNameToJavaTypeMap(java.util.HashSet instrumentClassNames)
|
private java.lang.String[] |
createClassPath()
Computes the classpath using the directory with the instrumented .class files and the required JAR files. |
protected org.eclipse.jdt.launching.VMRunnerConfiguration |
createConfig(java.lang.String testName,
int port)
Creates a configuration with class path that includes org.eclipse.jdt.junit plugin. |
protected java.lang.String |
findJUnitJarInPlugins()
|
private java.util.HashSet |
getInstrumentClassNames(org.softevo.sibrelib.source.ClassFileSource source,
org.softevo.sibrelib.classfilter.ClassFilter filter)
Calculates the names of all classes that shall be instrumented. |
private void |
initLists()
Initializes the two fields - outputLocations and requiredJars . |
java.util.HashMap |
instrument()
Instruments all the .class files in the working directory. |
AverageSequenceWeightEvaluator |
launch(org.eclipse.jdt.internal.junit.ui.TestRunInfo failingRun,
org.eclipse.jdt.internal.junit.ui.TestRunInfo[] passingRuns,
org.eclipse.core.runtime.IProgressMonitor monitor)
Reruns the JUnit tests requested by the user on the instrumented byte code. |
void |
prepareRuntimeClasses()
This method prepares and copies all runtime classes needed by ample. |
protected XMLPatternFileReader |
runTest(org.eclipse.jdt.internal.junit.ui.TestRunInfo testRun,
org.eclipse.jdt.launching.IVMInstall vm)
This method executes a junit test. |
void |
streamAppended(java.lang.String text,
org.eclipse.debug.core.model.IStreamMonitor monitor)
Implementation of IStreamListener . |
protected void |
writeOptionsClass()
This method creates the options class and fills it with the values needed by the instrumentation configuration. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private InstrumentationConfiguration config
private org.eclipse.debug.core.ILaunchConfiguration launchConfiguration
private org.eclipse.jdt.core.IJavaProject project
private java.io.File pluginDir
project
private java.util.ArrayList outputLocations
private java.util.ArrayList requiredJars
The last two entries of this list are the names of the two JAR files that enable JUnit support in Eclipse.
Constructor Detail |
---|
public AmpleLauncher(org.eclipse.jdt.core.IJavaProject project, InstrumentationConfiguration config, org.eclipse.debug.core.ILaunchConfiguration launchConfiguration) throws org.eclipse.jdt.core.JavaModelException, JUnitSupportException, java.lang.NullPointerException
AmpleLauncher
.
project
- Targeted Java project.
org.eclipse.jdt.core.JavaModelException
- If an error occured while accessing resources of the targeted Java project.
JUnitSupportException
- If locating Eclipse's JUnit support (the JAR files) has failed.
java.lang.NullPointerException
- ...Method Detail |
---|
public void streamAppended(java.lang.String text, org.eclipse.debug.core.model.IStreamMonitor monitor)
IStreamListener
.
streamAppended
in interface org.eclipse.debug.core.IStreamListener
public void cleanWorkingDir()
private java.util.HashSet getInstrumentClassNames(org.softevo.sibrelib.source.ClassFileSource source, org.softevo.sibrelib.classfilter.ClassFilter filter)
source
- the class file source
private java.util.HashMap createClassNameToJavaTypeMap(java.util.HashSet instrumentClassNames) throws org.eclipse.jdt.core.JavaModelException
org.eclipse.jdt.core.JavaModelException
private void copyDirectoryRecursively(java.io.File sourceDirectory, java.io.File targetDirectory) throws java.io.IOException
java.io.IOException
public void copyClassFiles() throws java.io.IOException
java.io.IOException
- If copying a file to Ample's working directory fails, e.g. due to name collision.public java.util.HashMap instrument() throws org.softevo.sibrelib.InstrumentationException, java.io.IOException, java.lang.ClassNotFoundException, org.eclipse.core.runtime.CoreException
Note that copyClassFiles()
should be called prior to calling this method.
org.softevo.sibrelib.InstrumentationException
java.io.IOException
java.lang.ClassNotFoundException
org.eclipse.core.runtime.CoreException
protected void writeOptionsClass() throws java.io.IOException
java.io.IOException
- if an exception occurs writing the classprotected void copyFromJar(java.lang.String sourceDirectory) throws java.io.IOException
sourceDirectory
-
java.io.IOException
protected void copyAmpleRuntimeClasses(java.lang.String sourceDirectory) throws java.io.IOException
sourceDirectory
- the directory where the classes are located (the plugin directory of ample)
java.io.IOException
- if an exception occurs copying classesprotected java.lang.String findJUnitJarInPlugins() throws java.net.MalformedURLException, java.io.IOException
java.net.MalformedURLException
java.io.IOException
public void prepareRuntimeClasses() throws java.io.IOException, java.net.MalformedURLException
It should be called after instrument()
.
java.io.IOException
java.net.MalformedURLException
protected XMLPatternFileReader runTest(org.eclipse.jdt.internal.junit.ui.TestRunInfo testRun, org.eclipse.jdt.launching.IVMInstall vm) throws org.eclipse.core.runtime.CoreException, AnalysisException, java.util.MissingResourceException
testRun
- the test to be executedvm
- the virtual machine to run the test
null
if something went wrong
org.eclipse.core.runtime.CoreException
- if an exception occurs launching the process
AnalysisException
- if an exception occurs reading the pattern file
java.util.MissingResourceException
- if a workspace ressource cannot be foundpublic AverageSequenceWeightEvaluator launch(org.eclipse.jdt.internal.junit.ui.TestRunInfo failingRun, org.eclipse.jdt.internal.junit.ui.TestRunInfo[] passingRuns, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException, java.util.MissingResourceException, AnalysisException
Note that instrument()
should be called prior to calling this method.
junitLaunchConfig
- Launch configuration of the JUnit tests run before running Ample.testRuns
- Array of test runs to be launched.
org.eclipse.core.runtime.CoreException
- ...
java.util.MissingResourceException
AnalysisException
private static void copyFile(java.io.File file, java.io.File targetDir) throws java.io.IOException
file
- File to be copied. If the specified file does not exist, calling this method has no effect.targetDir
- Location of the file.
java.io.IOException
- When I/O error occurs.private void addJUnitJars(java.util.ArrayList jarsList) throws JUnitSupportException
Note: This method contains code copied from JUnitLaunchConfiguration.createClassPath(ILaunchConfiguration)
.
jarsList
- List of JAR file names.
JUnitSupportException
- If locating any of the two JAR files has failed.
java.lang.NullPointerException
- If jarsList
is null
.private void initLists() throws org.eclipse.jdt.core.JavaModelException, JUnitSupportException, java.lang.NullPointerException
outputLocations
and requiredJars
.
org.eclipse.jdt.core.JavaModelException
- If an error occured while accessing resources of the targeted Java project.
JUnitSupportException
- If locating Eclipse's JUnit support (the JAR files) has failed.
java.lang.NullPointerException
- ...private java.lang.String[] createClassPath()
String
array.protected org.eclipse.jdt.launching.VMRunnerConfiguration createConfig(java.lang.String testName, int port) throws org.eclipse.core.runtime.CoreException, java.util.MissingResourceException
org.eclipse.jdt.junit
plugin.
In addition it adds the port for the RemoteTestRunner as an argument.
Note: This method contains code copied from
JUnitLaunchConfiguration.createVMRunner(ILaunchConfiguration, IType[], int)
.
testName
- Name of test to be run. It has the form {classname}:{methodname}.
- Throws:
org.eclipse.core.runtime.CoreException
- ...
java.util.MissingResourceException
- If no free port could be found.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |