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

migrating all hystrix-javanica tests to hystrix-junit #1184

Merged
merged 1 commit into from
Apr 20, 2016
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
1 change: 1 addition & 0 deletions hystrix-contrib/hystrix-javanica/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ dependencies {
compile 'com.google.code.findbugs:jsr305:2.0.0'
compile 'org.ow2.asm:asm:5.0.4'
testCompile 'junit:junit-dep:4.10'
testCompile project(':hystrix-junit')
testCompile 'org.springframework:spring-core:4.0.0.RELEASE'
testCompile 'org.springframework:spring-context:4.0.0.RELEASE'
testCompile 'org.springframework:spring-aop:4.0.0.RELEASE'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,22 @@
*/
package com.netflix.hystrix.contrib.javanica.test.common;

import com.netflix.hystrix.Hystrix;
import com.hystrix.junit.HystrixRequestContextRule;
import com.netflix.hystrix.strategy.concurrency.HystrixRequestContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;

/**
* Created by dmgcodevil
*/
public abstract class BasicHystrixTest {

private HystrixRequestContext context;
@Rule
public HystrixRequestContextRule request = new HystrixRequestContextRule();

protected final HystrixRequestContext getHystrixContext() {
return context;
}

@Before
public void setUp() throws Exception {
context = createContext();
}

@After
public void tearDown() throws Exception {
context.shutdown();
}

private HystrixRequestContext createContext() {
HystrixRequestContext c = HystrixRequestContext.initializeContext();
Hystrix.reset();
return c;
return request.context();
}


protected void resetContext() {
if (context != null) {
context.shutdown();
}
context = createContext();
request.reset();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public abstract class BasicCacheTest extends BasicHystrixTest {

@Before
public void setUp() throws Exception {
super.setUp();
userService = createUserService();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public abstract class BasicCollapserTest extends BasicHystrixTest {

@Before
public void setUp() throws Exception {
super.setUp();
userService = createUserService();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public abstract class BasicCommandTest extends BasicHystrixTest {

@Before
public void setUp() throws Exception {
super.setUp();
userService = createUserService();
advancedUserService = createAdvancedUserServiceService();
genericUserService = createGenericUserService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public abstract class BasicCollapserPropertiesTest extends BasicHystrixTest {

@Before
public void setUp() throws Exception {
super.setUp();
userService = createUserService();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public abstract class BasicCommandPropertiesTest extends BasicHystrixTest {
@Before
public void setUp() throws Exception {
userService = createUserService();
super.setUp();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public abstract class BasicErrorPropagationTest extends BasicHystrixTest {

@Before
public void setUp() throws Exception {
super.setUp();
MockitoAnnotations.initMocks(this);
userService = createUserService();
userService.setFailoverService(failoverService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public abstract class BasicCommandFallbackTest extends BasicHystrixTest {

@Before
public void setUp() throws Exception {
super.setUp();
userService = createUserService();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public abstract class BasicObservableTest extends BasicHystrixTest {

@Before
public void setUp() throws Exception {
super.setUp();
userService = createUserService();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.hystrix.junit;

import com.netflix.hystrix.Hystrix;
import com.netflix.hystrix.strategy.concurrency.HystrixRequestContext;
import org.junit.rules.ExternalResource;

Expand All @@ -35,8 +36,9 @@ public final class HystrixRequestContextRule extends ExternalResource {
private HystrixRequestContext context;

@Override
protected void before() throws Throwable {
protected void before() {
this.context = HystrixRequestContext.initializeContext();
Hystrix.reset();
}

@Override
Expand All @@ -50,4 +52,9 @@ protected void after() {
public HystrixRequestContext context() {
return this.context;
}

public void reset() {
after();
before();
}
}