Search in sources :

Example 1 with ReadableWritableEntity

use of ee.jakarta.tck.ws.rs.ee.rs.ext.messagebodyreaderwriter.ReadableWritableEntity in project jaxrs-api by eclipse-ee4j.

the class JAXRSProvidersClientIT method writeBodyEntityUsingWriterTest.

/*
   * @testName: writeBodyEntityUsingWriterTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:87; JAXRS:JAVADOC:276; JAXRS:JAVADOC:283;
   * JAXRS:JAVADOC:132; JAXRS:JAVADOC:275; JAXRS:JAVADOC:276; JAXRS:JAVADOC:304;
   * 
   * @test_Strategy: Check BodyWriter is used for text/xml to write entity
   */
@Test
public void writeBodyEntityUsingWriterTest() throws Fault {
    String ename = EnumProvider.JAXRS.name();
    String search = new ReadableWritableEntity(ename).toXmlString();
    setProperty(Property.REQUEST_HEADERS, "Accept: " + MediaType.TEXT_XML);
    setProperty(Property.REQUEST, buildRequest(GET, "writeBodyEntityUsingWriter"));
    setProperty(Property.STATUS_CODE, getStatusCode(Status.OK));
    setProperty(Property.SEARCH_STRING, search);
    invoke();
}
Also used : ReadableWritableEntity(ee.jakarta.tck.ws.rs.ee.rs.ext.messagebodyreaderwriter.ReadableWritableEntity) Test(org.junit.jupiter.api.Test)

Example 2 with ReadableWritableEntity

use of ee.jakarta.tck.ws.rs.ee.rs.ext.messagebodyreaderwriter.ReadableWritableEntity in project jaxrs-api by eclipse-ee4j.

the class JAXRSProvidersClientIT method writeHeaderEntityUsingWriterTest.

/*
   * @testName: writeHeaderEntityUsingWriterTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:87; JAXRS:JAVADOC:276; JAXRS:JAVADOC:132;
   * JAXRS:JAVADOC:275; JAXRS:JAVADOC:277; JAXRS:JAVADOC:304;
   * 
   * @test_Strategy: Check HeaderWriter is used for text/xml to write entity
   */
@Test
public void writeHeaderEntityUsingWriterTest() throws Fault {
    String ename = EnumProvider.JAXRS.name();
    String search = new ReadableWritableEntity(ename).toXmlString();
    setProperty(Property.REQUEST_HEADERS, "Accept: " + MediaType.TEXT_XML);
    setProperty(Property.REQUEST, buildRequest(GET, "writeHeaderEntityUsingWriter"));
    setProperty(Property.STATUS_CODE, getStatusCode(Status.OK));
    setProperty(Property.EXPECTED_HEADERS, ReadableWritableEntity.NAME + ":" + search);
    invoke();
}
Also used : ReadableWritableEntity(ee.jakarta.tck.ws.rs.ee.rs.ext.messagebodyreaderwriter.ReadableWritableEntity) Test(org.junit.jupiter.api.Test)

Example 3 with ReadableWritableEntity

use of ee.jakarta.tck.ws.rs.ee.rs.ext.messagebodyreaderwriter.ReadableWritableEntity in project jaxrs-api by eclipse-ee4j.

the class JAXRSProvidersClientIT method readEntityFromHeaderTest.

/*
   * @testName: readEntityFromHeaderTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:271; JAXRS:JAVADOC:272; JAXRS:JAVADOC:138;
   * JAXRS:JAVADOC:304; JAXRS:JAVADOC:282;
   * 
   * @test_Strategy: Put entity to header and read it using reader
   */
@Test
public void readEntityFromHeaderTest() throws Fault {
    ReadableWritableEntity entity;
    entity = new ReadableWritableEntity(EnumProvider.JAXRS.name());
    String header = ReadableWritableEntity.NAME + ":" + entity.toXmlString();
    setProperty(Property.REQUEST_HEADERS, "Content-Type: " + MediaType.TEXT_XML);
    setProperty(Property.REQUEST_HEADERS, header);
    setProperty(Property.REQUEST, buildRequest("POST", "readEntityFromHeader"));
    setProperty(Property.STATUS_CODE, getStatusCode(Status.OK));
    invoke();
}
Also used : ReadableWritableEntity(ee.jakarta.tck.ws.rs.ee.rs.ext.messagebodyreaderwriter.ReadableWritableEntity) Test(org.junit.jupiter.api.Test)

Example 4 with ReadableWritableEntity

use of ee.jakarta.tck.ws.rs.ee.rs.ext.messagebodyreaderwriter.ReadableWritableEntity in project jaxrs-api by eclipse-ee4j.

the class ProvidersServlet method isRegisteredWriterXml.

@GET
@Path("isRegisteredMessageWriterXml")
public Response isRegisteredWriterXml() {
    MessageBodyWriter<ReadableWritableEntity> entity;
    entity = providers.getMessageBodyWriter(ReadableWritableEntity.class, null, getMethodAnnotations("writeBodyEntityUsingWriter"), MediaType.TEXT_XML_TYPE);
    Status status = entity == null ? Status.NOT_ACCEPTABLE : Status.OK;
    return Response.status(status).build();
}
Also used : Status(jakarta.ws.rs.core.Response.Status) ReadableWritableEntity(ee.jakarta.tck.ws.rs.ee.rs.ext.messagebodyreaderwriter.ReadableWritableEntity) Path(jakarta.ws.rs.Path) GET(jakarta.ws.rs.GET)

Example 5 with ReadableWritableEntity

use of ee.jakarta.tck.ws.rs.ee.rs.ext.messagebodyreaderwriter.ReadableWritableEntity in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method clientAnyWriterUsageTest.

/*
   * @testName: clientAnyWriterUsageTest
   * 
   * @assertion_ids: JAXRS:SPEC:69;
   * 
   * @test_Strategy: JAX-RS implementations are REQUIRED to use entity providers
   */
@Test
public void clientAnyWriterUsageTest() throws Fault {
    ReadableWritableEntity entity = new ReadableWritableEntity(String.valueOf(serialVersionUID));
    addProvider(new EntityMessageWriter());
    setProperty(Property.REQUEST, buildRequest(Request.POST, "writerprovider"));
    setProperty(Property.REQUEST_HEADERS, buildAccept(MediaType.TEXT_XML_TYPE));
    setRequestContentEntity(entity);
    setProperty(Property.SEARCH_STRING, entity.toXmlString());
    invoke();
}
Also used : ReadableWritableEntity(ee.jakarta.tck.ws.rs.ee.rs.ext.messagebodyreaderwriter.ReadableWritableEntity) Test(org.junit.jupiter.api.Test)

Aggregations

ReadableWritableEntity (ee.jakarta.tck.ws.rs.ee.rs.ext.messagebodyreaderwriter.ReadableWritableEntity)12 Test (org.junit.jupiter.api.Test)6 GET (jakarta.ws.rs.GET)5 Path (jakarta.ws.rs.Path)5 Status (jakarta.ws.rs.core.Response.Status)4 ApplicationHolderSingleton (ee.jakarta.tck.ws.rs.ee.rs.core.application.ApplicationHolderSingleton)1 ResponseBuilder (jakarta.ws.rs.core.Response.ResponseBuilder)1 RuntimeDelegate (jakarta.ws.rs.ext.RuntimeDelegate)1 HashSet (java.util.HashSet)1