use of org.eclipse.milo.opcua.sdk.client.AddressSpace in project milo by eclipse.
the class UaMethodTest method callMethodWithNoInputsOrOutputs.
@Test
public void callMethodWithNoInputsOrOutputs() throws UaException {
AddressSpace addressSpace = client.getAddressSpace();
UaObjectNode objectsNode = addressSpace.getObjectNode(Identifiers.ObjectsFolder);
Variant[] outputs = objectsNode.callMethod(new QualifiedName(2, "hasNoInputsOrOutputs()"), new Variant[0]);
assertEquals(0, outputs.length);
}
use of org.eclipse.milo.opcua.sdk.client.AddressSpace in project milo by eclipse.
the class UaMethodTest method findMethodNotFound.
@Test
public void findMethodNotFound() throws UaException {
AddressSpace addressSpace = client.getAddressSpace();
UaObjectNode serverNode = addressSpace.getObjectNode(Identifiers.Server);
assertThrows(UaException.class, () -> serverNode.getMethod("foo"));
}
use of org.eclipse.milo.opcua.sdk.client.AddressSpace in project milo by eclipse.
the class UaMethodTest method throwsUaMethodException.
@Test
public void throwsUaMethodException() throws UaException {
AddressSpace addressSpace = client.getAddressSpace();
UaObjectNode objectsNode = addressSpace.getObjectNode(Identifiers.ObjectsFolder);
assertThrows(UaMethodException.class, () -> {
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()));
throw e;
}
});
}
use of org.eclipse.milo.opcua.sdk.client.AddressSpace in project milo by eclipse.
the class UaMethodTest method callMethodWithHasComponentReference.
@Test
public void callMethodWithHasComponentReference() throws UaException {
AddressSpace addressSpace = client.getAddressSpace();
UaObjectNode objectsNode = addressSpace.getObjectNode(Identifiers.ObjectsFolder);
Variant[] outputs = objectsNode.callMethod(new QualifiedName(2, "sqrt(x)"), new Variant[] { new Variant(16.0) });
assertEquals(4.0, outputs[0].getValue());
}
use of org.eclipse.milo.opcua.sdk.client.AddressSpace 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());
}
}
Aggregations