Skip to content

Commit

Permalink
Merge branch 'execution-printing'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Moore committed Jun 9, 2014
2 parents 94212ec + 2cfaad1 commit 9d56d2c
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,18 @@
* @author ian
*
*/
public interface IJunitNotifier extends INotifier {
//
// void notifyTestStarted(final Description junitDescription);
//
//
// void notifyTestFinished(final Description junitDescription);
//
//
// void notifyTestFailed(final Description junitDescription, final Throwable
// cause);
//
//
// void notifyTestIgnored(Description junitDescription);
//
public interface IJunitNotifier extends IExecutionListener {

/**
* @param junitNotifier
*/
void setJunitRunNotifier(RunNotifier junitNotifier);


/**
* @param descriptionMap
*/
void setDescriptionMap(Map<Long, Description> descriptionMap);


/**
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void setDescriptionMap(final Map<Long, Description> descriptionMap) {
* (com.technophobia.substeps.execution.ExecutionNode, java.lang.Throwable)
*/

public void notifyNodeFailed(final IExecutionNode node, final Throwable cause) {
public void onNodeFailed(final IExecutionNode node, final Throwable cause) {

final Description description = descriptionMap.get(Long.valueOf(node.getId()));
notifyTestFailed(description, cause);
Expand All @@ -135,7 +135,7 @@ public void notifyNodeFailed(final IExecutionNode node, final Throwable cause) {
* (com.technophobia.substeps.execution.ExecutionNode)
*/

public void notifyNodeStarted(final IExecutionNode node) {
public void onNodeStarted(final IExecutionNode node) {

final Description description = descriptionMap.get(Long.valueOf(node.getId()));

Expand All @@ -154,7 +154,7 @@ public void notifyNodeStarted(final IExecutionNode node) {
* (com.technophobia.substeps.execution.ExecutionNode)
*/

public void notifyNodeFinished(final IExecutionNode node) {
public void onNodeFinished(final IExecutionNode node) {

final Description description = descriptionMap.get(Long.valueOf(node.getId()));
notifyTestFinished(description);
Expand All @@ -169,7 +169,7 @@ public void notifyNodeFinished(final IExecutionNode node) {
* (com.technophobia.substeps.execution.ExecutionNode)
*/

public void notifyNodeIgnored(final IExecutionNode node) {
public void onNodeIgnored(final IExecutionNode node) {

final Description description = descriptionMap.get(Long.valueOf(node.getId()));
notifyTestIgnored(description);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void notifyTestIgnored(final Description des) {
* uk.co.itmoore.bddrunner.runner.INotifier#notifyTestFailed(uk.co.itmoore
* .bddrunner.execution.ExecutionNode, java.lang.Throwable)
*/
public void notifyTestFailed(final IExecutionNode rootNode, final Throwable cause) {
public void onTestFailed(final IExecutionNode rootNode, final Throwable cause) {

}

Expand All @@ -130,7 +130,7 @@ public void notifyTestFailed(final IExecutionNode rootNode, final Throwable caus
* uk.co.itmoore.bddrunner.runner.INotifier#notifyTestStarted(uk.co.itmoore
* .bddrunner.execution.ExecutionNode)
*/
public void notifyTestStarted(final IExecutionNode node) {
public void onTestStarted(final IExecutionNode node) {

}

Expand All @@ -141,7 +141,7 @@ public void notifyTestStarted(final IExecutionNode node) {
* uk.co.itmoore.bddrunner.runner.INotifier#notifyTestFinished(uk.co.itmoore
* .bddrunner.execution.ExecutionNode)
*/
public void notifyTestFinished(final IExecutionNode node) {
public void onTestFinished(final IExecutionNode node) {

}

Expand All @@ -163,7 +163,7 @@ public void setDescriptionMap(final Map<Long, Description> descriptionMap) {
* uk.co.itmoore.bddrunner.runner.INotifier#addListener(uk.co.itmoore.bddrunner
* .runner.INotifier)
*/
public void addListener(final INotifier listener) {
public void addListener(final IExecutionListener listener) {

}

Expand All @@ -174,7 +174,7 @@ public void addListener(final INotifier listener) {
* com.technophobia.substeps.runner.INotifier#notifyTestIgnored(com.technophobia
* .substeps.execution.ExecutionNode)
*/
public void notifyTestIgnored(final IExecutionNode node) {
public void onTestIgnored(final IExecutionNode node) {

}

Expand All @@ -185,7 +185,7 @@ public void notifyTestIgnored(final IExecutionNode node) {
* com.technophobia.substeps.runner.INotifier#notifyNodeFailed(com.technophobia
* .substeps.execution.ExecutionNode, java.lang.Throwable)
*/
public void notifyNodeFailed(final IExecutionNode rootNode, final Throwable cause) {
public void onNodeFailed(final IExecutionNode rootNode, final Throwable cause) {

}

Expand All @@ -196,7 +196,7 @@ public void notifyNodeFailed(final IExecutionNode rootNode, final Throwable caus
* com.technophobia.substeps.runner.INotifier#notifyNodeStarted(com.technophobia
* .substeps.execution.ExecutionNode)
*/
public void notifyNodeStarted(final IExecutionNode node) {
public void onNodeStarted(final IExecutionNode node) {

}

Expand All @@ -206,7 +206,7 @@ public void notifyNodeStarted(final IExecutionNode node) {
* @see com.technophobia.substeps.runner.INotifier#notifyNodeFinished(com.
* technophobia.substeps.execution.ExecutionNode)
*/
public void notifyNodeFinished(final IExecutionNode node) {
public void onNodeFinished(final IExecutionNode node) {

}

Expand All @@ -217,7 +217,7 @@ public void notifyNodeFinished(final IExecutionNode node) {
* com.technophobia.substeps.runner.INotifier#notifyNodeIgnored(com.technophobia
* .substeps.execution.ExecutionNode)
*/
public void notifyNodeIgnored(final IExecutionNode node) {
public void onNodeIgnored(final IExecutionNode node) {

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public class ExecutionConfig {
* @parameter default-value=true
* @required
*/
private boolean strict = true;
private final boolean strict = true;

/**
* If true any parse errors will fail the build immediately, rather than
Expand All @@ -95,7 +95,7 @@ public class ExecutionConfig {
* @parameter default-value=true
* @required
*/
private boolean fastFailParseErrors = true;
private final boolean fastFailParseErrors = true;

/**
* @parameter
Expand Down Expand Up @@ -131,29 +131,41 @@ public class ExecutionConfig {
*/
private String[] initialisationClass;

/**
*
*
*
* Class that implements INotifier will be called to notify of execution
* events
*
* @parameter
* @required
*/
private String[] executionListeners;

public SubstepsExecutionConfig asSubstepsExecutionConfig() throws MojoExecutionException {

try {
SubstepsExecutionConfig executionConfig = new SubstepsExecutionConfig();
final SubstepsExecutionConfig executionConfig = new SubstepsExecutionConfig();

reflectivelySetFields(executionConfig);

return executionConfig;

} catch (Exception exception) {
} catch (final Exception exception) {

throw new MojoExecutionException("Unable to convert " + ExecutionConfig.class.getName() + " into "
+ SubstepsExecutionConfig.class.getName(), exception);
}
}

private void reflectivelySetFields(SubstepsExecutionConfig executionConfig) throws NoSuchFieldException,
private void reflectivelySetFields(final SubstepsExecutionConfig executionConfig) throws NoSuchFieldException,
IllegalAccessException {

for (Field mojoField : ExecutionConfig.class.getDeclaredFields()) {
for (final Field mojoField : ExecutionConfig.class.getDeclaredFields()) {

if (!Modifier.isFinal(mojoField.getModifiers())) {
Field executionConfigField = SubstepsExecutionConfig.class.getDeclaredField(mojoField.getName());
final Field executionConfigField = SubstepsExecutionConfig.class.getDeclaredField(mojoField.getName());
executionConfigField.setAccessible(true);
executionConfigField.set(executionConfig, mojoField.get(this));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public class ForkedRunner implements MojoRunner {

private final InputStreamConsumer consumer;


ForkedRunner(final Log log, final int jmxPort, final String vmArgs, final List<String> testClasspathElements,
final List<String> stepImplementationArtifacts, final ArtifactResolver artifactResolver,
final ArtifactFactory artifactFactory, final MavenProjectBuilder mavenProjectBuilder,
Expand All @@ -106,13 +105,11 @@ public class ForkedRunner implements MojoRunner {
initialiseClient();
}


private void initialiseClient() throws MojoExecutionException {

this.substepsJmxClient.init(this.jmxPort);
}


public void shutdown() {

this.substepsJmxClient.shutdown();
Expand Down Expand Up @@ -143,7 +140,6 @@ public void shutdown() {

}


private InputStreamConsumer startMBeanJVM() throws MojoExecutionException {
// launch the jvm process that will contain the Substeps MBean Server
// build up the class path based on this projects classpath
Expand Down Expand Up @@ -198,7 +194,6 @@ private InputStreamConsumer startMBeanJVM() throws MojoExecutionException {
return localConsumer;
}


/**
* @param cpBuf
* @return
Expand Down Expand Up @@ -248,7 +243,6 @@ private List<String> buildSubstepsRunnerCommand() throws MojoExecutionException
return command;
}


@SuppressWarnings("unchecked")
private void addCurrentVmArgs(final List<String> command) {

Expand All @@ -259,7 +253,6 @@ private void addCurrentVmArgs(final List<String> command) {

}


private String createClasspathString() throws MojoExecutionException {

final List<String> classPathElements = Lists.newArrayList();
Expand All @@ -270,7 +263,6 @@ private String createClasspathString() throws MojoExecutionException {
return Joiner.on(File.pathSeparator).join(classPathElements);
}


@SuppressWarnings("unchecked")
private List<String> resolveStepImplementationArtifacts() throws MojoExecutionException {

Expand Down Expand Up @@ -337,36 +329,31 @@ private List<String> resolveStepImplementationArtifacts() throws MojoExecutionEx
return stepImplementationArtifactJars;
}


private void addArtifactPath(final List<String> stepImplementationArtifactJars, final Artifact artifact) {
final String path = artifact.getFile().getPath();
this.log.info("Adding dependency to classpath for forked jvm: " + path);
stepImplementationArtifactJars.add(path);
}


public RootNode prepareExecutionConfig(final SubstepsExecutionConfig theConfig) {

return this.substepsJmxClient.prepareExecutionConfig(theConfig);
}


public RootNode run() {

this.log.info("Running substeps tests in forked jvm");
return this.substepsJmxClient.run();
}


public List<SubstepExecutionFailure> getFailures() {

return this.substepsJmxClient.getFailures();
}

public void addNotifier(final IExecutionListener listener) {

public void addNotifier(final INotifier notifier) {

this.substepsJmxClient.addNotifier(notifier);
this.substepsJmxClient.addNotifier(listener);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class InProcessRunner implements MojoRunner {
SubstepsRunner executionNodeRunner = ExecutionNodeRunnerFactory.createRunner();
private final Log log;

InProcessRunner(Log log) {
InProcessRunner(final Log log) {

this.log = log;
}
Expand All @@ -39,7 +39,7 @@ public RootNode run() {
return executionNodeRunner.run();
}

public RootNode prepareExecutionConfig(SubstepsExecutionConfig theConfig) {
public RootNode prepareExecutionConfig(final SubstepsExecutionConfig theConfig) {

return executionNodeRunner.prepareExecutionConfig(theConfig);
}
Expand All @@ -48,8 +48,8 @@ public List<SubstepExecutionFailure> getFailures() {
return executionNodeRunner.getFailures();
}

public void addNotifier(INotifier notifier) {
executionNodeRunner.addNotifier(notifier);
public void addNotifier(final IExecutionListener listener) {
executionNodeRunner.addNotifier(listener);
}

public void shutdown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public void init(final int portNumber) throws MojoExecutionException {

throw new MojoExecutionException("Failed to connect to substeps server", e);

} catch (NullPointerException e) {
} catch (final NullPointerException e) {

throw new MojoExecutionException("Failed to connect to substeps server", e);
} catch (MalformedObjectNameException e) {
} catch (final MalformedObjectNameException e) {

throw new MojoExecutionException("Failed to connect to substeps server", e);
}
Expand All @@ -99,9 +99,9 @@ public RootNode run() {
return this.mbean.run();
}

public void addNotifier(INotifier notifier) {
public void addNotifier(final IExecutionListener listener) {

this.mbean.addNotifier(notifier);
this.mbean.addNotifier(listener);
}

public boolean shutdown() {
Expand All @@ -112,7 +112,7 @@ public boolean shutdown() {
this.mbean.shutdown();
successfulShutdown = true;

} catch (RuntimeException re) {
} catch (final RuntimeException re) {

this.log.debug("Unable to connect to server to shutdown, it may have already closed");

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ There is also a [Substeps Google group](http://groups.google.com/group/substeps?

Release Notes
=============
1.1.3
-----
* Changes to support ExecutionListener refactoring in core and api projects

1.1.2
-----
* version number bump in line with other substeps libraries

1.1.1
-----
Expand Down
Loading

0 comments on commit 9d56d2c

Please sign in to comment.