use of org.wso2.carbon.apimgt.output.adapter.http.ExtendedHTTPEventAdapterFactory in project carbon-apimgt by wso2.
the class ExtendedHTTPEventAdapterServiceDS method activate.
@Activate
protected void activate(ComponentContext context) {
ExtendedHTTPEventAdapterFactory extendedHttpEventAdaptorFactory = new ExtendedHTTPEventAdapterFactory();
BundleContext bundleContext = context.getBundleContext();
bundleContext.registerService(OutputEventAdapterFactory.class.getName(), extendedHttpEventAdaptorFactory, null);
if (log.isDebugEnabled()) {
log.debug("Successfully deployed the Extended Http event adaptor service");
}
}
use of org.wso2.carbon.apimgt.output.adapter.http.ExtendedHTTPEventAdapterFactory in project carbon-apimgt by wso2.
the class ExtendedHTTPEventAdaptorTestCase method testHttpPublisherFactory.
@Test
public void testHttpPublisherFactory() {
logger.info("Test case for factory properties of Extended HTTP output adaptor.");
ExtendedHTTPEventAdapterFactory adapterFactory = new ExtendedHTTPEventAdapterFactory();
List<Property> dyPropertyList = adapterFactory.getDynamicPropertyList();
List<Property> propertyList = new ArrayList<>();
Property property = new Property("http.url");
property.setRequired(true);
property.setSecured(false);
property.setEncrypted(false);
property.setDisplayName("URL");
property.setDefaultValue(null);
property.setOptions(null);
property.setHint("The target HTTP/HTTPS URL, e.g. \"http://yourhost:8080/service\"");
propertyList.add(property);
property = new Property("http.username");
property.setRequired(false);
property.setSecured(false);
property.setEncrypted(false);
property.setDisplayName("Username");
property.setDefaultValue(null);
property.setOptions(null);
property.setHint("HTTP BasicAuth username");
propertyList.add(property);
property = new Property("http.password");
property.setRequired(false);
property.setSecured(true);
property.setEncrypted(true);
property.setDisplayName("Password");
property.setDefaultValue(null);
property.setOptions(null);
property.setHint("HTTP BasicAuth password");
propertyList.add(property);
property = new Property("http.headers");
property.setRequired(false);
property.setSecured(false);
property.setEncrypted(false);
property.setDisplayName("Headers");
property.setDefaultValue(null);
property.setOptions(null);
property.setHint("Custom HTTP headers, e.g. \"header1: value1, header2: value2\"");
propertyList.add(property);
Assert.assertEquals(4, dyPropertyList.size());
int i = 0;
for (Property prop : propertyList) {
Assert.assertEquals(prop.getPropertyName(), dyPropertyList.get(i).getPropertyName());
Assert.assertEquals(prop.getDefaultValue(), dyPropertyList.get(i).getDefaultValue());
Assert.assertEquals(prop.getDisplayName(), dyPropertyList.get(i).getDisplayName());
Assert.assertEquals(prop.getHint(), dyPropertyList.get(i).getHint());
i++;
}
List<String> types = new ArrayList<>();
types.add("text");
types.add("xml");
types.add("json");
List<String> supportedTypes = adapterFactory.getSupportedMessageFormats();
Assert.assertEquals(supportedTypes.toString(), types.toString());
Assert.assertEquals("http-extended", adapterFactory.getType());
setupCarbonConfig();
PrivilegedCarbonContext privilegedCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
privilegedCarbonContext.setTenantId(-1234);
OutputEventAdapterConfiguration eventAdapterConfiguration = new OutputEventAdapterConfiguration();
eventAdapterConfiguration.setName("TestHttpAdaptor");
eventAdapterConfiguration.setType("http-extended");
eventAdapterConfiguration.setMessageFormat("text");
Map<String, String> staticPropertes = new HashMap<>();
staticPropertes.put("http.client.method", "HttpPost");
staticPropertes.put("http.proxy.port", "9090");
staticPropertes.put("http.proxy.host", "localhost");
staticPropertes.put("oauth.url", "localhost:9090/token");
staticPropertes.put("oauth.consumer.key", "key");
staticPropertes.put("oauth.consumer.secret", "secret");
eventAdapterConfiguration.setStaticProperties(staticPropertes);
Map<String, String> globalProperties = new HashMap<>();
globalProperties.put("jobQueueSize", "10000");
globalProperties.put("keepAliveTimeInMillis", "20000");
globalProperties.put("maxThread", "100");
globalProperties.put("minThread", "8");
globalProperties.put("defaultMaxConnectionsPerHost", "50");
globalProperties.put("maxTotalConnections", "1000");
adapterFactory.createEventAdapter(eventAdapterConfiguration, globalProperties);
}
Aggregations