Polish
This commit is contained in:
@@ -19,7 +19,6 @@ package org.springframework.boot.cli.compiler.autoconfigure;
|
||||
import org.codehaus.groovy.ast.ClassNode;
|
||||
import org.codehaus.groovy.control.CompilationFailedException;
|
||||
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;
|
||||
@@ -30,7 +29,7 @@ import org.springframework.boot.cli.compiler.DependencyCustomizer;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public class CachingAutoConfiguration extends CompilerAutoConfiguration {
|
||||
public class CachingCompilerAutoConfiguration extends CompilerAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public boolean matches(ClassNode classNode) {
|
||||
@@ -41,13 +40,13 @@ public class CachingAutoConfiguration extends CompilerAutoConfiguration {
|
||||
public void applyDependencies(DependencyCustomizer dependencies)
|
||||
throws CompilationFailedException {
|
||||
dependencies.add("spring-context-support");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyImports(ImportCustomizer imports) throws CompilationFailedException {
|
||||
imports.addStarImports("org.springframework.cache",
|
||||
"org.springframework.cache.annotation", "org.springframework.cache.concurrent");
|
||||
"org.springframework.cache.annotation",
|
||||
"org.springframework.cache.concurrent");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,7 +22,6 @@ 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.groovy.EnableJmsMessaging;
|
||||
|
||||
/**
|
||||
* {@link CompilerAutoConfiguration} for Spring JMS.
|
||||
@@ -34,26 +33,25 @@ public class JmsCompilerAutoConfiguration extends CompilerAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public boolean matches(ClassNode classNode) {
|
||||
return AstUtils.hasAtLeastOneAnnotation(classNode, "EnableJms") ||
|
||||
AstUtils.hasAtLeastOneAnnotation(classNode, "EnableJmsMessaging");
|
||||
return AstUtils.hasAtLeastOneAnnotation(classNode, "EnableJms")
|
||||
|| AstUtils.hasAtLeastOneAnnotation(classNode, "EnableJmsMessaging");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies)
|
||||
throws CompilationFailedException {
|
||||
dependencies.add("spring-jms", "jms-api");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void applyImports(ImportCustomizer imports) throws CompilationFailedException {
|
||||
imports.addStarImports("javax.jms",
|
||||
"org.springframework.jms.annotation",
|
||||
"org.springframework.jms.config",
|
||||
"org.springframework.jms.core",
|
||||
imports.addStarImports("javax.jms", "org.springframework.jms.annotation",
|
||||
"org.springframework.jms.config", "org.springframework.jms.core",
|
||||
"org.springframework.jms.listener",
|
||||
"org.springframework.jms.listener.adapter")
|
||||
.addImports(EnableJmsMessaging.class.getCanonicalName());
|
||||
"org.springframework.jms.listener.adapter").addImports(
|
||||
org.springframework.boot.groovy.EnableJmsMessaging.class
|
||||
.getCanonicalName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ org.springframework.boot.cli.compiler.autoconfigure.SpringMvcCompilerAutoConfigu
|
||||
org.springframework.boot.cli.compiler.autoconfigure.SpringBatchCompilerAutoConfiguration
|
||||
org.springframework.boot.cli.compiler.autoconfigure.RabbitCompilerAutoConfiguration
|
||||
org.springframework.boot.cli.compiler.autoconfigure.ReactorCompilerAutoConfiguration
|
||||
org.springframework.boot.cli.compiler.autoconfigure.CachingAutoConfiguration
|
||||
org.springframework.boot.cli.compiler.autoconfigure.CachingCompilerAutoConfiguration
|
||||
org.springframework.boot.cli.compiler.autoconfigure.JdbcCompilerAutoConfiguration
|
||||
org.springframework.boot.cli.compiler.autoconfigure.JmsCompilerAutoConfiguration
|
||||
org.springframework.boot.cli.compiler.autoconfigure.JUnitCompilerAutoConfiguration
|
||||
@@ -17,4 +17,4 @@ org.springframework.boot.cli.compiler.autoconfigure.SpringSocialFacebookCompiler
|
||||
org.springframework.boot.cli.compiler.autoconfigure.SpringSocialLinkedInCompilerAutoConfiguration
|
||||
org.springframework.boot.cli.compiler.autoconfigure.SpringSocialTwitterCompilerAutoConfiguration
|
||||
org.springframework.boot.cli.compiler.autoconfigure.SpringTestCompilerAutoConfiguration
|
||||
org.springframework.boot.cli.compiler.autoconfigure.SpringWebsocketCompilerAutoConfiguration
|
||||
org.springframework.boot.cli.compiler.autoconfigure.SpringWebsocketCompilerAutoConfiguration
|
||||
|
||||
@@ -27,6 +27,8 @@ import org.junit.Test;
|
||||
import org.springframework.boot.cli.command.grab.GrabCommand;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@@ -68,8 +70,9 @@ public class GrabCommandIntegrationTests {
|
||||
this.cli.grab("duplicateGrabMetadata.groovy");
|
||||
fail();
|
||||
}
|
||||
catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("Duplicate @GrabMetadata annotation"));
|
||||
catch (Exception ex) {
|
||||
assertThat(ex.getMessage(),
|
||||
containsString("Duplicate @GrabMetadata annotation"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,9 +79,4 @@ public class ReproIntegrationTests {
|
||||
assertThat(this.cli.getOutput(), containsString("Hello World"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void caching() throws Exception {
|
||||
this.cli.run("caching.groovy");
|
||||
assertThat(this.cli.getOutput(), containsString("Hello World"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,9 @@ import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
@@ -156,4 +158,10 @@ public class SampleIntegrationTests {
|
||||
assertEquals("Hello Normal Device!", this.cli.getHttpOutput());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void caching() throws Exception {
|
||||
this.cli.run("caching.groovy");
|
||||
assertThat(this.cli.getOutput(), containsString("Hello World"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
package org.test
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
class Sample {
|
||||
|
||||
@Bean CacheManager cacheManager() {
|
||||
new ConcurrentMapCacheManager()
|
||||
}
|
||||
|
||||
@Component
|
||||
static class MyClient implements CommandLineRunner {
|
||||
|
||||
private final MyService myService
|
||||
|
||||
@Autowired
|
||||
MyClient(MyService myService) {
|
||||
this.myService = myService
|
||||
}
|
||||
|
||||
void run(String... args) {
|
||||
long counter = myService.get('someKey')
|
||||
long counter2 = myService.get('someKey')
|
||||
if (counter == counter2) {
|
||||
println 'Hello World'
|
||||
} else {
|
||||
println 'Something went wrong with the cache setup'
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
static class MyService {
|
||||
|
||||
private final AtomicLong counter = new AtomicLong()
|
||||
|
||||
@Cacheable('foo')
|
||||
Long get(String id) {
|
||||
return counter.getAndIncrement()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user