use of org.apache.cxf.ws.policy.PolicyException in project cxf by apache.
the class ExternalAttachmentProviderTest method testReadDocumentNotExisting.
@Test
public void testReadDocumentNotExisting() throws MalformedURLException {
ExternalAttachmentProvider eap = new ExternalAttachmentProvider();
URL url = ExternalAttachmentProviderTest.class.getResource("resources/attachments1.xml");
String uri = url.toExternalForm();
uri = uri.replaceAll("attachments1.xml", "attachments0.xml");
eap.setLocation(new UrlResource(uri));
try {
eap.readDocument();
fail("Expected PolicyException not thrown.");
} catch (PolicyException ex) {
assertTrue(ex.getCause() instanceof FileNotFoundException);
}
}
use of org.apache.cxf.ws.policy.PolicyException in project cxf by apache.
the class Wsdl11AttachmentPolicyProviderTest method testElementPolicies.
@Test
public void testElementPolicies() throws WSDLException {
Policy p;
// no extensions
p = app.getElementPolicy(services[0]);
assertTrue(p == null || p.isEmpty());
// extensions not of type Policy or PolicyReference
p = app.getElementPolicy(services[1]);
assertTrue(p == null || p.isEmpty());
// one extension of type Policy, without assertion builder
try {
p = app.getElementPolicy(services[2]);
fail("Expected PolicyException not thrown.");
} catch (PolicyException ex) {
// expected
}
// one extension of type Policy
p = app.getElementPolicy(services[3]);
assertNotNull(p);
assertTrue(!p.isEmpty());
verifyAssertionsOnly(p, 2);
// two extensions of type Policy
p = app.getElementPolicy(services[4]);
assertNotNull(p);
assertTrue(!p.isEmpty());
verifyAssertionsOnly(p, 3);
EndpointInfo ei = new EndpointInfo();
assertTrue(app.getElementPolicy(ei) == null);
}
use of org.apache.cxf.ws.policy.PolicyException in project cxf by apache.
the class Wsdl11AttachmentPolicyProviderTest method testResolveLocal.
@Test
public void testResolveLocal() {
Policy ep;
// service has one extension of type PolicyReference, reference can be resolved locally
ep = app.getElementPolicy(services[16]);
assertNotNull(ep);
verifyAssertionsOnly(ep, 2);
// port has one extension of type PolicyReference, reference cannot be resolved locally
try {
app.getElementPolicy(endpoints[16]);
fail("Expected PolicyException not thrown.");
} catch (PolicyException ex) {
// expected
}
}
use of org.apache.cxf.ws.policy.PolicyException in project cxf by apache.
the class Wsdl11AttachmentPolicyProviderTest method testEffectiveServicePolicies.
@Test
public void testEffectiveServicePolicies() throws WSDLException {
Policy p;
Policy ep;
// no extensions
ep = app.getEffectivePolicy(services[0], null);
assertTrue(ep == null || ep.isEmpty());
p = app.getElementPolicy(services[0]);
assertTrue(p == null || p.isEmpty());
// extensions not of type Policy or PolicyReference
ep = app.getEffectivePolicy(services[1], null);
assertTrue(ep == null || ep.isEmpty());
// one extension of type Policy, without assertion builder
try {
ep = app.getEffectivePolicy(services[2], null);
fail("Expected PolicyException not thrown.");
} catch (PolicyException ex) {
// expected
}
// one extension of type Policy
ep = app.getEffectivePolicy(services[3], null);
assertNotNull(ep);
assertTrue(!ep.isEmpty());
verifyAssertionsOnly(ep, 2);
p = app.getElementPolicy(services[3]);
assertTrue(PolicyComparator.compare(p, ep));
// two extensions of type Policy
ep = app.getEffectivePolicy(services[4], null);
assertNotNull(ep);
assertTrue(!ep.isEmpty());
verifyAssertionsOnly(ep, 3);
p = app.getElementPolicy(services[4]);
assertTrue(PolicyComparator.compare(p, ep));
}
use of org.apache.cxf.ws.policy.PolicyException in project cxf by apache.
the class AbstractTokenInterceptor method policyNotAsserted.
protected void policyNotAsserted(AbstractToken assertion, Exception reason, SoapMessage message) {
if (assertion == null) {
return;
}
AssertionInfoMap aim = message.get(AssertionInfoMap.class);
Collection<AssertionInfo> ais = aim.get(assertion.getName());
if (ais != null) {
for (AssertionInfo ai : ais) {
if (ai.getAssertion() == assertion) {
ai.setNotAsserted(reason.getMessage());
}
}
}
throw new PolicyException(reason);
}
Aggregations