Search in sources :

Example 11 with RuntimeDelegate

use of javax.ws.rs.ext.RuntimeDelegate in project jersey by jersey.

the class InboundMessageContext method iterableToList.

private static List<String> iterableToList(final Iterable<?> values) {
    final LinkedList<String> linkedList = new LinkedList<String>();
    final RuntimeDelegate rd = RuntimeDelegate.getInstance();
    for (Object element : values) {
        linkedList.add(HeaderUtils.asString(element, rd));
    }
    return linkedList;
}
Also used : LinkedList(java.util.LinkedList) RuntimeDelegate(javax.ws.rs.ext.RuntimeDelegate)

Example 12 with RuntimeDelegate

use of javax.ws.rs.ext.RuntimeDelegate in project cxf by apache.

the class RuntimeDelegateImplTest method testRuntimeDelegate.

@Test
public void testRuntimeDelegate() throws Exception {
    RuntimeDelegate rd = RuntimeDelegate.getInstance();
    assertSame(rd.getClass(), RuntimeDelegateImpl.class);
}
Also used : RuntimeDelegate(javax.ws.rs.ext.RuntimeDelegate) Test(org.junit.Test)

Example 13 with RuntimeDelegate

use of javax.ws.rs.ext.RuntimeDelegate in project jbpm by kiegroup.

the class BasicAuthRestWorkItemHandlerTest method initialize.

@SuppressWarnings({ "rawtypes" })
@BeforeClass
public static void initialize() throws Exception {
    SimpleRESTApplication application = new SimpleRESTApplication();
    RuntimeDelegate delegate = RuntimeDelegate.getInstance();
    JAXRSServerFactoryBean bean = delegate.createEndpoint(application, JAXRSServerFactoryBean.class);
    bean.setProvider(new JAXBElementProvider());
    bean.setAddress("http://localhost:9998" + bean.getAddress());
    // disabled logging interceptor by default but proves to be useful
    // bean.getInInterceptors().add(new LoggingInInterceptor(new PrintWriter(System.out, true)));
    bean.setProvider(new AuthenticationFilter());
    server = bean.create();
    server.start();
}
Also used : JAXBElementProvider(org.apache.cxf.jaxrs.provider.JAXBElementProvider) JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean) RuntimeDelegate(javax.ws.rs.ext.RuntimeDelegate) BeforeClass(org.junit.BeforeClass)

Example 14 with RuntimeDelegate

use of javax.ws.rs.ext.RuntimeDelegate in project scout.rt by eclipse.

the class DefaultExceptionMapperTest method beforeClass.

@BeforeClass
public static void beforeClass() {
    // Setup mocked JAX-RS runtime (without a mock, a real JAX-RS runtime needs to be on the classpath during test execution)
    RuntimeDelegate runtimeDelegate = mock(RuntimeDelegate.class);
    RuntimeDelegate.setInstance(runtimeDelegate);
    final ResponseBuilder responseBuilder = mock(ResponseBuilder.class);
    when(runtimeDelegate.createResponseBuilder()).thenReturn(responseBuilder);
    when((responseBuilder).status(Mockito.any(Response.Status.class))).then(new Answer<ResponseBuilder>() {

        @Override
        public ResponseBuilder answer(InvocationOnMock invocation) throws Throwable {
            return addStatus(responseBuilder, ((Response.Status) invocation.getArgument(0)).getStatusCode());
        }
    });
    when((responseBuilder.status(Mockito.any(StatusType.class)))).then(new Answer<ResponseBuilder>() {

        @Override
        public ResponseBuilder answer(InvocationOnMock invocation) throws Throwable {
            return addStatus(responseBuilder, ((Response.StatusType) invocation.getArgument(0)).getStatusCode());
        }
    });
    when((responseBuilder.status(Mockito.anyInt()))).then(new Answer<ResponseBuilder>() {

        @Override
        public ResponseBuilder answer(InvocationOnMock invocation) throws Throwable {
            return addStatus(responseBuilder, ((int) invocation.getArgument(0)));
        }
    });
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) StatusType(javax.ws.rs.core.Response.StatusType) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) RuntimeDelegate(javax.ws.rs.ext.RuntimeDelegate) BeforeClass(org.junit.BeforeClass)

Aggregations

RuntimeDelegate (javax.ws.rs.ext.RuntimeDelegate)14 HashSet (java.util.HashSet)4 Map (java.util.Map)4 MultivaluedMap (javax.ws.rs.core.MultivaluedMap)4 JAXRSServerFactoryBean (org.apache.cxf.jaxrs.JAXRSServerFactoryBean)4 BeforeClass (org.junit.BeforeClass)4 IOException (java.io.IOException)3 OutputStream (java.io.OutputStream)3 Annotation (java.lang.annotation.Annotation)3 Type (java.lang.reflect.Type)3 URI (java.net.URI)3 ParseException (java.text.ParseException)3 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 Date (java.util.Date)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Locale (java.util.Locale)3 Set (java.util.Set)3 Function (java.util.function.Function)3