use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.
the class ColocUtilTest method testIsSameFaultInfo.
@Test
public void testIsSameFaultInfo() {
OperationInfo oi = control.createMock(OperationInfo.class);
boolean match = ColocUtil.isSameFaultInfo(null, null);
assertEquals("Should return true", true, match);
List<FaultInfo> fil1 = new ArrayList<>();
match = ColocUtil.isSameFaultInfo(fil1, null);
assertEquals("Should not find a match", false, match);
match = ColocUtil.isSameFaultInfo(null, fil1);
assertEquals("Should not find a match", false, match);
List<FaultInfo> fil2 = new ArrayList<>();
match = ColocUtil.isSameFaultInfo(fil1, fil2);
QName fn1 = new QName("A", "B");
QName fn2 = new QName("C", "D");
FaultInfo fi1 = new FaultInfo(fn1, null, oi);
fi1.setProperty(Class.class.getName(), PingMeFault.class);
fil1.add(fi1);
FaultInfo fi2 = new FaultInfo(fn2, null, oi);
fi2.setProperty(Class.class.getName(), FaultDetailT.class);
match = ColocUtil.isSameFaultInfo(fil1, fil2);
assertEquals("Should not find a match", false, match);
FaultInfo fi3 = new FaultInfo(fn2, null, oi);
fi3.setProperty(Class.class.getName(), PingMeFault.class);
fil2.add(fi3);
match = ColocUtil.isSameFaultInfo(fil1, fil2);
assertEquals("Should find a match", true, match);
}
use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.
the class CorbaStreamFaultInInterceptor method getFaultInfo.
protected FaultInfo getFaultInfo(OperationInfo opInfo, QName faultName) {
Iterator<FaultInfo> faults = opInfo.getFaults().iterator();
while (faults.hasNext()) {
FaultInfo fault = faults.next();
MessagePartInfo partInfo = fault.getMessageParts().get(0);
if (partInfo.isElement() && partInfo.getElementQName().getLocalPart().equals(faultName.getLocalPart())) {
return fault;
} else if (partInfo.getTypeQName().getLocalPart().equals(faultName.getLocalPart())) {
return fault;
}
}
return null;
}
use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.
the class CorbaStreamFaultOutInterceptor method getFaultMessagePartInfo.
protected MessagePartInfo getFaultMessagePartInfo(OperationInfo opInfo, QName faultName) {
Iterator<FaultInfo> faults = opInfo.getFaults().iterator();
while (faults.hasNext()) {
FaultInfo fault = faults.next();
MessagePartInfo partInfo = fault.getMessageParts().get(0);
if (partInfo.isElement() && partInfo.getElementQName().getLocalPart().equals(faultName.getLocalPart())) {
return partInfo;
} else if (partInfo.getTypeQName().getLocalPart().equals(faultName.getLocalPart())) {
return partInfo;
}
}
return null;
}
use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.
the class MAPAggregatorTest method setUpBindingOperationInfo.
private BindingOperationInfo setUpBindingOperationInfo(String nsuri, String opreq, String opresp, String opfault, Method method) {
ServiceInfo si = new ServiceInfo();
InterfaceInfo iinf = new InterfaceInfo(si, new QName(nsuri, method.getDeclaringClass().getSimpleName()));
OperationInfo opInfo = iinf.addOperation(new QName(nsuri, method.getName()));
opInfo.setProperty(Method.class.getName(), method);
opInfo.setInput(opreq, opInfo.createMessage(new QName(nsuri, opreq), Type.INPUT));
opInfo.setOutput(opresp, opInfo.createMessage(new QName(nsuri, opresp), Type.INPUT));
FaultInfo finfo = opInfo.addFault(new QName(nsuri, opfault), new QName(nsuri, opfault));
finfo.addMessagePart("fault");
return new TestBindingOperationInfo(opInfo);
}
use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.
the class PolicyAnnotationListener method addPolicies.
private void addPolicies(AbstractServiceFactoryBean factory, OperationInfo inf, Method m) {
if (m == null) {
return;
}
Policy p = m.getAnnotation(Policy.class);
Policies ps = m.getAnnotation(Policies.class);
if (p != null || ps != null) {
List<Policy> list = new ArrayList<>();
if (p != null) {
list.add(p);
}
if (ps != null) {
list.addAll(Arrays.asList(ps.value()));
}
ListIterator<Policy> it = list.listIterator();
while (it.hasNext()) {
p = it.next();
Policy.Placement place = p.placement();
if (place == Policy.Placement.DEFAULT) {
place = Policy.Placement.BINDING_OPERATION;
}
ServiceInfo service = inf.getInterface().getService();
Class<?> cls = m.getDeclaringClass();
switch(place) {
case PORT_TYPE_OPERATION:
addPolicy(inf, service, p, cls, inf.getName().getLocalPart() + "PortTypeOpPolicy");
it.remove();
break;
case PORT_TYPE_OPERATION_INPUT:
addPolicy(inf.getInput(), service, p, cls, inf.getName().getLocalPart() + "PortTypeOpInputPolicy");
it.remove();
break;
case PORT_TYPE_OPERATION_OUTPUT:
addPolicy(inf.getOutput(), service, p, cls, inf.getName().getLocalPart() + "PortTypeOpOutputPolicy");
it.remove();
break;
case PORT_TYPE_OPERATION_FAULT:
{
for (FaultInfo f : inf.getFaults()) {
if (p.faultClass().equals(f.getProperty(Class.class.getName()))) {
addPolicy(f, service, p, cls, f.getName().getLocalPart() + "PortTypeOpFaultPolicy");
it.remove();
}
}
break;
}
default:
}
}
if (!list.isEmpty()) {
List<Policy> stuff = CastUtils.cast((List<?>) inf.getProperty(EXTRA_POLICIES));
if (stuff != null) {
for (Policy p2 : list) {
if (!stuff.contains(p2)) {
stuff.add(p2);
}
}
} else {
inf.setProperty(EXTRA_POLICIES, list);
}
}
}
}
Aggregations