Commit 2f653f06 authored by Dave Syer's avatar Dave Syer

Add support for Spring HTTP in CLI tests

parent 51518a20
...@@ -51,6 +51,7 @@ public class SpringMvcCompilerAutoConfiguration extends CompilerAutoConfiguratio ...@@ -51,6 +51,7 @@ public class SpringMvcCompilerAutoConfiguration extends CompilerAutoConfiguratio
imports.addStarImports("org.springframework.web.bind.annotation", imports.addStarImports("org.springframework.web.bind.annotation",
"org.springframework.web.servlet.config.annotation", "org.springframework.web.servlet.config.annotation",
"org.springframework.web.servlet", "org.springframework.web.servlet",
"org.springframework.http",
"org.springframework.web.servlet.handler", "org.springframework.http", "org.springframework.web.servlet.handler", "org.springframework.http",
"org.springframework.ui", "groovy.text"); "org.springframework.ui", "groovy.text");
imports.addStaticImport(GroovyTemplate.class.getName(), "template"); imports.addStaticImport(GroovyTemplate.class.getName(), "template");
......
...@@ -28,6 +28,7 @@ import org.codehaus.groovy.control.SourceUnit; ...@@ -28,6 +28,7 @@ import org.codehaus.groovy.control.SourceUnit;
import org.codehaus.groovy.control.customizers.ImportCustomizer; import org.codehaus.groovy.control.customizers.ImportCustomizer;
import org.springframework.boot.cli.compiler.AstUtils; import org.springframework.boot.cli.compiler.AstUtils;
import org.springframework.boot.cli.compiler.CompilerAutoConfiguration; import org.springframework.boot.cli.compiler.CompilerAutoConfiguration;
import org.springframework.boot.cli.compiler.DependencyCustomizer;
import org.springframework.boot.cli.compiler.GroovyCompilerConfiguration; import org.springframework.boot.cli.compiler.GroovyCompilerConfiguration;
/** /**
...@@ -44,6 +45,12 @@ public class SpringTestCompilerAutoConfiguration extends CompilerAutoConfigurati ...@@ -44,6 +45,12 @@ public class SpringTestCompilerAutoConfiguration extends CompilerAutoConfigurati
"SpringApplicationConfiguration"); "SpringApplicationConfiguration");
} }
@Override
public void applyDependencies(DependencyCustomizer dependencies) {
dependencies.ifAnyMissingClasses("org.springframework.http.HttpHeaders").add(
"spring-boot-starter-web");
}
@Override @Override
public void apply(GroovyClassLoader loader, public void apply(GroovyClassLoader loader,
GroovyCompilerConfiguration configuration, GeneratorContext generatorContext, GroovyCompilerConfiguration configuration, GeneratorContext generatorContext,
...@@ -58,10 +65,9 @@ public class SpringTestCompilerAutoConfiguration extends CompilerAutoConfigurati ...@@ -58,10 +65,9 @@ public class SpringTestCompilerAutoConfiguration extends CompilerAutoConfigurati
@Override @Override
public void applyImports(ImportCustomizer imports) throws CompilationFailedException { public void applyImports(ImportCustomizer imports) throws CompilationFailedException {
imports.addStarImports("org.junit.runner") imports.addStarImports("org.junit.runner", "org.springframework.boot.test",
.addStarImports("org.springframework.boot.test") "org.springframework.http", "org.springframework.test.context.junit4",
.addStarImports("org.springframework.test.context.junit4") "org.springframework.test.annotation").addImports(
.addStarImports("org.springframework.test.annotation") "org.springframework.test.context.web.WebAppConfiguration");
.addImports("org.springframework.test.context.web.WebAppConfiguration");
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment