use of org.apache.cxf.ws.rm.v200702.SequenceType in project cxf by apache.
the class VersionTransformer method convert.
/**
* Convert 200502 wsrm:SequenceType with 200508 WS-Addressing namespace to internal form.
*
* @param exposed (non-<code>null</code>)
* @return converted
*/
public static SequenceType convert(org.apache.cxf.ws.rm.v200502wsa15.SequenceType exposed) {
SequenceType internal = new SequenceType();
internal.setIdentifier(convert(exposed.getIdentifier()));
internal.setMessageNumber(exposed.getMessageNumber());
addAll(exposed.getAny(), internal.getAny());
putAll(exposed.getOtherAttributes(), internal.getOtherAttributes());
return internal;
}
use of org.apache.cxf.ws.rm.v200702.SequenceType in project cxf by apache.
the class RetransmissionQueueImplTest method setUpSequenceType.
private SequenceType setUpSequenceType(Message message, String sid, Long messageNumber) {
RMProperties rmps = createMock(RMProperties.class);
if (message != null) {
message.get(RMMessageConstants.RM_PROPERTIES_OUTBOUND);
EasyMock.expectLastCall().andReturn(rmps);
}
properties.add(rmps);
SequenceType sequence = createMock(SequenceType.class);
if (message != null) {
rmps.getSequence();
EasyMock.expectLastCall().andReturn(sequence);
}
if (messageNumber != null) {
EasyMock.expect(sequence.getMessageNumber()).andReturn(messageNumber).anyTimes();
}
Identifier id = createMock(Identifier.class);
EasyMock.expect(sequence.getIdentifier()).andReturn(id).anyTimes();
EasyMock.expect(id.getValue()).andReturn(sid).anyTimes();
identifiers.add(id);
sequences.add(sequence);
return sequence;
}
use of org.apache.cxf.ws.rm.v200702.SequenceType in project midpoint by Evolveum.
the class SequenceTest method test020_ReachingLimit.
@Test
public void test020_ReachingLimit() throws Exception {
OperationResult result = new OperationResult("test020_ReachingLimit");
final File file = new File(TEST_DIR + "sequence-bound.xml");
PrismObject<SequenceType> sequence = prismContext.parseObject(file);
String oid = repositoryService.addObject(sequence, null, result);
assertEquals(0L, repositoryService.advanceSequence(oid, result));
assertEquals(1L, repositoryService.advanceSequence(oid, result));
assertEquals(2L, repositoryService.advanceSequence(oid, result));
assertEquals(3L, repositoryService.advanceSequence(oid, result));
assertEquals(4L, repositoryService.advanceSequence(oid, result));
assertEquals(5L, repositoryService.advanceSequence(oid, result));
assertEquals(6L, repositoryService.advanceSequence(oid, result));
assertEquals(7L, repositoryService.advanceSequence(oid, result));
assertEquals(8L, repositoryService.advanceSequence(oid, result));
assertEquals(9L, repositoryService.advanceSequence(oid, result));
try {
long value = repositoryService.advanceSequence(oid, result);
fail("Expected an exception, got value of " + value);
} catch (SystemException e) {
// ok
}
}
use of org.apache.cxf.ws.rm.v200702.SequenceType in project midpoint by Evolveum.
the class SequenceTest method concurrencyUniversal.
private void concurrencyUniversal(String name, String sequenceFileName, long duration, WorkerThread[] workerThreads, boolean alwaysOrder) throws Exception {
Session session = getFactory().openSession();
session.doWork(connection -> System.out.println(">>>>" + connection.getTransactionIsolation()));
session.close();
final File file = new File(TEST_DIR + sequenceFileName);
PrismObject<SequenceType> sequence = prismContext.parseObject(file);
sequence.asObjectable().setName(new PolyStringType(name));
OperationResult result = new OperationResult("Concurrency Test");
String oid = repositoryService.addObject(sequence, null, result);
logger.info("*** Object added: " + oid + " ***");
logger.info("*** Starting modifier threads ***");
for (WorkerThread t : workerThreads) {
t.setOid(oid);
t.start();
}
logger.info("*** Waiting " + duration + " ms ***");
Thread.sleep(duration);
for (WorkerThread t : workerThreads) {
t.stop = true;
}
long endTime = System.currentTimeMillis() + STOP_TIMEOUT;
for (; ; ) {
long remaining = endTime - System.currentTimeMillis();
if (remaining <= 0) {
break;
}
for (WorkerThread t : workerThreads) {
t.join(remaining);
remaining = endTime - System.currentTimeMillis();
if (remaining <= 0) {
break;
}
}
}
for (WorkerThread t : workerThreads) {
logger.info("Worker thread {} finished after {} iterations with result: {}", t.id, t.counter, t.threadResult != null ? t.threadResult : "OK");
}
for (WorkerThread t : workerThreads) {
if (t.threadResult != null) {
throw new AssertionError("Worker thread " + t.id + " finished with an exception: " + t.threadResult, t.threadResult);
}
}
List<Long> allValues = new ArrayList<>();
for (WorkerThread t : workerThreads) {
allValues.addAll(t.values);
}
if (alwaysOrder || workerThreads.length > 1) {
Collections.sort(allValues);
}
logger.trace("Checking a list of {} values", allValues.size());
for (int i = 0; i < allValues.size(); i++) {
if (allValues.get(i) != i) {
logger.error("Incorrect value at position {}: {}", i, allValues.get(i));
for (WorkerThread t : workerThreads) {
logger.info("Thread {}: {}", t.id, t.values);
}
fail("Incorrect value at position " + i + ": " + allValues.get(i));
}
}
}
use of org.apache.cxf.ws.rm.v200702.SequenceType in project midpoint by Evolveum.
the class SequenceTest method test010_ReturningValues.
@Test
public void test010_ReturningValues() throws Exception {
OperationResult result = new OperationResult("test010_ReturningValues");
final File file = new File(TEST_DIR + "sequence-bound-returned-wrapped.xml");
PrismObject<SequenceType> sequence = prismContext.parseObject(file);
String oid = repositoryService.addObject(sequence, null, result);
assertEquals(0L, repositoryService.advanceSequence(oid, result));
assertEquals(1L, repositoryService.advanceSequence(oid, result));
assertEquals(2L, repositoryService.advanceSequence(oid, result));
assertEquals(3L, repositoryService.advanceSequence(oid, result));
assertEquals(4L, repositoryService.advanceSequence(oid, result));
repositoryService.returnUnusedValuesToSequence(oid, Arrays.asList(2L, 4L), result);
assertEquals(2L, repositoryService.advanceSequence(oid, result));
assertEquals(4L, repositoryService.advanceSequence(oid, result));
assertEquals(5L, repositoryService.advanceSequence(oid, result));
assertEquals(6L, repositoryService.advanceSequence(oid, result));
repositoryService.returnUnusedValuesToSequence(oid, null, result);
repositoryService.returnUnusedValuesToSequence(oid, new ArrayList<>(), result);
repositoryService.returnUnusedValuesToSequence(oid, Collections.singletonList(6L), result);
assertEquals(6L, repositoryService.advanceSequence(oid, result));
repositoryService.returnUnusedValuesToSequence(oid, Arrays.asList(0L, 1L, 2L, 3L, 4L, 5L, 6L), // only 0-4 will be returned
result);
assertEquals(0L, repositoryService.advanceSequence(oid, result));
assertEquals(1L, repositoryService.advanceSequence(oid, result));
assertEquals(2L, repositoryService.advanceSequence(oid, result));
assertEquals(3L, repositoryService.advanceSequence(oid, result));
assertEquals(4L, repositoryService.advanceSequence(oid, result));
assertEquals(7L, repositoryService.advanceSequence(oid, result));
assertEquals(8L, repositoryService.advanceSequence(oid, result));
assertEquals(9L, repositoryService.advanceSequence(oid, result));
assertEquals(0L, repositoryService.advanceSequence(oid, result));
assertEquals(1L, repositoryService.advanceSequence(oid, result));
assertEquals(2L, repositoryService.advanceSequence(oid, result));
}
Aggregations