use of org.apache.axis2.builder.Builder in project wso2-synapse by wso2.
the class BinaryRelayBuilderTest method testProcessDocument.
/**
* This method tests whether it is possible to create OMElement from the input stream
* @throws Exception
*/
@Test
public void testProcessDocument() throws Exception {
InputStream in = new ByteArrayInputStream("testString".getBytes());
String contentType = "application/xml";
MessageContext messageContext = new MessageContext();
BinaryRelayBuilder builder = new BinaryRelayBuilder();
OMElement response = builder.processDocument(in, contentType, messageContext);
String expected = "<?xml version='1.0' encoding='utf-8'?>" + "<soapenv:Envelope xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">" + "<soapenv:Body><ns:binary xmlns:ns=\"http://ws.apache.org/commons/ns/payload\">dGVzdFN0cmluZw==</ns:binary>" + "</soapenv:Body></soapenv:Envelope>";
Assert.assertEquals("Couldn't create OMElement!", expected, response.toString());
}
use of org.apache.axis2.builder.Builder in project wso2-synapse by wso2.
the class RelayUtilsTest method testShouldOverwriteContentType.
@Test
public void testShouldOverwriteContentType() {
MessageContext msgContext1 = Mockito.mock(MessageContext.class);
TargetRequest tgtRequest1 = Mockito.mock(TargetRequest.class);
Mockito.when(msgContext1.getProperty(PassThroughConstants.MESSAGE_BUILDER_INVOKED)).thenReturn(Boolean.FALSE);
Mockito.when(msgContext1.getProperty(PassThroughConstants.NO_ENTITY_BODY)).thenReturn(Boolean.TRUE);
boolean result = RelayUtils.shouldOverwriteContentType(msgContext1, tgtRequest1);
Assert.assertFalse("Content type has been chosen to overwrite when builder is not invoked and " + "no incoming content type is present", result);
Mockito.when(msgContext1.getProperty(PassThroughConstants.MESSAGE_BUILDER_INVOKED)).thenReturn(Boolean.TRUE);
Mockito.when(msgContext1.getProperty(PassThroughConstants.NO_ENTITY_BODY)).thenReturn(Boolean.FALSE);
result = RelayUtils.shouldOverwriteContentType(msgContext1, tgtRequest1);
Assert.assertTrue("Content type has not been chosen to overwrite when there's a body " + "and builder is invoked", result);
Map<String, LinkedHashSet<String>> headers = new HashMap<>();
LinkedHashSet<String> contentTypeHeaderSet = new LinkedHashSet<>();
contentTypeHeaderSet.add("application/json");
headers.put("Content-Type", contentTypeHeaderSet);
Mockito.when(tgtRequest1.getHeaders()).thenReturn(headers);
result = RelayUtils.shouldOverwriteContentType(msgContext1, tgtRequest1);
Assert.assertTrue("Content type has not been chosen to overwrite when there's a content type header", result);
}
use of org.apache.axis2.builder.Builder in project wso2-synapse by wso2.
the class VFSTransportTest method suite.
public static TestSuite suite() throws Exception {
// TODO: the VFS listener doesn't like reuseResources == true...
ManagedTestSuite suite = new ManagedTestSuite(VFSTransportTest.class, false);
// Since VFS has no Content-Type header, SwA is not supported.
suite.addExclude("(test=AsyncSwA)");
TransportTestSuiteBuilder builder = new TransportTestSuiteBuilder(suite);
ContentTypeServiceConfigurator cfgtr = new ContentTypeServiceConfigurator("transport.vfs.ContentType");
builder.addEnvironment(new VFSTestEnvironment(new File("target/vfs3")), new VFSTransportDescriptionFactory());
builder.addAsyncChannel(new VFSAsyncFileChannel("req/in"));
builder.addAxisAsyncTestClient(new AxisAsyncTestClient());
builder.addByteArrayAsyncTestClient(new VFSAsyncClient());
builder.addAxisAsyncEndpoint(new AxisAsyncEndpoint(), cfgtr);
builder.addByteArrayAsyncEndpoint(new VFSMockAsyncEndpoint());
builder.addRequestResponseChannel(new VFSRequestResponseFileChannel("req/in", "req/out"));
builder.addByteArrayRequestResponseTestClient(new VFSRequestResponseClient());
builder.addEchoEndpoint(new AxisEchoEndpoint(), cfgtr);
builder.build();
// suite.addTest(new MinConcurrencyTest(server, new AsyncChannel[] { new VFSFileChannel("req/in1"), new VFSFileChannel("req/in2") }, 1, true, env, tdf));
return suite;
}
use of org.apache.axis2.builder.Builder in project pentaho-platform by pentaho.
the class AbstractAxisConfigurator method getAxisConfiguration.
/**
* Creates the AxisConfiguration object using an XML document. Subclasses of this class must provide the XML via an
* input stream. The concrete implementation can store the XML file wherever it wants as we only need an InputStream
*/
public AxisConfiguration getAxisConfiguration() throws AxisFault {
if (axisConfig != null) {
// we have already initialized
return axisConfig;
}
try {
// create a new AxisConfiguration
axisConfig = new AxisConfiguration();
// get the config XML input stream
InputStream in = getConfigXml();
// build the configuration
AxisConfigBuilder builder = new AxisConfigBuilder(in, axisConfig, null);
builder.populateConfig();
} catch (Exception e) {
e.printStackTrace();
throw AxisFault.makeFault(e);
}
// set this object as the Axis configurator. Axis will call loadServices().
axisConfig.setConfigurator(this);
return axisConfig;
}
use of org.apache.axis2.builder.Builder in project wso2-synapse by wso2.
the class MultiSSLProfileReloader method reloadSSLProfileConfig.
public String reloadSSLProfileConfig() throws AxisFault {
Parameter oldParameter = transportInDescription.getParameter("SSLProfiles");
Parameter profilePathParam = transportInDescription.getParameter("SSLProfilesConfigPath");
if (oldParameter != null && profilePathParam != null) {
transportInDescription.removeParameter(oldParameter);
ServerConnFactoryBuilder builder = new ServerConnFactoryBuilder(transportInDescription, null);
TransportInDescription loadedTransportIn = builder.loadMultiProfileSSLConfig();
if (loadedTransportIn != null) {
transportInDescription = loadedTransportIn;
httpCoreNIOMultiSSLListener.reload(transportInDescription);
return "SSLProfiles reloaded Successfully";
}
// add old value back
transportInDescription.addParameter(oldParameter);
}
return "Failed to reload SSLProfiles";
}
Aggregations