incubator-yoko-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Darren Middleman" <dmiddle...@gmail.com>
Subject Re: octet idltowsdl type test
Date Fri, 16 Feb 2007 16:52:17 GMT
Hello Matteo,

Those changes look fine.  I think the initial approach was based more around
what the
CORBA side expected but I think your approach is probably more appropriate
for the
binding.

Cheers,
Darren


On 2/16/07, Vescovi, Matteo <matteo.vescovi@iona.com> wrote:
>
> Hi,
> I have a patch (attached) that fixes the IdlToWsdl type test testOctet.
>
> The fix mainly consists in modifying the CorbaPrimitiveHandler to use a
> java:Short to handle a corba:octet in accordance with the JAXB spec
> (i.e. corba:octet maps to a xsd:unsignedByte, which maps to a java:short).
>
> However, this causes a regression in CorbaTypeTest.testBase64Binary().
>
> Before I start fixing that test too, it would be great if someone could
> confirm that what I have so far is correct and I am not approaching this
> from the wrong angle.
>
> Apply the patch with `patch -p0 < idltowsdl_type_test_octet.diff' from
> trunk.
>
> Cheers,
> - Matteo
>
>
>
> Index:
> bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaObjectReaderTest.java
> ===================================================================
> ---
> bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaObjectReaderTest.java    (revision
> 508350)
> +++
> bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaObjectReaderTest.java    (working
> copy)
> @@ -128,7 +128,7 @@
>          InputStream iStream = oStream.create_input_stream();
>          CorbaObjectReader reader = new CorbaObjectReader(iStream);
>
> -        Byte octetValue = reader.readOctet();
> +        Short octetValue = reader.readOctet();
>          assertTrue(octetValue.byteValue() == (byte)27);
>      }
>
> Index:
> bindings/src/test/java/org/apache/yoko/bindings/corba/IdlToWsdlTypeTest.java
> ===================================================================
> ---
> bindings/src/test/java/org/apache/yoko/bindings/corba/IdlToWsdlTypeTest.java        (revision
> 508350)
> +++
> bindings/src/test/java/org/apache/yoko/bindings/corba/IdlToWsdlTypeTest.java        (working
> copy)
> @@ -113,7 +113,7 @@
>      // following empty methods override real implementation until test
> failures are resolved
>      public void testUnsignedLong() { }
>      public void testWchar() { }
> -    public void testOctet () { }
> +    //public void testOctet () { }
>      public void testAny () { }
>      public void testString() { }
>      public void testWstring() { }
> Index:
> bindings/src/test/java/org/apache/yoko/bindings/corba/AbstractIdlToWsdlTypeTestClient.java
> ===================================================================
> ---
> bindings/src/test/java/org/apache/yoko/bindings/corba/AbstractIdlToWsdlTypeTestClient.java
 (revision
> 508350)
> +++
> bindings/src/test/java/org/apache/yoko/bindings/corba/AbstractIdlToWsdlTypeTestClient.java
 (working
> copy)
> @@ -196,10 +196,10 @@
>              {0, 0},
>              {0, 1},
>              {0, MAX_UNSIGNED_LONG / 2},
> -            {0, MAX_UNSIGNED_LONG * 5 / 8},
> -            {0, MAX_UNSIGNED_LONG * 3 / 4},
>              {0, MAX_UNSIGNED_LONG - 1},
> -            {0, MAX_UNSIGNED_LONG}
> +            {0, MAX_UNSIGNED_LONG},
> +            {MAX_UNSIGNED_LONG, 0},
> +            {MAX_UNSIGNED_LONG, MAX_UNSIGNED_LONG}
>          };
>
>          for (int i = 0; i < valueSets.length; i++) {
> @@ -310,13 +310,13 @@
>
>      public void testOctet() throws Exception {
>          short valueSets[][] = {
> -            {0, 0},
> +            {0, 0},
>              {0, 1},
> -            {-1, 0},
> -            {Short.MIN_VALUE, Short.MAX_VALUE},
> -            {Short.MAX_VALUE, Short.MIN_VALUE}
> +            {0, 128},
> +            {0, 255}
> +            //{0, 256} // should fail here
>          };
> -
> +
>          for (int i = 0; i < valueSets.length; i++) {
>              short in = valueSets[i][0];
>              Holder<Short> inoutOrig = new Holder<Short>(valueSets[i][1]);
> Index:
> bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectReader.java
> ===================================================================
> ---
> bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectReader.java        (revision
> 508350)
> +++
> bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectReader.java        (working
> copy)
> @@ -75,7 +75,7 @@
>              ((CorbaPrimitiveHandler)obj).setValue(this.readWChar());
>              break;
>          case TCKind._tk_octet:
> -            Byte octetValue = this.readOctet();
> +            Short octetValue = this.readOctet();
>              ((CorbaPrimitiveHandler)obj).setValue(octetValue);
>              break;
>          case TCKind._tk_short:
> @@ -170,9 +170,13 @@
>          }
>      }
>
> -    public Byte readOctet() throws CorbaBindingException {
> -        try {
> -            return new Byte(stream.read_octet());
> +    public Short readOctet() throws CorbaBindingException {
> +        try {
> +            Short result = new Short(stream.read_octet());
> +            if (result < 0) {
> +                result = new Integer((result - Byte.MIN_VALUE) -
> Byte.MIN_VALUE).shortValue();
> +            }
> +            return result;
>          } catch (org.omg.CORBA.MARSHAL ex) {
>              LOG.log(Level.SEVERE, "CorbaObjectReader: could not read
> octet");
>              throw new CorbaBindingException("CorbaObjectReader: readOctet
> MARSHAL exception", ex);
> @@ -212,7 +216,13 @@
>
>      public BigInteger readULong() throws CorbaBindingException {
>          try {
> -            return new BigInteger(stream.read_ulong() + "");
> +            BigInteger result = new BigInteger(stream.read_ulong() + "");
> +            if (result.signum() == -1) {
> +                // 4294967296 == 2^32
> +                result = result.add(new BigInteger("4294967296"));
> +            }
> +            return result;
> +            //return new BigInteger(stream.read_ulong() + "");
>          } catch (org.omg.CORBA.MARSHAL ex) {
>              LOG.log(Level.SEVERE, "CorbaObjectReader: could not read
> unsigned long");
>              throw new CorbaBindingException("CorbaObjectReader: readULong
> MARSHAL exception", ex);
> Index:
> bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectWriter.java
> ===================================================================
> ---
> bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectWriter.java        (revision
> 508350)
> +++
> bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectWriter.java        (working
> copy)
> @@ -64,7 +64,7 @@
>              this.writeWChar
> ((Character)((CorbaPrimitiveHandler)obj).getValue());
>              break;
>          case TCKind._tk_octet:
> -            this.writeOctet
> ((Byte)((CorbaPrimitiveHandler)obj).getValue());
> +            this.writeOctet
> ((Short)((CorbaPrimitiveHandler)obj).getValue());
>              break;
>          case TCKind._tk_short:
>              this.writeShort
> ((Short)((CorbaPrimitiveHandler)obj).getValue());
> @@ -143,8 +143,11 @@
>          stream.write_wchar(c.charValue());
>      }
>
> -    public void writeOctet(Byte b) throws CorbaBindingException {
> -        stream.write_octet(b.byteValue());
> +    public void writeOctet(Short s) throws CorbaBindingException {
> +        if (s < 0 || s > 255) {
> +            throw new org.omg.CORBA.MARSHAL("CorbaObjectWriter:
> writeOctet MARSHAL exception");
> +        }
> +        stream.write_octet(s.byteValue());
>      }
>
>      public void writeShort(Short s) throws CorbaBindingException {
> Index:
> bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaPrimitiveHandler.java
> ===================================================================
> ---
> bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaPrimitiveHandler.java
     (revision
> 508350)
> +++
> bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaPrimitiveHandler.java
     (working
> copy)
> @@ -57,7 +57,7 @@
>              data = ((Character)value).toString();
>              break;
>          case TCKind._tk_octet:
> -            data = ((Byte)value).toString();
> +            data = ((Short)value).toString();
>              break;
>          case TCKind._tk_short:
>              data = ((Short)value).toString();
> @@ -109,7 +109,7 @@
>              value = new Character(data.charAt(0));
>              break;
>          case TCKind._tk_octet:
> -            value = new Byte(data);
> +            value = new Short(data);
>              break;
>          case TCKind._tk_short:
>              value = new Short(data);
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message