Search in sources :

Example 11 with JAXBElement

use of jakarta.xml.bind.JAXBElement in project jaxrs-api by eclipse-ee4j.

the class Resource method getJaxbElement.

@GET
@Path("getjaxb")
public Response getJaxbElement() {
    JAXBElement<String> element = new JAXBElement<String>(new QName("resource"), String.class, getClass().getName());
    GenericEntity<JAXBElement<String>> generic = new GenericEntity<JAXBElement<String>>(element) {
    };
    return buildResponse(generic, MediaType.TEXT_XML_TYPE);
}
Also used : QName(javax.xml.namespace.QName) GenericEntity(jakarta.ws.rs.core.GenericEntity) JAXBElement(jakarta.xml.bind.JAXBElement) Path(jakarta.ws.rs.Path) GET(jakarta.ws.rs.GET)

Example 12 with JAXBElement

use of jakarta.xml.bind.JAXBElement in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method readWriteJaxbProviderTest.

/* Run test */
/*
   * @testName: readWriteJaxbProviderTest
   * 
   * @assertion_ids: JAXRS:SPEC:35
   * 
   * @test_Strategy: An implementation MUST support application-provided entity
   * providers and MUST use those in preference to its own pre-packaged
   * providers when either could handle the same request. More precisely, step 4
   * in Section 4.2.1 and step 5 in Section 4.2.2 MUST prefer
   * application-provided over pre-packaged entity providers. i.e. When have the
   * same mediaType
   */
@Test
@Tag("xml_binding")
public void readWriteJaxbProviderTest() throws Fault {
    JAXBElement<String> element = new JAXBElement<String>(new QName("jaxb"), String.class, "jaxb");
    setRequestContentEntity(element);
    setPropertyAndInvoke("jaxb", MediaType.APPLICATION_XML_TYPE);
}
Also used : QName(javax.xml.namespace.QName) JAXBElement(jakarta.xml.bind.JAXBElement) Test(org.junit.jupiter.api.Test) Tag(org.junit.jupiter.api.Tag)

Example 13 with JAXBElement

use of jakarta.xml.bind.JAXBElement in project jaxrs-api by eclipse-ee4j.

the class SomeUnmarshaller method unmarshal.

@Override
public <T> JAXBElement<T> unmarshal(Source source, Class<T> declaredType) throws JAXBException {
    String name = getClass().getSimpleName();
    @SuppressWarnings("unchecked") JAXBElement<T> el = new JAXBElement<T>(new QName(name), declaredType, (T) name);
    return el;
}
Also used : QName(javax.xml.namespace.QName) JAXBElement(jakarta.xml.bind.JAXBElement)

Example 14 with JAXBElement

use of jakarta.xml.bind.JAXBElement in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method clientJaxbElementWriterTest.

/*
   * @testName: clientJaxbElementWriterTest
   * 
   * @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
@Tag("xml_binding")
public void clientJaxbElementWriterTest() throws Fault {
    setProperty(Property.REQUEST_HEADERS, buildContentType(MediaType.APPLICATION_XML_TYPE));
    JAXBElement<String> element = new JAXBElement<String>(new QName(""), String.class, entity);
    standardWriterInvocation(element);
}
Also used : QName(javax.xml.namespace.QName) JAXBElement(jakarta.xml.bind.JAXBElement) Test(org.junit.jupiter.api.Test) Tag(org.junit.jupiter.api.Tag)

Example 15 with JAXBElement

use of jakarta.xml.bind.JAXBElement in project xades4j by luisgoncalves.

the class ToXmlSignaturePolicyConverter method getSignaturePolicy.

private XmlSignaturePolicyIdType getSignaturePolicy(SignaturePolicyData sigPolicyData, Document doc) {
    XmlSignaturePolicyIdType xmlSigPolicyId = new XmlSignaturePolicyIdType();
    // Identifier
    xmlSigPolicyId.setSigPolicyId(ToXmlUtils.getXmlObjectId(sigPolicyData.getIdentifier()));
    // Hash
    XmlDigestMethodType xmlDigestMethod = new XmlDigestMethodType();
    xmlDigestMethod.setAlgorithm(sigPolicyData.getDigestAlgorithm());
    XmlDigestAlgAndValueType xmlDigest = new XmlDigestAlgAndValueType();
    xmlDigest.setDigestMethod(xmlDigestMethod);
    xmlDigest.setDigestValue(sigPolicyData.getDigestValue());
    xmlSigPolicyId.setSigPolicyHash(xmlDigest);
    // Qualifiers
    String url = sigPolicyData.getLocationUrl();
    if (url != null) {
        JAXBElement<String> xmlSPURI = new JAXBElement<String>(new QName(QualifyingProperty.XADES_XMLNS, "SPURI"), String.class, url);
        XmlAnyType xmlQualifier = new XmlAnyType();
        xmlQualifier.getContent().add(xmlSPURI);
        XmlSigPolicyQualifiersListType xmlQualifiers = new XmlSigPolicyQualifiersListType();
        xmlQualifiers.getSigPolicyQualifier().add(xmlQualifier);
        xmlSigPolicyId.setSigPolicyQualifiers(xmlQualifiers);
    }
    return xmlSigPolicyId;
}
Also used : XmlDigestAlgAndValueType(xades4j.xml.bind.xades.XmlDigestAlgAndValueType) XmlAnyType(xades4j.xml.bind.xades.XmlAnyType) QName(javax.xml.namespace.QName) XmlDigestMethodType(xades4j.xml.bind.xmldsig.XmlDigestMethodType) JAXBElement(jakarta.xml.bind.JAXBElement) XmlSignaturePolicyIdType(xades4j.xml.bind.xades.XmlSignaturePolicyIdType) XmlSigPolicyQualifiersListType(xades4j.xml.bind.xades.XmlSigPolicyQualifiersListType)

Aggregations

JAXBElement (jakarta.xml.bind.JAXBElement)16 QName (javax.xml.namespace.QName)11 Test (org.junit.jupiter.api.Test)6 GET (jakarta.ws.rs.GET)3 Path (jakarta.ws.rs.Path)3 StringReader (java.io.StringReader)3 StreamSource (javax.xml.transform.stream.StreamSource)3 Tag (org.junit.jupiter.api.Tag)3 FileDataSource (jakarta.activation.FileDataSource)2 Produces (jakarta.ws.rs.Produces)2 GenericEntity (jakarta.ws.rs.core.GenericEntity)2 SseEventSink (jakarta.ws.rs.sse.SseEventSink)2 JAXBContext (jakarta.xml.bind.JAXBContext)2 JAXBException (jakarta.xml.bind.JAXBException)2 Unmarshaller (jakarta.xml.bind.Unmarshaller)2 Source (javax.xml.transform.Source)2 FlightType (org.springframework.oxm.jaxb.test.FlightType)2 XmlAnyType (xades4j.xml.bind.xades.XmlAnyType)2 XmlSigPolicyQualifiersListType (xades4j.xml.bind.xades.XmlSigPolicyQualifiersListType)2 DataHandler (jakarta.activation.DataHandler)1