Search in sources :

Example 1 with SimpleRenderer

use of net.sourceforge.pmd.cpd.SimpleRenderer 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
    }
}
Also used : UnsetInputPropertiesException(name.herlin.command.UnsetInputPropertiesException) SimpleRenderer(net.sourceforge.pmd.cpd.SimpleRenderer) Test(org.junit.Test)

Example 2 with SimpleRenderer

use of net.sourceforge.pmd.cpd.SimpleRenderer in project pmd-eclipse-plugin by pmd.

the class DetectCutAndPasteCmdTest method testDetectCutAndPasteCmdBasic1.

/**
 * Test the basic usage of the cpd command
 */
@Test
public void testDetectCutAndPasteCmdBasic1() throws CommandException, CoreException {
    final DetectCutAndPasteCmd cmd = new DetectCutAndPasteCmd();
    cmd.setProject(this.testProject);
    cmd.setRenderer(new SimpleRenderer());
    cmd.setReportName(PMDRuntimeConstants.SIMPLE_CPDREPORT_NAME);
    cmd.setCreateReport(true);
    cmd.setLanguage("java");
    cmd.setMinTileSize(10);
    cmd.performExecute();
    cmd.join();
    final IFolder reportFolder = this.testProject.getFolder(PMDRuntimeConstants.REPORT_FOLDER);
    Assert.assertTrue("The report folder doesn't exist: " + reportFolder, reportFolder.exists());
    final IFile reportFile = reportFolder.getFile(PMDRuntimeConstants.SIMPLE_CPDREPORT_NAME);
    Assert.assertTrue("The report file doesn't exist: " + reportFile, reportFile.exists());
    if (reportFile.exists()) {
        reportFile.delete(true, false, null);
    }
    if (reportFolder.exists()) {
        reportFolder.delete(true, false, null);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) SimpleRenderer(net.sourceforge.pmd.cpd.SimpleRenderer) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

Example 3 with SimpleRenderer

use of net.sourceforge.pmd.cpd.SimpleRenderer in project pmd-eclipse-plugin by pmd.

the class DetectCutAndPasteCmdTest method testDetectCutAndPasteCmdNullArg5.

/**
 * Test robustness #5
 *
 * @throws CommandException
 */
@Test
public void testDetectCutAndPasteCmdNullArg5() throws CommandException {
    try {
        final DetectCutAndPasteCmd cmd = new DetectCutAndPasteCmd();
        cmd.setProject(null);
        cmd.setRenderer(new SimpleRenderer());
        cmd.setReportName(null);
        cmd.performExecute();
        Assert.fail();
    } catch (final UnsetInputPropertiesException e) {
    // yes cool
    }
}
Also used : UnsetInputPropertiesException(name.herlin.command.UnsetInputPropertiesException) SimpleRenderer(net.sourceforge.pmd.cpd.SimpleRenderer) Test(org.junit.Test)

Example 4 with SimpleRenderer

use of net.sourceforge.pmd.cpd.SimpleRenderer in project pmd-eclipse-plugin by pmd.

the class DetectCutAndPasteCmdTest method testDetectCutAndPasteCmdNullArg3.

/**
 * Test robustness #3
 *
 * @throws CommandException
 */
@Test
public void testDetectCutAndPasteCmdNullArg3() throws CommandException {
    try {
        final DetectCutAndPasteCmd cmd = new DetectCutAndPasteCmd();
        cmd.setProject(this.testProject);
        cmd.setRenderer(new SimpleRenderer());
        cmd.setReportName(null);
        cmd.performExecute();
        Assert.fail();
    } catch (final UnsetInputPropertiesException e) {
    // yes cool
    }
}
Also used : UnsetInputPropertiesException(name.herlin.command.UnsetInputPropertiesException) SimpleRenderer(net.sourceforge.pmd.cpd.SimpleRenderer) Test(org.junit.Test)

Aggregations

SimpleRenderer (net.sourceforge.pmd.cpd.SimpleRenderer)4 Test (org.junit.Test)4 UnsetInputPropertiesException (name.herlin.command.UnsetInputPropertiesException)3 IFile (org.eclipse.core.resources.IFile)1 IFolder (org.eclipse.core.resources.IFolder)1