[JAVA-13854] Half list moved (#12598)
* [JAVA-13854] added parent module * [JAVA-13854] moved apache-tapestry(submodule) to web-modules(parent) * [JAVA-13854] moved bootique(submodule) to web-modules(parent) * [JAVA-13854] moved dropwizard(submodule) to web-modules(parent) * [JAVA-13854] moved blade(submodule) to web-modules(parent) * [JAVA-13854] moved java-lite(submodule) to web-modules(parent) * [JAVA-13854] moved jooby(submodule) to web-modules(parent) * [JAVA-13854] moved linkrest(submodule) to web-modules(parent) * [JAVA-13854] moved ninja(submodule) to web-modules(parent) * [JAVA-13854] moved ratpack(submodule) to web-modules(parent) * [JAVA-13854] moved resteasy(submodule) to web-modules(parent) * [JAVA-13854] moved restx(submodule) to web-modules(parent) * [JAVA-13854] moved spark-java(submodule) to web-modules(parent) * [JAVA-13854] moved vraptor(submodule) to web-modules(parent) * [JAVA-13854] delete modules that were moved * [JAVA-13854] * [JAVA-13854] * [JAVA-13854] delete ninja submodule + moved raml(submodule) to web-modules(parent) * [JAVA-13854] moved gwt(submodule) to web-modules(parent) * [JAVA-13854] moved jakarta-ee(submodule) to web-modules(parent) * [JAVA-13854] moved javax-servlets(submodule) to web-modules(parent) * [JAVA-13854] moved javax-servlets-2(submodule) to web-modules(parent) * [JAVA-13854] moved jee-7(submodule) to web-modules(parent) * [JAVA-13854] moved play-framework(not a module) to web-modules * [JAVA-13854] fix failing test * [JAVA-13854] moved struts-2(submodule) to web-modules(parent) * [JAVA-13854] moved wicket(submodule) to web-modules(parent) * [JAVA-13854] deleted modules that were moved to web-modules * JAVA-13854 Removed moved modules from the main pom.xml Co-authored-by: panagiotiskakos <panagiotis.kakos@libra-is.com> Co-authored-by: Dhawal Kapil <dhawalkapil@gmail.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package com.baeldung;
|
||||
|
||||
import ratpack.groovy.Groovy
|
||||
import ratpack.groovy.test.GroovyRatpackMainApplicationUnderTest;
|
||||
import ratpack.test.http.TestHttpClient;
|
||||
import ratpack.test.ServerBackedApplicationUnderTest;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.JUnit4
|
||||
import ratpack.test.MainClassApplicationUnderTest
|
||||
|
||||
class RatpackGroovySpec {
|
||||
|
||||
ServerBackedApplicationUnderTest ratpackGroovyApp = new MainClassApplicationUnderTest(RatpackGroovyApp.class)
|
||||
@Delegate TestHttpClient client = TestHttpClient.testHttpClient(ratpackGroovyApp)
|
||||
|
||||
@Test
|
||||
void "test if app is started"() {
|
||||
when:
|
||||
get("")
|
||||
|
||||
then:
|
||||
assert response.statusCode == 200
|
||||
assert response.body.text == "Hello World from Ratpack with Groovy!!"
|
||||
}
|
||||
|
||||
@Test
|
||||
void "test greet with name"() {
|
||||
when:
|
||||
get("greet/Lewis")
|
||||
|
||||
then:
|
||||
assert response.statusCode == 200
|
||||
assert response.body.text == "Hello Lewis!!!"
|
||||
}
|
||||
|
||||
@Test
|
||||
void "test fetchUsers"() {
|
||||
when:
|
||||
get("fetchUsers")
|
||||
|
||||
then:
|
||||
assert response.statusCode == 200
|
||||
assert response.body.text == '[{"ID":1,"TITLE":"Mr","NAME":"Norman Potter","COUNTRY":"USA"},{"ID":2,"TITLE":"Miss","NAME":"Ketty Smith","COUNTRY":"FRANCE"}]'
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.baeldung;
|
||||
|
||||
import com.baeldung.model.Employee;
|
||||
import org.junit.Test;
|
||||
import ratpack.exec.Promise;
|
||||
import ratpack.func.Action;
|
||||
import ratpack.handling.Chain;
|
||||
import ratpack.handling.Handler;
|
||||
import ratpack.registry.Registry;
|
||||
import ratpack.test.embed.EmbeddedApp;
|
||||
import ratpack.test.exec.ExecHarness;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class AppHttpUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenAnyUri_GetEmployeeFromSameRegistry() throws Exception {
|
||||
Handler allHandler = ctx -> {
|
||||
Long id = Long.valueOf(ctx.getPathTokens()
|
||||
.get("id"));
|
||||
Employee employee = new Employee(id, "Mr", "NY");
|
||||
ctx.next(Registry.single(Employee.class, employee));
|
||||
};
|
||||
Handler empNameHandler = ctx -> {
|
||||
Employee employee = ctx.get(Employee.class);
|
||||
ctx.getResponse()
|
||||
.send("Name of employee with ID " + employee.getId() + " is " + employee.getName());
|
||||
};
|
||||
Handler empTitleHandler = ctx -> {
|
||||
Employee employee = ctx.get(Employee.class);
|
||||
ctx.getResponse()
|
||||
.send("Title of employee with ID " + employee.getId() + " is " + employee.getTitle());
|
||||
};
|
||||
|
||||
Action<Chain> chainAction = chain -> chain.prefix("employee/:id", empChain -> {
|
||||
empChain.all(allHandler)
|
||||
.get("name", empNameHandler)
|
||||
.get("title", empTitleHandler);
|
||||
});
|
||||
EmbeddedApp.fromHandlers(chainAction)
|
||||
.test(testHttpClient -> {
|
||||
assertEquals("Name of employee with ID 1 is NY", testHttpClient.get("employee/1/name")
|
||||
.getBody()
|
||||
.getText());
|
||||
assertEquals("Title of employee with ID 1 is Mr", testHttpClient.get("employee/1/title")
|
||||
.getBody()
|
||||
.getText());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenSyncDataSource_GetDataFromPromise() throws Exception {
|
||||
String value = ExecHarness.yieldSingle(execution -> Promise.sync(() -> "Foo"))
|
||||
.getValueOrThrow();
|
||||
assertEquals("Foo", value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.baeldung;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import com.baeldung.model.Employee;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import ratpack.test.MainClassApplicationUnderTest;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
public class ApplicationIntegrationTest {
|
||||
|
||||
MainClassApplicationUnderTest appUnderTest = new MainClassApplicationUnderTest(Application.class);
|
||||
|
||||
@Test
|
||||
public void givenDefaultUrl_getStaticText() {
|
||||
assertEquals("Welcome to baeldung ratpack!!!", appUnderTest.getHttpClient().getText("/"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDynamicUrl_getDynamicText() {
|
||||
assertEquals("Hello dummybot!!!", appUnderTest.getHttpClient().getText("/dummybot"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenUrl_getListOfEmployee() throws JsonProcessingException {
|
||||
List<Employee> employees = new ArrayList<Employee>();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
employees.add(new Employee(1L, "Mr", "John Doe"));
|
||||
employees.add(new Employee(2L, "Mr", "White Snow"));
|
||||
|
||||
assertEquals(mapper.writeValueAsString(employees), appUnderTest.getHttpClient().getText("/data/employees"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenStaticUrl_getDynamicText() {
|
||||
assertEquals(21, appUnderTest.getHttpClient().getText("/randomString").length());
|
||||
}
|
||||
|
||||
@After
|
||||
public void shutdown() {
|
||||
appUnderTest.close();
|
||||
}
|
||||
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package com.baeldung.hystrix;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import ratpack.test.MainClassApplicationUnderTest;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* @author aiet
|
||||
*/
|
||||
public class RatpackHystrixAppFallbackLiveTest {
|
||||
|
||||
static MainClassApplicationUnderTest appUnderTest;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
System.setProperty("ratpack.hystrix.timeout", "10");
|
||||
appUnderTest = new MainClassApplicationUnderTest(RatpackHystrixApp.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenFetchReactive_thenGotFallbackProfile() {
|
||||
assertThat(appUnderTest
|
||||
.getHttpClient()
|
||||
.getText("rx"), containsString("reactive fallback profile"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenFetchAsync_thenGotFallbackProfile() {
|
||||
assertThat(appUnderTest
|
||||
.getHttpClient()
|
||||
.getText("async"), containsString("async fallback profile"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenFetchSync_thenGotFallbackProfile() {
|
||||
assertThat(appUnderTest
|
||||
.getHttpClient()
|
||||
.getText("sync"), containsString("sync fallback profile"));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void clean() {
|
||||
appUnderTest.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.baeldung.hystrix;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import ratpack.test.MainClassApplicationUnderTest;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* @author aiet
|
||||
*/
|
||||
public class RatpackHystrixAppLiveTest {
|
||||
|
||||
static MainClassApplicationUnderTest appUnderTest;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
System.setProperty("ratpack.hystrix.timeout", "5000");
|
||||
appUnderTest = new MainClassApplicationUnderTest(RatpackHystrixApp.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenFetchReactive_thenGotEugenProfile() {
|
||||
assertThat(appUnderTest
|
||||
.getHttpClient()
|
||||
.getText("rx"), containsString("www.baeldung.com"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenFetchAsync_thenGotEugenProfile() {
|
||||
assertThat(appUnderTest
|
||||
.getHttpClient()
|
||||
.getText("async"), containsString("www.baeldung.com"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenFetchSync_thenGotEugenProfile() {
|
||||
assertThat(appUnderTest
|
||||
.getHttpClient()
|
||||
.getText("sync"), containsString("www.baeldung.com"));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void clean() {
|
||||
appUnderTest.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.baeldung.ratpack;
|
||||
|
||||
import org.reactivestreams.Publisher;
|
||||
import org.reactivestreams.Subscriber;
|
||||
import org.reactivestreams.Subscription;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
// Non-thread safe !!!
|
||||
class CompliantPublisher implements Publisher<Integer> {
|
||||
String name;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(CompliantPublisher.class);
|
||||
private long available;
|
||||
|
||||
|
||||
public CompliantPublisher(long available) {
|
||||
this.available = available;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribe(Subscriber<? super Integer> subscriber) {
|
||||
log.info("subscribe");
|
||||
subscriber.onSubscribe(new CompliantSubscription(subscriber));
|
||||
|
||||
}
|
||||
|
||||
|
||||
private class CompliantSubscription implements Subscription {
|
||||
|
||||
private Subscriber<? super Integer> subscriber;
|
||||
private int recurseLevel;
|
||||
private long requested;
|
||||
private boolean cancelled;
|
||||
|
||||
public CompliantSubscription(Subscriber<? super Integer> subscriber) {
|
||||
this.subscriber = subscriber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void request(long n) {
|
||||
log.info("request: requested={}, available={}", n, available);
|
||||
requested += n;
|
||||
if ( recurseLevel > 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
recurseLevel++;
|
||||
for (int i = 0 ; i < (requested) && !cancelled && available > 0 ; i++, available-- ) {
|
||||
subscriber.onNext(i);
|
||||
}
|
||||
subscriber.onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
cancelled = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.baeldung.ratpack;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.reactivestreams.Subscriber;
|
||||
import org.reactivestreams.Subscription;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class LoggingSubscriber<T> implements Subscriber<T> {
|
||||
private static final Logger log = LoggerFactory.getLogger(LoggingSubscriber.class);
|
||||
|
||||
private Subscription subscription;
|
||||
private long requested;
|
||||
private long received;
|
||||
private CountDownLatch finished = new CountDownLatch(1);
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
log.info("onComplete: sub={}", subscription.hashCode());
|
||||
finished.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable t) {
|
||||
log.error("Error: sub={}, message={}", subscription.hashCode(), t.getMessage(),t);
|
||||
finished.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(T value) {
|
||||
log.info("onNext: sub={}, value={}", subscription.hashCode(), value);
|
||||
this.received++;
|
||||
this.requested++;
|
||||
subscription.request(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Subscription sub) {
|
||||
log.info("onSubscribe: sub={}", sub.hashCode());
|
||||
this.subscription = sub;
|
||||
this.received = 0;
|
||||
this.requested = 1;
|
||||
sub.request(1);
|
||||
}
|
||||
|
||||
|
||||
public long getRequested() {
|
||||
return requested;
|
||||
}
|
||||
|
||||
public long getReceived() {
|
||||
return received;
|
||||
}
|
||||
|
||||
public void block() {
|
||||
try {
|
||||
finished.await(10, TimeUnit.SECONDS);
|
||||
}
|
||||
catch(InterruptedException iex) {
|
||||
throw new RuntimeException(iex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.baeldung.ratpack;
|
||||
|
||||
import org.reactivestreams.Publisher;
|
||||
import org.reactivestreams.Subscriber;
|
||||
import org.reactivestreams.Subscription;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class NonCompliantPublisher implements Publisher<Integer> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(NonCompliantPublisher.class);
|
||||
|
||||
@Override
|
||||
public void subscribe(Subscriber<? super Integer> subscriber) {
|
||||
log.info("subscribe");
|
||||
subscriber.onSubscribe(new NonCompliantSubscription(subscriber));
|
||||
}
|
||||
|
||||
private class NonCompliantSubscription implements Subscription {
|
||||
private Subscriber<? super Integer> subscriber;
|
||||
private int recurseLevel = 0;
|
||||
|
||||
public NonCompliantSubscription(Subscriber<? super Integer> subscriber) {
|
||||
this.subscriber = subscriber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void request(long n) {
|
||||
log.info("request: n={}", n);
|
||||
if ( recurseLevel > 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
recurseLevel++;
|
||||
for (int i = 0 ; i < (n + 5) ; i ++ ) {
|
||||
subscriber.onNext(i);
|
||||
}
|
||||
subscriber.onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.baeldung.ratpack;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.reactivestreams.Publisher;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ratpack.exec.ExecResult;
|
||||
import ratpack.func.Action;
|
||||
import ratpack.stream.StreamEvent;
|
||||
import ratpack.stream.Streams;
|
||||
import ratpack.stream.TransformablePublisher;
|
||||
import ratpack.test.exec.ExecHarness;
|
||||
|
||||
public class RatpackStreamsUnitTest {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(RatpackStreamsUnitTest.class);
|
||||
|
||||
@Test
|
||||
public void whenPublish_thenSuccess() {
|
||||
|
||||
Publisher<String> pub = Streams.publish(Arrays.asList("hello", "hello again"));
|
||||
LoggingSubscriber<String> sub = new LoggingSubscriber<String>();
|
||||
pub.subscribe(sub);
|
||||
sub.block();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void whenYield_thenSuccess() {
|
||||
|
||||
Publisher<String> pub = Streams.yield((t) -> {
|
||||
return t.getRequestNum() < 5 ? "hello" : null;
|
||||
});
|
||||
|
||||
LoggingSubscriber<String> sub = new LoggingSubscriber<String>();
|
||||
pub.subscribe(sub);
|
||||
sub.block();
|
||||
assertEquals(5, sub.getReceived());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenPeriodic_thenSuccess() {
|
||||
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
|
||||
Publisher<String> pub = Streams.periodically(executor, Duration.ofSeconds(1), (t) -> {
|
||||
return t < 5 ? String.format("hello %d",t): null;
|
||||
});
|
||||
|
||||
LoggingSubscriber<String> sub = new LoggingSubscriber<String>();
|
||||
pub.subscribe(sub);
|
||||
sub.block();
|
||||
assertEquals(5, sub.getReceived());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenMap_thenSuccess() throws Exception {
|
||||
|
||||
TransformablePublisher<String> pub = Streams.yield( t -> {
|
||||
return t.getRequestNum() < 5 ? t.getRequestNum() : null;
|
||||
})
|
||||
.map(v -> String.format("item %d", v));
|
||||
|
||||
ExecResult<List<String>> result = ExecHarness.yieldSingle((c) -> pub.toList() );
|
||||
assertTrue("should succeed", result.isSuccess());
|
||||
assertEquals("should have 5 items",5,result.getValue().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenNonCompliantPublisherWithBuffer_thenSuccess() throws Exception {
|
||||
|
||||
TransformablePublisher<Integer> pub = Streams.transformable(new NonCompliantPublisher())
|
||||
.wiretap(new LoggingAction("before buffer"))
|
||||
.buffer()
|
||||
.wiretap(new LoggingAction("after buffer"))
|
||||
.take(1);
|
||||
|
||||
LoggingSubscriber<Integer> sub = new LoggingSubscriber<>();
|
||||
pub.subscribe(sub);
|
||||
sub.block();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenNonCompliantPublisherWithoutBuffer_thenSuccess() throws Exception {
|
||||
TransformablePublisher<Integer> pub = Streams.transformable(new NonCompliantPublisher())
|
||||
.wiretap(new LoggingAction(""))
|
||||
.take(1);
|
||||
|
||||
LoggingSubscriber<Integer> sub = new LoggingSubscriber<>();
|
||||
pub.subscribe(sub);
|
||||
sub.block();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCompliantPublisherWithoutBatch_thenSuccess() throws Exception {
|
||||
|
||||
TransformablePublisher<Integer> pub = Streams.transformable(new CompliantPublisher(10))
|
||||
.wiretap(new LoggingAction(""));
|
||||
|
||||
LoggingSubscriber<Integer> sub = new LoggingSubscriber<>();
|
||||
pub.subscribe(sub);
|
||||
sub.block();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCompliantPublisherWithBatch_thenSuccess() throws Exception {
|
||||
|
||||
TransformablePublisher<Integer> pub = Streams.transformable(new CompliantPublisher(10))
|
||||
.wiretap(new LoggingAction("before batch"))
|
||||
.batch(5, Action.noop())
|
||||
.wiretap(new LoggingAction("after batch"));
|
||||
|
||||
LoggingSubscriber<Integer> sub = new LoggingSubscriber<>();
|
||||
pub.subscribe(sub);
|
||||
sub.block();
|
||||
}
|
||||
|
||||
private static class LoggingAction implements Action<StreamEvent<Integer>>{
|
||||
private final String label;
|
||||
|
||||
public LoggingAction(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(StreamEvent<Integer> e) throws Exception {
|
||||
log.info("{}: event={}", label,e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package com.baeldung.spring;
|
||||
|
||||
import org.junit.Test;
|
||||
import ratpack.test.MainClassApplicationUnderTest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* @author aiet
|
||||
*/
|
||||
public class EmbedRatpackAppIntegrationTest {
|
||||
|
||||
MainClassApplicationUnderTest appUnderTest = new MainClassApplicationUnderTest(EmbedRatpackApp.class);
|
||||
|
||||
@Test
|
||||
public void whenSayHello_thenGotWelcomeMessage() {
|
||||
assertEquals("hello baeldung!", appUnderTest
|
||||
.getHttpClient()
|
||||
.getText("/hello"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenRequestList_thenGotArticles() throws IOException {
|
||||
assertEquals(3, appUnderTest
|
||||
.getHttpClient()
|
||||
.getText("/list")
|
||||
.split(",").length);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenRequestStaticResource_thenGotStaticContent() {
|
||||
assertThat(appUnderTest
|
||||
.getHttpClient()
|
||||
.getText("/"), containsString("page is static"));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user