Skip to content

Commit 35cce2a

Browse files
Merge pull request #2418 from SanojPunchihewa/bug-fixes-api
Fix connector deployment issue in unit tests
2 parents 2f14d83 + f474706 commit 35cce2a

File tree

7 files changed

+69
-6
lines changed

7 files changed

+69
-6
lines changed

modules/core/src/main/java/org/apache/synapse/config/xml/ClassMediatorFactory.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.synapse.Mediator;
2626
import org.apache.synapse.SynapseException;
2727
import org.apache.synapse.SynapseConstants;
28+
import org.apache.synapse.mediators.AbstractMediator;
2829
import org.apache.synapse.mediators.ext.ClassMediator;
2930
import org.apache.synapse.mediators.v2.Utils;
3031
import org.apache.synapse.mediators.v2.ext.AbstractClassMediator;
@@ -118,6 +119,9 @@ public Mediator createSpecificMediator(OMElement elem, Properties properties) {
118119

119120
try {
120121
mediator = (Mediator) clazz.newInstance();
122+
if (mediator instanceof AbstractMediator && FactoryUtils.isVersionedDeployment(properties)) {
123+
((AbstractMediator) mediator).setArtifactIdentifier(properties.getProperty(SynapseConstants.SYNAPSE_ARTIFACT_IDENTIFIER));
124+
}
121125
} catch (Throwable e) {
122126
String msg = "Error in instantiating class : " + name.getAttributeValue();
123127
log.error(msg, e);

modules/core/src/main/java/org/apache/synapse/config/xml/inbound/InboundEndpointFactory.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ public static InboundEndpoint createInboundEndpoint(OMElement inboundEndpointEle
6363

6464
InboundEndpoint inboundEndpoint = new InboundEndpoint();
6565
if (inboundEndpointElem.getAttributeValue(ATT_NAME) != null) {
66-
inboundEndpoint.setName(FactoryUtils.getFullyQualifiedName(properties,
67-
inboundEndpointElem.getAttributeValue(ATT_NAME)));
66+
inboundEndpoint.setName(inboundEndpointElem.getAttributeValue(ATT_NAME));
6867
} else {
6968
String msg = "Inbound Endpoint name cannot be null";
7069
log.error(msg);

modules/core/src/main/java/org/apache/synapse/libraries/util/LibDeployerUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ private static SynapseLibrary createSynapseLibraryWithDeps(OMElement artifactEle
218218
}
219219
String packageName = readAttribute(artifactEle, LibDeployerConstants.PACKAGE_ATTR);
220220
SynapseLibrary synLib;
221-
if (deploymentFileData.isVersionedDeployment()) {
221+
if (deploymentFileData != null && deploymentFileData.isVersionedDeployment()) {
222222
synLib = new SynapseLibrary(deploymentFileData.getArtifactIdentifier(), readAttribute(artifactEle, LibDeployerConstants.NAME),
223223
packageName);
224224
} else {

modules/core/src/main/java/org/apache/synapse/mediators/AbstractMediator.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public abstract class AbstractMediator implements Mediator, AspectConfigurable {
7272
private boolean isSkipEnabled = false;
7373

7474
private SynapseMediationFlowPoint flowPoint = null;
75+
private String artifactIdentifier;
7576

7677

7778
/**
@@ -567,4 +568,14 @@ protected MediatorFaultHandler getLastSequenceFaultHandler(MessageContext synCtx
567568
}
568569
return null;
569570
}
571+
572+
public String getArtifactIdentifier() {
573+
574+
return artifactIdentifier;
575+
}
576+
577+
public void setArtifactIdentifier(String artifactIdentifier) {
578+
579+
this.artifactIdentifier = artifactIdentifier;
580+
}
570581
}

modules/core/src/main/java/org/apache/synapse/startup/quartz/SimpleQuartzFactory.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ private void updateTaskForVersioning(TaskDescription taskDescription, Properties
136136

137137
taskDescription.setName(FactoryUtils.getFullyQualifiedName(properties, taskDescription.getName()));
138138
taskDescription.getXmlProperties().forEach(prop -> {
139-
if (prop.getAttributeValue(NAME).equals("sequenceName")
140-
|| prop.getAttributeValue(NAME).equals("proxyName")) {
139+
if (prop.getAttributeValue(NAME).equals("sequenceName")) {
141140
prop.setText(FactoryUtils.getFullyQualifiedName(properties, prop.getText()));
142141
String value = prop.getAttributeValue(VALUE);
143142
if (value != null) {

modules/core/src/test/java/org/apache/synapse/endpoints/dynamic/InboundEndpointTestCase.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import org.apache.synapse.config.xml.inbound.InboundEndpointSerializer;
2929
import org.apache.synapse.inbound.InboundEndpoint;
3030

31+
import java.util.Properties;
32+
3133
/**
3234
* Testing InboundEndpoint related operations
3335
*/
@@ -73,6 +75,30 @@ public class InboundEndpointTestCase extends TestCase {
7375
+ "<sequence xmlns=\"http://ws.apache.org/ns/synapse\" name=\"receiveSeq\">\n" + " <send/>\n"
7476
+ "</sequence>";
7577

78+
private static final String rabbitMQInbound = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
79+
"<inboundEndpoint name=\"RabbitMQInbound\" sequence=\"RabbitMQInbound-inboundSequence\" onError=\"RabbitMQInbound-inboundErrorSequence\" suspend=\"false\" protocol=\"rabbitmq\">\n" +
80+
" <parameters xmlns=\"http://ws.apache.org/ns/synapse\">\n" +
81+
" <parameter name=\"rabbitmq.connection.factory\">QueueConnectionFactory</parameter>\n" +
82+
" <parameter name=\"rabbitmq.server.host.name\">localhost</parameter>\n" +
83+
" <parameter name=\"rabbitmq.server.port\">5672</parameter>\n" +
84+
" <parameter name=\"rabbitmq.server.user.name\">guest</parameter>\n" +
85+
" <parameter name=\"rabbitmq.server.password\">guest</parameter>\n" +
86+
" <parameter name=\"rabbitmq.queue.name\">queue_transaction</parameter>\n" +
87+
" <parameter name=\"sequential\">true</parameter>\n" +
88+
" <parameter name=\"coordination\">true</parameter>\n" +
89+
" <parameter name=\"rabbitmq.queue.durable\">false</parameter>\n" +
90+
" <parameter name=\"rabbitmq.queue.exclusive\">false</parameter>\n" +
91+
" <parameter name=\"rabbitmq.queue.auto.delete\">false</parameter>\n" +
92+
" <parameter name=\"rabbitmq.queue.auto.ack\">false</parameter>\n" +
93+
" <parameter name=\"rabbitmq.queue.autodeclare\">false</parameter>\n" +
94+
" <parameter name=\"rabbitmq.exchange.durable\">false</parameter>\n" +
95+
" <parameter name=\"rabbitmq.exchange.auto.delete\">false</parameter>\n" +
96+
" <parameter name=\"rabbitmq.exchange.autodeclare\">false</parameter>\n" +
97+
" <parameter name=\"rabbitmq.connection.ssl.enabled\">false</parameter>\n" +
98+
" <parameter name=\"rabbitmq.channel.consumer.qos\">0</parameter>\n" +
99+
" </parameters>\n" +
100+
"</inboundEndpoint>";
101+
76102
public void testCreateValidInboundEP() throws Exception {
77103
ep = factory.createInboundEndpoint(AXIOMUtil.stringToOM(sampleEP), config);
78104
Assert.assertNotNull("Inbound Endpoint is null", ep);
@@ -110,4 +136,28 @@ public void testCreateInvalidInboundEP() throws Exception {
110136
Assert.assertEquals(e.getMessage().contains("Inbound Endpoint name cannot be null"), true);
111137
}
112138
}
139+
140+
public void testInboundEPWithVersionedDeployment() throws Exception {
141+
142+
Properties properties = new Properties();
143+
properties.put("synapse.artifact.versioned.deployment", true);
144+
properties.put("synapse.artifact.identifier", "com.microintegrator.projects__beta1__1.0.2");
145+
146+
ep = factory.createInboundEndpoint(AXIOMUtil.stringToOM(rabbitMQInbound), config, properties);
147+
Assert.assertEquals("RabbitMQInbound", ep.getName());
148+
Assert.assertEquals("com.microintegrator.projects__beta1__1.0.2__RabbitMQInbound-inboundSequence", ep.getInjectingSeq());
149+
Assert.assertEquals("com.microintegrator.projects__beta1__1.0.2__RabbitMQInbound-inboundErrorSequence", ep.getOnErrorSeq());
150+
}
151+
152+
public void testInboundEPWithNonVersionedDeployment() throws Exception {
153+
154+
Properties properties = new Properties();
155+
properties.put("synapse.artifact.versioned.deployment", false);
156+
properties.put("synapse.artifact.identifier", "com.microintegrator.projects__beta1__1.0.2");
157+
158+
ep = factory.createInboundEndpoint(AXIOMUtil.stringToOM(rabbitMQInbound), config, properties);
159+
Assert.assertEquals("RabbitMQInbound", ep.getName());
160+
Assert.assertEquals("RabbitMQInbound-inboundSequence", ep.getInjectingSeq());
161+
Assert.assertEquals("RabbitMQInbound-inboundErrorSequence", ep.getOnErrorSeq());
162+
}
113163
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,7 @@
15641564
<mina.version>2.1.6</mina.version>
15651565
<jms-1.1-spec.version>1.1</jms-1.1-spec.version>
15661566
<!-- Axis2 and its dependencies -->
1567-
<axis2.version>1.6.1-wso2v112</axis2.version>
1567+
<axis2.version>1.6.1-wso2v113</axis2.version>
15681568
<axis2.transport.version>2.0.0-wso2v77</axis2.transport.version>
15691569
<axiom.version>1.2.11-wso2v30</axiom.version>
15701570
<xml_schema.version>1.4.7</xml_schema.version>

0 commit comments

Comments
 (0)