Search in sources :

Example 21 with Observer

use of com.linkedin.r2.message.stream.entitystream.Observer in project rest.li by linkedin.

the class TestRestLiServer method testUnstructuredDataGetWithBody.

@Test
public void testUnstructuredDataGetWithBody() throws Exception {
    EntityStream streams = EntityStreams.newEntityStream(new ByteStringWriter(ByteString.copy(new byte[] { 1, 2, 3, 4 })));
    Observer observer = new TestObserver();
    streams.addObserver(observer);
    final StreamRequest streamRequest = new StreamRequestBuilder(new URI("/reactiveGreetingCollectionUnstructuredData/hello")).setHeader(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION, AllProtocolVersions.BASELINE_PROTOCOL_VERSION.toString()).build(streams);
    final Callback<StreamResponse> callback = new Callback<StreamResponse>() {

        @Override
        public void onSuccess(StreamResponse streamResponse) {
        }

        @Override
        public void onError(Throwable e) {
        }
    };
    _server.handleRequest(streamRequest, new RequestContext(), callback);
    assertTrue(((TestObserver) observer).isDone());
}
Also used : EntityStream(com.linkedin.r2.message.stream.entitystream.EntityStream) SinglePartMIMEFullReaderCallback(com.linkedin.multipart.utils.MIMETestUtils.SinglePartMIMEFullReaderCallback) Callback(com.linkedin.common.callback.Callback) MultiPartMIMEFullReaderCallback(com.linkedin.multipart.utils.MIMETestUtils.MultiPartMIMEFullReaderCallback) Observer(com.linkedin.r2.message.stream.entitystream.Observer) StreamResponse(com.linkedin.r2.message.stream.StreamResponse) FilterRequestContext(com.linkedin.restli.server.filter.FilterRequestContext) RequestContext(com.linkedin.r2.message.RequestContext) ByteStringWriter(com.linkedin.r2.message.stream.entitystream.ByteStringWriter) StreamRequestBuilder(com.linkedin.r2.message.stream.StreamRequestBuilder) URI(java.net.URI) StreamRequest(com.linkedin.r2.message.stream.StreamRequest) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

EntityStream (com.linkedin.r2.message.stream.entitystream.EntityStream)15 Test (org.testng.annotations.Test)10 CountDownLatch (java.util.concurrent.CountDownLatch)9 ByteString (com.linkedin.data.ByteString)8 Observer (com.linkedin.r2.message.stream.entitystream.Observer)7 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)6 ExecutorService (java.util.concurrent.ExecutorService)4 ReadHandle (com.linkedin.r2.message.stream.entitystream.ReadHandle)3 StreamRequest (com.linkedin.r2.message.stream.StreamRequest)2 StreamResponse (com.linkedin.r2.message.stream.StreamResponse)2 WriteHandle (com.linkedin.r2.message.stream.entitystream.WriteHandle)2 Callback (com.linkedin.common.callback.Callback)1 MultiPartMIMEFullReaderCallback (com.linkedin.multipart.utils.MIMETestUtils.MultiPartMIMEFullReaderCallback)1 SinglePartMIMEFullReaderCallback (com.linkedin.multipart.utils.MIMETestUtils.SinglePartMIMEFullReaderCallback)1 RequestContext (com.linkedin.r2.message.RequestContext)1 StreamRequestBuilder (com.linkedin.r2.message.stream.StreamRequestBuilder)1 BaseConnector (com.linkedin.r2.message.stream.entitystream.BaseConnector)1 ByteStringWriter (com.linkedin.r2.message.stream.entitystream.ByteStringWriter)1 FullEntityObserver (com.linkedin.r2.message.stream.entitystream.FullEntityObserver)1 MessageType (com.linkedin.r2.transport.common.MessageType)1