Search in sources :

Example 6 with RuntimeDelegate

use of jakarta.ws.rs.ext.RuntimeDelegate in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method askForTckRuntimeDelegateGivenBySetInstanceTest.

/*
   * @testName: askForTckRuntimeDelegateGivenBySetInstanceTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:291;JAXRS:JAVADOC:292;
   * 
   * @test_Strategy: Set new RuntimeDelegate and check it is TckRuntimeDelegate
   * 
   */
@Test
public void askForTckRuntimeDelegateGivenBySetInstanceTest() throws Fault {
    RuntimeDelegate original = RuntimeDelegate.getInstance();
    RuntimeDelegate.setInstance(new TckRuntimeDelegate());
    try {
        assertRuntimeDelegate();
    } finally {
        RuntimeDelegate.setInstance(original);
        assertRuntimeDelegate(false);
    }
}
Also used : TckRuntimeDelegate(ee.jakarta.tck.ws.rs.api.rs.ext.runtimedelegate.TckRuntimeDelegate) RuntimeDelegate(jakarta.ws.rs.ext.RuntimeDelegate) TckRuntimeDelegate(ee.jakarta.tck.ws.rs.api.rs.ext.runtimedelegate.TckRuntimeDelegate) Test(org.junit.jupiter.api.Test)

Example 7 with RuntimeDelegate

use of jakarta.ws.rs.ext.RuntimeDelegate in project jaxrs-api by eclipse-ee4j.

the class ResponseTest method setStringBeanRuntime.

// For the methods that checks for the header delegate this is the way
// to add header delegate by switching runtimedelegate
// As long as the runtime delegate is one only for whole classloader
@Path("setstringbeanruntime")
@GET
public Response setStringBeanRuntime() {
    RuntimeDelegate original = RuntimeDelegate.getInstance();
    if (!(original instanceof StringBeanRuntimeDelegate)) {
        StringBeanRuntimeDelegate sbrd = new StringBeanRuntimeDelegate(original);
        RuntimeDelegate.setInstance(sbrd);
    }
    return Response.ok().build();
}
Also used : StringBeanRuntimeDelegate(ee.jakarta.tck.ws.rs.common.provider.StringBeanRuntimeDelegate) RuntimeDelegate(jakarta.ws.rs.ext.RuntimeDelegate) StringBeanRuntimeDelegate(ee.jakarta.tck.ws.rs.common.provider.StringBeanRuntimeDelegate) Path(jakarta.ws.rs.Path) GET(jakarta.ws.rs.GET)

Example 8 with RuntimeDelegate

use of jakarta.ws.rs.ext.RuntimeDelegate in project jaxrs-api by eclipse-ee4j.

the class ResponseTest method setOriginalRuntime.

// We need to switch back to the original runtime delegate since
// we cannot be sure what happen when the war with our runtimedelegate gets
// undeployed
@Path("setoriginalruntime")
@GET
public Response setOriginalRuntime() {
    Response response = null;
    RuntimeDelegate stringBeanDelegate = RuntimeDelegate.getInstance();
    if (stringBeanDelegate instanceof StringBeanRuntimeDelegate) {
        RuntimeDelegate original = ((StringBeanRuntimeDelegate) stringBeanDelegate).getOriginal();
        RuntimeDelegate.setInstance(original);
        response = Response.ok().build();
    } else
        response = Response.status(Status.NO_CONTENT).build();
    return response;
}
Also used : Response(jakarta.ws.rs.core.Response) StringBeanRuntimeDelegate(ee.jakarta.tck.ws.rs.common.provider.StringBeanRuntimeDelegate) RuntimeDelegate(jakarta.ws.rs.ext.RuntimeDelegate) StringBeanRuntimeDelegate(ee.jakarta.tck.ws.rs.common.provider.StringBeanRuntimeDelegate) Path(jakarta.ws.rs.Path) GET(jakarta.ws.rs.GET)

Example 9 with RuntimeDelegate

use of jakarta.ws.rs.ext.RuntimeDelegate in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method getStringHeadersUsingToStringTest.

/*
   * @testName: getStringHeadersUsingToStringTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:859;
   * 
   * @test_Strategy: Get view of the response headers and their string values.
   * Each single header value is converted to String using a
   * RuntimeDelegate.HeaderDelegate or using its toString
   */
