Search in sources :

Example 26 with ByteArrayBuffer

use of com.sun.xml.ws.util.ByteArrayBuffer in project metro-jax-ws by eclipse-ee4j.

the class SerializableWebServiceExceptionTest method testClientTransportExSerial5.

/**
 * Tests non-serializable argument, should serialize as String
 * @throws Exception
 */
public void testClientTransportExSerial5() throws Exception {
    ClientTransportException cte_orig = new ClientTransportException(ClientMessages.localizableFAILED_TO_PARSE(new URL("http://example.com?wsdl"), Thread.currentThread()));
    ByteArrayBuffer buffer = new ByteArrayBuffer();
    ObjectOutputStream oos = new ObjectOutputStream(buffer);
    oos.writeObject(cte_orig);
    ObjectInputStream ois = new ObjectInputStream(buffer.newInputStream());
    WebServiceException wse_ser = (WebServiceException) ois.readObject();
    ObjectInputStream ois1 = new ObjectInputStream(buffer.newInputStream());
    ClientTransportException cte_ser = (ClientTransportException) ois1.readObject();
    assertEquals(cte_orig.getLocalizedMessage(), cte_ser.getLocalizedMessage());
    assertEquals(cte_orig.getResourceBundleName(), cte_ser.getResourceBundleName());
    assertEquals(cte_orig.getKey(), cte_ser.getKey());
    assert (cte_orig.getArguments().length == cte_ser.getArguments().length);
    assertEquals(cte_orig.getArguments()[0], cte_ser.getArguments()[0]);
    assert (cte_ser.getArguments()[1] instanceof String);
    assertEquals(cte_orig.getArguments()[1].toString(), cte_ser.getArguments()[1].toString());
}
Also used : ClientTransportException(com.sun.xml.ws.client.ClientTransportException) WebServiceException(jakarta.xml.ws.WebServiceException) ObjectOutputStream(java.io.ObjectOutputStream) URL(java.net.URL) ByteArrayBuffer(com.sun.xml.ws.util.ByteArrayBuffer) ObjectInputStream(java.io.ObjectInputStream)

Example 27 with ByteArrayBuffer

use of com.sun.xml.ws.util.ByteArrayBuffer in project metro-jax-ws by eclipse-ee4j.

the class SerializableWebServiceExceptionTest method testClientTransportExSerial2.

/**
 * Tests Nested Exception
 * @throws Exception
 */
public void testClientTransportExSerial2() throws Exception {
    ClientTransportException cte_orig = new ClientTransportException(ClientMessages.localizableEPR_WITHOUT_ADDRESSING_ON());
    cte_orig.fillInStackTrace();
    ByteArrayBuffer buffer = new ByteArrayBuffer();
    ObjectOutputStream oos = new ObjectOutputStream(buffer);
    oos.writeObject(new WebServiceException(cte_orig));
    ObjectInputStream ois = new ObjectInputStream(buffer.newInputStream());
    WebServiceException wse_ser = (WebServiceException) ois.readObject();
    ClientTransportException cte_ser = (ClientTransportException) wse_ser.getCause();
    assertEquals(cte_orig.getLocalizedMessage(), cte_ser.getLocalizedMessage());
    assertEquals(cte_orig.getResourceBundleName(), cte_ser.getResourceBundleName());
    assertEquals(cte_orig.getKey(), cte_ser.getKey());
    assert (cte_orig.getArguments().length == cte_ser.getArguments().length);
}
Also used : ClientTransportException(com.sun.xml.ws.client.ClientTransportException) WebServiceException(jakarta.xml.ws.WebServiceException) ObjectOutputStream(java.io.ObjectOutputStream) ByteArrayBuffer(com.sun.xml.ws.util.ByteArrayBuffer) ObjectInputStream(java.io.ObjectInputStream)

Example 28 with ByteArrayBuffer

use of com.sun.xml.ws.util.ByteArrayBuffer in project metro-jax-ws by eclipse-ee4j.

the class SerializableWebServiceExceptionTest method testClientTransportExSerial1.

/**
 *  Tests Localizable with no args
 * @throws Exception
 */
