use of org.wso2.carbon.config.ConfigurationException in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method init.
@BeforeClass
void init() {
File temp = Files.createTempDir();
temp.deleteOnExit();
System.setProperty("gwHome", temp.getAbsolutePath());
// Set the resource path, where contain composer test JS
System.setProperty("carbon.home", new File("src/test/resources").getAbsolutePath());
WorkflowExtensionsConfigBuilder.build(new ConfigProvider() {
@Override
public <T> T getConfigurationObject(Class<T> configClass) throws ConfigurationException {
T workflowConfig = (T) new WorkflowConfig();
return workflowConfig;
}
@Override
public Object getConfigurationObject(String s) throws ConfigurationException {
return null;
}
public <T> T getConfigurationObject(String s, Class<T> aClass) throws ConfigurationException {
return null;
}
});
}
use of org.wso2.carbon.config.ConfigurationException in project carbon-apimgt by wso2.
the class APIStoreImplTestCase method setup.
@BeforeTest
public void setup() throws Exception {
WorkflowExtensionsConfigBuilder.build(new ConfigProvider() {
@Override
public <T> T getConfigurationObject(Class<T> configClass) throws ConfigurationException {
T workflowConfig = (T) new WorkflowConfig();
return workflowConfig;
}
@Override
public Object getConfigurationObject(String s) throws ConfigurationException {
return null;
}
public <T> T getConfigurationObject(String s, Class<T> aClass) throws ConfigurationException {
return null;
}
});
ConfigProvider configProvider = Mockito.mock(ConfigProvider.class);
ServiceReferenceHolder.getInstance().setConfigProvider(configProvider);
}
use of org.wso2.carbon.config.ConfigurationException in project carbon-apimgt by wso2.
the class ServiceReferenceHolderTestCase method testGetAPIMAppConfiguration.
@Test
public void testGetAPIMAppConfiguration() throws ConfigurationException {
// // Happy Path
ServiceReferenceHolder instance = ServiceReferenceHolder.getInstance();
ConfigProvider configProvider = Mockito.mock(ConfigProvider.class);
instance.setConfigProvider(configProvider);
APIMAppConfigurations expectedConfigs = new APIMAppConfigurations();
expectedConfigs.setApimBaseUrl("https://localhost:9443/");
Mockito.when(configProvider.getConfigurationObject(Mockito.any(Class.class))).thenReturn(expectedConfigs);
APIMAppConfigurations actualConfigs = instance.getAPIMAppConfiguration();
Assert.assertNotNull(actualConfigs);
Assert.assertEquals(expectedConfigs.getApimBaseUrl(), actualConfigs.getApimBaseUrl());
// // Error path
// // ConfigurationException
Mockito.when(configProvider.getConfigurationObject(Mockito.any(Class.class))).thenThrow(ConfigurationException.class);
actualConfigs = instance.getAPIMAppConfiguration();
Assert.assertNotNull(actualConfigs);
// // config provider is null
instance.setConfigProvider(null);
actualConfigs = instance.getAPIMAppConfiguration();
Assert.assertNotNull(actualConfigs);
}
use of org.wso2.carbon.config.ConfigurationException in project carbon-business-process by wso2.
the class AnalyticsPublisherExtensionOperation method evaluateXPathExpression.
private String evaluateXPathExpression(ExtensionContext context, String xpath, Element element) throws FaultException {
String result = "";
QName qnVariableData = new QName(Namespaces.BPEL11_NS, "getVariableData");
QName qnGetVariableProperty = new QName(Namespaces.BPEL11_NS, "getVariableProperty");
QName qnGetLinkStatus = new QName(Namespaces.BPEL11_NS, "getLinkStatus");
QName qnDoXslTransform = new QName(Namespaces.BPEL11_NS, "getDoXslTransform");
OXPath20ExpressionBPEL20 oexpr = new OXPath20ExpressionBPEL20(context.getInternalInstance().getProcessModel().getOwner(), qnVariableData, qnGetVariableProperty, qnGetLinkStatus, qnDoXslTransform, false);
OExpressionLanguage oExpressionLanguage = new OExpressionLanguage(context.getProcessModel().getOwner(), null);
oExpressionLanguage.expressionLanguageUri = "urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0";
oexpr.expressionLanguage = oExpressionLanguage;
oExpressionLanguage.properties.put("runtime-class", "org.apache.ode.bpel.elang.xpath20.runtime.XPath20ExpressionRuntime");
try {
context.getInternalInstance().getExpLangRuntime().registerRuntime(oExpressionLanguage);
} catch (ConfigurationException ex) {
String errMsg = "Error when trying to register xpath runtime";
log.error(errMsg, ex);
handleException(errMsg, ex);
}
oexpr.insertMissingData = true;
ScopeFrame scopeFrame = ((ExtensionContextImpl) context).getScopeFrame();
ExprEvaluationContextImpl exprEvaluationContext = new ExprEvaluationContextImpl(scopeFrame, context.getInternalInstance());
oexpr.vars = (HashMap) context.getVisibleVariables();
oexpr.namespaceCtx = context.getProcessModel().namespaceContext;
try {
oexpr.xpath = xpath;
List resultList = context.getInternalInstance().getExpLangRuntime().evaluate(oexpr, exprEvaluationContext);
if (result != null) {
Iterator iterator = resultList.iterator();
/**
* for analytics publishing to work, there should only be a single node here
*/
while (iterator.hasNext()) {
Node node = ((Node) iterator.next());
if (node.getNodeType() == Node.ELEMENT_NODE) {
result += node.getTextContent();
} else if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
result += node.getNodeValue();
}
}
}
} catch (EvaluationException e) {
String errMsg = "Xpath evaluation failed";
log.error(errMsg);
handleException(errMsg, e);
}
return result;
}
Aggregations