Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got Javanica unit tests compiling (but failing) #359

Merged
merged 3 commits into from
Dec 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import rx.internal.operators.OperatorMulticast;

import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;
import java.util.concurrent.RunnableFuture;

Expand All @@ -30,7 +29,6 @@ public static List<Object[]> data() {
{returnType(Future.class), shouldHaveExecutionType(ASYNCHRONOUS)},
{returnType(AsyncResult.class), shouldHaveExecutionType(ASYNCHRONOUS)},
{returnType(RunnableFuture.class), shouldHaveExecutionType(ASYNCHRONOUS)},
{returnType(CompletableFuture.class), shouldHaveExecutionType(ASYNCHRONOUS)},
{returnType(Observable.class), shouldHaveExecutionType(OBSERVABLE)},
{returnType(OperatorMulticast.class), shouldHaveExecutionType(OBSERVABLE)},
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.netflix.hystrix.contrib.javanica.test.spring.cache;

import com.google.common.collect.Iterables;
import com.netflix.hystrix.HystrixExecutableInfo;
import com.netflix.hystrix.HystrixInvokableInfo;
import com.netflix.hystrix.HystrixRequestLog;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.test.spring.conf.AopCglibConfig;
Expand Down Expand Up @@ -38,7 +38,7 @@ public void testGetUserCache() {
try {

User user = userService.getUser("1", "name");
HystrixExecutableInfo getUserByIdCommand = getLastExecutedCommand();
HystrixInvokableInfo<?> getUserByIdCommand = getLastExecutedCommand();
assertEquals("1", user.getId());

// this is the first time we've executed this command with
Expand All @@ -59,7 +59,7 @@ public void testGetUserCache() {
context = HystrixRequestContext.initializeContext();
try {
User user = userService.getUser("1", "name");
HystrixExecutableInfo getUserByIdCommand = getLastExecutedCommand();
HystrixInvokableInfo<?> getUserByIdCommand = getLastExecutedCommand();
assertEquals("1", user.getId());
// this is a new request context so this
// should not come from cache
Expand All @@ -69,8 +69,8 @@ public void testGetUserCache() {
}
}

private HystrixExecutableInfo getLastExecutedCommand() {
Collection<HystrixExecutableInfo<?>> executedCommands =
private HystrixInvokableInfo<?> getLastExecutedCommand() {
Collection<HystrixInvokableInfo<?>> executedCommands =
HystrixRequestLog.getCurrentRequest().getAllExecutedCommands();
return Iterables.getLast(executedCommands);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.netflix.hystrix.contrib.javanica.test.spring.collapser;

import com.netflix.hystrix.HystrixEventType;
import com.netflix.hystrix.HystrixInvokableInfo;
import com.netflix.hystrix.HystrixRequestLog;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCollapser;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
Expand Down Expand Up @@ -53,7 +54,7 @@ public void testCollapserAsync() throws ExecutionException, InterruptedException
// assert that the batch command 'GetUserCommand' was in fact
// executed and that it executed only once
assertEquals(1, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
com.netflix.hystrix.HystrixExecutableInfo<?> command = HystrixRequestLog.getCurrentRequest()
HystrixInvokableInfo<?> command = HystrixRequestLog.getCurrentRequest()
.getAllExecutedCommands().iterator().next();
// assert the command is the one we're expecting
assertEquals("GetUserCommand", command.getCommandKey().name());
Expand Down Expand Up @@ -169,7 +170,7 @@ public void testCollapserSync() throws ExecutionException, InterruptedException
assertEquals("name: 3", u3.getName());
assertEquals("name: 4", u4.getName());

com.netflix.hystrix.HystrixExecutableInfo<?> command = HystrixRequestLog.getCurrentRequest()
HystrixInvokableInfo<?> command = HystrixRequestLog.getCurrentRequest()
.getAllExecutedCommands().iterator().next();
assertEquals("GetUserCommand", command.getCommandKey().name());
// confirm that it was a COLLAPSED command execution
Expand All @@ -187,7 +188,7 @@ public void testCollapserSyncWithFallbackCommand() throws ExecutionException, In
try {
User u1 = userService.getUserSync("5", "name: ");
assertEquals("name: 5", u1.getName());
com.netflix.hystrix.HystrixExecutableInfo<?> command = HystrixRequestLog.getCurrentRequest()
HystrixInvokableInfo<?> command = HystrixRequestLog.getCurrentRequest()
.getAllExecutedCommands().iterator().next();
assertEquals("GetUserCommand", command.getCommandKey().name());
// confirm that it was a COLLAPSED command execution
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.netflix.hystrix.contrib.javanica.test.spring.configuration.collapser;

import com.netflix.hystrix.HystrixEventType;
import com.netflix.hystrix.HystrixInvokableInfo;
import com.netflix.hystrix.HystrixRequestLog;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCollapser;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
Expand Down Expand Up @@ -44,7 +45,7 @@ public void testCollapser() throws ExecutionException, InterruptedException {
assertEquals("name: 3", u3.getName());
assertEquals("name: 4", u4.getName());

com.netflix.hystrix.HystrixExecutableInfo<?> command = HystrixRequestLog.getCurrentRequest()
HystrixInvokableInfo<?> command = HystrixRequestLog.getCurrentRequest()
.getAllExecutedCommands().iterator().next();
assertEquals("getUser", command.getCommandKey().name());
//When a command is fronted by an HystrixCollapser then this marks how many requests are collapsed into the single command execution.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.netflix.hystrix.contrib.javanica.test.spring.configuration.command;

import com.netflix.hystrix.HystrixEventType;
import com.netflix.hystrix.HystrixInvokableInfo;
import com.netflix.hystrix.HystrixRequestLog;
import com.netflix.hystrix.HystrixThreadPool;
import com.netflix.hystrix.HystrixThreadPoolProperties;
Expand Down Expand Up @@ -38,7 +39,7 @@ public void testGetUser() throws NoSuchFieldException, IllegalAccessException {
User u1 = userService.getUser("1", "name: ");
assertEquals("name: 1", u1.getName());
assertEquals(1, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
com.netflix.hystrix.HystrixExecutableInfo<?> command = HystrixRequestLog.getCurrentRequest()
HystrixInvokableInfo<?> command = HystrixRequestLog.getCurrentRequest()
.getAllExecutedCommands().iterator().next();
assertEquals("GetUserCommand", command.getCommandKey().name());
assertEquals("UserGroupKey", command.getCommandGroup().name());
Expand Down Expand Up @@ -74,7 +75,7 @@ public void testGetUserDefaultPropertiesValues() {
User u1 = userService.getUserDefProperties("1", "name: ");
assertEquals("name: 1", u1.getName());
assertEquals(1, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
com.netflix.hystrix.HystrixExecutableInfo<?> command = HystrixRequestLog.getCurrentRequest()
HystrixInvokableInfo<?> command = HystrixRequestLog.getCurrentRequest()
.getAllExecutedCommands().iterator().next();
assertEquals("getUserDefProperties", command.getCommandKey().name());
assertEquals("UserService", command.getCommandGroup().name());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.netflix.hystrix.contrib.javanica.test.spring.fallback;

import com.netflix.hystrix.HystrixEventType;
import com.netflix.hystrix.HystrixInvokableInfo;
import com.netflix.hystrix.HystrixRequestLog;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.command.AsyncResult;
Expand Down Expand Up @@ -43,7 +44,7 @@ public void testGetUserAsyncWithFallback() throws ExecutionException, Interrupte

assertEquals("def", f1.get().getName());
assertEquals(1, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
com.netflix.hystrix.HystrixExecutableInfo<?> command = HystrixRequestLog.getCurrentRequest()
HystrixInvokableInfo<?> command = HystrixRequestLog.getCurrentRequest()
.getAllExecutedCommands().iterator().next();
assertEquals("getUserAsync", command.getCommandKey().name());

Expand All @@ -64,7 +65,7 @@ public void testGetUserSyncWithFallback() {

assertEquals("def", u1.getName());
assertEquals(1, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
com.netflix.hystrix.HystrixExecutableInfo<?> command = HystrixRequestLog.getCurrentRequest()
HystrixInvokableInfo<?> command = HystrixRequestLog.getCurrentRequest()
.getAllExecutedCommands().iterator().next();

assertEquals("getUserSync", command.getCommandKey().name());
Expand Down Expand Up @@ -94,7 +95,7 @@ public void testGetUserAsyncWithFallbackCommand() throws ExecutionException, Int
assertEquals("def", f1.get().getName());

assertEquals(3, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
com.netflix.hystrix.HystrixExecutableInfo<?> getUserAsyncFallbackCommand = getHystrixCommandByKey(
HystrixInvokableInfo<?> getUserAsyncFallbackCommand = getHystrixCommandByKey(
"getUserAsyncFallbackCommand");
com.netflix.hystrix.HystrixCommand firstFallbackCommand = getHystrixCommandByKey("firstFallbackCommand");
com.netflix.hystrix.HystrixCommand secondFallbackCommand = getHystrixCommandByKey("secondFallbackCommand");
Expand All @@ -119,7 +120,7 @@ public void testGetUserSyncWithFallbackCommand() {

assertEquals("def", u1.getName());
assertEquals(3, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
com.netflix.hystrix.HystrixExecutableInfo<?> getUserSyncFallbackCommand = getHystrixCommandByKey(
HystrixInvokableInfo<?> getUserSyncFallbackCommand = getHystrixCommandByKey(
"getUserSyncFallbackCommand");
com.netflix.hystrix.HystrixCommand firstFallbackCommand = getHystrixCommandByKey("firstFallbackCommand");
com.netflix.hystrix.HystrixCommand secondFallbackCommand = getHystrixCommandByKey("secondFallbackCommand");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void testGetUserByIdObservable() {
try {

// blocking
assertEquals("name: 1", userService.getUser("1", "name: ").toBlockingObservable().single().getName());
assertEquals("name: 1", userService.getUser("1", "name: ").toBlocking().single().getName());

// non-blocking
// - this is a verbose anonymous inner-class approach and doesn't do assertions
Expand Down Expand Up @@ -88,7 +88,7 @@ public void testGetUserWithFallback() {
final User exUser = new User("def", "def");

// blocking
assertEquals(exUser, userService.getUser(" ", "").toBlockingObservable().single());
assertEquals(exUser, userService.getUser(" ", "").toBlocking().single());
assertEquals(1, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
com.netflix.hystrix.HystrixCommand getUserCommand = getHystrixCommandByKey("getUser");
// confirm that command has failed
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ include 'hystrix-core', \
'hystrix-contrib:hystrix-codahale-metrics-publisher', \
'hystrix-contrib:hystrix-yammer-metrics-publisher', \
'hystrix-contrib:hystrix-network-auditor-agent', \
'hystrix-contrib:hystrix-javanica', \
//'hystrix-contrib:hystrix-javanica', \
'hystrix-dashboard'