use of org.apache.synapse.endpoints.AddressEndpoint in project wso2-synapse by wso2.
the class SynapseObserverTest method testSimpleObserver.
public void testSimpleObserver() {
SynapseConfiguration synapseConfig = new SynapseConfiguration();
synapseConfig.setAxisConfiguration(new AxisConfiguration());
synapseConfig.registerObserver(observer);
Endpoint epr = new AddressEndpoint();
epr.setName("endpoint1");
synapseConfig.addEndpoint(epr.getName(), epr);
assertItemAdded(epr.getName(), ENDPOINT);
synapseConfig.removeEndpoint(epr.getName());
assertItemRemoved(epr.getName(), ENDPOINT);
SequenceMediator seq = new SequenceMediator();
seq.setName("sequence1");
synapseConfig.addSequence(seq.getName(), seq);
assertItemAdded(seq.getName(), SEQUENCE);
synapseConfig.removeSequence(seq.getName());
assertItemRemoved(seq.getName(), SEQUENCE);
TemplateMediator template = new TemplateMediator();
template.setName("template1");
synapseConfig.addSequenceTemplate(template.getName(), template);
assertItemAdded(template.getName(), SEQUENCE_TEMPLATE);
synapseConfig.removeSequenceTemplate(template.getName());
assertItemRemoved(template.getName(), SEQUENCE_TEMPLATE);
Entry entry = new Entry();
entry.setKey("entry1");
synapseConfig.addEntry(entry.getKey(), entry);
assertItemAdded(entry.getKey(), ENTRY);
synapseConfig.removeEntry(entry.getKey());
assertItemRemoved(entry.getKey(), ENTRY);
ProxyService proxy = new ProxyService("proxy1");
synapseConfig.addProxyService(proxy.getName(), proxy);
assertItemAdded(proxy.getName(), PROXY);
synapseConfig.removeProxyService(proxy.getName());
assertItemRemoved(proxy.getName(), PROXY);
Startup startup = new StartUpController();
startup.setName("startup1");
synapseConfig.addStartup(startup);
assertItemAdded(startup.getName(), STARTUP);
synapseConfig.removeStartup(startup.getName());
assertItemRemoved(startup.getName(), STARTUP);
SynapseEventSource eventSrc = new SynapseEventSource("eventSrc1");
synapseConfig.addEventSource(eventSrc.getName(), eventSrc);
assertItemAdded(eventSrc.getName(), EVENT_SRC);
synapseConfig.removeEventSource(eventSrc.getName());
assertItemRemoved(eventSrc.getName(), EVENT_SRC);
PriorityExecutor exec = new PriorityExecutor();
exec.setName("exec1");
synapseConfig.addPriorityExecutor(exec.getName(), exec);
assertItemAdded(exec.getName(), EXECUTOR);
synapseConfig.removeExecutor(exec.getName());
assertItemRemoved(exec.getName(), EXECUTOR);
}
use of org.apache.synapse.endpoints.AddressEndpoint in project wso2-synapse by wso2.
the class CallMediatorSerializationTest method testSimpleFailoverCallSerialization.
public void testSimpleFailoverCallSerialization() {
String callConfig = "<call xmlns=\"http://ws.apache.org/ns/synapse\">" + "<endpoint>" + "<failover>" + "<endpoint>" + "<address uri=\"http://localhost:9001/services/Service1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "<endpoint>" + "<address uri=\"http://localhost:9002/services/Service1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "<endpoint>" + "<address uri=\"http://localhost:9003/services/Service1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "</failover>" + "</endpoint>" + "</call>";
OMElement config1 = createOMElement(callConfig);
CallMediator call1 = (CallMediator) factory.createMediator(config1, new Properties());
OMElement config2 = serializer.serializeMediator(null, call1);
CallMediator call2 = (CallMediator) factory.createMediator(config2, new Properties());
assertTrue("Top level endpoint should be a failover endpoint.", call2.getEndpoint() instanceof FailoverEndpoint);
FailoverEndpoint endpoint = (FailoverEndpoint) call2.getEndpoint();
List addresses = endpoint.getChildren();
assertEquals("There should be 3 leaf level address endpoints", addresses.size(), 3);
assertTrue("Leaf level endpoints should be address endpoints", addresses.get(0) instanceof AddressEndpoint);
assertTrue("Leaf level endpoints should be address endpoints", addresses.get(1) instanceof AddressEndpoint);
assertTrue("Leaf level endpoints should be address endpoints", addresses.get(2) instanceof AddressEndpoint);
AddressEndpoint addressEndpoint = (AddressEndpoint) addresses.get(0);
assertTrue("URI of address endpoint is not serialized properly", "http://localhost:9001/services/Service1".equals(addressEndpoint.getDefinition().getAddress()));
}
use of org.apache.synapse.endpoints.AddressEndpoint in project wso2-synapse by wso2.
the class CallMediatorSerializationTest method testNestedLoadbalanceFailoverCallSerialization.
public void testNestedLoadbalanceFailoverCallSerialization() {
String callConfig = "<call xmlns=\"http://ws.apache.org/ns/synapse\">" + "<endpoint>" + "<loadbalance>" + "<endpoint>" + "<address uri=\"http://localhost:9001/services/Service1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "<endpoint>" + "<failover>" + "<endpoint>" + "<address uri=\"http://localhost:9002/services/Service1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "<endpoint>" + "<address uri=\"http://localhost:9003/services/Service1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "</failover>" + "</endpoint>" + "</loadbalance>" + "</endpoint>" + "</call>";
OMElement config1 = createOMElement(callConfig);
CallMediator call1 = (CallMediator) factory.createMediator(config1, new Properties());
OMElement config2 = serializer.serializeMediator(null, call1);
CallMediator call2 = (CallMediator) factory.createMediator(config2, new Properties());
assertTrue("Top level endpoint should be a load balance endpoint.", call2.getEndpoint() instanceof LoadbalanceEndpoint);
LoadbalanceEndpoint loadbalanceEndpoint = (LoadbalanceEndpoint) call2.getEndpoint();
List children = loadbalanceEndpoint.getChildren();
assertEquals("Top level endpoint should have 2 child endpoints.", children.size(), 2);
assertTrue("First child should be a address endpoint", children.get(0) instanceof AddressEndpoint);
assertTrue("Second child should be a fail over endpoint", children.get(1) instanceof FailoverEndpoint);
FailoverEndpoint failoverEndpoint = (FailoverEndpoint) children.get(1);
List children2 = failoverEndpoint.getChildren();
assertEquals("Fail over endpoint should have 2 children.", children2.size(), 2);
assertTrue("Children of the fail over endpoint should be address endpoints.", children2.get(0) instanceof AddressEndpoint);
assertTrue("Children of the fail over endpoint should be address endpoints.", children2.get(1) instanceof AddressEndpoint);
}
use of org.apache.synapse.endpoints.AddressEndpoint in project wso2-synapse by wso2.
the class CallMediatorSerializationTest method testSimpleLoadbalanceCallSerialization.
public void testSimpleLoadbalanceCallSerialization() {
String callConfig = "<call xmlns=\"http://ws.apache.org/ns/synapse\">" + "<endpoint>" + "<loadbalance>" + "<endpoint>" + "<address uri=\"http://localhost:9001/services/Service1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "<endpoint>" + "<address uri=\"http://localhost:9002/services/Service1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "<endpoint>" + "<address uri=\"http://localhost:9003/services/Service1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "</loadbalance>" + "</endpoint>" + "</call>";
OMElement config1 = createOMElement(callConfig);
CallMediator call1 = (CallMediator) factory.createMediator(config1, new Properties());
OMElement config2 = serializer.serializeMediator(null, call1);
CallMediator call2 = (CallMediator) factory.createMediator(config2, new Properties());
assertTrue("Top level endpoint should be a load balance endpoint.", call2.getEndpoint() instanceof LoadbalanceEndpoint);
LoadbalanceEndpoint endpoint = (LoadbalanceEndpoint) call2.getEndpoint();
List addresses = endpoint.getChildren();
assertEquals("There should be 3 leaf level address endpoints", addresses.size(), 3);
assertTrue("Leaf level endpoints should be address endpoints", addresses.get(0) instanceof AddressEndpoint);
assertTrue("Leaf level endpoints should be address endpoints", addresses.get(1) instanceof AddressEndpoint);
assertTrue("Leaf level endpoints should be address endpoints", addresses.get(2) instanceof AddressEndpoint);
AddressEndpoint addressEndpoint = (AddressEndpoint) addresses.get(0);
assertTrue("URI of address endpoint is not serialized properly", "http://localhost:9001/services/Service1".equals(addressEndpoint.getDefinition().getAddress()));
}
use of org.apache.synapse.endpoints.AddressEndpoint in project wso2-synapse by wso2.
the class AddressEndpointFactory method createEndpoint.
@Override
protected Endpoint createEndpoint(OMElement epConfig, boolean anonymousEndpoint, Properties properties) {
AddressEndpoint addressEndpoint = new AddressEndpoint();
OMAttribute name = epConfig.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "name"));
if (name != null) {
addressEndpoint.setName(name.getAttributeValue());
}
OMElement addressElement = epConfig.getFirstChildWithName(new QName(SynapseConstants.SYNAPSE_NAMESPACE, "address"));
if (addressElement != null) {
EndpointDefinition definition = createEndpointDefinition(addressElement);
addressEndpoint.setDefinition(definition);
processAuditStatus(definition, addressEndpoint.getName(), addressElement);
}
processProperties(addressEndpoint, epConfig);
return addressEndpoint;
}
Aggregations