public void testClientTransportExSerial1() throws Exception {
    ClientTransportException cte_orig = new ClientTransportException(ClientMessages.localizableEPR_WITHOUT_ADDRESSING_ON());
    cte_orig.fillInStackTrace();
    ByteArrayBuffer buffer = new ByteArrayBuffer();
    ObjectOutputStream oos = new ObjectOutputStream(buffer);
    oos.writeObject(cte_orig);
    ObjectInputStream ois = new ObjectInputStream(buffer.newInputStream());
    ClientTransportException cte_ser = (ClientTransportException) ois.readObject();
    assertEquals(cte_orig.getLocalizedMessage(), cte_ser.getLocalizedMessage());
    assertEquals(cte_orig.getResourceBundleName(), cte_ser.getResourceBundleName());
    assertEquals(cte_orig.getKey(), cte_ser.getKey());
    assert (cte_orig.getArguments().length == cte_ser.getArguments().length);
}
Also used : ClientTransportException(com.sun.xml.ws.client.ClientTransportException) ObjectOutputStream(java.io.ObjectOutputStream) ByteArrayBuffer(com.sun.xml.ws.util.ByteArrayBuffer) ObjectInputStream(java.io.ObjectInputStream)

Example 29 with ByteArrayBuffer

use of com.sun.xml.ws.util.ByteArrayBuffer in project metro-jax-ws by eclipse-ee4j.

the class SerializableWebServiceExceptionTest method testClientTransportExSerial4.

/**
 * Tests with two serializable arguments
 * @throws Exception
 */
public void testClientTransportExSerial4() throws Exception {
    WebServiceException wse_orig = new ClientTransportException(ClientMessages.localizableFAILED_TO_PARSE(new URL("http://example.com?wsdl"), new java.io.IOException("Can't access url")));
    ClientTransportException cte_orig = (ClientTransportException) wse_orig;
    ByteArrayBuffer buffer = new ByteArrayBuffer();
    ObjectOutputStream oos = new ObjectOutputStream(buffer);
    oos.writeObject(cte_orig);
    ObjectInputStream ois = new ObjectInputStream(buffer.newInputStream());
    WebServiceException wse_ser = (WebServiceException) ois.readObject();
    ObjectInputStream ois1 = new ObjectInputStream(buffer.newInputStream());
    ClientTransportException cte_ser = (ClientTransportException) ois1.readObject();
    assertEquals(cte_orig.getLocalizedMessage(), cte_ser.getLocalizedMessage());
    assertEquals(cte_orig.getResourceBundleName(), cte_ser.getResourceBundleName());
    assertEquals(cte_orig.getKey(), cte_ser.getKey());
    assert (cte_orig.getArguments().length == cte_ser.getArguments().length);
    assertEquals(cte_orig.getArguments()[0], cte_ser.getArguments()[0]);
    assertEquals(cte_orig.getArguments()[1].getClass(), cte_ser.getArguments()[1].getClass());
    assertEquals(cte_orig.getArguments()[1].toString(), cte_ser.getArguments()[1].toString());
}
Also used : ClientTransportException(com.sun.xml.ws.client.ClientTransportException) WebServiceException(jakarta.xml.ws.WebServiceException) ObjectOutputStream(java.io.ObjectOutputStream) URL(java.net.URL) ByteArrayBuffer(com.sun.xml.ws.util.ByteArrayBuffer) ObjectInputStream(java.io.ObjectInputStream)

Aggregations

ByteArrayBuffer (com.sun.xml.ws.util.ByteArrayBuffer)29 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)13 Message (com.sun.xml.ws.api.message.Message)9 WebServiceException (jakarta.xml.ws.WebServiceException)9 Packet (com.sun.xml.ws.api.message.Packet)7 ClientTransportException (com.sun.xml.ws.client.ClientTransportException)7 SAAJMessage (com.sun.xml.ws.message.saaj.SAAJMessage)6 SOAPMessage (jakarta.xml.soap.SOAPMessage)6 IOException (java.io.IOException)6 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)5 ObjectInputStream (java.io.ObjectInputStream)5 ObjectOutputStream (java.io.ObjectOutputStream)5 Transformer (javax.xml.transform.Transformer)5 StreamSource (javax.xml.transform.stream.StreamSource)5 XMLInputFactory (javax.xml.stream.XMLInputFactory)4 XMLStreamReader (javax.xml.stream.XMLStreamReader)4 URL (java.net.URL)3 XMLStreamException (javax.xml.stream.XMLStreamException)3 TransformerException (javax.xml.transform.TransformerException)3 DOMResult (javax.xml.transform.dom.DOMResult)3