Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions modules/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -318,5 +318,9 @@
<artifactId>xercesImpl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class ServerContextInformation {
private ServerState serverState = ServerState.UNDETERMINED;
/** Reference to the server configuration */
private ServerConfigurationInformation serverConfigurationInformation;
/** whether unit test mode is enabled or not */
private boolean isUnitTestModeEnabled=false;

public ServerContextInformation(ServerConfigurationInformation serverConfigurationInformation) {
this.serverConfigurationInformation = serverConfigurationInformation;
Expand Down Expand Up @@ -96,4 +98,12 @@ public void setSynapseEnvironment(SynapseEnvironment synapseEnvironment) {
public ServerConfigurationInformation getServerConfigurationInformation() {
return serverConfigurationInformation;
}

public boolean isServerUnitTestModeEnabled(){
return isUnitTestModeEnabled;
}

public void setServerUnitTestModeEnabled(boolean isUnitTestModeEnabled){
this.isUnitTestModeEnabled=isUnitTestModeEnabled;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.apache.synapse.rest.RESTRequestHandler;
import org.apache.synapse.task.SynapseTaskManager;
import org.apache.synapse.transport.passthru.util.RelayUtils;
import org.apache.synapse.unittest.UnitTestingExecutor;
import org.apache.synapse.util.concurrent.SynapseThreadPool;
import org.apache.synapse.util.xpath.ext.SynapseXpathFunctionContextProvider;
import org.apache.synapse.util.xpath.ext.SynapseXpathVariableResolver;
Expand Down Expand Up @@ -83,6 +84,9 @@ public class Axis2SynapseEnvironment implements SynapseEnvironment {

private boolean synapseDebugMode;

/** Unit test mode is enabled/disabled*/
private boolean isUnitTestEnabled = false;

public Axis2SynapseEnvironment(SynapseConfiguration synCfg) {

int coreThreads = SynapseThreadPool.SYNAPSE_CORE_THREADS;
Expand Down Expand Up @@ -126,7 +130,25 @@ public Axis2SynapseEnvironment(ConfigurationContext cfgCtx,
public Axis2SynapseEnvironment(ConfigurationContext cfgCtx,
SynapseConfiguration synapseConfig, ServerContextInformation contextInformation) {
this(cfgCtx, synapseConfig);
this.contextInformation = contextInformation;
this.contextInformation = contextInformation;
setSeverUnitTestMode(contextInformation);
}

/**
* This method is to set the unit test mode is enabled.
* unit test message context and environment initializes
*/
private void setSeverUnitTestMode(ServerContextInformation contextInformation) {
if (Boolean.parseBoolean(System.getProperty("synapseTest"))) {
setUnitTestEnabled(true);
contextInformation.setServerUnitTestModeEnabled(true);
log.info("Synapse unit testing server enabled");

//starting UnitTestingExecutor
UnitTestingExecutor testExecutor = UnitTestingExecutor.getExecuteInstance();
testExecutor.setSynapseConfiguration(this.synapseConfig);
testExecutor.start();
}
}

public boolean injectMessage(final MessageContext synCtx) {
Expand Down Expand Up @@ -551,7 +573,26 @@ private Mediator getProxyOutSequence(MessageContext synCtx, ProxyService proxySe
return null;
}


public void setSynapseDebugMode(boolean synapseDebugMode) {
this.synapseDebugMode = synapseDebugMode;
}

/**
* Whether unit test is enabled in the environment.
*
* @return whether debugging is enabled in the environment
*/
public boolean isUnitTestEnabled() {
return isUnitTestEnabled;
}

/**
* set unit test mode enabled in the environment.
*
* @param isUnitTestEnabled boolean value of unit test mode
*/
public void setUnitTestEnabled(boolean isUnitTestEnabled) {
this.isUnitTestEnabled = isUnitTestEnabled;
}
}
Loading