class Dirs {
- void init(Runner runner) {
+ void init(Runner<?> runner) {
boolean onProject = Utils.taskRequiresProject(runner.properties());
if (onProject) {
initProjectDirs(runner);
}
}
- private void initProjectDirs(Runner runner) {
+ private void initProjectDirs(Runner<?> runner) {
String path = runner.property(ScanProperties.PROJECT_BASEDIR, ".");
File projectDir = new File(path);
if (!projectDir.isDirectory()) {
/**
* Non-scan task
*/
- private void initTaskDirs(Runner runner) {
+ private void initTaskDirs(Runner<?> runner) {
String path = runner.property(RunnerProperties.WORK_DIR, ".");
File workDir = new File(path);
runner.setProperty(RunnerProperties.WORK_DIR, workDir.getAbsolutePath());
class SourceEncoding {
- void init(Runner runner) {
+ void init(Runner<?> runner) {
boolean onProject = Utils.taskRequiresProject(runner.properties());
if (onProject) {
String sourceEncoding = runner.property(ScanProperties.PROJECT_SOURCE_ENCODING, "");
public class DirsTest {
- Runner runner = new SimpleRunner();
+ Runner<?> runner = new SimpleRunner();
Dirs dirs = new Dirs();
@Rule
*/
package org.sonar.runner.api;
-class SimpleRunner extends Runner {
+class SimpleRunner extends Runner<SimpleRunner> {
@Override
protected void doExecute() {
}
public class SourceEncodingTest {
SourceEncoding encoding = new SourceEncoding();
- Runner runner = new SimpleRunner();
+ Runner<?> runner = new SimpleRunner();
@Test
public void should_set_default_platform_encoding() throws Exception {
class RunnerFactory {
- Runner create(Properties props) {
- Runner runner;
+ Runner<?> create(Properties props) {
+ Runner<?> runner;
if ("fork".equals(props.getProperty("sonarRunner.mode"))) {
runner = ForkedRunner.create();
String jvmArgs = props.getProperty("sonarRunner.fork.jvmArgs", "");
@Test
public void should_create_embedded_runner_by_default() {
props.setProperty("foo", "bar");
- Runner runner = new RunnerFactory().create(props);
+ Runner<?> runner = new RunnerFactory().create(props);
assertThat(runner).isInstanceOf(EmbeddedRunner.class);
assertThat(runner.properties().get("foo")).isEqualTo("bar");
props.setProperty("foo", "bar");
props.setProperty("sonarRunner.mode", "fork");
props.setProperty("sonarRunner.fork.jvmArgs", "-Xms128m -Xmx512m");
- Runner runner = new RunnerFactory().create(props);
+ Runner<?> runner = new RunnerFactory().create(props);
assertThat(runner).isInstanceOf(ForkedRunner.class);
assertThat(runner.properties().get("foo")).isEqualTo("bar");
public void should_create_forked_runner_with_jvm_arguments() {
props.setProperty("foo", "bar");
props.setProperty("sonarRunner.mode", "fork");
- Runner runner = new RunnerFactory().create(props);
+ Runner<?> runner = new RunnerFactory().create(props);
assertThat(runner).isInstanceOf(ForkedRunner.class);
assertThat(runner.properties().get("foo")).isEqualTo("bar");
}), argThat(new ArgumentMatcher<List<Object>>() {
@Override
public boolean matches(Object o) {
- return ((List) o).isEmpty();
+ return ((List<?>) o).isEmpty();
}
}));
}
*/
package org.sonar.runner.impl;
+import java.io.IOException;
+
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
public ExpectedException thrown = ExpectedException.none();
@Test
- public void should_restrict_loading_from_parent() throws Exception {
+ public void should_restrict_loading_from_parent() throws IOException {
ClassLoader parentClassloader = getClass().getClassLoader();
IsolatedClassloader classLoader = new IsolatedClassloader(parentClassloader, new String[][] {new String[] {"UNMASK", "org.apache.ant."}});
assertThat(classLoader.canLoadFromParent("org.apache.ant.Foo")).isTrue();
assertThat(classLoader.canLoadFromParent("org.apache.ant.project.Project")).isTrue();
+ classLoader.close();
}
@Test
- public void should_use_isolated_system_classloader_when_parent_is_excluded() throws ClassNotFoundException {
+ public void should_use_isolated_system_classloader_when_parent_is_excluded() throws ClassNotFoundException, IOException {
thrown.expect(ClassNotFoundException.class);
thrown.expectMessage("org.junit.Test");
ClassLoader parent = getClass().getClassLoader();
// JUnit is available in the parent classloader (classpath used to execute this test) but not in the core JVM
assertThat(classLoader.loadClass("java.lang.String", false)).isNotNull();
classLoader.loadClass("org.junit.Test", false);
+ classLoader.close();
}
@Test
- public void should_find_in_parent_when_matches_unmasked_packages() throws ClassNotFoundException {
+ public void should_find_in_parent_when_matches_unmasked_packages() throws ClassNotFoundException, IOException {
ClassLoader parent = getClass().getClassLoader();
IsolatedClassloader classLoader = new IsolatedClassloader(parent, new String[][] {new String[] {"UNMASK", "org.junit."}});
// JUnit is available in the parent classloader (classpath used to execute this test) but not in the core JVM
assertThat(classLoader.loadClass("org.junit.Test", false)).isNotNull();
+ classLoader.close();
}
}
import org.junit.rules.TemporaryFolder;
import java.io.File;
-import java.io.IOException;
-import java.nio.file.Paths;
import java.util.Properties;
import static org.fest.assertions.Assertions.assertThat;