use of name.herlin.command.UnsetInputPropertiesException in project pmd-eclipse-plugin by pmd.
the class DetectCutAndPasteCmdTest method testDetectCutAndPasteCmdNullArg1.
/**
* Test robustness #1
*
* @throws CommandException
*/
@Test
public void testDetectCutAndPasteCmdNullArg1() throws CommandException {
try {
final DetectCutAndPasteCmd cmd = new DetectCutAndPasteCmd();
cmd.setProject(null);
cmd.setRenderer(new SimpleRenderer());
cmd.setReportName(PMDRuntimeConstants.SIMPLE_CPDREPORT_NAME);
cmd.performExecute();
Assert.fail();
} catch (final UnsetInputPropertiesException e) {
// yes cool
}
}
use of name.herlin.command.UnsetInputPropertiesException in project pmd-eclipse-plugin by pmd.
the class RenderReportCmdTest method testRenderReportCmdNullArg3.
/**
* Test robustness #3
*
* @throws CommandException
*/
@Test
public void testRenderReportCmdNullArg3() throws CommandException {
try {
final RenderReportsCmd cmd = new RenderReportsCmd();
cmd.setProject(this.testProject);
cmd.registerRenderer(new HTMLRenderer(), null);
cmd.performExecute();
Assert.fail();
} catch (final UnsetInputPropertiesException e) {
// yes cool
}
}
use of name.herlin.command.UnsetInputPropertiesException in project pmd-eclipse-plugin by pmd.
the class RenderReportCmdTest method testRenderReportCmdNullArg1.
/**
* Test robustness #1
*
* @throws CommandException
*/
@Test
public void testRenderReportCmdNullArg1() throws CommandException {
try {
final RenderReportsCmd cmd = new RenderReportsCmd();
cmd.setProject(null);
cmd.registerRenderer(new HTMLRenderer(), PMDRuntimeConstants.HTML_REPORT_NAME);
cmd.performExecute();
Assert.fail();
} catch (final UnsetInputPropertiesException e) {
// yes cool
}
}
use of name.herlin.command.UnsetInputPropertiesException in project pmd-eclipse-plugin by pmd.
the class RenderReportCmdTest method testRenderReportCmdNullArg5.
/**
* Test robustness #5
*
* @throws CommandException
*/
@Test
public void testRenderReportCmdNullArg5() throws CommandException {
try {
final RenderReportsCmd cmd = new RenderReportsCmd();
cmd.setProject(null);
cmd.registerRenderer(new HTMLRenderer(), null);
cmd.performExecute();
Assert.fail();
} catch (final UnsetInputPropertiesException e) {
// yes cool
}
}
use of name.herlin.command.UnsetInputPropertiesException in project pmd-eclipse-plugin by pmd.
the class JobCommandProcessor method processCommand.
/**
* @see name.herlin.command.CommandProcessor#processCommand(name.herlin.command.AbstractProcessableCommand)
*/
public void processCommand(final AbstractProcessableCommand aCommand) throws CommandException {
LOG.debug("Begining job command " + aCommand.getName());
if (!aCommand.isReadyToExecute()) {
throw new UnsetInputPropertiesException();
}
final Job job = new Job(aCommand.getName()) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
if (aCommand instanceof AbstractDefaultCommand) {
((AbstractDefaultCommand) aCommand).setMonitor(monitor);
}
Timer timer = new Timer();
aCommand.execute();
timer.stop();
PMDPlugin.getDefault().logInformation("Command " + aCommand.getName() + " excecuted in " + timer.getDuration() + "ms");
} catch (CommandException e) {
PMDPlugin.getDefault().logError("Error executing command " + aCommand.getName(), e);
}
synchronized (outstanding) {
count.decrementAndGet();
Job job = outstanding.poll();
if (job != null) {
job.schedule();
}
}
return Status.OK_STATUS;
}
};
if (aCommand instanceof AbstractDefaultCommand) {
job.setUser(((AbstractDefaultCommand) aCommand).isUserInitiated());
}
synchronized (outstanding) {
if (count.incrementAndGet() > 10) {
// too many already running, put in a queue to run later
outstanding.add(job);
} else {
job.schedule();
}
}
this.addJob(aCommand, job);
LOG.debug("Ending job command " + aCommand.getName());
}
Aggregations