use of org.apache.cxf.ws.rm.v200702.Expires in project cxf by apache.
the class ServantTest method verifyCreateSequenceExpiresSetAtBoth.
private void verifyCreateSequenceExpiresSetAtBoth(Servant servant, RMManager manager) throws SequenceFault {
DestinationPolicyType dp = RMMANGER_FACTORY.createDestinationPolicyType();
AcksPolicyType ap = RMMANGER_FACTORY.createAcksPolicyType();
dp.setAcksPolicy(ap);
dp.setSequenceExpiration(DURATION_SHORT);
manager.setDestinationPolicy(dp);
Expires expires = new Expires();
expires.setValue(DURATION_VERY_SHORT);
Message message = createTestCreateSequenceMessage(expires, null);
CreateSequenceResponseType csr = (CreateSequenceResponseType) servant.createSequence(message);
Expires expires2 = csr.getExpires();
assertNotNull(expires2);
assertEquals(DURATION_VERY_SHORT, expires2.getValue());
}
use of org.apache.cxf.ws.rm.v200702.Expires in project cxf by apache.
the class ServantTest method verifyCreateSequenceExpiresSetAtSource.
private void verifyCreateSequenceExpiresSetAtSource(Servant servant, RMManager manager) throws SequenceFault {
DestinationPolicyType dp = RMMANGER_FACTORY.createDestinationPolicyType();
AcksPolicyType ap = RMMANGER_FACTORY.createAcksPolicyType();
dp.setAcksPolicy(ap);
manager.setDestinationPolicy(dp);
Expires expires = new Expires();
expires.setValue(DURATION_SHORT);
Message message = createTestCreateSequenceMessage(expires, null);
CreateSequenceResponseType csr = (CreateSequenceResponseType) servant.createSequence(message);
Expires expires2 = csr.getExpires();
assertNotNull(expires2);
assertEquals(DURATION_SHORT, expires2.getValue());
}
use of org.apache.cxf.ws.rm.v200702.Expires in project cxf by apache.
the class SourceSequenceTest method testSetExpires.
@Test
public void testSetExpires() {
SourceSequence seq = new SourceSequence(id, ProtocolVariation.RM10WSA200408);
Expires expires = factory.createExpires();
seq.setExpires(expires);
assertFalse(seq.isExpired());
Duration d = DatatypeFactory.PT0S;
expires.setValue(d);
seq.setExpires(expires);
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
assertFalse(seq.isExpired());
}
d = DatatypeFactory.createDuration("PT1S");
expires.setValue(d);
seq.setExpires(expires);
assertFalse(seq.isExpired());
d = DatatypeFactory.createDuration("-PT1S");
expires.setValue(d);
seq.setExpires(expires);
assertTrue(seq.isExpired());
}
use of org.apache.cxf.ws.rm.v200702.Expires in project cxf by apache.
the class Proxy method createSequence.
public CreateSequenceResponseType createSequence(EndpointReferenceType defaultAcksTo, RelatesToType relatesTo, boolean isServer, final ProtocolVariation protocol, final Exchange exchange, Map<String, Object> context) throws RMException {
this.sequenceContext = context;
SourcePolicyType sp = reliableEndpoint.getManager().getSourcePolicy();
CreateSequenceType create = new CreateSequenceType();
String address = sp.getAcksTo();
final EndpointReferenceType acksTo;
if (null != address) {
acksTo = RMUtils.createReference(address);
} else {
acksTo = defaultAcksTo;
}
create.setAcksTo(acksTo);
Duration d = sp.getSequenceExpiration();
if (null != d) {
Expires expires = new Expires();
expires.setValue(d);
create.setExpires(expires);
}
if (sp.isIncludeOffer()) {
OfferType offer = new OfferType();
d = sp.getOfferedSequenceExpiration();
if (null != d) {
Expires expires = new Expires();
expires.setValue(d);
offer.setExpires(expires);
}
offer.setIdentifier(reliableEndpoint.getSource().generateSequenceIdentifier());
offer.setEndpoint(acksTo);
create.setOffer(offer);
setOfferedIdentifier(offer);
}
InterfaceInfo ii = reliableEndpoint.getEndpoint(protocol).getEndpointInfo().getService().getInterface();
EncoderDecoder codec = protocol.getCodec();
RMConstants constants = codec.getConstants();
final OperationInfo oi = isServer ? ii.getOperation(constants.getCreateSequenceOnewayOperationName()) : ii.getOperation(constants.getCreateSequenceOperationName());
final Object send = codec.convertToSend(create);
if (isServer) {
LOG.fine("sending CreateSequenceRequest from server side");
Runnable r = new Runnable() {
public void run() {
try {
invoke(oi, protocol, new Object[] { send }, null, exchange);
} catch (RMException ex) {
// already logged
}
}
};
Executor ex = reliableEndpoint.getApplicationEndpoint().getExecutor();
if (ex == null) {
ex = SynchronousExecutor.getInstance();
}
ex.execute(r);
return null;
}
Object resp = invoke(oi, protocol, new Object[] { send }, context, exchange);
return codec.convertReceivedCreateSequenceResponse(resp);
}
Aggregations