Search in sources :

Example 1 with XmlEntityStructHolder

use of alma.xmlentity.XmlEntityStructHolder in project ACS by ACS-Community.

the class DynamicProxyFactoryTest method testCallXmlInOutMethod.

public void testCallXmlInOutMethod() throws DynWrapperException {
    XmlComponentOperations serverProxy = createServerProxy();
    assertNotNull(serverProxy);
    XmlEntityStruct entStructObsProp = serverProxy.createObsProposal();
    XmlEntityStructHolder xesh = new XmlEntityStructHolder();
    // send invalid xml
    entStructObsProp.xmlString = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + "<ns1:ObsProposal xmlns:ns1=\"AlmaTest/ObsProposal\">" + "	<ns1:ObsProposalEntity entityIdEncrypted=\"ljasd;ljfa;lsfd\"" + "		entityId=\"uid://X0000000000000000/X00000001\" entityTypeName=\"ObsProposal\"/>" + "	<ns1:ContactPerson>Otis P. Driftwood.</ns1:ContactPerson>" + "</ns1:ObsProposal>";
    serverProxy.xmlInOutMethod(entStructObsProp, xesh);
    assertNotNull(xesh.value);
    String xml = xesh.value.xmlString;
    assertNotNull(xml);
    System.out.println("received out-param SchedBlock as XML: " + xml);
}
Also used : XmlEntityStructHolder(alma.xmlentity.XmlEntityStructHolder) XmlComponentOperations(alma.demo.XmlComponentOperations) XmlEntityStruct(alma.xmlentity.XmlEntityStruct)

Example 2 with XmlEntityStructHolder

use of alma.xmlentity.XmlEntityStructHolder in project ACS by ACS-Community.

the class DynamicProxyFactoryTest method testInvalidXml.

public void testInvalidXml() throws DynWrapperException {
    XmlComponentOperations serverProxy = createServerProxy();
    assertNotNull(serverProxy);
    XmlEntityStruct entStructObsProp = serverProxy.createObsProposal();
    XmlEntityStructHolder xesh = new XmlEntityStructHolder();
    // send invalid xml
    entStructObsProp.xmlString = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + //			"<ns1:ObsProposal xmlns:ns1=\"AlmaTest/ObsProposal\">" +
    "	<ns1:ObsProposalEntity entityIdEncrypted=\"ljasd;ljfa;lsfd\"" + "		entityId=\"uid://X0000000000000000/X00000001\" entityTypeName=\"ObsProposal\"/>" + "	<ns1:PerformanceGoals>peak performance enduring a 24-7-365 schedule.</ns1:PerformanceGoals>" + "</ns1:ObsProposal>";
    try {
        serverProxy.xmlInOutMethod(entStructObsProp, xesh);
        fail("invalid XML should have caused an exception");
    } catch (UndeclaredThrowableException e) {
        Throwable cause = e.getCause();
        assertTrue(cause instanceof DynWrapperException);
        Throwable cause2 = cause.getCause();
        assertTrue(cause2 instanceof MarshalException);
        assertTrue(((MarshalException) cause2).getCause() instanceof org.xml.sax.SAXException);
    }
}
Also used : XmlEntityStructHolder(alma.xmlentity.XmlEntityStructHolder) MarshalException(org.exolab.castor.xml.MarshalException) XmlComponentOperations(alma.demo.XmlComponentOperations) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) XmlEntityStruct(alma.xmlentity.XmlEntityStruct)

Example 3 with XmlEntityStructHolder

use of alma.xmlentity.XmlEntityStructHolder in project ACS by ACS-Community.

the class DynamicProxyFactoryTest method testEmptyXml.

/**
	 * Sends an empty (one blank) XML representation of an ObsProposal to the method
	 * <code>xmlInOutMethod</code>. Expects to not get an exception.
	 * @throws DynWrapperException
	 */
public void testEmptyXml() throws DynWrapperException {
    XmlComponentOperations serverProxy = createServerProxy();
    assertNotNull(serverProxy);
    // just to have a valid struct
    XmlEntityStruct entStructObsProp = serverProxy.createObsProposal();
    XmlEntityStructHolder xesh = new XmlEntityStructHolder();
    // send empty xml
    entStructObsProp.xmlString = " ";
    serverProxy.xmlInOutMethod(entStructObsProp, xesh);
    // ObsProposal in-param and thus SchedBlock out-param are null, 
    // so that the out-XmlEntityStruct struct must be empty.
    assertEquals("", xesh.value.xmlString);
}
Also used : XmlEntityStructHolder(alma.xmlentity.XmlEntityStructHolder) XmlComponentOperations(alma.demo.XmlComponentOperations) XmlEntityStruct(alma.xmlentity.XmlEntityStruct)

Aggregations

XmlComponentOperations (alma.demo.XmlComponentOperations)3 XmlEntityStruct (alma.xmlentity.XmlEntityStruct)3 XmlEntityStructHolder (alma.xmlentity.XmlEntityStructHolder)3 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 MarshalException (org.exolab.castor.xml.MarshalException)1