Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package io.airlift.skeleton;
 
import static io.airlift.http.client.Request.Builder.prepareGet;
import static io.airlift.http.client.StatusResponseHandler.createStatusResponseHandler;
import static javax.ws.rs.core.Response.Status.OK;
import static org.testng.Assert.assertEquals;
@Test(singleThreaded = true)
public class TestServer
    private HttpClient client;
    private TestingHttpServer server;
    public void setup()
            throws Exception
    {
        Bootstrap app = new Bootstrap(
                new TestingNodeModule(),
                new TestingHttpServerModule(),
                new JsonModule(),
                new JaxrsModule(true),
                new JmxHttpModule(),
                new JmxModule(),
                new MainModule());
        Injector injector = app
                .strictConfig()
                .doNotInitializeLogging()
                .initialize();
         = injector.getInstance(LifeCycleManager.class);
         = injector.getInstance(TestingHttpServer.class);
         = new JettyHttpClient();
    }
    @AfterMethod(alwaysRun = true)
    public void teardown()
            throws Exception
    {
        try {
            if ( != null) {
                .stop();
            }
        }
        finally {
            Closeables.closeQuietly();
        }
    }
    @Test
    public void testNothing()
            throws Exception
    {
        StatusResponse response = .execute(
                prepareGet().setUri(uriFor("/v1/jmx/mbean")).build(),
                createStatusResponseHandler());
        assertEquals(response.getStatusCode(), .getStatusCode());
    }
    private URI uriFor(String path)
    {
        return .getBaseUrl().resolve(path);
    }
New to GrepCode? Check out our FAQ X