Skip to content

Commit

Permalink
https://github.com/grails/grails-core/issues/11367
Browse files Browse the repository at this point in the history
Expanded integrationtest to demonstrate that it is not possible to inject StatefulRedisConnection without @qualifier("io.lettuce.core.api.StatefulRedisConnection(Primary)")
  • Loading branch information
andersaaberg committed Oct 18, 2019
1 parent 59f189c commit fe36116
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
2 changes: 2 additions & 0 deletions micronaut/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ dependencies {
compile "org.hibernate:hibernate-core:5.4.0.Final"
compile "org.grails.plugins:gsp"
compileOnly "io.micronaut:micronaut-inject-groovy"
compile 'io.micronaut.configuration:micronaut-redis-lettuce:1.1.0'
console "org.grails:grails-console"
profile "org.grails.profiles:web"
runtime "org.glassfish.web:el-impl:2.1.2-b03"
Expand All @@ -71,6 +72,7 @@ dependencies {
testCompile "org.seleniumhq.selenium:selenium-support:3.14.0"
testRuntime "org.seleniumhq.selenium:selenium-chrome-driver:3.14.0"
testRuntime "org.seleniumhq.selenium:selenium-firefox-driver:3.14.0"
testCompile "com.github.kstyrc:embedded-redis:0.6"
}

bootRun {
Expand Down
2 changes: 2 additions & 0 deletions micronaut/grails-app/conf/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,5 @@ environments:
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
redis:
enabled: true
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package micronaut
import bean.injection.NamedService
import bean.injection.Qualified
import org.springframework.beans.factory.annotation.Autowired

import javax.inject.Inject
import io.lettuce.core.api.StatefulRedisConnection
import org.springframework.beans.factory.annotation.Qualifier
import javax.inject.Named

class BeanInjectionService {
Expand All @@ -26,4 +26,9 @@ class BeanInjectionService {

@Autowired
NamedService namedService

// TODO: it should not be needed to add this Qualifier
@Qualifier("io.lettuce.core.api.StatefulRedisConnection(Primary)")
@Autowired
StatefulRedisConnection<String, String> statefulRedisConnection
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,23 @@ package micronaut
import grails.testing.mixin.integration.Integration
import org.springframework.beans.factory.annotation.Autowired
import spock.lang.Specification
import redis.embedded.RedisServer

@Integration
class BeanInjectionServiceSpec extends Specification {

static RedisServer redisServer = new RedisServer(6379)

def setupSpec() {
redisServer.start()
}

def cleanupSpec() {
if(redisServer) {
redisServer.stop()
}
}

@Autowired
BeanInjectionService service

Expand All @@ -17,5 +30,6 @@ class BeanInjectionServiceSpec extends Specification {
service.namedService3.name == "special"
service.namedService4.name == "qualified"
service.namedService.name == "primary"
service.statefulRedisConnection.sync().ping() == 'PONG'
}
}

0 comments on commit fe36116

Please sign in to comment.