Fix build; convert tests from JUnit 3 to 4; make some failing tests pass.
This commit is contained in:
1 parent
54cfe41206
commit
a524a52008
32 files changed
+4134
-3848
No files matched your search
@@ -0,0 +1,5 @@
|
||||
10-08-2012:
|
||||
- Fix build: Update MANIFEST.MF Bundle-Version, add js-cvs-12122009.jar, use JDK 1.6 instead of 1.5. Also changed eclipse/plugins/org.eclipse.pde.build_3.8.0.v20110728/scripts/build.xml to set the builderDirectory using pathconvert. This is almost certainly the Wrong Way but has the advantage of working.
|
||||
- Convert all tests from JUnit 3.x to 4.x.
|
||||
- Make some failing tests pass.
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
<property name="eclipse.pde.version" value="3.4.1.R34x_v20080805"/>
|
||||
<property name="eclipse.launcher.version" value="1.0.101.R34x_v20080819"/>
|
||||
|
||||
<!-- setting builder property to either buildDirectory or basedir as this is broken on my box -->
|
||||
<property name="builder" value="${buildDirectory}"/>
|
||||
<property name="builder" value="${basedir}"/>
|
||||
|
||||
<target name="clean">
|
||||
<antcall target="clean-features" />
|
||||
<delete quiet="true">
|
||||
@@ -59,4 +63,4 @@
|
||||
</move>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
@@ -0,0 +1,4 @@
|
||||
eclipse.home=C:/Users/Thomas/eclipse-4.2M3/eclipse
|
||||
buildDirectory=C:/Users/Thomas/Projects/pmd/pmd-eclipse-plugin
|
||||
eclipse.pde.version=3.8.0.v20110728
|
||||
eclipse.launcher.version=1.3.0.v20111003-1644
|
||||
@@ -1,16 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="lib/saxon9.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="test"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/asm-3.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/castor-1.1.2.1-xml.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jaxen-1.1.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/junit.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/log4j-1.2.15.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/pmd-5.0.jar" sourcepath="/pmd"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="test"/>
|
||||
<classpathentry kind="lib" path="lib/xercesImpl-2.6.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/saxon9.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/js-cvs-12122009.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/pmd-5.0.jar" sourcepath="C:/Users/Thomas/Projects/pmd/pmd/src/main/java"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/xercesImpl-2.6.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/xmlParserAPIs-2.6.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="bin" sourcepath="bin"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
#Wed Sep 24 18:03:20 PDT 2008
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
+95
-17
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %plugin.name
|
||||
Bundle-SymbolicName: net.sourceforge.pmd.eclipse.plugin;singleton:=true
|
||||
Bundle-Version: 5.0.0.v20100826
|
||||
Bundle-Version: 5.0.0.v200810141040
|
||||
Bundle-Activator: net.sourceforge.pmd.eclipse.plugin.PMDPlugin
|
||||
Require-Bundle: org.apache.commons.logging;bundle-version="1.0.4",
|
||||
org.eclipse.core.resources,
|
||||
@@ -15,8 +15,7 @@ Require-Bundle: org.apache.commons.logging;bundle-version="1.0.4",
|
||||
org.eclipse.team.core,
|
||||
org.eclipse.search,
|
||||
org.eclipse.help,
|
||||
org.eclipse.help.ui,
|
||||
org.eclipse.help.appserver
|
||||
org.eclipse.help.ui
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Bundle-Vendor: %plugin.provider
|
||||
@@ -31,19 +30,98 @@ Bundle-ClassPath: lib/asm-3.2.jar,
|
||||
lib/xercesImpl-2.6.2.jar,
|
||||
lib/xmlParserAPIs-2.6.2.jar,
|
||||
pmd-plugin.jar,
|
||||
lib/groupingTree.jar
|
||||
lib/groupingTree.jar,
|
||||
.,
|
||||
bin/
|
||||
Bundle-Localization: plugin
|
||||
Export-Package: net.sourceforge.pmd,
|
||||
net.sourceforge.pmd.eclipse.core,
|
||||
net.sourceforge.pmd.eclipse.plugin,
|
||||
net.sourceforge.pmd.eclipse.runtime,
|
||||
net.sourceforge.pmd.eclipse.runtime.builder,
|
||||
net.sourceforge.pmd.eclipse.runtime.properties,
|
||||
net.sourceforge.pmd.eclipse.runtime.writer,
|
||||
Export-Package: name.herlin.command,
|
||||
net.sourceforge.pmd;
|
||||
uses:="net.sourceforge.pmd.stat,
|
||||
net.sourceforge.pmd.lang,
|
||||
net.sourceforge.pmd.util.datasource,
|
||||
net.sourceforge.pmd.renderers,
|
||||
net.sourceforge.pmd.lang.rule.properties,
|
||||
net.sourceforge.pmd.lang.dfa.report",
|
||||
net.sourceforge.pmd.cpd,
|
||||
net.sourceforge.pmd.eclipse.core;uses:="net.sourceforge.pmd",
|
||||
net.sourceforge.pmd.eclipse.core.impl,
|
||||
net.sourceforge.pmd.eclipse.core.rulesets,
|
||||
net.sourceforge.pmd.eclipse.core.rulesets.impl,
|
||||
net.sourceforge.pmd.eclipse.core.rulesets.vo,
|
||||
net.sourceforge.pmd.eclipse.plugin;
|
||||
uses:="org.eclipse.core.runtime,
|
||||
net.sourceforge.pmd.eclipse.runtime.properties,
|
||||
org.eclipse.jface.resource,
|
||||
org.eclipse.ui.plugin,
|
||||
net.sourceforge.pmd.eclipse.ui.nls,
|
||||
net.sourceforge.pmd,
|
||||
net.sourceforge.pmd.eclipse.runtime.preferences,
|
||||
net.sourceforge.pmd.lang,
|
||||
net.sourceforge.pmd.eclipse.ui,
|
||||
net.sourceforge.pmd.eclipse.core,
|
||||
net.sourceforge.pmd.eclipse.runtime.writer,
|
||||
net.sourceforge.pmd.eclipse.ui.priority,
|
||||
org.eclipse.jdt.core,
|
||||
org.eclipse.core.resources,
|
||||
org.eclipse.swt.graphics,
|
||||
org.osgi.framework,
|
||||
org.eclipse.swt.widgets,
|
||||
net.sourceforge.pmd.eclipse.util",
|
||||
net.sourceforge.pmd.eclipse.runtime;uses:="net.sourceforge.pmd.lang.rule.properties",
|
||||
net.sourceforge.pmd.eclipse.runtime.builder;
|
||||
uses:="org.eclipse.core.runtime,
|
||||
org.apache.log4j,
|
||||
org.eclipse.core.resources,
|
||||
net.sourceforge.pmd.eclipse.ui.model",
|
||||
net.sourceforge.pmd.eclipse.runtime.cmd,
|
||||
net.sourceforge.pmd.eclipse.runtime.preferences,
|
||||
net.sourceforge.pmd.eclipse.runtime.properties;uses:="org.eclipse.ui,org.eclipse.core.resources,net.sourceforge.pmd",
|
||||
net.sourceforge.pmd.eclipse.runtime.writer;uses:="net.sourceforge.pmd.lang.java.ast,net.sourceforge.pmd",
|
||||
net.sourceforge.pmd.eclipse.ui,
|
||||
net.sourceforge.pmd.eclipse.ui.actions,
|
||||
net.sourceforge.pmd.eclipse.ui.model,
|
||||
net.sourceforge.pmd.eclipse.ui.preferences.br,
|
||||
net.sourceforge.pmd.eclipse.ui.views.actions,
|
||||
net.sourceforge.pmd.util,
|
||||
org.apache.log4j
|
||||
net.sourceforge.pmd.eclipse.ui.actions;
|
||||
uses:="org.eclipse.jface.action,
|
||||
org.eclipse.jface.operation,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.ui,
|
||||
org.eclipse.core.resources,
|
||||
org.eclipse.jface.viewers,
|
||||
net.sourceforge.pmd,
|
||||
org.eclipse.core.commands",
|
||||
net.sourceforge.pmd.eclipse.ui.model;uses:="org.eclipse.jdt.core,org.eclipse.core.resources,net.sourceforge.pmd.lang.ast",
|
||||
net.sourceforge.pmd.eclipse.ui.preferences.br;
|
||||
uses:="net.sourceforge.pmd.eclipse.ui.preferences,
|
||||
net.sourceforge.pmd.eclipse.plugin,
|
||||
net.sourceforge.pmd.eclipse.ui.views,
|
||||
org.eclipse.ui,
|
||||
org.eclipse.swt.events,
|
||||
net.sourceforge.pmd,
|
||||
net.sourceforge.pmd.eclipse.runtime.preferences,
|
||||
net.sourceforge.pmd.lang.rule.properties,
|
||||
org.eclipse.jface.preference,
|
||||
net.sourceforge.pmd.lang,
|
||||
net.sourceforge.pmd.eclipse.ui,
|
||||
org.eclipse.jface.viewers,
|
||||
org.eclipse.swt.graphics,
|
||||
org.eclipse.ui.dialogs,
|
||||
org.eclipse.swt.widgets,
|
||||
net.sourceforge.pmd.eclipse.util",
|
||||
net.sourceforge.pmd.eclipse.ui.properties,
|
||||
net.sourceforge.pmd.eclipse.ui.views.actions;
|
||||
uses:="org.eclipse.ui.texteditor,
|
||||
org.eclipse.core.runtime,
|
||||
net.sourceforge.pmd.eclipse.ui.views,
|
||||
org.eclipse.ui.menus,
|
||||
net.sourceforge.pmd,
|
||||
net.sourceforge.pmd.eclipse.runtime.preferences,
|
||||
org.eclipse.jface.action,
|
||||
org.eclipse.core.resources,
|
||||
org.eclipse.ui.services,
|
||||
net.sourceforge.pmd.eclipse.ui.model,
|
||||
org.eclipse.jface.viewers,
|
||||
org.eclipse.swt.widgets",
|
||||
net.sourceforge.pmd.lang,
|
||||
net.sourceforge.pmd.lang.java.rule,
|
||||
net.sourceforge.pmd.renderers,
|
||||
net.sourceforge.pmd.util;uses:="net.sourceforge.pmd.lang.java.ast",
|
||||
net.sourceforge.pmd.util.datasource,
|
||||
org.apache.log4j;uses:="org.apache.log4j.helpers,org.apache.log4j.or,org.apache.log4j.spi"
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.2"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
|
||||
<extension-point id="rulesets" name="rulesets" schema="schema/rulesets.exsd"/>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="test"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="test"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/net.sourceforge.pmd.eclipse.plugin"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,12 +1,6 @@
|
||||
#Tue Nov 13 14:44:42 PST 2007
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
@@ -0,0 +1,15 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Version: 5.0.0.v200810141040
|
||||
Bundle-Name: PMD Test Plugin
|
||||
Bundle-SymbolicName: net.sourceforge.pmd.eclipse.plugin.test;singleton=true
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Bundle-Vendor: PMD Development Team
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
net.sourceforge.pmd.eclipse.plugin,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.core.resources,
|
||||
org.eclipse.jdt,
|
||||
org.eclipse.jdt.core,
|
||||
org.junit
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
@@ -1,4 +1,10 @@
|
||||
source.pmd-eclipse-test.jar = test/
|
||||
output.pmd-eclipse-test.jar = bin/
|
||||
bin.includes = plugin.xml,\
|
||||
pmd-eclipse-test.jar
|
||||
pmd-eclipse-test.jar,\
|
||||
META-INF/,\
|
||||
bin/,\
|
||||
.ruleset
|
||||
jars.compile.order = pmd-eclipse-test.jar,\
|
||||
.
|
||||
source.. =
|
||||
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.0"?>
|
||||
<plugin
|
||||
id="net.sourceforge.pmd.eclipse.test"
|
||||
name="PMD Eclipse Test Plug-in"
|
||||
version="5.0.0.v200810141040"
|
||||
provider-name="PMD Development Team">
|
||||
|
||||
<runtime>
|
||||
<library name="pmd-eclipse-test.jar">
|
||||
<export name="*"/>
|
||||
</library>
|
||||
</runtime>
|
||||
<requires>
|
||||
<import plugin="net.sourceforge.pmd.eclipse.plugin"/>
|
||||
<import plugin="org.junit"/>
|
||||
<import plugin="org.eclipse.core.runtime"/>
|
||||
<import plugin="org.eclipse.ui"/>
|
||||
<import plugin="org.eclipse.core.resources"/>
|
||||
<import plugin="org.eclipse.jdt"/>
|
||||
<import plugin="org.eclipse.jdt.core"/>
|
||||
</requires>
|
||||
|
||||
</plugin>
|
||||
+172
-153
File diff suppressed because it is too large.
Load diff
+239
-213
File diff suppressed because it is too large.
Load diff
+96
-103
@@ -1,31 +1,29 @@
|
||||
/*
|
||||
* Created on 7 juin 2005
|
||||
*
|
||||
* Copyright (c) 2005, PMD for Eclipse Development Team
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2005, PMD for Eclipse Development Team All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * The end-user documentation included with the redistribution, if
|
||||
* any, must include the following acknowledgement:
|
||||
* "This product includes software developed in part by support from
|
||||
* the Defense Advanced Research Project Agency (DARPA)"
|
||||
* * Neither the name of "PMD for Eclipse Development Team" nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. * Redistributions
|
||||
* in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. * The end-user documentation
|
||||
* included with the redistribution, if any, must include the following
|
||||
* acknowledgement: "This product includes software developed in part by
|
||||
* support from the Defense Advanced Research Project Agency (DARPA)" *
|
||||
* Neither the name of "PMD for Eclipse Development Team" nor the names of
|
||||
* its contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
@@ -38,97 +36,92 @@ package net.sourceforge.pmd.eclipse.core;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sourceforge.pmd.RuleSet;
|
||||
import net.sourceforge.pmd.RuleSetFactory;
|
||||
import net.sourceforge.pmd.RuleSetNotFoundException;
|
||||
import net.sourceforge.pmd.eclipse.plugin.PMDPlugin;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Test the PMD Core plugin
|
||||
*
|
||||
*
|
||||
* @author Philippe Herlin
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class PMDCorePluginTest extends TestCase {
|
||||
public class PMDCorePluginTest {
|
||||
|
||||
/**
|
||||
* Constructor for PMDPluginTest.
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public PMDCorePluginTest(String name) {
|
||||
super(name);
|
||||
/**
|
||||
* Test the default rulesets has been registered For this test to work, no
|
||||
* Fragment or only the test plugin fragment should be installed.
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testDefaultPMDRuleSetsRegistered() throws RuleSetNotFoundException {
|
||||
final Set<RuleSet> defaultRuleSets = PMDPlugin.getDefault().getRuleSetManager().getRegisteredRuleSets();
|
||||
Assert.assertFalse("No registered default rulesets!", defaultRuleSets.isEmpty());
|
||||
|
||||
final RuleSetFactory factory = new RuleSetFactory();
|
||||
final Iterator<RuleSet> iterator = factory.getRegisteredRuleSets();
|
||||
while (iterator.hasNext()) {
|
||||
final RuleSet ruleSet = iterator.next();
|
||||
Assert.assertTrue("RuleSet \"" + ruleSet.getName() + "\" has not been registered", ruleSetRegistered(ruleSet, defaultRuleSets));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the core plugin has been instantiated
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testPMDPluginNotNull() {
|
||||
Assert.assertNotNull("The Core Plugin has not been instantiated", PMDPlugin.getDefault());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that we can get a ruleset manager
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testRuleSetManagerNotNull() {
|
||||
Assert.assertNotNull("Cannot get a ruleset manager", PMDPlugin.getDefault().getRuleSetManager());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test all the known PMD rulesets has been registered For this test to
|
||||
* work, no fragment or only the test plugin fragment should be installed.
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testStandardPMDRuleSetsRegistered() throws RuleSetNotFoundException {
|
||||
final Set<RuleSet> registeredRuleSets = PMDPlugin.getDefault().getRuleSetManager().getRegisteredRuleSets();
|
||||
Assert.assertFalse("No registered rulesets!", registeredRuleSets.isEmpty());
|
||||
|
||||
final RuleSetFactory factory = new RuleSetFactory();
|
||||
final Iterator<RuleSet> iterator = factory.getRegisteredRuleSets();
|
||||
while (iterator.hasNext()) {
|
||||
final RuleSet ruleSet = iterator.next();
|
||||
Assert.assertTrue("RuleSet \"" + ruleSet.getName() + "\" has not been registered", ruleSetRegistered(ruleSet, registeredRuleSets));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* test if a ruleset is registered
|
||||
*
|
||||
* @param ruleSet
|
||||
* @param set
|
||||
* @return true if OK
|
||||
*/
|
||||
private boolean ruleSetRegistered(final RuleSet ruleSet, final Set<RuleSet> set) {
|
||||
boolean registered = false;
|
||||
|
||||
final Iterator<RuleSet> i = set.iterator();
|
||||
while (i.hasNext() && !registered) {
|
||||
final RuleSet registeredRuleSet = i.next();
|
||||
registered = registeredRuleSet.getName().equals(ruleSet.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the core plugin has been instantiated
|
||||
*
|
||||
*/
|
||||
public void testPMDPluginNotNull() {
|
||||
assertNotNull("The Core Plugin has not been instantiated", PMDPlugin.getDefault());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that we can get a ruleset manager
|
||||
*
|
||||
*/
|
||||
public void testRuleSetManagerNotNull() {
|
||||
assertNotNull("Cannot get a ruleset manager", PMDPlugin.getDefault().getRuleSetManager());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test all the known PMD rulesets has been registered For this test to
|
||||
* work, no fragment or only the test plugin fragment should be installed.
|
||||
*
|
||||
*/
|
||||
public void testStandardPMDRuleSetsRegistered() throws RuleSetNotFoundException {
|
||||
Set<RuleSet> registeredRuleSets = PMDPlugin.getDefault().getRuleSetManager().getRegisteredRuleSets();
|
||||
assertFalse("No registered rulesets!", registeredRuleSets.isEmpty());
|
||||
|
||||
RuleSetFactory factory = new RuleSetFactory();
|
||||
Iterator<RuleSet> iterator = factory.getRegisteredRuleSets();
|
||||
while (iterator.hasNext()) {
|
||||
RuleSet ruleSet = iterator.next();
|
||||
assertTrue("RuleSet \"" + ruleSet.getName() + "\" has not been registered", ruleSetRegistered(ruleSet,
|
||||
registeredRuleSets));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the default rulesets has been registered For this test to work, no
|
||||
* Fragment or only the test plugin fragment should be installed.
|
||||
*
|
||||
*/
|
||||
public void testDefaultPMDRuleSetsRegistered() throws RuleSetNotFoundException {
|
||||
Set<RuleSet> defaultRuleSets = PMDPlugin.getDefault().getRuleSetManager().getRegisteredRuleSets();
|
||||
assertFalse("No registered default rulesets!", defaultRuleSets.isEmpty());
|
||||
|
||||
RuleSetFactory factory = new RuleSetFactory();
|
||||
Iterator<RuleSet> iterator = factory.getRegisteredRuleSets();
|
||||
while (iterator.hasNext()) {
|
||||
RuleSet ruleSet = iterator.next();
|
||||
assertTrue("RuleSet \"" + ruleSet.getName() + "\" has not been registered", ruleSetRegistered(ruleSet,
|
||||
defaultRuleSets));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* test if a ruleset is registered
|
||||
*
|
||||
* @param ruleSet
|
||||
* @param set
|
||||
* @return true if OK
|
||||
*/
|
||||
private boolean ruleSetRegistered(RuleSet ruleSet, Set<RuleSet> set) {
|
||||
boolean registered = false;
|
||||
|
||||
Iterator<RuleSet> i = set.iterator();
|
||||
while (i.hasNext() && !registered) {
|
||||
RuleSet registeredRuleSet = i.next();
|
||||
registered = registeredRuleSet.getName().equals(ruleSet.getName());
|
||||
}
|
||||
|
||||
return registered;
|
||||
}
|
||||
return registered;
|
||||
}
|
||||
}
|
||||
+188
-180
File diff suppressed because it is too large.
Load diff
+76
-74
@@ -1,31 +1,29 @@
|
||||
/*
|
||||
* Created on 2 juillet 2005
|
||||
*
|
||||
* Copyright (c) 2005, PMD for Eclipse Development Team
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2005, PMD for Eclipse Development Team All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * The end-user documentation included with the redistribution, if
|
||||
* any, must include the following acknowledgement:
|
||||
* "This product includes software developed in part by support from
|
||||
* the Defense Advanced Research Project Agency (DARPA)"
|
||||
* * Neither the name of "PMD for Eclipse Development Team" nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. * Redistributions
|
||||
* in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. * The end-user documentation
|
||||
* included with the redistribution, if any, must include the following
|
||||
* acknowledgement: "This product includes software developed in part by
|
||||
* support from the Defense Advanced Research Project Agency (DARPA)" *
|
||||
* Neither the name of "PMD for Eclipse Development Team" nor the names of
|
||||
* its contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
@@ -38,70 +36,74 @@ package net.sourceforge.pmd.eclipse.core.ext;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sourceforge.pmd.RuleSet;
|
||||
import net.sourceforge.pmd.RuleSetFactory;
|
||||
import net.sourceforge.pmd.RuleSetNotFoundException;
|
||||
import net.sourceforge.pmd.eclipse.plugin.PMDPlugin;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Test the ruleset extension
|
||||
*
|
||||
*
|
||||
* @author Philippe Herlin
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class RuleSetsExtensionProcessorTest extends TestCase {
|
||||
public class RuleSetsExtensionProcessorTest {
|
||||
|
||||
/**
|
||||
* Tests the additional rulesets has been registered. For this test to work,
|
||||
* the test plugin fragment must be installed.
|
||||
*
|
||||
*/
|
||||
public void testAdditionalRuleSetsRegistered() throws RuleSetNotFoundException {
|
||||
Set<RuleSet> registeredRuleSets = PMDPlugin.getDefault().getRuleSetManager().getRegisteredRuleSets();
|
||||
assertFalse("No registered rulesets!", registeredRuleSets.isEmpty());
|
||||
/**
|
||||
* Tests the additional default rulesets has been registered. For this
|
||||
* test to work, the test plugin fragment must be installed.
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testAdditionalDefaultRuleSetsRegistered() throws RuleSetNotFoundException {
|
||||
final Set<RuleSet> registeredRuleSets = PMDPlugin.getDefault().getRuleSetManager().getDefaultRuleSets();
|
||||
Assert.assertFalse("No registered default rulesets!", registeredRuleSets.isEmpty());
|
||||
|
||||
RuleSetFactory factory = new RuleSetFactory();
|
||||
RuleSet ruleSet = factory.createRuleSet("rulesets/extra1.xml");
|
||||
assertTrue("RuleSet \"rulesets/extra1.xml\" has not been registered", ruleSetRegistered(ruleSet, registeredRuleSets));
|
||||
final RuleSetFactory factory = new RuleSetFactory();
|
||||
RuleSet ruleSet = factory.createRuleSet("rulesets/extra1.xml");
|
||||
Assert.assertTrue("RuleSet \"rulesets/extra1.xml\" has not been registered", ruleSetRegistered(ruleSet, registeredRuleSets));
|
||||
|
||||
ruleSet = factory.createRuleSet("rulesets/extra2.xml");
|
||||
assertTrue("RuleSet \"rulesets/extra2.xml\" has not been registered", ruleSetRegistered(ruleSet, registeredRuleSets));
|
||||
ruleSet = factory.createRuleSet("rulesets/extra2.xml");
|
||||
Assert.assertTrue("RuleSet \"rulesets/extra2.xml\" has not been registered", ruleSetRegistered(ruleSet, registeredRuleSets));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the additional rulesets has been registered. For this test to
|
||||
* work, the test plugin fragment must be installed.
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testAdditionalRuleSetsRegistered() throws RuleSetNotFoundException {
|
||||
final Set<RuleSet> registeredRuleSets = PMDPlugin.getDefault().getRuleSetManager().getRegisteredRuleSets();
|
||||
Assert.assertFalse("No registered rulesets!", registeredRuleSets.isEmpty());
|
||||
|
||||
final RuleSetFactory factory = new RuleSetFactory();
|
||||
RuleSet ruleSet = factory.createRuleSet("rulesets/extra1.xml");
|
||||
Assert.assertTrue("RuleSet \"rulesets/extra1.xml\" has not been registered", ruleSetRegistered(ruleSet, registeredRuleSets));
|
||||
|
||||
ruleSet = factory.createRuleSet("rulesets/extra2.xml");
|
||||
Assert.assertTrue("RuleSet \"rulesets/extra2.xml\" has not been registered", ruleSetRegistered(ruleSet, registeredRuleSets));
|
||||
}
|
||||
|
||||
/**
|
||||
* test if a ruleset is registered
|
||||
*
|
||||
* @param ruleSet
|
||||
* @param set
|
||||
* @return true if OK
|
||||
*/
|
||||
private boolean ruleSetRegistered(final RuleSet ruleSet, final Set<RuleSet> set) {
|
||||
boolean registered = false;
|
||||
|
||||
final Iterator<RuleSet> i = set.iterator();
|
||||
while (i.hasNext() && !registered) {
|
||||
final RuleSet registeredRuleSet = i.next();
|
||||
registered = registeredRuleSet.getName().equals(ruleSet.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the additional default rulesets has been registered. For this test
|
||||
* to work, the test plugin fragment must be installed.
|
||||
*
|
||||
*/
|
||||
public void testAdditionalDefaultRuleSetsRegistered() throws RuleSetNotFoundException {
|
||||
Set<RuleSet> registeredRuleSets = PMDPlugin.getDefault().getRuleSetManager().getDefaultRuleSets();
|
||||
assertFalse("No registered default rulesets!", registeredRuleSets.isEmpty());
|
||||
|
||||
RuleSetFactory factory = new RuleSetFactory();
|
||||
RuleSet ruleSet = factory.createRuleSet("rulesets/extra1.xml");
|
||||
assertTrue("RuleSet \"rulesets/extra1.xml\" has not been registered", ruleSetRegistered(ruleSet, registeredRuleSets));
|
||||
|
||||
ruleSet = factory.createRuleSet("rulesets/extra2.xml");
|
||||
assertTrue("RuleSet \"rulesets/extra2.xml\" has not been registered", ruleSetRegistered(ruleSet, registeredRuleSets));
|
||||
}
|
||||
|
||||
/**
|
||||
* test if a ruleset is registered
|
||||
*
|
||||
* @param ruleSet
|
||||
* @param set
|
||||
* @return true if OK
|
||||
*/
|
||||
private boolean ruleSetRegistered(RuleSet ruleSet, Set<RuleSet> set) {
|
||||
boolean registered = false;
|
||||
|
||||
Iterator<RuleSet> i = set.iterator();
|
||||
while (i.hasNext() && !registered) {
|
||||
RuleSet registeredRuleSet = i.next();
|
||||
registered = registeredRuleSet.getName().equals(ruleSet.getName());
|
||||
}
|
||||
|
||||
return registered;
|
||||
}
|
||||
return registered;
|
||||
}
|
||||
}
|
||||
+33
-44
@@ -1,31 +1,29 @@
|
||||
/*
|
||||
* Created on 22 juin 2006
|
||||
*
|
||||
* Copyright (c) 2006, PMD for Eclipse Development Team
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2006, PMD for Eclipse Development Team All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * The end-user documentation included with the redistribution, if
|
||||
* any, must include the following acknowledgement:
|
||||
* "This product includes software developed in part by support from
|
||||
* the Defense Advanced Research Project Agency (DARPA)"
|
||||
* * Neither the name of "PMD for Eclipse Development Team" nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. * Redistributions
|
||||
* in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. * The end-user documentation
|
||||
* included with the redistribution, if any, must include the following
|
||||
* acknowledgement: "This product includes software developed in part by
|
||||
* support from the Defense Advanced Research Project Agency (DARPA)" *
|
||||
* Neither the name of "PMD for Eclipse Development Team" nor the names of
|
||||
* its contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
@@ -36,36 +34,27 @@
|
||||
|
||||
package net.sourceforge.pmd.eclipse.core.rulesets;
|
||||
|
||||
import net.sourceforge.pmd.eclipse.core.rulesets.impl.RuleSetsManagerImplTest;
|
||||
import net.sourceforge.pmd.eclipse.core.rulesets.vo.PriorityTest;
|
||||
import net.sourceforge.pmd.eclipse.core.rulesets.vo.PropertiesTest;
|
||||
import net.sourceforge.pmd.eclipse.core.rulesets.vo.PropertyTest;
|
||||
import net.sourceforge.pmd.eclipse.core.rulesets.vo.RuleSetTest;
|
||||
import net.sourceforge.pmd.eclipse.core.rulesets.vo.RuleSetsTest;
|
||||
import net.sourceforge.pmd.eclipse.core.rulesets.vo.RuleTest;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Herlin
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public class AllTests {
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite("Tests for net.sourceforge.pmd.eclipse.core.rulesets");
|
||||
//$JUnit-BEGIN$
|
||||
suite.addTestSuite(RuleTest.class);
|
||||
suite.addTestSuite(PriorityTest.class);
|
||||
suite.addTestSuite(PropertiesTest.class);
|
||||
suite.addTestSuite(PropertyTest.class);
|
||||
suite.addTestSuite(RuleSetsTest.class);
|
||||
suite.addTestSuite(RuleSetTest.class);
|
||||
suite.addTestSuite(RuleSetsManagerImplTest.class);
|
||||
//$JUnit-END$
|
||||
return suite;
|
||||
}
|
||||
//
|
||||
// public static Test suite() {
|
||||
// TestSuite suite = new TestSuite("Tests for net.sourceforge.pmd.eclipse.core.rulesets");
|
||||
// //$JUnit-BEGIN$
|
||||
// suite.addTestSuite(RuleTest.class);
|
||||
// suite.addTestSuite(PriorityTest.class);
|
||||
// suite.addTestSuite(PropertiesTest.class);
|
||||
// suite.addTestSuite(PropertyTest.class);
|
||||
// suite.addTestSuite(RuleSetsTest.class);
|
||||
// suite.addTestSuite(RuleSetTest.class);
|
||||
// suite.addTestSuite(RuleSetsManagerImplTest.class);
|
||||
// //$JUnit-END$
|
||||
// return suite;
|
||||
// }
|
||||
|
||||
}
|
||||
+145
-129
File diff suppressed because it is too large.
Load diff
+153
-140
File diff suppressed because it is too large.
Load diff
+284
-267
File diff suppressed because it is too large.
Load diff
+226
-209
File diff suppressed because it is too large.
Load diff
+599
-555
File diff suppressed because it is too large.
Load diff
+276
-256
File diff suppressed because it is too large.
Load diff
+421
-399
File diff suppressed because it is too large.
Load diff
+40
-42
@@ -1,31 +1,29 @@
|
||||
/*
|
||||
* Created on 22 juin 2006
|
||||
*
|
||||
* Copyright (c) 2006, PMD for Eclipse Development Team
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2006, PMD for Eclipse Development Team All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * The end-user documentation included with the redistribution, if
|
||||
* any, must include the following acknowledgement:
|
||||
* "This product includes software developed in part by support from
|
||||
* the Defense Advanced Research Project Agency (DARPA)"
|
||||
* * Neither the name of "PMD for Eclipse Development Team" nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. * Redistributions
|
||||
* in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. * The end-user documentation
|
||||
* included with the redistribution, if any, must include the following
|
||||
* acknowledgement: "This product includes software developed in part by
|
||||
* support from the Defense Advanced Research Project Agency (DARPA)" *
|
||||
* Neither the name of "PMD for Eclipse Development Team" nor the names of
|
||||
* its contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
@@ -44,34 +42,34 @@ import net.sourceforge.pmd.RuleSetFactory;
|
||||
import net.sourceforge.pmd.RuleSetNotFoundException;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Herlin
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public class TestManager {
|
||||
private static RuleSet basicRuleSet;
|
||||
private static Rule[] rules;
|
||||
private static RuleSet basicRuleSet;
|
||||
private static Rule[] rules;
|
||||
|
||||
public static Rule getRule(int i) throws RuleSetNotFoundException {
|
||||
if (rules == null) {
|
||||
getRuleSet();
|
||||
}
|
||||
|
||||
return rules[i];
|
||||
public static Rule getRule(final int i) throws RuleSetNotFoundException {
|
||||
if (rules == null) {
|
||||
getRuleSet();
|
||||
}
|
||||
|
||||
public static RuleSet getRuleSet() throws RuleSetNotFoundException {
|
||||
if (basicRuleSet == null) {
|
||||
basicRuleSet = new RuleSetFactory().createRuleSet("rulesets/basic.xml");
|
||||
Iterator<Rule> i = getRuleSet().getRules().iterator();
|
||||
rules = new Rule[4];
|
||||
for (int j = 0; j < 4; j++) {
|
||||
rules[j] = i.next();
|
||||
}
|
||||
}
|
||||
return rules[i];
|
||||
}
|
||||
|
||||
return basicRuleSet;
|
||||
public static RuleSet getRuleSet() throws RuleSetNotFoundException {
|
||||
if (basicRuleSet == null) {
|
||||
basicRuleSet = new RuleSetFactory().createRuleSet("rulesets/java/basic.xml");
|
||||
final Iterator<Rule> i = getRuleSet().getRules().iterator();
|
||||
rules = new Rule[4];
|
||||
for (int j = 0; j < 4; j++) {
|
||||
rules[j] = i.next();
|
||||
}
|
||||
}
|
||||
|
||||
return basicRuleSet;
|
||||
}
|
||||
|
||||
}
|
||||
+235
-229
File diff suppressed because it is too large.
Load diff
+212
-208
File diff suppressed because it is too large.
Load diff
+108
-113
@@ -1,31 +1,29 @@
|
||||
/*
|
||||
* Created on 12 avr. 2005
|
||||
*
|
||||
* Copyright (c) 2005, PMD for Eclipse Development Team
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2005, PMD for Eclipse Development Team All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * The end-user documentation included with the redistribution, if
|
||||
* any, must include the following acknowledgement:
|
||||
* "This product includes software developed in part by support from
|
||||
* the Defense Advanced Research Project Agency (DARPA)"
|
||||
* * Neither the name of "PMD for Eclipse Development Team" nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. * Redistributions
|
||||
* in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. * The end-user documentation
|
||||
* included with the redistribution, if any, must include the following
|
||||
* acknowledgement: "This product includes software developed in part by
|
||||
* support from the Defense Advanced Research Project Agency (DARPA)" *
|
||||
* Neither the name of "PMD for Eclipse Development Team" nor the names of
|
||||
* its contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
@@ -39,7 +37,6 @@ import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import name.herlin.command.CommandException;
|
||||
import name.herlin.command.UnsetInputPropertiesException;
|
||||
import net.sourceforge.pmd.eclipse.EclipseUtils;
|
||||
@@ -47,110 +44,108 @@ import net.sourceforge.pmd.eclipse.EclipseUtils;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* This tests the PMD Processor command
|
||||
*
|
||||
*
|
||||
* @author Philippe Herlin
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ReviewCmdTest extends TestCase {
|
||||
private IProject testProject;
|
||||
public class ReviewCmdTest {
|
||||
private IProject testProject;
|
||||
|
||||
/**
|
||||
* Test case constructor
|
||||
*
|
||||
* @param name
|
||||
* of the test case
|
||||
*/
|
||||
public ReviewCmdTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
/**
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
/**
|
||||
* Test the basic usage of the processor command
|
||||
*
|
||||
*/
|
||||
public void testReviewCmdBasic() throws CommandException, CoreException {
|
||||
ReviewCodeCmd cmd = new ReviewCodeCmd();
|
||||
cmd.addResource(this.testProject);
|
||||
cmd.performExecute();
|
||||
cmd.join();
|
||||
Map<IFile, Set<MarkerInfo>> markers = cmd.getMarkers();
|
||||
// 1. Create a Java project
|
||||
this.testProject = EclipseUtils.createJavaProject("PMDTestProject");
|
||||
Assert.assertTrue("A test project cannot be created; the tests cannot be performed.",
|
||||
this.testProject != null && this.testProject.exists() && this.testProject.isAccessible());
|
||||
|
||||
// We do not test PMD, only a non-empty report is enough
|
||||
assertNotNull(markers);
|
||||
assertTrue("Report size = " + markers.size(), markers.size() > 0);
|
||||
}
|
||||
// 2. Create a test source file inside that project
|
||||
final IFile testFile = EclipseUtils.createTestSourceFile(this.testProject);
|
||||
final InputStream is = EclipseUtils.getResourceStream(this.testProject, "/Test.java");
|
||||
Assert.assertNotNull("Cannot find the test source file", is);
|
||||
is.close();
|
||||
|
||||
/**
|
||||
* The ReviewCodeCmd must also work on a ResourceDelta
|
||||
* @throws CommandException
|
||||
*/
|
||||
public void testReviewCmdDelta() throws CommandException {
|
||||
// Don't know how to test that yet
|
||||
// How to instantiate a ResourceDelta ?
|
||||
// Let's comment for now
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normally a null resource and a null resource delta is not acceptable.
|
||||
* @throws CommandException
|
||||
*/
|
||||
public void testReviewCmdNullResource() throws CommandException {
|
||||
try {
|
||||
ReviewCodeCmd cmd = new ReviewCodeCmd();
|
||||
cmd.addResource(null);
|
||||
cmd.setResourceDelta(null);
|
||||
cmd.performExecute();
|
||||
fail("An Exception must be thrown");
|
||||
} catch (UnsetInputPropertiesException e) {
|
||||
fail("An IllegalArgumentException must have been thrown before");
|
||||
} catch (IllegalArgumentException e) {
|
||||
; // cool, success
|
||||
/**
|
||||
* @see junit.framework.TestCase#tearDown()
|
||||
*/
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
try {
|
||||
if (this.testProject != null) {
|
||||
if (this.testProject.exists() && this.testProject.isAccessible()) {
|
||||
EclipseUtils.removePMDNature(this.testProject);
|
||||
// this.testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||
// Thread.sleep(500);
|
||||
// this.testProject.delete(true, true, null);
|
||||
// this.testProject = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
// 1. Create a Java project
|
||||
this.testProject = EclipseUtils.createJavaProject("PMDTestProject");
|
||||
assertTrue("A test project cannot be created; the tests cannot be performed.", this.testProject != null
|
||||
&& this.testProject.exists() && this.testProject.isAccessible());
|
||||
|
||||
// 2. Create a test source file inside that project
|
||||
IFile testFile = EclipseUtils.createTestSourceFile(this.testProject);
|
||||
InputStream is = EclipseUtils.getResourceStream(this.testProject, "/Test.java");
|
||||
assertNotNull("Cannot find the test source file", is);
|
||||
is.close();
|
||||
|
||||
catch (final Exception e) {
|
||||
System.out.println("Exception " + e.getClass().getName() + " when tearing down. Ignored.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see junit.framework.TestCase#tearDown()
|
||||
*/
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
try {
|
||||
if (this.testProject != null) {
|
||||
if (this.testProject.exists() && this.testProject.isAccessible()) {
|
||||
EclipseUtils.removePMDNature(this.testProject);
|
||||
// this.testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||
// Thread.sleep(500);
|
||||
// this.testProject.delete(true, true, null);
|
||||
// this.testProject = null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Test the basic usage of the processor command
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testReviewCmdBasic() throws CommandException, CoreException {
|
||||
final ReviewCodeCmd cmd = new ReviewCodeCmd();
|
||||
cmd.addResource(this.testProject);
|
||||
cmd.performExecute();
|
||||
cmd.join();
|
||||
final Map<IFile, Set<MarkerInfo2>> markers = cmd.getMarkers();
|
||||
|
||||
super.tearDown();
|
||||
} catch (Exception e) {
|
||||
System.out.println("Exception " + e.getClass().getName() + " when tearing down. Ignored.");
|
||||
}
|
||||
// We do not test PMD, only a non-empty report is enough
|
||||
Assert.assertNotNull(markers);
|
||||
Assert.assertTrue("Report size = " + markers.size(), markers.size() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* The ReviewCodeCmd must also work on a ResourceDelta
|
||||
*
|
||||
* @throws CommandException
|
||||
*/
|
||||
@Test
|
||||
public void testReviewCmdDelta() throws CommandException {
|
||||
// Don't know how to test that yet
|
||||
// How to instantiate a ResourceDelta ?
|
||||
// Let's comment for now
|
||||
}
|
||||
|
||||
/**
|
||||
* Normally a null resource and a null resource delta is not acceptable.
|
||||
*
|
||||
* @throws CommandException
|
||||
*/
|
||||
@Test
|
||||
public void testReviewCmdNullResource() throws CommandException {
|
||||
try {
|
||||
final ReviewCodeCmd cmd = new ReviewCodeCmd();
|
||||
cmd.addResource(null);
|
||||
cmd.setResourceDelta(null);
|
||||
cmd.performExecute();
|
||||
Assert.fail("An Exception must be thrown");
|
||||
}
|
||||
catch (final UnsetInputPropertiesException e) {
|
||||
Assert.fail("An IllegalArgumentException must have been thrown before");
|
||||
}
|
||||
catch (final IllegalArgumentException e) {
|
||||
; // cool, success
|
||||
}
|
||||
}
|
||||
}
|
||||
+381
-378
File diff suppressed because it is too large.
Load diff
Loaded 30 of 32 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user