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);
}
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);
}
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;
}
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);
}
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;
}
Aggregations