Search in sources :

Example 1 with AsyncResultVoid

use of net.servicestack.client.AsyncResultVoid in project ServiceStack.Java by ServiceStack.

the class TestServiceTestsAsync method test_Can_send_ReturnVoid_Async.

public void test_Can_send_ReturnVoid_Async() {
    final CountDownLatch signal = new CountDownLatch(1);
    final List<String> sentMethods = new ArrayList<>();
    client.RequestFilter = new ConnectionFilter() {

        @Override
        public void exec(HttpURLConnection conn) {
            sentMethods.add(conn.getRequestMethod());
        }
    };
    client.sendAsync(new HelloReturnVoid().setId(1), new AsyncResultVoid() {

        @Override
        public void success() {
            assertEquals(HttpMethods.Post, sentMethods.get(sentMethods.size() - 1));
            signal.countDown();
        }
    });
}
Also used : ConnectionFilter(net.servicestack.client.ConnectionFilter) HttpURLConnection(java.net.HttpURLConnection) AsyncResultVoid(net.servicestack.client.AsyncResultVoid) ArrayList(java.util.ArrayList) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 2 with AsyncResultVoid

use of net.servicestack.client.AsyncResultVoid in project ServiceStack.Java by ServiceStack.

the class TestServiceTestsAsync method test_Can_delete_ReturnVoid_Async.

public void test_Can_delete_ReturnVoid_Async() {
    final CountDownLatch signal = new CountDownLatch(1);
    final List<String> sentMethods = new ArrayList<>();
    client.RequestFilter = new ConnectionFilter() {

        @Override
        public void exec(HttpURLConnection conn) {
            sentMethods.add(conn.getRequestMethod());
        }
    };
    client.deleteAsync(new HelloReturnVoid().setId(1), new AsyncResultVoid() {

        @Override
        public void success() {
            assertEquals(HttpMethods.Delete, sentMethods.get(sentMethods.size() - 1));
            signal.countDown();
        }
    });
}
Also used : ConnectionFilter(net.servicestack.client.ConnectionFilter) HttpURLConnection(java.net.HttpURLConnection) AsyncResultVoid(net.servicestack.client.AsyncResultVoid) ArrayList(java.util.ArrayList) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

HttpURLConnection (java.net.HttpURLConnection)2 ArrayList (java.util.ArrayList)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 AsyncResultVoid (net.servicestack.client.AsyncResultVoid)2 ConnectionFilter (net.servicestack.client.ConnectionFilter)2