Search in sources :

Example 6 with DefaultSerializerProvider

use of net.morimekta.providence.serializer.DefaultSerializerProvider in project providence by morimekta.

the class DropWizardIT method testProvidenceServlet.

@Test
public void testProvidenceServlet() throws IOException, CalculateException {
    // This test is just to prove that the providence servlet can be used in dropwizard too.
    Calculator.Iface client = new Calculator.Client(new HttpClientHandler(() -> new GenericUrl(uri("test")), factory(), new DefaultSerializerProvider()));
    Operand result = client.calculate(new Operation(Operator.ADD, list(withNumber(52d), withImaginary(new Imaginary(1d, -1d)), withNumber(15d))));
    assertThat(debugString(result), is(equalTo("{\n" + "  imaginary = {\n" + "    v = 68\n" + "    i = -1\n" + "  }\n" + "}")));
}
Also used : Operand(net.morimekta.test.providence.jax.rs.calculator.Operand) Calculator(net.morimekta.test.providence.jax.rs.calculator.Calculator) DefaultSerializerProvider(net.morimekta.providence.serializer.DefaultSerializerProvider) Operand.withImaginary(net.morimekta.test.providence.jax.rs.calculator.Operand.withImaginary) Imaginary(net.morimekta.test.providence.jax.rs.number.Imaginary) GenericUrl(com.google.api.client.http.GenericUrl) Operation(net.morimekta.test.providence.jax.rs.calculator.Operation) Client(javax.ws.rs.client.Client) HttpClientHandler(net.morimekta.providence.client.HttpClientHandler) Test(org.junit.Test)

Example 7 with DefaultSerializerProvider

use of net.morimekta.providence.serializer.DefaultSerializerProvider in project providence by morimekta.

the class TestApplication method run.

@Override
public void run(TestConfiguration testConfiguration, Environment environment) throws Exception {
    Calculator.Iface impl = new TestCalculator();
    environment.jersey().register(DefaultProvidenceMessageBodyReader.class);
    environment.jersey().register(DefaultProvidenceMessageBodyWriter.class);
    environment.jersey().register(new TestCalculatorResource(impl));
    environment.getApplicationContext().addServlet(new ServletHolder(new ProvidenceServlet(new Calculator.Processor(impl), new DefaultSerializerProvider())), "/test");
}
Also used : ServletHolder(org.eclipse.jetty.servlet.ServletHolder) Calculator(net.morimekta.test.providence.jax.rs.calculator.Calculator) DefaultSerializerProvider(net.morimekta.providence.serializer.DefaultSerializerProvider) ProvidenceServlet(net.morimekta.providence.server.ProvidenceServlet)

Aggregations

DefaultSerializerProvider (net.morimekta.providence.serializer.DefaultSerializerProvider)7 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)5 Server (org.eclipse.jetty.server.Server)4 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)4 Before (org.junit.Before)4 ServiceCallInstrumentation (net.morimekta.providence.util.ServiceCallInstrumentation)3 ProvidenceServlet (net.morimekta.providence.server.ProvidenceServlet)2 NoLogging (net.morimekta.providence.server.internal.NoLogging)2 Calculator (net.morimekta.test.providence.jax.rs.calculator.Calculator)2 TestService (net.morimekta.test.providence.service.TestService)2 GenericUrl (com.google.api.client.http.GenericUrl)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 ServerSocket (java.net.ServerSocket)1 Socket (java.net.Socket)1 SocketTimeoutException (java.net.SocketTimeoutException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 HttpServlet (javax.servlet.http.HttpServlet)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1