-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
715 additions
and
122 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
coverage-report/src/test/java/org/jooby/issues/Issue484.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.jooby.issues; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.jooby.Deferred; | ||
import org.jooby.test.ServerFeature; | ||
import org.junit.Test; | ||
|
||
public class Issue484 extends ServerFeature { | ||
|
||
{ | ||
get("/484", req -> { | ||
String t1 = Thread.currentThread().getName(); | ||
return new Deferred(deferred -> { | ||
deferred.resolve(t1 + ":" + Thread.currentThread().getName()); | ||
}); | ||
}); | ||
|
||
get("/484/promise", promise(deferred -> { | ||
String t1 = Thread.currentThread().getName(); | ||
deferred.resolve(t1 + ":" + Thread.currentThread().getName()); | ||
})); | ||
} | ||
|
||
@Test | ||
public void deferredOnDefaultExecutor() throws Exception { | ||
request() | ||
.get("/484") | ||
.expect(rsp -> { | ||
String[] threads = rsp.split(":"); | ||
assertEquals(threads[0], threads[1]); | ||
}); | ||
|
||
request() | ||
.get("/484/promise") | ||
.expect(rsp -> { | ||
String[] threads = rsp.split(":"); | ||
assertEquals(threads[0], threads[1]); | ||
}); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
coverage-report/src/test/java/org/jooby/issues/Issue484b.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.jooby.issues; | ||
|
||
import static org.junit.Assert.assertNotEquals; | ||
|
||
import java.util.concurrent.ForkJoinPool; | ||
|
||
import org.jooby.Deferred; | ||
import org.jooby.test.ServerFeature; | ||
import org.junit.Test; | ||
|
||
public class Issue484b extends ServerFeature { | ||
|
||
{ | ||
executor(new ForkJoinPool()); | ||
|
||
get("/484", req -> { | ||
return new Deferred(deferred -> { | ||
deferred.resolve(deferred.callerThread() + ":" + Thread.currentThread().getName()); | ||
}); | ||
}); | ||
|
||
get("/484/promise", promise(deferred -> { | ||
deferred.resolve(deferred.callerThread() + ":" + Thread.currentThread().getName()); | ||
})); | ||
} | ||
|
||
@Test | ||
public void deferredWithExecutorInstance() throws Exception { | ||
request() | ||
.get("/484") | ||
.expect(rsp -> { | ||
System.out.println(rsp); | ||
String[] threads = rsp.split(":"); | ||
assertNotEquals(threads[0], threads[1]); | ||
}); | ||
|
||
request() | ||
.get("/484/promise") | ||
.expect(rsp -> { | ||
System.out.println(rsp); | ||
String[] threads = rsp.split(":"); | ||
assertNotEquals(threads[0], threads[1]); | ||
}); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
coverage-report/src/test/java/org/jooby/issues/Issue484c.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.jooby.issues; | ||
|
||
import static org.junit.Assert.assertNotEquals; | ||
|
||
import java.util.concurrent.Executor; | ||
import java.util.concurrent.Executors; | ||
|
||
import org.jooby.Deferred; | ||
import org.jooby.test.ServerFeature; | ||
import org.junit.Test; | ||
|
||
import com.google.inject.Key; | ||
import com.google.inject.name.Names; | ||
|
||
public class Issue484c extends ServerFeature { | ||
|
||
{ | ||
executor("ste"); | ||
|
||
use((env, conf, binder) -> { | ||
binder.bind(Key.get(Executor.class, Names.named("ste"))) | ||
.toInstance(Executors.newSingleThreadExecutor()); | ||
}); | ||
|
||
get("/484", req -> { | ||
return new Deferred(deferred -> { | ||
deferred.resolve(deferred.callerThread() + ":" + Thread.currentThread().getName()); | ||
}); | ||
}); | ||
|
||
get("/484/promise", promise((req, deferred) -> { | ||
deferred.resolve(deferred.callerThread() + ":" + Thread.currentThread().getName()); | ||
})); | ||
} | ||
|
||
@Test | ||
public void deferredWithExecutorReference() throws Exception { | ||
request() | ||
.get("/484") | ||
.expect(rsp -> { | ||
System.out.println(rsp); | ||
String[] threads = rsp.split(":"); | ||
assertNotEquals(threads[0], threads[1]); | ||
}); | ||
|
||
request() | ||
.get("/484/promise") | ||
.expect(rsp -> { | ||
System.out.println(rsp); | ||
String[] threads = rsp.split(":"); | ||
assertNotEquals(threads[0], threads[1]); | ||
}); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
coverage-report/src/test/java/org/jooby/issues/Issue484d.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.jooby.issues; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.jooby.Deferred; | ||
import org.jooby.exec.Exec; | ||
import org.jooby.test.ServerFeature; | ||
import org.junit.Test; | ||
|
||
import com.typesafe.config.ConfigFactory; | ||
import com.typesafe.config.ConfigValueFactory; | ||
|
||
public class Issue484d extends ServerFeature { | ||
|
||
{ | ||
use(ConfigFactory.empty() | ||
.withValue("executors.fj", ConfigValueFactory.fromAnyRef("forkjoin = 2")) | ||
.withValue("executors.cached", ConfigValueFactory.fromAnyRef("cached"))); | ||
|
||
executor("fj"); | ||
|
||
use(new Exec()); | ||
|
||
get("/484", req -> new Deferred(deferred -> { | ||
deferred.resolve(Thread.currentThread().getName()); | ||
})); | ||
|
||
get("/484/cached", req -> new Deferred("cached", deferred -> { | ||
deferred.resolve(Thread.currentThread().getName()); | ||
})); | ||
|
||
get("/484/fj", promise(deferred -> { | ||
deferred.resolve(Thread.currentThread().getName()); | ||
})); | ||
|
||
get("/484/local/cached", promise("cached", (req, deferred) -> { | ||
deferred.resolve(Thread.currentThread().getName()); | ||
})); | ||
|
||
get("/484/local/fj", promise("fj", deferred -> { | ||
deferred.resolve(Thread.currentThread().getName()); | ||
})); | ||
} | ||
|
||
@Test | ||
public void deferredOnGloablOrLocalExecutor() throws Exception { | ||
request() | ||
.get("/484") | ||
.expect(rsp -> { | ||
assertTrue(rsp.startsWith("forkjoin")); | ||
}); | ||
|
||
request() | ||
.get("/484/cached") | ||
.expect(rsp -> { | ||
assertTrue(rsp.startsWith("cached")); | ||
}); | ||
|
||
request() | ||
.get("/484/fj") | ||
.expect(rsp -> { | ||
assertTrue(rsp.startsWith("forkjoin")); | ||
}); | ||
|
||
request() | ||
.get("/484/local/cached") | ||
.expect(rsp -> { | ||
assertTrue(rsp.startsWith("cached")); | ||
}); | ||
|
||
request() | ||
.get("/484/local/fj") | ||
.expect(rsp -> { | ||
assertTrue(rsp.startsWith("forkjoin")); | ||
}); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
coverage-report/src/test/java/org/jooby/issues/Issue485.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.jooby.issues; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.ForkJoinPool; | ||
|
||
import org.jooby.test.ServerFeature; | ||
import org.junit.Test; | ||
|
||
public class Issue485 extends ServerFeature { | ||
|
||
{ | ||
executor(new ForkJoinPool()); | ||
executor("cached", Executors.newCachedThreadPool()); | ||
|
||
get("/485/fj", promise(deferred -> { | ||
deferred.resolve(Thread.currentThread().getName()); | ||
})); | ||
|
||
get("/485/cached", promise("cached", deferred -> { | ||
deferred.resolve(Thread.currentThread().getName()); | ||
})); | ||
|
||
} | ||
|
||
@Test | ||
public void globalOrLocalExecutor() throws Exception { | ||
request() | ||
.get("/485/fj") | ||
.expect(rsp -> { | ||
assertTrue(rsp.toLowerCase().startsWith("forkjoinpool")); | ||
}); | ||
|
||
request() | ||
.get("/485/cached") | ||
.expect(rsp -> { | ||
assertTrue(rsp.toLowerCase().startsWith("pool")); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.