This file contains hidden or 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
@RunWith(Arquillian.class) | |
public class BookTest { | |
@Deployment(testable = false, name = "bookservice") | |
public static WebArchive createDeploymentBookInfoService() { | |
return ShrinkWrap.create(WebArchive.class, "bookservice.war").addClasses(BookInfoService.class, ApplicationResource.class); | |
} | |
@Deployment(testable = false, name = "bookcomments") | |
public static WebArchive createDeploymentCommentsService() { |
This file contains hidden or 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
@GET | |
@Path("{isbn}") | |
@Produces(MediaType.APPLICATION_JSON) | |
public void bookAndComment(@Suspended final AsyncResponse asyncResponse, @PathParam("isbn") String isbn) { | |
//Calling previous defined functions | |
Observable<JsonObject> bookInfo = getBookInfo(isbn); | |
Observable<JsonArray> comments = getComments(isbn); | |
Observable.zip(bookInfo, comments, (JsonObject book, JsonArray bookcomments) -> | |
Json.createObjectBuilder().add("book", book).add("comments", bookcomments).build() |
This file contains hidden or 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
public Observable<JsonArray> getComments(final String isbn) { | |
return Observable.create((Observable.OnSubscribe<JsonArray>) subscriber -> { | |
Runnable r = () -> { | |
subscriber.onNext(commentServiceTarget.path(isbn).request().get(JsonArray.class)); | |
subscriber.onCompleted(); | |
}; | |
executor.execute(r); |
This file contains hidden or 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
public Observable<JsonObject> getBookInfo(final String isbn) { | |
return Observable.create((Observable.OnSubscribe<JsonObject>) subscriber -> { | |
Runnable r = () -> { | |
subscriber.onNext(bookServiceTarget.path(isbn).request().get(JsonObject.class)); | |
subscriber.onCompleted(); | |
}; | |
executor.execute(r); |
This file contains hidden or 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
@Singleton | |
@Path("book") | |
public class BookService { | |
private static final String BOOKSERVICE = "http://localhost:8080/bookservice"; | |
private static final String COMMENTSERVICE = "http://localhost:8080/bookcomments"; | |
@Resource(name = "DefaultManagedExecutorService") | |
ManagedExecutorService executor; |
This file contains hidden or 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
@ApplicationPath("rest") | |
public class ApplicationResource extends Application { | |
} |
This file contains hidden or 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
@Singleton | |
@Path("comments") | |
public class CommentsService { | |
@GET | |
@Path("{isbn}") | |
@Produces(MediaType.APPLICATION_JSON) | |
public JsonArray bookComments(@PathParam("isbn") String isbn) { | |
return Json.createArrayBuilder().add("Good Book").add("Awesome").build(); |
This file contains hidden or 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
@Singleton | |
@Path("bookinfo") | |
public class BookInfoService { | |
@GET | |
@Path("{isbn}") | |
@Produces(MediaType.APPLICATION_JSON) | |
@Consumes(MediaType.APPLICATION_JSON) | |
public JsonObject findBookByISBN(@PathParam("isbn") String isbn) { |
This file contains hidden or 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
<repository> | |
<id>jboss-public-repository-group</id> | |
<name>JBoss Public Maven Repository Group</name> | |
<url>https://repository.jboss.org/nexus/content/groups/public</url> | |
</repository> | |
<dependency> | |
<groupId>org.jboss.arquillian.container</groupId> | |
<artifactId>undertow-embedded</artifactId> | |
<version>1.0.0.Alpha1</version> |
This file contains hidden or 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
<container qualifier="undertow" default="true"> | |
<configuration> | |
<property name="bindAddress">localhost</property> | |
<property name="bindHttpPort">9090</property> <1> | |
</configuration> | |
</container> |
NewerOlder