+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * 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.batch.bootstrap;
-
-import org.junit.Test;
-
-import java.io.File;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertNull;
-
-public class BootstrapClassLoaderTest {
-
- @Test
- public void testClassLoader() throws URISyntaxException {
- /* foo.jar has just one file /foo/foo.txt */
- assertNull(getClass().getClassLoader().getResource("foo/foo.txt"));
-
- URL url = getClass().getResource("/org/sonar/batch/bootstrap/BootstrapClassLoaderTest/foo.jar");
- JdbcDriverHolder classloader = new JdbcDriverHolder(new File(url.toURI()));
- assertNotNull(classloader.getClassLoader());
- assertNotNull(classloader.getClassLoader().getResource("foo/foo.txt"));
-
- }
-}
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * 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.batch.bootstrap;
+
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNull;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.junit.Test;
+
+public class JdbcDriverHolderTest {
+
+ @Test
+ public void testClassLoader() throws URISyntaxException {
+ /* foo.jar has just one file /foo/foo.txt */
+ assertNull(getClass().getClassLoader().getResource("foo/foo.txt"));
+
+ URL url = getClass().getResource("/org/sonar/batch/bootstrap/JdbcDriverHolderTest/foo.jar");
+ JdbcDriverHolder classloader = new JdbcDriverHolder(new File(url.toURI()));
+ assertNotNull(classloader.getClassLoader());
+ assertNotNull(classloader.getClassLoader().getResource("foo/foo.txt"));
+
+ classloader.stop();
+ assertNull(classloader.getClassLoader());
+ }
+
+}
*/
package org.sonar.api.batch.bootstrap;
-import org.hamcrest.CoreMatchers;
-import org.junit.Test;
-import org.sonar.api.CoreProperties;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
import java.io.File;
import java.util.List;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
+import org.hamcrest.CoreMatchers;
+import org.junit.Test;
+import org.sonar.api.CoreProperties;
public class ProjectDefinitionTest {
assertThat(def.getKey(), is("mykey"));
}
+ @Test
+ public void shouldSetVersion() {
+ ProjectDefinition def = ProjectDefinition.create();
+ def.setVersion("2.0-SNAPSHOT");
+ assertThat(def.getVersion(), is("2.0-SNAPSHOT"));
+ }
+
+ /**
+ * Compatibility with Ant task.
+ */
+ @Test
+ public void shouldNotCloneProperties() {
+ Properties props = new Properties();
+
+ ProjectDefinition def = ProjectDefinition.create(props);
+ assertThat(def.getKey(), nullValue());
+
+ props.setProperty(CoreProperties.PROJECT_KEY_PROPERTY, "mykey");
+ assertThat(def.getKey(), is("mykey"));
+ }
+
@Test
public void shouldSetOptionalFields() {
ProjectDefinition def = ProjectDefinition.create();
public void shouldGetKeyFromProperties() {
Properties props = new Properties();
props.setProperty(CoreProperties.PROJECT_KEY_PROPERTY, "foo");
- ProjectDefinition def = ProjectDefinition.create(props);
+ ProjectDefinition def = ProjectDefinition.create();
+ def.setProperties(props);
assertThat(def.getKey(), is("foo"));
}