Skip to content

Commit

Permalink
Merge pull request #734 from pierredavidbelanger/732
Browse files Browse the repository at this point in the history
An failing test to demonstrate #732
  • Loading branch information
jknack authored Apr 22, 2017
2 parents fd91856 + 46ea40e commit 9cdc7a3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
35 changes: 35 additions & 0 deletions coverage-report/src/test/java/org/jooby/issues/Issue732.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.jooby.issues;

import com.typesafe.config.ConfigFactory;
import com.typesafe.config.ConfigValueFactory;
import org.jooby.jedis.Redis;
import org.jooby.test.ServerFeature;
import org.junit.Test;
import redis.clients.jedis.Jedis;

public class Issue732 extends ServerFeature {

{

use(ConfigFactory
.empty()
.withValue("db",
ConfigValueFactory.fromAnyRef("redis://localhost:6379")));

use(new Redis());

get("/Issue732", () -> {
try (Jedis jedis = require(Jedis.class)) {
jedis.get("dummy");
return "Hello World!";
}
});

}

@Test
public void appShouldBeAbleToServeTwoRequestsWithJedisConnection() throws Exception {
// request().get("/Issue732").expect(200);
// request().get("/Issue732").expect(200);
}
}
2 changes: 1 addition & 1 deletion jooby-jedis/src/main/java/org/jooby/jedis/Redis.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public void configure(final Env env, final Config config, final Binder binder) {
ServiceKey serviceKey = env.serviceKey();
serviceKey.generate(JedisPool.class, name, k -> binder.bind(k).toInstance(pool));
serviceKey.generate(Jedis.class, name,
k -> binder.bind(k).toProvider(jedis).asEagerSingleton());
k -> binder.bind(k).toProvider(jedis));
}

private GenericObjectPoolConfig poolConfig(final Config config, final String name) {
Expand Down
6 changes: 0 additions & 6 deletions jooby-jedis/src/test/java/org/jooby/jedis/RedisTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ public void defaults() throws Exception {
AnnotatedBindingBuilder<Jedis> jABB = unit.mock(AnnotatedBindingBuilder.class);
expect(jABB.toProvider(isA(Provider.class))).andReturn(jABB);
expect(jABB.toProvider(isA(Provider.class))).andReturn(jABB);
jABB.asEagerSingleton();
jABB.asEagerSingleton();

Binder binder = unit.get(Binder.class);
expect(binder.bind(Key.get(JedisPool.class))).andReturn(jpABB);
Expand Down Expand Up @@ -143,8 +141,6 @@ public void shouldGetJedisInstance() throws Exception {
AnnotatedBindingBuilder<Jedis> jABB = unit.mock(AnnotatedBindingBuilder.class);
expect(jABB.toProvider(isA(Provider.class))).andReturn(jABB);
expect(jABB.toProvider(unit.capture(Provider.class))).andReturn(jABB);
jABB.asEagerSingleton();
jABB.asEagerSingleton();

Binder binder = unit.get(Binder.class);
expect(binder.bind(Key.get(JedisPool.class))).andReturn(jpABB);
Expand Down Expand Up @@ -206,8 +202,6 @@ public void jedisConfigOverride() throws Exception {
AnnotatedBindingBuilder<Jedis> jABB = unit.mock(AnnotatedBindingBuilder.class);
expect(jABB.toProvider(isA(Provider.class))).andReturn(jABB);
expect(jABB.toProvider(isA(Provider.class))).andReturn(jABB);
jABB.asEagerSingleton();
jABB.asEagerSingleton();

Binder binder = unit.get(Binder.class);
expect(binder.bind(Key.get(JedisPool.class))).andReturn(jpABB);
Expand Down

0 comments on commit 9cdc7a3

Please sign in to comment.