use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.
the class EngineWithoutPhaseResolvingTest method testServerReceive.
public void testServerReceive() throws Exception {
mc.setTo(new EndpointReference("axis2/services/NullService"));
mc.setServerSide(true);
AxisEngine.receive(mc);
}
use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.
the class EnumTest method testEnumPojo.
public void testEnumPojo() throws Exception {
QName opEnumPojo = new QName("http://engine.axis2.apache.org", "enumPojo", "asix");
Event event = new Event();
event.setEventDesc("Event Description");
event.setEventName("Event Name");
event.setStartingDay(EnumService.Day.FRIDAY);
// Constructing the arguments array for the method invocation
Object[] opAddEventArgs = new Object[] { event };
// Invoking the method
RPCServiceClient serviceClient = getRPCClient();
Options options = serviceClient.getOptions();
EndpointReference targetEPR = new EndpointReference("local://services/EnumService");
options.setTo(targetEPR);
options.setAction("enumPojo");
Class[] returnTypes = new Class[] { Event.class };
Object[] ret = serviceClient.invokeBlocking(opEnumPojo, opAddEventArgs, returnTypes);
// assertEquals(event, ret[0]);
Event res = (Event) ret[0];
assertEquals(event.getEventDesc(), res.getEventDesc());
assertEquals(event.getEventName(), res.getEventName());
assertEquals(event.getStartingDay(), res.getStartingDay());
}
use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.
the class OptionsSaveTest method testSaveAndRestore.
public void testSaveAndRestore() throws Exception {
File theFile = null;
String theFilename = null;
boolean saved = false;
boolean restored = false;
boolean done = false;
boolean comparesOk = false;
AxisConfiguration axisConfiguration = new AxisConfiguration();
ConfigurationContext configurationContext = new ConfigurationContext(axisConfiguration);
log.debug("OptionsSaveTest:testSaveAndRestore(): BEGIN ---------------");
// ---------------------------------------------------------
// setup an options object to use
// ---------------------------------------------------------
Options options = new Options();
options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
options.setExceptionToBeThrownOnSOAPFault(true);
options.setTimeOutInMilliSeconds(5000L);
options.setUseSeparateListener(false);
options.setAction("SoapAction");
options.setFaultTo(new EndpointReference("http://ws.apache.org/axis2/faultTo"));
options.setFrom(new EndpointReference("http://ws.apache.org/axis2/from"));
options.setTo(new EndpointReference("http://ws.apache.org/axis2/to"));
options.setReplyTo(new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL));
TransportOutDescription transportOut = new TransportOutDescription("null");
TransportOutDescription transportOut2 = new TransportOutDescription("happy");
TransportOutDescription transportOut3 = new TransportOutDescription("golucky");
transportOut.setSender(new HTTPClient4TransportSender());
transportOut2.setSender(new HTTPClient4TransportSender());
transportOut3.setSender(new HTTPClient4TransportSender());
options.setTransportOut(transportOut);
axisConfiguration.addTransportOut(transportOut3);
axisConfiguration.addTransportOut(transportOut2);
axisConfiguration.addTransportOut(transportOut);
TransportInDescription transportIn = new TransportInDescription("null");
TransportInDescription transportIn2 = new TransportInDescription("always");
TransportInDescription transportIn3 = new TransportInDescription("thebest");
transportIn.setReceiver(new SimpleHTTPServer());
transportIn2.setReceiver(new SimpleHTTPServer());
transportIn3.setReceiver(new SimpleHTTPServer());
options.setTransportIn(transportIn);
axisConfiguration.addTransportIn(transportIn2);
axisConfiguration.addTransportIn(transportIn);
axisConfiguration.addTransportIn(transportIn3);
options.setMessageId("msgId012345");
options.setProperty("key01", "value01");
options.setProperty("key02", "value02");
options.setProperty("key03", "value03");
options.setProperty("key04", "value04");
options.setProperty("key05", "value05");
options.setProperty("key06", "value06");
options.setProperty("key07", "value07");
options.setProperty("key08", "value08");
options.setProperty("key09", "value09");
options.setProperty("key10", "value10");
// ---------------------------------------------------------
try {
theFile = File.createTempFile("optionsSave", null);
theFilename = theFile.getName();
log.debug("OptionsSaveTest:testSaveAndRestore(): temp file = [" + theFilename + "]");
} catch (Exception ex) {
log.debug("OptionsSaveTest:testSaveAndRestore(): error creating temp file = [" + ex.getMessage() + "]");
theFile = null;
}
if (theFile != null) {
// ---------------------------------------------------------
try {
// setup an output stream to a physical file
FileOutputStream outStream = new FileOutputStream(theFile);
// attach a stream capable of writing objects to the
// stream connected to the file
ObjectOutputStream outObjStream = new ObjectOutputStream(outStream);
// try to save the message context
log.debug("OptionsSaveTest:testSaveAndRestore(): saving .....");
saved = false;
outObjStream.writeObject(options);
// close out the streams
outObjStream.flush();
outObjStream.close();
outStream.flush();
outStream.close();
saved = true;
log.debug("OptionsSaveTest:testSaveAndRestore(): ....save operation completed.....");
long filesize = theFile.length();
log.debug("OptionsSaveTest:testSaveAndRestore(): file size after save [" + filesize + "] temp file = [" + theFilename + "]");
} catch (Exception ex2) {
if (saved != true) {
log.debug("OptionsSaveTest:testSaveAndRestore(): error during save [" + ex2.getClass().getName() + " : " + ex2.getMessage() + "]");
ex2.printStackTrace();
} else {
log.debug("OptionsSaveTest:testSaveAndRestore(): error during restore [" + ex2.getClass().getName() + " : " + ex2.getMessage() + "]");
ex2.printStackTrace();
}
}
assertTrue(saved);
// ---------------------------------------------------------
try {
// setup an input stream to the file
FileInputStream inStream = new FileInputStream(theFile);
// attach a stream capable of reading objects from the
// stream connected to the file
ObjectInputStream inObjStream = new ObjectInputStream(inStream);
// try to restore the options
log.debug("OptionsSaveTest:testSaveAndRestore(): restoring .....");
restored = false;
Options options_restored = (Options) inObjStream.readObject();
inObjStream.close();
inStream.close();
options_restored.activate(configurationContext);
restored = true;
log.debug("OptionsSaveTest:testSaveAndRestore(): ....restored operation completed.....");
comparesOk = options_restored.isEquivalent(options);
log.debug("OptionsSaveTest:testSaveAndRestore(): Options equivalency [" + comparesOk + "]");
} catch (Exception ex2) {
log.debug("OptionsSaveTest:testSaveAndRestore(): error during restore [" + ex2.getClass().getName() + " : " + ex2.getMessage() + "]");
ex2.printStackTrace();
}
assertTrue(restored);
assertTrue(comparesOk);
// if the save/restore of the object succeeded,
// then don't keep the temporary file around
boolean removeTmpFile = saved && restored && comparesOk;
if (removeTmpFile) {
try {
theFile.delete();
} catch (Exception e) {
// just absorb it
}
}
// indicate that the temp file was created ok
done = true;
}
// this is false when there are problems with the temporary file
assertTrue(done);
log.debug("OptionsSaveTest:testSaveAndRestore(): END ---------------");
}
use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.
the class PausingHandlerExecutionTest method createClient.
private ServiceClient createClient() throws Exception {
Options options = new Options();
options.setTo(new EndpointReference("http://127.0.0.1:" + server.getPort() + "/axis2/services/EchoXMLService/echoOMElement"));
options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
options.setAction(operationName.getLocalPart());
options.setUseSeparateListener(true);
options.setTimeOutInMilliSeconds(50000);
ConfigurationContext configContext = UtilServer.createClientConfigurationContext();
ServiceClient sender = new ServiceClient(configContext, null);
sender.setOptions(options);
sender.engageModule("addressing");
return sender;
}
use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.
the class ServiceClientTest method testFireAndForget.
public void testFireAndForget() throws Exception {
EndpointReference targetEPR = new EndpointReference("http://127.0.0.1:" + (UtilServer.TESTING_PORT) + // "http://127.0.0.1:" + 5556
"/axis2/services/Echo/echoOMElementNoResponse");
OMElement payload = createDummyOMElement();
Options options = new Options();
options.setTo(targetEPR);
options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
options.setAction("urn:echoOMElementNoResponse");
ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
ServiceClient sender = new ServiceClient(configContext, null);
sender.setOptions(options);
sender.fireAndForget(payload);
Thread.sleep(100);
String value = System.getProperty("echoOMElementNoResponse");
System.setProperty("echoOMElementNoResponse", "");
assertEquals(value, "echoOMElementNoResponse");
}
Aggregations