@Inject public SwaggerServletContext(JerseyOptions options) { contextPath = options.getBaseUri().toString(); }
public int getMaxBodySize() { if (maxBodySize == null) { maxBodySize = getContainer().getOptions().getMaxBodySize(); if (maxBodySize <= 0) { maxBodySize = DefaultJerseyOptions.DEFAULT_MAX_BODY_SIZE; } } return maxBodySize; }
List<String> packages = options.getPackages(); Set<Class<?>> components = options.getComponents(); boolean hasPackages = (packages != null && !packages.isEmpty()); boolean hasComponents = (components != null && !components.isEmpty()); Set<Object> instances = options.getInstances(); if (instances != null) { rc.registerInstances(instances); Map<String, Object> properties = options.getProperties(); if (properties != null) { rc.addProperties(properties);
@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); }
@Before public void setUp() throws Exception { when(options.getPackages()).thenReturn(packages); locator = ServiceLocatorFactory.getInstance().create(null); }
List<String> packages = options.getPackages(); Set<Class<?>> components = options.getComponents(); boolean hasPackages = (packages != null && !packages.isEmpty()); boolean hasComponents = (components != null && !components.isEmpty()); Set<Object> instances = options.getInstances(); if (instances != null) { rc.registerInstances(instances); Map<String, Object> properties = options.getProperties(); if (properties != null) { rc.addProperties(properties);
@Override public URI getBaseUri() { if (baseUri == null) { baseUri = getContainer().getOptions().getBaseUri(); if (baseUri == null) { throw new IllegalStateException("baseUri is null, have you called init() first?"); } } return baseUri; }
public int getMaxBodySize() { if (maxBodySize == null) { maxBodySize = getContainer().getOptions().getMaxBodySize(); if (maxBodySize <= 0) { maxBodySize = DefaultJerseyOptions.DEFAULT_MAX_BODY_SIZE; } } return maxBodySize; }
@Override public URI getBaseUri() { if (baseUri == null) { baseUri = getContainer().getOptions().getBaseUri(); if (baseUri == null) { throw new IllegalStateException("baseUri is null, have you called init() first?"); } } return baseUri; }
@Test public void testGetBaseURI() throws Exception { URI baseUri = URI.create("/test"); when(options.getBaseUri()).thenReturn(baseUri); URI result = jerseyHandler.getBaseUri(); assertEquals(baseUri, result); }