use of org.apache.axiom.soap.SOAPProcessingException in project webservices-axiom by apache.
the class TestGetBooleanAttributeInvalid method runTest.
@Override
protected void runTest() throws Throwable {
SOAPHeader header = soapFactory.getDefaultEnvelope().getOrCreateHeader();
SOAPHeaderBlock headerBlock = header.addHeaderBlock(new QName("urn:test", "test", "p"));
headerBlock.addAttribute(attribute.getName(spec), value, header.getNamespace());
try {
attribute.getAdapter(BooleanAttributeAccessor.class).getValue(headerBlock);
fail("Expected SOAPProcessingException");
} catch (SOAPProcessingException ex) {
// Expected
}
}
use of org.apache.axiom.soap.SOAPProcessingException in project webservices-axiom by apache.
the class TestWrongParent1 method runTest.
@Override
protected void runTest() throws Throwable {
SOAPFaultCode parent = soapFactory.createSOAPFaultCode();
SOAPFault fault = soapFactory.createSOAPFault();
try {
parent.addChild(fault);
fail("Expected SOAPProcessingException");
} catch (SOAPProcessingException ex) {
// Expected
}
}
use of org.apache.axiom.soap.SOAPProcessingException in project webservices-axiom by apache.
the class TestCreateSOAPModelBuilderMTOMContentTypeMismatch method runTest.
@Override
protected void runTest() throws Throwable {
final SOAPSample sample = SOAPSampleSet.NO_HEADER.getMessage(spec);
// Generate an MTOM message with the wrong content type
MimeMessage message = new MimeMessage((Session) null);
MimeMultipart mp = new MimeMultipart("related");
MimeBodyPart bp = new MimeBodyPart();
String contentID = "<" + UIDGenerator.generateContentId() + ">";
bp.setDataHandler(new DataHandler(new DataSource() {
@Override
public String getContentType() {
return "application/xop+xml; charset=\"" + sample.getEncoding() + "\"; type=\"" + spec.getAltSpec().getContentType() + "\"";
}
@Override
public InputStream getInputStream() throws IOException {
return sample.getInputStream();
}
@Override
public String getName() {
return null;
}
@Override
public OutputStream getOutputStream() {
throw new UnsupportedOperationException();
}
}));
bp.addHeader("Content-Transfer-Encoding", "binary");
bp.addHeader("Content-ID", contentID);
mp.addBodyPart(bp);
message.setContent(mp);
message.saveChanges();
ContentType contentType = new ContentType(message.getContentType()).toBuilder().setParameter("type", "application/xop+xml").setParameter("start", contentID).setParameter("start-info", spec.getAltSpec().getContentType()).build();
MemoryBlob blob = Blobs.createMemoryBlob();
OutputStream out = blob.getOutputStream();
mp.writeTo(out);
out.close();
// Now attempt to create an Axiom builder
try {
OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, MultipartBody.builder().setInputStream(blob.getInputStream()).setContentType(contentType).build());
fail("Expected SOAPProcessingException");
} catch (SOAPProcessingException ex) {
// Expected
}
}
use of org.apache.axiom.soap.SOAPProcessingException in project webservices-axiom by apache.
the class TestAddElementAfterBody method runTest.
@Override
protected void runTest() throws Throwable {
SOAPEnvelope env = soapFactory.createSOAPEnvelope();
if (header) {
soapFactory.createSOAPHeader(env);
}
soapFactory.createSOAPBody(env);
OMElement elem = env.getOMFactory().createOMElement(new QName("foo"));
if (spec.isAllowsElementsAfterBody()) {
env.addChild(elem);
} else {
try {
env.addChild(elem);
fail("Expected SOAPProcessingException");
} catch (SOAPProcessingException ex) {
// expected
}
}
}
use of org.apache.axiom.soap.SOAPProcessingException in project webservices-axiom by apache.
the class BadInputTest method runTest.
@Override
protected void runTest() throws Throwable {
try {
SOAPEnvelope soapEnvelope = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, BadInputTest.class.getClassLoader().getResourceAsStream("badsoap/" + file), null).getSOAPEnvelope();
OMTestUtils.walkThrough(soapEnvelope);
fail("this must failed gracefully with SOAPProcessingException");
} catch (SOAPProcessingException e) {
return;
}
}
Aggregations