diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2010-09-06 14:08:06 +0000 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2010-09-06 14:08:06 +0000 |
commit | aeadc1f9129274949daaa57738c7c4550bdfbc7b (patch) | |
tree | 08dadf5ef7474fc41d1d48f74648f1ba8b55f34d /sonar-plugin-api/src/test/java/org/sonar/api/resources/JavaPackageTest.java | |
download | sonarqube-aeadc1f9129274949daaa57738c7c4550bdfbc7b.tar.gz sonarqube-aeadc1f9129274949daaa57738c7c4550bdfbc7b.zip |
SONAR-236 remove deprecated code from checkstyle plugin + display default value of rule parameters in Q profile console
Diffstat (limited to 'sonar-plugin-api/src/test/java/org/sonar/api/resources/JavaPackageTest.java')
-rw-r--r-- | sonar-plugin-api/src/test/java/org/sonar/api/resources/JavaPackageTest.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/JavaPackageTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/JavaPackageTest.java new file mode 100644 index 00000000000..827bbd55d61 --- /dev/null +++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/JavaPackageTest.java @@ -0,0 +1,58 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2009 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.api.resources; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.*; +import org.junit.Test; + +public class JavaPackageTest { + @Test + public void defaultPackage() { + assertEquals(new JavaPackage(), new JavaPackage()); + assertEquals(JavaPackage.DEFAULT_PACKAGE_NAME, new JavaPackage(null).getKey()); + assertEquals(JavaPackage.DEFAULT_PACKAGE_NAME, new JavaPackage(null).getName()); + assertEquals(JavaPackage.DEFAULT_PACKAGE_NAME, new JavaPackage("").getKey()); + assertThat(new JavaPackage(null).isDefault(), is(true)); + } + + @Test + public void testNewPackage() { + assertEquals(new JavaPackage(" foo.bar "), new JavaPackage("foo.bar")); + JavaPackage pac = new JavaPackage("foo.bar"); + assertEquals("foo.bar", pac.getKey()); + assertEquals("foo.bar", pac.getName()); + } + + @Test + public void singleLevelPackage() { + assertEquals(new JavaPackage("foo"), new JavaPackage("foo")); + JavaPackage pac = new JavaPackage("foo"); + assertEquals("foo", pac.getKey()); + assertEquals("foo", pac.getName()); + } + + @Test + public void shouldNotMatchFilePatterns() { + JavaPackage pac = new JavaPackage("org.sonar.commons"); + assertFalse(pac.matchFilePattern("**")); + } + +} |