Skip to content

Instantly share code, notes, and snippets.

View lordofthejars's full-sized avatar
🏠
Working from home

Alex Soto lordofthejars

🏠
Working from home
View GitHub Profile
Observable<String> obs = new HelloWorldCommand().observe();
obs.subscribe((v) -> {
System.out.println("onNext: " + v);
}
public class HelloWorldCommand extends HystrixCommand<String> {
public HelloWorldCommand() {
super(HystrixCommandGroupKey.Factory.asKey("HelloWorld"));
}
@Override
protected String getFallback() {
return "Good Bye";
}
public class HelloWorldCommand extends HystrixCommand<String> {
public HelloWorldCommand() {
super(HystrixCommandGroupKey.Factory.asKey("HelloWorld"));
}
@Override
protected String getFallback() {
return "Good Bye";
}
@Test
public void should_execute_fallback_method_when_circuit_is_open() {
//Initialize HystrixRequestContext to be able to get some metrics
HystrixRequestContext context = HystrixRequestContext.initializeContext();
HystrixCommandMetrics creditCardMetrics = HystrixCommandMetrics.getInstance(HystrixCommandKey.Factory.asKey(HelloWorldRestCommand.class.getSimpleName()));
//We use Archaius to set the circuit as closed.
ConfigurationManager.getConfigInstance().setProperty("hystrix.command.default.circuitBreaker.forceOpen", false);
//Instead of
archive.merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class)
.importDirectory(WEBAPP_SRC).as(GenericArchive.class),
"/", Filters.include(".*\\.js$"))
archive.merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class)
.importDirectory(WEBAPP_SRC).as(GenericArchive.class),
"/", Filters.include(".*\\.css$"))
archive.merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class)
.importDirectory(WEBAPP_SRC).as(GenericArchive.class),
"/", Filters.include(".*\\.xhtml"))
List<WebElement> elements = session.findElements(xpath("//table/tbody/tr/td/span[@class='title']"));
return elements.stream().map(WebElement::getText).collect(Collectors.toList());
@Controller
@EnableAutoConfiguration
public class SampleController {
@RequestMapping("/")
@ResponseBody
String home() {
return "Hello World!";
}
<dependencies>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>tomee-embedded</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
import javax.ejb.Stateless;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
@Stateless
@Path("/sample")
public class SampleController {
@GET
public class TomEEApplication {
private static void startAndDeploy(Archive<?> archive) {
Container container;
try {
Configuration configuration = new Configuration();
String tomeeDir = Files.createTempDirectory("apache-tomee").toFile().getAbsolutePath();
configuration.setDir(tomeeDir);