Search in sources :

Example 1 with NoLogging

use of net.morimekta.providence.tools.rpc.internal.NoLogging in project providence by morimekta.

the class RPCProvidenceHttpTest method setUp.

@Before
public void setUp() throws Exception {
    Log.setLog(new NoLogging());
    rc = copyResourceTo("/pvdrc", temp.getRoot());
    copyResourceTo("/test.thrift", temp.getRoot());
    impl = mock(MyService.Iface.class);
    server = new Server(0);
    DefaultSerializerProvider provider = new DefaultSerializerProvider();
    ServletContextHandler handler = new ServletContextHandler();
    handler.addServlet(new ServletHolder(new ProvidenceServlet(new MyService.Processor(impl), provider)), "/" + ENDPOINT);
    server.setHandler(handler);
    server.start();
    port = getExposedPort(server);
    Thread.sleep(1);
    exitCode = 0;
    rpc = new RPC(console.tty()) {

        @Override
        protected void exit(int i) {
            exitCode = i;
        }
    };
}
Also used : Server(org.eclipse.jetty.server.Server) NoLogging(net.morimekta.providence.tools.rpc.internal.NoLogging) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) MyService(net.morimekta.test.providence.MyService) DefaultSerializerProvider(net.morimekta.providence.serializer.DefaultSerializerProvider) ProvidenceServlet(net.morimekta.providence.server.ProvidenceServlet) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) Before(org.junit.Before)

Example 2 with NoLogging

use of net.morimekta.providence.tools.rpc.internal.NoLogging in project providence by morimekta.

the class RPCThriftHttpTest method setUp.

@Before
public void setUp() throws Exception {
    Log.setLog(new NoLogging());
    rc = copyResourceTo("/pvdrc", temp.getRoot());
    copyResourceTo("/test.thrift", temp.getRoot());
    impl = mock(MyService.Iface.class);
    server = new Server(port);
    ServletContextHandler handler = new ServletContextHandler();
    handler.addServlet(new ServletHolder(new TServlet(new MyService.Processor<>(impl), new TBinaryProtocol.Factory(true, true))), ENDPOINT);
    handler.addServlet(new ServletHolder(new HttpServlet() {

        @Override
        protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            resp.setStatus(HttpServletResponse.SC_OK);
            resp.getWriter().write(html(head(title("Fail!")), body(h1("Fail!"), span("Truly failure"))).render());
        }
    }), HTML_ENDPOINT);
    handler.addServlet(new ServletHolder(new HttpServlet() {

        @Override
        protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            resp.setStatus(HttpServletResponse.SC_OK);
            resp.getWriter().write("{\"error\":\"Fail!\"}");
        }
    }), JSON_ENDPOINT);
    server.setHandler(handler);
    server.start();
    port = getExposedPort(server);
    Thread.sleep(1);
    exitCode = 0;
    rpc = new RPC(console.tty()) {

        @Override
        protected void exit(int i) {
            exitCode = i;
        }
    };
}
Also used : Server(org.eclipse.jetty.server.Server) NoLogging(net.morimekta.providence.tools.rpc.internal.NoLogging) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) HttpServlet(javax.servlet.http.HttpServlet) HttpServletResponse(javax.servlet.http.HttpServletResponse) TServlet(org.apache.thrift.server.TServlet) HttpServletRequest(javax.servlet.http.HttpServletRequest) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) MyService(net.morimekta.test.thrift.MyService) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) Before(org.junit.Before)

Example 3 with NoLogging

use of net.morimekta.providence.tools.rpc.internal.NoLogging in project providence by morimekta.

the class RPCThriftSocketTest method setUp.

@Before
public void setUp() throws Exception {
    Log.setLog(new NoLogging());
    rc = copyResourceTo("/pvdrc", temp.getRoot());
    copyResourceTo("/test.thrift", temp.getRoot());
    impl = Mockito.mock(MyService.Iface.class);
    TServerSocket transport = new TServerSocket(0);
    server = new TSimpleServer(new TServer.Args(transport).protocolFactory(new TBinaryProtocol.Factory()).processor(new MyService.Processor<>(impl)));
    ExecutorService executor = Executors.newSingleThreadExecutor();
    executor.submit(server::serve);
    Thread.sleep(1);
    port = transport.getServerSocket().getLocalPort();
    exitCode = 0;
    rpc = new RPC(console.tty()) {

        @Override
        protected void exit(int i) {
            exitCode = i;
        }
    };
}
Also used : NoLogging(net.morimekta.providence.tools.rpc.internal.NoLogging) TServerSocket(org.apache.thrift.transport.TServerSocket) MyService(net.morimekta.test.thrift.MyService) ExecutorService(java.util.concurrent.ExecutorService) TSimpleServer(org.apache.thrift.server.TSimpleServer) Before(org.junit.Before)

Aggregations

NoLogging (net.morimekta.providence.tools.rpc.internal.NoLogging)3 Before (org.junit.Before)3 MyService (net.morimekta.test.thrift.MyService)2 Server (org.eclipse.jetty.server.Server)2 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)2 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)2 ExecutorService (java.util.concurrent.ExecutorService)1 HttpServlet (javax.servlet.http.HttpServlet)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 DefaultSerializerProvider (net.morimekta.providence.serializer.DefaultSerializerProvider)1 ProvidenceServlet (net.morimekta.providence.server.ProvidenceServlet)1 MyService (net.morimekta.test.providence.MyService)1 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)1 TServlet (org.apache.thrift.server.TServlet)1 TSimpleServer (org.apache.thrift.server.TSimpleServer)1 TServerSocket (org.apache.thrift.transport.TServerSocket)1