Skip to content

Commit 1466dea

Browse files
committed
Update tests to use new ruleset categories
1 parent 486aea5 commit 1466dea

File tree

2 files changed

+39
-35
lines changed

2 files changed

+39
-35
lines changed

net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/BasicPMDTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ public void testRunPmdJdk13() {
120120
context.setSourceCodeFilename("foo.java");
121121
context.setReport(new Report());
122122

123-
final RuleSet unnecessaryRuleSet = new RuleSetFactory().createRuleSet("rulesets/java/unnecessary.xml");
124-
RuleSets rSets = new RuleSets(unnecessaryRuleSet);
123+
final RuleSet codeStyleRuleSet = new RuleSetFactory().createRuleSet("category/java/codestyle.xml/UnnecessaryReturn");
124+
RuleSets rSets = new RuleSets(codeStyleRuleSet);
125125
new SourceCodeProcessor(configuration).processSourceCode(new StringDataSource(sourceCode).getInputStream(),
126126
rSets, context);
127127

@@ -158,8 +158,8 @@ public void testRunPmdJdk14() {
158158
context.setSourceCodeFilename("foo.java");
159159
context.setReport(new Report());
160160

161-
final RuleSet unnecessaryRuleSet = new RuleSetFactory().createRuleSet("rulesets/java/unnecessary.xml");
162-
RuleSets rSets = new RuleSets(unnecessaryRuleSet);
161+
final RuleSet codeStyleRuleSet = new RuleSetFactory().createRuleSet("category/java/codestyle.xml/UnnecessaryReturn");
162+
RuleSets rSets = new RuleSets(codeStyleRuleSet);
163163
new SourceCodeProcessor(configuration).processSourceCode(new StringDataSource(sourceCode).getInputStream(),
164164
rSets, context);
165165

@@ -196,8 +196,8 @@ public void testRunPmdJdk15() {
196196
context.setSourceCodeFilename("foo.java");
197197
context.setReport(new Report());
198198

199-
final RuleSet unnecessaryRuleSet = new RuleSetFactory().createRuleSet("rulesets/java/unnecessary.xml");
200-
RuleSets rSets = new RuleSets(unnecessaryRuleSet);
199+
final RuleSet codeStyleRuleSet = new RuleSetFactory().createRuleSet("category/java/codestyle.xml/UnnecessaryReturn");
200+
RuleSets rSets = new RuleSets(codeStyleRuleSet);
201201
new SourceCodeProcessor(configuration).processSourceCode(new StringDataSource(sourceCode).getInputStream(),
202202
rSets, context);
203203

net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/runtime/properties/ProjectPropertiesModelTest.java

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.junit.After;
4747
import org.junit.Assert;
4848
import org.junit.Before;
49+
import org.junit.Ignore;
4950
import org.junit.Test;
5051

5152
import net.sourceforge.pmd.Rule;
@@ -238,55 +239,58 @@ public void testProjectRuleSet1() throws PropertiesException, RuleSetNotFoundExc
238239

239240
final RuleSetFactory factory = new RuleSetFactory();
240241

241-
// use the basic ruleset because it should be included in the plugin
242-
// ruleset.
243-
final RuleSet basicRuleSet = factory.createRuleSet("rulesets/java/basic.xml");
242+
// use the best practices ruleset because it should be included in the plugin ruleset.
243+
final RuleSet bestPracticesRuleSet = factory.createRuleSet("category/java/bestpractices.xml");
244244

245245
// First set the project ruleset
246-
model.setProjectRuleSet(basicRuleSet);
246+
model.setProjectRuleSet(bestPracticesRuleSet);
247247
model.sync();
248248

249249
// Test the ruleset we set is equal to the ruleset we queried
250250
final RuleSet projectRuleSet = model.getProjectRuleSet();
251251
Assert.assertNotNull("Project ruleset has not been set", projectRuleSet);
252252
Assert.assertTrue("The project ruleset is not the basic ruleset",
253-
EclipseUtils.assertRuleSetEquals(basicRuleSet.getRules(), projectRuleSet.getRules(), System.out));
253+
EclipseUtils.assertRuleSetEquals(bestPracticesRuleSet.getRules(), projectRuleSet.getRules(), System.out));
254254
}
255255

256256
/**
257257
* When rules are removed from the plugin preferences, these rules should also be removed from the project euh...
258258
* ben en fait non. annulé.
259259
*/
260260
@Test
261+
@Ignore("implementation is not finished - maybe the behavior would even be wrong")
261262
public void testProjectRuleSet2() throws PropertiesException, RuleSetNotFoundException, CoreException {
262-
/*
263-
* // First ensure that the plugin initial ruleset is equal to the project // ruleset IProjectPropertiesManager
264-
* mgr = PMDPlugin.getDefault().getPropertiesManager(); IProjectProperties model =
265-
* mgr.loadProjectProperties(this.testProject);
266-
*
267-
* RuleSet projectRuleSet = model.getProjectRuleSet();
268-
* assertEquals("The project ruleset is not equal to the plugin ruleset", this.initialPluginRuleSet.getRules(),
269-
* projectRuleSet .getRules());
270-
*
271-
* // use the basic ruleset and set it at the only plugin ruleset RuleSetFactory factory = new RuleSetFactory();
272-
* RuleSet basicRuleSet = factory.createSingleRuleSet("rulesets/basic.xml");
273-
*
274-
* IPreferencesManager pmgr = PMDPlugin.getDefault().getPreferencesManager(); pmgr.setRuleSet(basicRuleSet);
275-
*
276-
* projectRuleSet = model.getProjectRuleSet();
277-
*
278-
* dumpRuleSet(basicRuleSet); dumpRuleSet(projectRuleSet);
279-
* assertEquals("The project ruleset is not equal to the plugin ruleset", basicRuleSet.getRules(),
280-
* projectRuleSet.getRules());
281-
*/
263+
// First ensure that the plugin initial ruleset is equal to the project
264+
// // ruleset IProjectPropertiesManager
265+
final IProjectPropertiesManager mgr = PMDPlugin.getDefault().getPropertiesManager();
266+
final IProjectProperties model = mgr.loadProjectProperties(this.testProject);
267+
268+
RuleSet projectRuleSet = model.getProjectRuleSet();
269+
Assert.assertEquals("The project ruleset is not equal to the plugin ruleset",
270+
this.initialPluginRuleSet.getRules(), projectRuleSet.getRules());
271+
272+
final RuleSetFactory factory = new RuleSetFactory();
273+
274+
// use the best practices ruleset because it should be included in the
275+
// plugin ruleset.
276+
final RuleSet bestPracticesRuleSet = factory.createRuleSet("category/java/bestpractices.xml");
277+
278+
IPreferencesManager pmgr = PMDPlugin.getDefault().getPreferencesManager();
279+
pmgr.setRuleSet(bestPracticesRuleSet);
280+
281+
projectRuleSet = model.getProjectRuleSet();
282+
283+
dumpRuleSet(bestPracticesRuleSet);
284+
dumpRuleSet(projectRuleSet);
285+
Assert.assertEquals("The project ruleset is not equal to the plugin ruleset", bestPracticesRuleSet.getRules(),
286+
projectRuleSet.getRules());
282287
}
283288

284289
/**
285290
* When rules are added to the plugin preferences, these rules should also be added to the project
286291
*/
287292
@Test
288293
public void testProjectRuleSet3() throws PropertiesException, RuleSetNotFoundException, CoreException {
289-
290294
// First ensure that the plugin initial ruleset is equal to the project
291295
// ruleset
292296
final IProjectPropertiesManager mgr = PMDPlugin.getDefault().getPropertiesManager();
@@ -407,11 +411,11 @@ public void testRuleSetStoredInProjectFALSE() throws PropertiesException, RuleSe
407411
final IProjectProperties model = mgr.loadProjectProperties(this.testProject);
408412

409413
final RuleSetFactory factory = new RuleSetFactory();
410-
final RuleSet basicRuleSet = factory.createRuleSet("rulesets/java/basic.xml");
414+
final RuleSet bestPracticesRuleSet = factory.createRuleSet("category/java/bestpractices.xml");
411415
model.setPmdEnabled(true);
412416
model.setRuleSetStoredInProject(false);
413417
model.setProjectWorkingSet(null);
414-
model.setProjectRuleSet(basicRuleSet);
418+
model.setProjectRuleSet(bestPracticesRuleSet);
415419
model.sync();
416420

417421
model.createDefaultRuleSetFile();
@@ -433,7 +437,7 @@ public void testRuleSetStoredInProjectTRUE() throws PropertiesException, RuleSet
433437
final IProjectProperties model = mgr.loadProjectProperties(this.testProject);
434438

435439
final RuleSetFactory factory = new RuleSetFactory();
436-
final RuleSet basicRuleSet = factory.createRuleSet("rulesets/java/basic.xml");
440+
final RuleSet basicRuleSet = factory.createRuleSet("category/java/bestpractices.xml");
437441
model.setPmdEnabled(true);
438442
model.setRuleSetStoredInProject(false);
439443
model.setProjectWorkingSet(null);

0 commit comments

Comments
 (0)