diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-01-21 17:55:20 +0100 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-01-21 17:55:20 +0100 |
commit | 67245675f16f9b185cf858f4209ef49b89ab03f6 (patch) | |
tree | 13b2afcd6c3560de050424a0e4cf6f37bdcb0f1c /sonar-java-api/src/test | |
parent | 0ad781a4d3dfbd984259c1f276f276685872fd2a (diff) | |
download | sonarqube-67245675f16f9b185cf858f4209ef49b89ab03f6.tar.gz sonarqube-67245675f16f9b185cf858f4209ef49b89ab03f6.zip |
SONAR-2130 Publish measures of Java methods on resource tree
Diffstat (limited to 'sonar-java-api/src/test')
-rw-r--r-- | sonar-java-api/src/test/java/org/sonar/java/api/JavaMethodTest.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/sonar-java-api/src/test/java/org/sonar/java/api/JavaMethodTest.java b/sonar-java-api/src/test/java/org/sonar/java/api/JavaMethodTest.java new file mode 100644 index 00000000000..bc6976aca25 --- /dev/null +++ b/sonar-java-api/src/test/java/org/sonar/java/api/JavaMethodTest.java @@ -0,0 +1,49 @@ +/* + * 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.java.api; + +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +public class JavaMethodTest { + @Test + public void shouldCreateReference() { + String key = "org.foo.Bar#hello(LString;)V"; + JavaMethod method = JavaMethod.createRef(key); + assertThat(method.getKey(), is(key)); + assertThat(method.getClassName(), is("org.foo.Bar")); + assertThat(method.getLongName(), is(key)); + assertThat(method.getName(), is("hello(LString;)V")); + assertThat(method.getSignature(), is("hello(LString;)V")); + } + + @Test + public void shouldCreateReferenceFromClassAndSignature() { + String className = "org.foo.Bar"; + String signature = "hello(LString;)V"; + JavaMethod method = JavaMethod.createRef(JavaClass.createRef(className), signature); + assertThat(method.getKey(), is(className + "#" + signature)); + assertThat(method.getClassName(), is(className)); + assertThat(method.getName(), is(signature)); + assertThat(method.getSignature(), is(signature)); + } +} |