Add simplest hello world examples
This commit is contained in:
parent
8881fdcaf4
commit
5a172a792a
|
@ -0,0 +1,19 @@
|
||||||
|
package com.baeldung.hystrix;
|
||||||
|
|
||||||
|
import com.netflix.hystrix.HystrixCommand;
|
||||||
|
import com.netflix.hystrix.HystrixCommandGroupKey;
|
||||||
|
|
||||||
|
class CommandHelloWorld extends HystrixCommand<String> {
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
CommandHelloWorld(String name) {
|
||||||
|
super(HystrixCommandGroupKey.Factory.asKey("ExampleGroup"));
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String run() {
|
||||||
|
return "Hello " + name + "!";
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package com.baeldung.hystrix;
|
package com.baeldung.hystrix;
|
||||||
|
|
||||||
import com.netflix.hystrix.*;
|
import com.netflix.hystrix.*;
|
||||||
|
import com.netflix.hystrix.collapser.RequestCollapserFactory;
|
||||||
import com.netflix.hystrix.exception.HystrixRuntimeException;
|
import com.netflix.hystrix.exception.HystrixRuntimeException;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -23,8 +24,13 @@ public class HystrixTimeoutTest {
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
config = HystrixCommand
|
config = HystrixCommand
|
||||||
.Setter
|
.Setter
|
||||||
.withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroup1"));
|
.withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroup1"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenInputBob_andDefaultSettings_thenReturnHelloBob(){
|
||||||
|
assertThat(new CommandHelloWorld("Bob").execute(), equalTo("Hello Bob!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -36,7 +42,6 @@ public class HystrixTimeoutTest {
|
||||||
public void givenTimeoutEqualTo10000_andDefaultSettings_thenExpectHystrixRuntimeException() throws InterruptedException {
|
public void givenTimeoutEqualTo10000_andDefaultSettings_thenExpectHystrixRuntimeException() throws InterruptedException {
|
||||||
exception.expect(HystrixRuntimeException.class);
|
exception.expect(HystrixRuntimeException.class);
|
||||||
new RemoteServiceTestCommand(config, new RemoteServiceTestSimulator(10_000)).execute();
|
new RemoteServiceTestCommand(config, new RemoteServiceTestSimulator(10_000)).execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -54,5 +59,4 @@ public class HystrixTimeoutTest {
|
||||||
new RemoteServiceTestCommand(config, new RemoteServiceTestSimulator(15_000)).execute();
|
new RemoteServiceTestCommand(config, new RemoteServiceTestSimulator(15_000)).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue