/** * Releases resources */ @Override public void close() { // Destroy the jersey service locator if (jerseyHandler != null && jerseyHandler.getDelegate() != null) { ServiceLocatorFactory.getInstance().destroy(jerseyHandler.getDelegate().getServiceLocator()); jerseyHandler = null; } if (server != null) { server.close(); server = null; } } }
@Before public void setUp() { when(container.getOptions()).thenReturn(options); when(container.getVertx()).thenReturn(vertx); when(container.getApplicationHandlerDelegate()).thenReturn(applicationHandlerDelegate); when(applicationHandlerDelegate.getServiceLocator()).thenReturn(serviceLocator); when(options.getMaxBodySize()).thenReturn(1024); when(options.getBaseUri()).thenReturn(URI.create("/test")); when(request.absoluteURI()).thenReturn(URI.create("http://test.englishtown.com/test").toString()); when(request.response()).thenReturn(response); when(request.headers()).thenReturn(headers); JsonArray resources = new JsonArray().add("com.englishtown.vertx.jersey.resources"); config.put(DefaultJerseyOptions.CONFIG_RESOURCES, resources); ContainerResponseWriterProvider provider = mock(ContainerResponseWriterProvider.class); when(provider.get(any(HttpServerRequest.class), any(ContainerRequest.class))).thenReturn(mock(ContainerResponseWriter.class)); when(serviceLocator.<Ref<Vertx>>getService((new TypeLiteral<Ref<Vertx>>() { }).getType())).thenReturn(vertxRef); when(serviceLocator.<Ref<Container>>getService((new TypeLiteral<Ref<Container>>() { }).getType())).thenReturn(containerRef); jerseyHandler = new DefaultJerseyHandler(() -> container, provider, requestProcessors); }
/** * Shutdown jersey server and release resources */ @Override public void stop() { // Run jersey shutdown lifecycle if (container != null) { container.stop(); container = null; } // Destroy the jersey service locator if (jerseyHandler != null && jerseyHandler.getDelegate() != null) { ServiceLocatorFactory.getInstance().destroy(jerseyHandler.getDelegate().getServiceLocator()); jerseyHandler = null; } if (server != null) { server.close(); server = null; } } }
/** * Shutdown jersey server and release resources */ @Override public void stop() { // Run jersey shutdown lifecycle if (container != null) { container.stop(); container = null; } // Destroy the jersey service locator if (jerseyHandler != null && jerseyHandler.getDelegate() != null) { ServiceLocatorFactory.getInstance().destroy(jerseyHandler.getDelegate().getServiceLocator()); jerseyHandler = null; } if (server != null) { server.close(); server = null; } } }