@Test
public void getStringHeadersUsingToStringTest() throws Fault {
    RuntimeDelegate original = RuntimeDelegate.getInstance();
    RuntimeDelegate.setInstance(new StringBeanRuntimeDelegate(original));
    try {
        StringBuilder builder = new StringBuilder("s1");
        StringBuffer buffer = new StringBuffer("s2");
        StringBean bean = new StringBean("s3");
        Response response = Response.ok().header(builder.toString(), builder).header(buffer.toString(), buffer).header(bean.get(), bean).build();
        MultivaluedMap<String, String> headers = response.getStringHeaders();
        String header = headers.getFirst(builder.toString());
        assertContainsIgnoreCase(header, builder.toString(), "Header", builder, "has unexpected value", header);
        header = headers.getFirst(buffer.toString());
        assertContainsIgnoreCase(header, buffer.toString(), "Header", builder, "has unexpected value", header);
        logMsg("#getStringHeaders contains expected values", JaxrsUtil.iterableToString(",", headers.entrySet()));
    } finally {
        RuntimeDelegate.setInstance(original);
        StringBeanRuntimeDelegate.assertNotStringBeanRuntimeDelegate();
    }
}
Also used : Response(jakarta.ws.rs.core.Response) StringBeanRuntimeDelegate(ee.jakarta.tck.ws.rs.common.provider.StringBeanRuntimeDelegate) StringBean(ee.jakarta.tck.ws.rs.common.provider.StringBean) RuntimeDelegate(jakarta.ws.rs.ext.RuntimeDelegate) StringBeanRuntimeDelegate(ee.jakarta.tck.ws.rs.common.provider.StringBeanRuntimeDelegate) Test(org.junit.jupiter.api.Test)

Example 10 with RuntimeDelegate

use of jakarta.ws.rs.ext.RuntimeDelegate in project jaxrs-api by eclipse-ee4j.

the class Resource method setStringBeanRuntime.

// For the methods that checks for the header delegate this is the way
// to add header delegate by switching runtimedelegate
// As long as the runtime delegate is one only for whole classloader
@Path("setstringbeanruntime")
@GET
public Response setStringBeanRuntime() {
    RuntimeDelegate original = RuntimeDelegate.getInstance();
    if (!(original instanceof StringBeanRuntimeDelegate)) {
        StringBeanRuntimeDelegate sbrd = new StringBeanRuntimeDelegate(original);
        RuntimeDelegate.setInstance(sbrd);
    }
    return createResponseWithHeader().build();
}
Also used : StringBeanRuntimeDelegate(ee.jakarta.tck.ws.rs.common.provider.StringBeanRuntimeDelegate) RuntimeDelegate(jakarta.ws.rs.ext.RuntimeDelegate) StringBeanRuntimeDelegate(ee.jakarta.tck.ws.rs.common.provider.StringBeanRuntimeDelegate) Path(jakarta.ws.rs.Path) GET(jakarta.ws.rs.GET)

Aggregations

RuntimeDelegate (jakarta.ws.rs.ext.RuntimeDelegate)16 StringBeanRuntimeDelegate (ee.jakarta.tck.ws.rs.common.provider.StringBeanRuntimeDelegate)10 Test (org.junit.jupiter.api.Test)8 Response (jakarta.ws.rs.core.Response)7 StringBean (ee.jakarta.tck.ws.rs.common.provider.StringBean)6 GET (jakarta.ws.rs.GET)6 Path (jakarta.ws.rs.Path)6 ClientRequestContext (jakarta.ws.rs.client.ClientRequestContext)3 ResponseBuilder (jakarta.ws.rs.core.Response.ResponseBuilder)3 Invocation (jakarta.ws.rs.client.Invocation)2 HttpHandler (com.sun.net.httpserver.HttpHandler)1 TckRuntimeDelegate (ee.jakarta.tck.ws.rs.api.rs.ext.runtimedelegate.TckRuntimeDelegate)1 ReadableWritableEntity (ee.jakarta.tck.ws.rs.ee.rs.ext.messagebodyreaderwriter.ReadableWritableEntity)1 ClientResponseContext (jakarta.ws.rs.client.ClientResponseContext)1 Application (jakarta.ws.rs.core.Application)1 HashSet (java.util.HashSet)1