diff options
author | Matthew Newhook <matthew@zeroc.com> | 2014-10-23 16:28:09 -0230 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2014-10-23 16:28:09 -0230 |
commit | f6bb0396e7d8fd12ed50f72ab9fc99436d418576 (patch) | |
tree | ee6ef1cb32f2523839f210eb9ec3b924b97d5998 /java/test/Ice/classLoader | |
parent | Add Object.equals, and minor fix to HashMap.equals (diff) | |
download | ice-f6bb0396e7d8fd12ed50f72ab9fc99436d418576.tar.bz2 ice-f6bb0396e7d8fd12ed50f72ab9fc99436d418576.tar.xz ice-f6bb0396e7d8fd12ed50f72ab9fc99436d418576.zip |
More gradle changes.
Moved android stuff to its own package.
Moved java tests to src/main/java/test subdirectory.
Diffstat (limited to 'java/test/Ice/classLoader')
-rw-r--r-- | java/test/Ice/classLoader/AbstractClassI.java | 21 | ||||
-rw-r--r-- | java/test/Ice/classLoader/AllTests.java | 217 | ||||
-rw-r--r-- | java/test/Ice/classLoader/CertificateVerifierI.java | 19 | ||||
-rw-r--r-- | java/test/Ice/classLoader/Client.java | 39 | ||||
-rw-r--r-- | java/test/Ice/classLoader/InitialI.java | 55 | ||||
-rw-r--r-- | java/test/Ice/classLoader/PasswordCallbackI.java | 31 | ||||
-rw-r--r-- | java/test/Ice/classLoader/PluginFactoryI.java | 32 | ||||
-rw-r--r-- | java/test/Ice/classLoader/Server.java | 44 | ||||
-rw-r--r-- | java/test/Ice/classLoader/Test.ice | 36 | ||||
-rwxr-xr-x | java/test/Ice/classLoader/run.py | 23 |
10 files changed, 0 insertions, 517 deletions
diff --git a/java/test/Ice/classLoader/AbstractClassI.java b/java/test/Ice/classLoader/AbstractClassI.java deleted file mode 100644 index df7bcf8a4c4..00000000000 --- a/java/test/Ice/classLoader/AbstractClassI.java +++ /dev/null @@ -1,21 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2014 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.classLoader; - -import test.Ice.classLoader.Test.AbstractClass; - -class AbstractClassI extends AbstractClass -{ - @Override - public void - op(Ice.Current current) - { - } -} diff --git a/java/test/Ice/classLoader/AllTests.java b/java/test/Ice/classLoader/AllTests.java deleted file mode 100644 index d0181cff1a6..00000000000 --- a/java/test/Ice/classLoader/AllTests.java +++ /dev/null @@ -1,217 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2014 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.classLoader; - -import java.io.PrintWriter; - -import test.Ice.classLoader.Test.AbstractClass; -import test.Ice.classLoader.Test.ConcreteClass; -import test.Ice.classLoader.Test.E; -import test.Ice.classLoader.Test.InitialPrx; -import test.Ice.classLoader.Test.InitialPrxHelper; -import test.Util.Application; - -public class AllTests -{ - private static class MyObjectFactory implements Ice.ObjectFactory - { - @Override - public Ice.Object create(String type) - { - if(type.equals("::Test::AbstractClass")) - { - return new AbstractClassI(); - } - - assert (false); // Should never be reached - return null; - } - - @Override - public void destroy() - { - // Nothing to do - } - } - - private static class MyClassLoader extends ClassLoader - { - @Override - protected Class<?> loadClass(String name, boolean resolve) - throws ClassNotFoundException - { - _names.add(name); - return super.loadClass(name, resolve); - } - - void reset() - { - _names.clear(); - } - - boolean check(String name) - { - return _names.contains(name); - } - - private java.util.List<String> _names = new java.util.LinkedList<String>(); - } - - private static void - test(boolean b) - { - if(!b) - { - throw new RuntimeException(); - } - } - - public static void - allTests(Application app, boolean collocated) - { - Ice.Communicator communicator = app.communicator(); - PrintWriter out = app.getWriter(); - - // - // Verify that the class loader is used for Slice packages. - // - { - out.print("testing package... "); - out.flush(); - Ice.InitializationData initData = new Ice.InitializationData(); - initData.properties = communicator.getProperties()._clone(); - MyClassLoader classLoader = new MyClassLoader(); - initData.classLoader = classLoader; - Ice.Communicator ic = app.initialize(initData); - test(classLoader.check("test.Ice.classLoader.Test._Marker")); - ic.destroy(); - out.println("ok"); - } - - // - // Verify that the class loader is used for Ice plug-ins. - // - { - out.print("testing plug-in... "); - out.flush(); - Ice.InitializationData initData = new Ice.InitializationData(); - initData.properties = communicator.getProperties()._clone(); - initData.properties.setProperty("Ice.Plugin.Test", "test.Ice.classLoader.PluginFactoryI"); - MyClassLoader classLoader = new MyClassLoader(); - initData.classLoader = classLoader; - Ice.Communicator ic = app.initialize(initData); - test(classLoader.check("test.Ice.classLoader.PluginFactoryI")); - ic.destroy(); - out.println("ok"); - } - - // - // Verify that the class loader is used for IceSSL certificate verifiers and password callbacks. - // - if(communicator.getProperties().getProperty("Ice.Default.Protocol").equals("ssl")) - { - out.print("testing IceSSL certificate verifier and password callback... "); - out.flush(); - Ice.InitializationData initData = new Ice.InitializationData(); - initData.properties = communicator.getProperties()._clone(); - initData.properties.setProperty("IceSSL.CertVerifier", "test.Ice.classLoader.CertificateVerifierI"); - initData.properties.setProperty("IceSSL.PasswordCallback", "test.Ice.classLoader.PasswordCallbackI"); - MyClassLoader classLoader = new MyClassLoader(); - initData.classLoader = classLoader; - Ice.Communicator ic = app.initialize(initData); - test(classLoader.check("test.Ice.classLoader.CertificateVerifierI")); - test(classLoader.check("test.Ice.classLoader.PasswordCallbackI")); - ic.destroy(); - out.println("ok"); - } - - // - // Marshaling tests. - // - { - Ice.InitializationData initData = new Ice.InitializationData(); - initData.properties = communicator.getProperties()._clone(); - MyClassLoader classLoader = new MyClassLoader(); - initData.classLoader = classLoader; - Ice.Communicator ic = app.initialize(initData); - - String ref = "initial:default -p 12010"; - Ice.ObjectPrx base = ic.stringToProxy(ref); - test(base != null); - - InitialPrx initial = InitialPrxHelper.checkedCast(base); - test(initial != null); - - // - // Verify that the class loader is used for concrete classes. - // - { - out.print("testing concrete class... "); - out.flush(); - ConcreteClass cc = initial.getConcreteClass(); - test(cc != null); - test(classLoader.check("Test.ConcreteClass")); - test(classLoader.check("test.Ice.classLoader.Test.ConcreteClass")); - classLoader.reset(); - out.println("ok"); - } - - // - // Verify that the class loader is invoked when a factory is not installed, and is - // not invoked when a factory is installed. - // - { - out.print("testing abstract class... "); - out.flush(); - - try - { - initial.getAbstractClass(); - } - catch(Ice.NoObjectFactoryException ex) - { - // Expected. - } - test(classLoader.check("Test.AbstractClass")); - test(classLoader.check("test.Ice.classLoader.Test.AbstractClass")); - classLoader.reset(); - - ic.addObjectFactory(new MyObjectFactory(), "::Test::AbstractClass"); - AbstractClass ac = initial.getAbstractClass(); - test(ac != null); - test(!classLoader.check("Test.AbstractClass")); - test(!classLoader.check("test.Ice.classLoader.Test.AbstractClass")); - classLoader.reset(); - - out.println("ok"); - } - - // - // Verify that the class loader is used for user exceptions. - // - out.print("testing user exception... "); - out.flush(); - try - { - initial.throwException(); - test(false); - } - catch(E ex) - { - } - test(classLoader.check("Test.E")); - test(classLoader.check("test.Ice.classLoader.Test.E")); - out.println("ok"); - - initial.shutdown(); - ic.destroy(); - } - } -} diff --git a/java/test/Ice/classLoader/CertificateVerifierI.java b/java/test/Ice/classLoader/CertificateVerifierI.java deleted file mode 100644 index 3e681297f84..00000000000 --- a/java/test/Ice/classLoader/CertificateVerifierI.java +++ /dev/null @@ -1,19 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2014 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.classLoader; - -public class CertificateVerifierI implements IceSSL.CertificateVerifier -{ - @Override - public boolean verify(IceSSL.NativeConnectionInfo info) - { - return true; - } -} diff --git a/java/test/Ice/classLoader/Client.java b/java/test/Ice/classLoader/Client.java deleted file mode 100644 index 20152d6b598..00000000000 --- a/java/test/Ice/classLoader/Client.java +++ /dev/null @@ -1,39 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2014 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.classLoader; - -public class Client extends test.Util.Application -{ - @Override - public int run(String[] args) - { - AllTests.allTests(this, false); - return 0; - } - - @Override - protected Ice.InitializationData getInitData(Ice.StringSeqHolder argsH) - { - _initData = new Ice.InitializationData(); - _initData.properties = Ice.Util.createProperties(argsH); - _initData.properties.setProperty("Ice.Package.Test", "test.Ice.classLoader"); - return _initData; - } - - public static void main(String[] args) - { - Client app = new Client(); - int result = app.main("Client", args); - System.gc(); - System.exit(result); - } - - private Ice.InitializationData _initData; -} diff --git a/java/test/Ice/classLoader/InitialI.java b/java/test/Ice/classLoader/InitialI.java deleted file mode 100644 index a8056715aad..00000000000 --- a/java/test/Ice/classLoader/InitialI.java +++ /dev/null @@ -1,55 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2014 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.classLoader; - -import test.Ice.classLoader.Test.AbstractClass; -import test.Ice.classLoader.Test.ConcreteClass; -import test.Ice.classLoader.Test.E; -import test.Ice.classLoader.Test._InitialDisp; - -public final class InitialI extends _InitialDisp -{ - public - InitialI(Ice.ObjectAdapter adapter) - { - _adapter = adapter; - } - - @Override - public ConcreteClass - getConcreteClass(Ice.Current current) - { - return new ConcreteClass(); - } - - @Override - public AbstractClass - getAbstractClass(Ice.Current current) - { - return new AbstractClassI(); - } - - @Override - public void - throwException(Ice.Current current) - throws E - { - throw new E(); - } - - @Override - public void - shutdown(Ice.Current current) - { - _adapter.getCommunicator().shutdown(); - } - - private Ice.ObjectAdapter _adapter; -} diff --git a/java/test/Ice/classLoader/PasswordCallbackI.java b/java/test/Ice/classLoader/PasswordCallbackI.java deleted file mode 100644 index e5eba1462dd..00000000000 --- a/java/test/Ice/classLoader/PasswordCallbackI.java +++ /dev/null @@ -1,31 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2014 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.classLoader; - -public class PasswordCallbackI implements IceSSL.PasswordCallback -{ - @Override - public char[] getPassword(String alias) - { - return "password".toCharArray(); - } - - @Override - public char[] getTruststorePassword() - { - return "password".toCharArray(); - } - - @Override - public char[] getKeystorePassword() - { - return "password".toCharArray(); - } -} diff --git a/java/test/Ice/classLoader/PluginFactoryI.java b/java/test/Ice/classLoader/PluginFactoryI.java deleted file mode 100644 index 2416e04c420..00000000000 --- a/java/test/Ice/classLoader/PluginFactoryI.java +++ /dev/null @@ -1,32 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2014 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.classLoader; - -public class PluginFactoryI implements Ice.PluginFactory -{ - static class PluginI implements Ice.Plugin - { - @Override - public void initialize() - { - } - - @Override - public void destroy() - { - } - } - - @Override - public Ice.Plugin create(Ice.Communicator communicator, String name, String[] args) - { - return new PluginI(); - } -} diff --git a/java/test/Ice/classLoader/Server.java b/java/test/Ice/classLoader/Server.java deleted file mode 100644 index 79abca86364..00000000000 --- a/java/test/Ice/classLoader/Server.java +++ /dev/null @@ -1,44 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2014 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.classLoader; - -public class Server extends test.Util.Application -{ - @Override - public int run(String[] args) - { - Ice.Communicator communicator = communicator(); - Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); - Ice.Object object = new InitialI(adapter); - adapter.add(object, communicator.stringToIdentity("initial")); - adapter.activate(); - - return WAIT; - } - - @Override - 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.classLoader"); - initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010"); - initData.properties.setProperty("Ice.Default.SlicedFormat", "1"); - return initData; - } - - public static void main(String[] args) - { - Server app = new Server(); - int result = app.main("Server", args); - System.gc(); - System.exit(result); - } -} diff --git a/java/test/Ice/classLoader/Test.ice b/java/test/Ice/classLoader/Test.ice deleted file mode 100644 index 2df8659720e..00000000000 --- a/java/test/Ice/classLoader/Test.ice +++ /dev/null @@ -1,36 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2014 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.classLoader"]] -module Test -{ - -class ConcreteClass -{ - int i; -}; - -class AbstractClass -{ - void op(); -}; - -exception E {}; - -interface Initial -{ - ConcreteClass getConcreteClass(); - AbstractClass getAbstractClass(); - void throwException() throws E; - void shutdown(); -}; - -}; diff --git a/java/test/Ice/classLoader/run.py b/java/test/Ice/classLoader/run.py deleted file mode 100755 index 33fc2e8f3ac..00000000000 --- a/java/test/Ice/classLoader/run.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python -# ********************************************************************** -# -# Copyright (c) 2003-2014 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 - -TestUtil.clientServerTest() |