From fa6f273677f8d665c0dad1283883111e626be29e Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Fri, 15 Apr 2011 10:06:08 +0200 Subject: [PATCH] SONAR-1865 Dollars ($) are not accepted in java class names --- .../main/java/org/sonar/api/resources/JavaFile.java | 6 ------ .../java/org/sonar/api/resources/JavaFileTest.java | 13 +++++-------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/JavaFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/JavaFile.java index 1949efea86c..9b68e000f24 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/JavaFile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/JavaFile.java @@ -54,9 +54,6 @@ public class JavaFile extends Resource { if (className == null) { throw new IllegalArgumentException("Java filename can not be null"); } - if (className.indexOf('$') >= 0) { - throw new IllegalArgumentException("Java inner classes are not supported : " + className); - } this.filename = StringUtils.trim(className); String key; if (StringUtils.isBlank(packageKey)) { @@ -88,9 +85,6 @@ public class JavaFile extends Resource { if (key == null) { throw new IllegalArgumentException("Java filename can not be null"); } - if (key.indexOf('$') >= 0) { - throw new IllegalArgumentException("Java inner classes are not supported : " + key); - } String realKey = StringUtils.trim(key); this.unitTest = unitTest; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/JavaFileTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/JavaFileTest.java index 33b597c7f68..4605b640017 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/JavaFileTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/JavaFileTest.java @@ -55,14 +55,11 @@ public class JavaFileTest { assertThat(javaClass.getParent().getKey(), is("org.foo.bar")); } - @Test(expected = IllegalArgumentException.class) - public void doNotAcceptInnerClasses() { - new JavaFile("org.foo.bar", "Hello$Bar"); - } - - @Test(expected = IllegalArgumentException.class) - public void doNotAcceptInnerClasses2() { - new JavaFile("org.foo.bar.Hello$Bar"); + @Test + public void shouldAcceptFilenamesWithDollars() { + // $ is not used only for inner classes !!! + JavaFile javaFile = new JavaFile("org.foo.bar", "Hello$Bar"); + assertThat(javaFile.getKey(), is("org.foo.bar.Hello$Bar")); } @Test -- 2.39.5