use of org.apache.neethi.builders.PrimitiveAssertion in project cxf by apache.
the class RMPolicyUtilities method getRMConfiguration.
/**
* Returns an RMAssertion that is compatible with the default value and all RMAssertions pertaining to the
* message (can never be null).
*
* @param defaultValue the default value (non-<code>null</code>)
* @param message the message
* @return the compatible RMAssertion
*/
public static RMConfiguration getRMConfiguration(RMConfiguration defaultValue, Message message) {
RMConfiguration compatible = defaultValue;
Collection<AssertionInfo> ais = collectRMAssertions(message.get(AssertionInfoMap.class));
for (AssertionInfo ai : ais) {
if (ai.getAssertion() instanceof JaxbAssertion<?>) {
RMAssertion rma = (RMAssertion) ((JaxbAssertion<?>) ai.getAssertion()).getData();
compatible = intersect(rma, compatible);
} else if (ai.getAssertion() instanceof PrimitiveAssertion) {
PrimitiveAssertion assertion = (PrimitiveAssertion) ai.getAssertion();
if (RM11Constants.WSRMP_NAMESPACE_URI.equals(assertion.getName().getNamespaceURI())) {
compatible = intersect(assertion, compatible);
}
}
}
return compatible;
}
use of org.apache.neethi.builders.PrimitiveAssertion in project cxf by apache.
the class AssertionBuilderRegistryImplTest method testBuildUnknownAssertion.
@Test
public void testBuildUnknownAssertion() {
Bus bus = control.createMock(Bus.class);
PolicyBuilder builder = control.createMock(PolicyBuilder.class);
EasyMock.expect(bus.getExtension(PolicyBuilder.class)).andReturn(builder).anyTimes();
AssertionBuilderRegistryImpl reg = new AssertionBuilderRegistryImpl() {
protected void loadDynamic() {
// nothing
}
};
reg.setIgnoreUnknownAssertions(false);
Element[] elems = new Element[11];
QName[] qnames = new QName[11];
for (int i = 0; i < 11; i++) {
qnames[i] = new QName("http://my.company.com", "type" + Integer.toString(i));
elems[i] = control.createMock(Element.class);
EasyMock.expect(elems[i].getNamespaceURI()).andReturn(qnames[i].getNamespaceURI()).anyTimes();
EasyMock.expect(elems[i].getLocalName()).andReturn(qnames[i].getLocalPart()).anyTimes();
}
control.replay();
reg.setBus(bus);
assertFalse(reg.isIgnoreUnknownAssertions());
try {
reg.build(elems[0]);
fail("Expected PolicyException not thrown.");
} catch (PolicyException ex) {
assertEquals("NO_ASSERTIONBUILDER_EXC", ex.getCode());
}
reg.setIgnoreUnknownAssertions(true);
assertTrue(reg.isIgnoreUnknownAssertions());
for (int i = 0; i < 10; i++) {
Assertion assertion = reg.build(elems[i]);
assertTrue("Not a PrimitiveAsertion: " + assertion.getClass().getName(), assertion instanceof PrimitiveAssertion);
}
for (int i = 9; i >= 0; i--) {
assertTrue(reg.build(elems[i]) instanceof PrimitiveAssertion);
}
assertTrue(reg.build(elems[10]) instanceof PrimitiveAssertion);
}
Aggregations