use of org.apache.synapse.core.axis2.Axis2SynapseEnvironment in project wso2-synapse by wso2.
the class APIDeployerTest method testUndeploy.
/**
* Test undeploying an API
*
* @throws Exception
*/
@Test
public void testUndeploy() throws Exception {
String inputXML = "<api name=\"TestAPI\" context=\"/order\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "<resource url-mapping=\"/list\" inSequence=\"seq1\" outSequence=\"seq2\" xmlns=\"http://ws.apache.org/ns/synapse\"/>" + "</api>";
OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
APIDeployer apiDeployer = new APIDeployer();
SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration();
ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration);
SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration);
axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_ENV, synapseEnvironment));
axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_CONFIG, synapseConfiguration));
cfgCtx.setAxisConfiguration(axisConfiguration);
apiDeployer.init(cfgCtx);
apiDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
Assert.assertNotNull("API not deployed!", synapseConfiguration.getAPI("TestAPI"));
apiDeployer.undeploySynapseArtifact("TestAPI");
Assert.assertNull("Api cannot be undeployed!", synapseConfiguration.getAPI("TestAPI"));
}
use of org.apache.synapse.core.axis2.Axis2SynapseEnvironment in project wso2-synapse by wso2.
the class EndpointDeployerTest method testUndeploy.
/**
* Test undeploying an endpoint
*
* @throws Exception
*/
@Test
public void testUndeploy() throws Exception {
String inputXML = "<endpoint name = \"sampleEP\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "<address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" >" + "</address>" + "</endpoint>";
OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
EndpointDeployer endpointDeployer = new EndpointDeployer();
SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration();
ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration);
SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration);
axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_ENV, synapseEnvironment));
axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_CONFIG, synapseConfiguration));
cfgCtx.setAxisConfiguration(axisConfiguration);
endpointDeployer.init(cfgCtx);
endpointDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
Assert.assertNotNull("Endpoint not deployed!", synapseConfiguration.getEndpoint("sampleEP"));
endpointDeployer.undeploySynapseArtifact("sampleEP");
Assert.assertNull("Endpoint cannot be undeployed", synapseConfiguration.getEndpoint("sampleEP"));
}
use of org.apache.synapse.core.axis2.Axis2SynapseEnvironment in project wso2-synapse by wso2.
the class EndpointDeployerTest method testUpdate.
/**
* Test updating an endpoint
*
* @throws Exception
*/
@Test
public void testUpdate() throws Exception {
String inputXML = "<endpoint name = \"sampleEP\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "<address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" >" + "</address>" + "</endpoint>";
OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
EndpointDeployer endpointDeployer = new EndpointDeployer();
SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration();
ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration);
SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration);
axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_ENV, synapseEnvironment));
axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_CONFIG, synapseConfiguration));
cfgCtx.setAxisConfiguration(axisConfiguration);
endpointDeployer.init(cfgCtx);
endpointDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
String inputUpdateXML = "<endpoint name = \"sampleUpdatedEP\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "<address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" >" + "</address>" + "</endpoint>";
OMElement updatedElement = AXIOMUtil.stringToOM(inputUpdateXML);
String response = endpointDeployer.updateSynapseArtifact(updatedElement, "sampleUpdateFile", "sampleEP", null);
Assert.assertEquals("Endpoint not updated!", "sampleUpdatedEP", response);
}
use of org.apache.synapse.core.axis2.Axis2SynapseEnvironment in project wso2-synapse by wso2.
the class RabbitMQStoreTest method init.
@BeforeClass
public static void init() throws NoSuchFieldException {
rabbitMQStore = new RabbitMQStore();
// Accessing private variable using reflection
connectionFactory = RabbitMQStore.class.getDeclaredField("connectionFactory");
connectionFactory.setAccessible(true);
// Setting parameters of the RabbitMQStore
Map<String, Object> temp = new HashMap<>();
temp.put(RabbitMQStore.USERNAME, USERNAME);
temp.put(RabbitMQStore.PASSWORD, PASSWORD);
temp.put(RabbitMQStore.HOST_NAME, HOST);
temp.put(RabbitMQStore.HOST_PORT, PORT);
temp.put(RabbitMQStore.VIRTUAL_HOST, VIRTUAL_HOST);
temp.put(RabbitMQStore.QUEUE_NAME, QUEUE);
rabbitMQStore.setParameters(temp);
AxisConfiguration axisConfiguration = new AxisConfiguration();
configurationContext = new ConfigurationContext(axisConfiguration);
SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
Axis2SynapseEnvironment env = new Axis2SynapseEnvironment(configurationContext, synapseConfiguration);
rabbitMQStore.init(env);
}
use of org.apache.synapse.core.axis2.Axis2SynapseEnvironment in project wso2-synapse by wso2.
the class WeightedRRLCAlgorithmTest method createLoadBalanceEndpoint.
private LoadbalanceEndpoint createLoadBalanceEndpoint() {
LoadbalanceEndpoint loadbalanceEndpoint = new LoadbalanceEndpoint();
List<Endpoint> endpoints = createEndpoints();
WeightedRRLCAlgorithm algorithm = new WeightedRRLCAlgorithm();
MediatorProperty property = new MediatorProperty();
property.setName(WeightedRRLCAlgorithm.LB_WEIGHTED_RRLC_ROUNDS_PER_RECAL);
property.setValue("2");
loadbalanceEndpoint.addProperty(property);
algorithm.setEndpoints(endpoints);
algorithm.setLoadBalanceEndpoint(loadbalanceEndpoint);
loadbalanceEndpoint.setChildren(endpoints);
loadbalanceEndpoint.setAlgorithm(algorithm);
SynapseEnvironment env = new Axis2SynapseEnvironment(new ConfigurationContext(new AxisConfiguration()), new SynapseConfiguration());
loadbalanceEndpoint.init(env);
return loadbalanceEndpoint;
}
Aggregations