Add support for Spring HTTP in CLI tests

pull/1016/head
Dave Syer 11 years ago
parent 51518a2041
commit 2f653f0616

@ -51,6 +51,7 @@ public class SpringMvcCompilerAutoConfiguration extends CompilerAutoConfiguratio
imports.addStarImports("org.springframework.web.bind.annotation",
"org.springframework.web.servlet.config.annotation",
"org.springframework.web.servlet",
"org.springframework.http",
"org.springframework.web.servlet.handler", "org.springframework.http",
"org.springframework.ui", "groovy.text");
imports.addStaticImport(GroovyTemplate.class.getName(), "template");

@ -28,6 +28,7 @@ import org.codehaus.groovy.control.SourceUnit;
import org.codehaus.groovy.control.customizers.ImportCustomizer;
import org.springframework.boot.cli.compiler.AstUtils;
import org.springframework.boot.cli.compiler.CompilerAutoConfiguration;
import org.springframework.boot.cli.compiler.DependencyCustomizer;
import org.springframework.boot.cli.compiler.GroovyCompilerConfiguration;
/**
@ -44,6 +45,12 @@ public class SpringTestCompilerAutoConfiguration extends CompilerAutoConfigurati
"SpringApplicationConfiguration");
}
@Override
public void applyDependencies(DependencyCustomizer dependencies) {
dependencies.ifAnyMissingClasses("org.springframework.http.HttpHeaders").add(
"spring-boot-starter-web");
}
@Override
public void apply(GroovyClassLoader loader,
GroovyCompilerConfiguration configuration, GeneratorContext generatorContext,
@ -58,10 +65,9 @@ public class SpringTestCompilerAutoConfiguration extends CompilerAutoConfigurati
@Override
public void applyImports(ImportCustomizer imports) throws CompilationFailedException {
imports.addStarImports("org.junit.runner")
.addStarImports("org.springframework.boot.test")
.addStarImports("org.springframework.test.context.junit4")
.addStarImports("org.springframework.test.annotation")
.addImports("org.springframework.test.context.web.WebAppConfiguration");
imports.addStarImports("org.junit.runner", "org.springframework.boot.test",
"org.springframework.http", "org.springframework.test.context.junit4",
"org.springframework.test.annotation").addImports(
"org.springframework.test.context.web.WebAppConfiguration");
}
}

Loading…
Cancel
Save