Skip to content

Commit

Permalink
xdr: introduce argument-less constructor for XdrOpaque
Browse files Browse the repository at this point in the history
Motivation:
To use XdrOpaque as reply from an RPC call we need to create an instance
of XdrOpaque without arguments:

XdrAble arg = ...;
XdrOpaque reply = new XdrOpaque();
clnt.call(0, arg, reply);
  

Modification:
introduce argument-less constructor for XdrOpaque

Result:
XdrOpaque can be used as reply of rpc request.

Acked-by: Paul Millar
Target: master
  • Loading branch information
kofemann committed Apr 9, 2019
1 parent a6981bf commit 1d98aaa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009 - 2018 Deutsches Elektronen-Synchroton,
* Copyright (c) 2009 - 2019 Deutsches Elektronen-Synchroton,
* Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY
*
* This library is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -33,6 +33,9 @@ public class XdrOpaque implements XdrAble {

private byte[] _opaque;

public XdrOpaque() {
}

public XdrOpaque(byte[] opaque) {
_opaque = opaque;
}
Expand Down
Expand Up @@ -100,6 +100,24 @@ public void testDecodeWellKnown() throws IOException {
}
}

@Test
public void testDecodeWellKnownStandardConstructor() throws IOException {

byte[] data = new byte[]{
0x0, 0x0, 0x0, 0x08, // size
0x0C, 0x0A, 0x0F, 0x0E, 0x0B, 0x0A, 0x0B, 0x0E // data
};

try ( Xdr xdr = new Xdr(data)) {
xdr.beginDecoding();

XdrOpaque opaque = new XdrOpaque();
opaque.xdrDecode(xdr);
// the data part must match (e.g without size)
assertArrayEquals(Arrays.copyOfRange(data, 4, 12), opaque.getOpaque());
}
}

@Test
public void testEncodeWellKnown() throws IOException {

Expand Down

0 comments on commit 1d98aaa

Please sign in to comment.