Search in sources :

Example 51 with Axis2SynapseEnvironment

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"));
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) SynapseEnvironment(org.apache.synapse.core.SynapseEnvironment) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) Parameter(org.apache.axis2.description.Parameter) OMElement(org.apache.axiom.om.OMElement) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Test(org.junit.Test)

Example 52 with Axis2SynapseEnvironment

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"));
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) SynapseEnvironment(org.apache.synapse.core.SynapseEnvironment) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) Parameter(org.apache.axis2.description.Parameter) OMElement(org.apache.axiom.om.OMElement) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Test(org.junit.Test)

Example 53 with Axis2SynapseEnvironment

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);
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) SynapseEnvironment(org.apache.synapse.core.SynapseEnvironment) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) Parameter(org.apache.axis2.description.Parameter) OMElement(org.apache.axiom.om.OMElement) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Test(org.junit.Test)

Example 54 with Axis2SynapseEnvironment

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);
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) HashMap(java.util.HashMap) RabbitMQStore(org.apache.synapse.message.store.impl.rabbitmq.RabbitMQStore) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) BeforeClass(org.junit.BeforeClass)

Example 55 with Axis2SynapseEnvironment

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;
}
Also used : Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) LoadbalanceEndpoint(org.apache.synapse.endpoints.LoadbalanceEndpoint) MediatorProperty(org.apache.synapse.mediators.MediatorProperty) AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) Endpoint(org.apache.synapse.endpoints.Endpoint) LoadbalanceEndpoint(org.apache.synapse.endpoints.LoadbalanceEndpoint) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) SynapseEnvironment(org.apache.synapse.core.SynapseEnvironment) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration)

Aggregations

Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)81 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)64 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)57 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)49 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)43 Test (org.junit.Test)38 OMElement (org.apache.axiom.om.OMElement)30 Parameter (org.apache.axis2.description.Parameter)26 MessageContext (org.apache.synapse.MessageContext)23 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)21 Properties (java.util.Properties)14 TestMessageContext (org.apache.synapse.TestMessageContext)13 Mediator (org.apache.synapse.Mediator)12 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)10 ArrayList (java.util.ArrayList)8 AddressEndpoint (org.apache.synapse.endpoints.AddressEndpoint)7 Endpoint (org.apache.synapse.endpoints.Endpoint)7 HashMap (java.util.HashMap)5 OMDocument (org.apache.axiom.om.OMDocument)4 EndpointReference (org.apache.axis2.addressing.EndpointReference)4