Created
February 14, 2017 12:11
-
-
Save reikje/898d3050cd960b2e7d47be3e02d187cd to your computer and use it in GitHub Desktop.
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
package com.github.reikje | |
import java.net.{InetAddress, InetSocketAddress} | |
import com.twitter.finagle.{Address, Name, ThriftMux, param} | |
import com.twitter.util.{Await, Future} | |
import org.scalatest.{Matchers, WordSpec} | |
class RoundtripSpec extends WordSpec with Matchers { | |
"Microservice" should { | |
"respond to requests" in { | |
val service = new MicroServiceImpl("foo") | |
val server = ThriftMux.server | |
.configured(param.Label("zuul-thrift")) | |
.serveIface(new InetSocketAddress(InetAddress.getLoopbackAddress, 0), service) | |
val client = ThriftMux.client.newIface[MicroService.FutureIface]( | |
Name.bound(Address(server.boundAddress.asInstanceOf[InetSocketAddress])), "microservice-client" | |
) | |
val response = Await.result(client.request()) | |
response shouldBe "foo" | |
} | |
} | |
} | |
class MicroServiceImpl(response: String) extends MicroService.FutureIface { | |
override def request(): Future[String] = Future.value(response) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment