Search in sources :

Example 16 with SequenceType

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;
}
Also used : CreateSequenceType(org.apache.cxf.ws.rm.v200702.CreateSequenceType) TerminateSequenceType(org.apache.cxf.ws.rm.v200702.TerminateSequenceType) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType)

Example 17 with SequenceType

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;
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) RMProperties(org.apache.cxf.ws.rm.RMProperties)

Example 18 with SequenceType

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
    }
}
Also used : SystemException(com.evolveum.midpoint.util.exception.SystemException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SequenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType) File(java.io.File) Test(org.testng.annotations.Test)

Example 19 with SequenceType

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));
        }
    }
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SequenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType) File(java.io.File) Session(org.hibernate.Session)

Example 20 with SequenceType

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));
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SequenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType) File(java.io.File) Test(org.testng.annotations.Test)

Aggregations

SequenceType (org.apache.cxf.ws.rm.v200702.SequenceType)33 CloseSequenceType (org.apache.cxf.ws.rm.v200702.CloseSequenceType)12 RMProperties (org.apache.cxf.ws.rm.RMProperties)11 CreateSequenceType (org.apache.cxf.ws.rm.v200702.CreateSequenceType)11 TerminateSequenceType (org.apache.cxf.ws.rm.v200702.TerminateSequenceType)11 SequenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType)9 Message (org.apache.cxf.message.Message)8 Identifier (org.apache.cxf.ws.rm.v200702.Identifier)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)6 IOException (java.io.IOException)6 Unmarshaller (javax.xml.bind.Unmarshaller)5 AckRequestedType (org.apache.cxf.ws.rm.v200702.AckRequestedType)5 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)4 Endpoint (org.apache.cxf.endpoint.Endpoint)4 Exchange (org.apache.cxf.message.Exchange)4 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)4 SequenceAcknowledgement (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)4 Test (org.junit.Test)4 Test (org.testng.annotations.Test)4 SystemException (com.evolveum.midpoint.util.exception.SystemException)3