Search in sources :

Example 1 with DataSource

use of jakarta.activation.DataSource in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method clientDataSourceReaderTest.

/*
   * @testName: clientDataSourceReaderTest
   * 
   * @assertion_ids: JAXRS:SPEC:70;
   * 
   * @test_Strategy: See Section 4.2.4 for a list of entity providers that MUST
   * be supported by all JAX-RS implementations
   */
@Test
public void clientDataSourceReaderTest() throws Fault {
    standardReaderInvocation(MediaType.WILDCARD_TYPE);
    DataSource responseEntity = getResponse().readEntity(DataSource.class);
    assertTrue(responseEntity != null, "Returned Entity is null!");
    InputStreamReader reader;
    try {
        reader = new InputStreamReader(responseEntity.getInputStream());
    } catch (IOException e) {
        throw new Fault(e);
    }
    readerTest(reader);
}
Also used : InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) StringDataSource(ee.jakarta.tck.ws.rs.common.impl.StringDataSource) DataSource(jakarta.activation.DataSource) Test(org.junit.jupiter.api.Test)

Example 2 with DataSource

use of jakarta.activation.DataSource in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method clientDataSourceProviderTest.

/*
   * @testName: clientDataSourceProviderTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:863;
   * 
   * @test_Strategy: DataSource All media types.
   * 
   * for a zero-length response entities returns null or a corresponding Java
   * object that represents zero-length data.
   */
@Test
@Tag("xml_binding")
public void clientDataSourceProviderTest() throws Fault {
    setProperty(Property.REQUEST, buildRequest(Request.GET, "entity"));
    invoke();
    DataSource entity = getResponseBody(DataSource.class);
    String content = null;
    if (entity != null)
        try {
            content = JaxrsUtil.readFromStream(entity.getInputStream());
        } catch (Exception e) {
            throw new Fault(e);
        }
    assertTrue(content == null || content.length() == 0, "DataSource reader gets unexpected" + content);
}
Also used : ProcessingException(jakarta.ws.rs.ProcessingException) IOException(java.io.IOException) NoContentException(jakarta.ws.rs.core.NoContentException) DataSource(jakarta.activation.DataSource) Test(org.junit.jupiter.api.Test) Tag(org.junit.jupiter.api.Tag)

Example 3 with DataSource

use of jakarta.activation.DataSource in project spring-framework by spring-projects.

the class StandardClasses method standardClassDataHandler.

public JAXBElement<DataHandler> standardClassDataHandler() {
    DataSource dataSource = new URLDataSource(getClass().getResource("spring-ws.png"));
    DataHandler dataHandler = new DataHandler(dataSource);
    return new JAXBElement<>(NAME, DataHandler.class, dataHandler);
}
Also used : URLDataSource(jakarta.activation.URLDataSource) DataHandler(jakarta.activation.DataHandler) JAXBElement(jakarta.xml.bind.JAXBElement) URLDataSource(jakarta.activation.URLDataSource) DataSource(jakarta.activation.DataSource)

Example 4 with DataSource

use of jakarta.activation.DataSource in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method clientDataSourceWriterTest.

/*
   * @testName: clientDataSourceWriterTest
   * 
   * @assertion_ids: JAXRS:SPEC:70;
   * 
   * @test_Strategy: See Section 4.2.4 for a list of entity providers that MUST
   * be supported by all JAX-RS implementations
   */
@Test
public void clientDataSourceWriterTest() throws Fault {
    DataSource ds = new StringDataSource(entity, MediaType.WILDCARD_TYPE);
    standardWriterInvocation(ds);
}
Also used : StringDataSource(ee.jakarta.tck.ws.rs.common.impl.StringDataSource) StringDataSource(ee.jakarta.tck.ws.rs.common.impl.StringDataSource) DataSource(jakarta.activation.DataSource) Test(org.junit.jupiter.api.Test)

Aggregations

DataSource (jakarta.activation.DataSource)4 Test (org.junit.jupiter.api.Test)3 StringDataSource (ee.jakarta.tck.ws.rs.common.impl.StringDataSource)2 IOException (java.io.IOException)2 DataHandler (jakarta.activation.DataHandler)1 URLDataSource (jakarta.activation.URLDataSource)1 ProcessingException (jakarta.ws.rs.ProcessingException)1 NoContentException (jakarta.ws.rs.core.NoContentException)1 JAXBElement (jakarta.xml.bind.JAXBElement)1 InputStreamReader (java.io.InputStreamReader)1 Tag (org.junit.jupiter.api.Tag)1