Search in sources :

Example 1 with FixedSizeQueue

use of org.apache.synapse.commons.executors.queues.FixedSizeQueue in project wso2-synapse by wso2.

the class PriorityExecutorSerializerTest method testSerialize.

/**
 * Test serializing a PriorityExecutor created with FixedSizeQueues
 */
public void testSerialize() {
    PriorityExecutor priorityExecutor = new PriorityExecutor();
    priorityExecutor.setName("executor1");
    List<InternalQueue> internalQueueList = new ArrayList<>();
    internalQueueList.add(new FixedSizeQueue(10, 10));
    internalQueueList.add(new FixedSizeQueue(5, 25));
    MultiPriorityBlockingQueue multiPriorityBlockingQueue = new MultiPriorityBlockingQueue(internalQueueList, true, new PRRNextQueueAlgorithm());
    priorityExecutor.setQueue(multiPriorityBlockingQueue);
    OMElement element = PriorityExecutorSerializer.serialize(null, priorityExecutor, "http://ws.apache.org/ns/synapse");
    assertEquals("Invalid serialization of PriorityExecutor", "<priorityExecutor xmlns=\"http://ws.apache.org/ns/synapse\" name=\"executor1\">" + "<queues><queue size=\"10\" priority=\"10\" /><queue size=\"25\" priority=\"5\" /></queues>" + "<threads max=\"100\" core=\"20\" keep-alive=\"5\" />" + "</priorityExecutor>", element.toString());
}
Also used : FixedSizeQueue(org.apache.synapse.commons.executors.queues.FixedSizeQueue) PRRNextQueueAlgorithm(org.apache.synapse.commons.executors.PRRNextQueueAlgorithm) ArrayList(java.util.ArrayList) OMElement(org.apache.axiom.om.OMElement) PriorityExecutor(org.apache.synapse.commons.executors.PriorityExecutor) MultiPriorityBlockingQueue(org.apache.synapse.commons.executors.MultiPriorityBlockingQueue) InternalQueue(org.apache.synapse.commons.executors.InternalQueue)

Example 2 with FixedSizeQueue

use of org.apache.synapse.commons.executors.queues.FixedSizeQueue in project wso2-synapse by wso2.

the class PriorityExecutorSerializerTest method testSerializeGivenParentElement.

/**
 * Test serializing a PriorityExecutor when parent element is defined
 * @throws XMLStreamException
 */
public void testSerializeGivenParentElement() throws XMLStreamException {
    OMElement parentElement = AXIOMUtil.stringToOM("<definitions></definitions>");
    PriorityExecutor priorityExecutor = new PriorityExecutor();
    priorityExecutor.setName("executor1");
    List<InternalQueue> internalQueueList = new ArrayList<>();
    internalQueueList.add(new FixedSizeQueue(10, 10));
    internalQueueList.add(new FixedSizeQueue(5, 25));
    MultiPriorityBlockingQueue multiPriorityBlockingQueue = new MultiPriorityBlockingQueue(internalQueueList, true, new PRRNextQueueAlgorithm());
    priorityExecutor.setQueue(multiPriorityBlockingQueue);
    PriorityExecutorSerializer.serialize(parentElement, priorityExecutor, "http://ws.apache.org/ns/synapse");
    assertEquals("Invalid serialization of PriorityExecutor", "<definitions>" + "<priorityExecutor xmlns=\"http://ws.apache.org/ns/synapse\" name=\"executor1\">" + "<queues><queue size=\"10\" priority=\"10\" /><queue size=\"25\" priority=\"5\" /></queues>" + "<threads max=\"100\" core=\"20\" keep-alive=\"5\" />" + "</priorityExecutor>" + "</definitions>", parentElement.toString());
}
Also used : FixedSizeQueue(org.apache.synapse.commons.executors.queues.FixedSizeQueue) PRRNextQueueAlgorithm(org.apache.synapse.commons.executors.PRRNextQueueAlgorithm) ArrayList(java.util.ArrayList) OMElement(org.apache.axiom.om.OMElement) PriorityExecutor(org.apache.synapse.commons.executors.PriorityExecutor) MultiPriorityBlockingQueue(org.apache.synapse.commons.executors.MultiPriorityBlockingQueue) InternalQueue(org.apache.synapse.commons.executors.InternalQueue)

Aggregations

ArrayList (java.util.ArrayList)2 OMElement (org.apache.axiom.om.OMElement)2 InternalQueue (org.apache.synapse.commons.executors.InternalQueue)2 MultiPriorityBlockingQueue (org.apache.synapse.commons.executors.MultiPriorityBlockingQueue)2 PRRNextQueueAlgorithm (org.apache.synapse.commons.executors.PRRNextQueueAlgorithm)2 PriorityExecutor (org.apache.synapse.commons.executors.PriorityExecutor)2 FixedSizeQueue (org.apache.synapse.commons.executors.queues.FixedSizeQueue)2