summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rwxr-xr-xjava/allTests.py1
-rw-r--r--java/build.xml1
-rw-r--r--java/src/Ice/InputStreamI.java4
-rw-r--r--java/src/Ice/OutputStreamI.java4
-rw-r--r--java/src/IceGridGUI/LiveDeployment/Server.java58
-rw-r--r--java/src/IceInternal/BasicStream.java12
-rw-r--r--java/src/IceInternal/Outgoing.java2
-rw-r--r--java/src/IceInternal/OutgoingAsync.java2
-rw-r--r--java/test/Ice/enums/AllTests.java273
-rw-r--r--java/test/Ice/enums/Client.java40
-rw-r--r--java/test/Ice/enums/Server.java43
-rw-r--r--java/test/Ice/enums/Test.ice89
-rw-r--r--java/test/Ice/enums/TestIntfI.java49
-rwxr-xr-xjava/test/Ice/enums/run.py26
14 files changed, 563 insertions, 41 deletions
diff --git a/java/allTests.py b/java/allTests.py
index 521d3ac80ad..cc2e1cd6b72 100755
--- a/java/allTests.py
+++ b/java/allTests.py
@@ -69,6 +69,7 @@ tests = [
("Ice/optional", ["once"]),
("Ice/admin", ["core"]),
("Ice/metrics", ["core", "nossl", "noipv6"]),
+ ("Ice/enums", ["once"]),
("IceBox/admin", ["core", "noipv6", "nomx"]),
("IceBox/configuration", ["core", "noipv6", "nomx"]),
("Freeze/dbmap", ["once"]),
diff --git a/java/build.xml b/java/build.xml
index d64ae6c8108..f8865ce25d3 100644
--- a/java/build.xml
+++ b/java/build.xml
@@ -523,6 +523,7 @@
<include name="test/Ice/optional/Test.ice" />
<include name="test/Ice/optional/TestAMD.ice" />
<include name="test/Ice/stream/Test.ice" />
+ <include name="test/Ice/enums/Test.ice" />
</fileset>
</slice2java>
diff --git a/java/src/Ice/InputStreamI.java b/java/src/Ice/InputStreamI.java
index 588fffd3dbb..1bd53326c14 100644
--- a/java/src/Ice/InputStreamI.java
+++ b/java/src/Ice/InputStreamI.java
@@ -187,9 +187,9 @@ public class InputStreamI implements InputStream
}
public int
- readEnum(int limit)
+ readEnum(int maxValue)
{
- return _is.readEnum(limit);
+ return _is.readEnum(maxValue);
}
public void
diff --git a/java/src/Ice/OutputStreamI.java b/java/src/Ice/OutputStreamI.java
index 8d2e2c086d4..16d2323b809 100644
--- a/java/src/Ice/OutputStreamI.java
+++ b/java/src/Ice/OutputStreamI.java
@@ -160,9 +160,9 @@ public class OutputStreamI implements OutputStream
}
public void
- writeEnum(int v, int limit)
+ writeEnum(int v, int maxValue)
{
- _os.writeEnum(v, limit);
+ _os.writeEnum(v, maxValue);
}
public void
diff --git a/java/src/IceGridGUI/LiveDeployment/Server.java b/java/src/IceGridGUI/LiveDeployment/Server.java
index 58dc8b0e2b9..31e5ca08fd8 100644
--- a/java/src/IceGridGUI/LiveDeployment/Server.java
+++ b/java/src/IceGridGUI/LiveDeployment/Server.java
@@ -608,69 +608,69 @@ public class Server extends ListArrayTreeNode
//
_icons = new Icon[8][2][2];
_icons[0][0][0] = Utils.getIcon("/icons/16x16/server_unknown.png");
- _icons[ServerState.Inactive.ordinal() + 1][0][0] = Utils.getIcon("/icons/16x16/server_inactive.png");
- _icons[ServerState.Activating.ordinal() + 1][0][0] = Utils.getIcon("/icons/16x16/server_activating.png");
- _icons[ServerState.ActivationTimedOut.ordinal() + 1][0][0] =
+ _icons[ServerState.Inactive.value() + 1][0][0] = Utils.getIcon("/icons/16x16/server_inactive.png");
+ _icons[ServerState.Activating.value() + 1][0][0] = Utils.getIcon("/icons/16x16/server_activating.png");
+ _icons[ServerState.ActivationTimedOut.value() + 1][0][0] =
Utils.getIcon("/icons/16x16/server_activating.png");
- _icons[ServerState.Active.ordinal() + 1][0][0] = Utils.getIcon("/icons/16x16/server_active.png");
- _icons[ServerState.Deactivating.ordinal() + 1][0][0] =
+ _icons[ServerState.Active.value() + 1][0][0] = Utils.getIcon("/icons/16x16/server_active.png");
+ _icons[ServerState.Deactivating.value() + 1][0][0] =
Utils.getIcon("/icons/16x16/server_deactivating.png");
- _icons[ServerState.Destroying.ordinal() + 1][0][0] = Utils.getIcon("/icons/16x16/server_destroying.png");
- _icons[ServerState.Destroyed.ordinal() + 1][0][0] = Utils.getIcon("/icons/16x16/server_destroyed.png");
+ _icons[ServerState.Destroying.value() + 1][0][0] = Utils.getIcon("/icons/16x16/server_destroying.png");
+ _icons[ServerState.Destroyed.value() + 1][0][0] = Utils.getIcon("/icons/16x16/server_destroyed.png");
//
// IceBox servers
//
_icons[0][1][0] = Utils.getIcon("/icons/16x16/icebox_server_unknown.png");
- _icons[ServerState.Inactive.ordinal() + 1][1][0] =
+ _icons[ServerState.Inactive.value() + 1][1][0] =
Utils.getIcon("/icons/16x16/icebox_server_inactive.png");
- _icons[ServerState.Activating.ordinal() + 1][1][0] =
+ _icons[ServerState.Activating.value() + 1][1][0] =
Utils.getIcon("/icons/16x16/icebox_server_activating.png");
- _icons[ServerState.ActivationTimedOut.ordinal() + 1][1][0] =
+ _icons[ServerState.ActivationTimedOut.value() + 1][1][0] =
Utils.getIcon("/icons/16x16/icebox_server_activating.png");
- _icons[ServerState.Active.ordinal() + 1][1][0] = Utils.getIcon("/icons/16x16/icebox_server_active.png");
- _icons[ServerState.Deactivating.ordinal() + 1][1][0] =
+ _icons[ServerState.Active.value() + 1][1][0] = Utils.getIcon("/icons/16x16/icebox_server_active.png");
+ _icons[ServerState.Deactivating.value() + 1][1][0] =
Utils.getIcon("/icons/16x16/icebox_server_deactivating.png");
- _icons[ServerState.Destroying.ordinal() + 1][1][0] =
+ _icons[ServerState.Destroying.value() + 1][1][0] =
Utils.getIcon("/icons/16x16/icebox_server_destroying.png");
- _icons[ServerState.Destroyed.ordinal() + 1][1][0] =
+ _icons[ServerState.Destroyed.value() + 1][1][0] =
Utils.getIcon("/icons/16x16/icebox_server_destroyed.png");
//
// Regular servers (disabled)
//
_icons[0][0][1] = Utils.getIcon("/icons/16x16/server_unknown.png");
- _icons[ServerState.Inactive.ordinal() + 1][0][1] =
+ _icons[ServerState.Inactive.value() + 1][0][1] =
Utils.getIcon("/icons/16x16/server_disabled_inactive.png");
- _icons[ServerState.Activating.ordinal() + 1][0][1] =
+ _icons[ServerState.Activating.value() + 1][0][1] =
Utils.getIcon("/icons/16x16/server_disabled_activating.png");
- _icons[ServerState.ActivationTimedOut.ordinal() + 1][0][1] =
+ _icons[ServerState.ActivationTimedOut.value() + 1][0][1] =
Utils.getIcon("/icons/16x16/server_disabled_activating.png");
- _icons[ServerState.Active.ordinal() + 1][0][1] = Utils.getIcon("/icons/16x16/server_disabled_active.png");
- _icons[ServerState.Deactivating.ordinal() + 1][0][1] =
+ _icons[ServerState.Active.value() + 1][0][1] = Utils.getIcon("/icons/16x16/server_disabled_active.png");
+ _icons[ServerState.Deactivating.value() + 1][0][1] =
Utils.getIcon("/icons/16x16/server_disabled_deactivating.png");
- _icons[ServerState.Destroying.ordinal() + 1][0][1] =
+ _icons[ServerState.Destroying.value() + 1][0][1] =
Utils.getIcon("/icons/16x16/server_disabled_destroying.png");
- _icons[ServerState.Destroyed.ordinal() + 1][0][1] =
+ _icons[ServerState.Destroyed.value() + 1][0][1] =
Utils.getIcon("/icons/16x16/server_disabled_destroyed.png");
//
// IceBox servers (disabled)
//
_icons[0][1][1] = Utils.getIcon("/icons/16x16/icebox_server_unknown.png");
- _icons[ServerState.Inactive.ordinal() + 1][1][1]
+ _icons[ServerState.Inactive.value() + 1][1][1]
= Utils.getIcon("/icons/16x16/icebox_server_disabled_inactive.png");
- _icons[ServerState.Activating.ordinal() + 1][1][1] =
+ _icons[ServerState.Activating.value() + 1][1][1] =
Utils.getIcon("/icons/16x16/icebox_server_disabled_activating.png");
- _icons[ServerState.ActivationTimedOut.ordinal() + 1][1][1] =
+ _icons[ServerState.ActivationTimedOut.value() + 1][1][1] =
Utils.getIcon("/icons/16x16/icebox_server_disabled_activating.png");
- _icons[ServerState.Active.ordinal() + 1][1][1] =
+ _icons[ServerState.Active.value() + 1][1][1] =
Utils.getIcon("/icons/16x16/icebox_server_disabled_active.png");
- _icons[ServerState.Deactivating.ordinal() + 1][1][1] =
+ _icons[ServerState.Deactivating.value() + 1][1][1] =
Utils.getIcon("/icons/16x16/icebox_server_disabled_deactivating.png");
- _icons[ServerState.Destroying.ordinal() + 1][1][1] =
+ _icons[ServerState.Destroying.value() + 1][1][1] =
Utils.getIcon("/icons/16x16/icebox_server_disabled_destroying.png");
- _icons[ServerState.Destroyed.ordinal() + 1][1][1] =
+ _icons[ServerState.Destroyed.value() + 1][1][1] =
Utils.getIcon("/icons/16x16/icebox_server_disabled_destroyed.png");
}
@@ -901,7 +901,7 @@ public class Server extends ListArrayTreeNode
}
else
{
- _stateIconIndex = _state.ordinal() + 1;
+ _stateIconIndex = _state.value() + 1;
}
if(_state == ServerState.Active && getRoot().getTree().isExpanded(getPath()))
diff --git a/java/src/IceInternal/BasicStream.java b/java/src/IceInternal/BasicStream.java
index 20a2ebf9121..7ca5ab9e4ac 100644
--- a/java/src/IceInternal/BasicStream.java
+++ b/java/src/IceInternal/BasicStream.java
@@ -1973,15 +1973,15 @@ public class BasicStream
}
public void
- writeEnum(int v, int limit)
+ writeEnum(int v, int maxValue)
{
if(isWriteEncoding_1_0())
{
- if(limit <= 127)
+ if(maxValue < 127)
{
writeByte((byte)v);
}
- else if(limit <= 32767)
+ else if(maxValue < 32767)
{
writeShort((short)v);
}
@@ -1997,15 +1997,15 @@ public class BasicStream
}
public int
- readEnum(int limit)
+ readEnum(int maxValue)
{
if(getReadEncoding().equals(Ice.Util.Encoding_1_0))
{
- if(limit <= 127)
+ if(maxValue < 127)
{
return readByte();
}
- else if(limit <= 32767)
+ else if(maxValue < 32767)
{
return readShort();
}
diff --git a/java/src/IceInternal/Outgoing.java b/java/src/IceInternal/Outgoing.java
index 90848d502e6..f2d2b6317fe 100644
--- a/java/src/IceInternal/Outgoing.java
+++ b/java/src/IceInternal/Outgoing.java
@@ -594,7 +594,7 @@ public final class Outgoing implements OutgoingMessageCallback
_os.writeString(operation);
- _os.writeByte((byte)mode.ordinal());
+ _os.writeByte((byte)mode.value());
if(context != null)
{
diff --git a/java/src/IceInternal/OutgoingAsync.java b/java/src/IceInternal/OutgoingAsync.java
index cb44b4ea4dc..83166e27103 100644
--- a/java/src/IceInternal/OutgoingAsync.java
+++ b/java/src/IceInternal/OutgoingAsync.java
@@ -63,7 +63,7 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa
_os.writeString(operation);
- _os.writeByte((byte)mode.ordinal());
+ _os.writeByte((byte)mode.value());
if(ctx != null)
{
diff --git a/java/test/Ice/enums/AllTests.java b/java/test/Ice/enums/AllTests.java
new file mode 100644
index 00000000000..b86c3191aa2
--- /dev/null
+++ b/java/test/Ice/enums/AllTests.java
@@ -0,0 +1,273 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+package test.Ice.enums;
+
+import test.Ice.enums.Test.*;
+import java.io.PrintWriter;
+
+public class AllTests
+{
+ private static void
+ test(boolean b)
+ {
+ if(!b)
+ {
+ throw new RuntimeException();
+ }
+ }
+
+ public static TestIntfPrx
+ allTests(Ice.Communicator communicator, PrintWriter out)
+ {
+ String ref = "test:default -p 12010";
+ Ice.ObjectPrx obj = communicator.stringToProxy(ref);
+ test(obj != null);
+ TestIntfPrx proxy = TestIntfPrxHelper.checkedCast(obj);
+ test(proxy != null);
+
+ out.print("testing enum values... ");
+ out.flush();
+
+ test(ByteEnum.benum1.value() == 0);
+ test(ByteEnum.benum2.value() == 1);
+ test(ByteEnum.benum3.value() == ByteConst1.value);
+ test(ByteEnum.benum4.value() == ByteConst1.value + 1);
+ test(ByteEnum.benum5.value() == ShortConst1.value);
+ test(ByteEnum.benum6.value() == ShortConst1.value + 1);
+ test(ByteEnum.benum7.value() == IntConst1.value);
+ test(ByteEnum.benum8.value() == IntConst1.value + 1);
+ test(ByteEnum.benum9.value() == LongConst1.value);
+ test(ByteEnum.benum10.value() == LongConst1.value + 1);
+ test(ByteEnum.benum11.value() == ByteConst2.value);
+
+ test(ByteEnum.valueOf(0) == ByteEnum.benum1);
+ test(ByteEnum.valueOf(1) == ByteEnum.benum2);
+ test(ByteEnum.valueOf(ByteConst1.value) == ByteEnum.benum3);
+ test(ByteEnum.valueOf(ByteConst1.value + 1) == ByteEnum.benum4);
+ test(ByteEnum.valueOf(ShortConst1.value) == ByteEnum.benum5);
+ test(ByteEnum.valueOf(ShortConst1.value + 1) == ByteEnum.benum6);
+ test(ByteEnum.valueOf(IntConst1.value) == ByteEnum.benum7);
+ test(ByteEnum.valueOf(IntConst1.value + 1) == ByteEnum.benum8);
+ test(ByteEnum.valueOf((int)LongConst1.value) == ByteEnum.benum9);
+ test(ByteEnum.valueOf((int)LongConst1.value + 1) == ByteEnum.benum10);
+ test(ByteEnum.valueOf(ByteConst2.value) == ByteEnum.benum11);
+
+ test(ShortEnum.senum1.value() == 3);
+ test(ShortEnum.senum2.value() == 4);
+ test(ShortEnum.senum3.value() == ByteConst1.value);
+ test(ShortEnum.senum4.value() == ByteConst1.value + 1);
+ test(ShortEnum.senum5.value() == ShortConst1.value);
+ test(ShortEnum.senum6.value() == ShortConst1.value + 1);
+ test(ShortEnum.senum7.value() == IntConst1.value);
+ test(ShortEnum.senum8.value() == IntConst1.value + 1);
+ test(ShortEnum.senum9.value() == LongConst1.value);
+ test(ShortEnum.senum10.value() == LongConst1.value + 1);
+ test(ShortEnum.senum11.value() == ShortConst2.value);
+
+ test(ShortEnum.valueOf(3) == ShortEnum.senum1);
+ test(ShortEnum.valueOf(4) == ShortEnum.senum2);
+ test(ShortEnum.valueOf(ByteConst1.value) == ShortEnum.senum3);
+ test(ShortEnum.valueOf(ByteConst1.value + 1) == ShortEnum.senum4);
+ test(ShortEnum.valueOf(ShortConst1.value) == ShortEnum.senum5);
+ test(ShortEnum.valueOf(ShortConst1.value + 1) == ShortEnum.senum6);
+ test(ShortEnum.valueOf(IntConst1.value) == ShortEnum.senum7);
+ test(ShortEnum.valueOf(IntConst1.value + 1) == ShortEnum.senum8);
+ test(ShortEnum.valueOf((int)LongConst1.value) == ShortEnum.senum9);
+ test(ShortEnum.valueOf((int)LongConst1.value + 1) == ShortEnum.senum10);
+ test(ShortEnum.valueOf(ShortConst2.value) == ShortEnum.senum11);
+
+ test(IntEnum.ienum1.value() == 0);
+ test(IntEnum.ienum2.value() == 1);
+ test(IntEnum.ienum3.value() == ByteConst1.value);
+ test(IntEnum.ienum4.value() == ByteConst1.value + 1);
+ test(IntEnum.ienum5.value() == ShortConst1.value);
+ test(IntEnum.ienum6.value() == ShortConst1.value + 1);
+ test(IntEnum.ienum7.value() == IntConst1.value);
+ test(IntEnum.ienum8.value() == IntConst1.value + 1);
+ test(IntEnum.ienum9.value() == LongConst1.value);
+ test(IntEnum.ienum10.value() == LongConst1.value + 1);
+ test(IntEnum.ienum11.value() == IntConst2.value);
+ test(IntEnum.ienum12.value() == LongConst2.value);
+
+ test(IntEnum.valueOf(0) == IntEnum.ienum1);
+ test(IntEnum.valueOf(1) == IntEnum.ienum2);
+ test(IntEnum.valueOf(ByteConst1.value) == IntEnum.ienum3);
+ test(IntEnum.valueOf(ByteConst1.value + 1) == IntEnum.ienum4);
+ test(IntEnum.valueOf(ShortConst1.value) == IntEnum.ienum5);
+ test(IntEnum.valueOf(ShortConst1.value + 1) == IntEnum.ienum6);
+ test(IntEnum.valueOf(IntConst1.value) == IntEnum.ienum7);
+ test(IntEnum.valueOf(IntConst1.value + 1) == IntEnum.ienum8);
+ test(IntEnum.valueOf((int)LongConst1.value) == IntEnum.ienum9);
+ test(IntEnum.valueOf((int)LongConst1.value + 1) == IntEnum.ienum10);
+ test(IntEnum.valueOf(IntConst2.value) == IntEnum.ienum11);
+ test(IntEnum.valueOf((int)LongConst2.value) == IntEnum.ienum12);
+
+ test(SimpleEnum.red.value() == 0);
+ test(SimpleEnum.green.value() == 1);
+ test(SimpleEnum.blue.value() == 2);
+
+ test(SimpleEnum.valueOf(0) == SimpleEnum.red);
+ test(SimpleEnum.valueOf(1) == SimpleEnum.green);
+ test(SimpleEnum.valueOf(2) == SimpleEnum.blue);
+
+ out.println("ok");
+
+ out.print("testing enum streaming... ");
+ out.flush();
+
+ Ice.OutputStream os;
+ byte[] bytes;
+
+ final boolean encoding_1_0 =
+ communicator.getProperties().getProperty("Ice.Default.EncodingVersion").equals("1.0");
+
+ os = Ice.Util.createOutputStream(communicator);
+ ByteEnum.benum11.ice_write(os);
+ bytes = os.finished();
+ test(bytes.length == 1); // ByteEnum should require one byte
+
+ os = Ice.Util.createOutputStream(communicator);
+ ShortEnum.senum11.ice_write(os);
+ bytes = os.finished();
+ test(bytes.length == (encoding_1_0 ? 2 : 5));
+
+ os = Ice.Util.createOutputStream(communicator);
+ IntEnum.ienum11.ice_write(os);
+ bytes = os.finished();
+ test(bytes.length == (encoding_1_0 ? 4 : 5));
+
+ os = Ice.Util.createOutputStream(communicator);
+ SimpleEnum.blue.ice_write(os);
+ bytes = os.finished();
+ test(bytes.length == 1); // SimpleEnum should require one byte
+
+ out.println("ok");
+
+ out.print("testing enum operations... ");
+ out.flush();
+
+ ByteEnumHolder byteEnum = new ByteEnumHolder();
+ test(proxy.opByte(ByteEnum.benum1, byteEnum) == ByteEnum.benum1);
+ test(byteEnum.value == ByteEnum.benum1);
+ test(proxy.opByte(ByteEnum.benum11, byteEnum) == ByteEnum.benum11);
+ test(byteEnum.value == ByteEnum.benum11);
+
+ ShortEnumHolder shortEnum = new ShortEnumHolder();
+ test(proxy.opShort(ShortEnum.senum1, shortEnum) == ShortEnum.senum1);
+ test(shortEnum.value == ShortEnum.senum1);
+ test(proxy.opShort(ShortEnum.senum11, shortEnum) == ShortEnum.senum11);
+ test(shortEnum.value == ShortEnum.senum11);
+
+ IntEnumHolder intEnum = new IntEnumHolder();
+ test(proxy.opInt(IntEnum.ienum1, intEnum) == IntEnum.ienum1);
+ test(intEnum.value == IntEnum.ienum1);
+ test(proxy.opInt(IntEnum.ienum11, intEnum) == IntEnum.ienum11);
+ test(intEnum.value == IntEnum.ienum11);
+ test(proxy.opInt(IntEnum.ienum12, intEnum) == IntEnum.ienum12);
+ test(intEnum.value == IntEnum.ienum12);
+
+ SimpleEnumHolder s = new SimpleEnumHolder();
+ test(proxy.opSimple(SimpleEnum.green, s) == SimpleEnum.green);
+ test(s.value == SimpleEnum.green);
+
+ out.println("ok");
+
+ out.print("testing enum exceptions... ");
+ out.flush();
+
+ try
+ {
+ os = Ice.Util.createOutputStream(communicator);
+ os.writeByte((byte)2); // Invalid enumerator
+ Ice.InputStream in = Ice.Util.createInputStream(communicator, os.finished());
+ ByteEnum.ice_read(in);
+ test(false);
+ }
+ catch(Ice.MarshalException ex)
+ {
+ }
+
+ try
+ {
+ os = Ice.Util.createOutputStream(communicator);
+ os.writeByte((byte)128); // Invalid enumerator
+ Ice.InputStream in = Ice.Util.createInputStream(communicator, os.finished());
+ ByteEnum.ice_read(in);
+ test(false);
+ }
+ catch(Ice.MarshalException ex)
+ {
+ }
+
+ try
+ {
+ os = Ice.Util.createOutputStream(communicator);
+ os.writeShort((short)-1); // Negative enumerators are not supported
+ Ice.InputStream in = Ice.Util.createInputStream(communicator, os.finished());
+ ShortEnum.ice_read(in);
+ test(false);
+ }
+ catch(Ice.MarshalException ex)
+ {
+ }
+
+ try
+ {
+ os = Ice.Util.createOutputStream(communicator);
+ os.writeShort((short)0); // Invalid enumerator
+ Ice.InputStream in = Ice.Util.createInputStream(communicator, os.finished());
+ ShortEnum.ice_read(in);
+ test(false);
+ }
+ catch(Ice.MarshalException ex)
+ {
+ }
+
+ try
+ {
+ os = Ice.Util.createOutputStream(communicator);
+ os.writeShort((short)32767); // Invalid enumerator
+ Ice.InputStream in = Ice.Util.createInputStream(communicator, os.finished());
+ ShortEnum.ice_read(in);
+ test(false);
+ }
+ catch(Ice.MarshalException ex)
+ {
+ }
+
+ try
+ {
+ os = Ice.Util.createOutputStream(communicator);
+ os.writeInt(-1); // Negative enumerators are not supported
+ Ice.InputStream in = Ice.Util.createInputStream(communicator, os.finished());
+ IntEnum.ice_read(in);
+ test(false);
+ }
+ catch(Ice.MarshalException ex)
+ {
+ }
+
+ try
+ {
+ os = Ice.Util.createOutputStream(communicator);
+ os.writeInt(2); // Invalid enumerator
+ Ice.InputStream in = Ice.Util.createInputStream(communicator, os.finished());
+ IntEnum.ice_read(in);
+ test(false);
+ }
+ catch(Ice.MarshalException ex)
+ {
+ }
+
+ out.println("ok");
+
+ return proxy;
+ }
+}
diff --git a/java/test/Ice/enums/Client.java b/java/test/Ice/enums/Client.java
new file mode 100644
index 00000000000..52585870fd9
--- /dev/null
+++ b/java/test/Ice/enums/Client.java
@@ -0,0 +1,40 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+package test.Ice.enums;
+
+import test.Ice.enums.Test.TestIntfPrx;
+
+public class Client extends test.Util.Application
+{
+ public int run(String[] args)
+ {
+ Ice.Communicator communicator = communicator();
+ TestIntfPrx test = AllTests.allTests(communicator, getWriter());
+ test.shutdown();
+ return 0;
+ }
+
+ protected Ice.InitializationData getInitData(Ice.StringSeqHolder argsH)
+ {
+ Ice.InitializationData initData = new Ice.InitializationData();
+ initData.properties = Ice.Util.createProperties(argsH);
+ initData.properties.setProperty("Ice.Package.Test", "test.Ice.enums");
+ return initData;
+ }
+
+ public static void main(String[] args)
+ {
+ Client c = new Client();
+ int status = c.main("Client", args);
+
+ System.gc();
+ System.exit(status);
+ }
+}
diff --git a/java/test/Ice/enums/Server.java b/java/test/Ice/enums/Server.java
new file mode 100644
index 00000000000..dc1e98554f9
--- /dev/null
+++ b/java/test/Ice/enums/Server.java
@@ -0,0 +1,43 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+package test.Ice.enums;
+
+public class Server extends test.Util.Application
+{
+ public int run(String[] args)
+ {
+ Ice.Communicator communicator = communicator();
+ Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
+ Ice.Object test = new TestIntfI();
+ adapter.add(test, communicator.stringToIdentity("test"));
+
+ adapter.activate();
+
+ return WAIT;
+ }
+
+ protected Ice.InitializationData getInitData(Ice.StringSeqHolder argsH)
+ {
+ Ice.InitializationData initData = new Ice.InitializationData();
+ initData.properties = Ice.Util.createProperties(argsH);
+ initData.properties.setProperty("Ice.Package.Test", "test.Ice.enums");
+ initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010");
+ return initData;
+ }
+
+ public static void main(String[] args)
+ {
+ Server c = new Server();
+ int status = c.main("Server", args);
+
+ System.gc();
+ System.exit(status);
+ }
+}
diff --git a/java/test/Ice/enums/Test.ice b/java/test/Ice/enums/Test.ice
new file mode 100644
index 00000000000..f843258fcbc
--- /dev/null
+++ b/java/test/Ice/enums/Test.ice
@@ -0,0 +1,89 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#pragma once
+
+[["java:package:test.Ice.enums"]]
+module Test
+{
+
+const byte ByteConst1 = 10;
+const short ShortConst1 = 20;
+const int IntConst1 = 30;
+const long LongConst1 = 40;
+
+const byte ByteConst2 = 126;
+const short ShortConst2 = 32766;
+const int IntConst2 = 2147483647;
+const long LongConst2 = 2147483646;
+
+enum ByteEnum
+{
+ benum1,
+ benum2,
+ benum3 = ByteConst1,
+ benum4,
+ benum5 = ShortConst1,
+ benum6,
+ benum7 = IntConst1,
+ benum8,
+ benum9 = LongConst1,
+ benum10,
+ benum11 = ByteConst2
+};
+
+enum ShortEnum
+{
+ senum1 = 3,
+ senum2,
+ senum3 = ByteConst1,
+ senum4,
+ senum5 = ShortConst1,
+ senum6,
+ senum7 = IntConst1,
+ senum8,
+ senum9 = LongConst1,
+ senum10,
+ senum11 = ShortConst2
+};
+
+enum IntEnum
+{
+ ienum1,
+ ienum2,
+ ienum3 = ByteConst1,
+ ienum4,
+ ienum5 = ShortConst1,
+ ienum6,
+ ienum7 = IntConst1,
+ ienum8,
+ ienum9 = LongConst1,
+ ienum10,
+ ienum11 = IntConst2,
+ ienum12 = LongConst2
+};
+
+enum SimpleEnum
+{
+ red,
+ green,
+ blue
+};
+
+interface TestIntf
+{
+ ByteEnum opByte(ByteEnum b1, out ByteEnum b2);
+ ShortEnum opShort(ShortEnum s1, out ShortEnum s2);
+ IntEnum opInt(IntEnum i1, out IntEnum i2);
+ SimpleEnum opSimple(SimpleEnum s1, out SimpleEnum s2);
+
+ void shutdown();
+};
+
+};
diff --git a/java/test/Ice/enums/TestIntfI.java b/java/test/Ice/enums/TestIntfI.java
new file mode 100644
index 00000000000..92fdf0a7a24
--- /dev/null
+++ b/java/test/Ice/enums/TestIntfI.java
@@ -0,0 +1,49 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+package test.Ice.enums;
+
+import test.Ice.enums.Test.*;
+
+public final class TestIntfI extends _TestIntfDisp
+{
+ public ByteEnum
+ opByte(ByteEnum b1, ByteEnumHolder b2, Ice.Current current)
+ {
+ b2.value = b1;
+ return b1;
+ }
+
+ public ShortEnum
+ opShort(ShortEnum s1, ShortEnumHolder s2, Ice.Current current)
+ {
+ s2.value = s1;
+ return s1;
+ }
+
+ public IntEnum
+ opInt(IntEnum i1, IntEnumHolder i2, Ice.Current current)
+ {
+ i2.value = i1;
+ return i1;
+ }
+
+ public SimpleEnum
+ opSimple(SimpleEnum s1, SimpleEnumHolder s2, Ice.Current current)
+ {
+ s2.value = s1;
+ return s1;
+ }
+
+ public void
+ shutdown(Ice.Current current)
+ {
+ current.adapter.getCommunicator().shutdown();
+ }
+}
diff --git a/java/test/Ice/enums/run.py b/java/test/Ice/enums/run.py
new file mode 100755
index 00000000000..690e20e4973
--- /dev/null
+++ b/java/test/Ice/enums/run.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+import os, sys
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+print("Running test with 1.0 encoding.")
+TestUtil.clientServerTest(additionalClientOptions="--Ice.Default.EncodingVersion=1.0", additionalServerOptions="--Ice.Default.EncodingVersion=1.0")
+print("Running test with 1.1 encoding.")
+TestUtil.clientServerTest()