Search in sources :

Example 1 with UaMethodException

use of org.eclipse.milo.opcua.sdk.client.methods.UaMethodException in project milo by eclipse.

the class AbstractMethodInvocationHandlerTest method implementationCanValidateArguments.

@Test
public void implementationCanValidateArguments() throws UaException {
    AddressSpace addressSpace = client.getAddressSpace();
    UaObjectNode objectsNode = addressSpace.getObjectNode(Identifiers.ObjectsFolder);
    try {
        objectsNode.callMethod(new QualifiedName(2, "onlyAcceptsPositiveInputs()"), new Variant[] { new Variant(-1) });
    } catch (UaMethodException e) {
        System.out.println("result: " + e.getStatusCode());
        System.out.println("inputArgumentResults: " + Arrays.toString(e.getInputArgumentResults()));
        assertEquals(StatusCodes.Bad_InvalidArgument, e.getStatusCode().getValue());
        assertEquals(StatusCodes.Bad_OutOfRange, e.getInputArgumentResults()[0].getValue());
    }
}
Also used : Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) AddressSpace(org.eclipse.milo.opcua.sdk.client.AddressSpace) UaMethodException(org.eclipse.milo.opcua.sdk.client.methods.UaMethodException) UaObjectNode(org.eclipse.milo.opcua.sdk.client.nodes.UaObjectNode) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) Test(org.junit.jupiter.api.Test) AbstractClientServerTest(org.eclipse.milo.opcua.sdk.test.AbstractClientServerTest)

Aggregations

AddressSpace (org.eclipse.milo.opcua.sdk.client.AddressSpace)1 UaMethodException (org.eclipse.milo.opcua.sdk.client.methods.UaMethodException)1 UaObjectNode (org.eclipse.milo.opcua.sdk.client.nodes.UaObjectNode)1 AbstractClientServerTest (org.eclipse.milo.opcua.sdk.test.AbstractClientServerTest)1 QualifiedName (org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName)1 Variant (org.eclipse.milo.opcua.stack.core.types.builtin.Variant)1 Test (org.junit.jupiter.api.Test)1