BAEL-3863 moved Finagle package to libraries-rpc, added test
This commit is contained in:
parent
33edef47e1
commit
ff684f13b6
|
@ -2,8 +2,8 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>Finagle</artifactId>
|
||||
<name>Finagle</name>
|
||||
<artifactId>libraries-rpc</artifactId>
|
||||
<name>libraries-rpc</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.finagle;
|
||||
package com.baeldung.rpc.finagle;
|
||||
|
||||
import com.twitter.finagle.Http;
|
||||
import com.twitter.finagle.Service;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.finagle;
|
||||
package com.baeldung.rpc.finagle;
|
||||
|
||||
import com.twitter.finagle.Service;
|
||||
import com.twitter.finagle.http.Request;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.finagle;
|
||||
package com.baeldung.rpc.finagle;
|
||||
|
||||
import com.twitter.finagle.Service;
|
||||
import com.twitter.finagle.SimpleFilter;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.finagle;
|
||||
package com.baeldung.rpc.finagle;
|
||||
|
||||
import com.twitter.finagle.Http;
|
||||
import com.twitter.finagle.ListeningServer;
|
|
@ -0,0 +1,40 @@
|
|||
package com.baeldung.rpc.finagle;
|
||||
|
||||
import com.twitter.finagle.Http;
|
||||
import com.twitter.finagle.Service;
|
||||
import com.twitter.finagle.http.Method;
|
||||
import com.twitter.finagle.http.Request;
|
||||
import com.twitter.finagle.http.Response;
|
||||
import com.twitter.util.Await;
|
||||
import com.twitter.util.Future;
|
||||
import org.junit.Test;
|
||||
import scala.runtime.BoxedUnit;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ClientServerTest {
|
||||
@Test
|
||||
public void clientShouldReceiveResponseFromServer() throws Exception {
|
||||
// given
|
||||
Service serverService = new LogFilter().andThen(new GreetingService());
|
||||
Http.serve(":8080", serverService);
|
||||
|
||||
Service<Request, Response> clientService = new LogFilter().andThen(Http.newService(":8080"));
|
||||
|
||||
// when
|
||||
Request request = Request.apply(Method.Get(), "/?name=John");
|
||||
request.host("localhost");
|
||||
Future<Response> response = clientService.apply(request);
|
||||
|
||||
// then
|
||||
Await.result(response
|
||||
.onSuccess(r -> {
|
||||
assertEquals("Hello John", r.getContentString());
|
||||
return BoxedUnit.UNIT;
|
||||
})
|
||||
.onFailure(r -> {
|
||||
throw new RuntimeException(r);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
2
pom.xml
2
pom.xml
|
@ -418,7 +418,6 @@
|
|||
<module>ethereum</module>
|
||||
|
||||
<module>feign</module>
|
||||
<module>finagle</module>
|
||||
<module>flyway-cdi-extension</module>
|
||||
|
||||
<module>geotools</module>
|
||||
|
@ -509,6 +508,7 @@
|
|||
<module>libraries-http-2</module>
|
||||
<module>libraries-io</module>
|
||||
<module>libraries-primitive</module>
|
||||
<module>libraries-rpc</module>
|
||||
<module>libraries-security</module>
|
||||
<module>libraries-server</module>
|
||||
<module>libraries-testing</module>
|
||||
|
|
Loading…
Reference in New Issue