diff --git a/jpype/_core.py b/jpype/_core.py index 61b44a90d..a6ea4c60c 100644 --- a/jpype/_core.py +++ b/jpype/_core.py @@ -334,7 +334,7 @@ def startJVM( # Don't remove # ok, setup the jpype system classloader and add to the path after startup - # this guarentees all classes have the same permissions as they did in the past + # this guarantees all classes have the same permissions as they did in the past from urllib.parse import quote extra_jvm_args += [ '-Djava.system.class.loader=org.jpype.JPypeClassLoader', @@ -563,17 +563,17 @@ def synchronized(obj): return _jpype._JMonitor(obj) -def getJVMVersion(): +def getJVMVersion() -> tuple[int, int, int] | tuple[int, ...]: """ Get the JVM version if the JVM is started. This function can be used to determine the version of the JVM. It is useful to help determine why a Jar has failed to load. Returns: - A typle with the (major, minor, revison) of the JVM if running. + A tuple with the (major, minor, revision) of the JVM if running. """ if not _jpype.isStarted(): - return (0, 0, 0) + return 0, 0, 0 import re runtime = _jpype.JClass('java.lang.Runtime') @@ -582,8 +582,11 @@ def getJVMVersion(): # Java 9+ has a version method if not version: version = runtime.version() - version = (re.match("([0-9.]+)", str(version)).group(1)) - return tuple([int(i) for i in version.split('.')]) + match = re.match("([0-9.]+)", str(version)) + if not match: + raise RuntimeError("could not determine JVM version") + version = match.group(1) + return tuple(int(i) for i in version.split('.')) @_jcustomizer.JImplementationFor("java.lang.Runtime") diff --git a/native/jpype_module/src/main/java/org/jpype/JPypeSignal.java b/native/jpype_module/src/main/java/org/jpype/JPypeSignal.java index 639d74235..4af36646f 100644 --- a/native/jpype_module/src/main/java/org/jpype/JPypeSignal.java +++ b/native/jpype_module/src/main/java/org/jpype/JPypeSignal.java @@ -15,6 +15,7 @@ **************************************************************************** */ package org.jpype; +import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Proxy; @@ -51,10 +52,22 @@ static void installHandlers() Class SignalHandler = Class.forName("sun.misc.SignalHandler"); main = Thread.currentThread(); Method method = Signal.getMethod("handle", Signal, SignalHandler); + + Object handler = Proxy.newProxyInstance(ClassLoader.getSystemClassLoader(), new Class[] + { + SignalHandler + }, new InvocationHandler() + { + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable + { + main.interrupt(); + interruptPy(); + return null; + } + }); Object intr = Signal.getDeclaredConstructor(String.class).newInstance("INT"); - method.invoke(null, intr, getSignalHandler(SignalHandler, 2)); - Object intrTerm = Signal.getDeclaredConstructor(String.class).newInstance("TERM"); - method.invoke(null, intrTerm, getSignalHandler(SignalHandler, 15)); + method.invoke(null, intr, handler); } catch (InvocationTargetException | IllegalArgumentException | IllegalAccessException | InstantiationException | ClassNotFoundException | NoSuchMethodException | SecurityException ex) { // If we don't get the signal handler run without it. (ANDROID) diff --git a/pyproject.toml b/pyproject.toml index f17c0984c..9b432333c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ maintainers = [ description = "A Python to Java bridge" readme = "README.rst" requires-python = ">=3.8" -license = {text = "License :: OSI Approved :: Apache Software License"} +license = {text = "Apache-2.0"} classifiers = [ 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.8', diff --git a/setupext/test_java.py b/setupext/test_java.py index f481c26af..f42366e1c 100644 --- a/setupext/test_java.py +++ b/setupext/test_java.py @@ -87,4 +87,4 @@ def run(self): self.announce(" %s" % " ".join(cmdStr), level=distutils.log.INFO) subprocess.check_call(cmdStr) subprocess.check_call(shlex.split( - "javadoc -Xdoclint:none test/harness/jpype/doc/Test.java -d test/classes/")) + "javadoc -Xdoclint:none test/harness/jpype/test/doc/Test.java -d test/classes/")) diff --git a/test/build.xml b/test/build.xml index 605f33529..c7502a5cc 100644 --- a/test/build.xml +++ b/test/build.xml @@ -1,16 +1,17 @@ - + - + + + - - + - - + + @@ -20,54 +21,118 @@ + source="${version}" + target="${version}"> - + + source="${version}" + target="${version}"> - + + source="${version}" + target="${version}" + debug="true" + debuglevel="lines,vars,source"> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/harness/java8/jpype/lambda/Test1.java b/test/harness/java8/org/jpype/test/lambda/Test1.java similarity index 97% rename from test/harness/java8/jpype/lambda/Test1.java rename to test/harness/java8/org/jpype/test/lambda/Test1.java index baffc3ae2..c0d4c8f72 100644 --- a/test/harness/java8/jpype/lambda/Test1.java +++ b/test/harness/java8/org/jpype/test/lambda/Test1.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.lambda; +package org.jpype.test.lambda; import java.util.function.Function; diff --git a/test/harness/java9/org/jpype/mrjar/B.java b/test/harness/java9/org/jpype/mrjar/B.java new file mode 100644 index 000000000..bb68ba62b --- /dev/null +++ b/test/harness/java9/org/jpype/mrjar/B.java @@ -0,0 +1,9 @@ +package org.jpype.mrjar; + +public class B +{ + public String call() + { + return "9"; + } +} diff --git a/test/harness/java9/jpype/method/Caller.java b/test/harness/java9/org/jpype/test/method/Caller.java similarity index 98% rename from test/harness/java9/jpype/method/Caller.java rename to test/harness/java9/org/jpype/test/method/Caller.java index c1977e388..cbc17f0c8 100644 --- a/test/harness/java9/jpype/method/Caller.java +++ b/test/harness/java9/org/jpype/test/method/Caller.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.method; +package org.jpype.test.method; import jdk.internal.reflect.CallerSensitive; diff --git a/test/harness/jpype/str/Bad.java b/test/harness/jpype/str/Bad.java deleted file mode 100644 index 609de1d7e..000000000 --- a/test/harness/jpype/str/Bad.java +++ /dev/null @@ -1,24 +0,0 @@ -/* **************************************************************************** - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - See NOTICE file for details. -**************************************************************************** */ -package jpype.str; - -public class Bad -{ - public String toString() - { - return null; - } -} diff --git a/project/jars/missing/src/org/jpype/missing/Test.java b/test/harness/org/jpype/missing/Test.java similarity index 100% rename from project/jars/missing/src/org/jpype/missing/Test.java rename to test/harness/org/jpype/missing/Test.java diff --git a/test/harness/jpype/array/Test2.java b/test/harness/org/jpype/test/array/Test2.java similarity index 96% rename from test/harness/jpype/array/Test2.java rename to test/harness/org/jpype/test/array/Test2.java index 585871778..d794580f6 100644 --- a/test/harness/jpype/array/Test2.java +++ b/test/harness/org/jpype/test/array/Test2.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.array; +package org.jpype.test.array; public class Test2 { diff --git a/test/harness/jpype/array/TestArray.java b/test/harness/org/jpype/test/array/TestArray.java similarity index 97% rename from test/harness/jpype/array/TestArray.java rename to test/harness/org/jpype/test/array/TestArray.java index 315ccb2ed..3957b5cef 100644 --- a/test/harness/jpype/array/TestArray.java +++ b/test/harness/org/jpype/test/array/TestArray.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.array; +package org.jpype.test.array; public class TestArray { diff --git a/test/harness/jpype/attr/ClassWithBuffer.java b/test/harness/org/jpype/test/attr/ClassWithBuffer.java similarity index 96% rename from test/harness/jpype/attr/ClassWithBuffer.java rename to test/harness/org/jpype/test/attr/ClassWithBuffer.java index 04fae79fe..e57c0d3cf 100644 --- a/test/harness/jpype/attr/ClassWithBuffer.java +++ b/test/harness/org/jpype/test/attr/ClassWithBuffer.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.attr; +package org.jpype.test.attr; import java.awt.image.BufferStrategy; diff --git a/test/harness/jpype/attr/Holder.java b/test/harness/org/jpype/test/attr/Holder.java similarity index 96% rename from test/harness/jpype/attr/Holder.java rename to test/harness/org/jpype/test/attr/Holder.java index 3621da498..f4886d508 100644 --- a/test/harness/jpype/attr/Holder.java +++ b/test/harness/org/jpype/test/attr/Holder.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.attr; +package org.jpype.test.attr; public class Holder { diff --git a/test/harness/jpype/attr/SubHolder.java b/test/harness/org/jpype/test/attr/SubHolder.java similarity index 96% rename from test/harness/jpype/attr/SubHolder.java rename to test/harness/org/jpype/test/attr/SubHolder.java index 3f9a5b171..5fb3cdb87 100644 --- a/test/harness/jpype/attr/SubHolder.java +++ b/test/harness/org/jpype/test/attr/SubHolder.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.attr; +package org.jpype.test.attr; public class SubHolder extends Holder implements java.io.Serializable { diff --git a/test/harness/jpype/attr/SyntheticMethods.java b/test/harness/org/jpype/test/attr/SyntheticMethods.java similarity index 97% rename from test/harness/jpype/attr/SyntheticMethods.java rename to test/harness/org/jpype/test/attr/SyntheticMethods.java index b4217fdf7..b3d9e6959 100644 --- a/test/harness/jpype/attr/SyntheticMethods.java +++ b/test/harness/org/jpype/test/attr/SyntheticMethods.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.attr; +package org.jpype.test.attr; import java.util.List; diff --git a/test/harness/jpype/attr/Test1.java b/test/harness/org/jpype/test/attr/Test1.java similarity index 98% rename from test/harness/jpype/attr/Test1.java rename to test/harness/org/jpype/test/attr/Test1.java index 8e17cad18..f699caeea 100644 --- a/test/harness/jpype/attr/Test1.java +++ b/test/harness/org/jpype/test/attr/Test1.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.attr; +package org.jpype.test.attr; public class Test1 { diff --git a/test/harness/jpype/attr/Test2.java b/test/harness/org/jpype/test/attr/Test2.java similarity index 97% rename from test/harness/jpype/attr/Test2.java rename to test/harness/org/jpype/test/attr/Test2.java index f1b60cec9..1e6f0ee2d 100644 --- a/test/harness/jpype/attr/Test2.java +++ b/test/harness/org/jpype/test/attr/Test2.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.attr; +package org.jpype.test.attr; public class Test2 extends Test1 { diff --git a/test/harness/jpype/attr/TestKeywords.java b/test/harness/org/jpype/test/attr/TestKeywords.java similarity index 96% rename from test/harness/jpype/attr/TestKeywords.java rename to test/harness/org/jpype/test/attr/TestKeywords.java index 03dd4e86e..c9fa2fc21 100644 --- a/test/harness/jpype/attr/TestKeywords.java +++ b/test/harness/org/jpype/test/attr/TestKeywords.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.attr; +package org.jpype.test.attr; public class TestKeywords { diff --git a/test/harness/jpype/attr/TestOverloadA.java b/test/harness/org/jpype/test/attr/TestOverloadA.java similarity index 96% rename from test/harness/jpype/attr/TestOverloadA.java rename to test/harness/org/jpype/test/attr/TestOverloadA.java index 4aeba2ff2..c466b1391 100644 --- a/test/harness/jpype/attr/TestOverloadA.java +++ b/test/harness/org/jpype/test/attr/TestOverloadA.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.attr; +package org.jpype.test.attr; public class TestOverloadA { diff --git a/test/harness/jpype/attr/TestOverloadB.java b/test/harness/org/jpype/test/attr/TestOverloadB.java similarity index 96% rename from test/harness/jpype/attr/TestOverloadB.java rename to test/harness/org/jpype/test/attr/TestOverloadB.java index e90f6e59e..efc89d5b6 100644 --- a/test/harness/jpype/attr/TestOverloadB.java +++ b/test/harness/org/jpype/test/attr/TestOverloadB.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.attr; +package org.jpype.test.attr; public class TestOverloadB extends TestOverloadA { diff --git a/test/harness/jpype/attr/TestOverloadC.java b/test/harness/org/jpype/test/attr/TestOverloadC.java similarity index 96% rename from test/harness/jpype/attr/TestOverloadC.java rename to test/harness/org/jpype/test/attr/TestOverloadC.java index a3fb98841..89d602280 100644 --- a/test/harness/jpype/attr/TestOverloadC.java +++ b/test/harness/org/jpype/test/attr/TestOverloadC.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.attr; +package org.jpype.test.attr; public class TestOverloadC extends TestOverloadB { diff --git a/test/harness/jpype/boxed/Boxed.java b/test/harness/org/jpype/test/boxed/Boxed.java similarity index 98% rename from test/harness/jpype/boxed/Boxed.java rename to test/harness/org/jpype/test/boxed/Boxed.java index e6712d3df..3b5004530 100644 --- a/test/harness/jpype/boxed/Boxed.java +++ b/test/harness/org/jpype/test/boxed/Boxed.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.boxed; +package org.jpype.test.boxed; public class Boxed { diff --git a/test/harness/jpype/classhints/ClassHintsTest.java b/test/harness/org/jpype/test/classhints/ClassHintsTest.java similarity index 96% rename from test/harness/jpype/classhints/ClassHintsTest.java rename to test/harness/org/jpype/test/classhints/ClassHintsTest.java index f11c15738..106afe893 100644 --- a/test/harness/jpype/classhints/ClassHintsTest.java +++ b/test/harness/org/jpype/test/classhints/ClassHintsTest.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.classhints; +package org.jpype.test.classhints; public class ClassHintsTest { diff --git a/test/harness/jpype/classhints/Custom.java b/test/harness/org/jpype/test/classhints/Custom.java similarity index 95% rename from test/harness/jpype/classhints/Custom.java rename to test/harness/org/jpype/test/classhints/Custom.java index 78df00538..f6123aed1 100644 --- a/test/harness/jpype/classhints/Custom.java +++ b/test/harness/org/jpype/test/classhints/Custom.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.classhints; +package org.jpype.test.classhints; public interface Custom { diff --git a/test/harness/jpype/closeable/CloseableTest.java b/test/harness/org/jpype/test/closeable/CloseableTest.java similarity index 97% rename from test/harness/jpype/closeable/CloseableTest.java rename to test/harness/org/jpype/test/closeable/CloseableTest.java index 9d3789479..d624f79f6 100644 --- a/test/harness/jpype/closeable/CloseableTest.java +++ b/test/harness/org/jpype/test/closeable/CloseableTest.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.closeable; +package org.jpype.test.closeable; class CloseableTest implements java.io.Closeable { diff --git a/test/harness/jpype/collection/CollectionTest.java b/test/harness/org/jpype/test/collection/CollectionTest.java similarity index 96% rename from test/harness/jpype/collection/CollectionTest.java rename to test/harness/org/jpype/test/collection/CollectionTest.java index 61a3aeb37..fef180237 100644 --- a/test/harness/jpype/collection/CollectionTest.java +++ b/test/harness/org/jpype/test/collection/CollectionTest.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.collection; +package org.jpype.test.collection; import java.util.Collection; import java.util.Map; diff --git a/test/harness/jpype/collection/TestEnum.java b/test/harness/org/jpype/test/collection/TestEnum.java similarity index 95% rename from test/harness/jpype/collection/TestEnum.java rename to test/harness/org/jpype/test/collection/TestEnum.java index 6db98723d..32a62f25e 100644 --- a/test/harness/jpype/collection/TestEnum.java +++ b/test/harness/org/jpype/test/collection/TestEnum.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.collection; +package org.jpype.test.collection; enum TestEnum { diff --git a/test/harness/jpype/common/Fixture.java b/test/harness/org/jpype/test/common/Fixture.java similarity index 99% rename from test/harness/jpype/common/Fixture.java rename to test/harness/org/jpype/test/common/Fixture.java index 38bf9c794..a40985391 100644 --- a/test/harness/jpype/common/Fixture.java +++ b/test/harness/org/jpype/test/common/Fixture.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.common; +package org.jpype.test.common; public class Fixture { diff --git a/test/harness/jpype/common/OnShutdown.java b/test/harness/org/jpype/test/common/OnShutdown.java similarity index 98% rename from test/harness/jpype/common/OnShutdown.java rename to test/harness/org/jpype/test/common/OnShutdown.java index ff40de03f..18068b79d 100644 --- a/test/harness/jpype/common/OnShutdown.java +++ b/test/harness/org/jpype/test/common/OnShutdown.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.common; +package org.jpype.test.common; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; diff --git a/test/harness/jpype/doc/Test.java b/test/harness/org/jpype/test/doc/Test.java similarity index 98% rename from test/harness/jpype/doc/Test.java rename to test/harness/org/jpype/test/doc/Test.java index a2de9ec68..f44c36c26 100644 --- a/test/harness/jpype/doc/Test.java +++ b/test/harness/org/jpype/test/doc/Test.java @@ -1,7 +1,7 @@ /* * Attempt at javadoc coverage test. */ -package jpype.doc; +package org.jpype.test.doc; /** * A bunch of random stuff. diff --git a/test/harness/jpype/exc/ChildTestException.java b/test/harness/org/jpype/test/exc/ChildTestException.java similarity index 96% rename from test/harness/jpype/exc/ChildTestException.java rename to test/harness/org/jpype/test/exc/ChildTestException.java index 37015c4c9..d252e10a6 100644 --- a/test/harness/jpype/exc/ChildTestException.java +++ b/test/harness/org/jpype/test/exc/ChildTestException.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.exc; +package org.jpype.test.exc; public class ChildTestException extends ParentTestException { diff --git a/test/harness/jpype/exc/ExceptionTest.java b/test/harness/org/jpype/test/exc/ExceptionTest.java similarity index 98% rename from test/harness/jpype/exc/ExceptionTest.java rename to test/harness/org/jpype/test/exc/ExceptionTest.java index 981c5490f..67206ba8e 100644 --- a/test/harness/jpype/exc/ExceptionTest.java +++ b/test/harness/org/jpype/test/exc/ExceptionTest.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.exc; +package org.jpype.test.exc; public class ExceptionTest { diff --git a/test/harness/jpype/exc/ExceptionThrower.java b/test/harness/org/jpype/test/exc/ExceptionThrower.java similarity index 96% rename from test/harness/jpype/exc/ExceptionThrower.java rename to test/harness/org/jpype/test/exc/ExceptionThrower.java index 5a04cd3cb..353e3139d 100644 --- a/test/harness/jpype/exc/ExceptionThrower.java +++ b/test/harness/org/jpype/test/exc/ExceptionThrower.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.exc; +package org.jpype.test.exc; interface ExceptionThrower { diff --git a/test/harness/jpype/exc/ParentTestException.java b/test/harness/org/jpype/test/exc/ParentTestException.java similarity index 96% rename from test/harness/jpype/exc/ParentTestException.java rename to test/harness/org/jpype/test/exc/ParentTestException.java index 5fdd2cc3b..c6b2747b4 100644 --- a/test/harness/jpype/exc/ParentTestException.java +++ b/test/harness/org/jpype/test/exc/ParentTestException.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.exc; +package org.jpype.test.exc; public class ParentTestException extends java.lang.Exception { diff --git a/test/harness/jpype/exc/WierdException.java b/test/harness/org/jpype/test/exc/WierdException.java similarity index 97% rename from test/harness/jpype/exc/WierdException.java rename to test/harness/org/jpype/test/exc/WierdException.java index db08b04f3..f166db99d 100644 --- a/test/harness/jpype/exc/WierdException.java +++ b/test/harness/org/jpype/test/exc/WierdException.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.exc; +package org.jpype.test.exc; public class WierdException extends Exception { diff --git a/test/harness/org/jpype/fail/BadInitializer.java b/test/harness/org/jpype/test/fail/BadInitializer.java similarity index 96% rename from test/harness/org/jpype/fail/BadInitializer.java rename to test/harness/org/jpype/test/fail/BadInitializer.java index 22336f80c..055bedc4c 100644 --- a/test/harness/org/jpype/fail/BadInitializer.java +++ b/test/harness/org/jpype/test/fail/BadInitializer.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package org.jpype.fail; +package org.jpype.test.fail; public class BadInitializer { diff --git a/test/harness/org/jpype/fail/BadInitializer2.java b/test/harness/org/jpype/test/fail/BadInitializer2.java similarity index 97% rename from test/harness/org/jpype/fail/BadInitializer2.java rename to test/harness/org/jpype/test/fail/BadInitializer2.java index 8c146c842..2a8e20434 100644 --- a/test/harness/org/jpype/fail/BadInitializer2.java +++ b/test/harness/org/jpype/test/fail/BadInitializer2.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package org.jpype.fail; +package org.jpype.test.fail; // To test this with more than one path, we need a second // copy. Java caches the result of the first attempt diff --git a/test/harness/jpype/functional/Annotated.java b/test/harness/org/jpype/test/functional/Annotated.java similarity index 95% rename from test/harness/jpype/functional/Annotated.java rename to test/harness/org/jpype/test/functional/Annotated.java index 4c0a366d1..e5e177cd6 100644 --- a/test/harness/jpype/functional/Annotated.java +++ b/test/harness/org/jpype/test/functional/Annotated.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.functional; +package org.jpype.test.functional; @FunctionalInterface public interface Annotated diff --git a/test/harness/jpype/functional/AnnotatedWithObjectMethods.java b/test/harness/org/jpype/test/functional/AnnotatedWithObjectMethods.java similarity index 96% rename from test/harness/jpype/functional/AnnotatedWithObjectMethods.java rename to test/harness/org/jpype/test/functional/AnnotatedWithObjectMethods.java index 1201d81da..293b02891 100644 --- a/test/harness/jpype/functional/AnnotatedWithObjectMethods.java +++ b/test/harness/org/jpype/test/functional/AnnotatedWithObjectMethods.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.functional; +package org.jpype.test.functional; @FunctionalInterface public interface AnnotatedWithObjectMethods diff --git a/test/harness/jpype/functional/ExtendsFunctional.java b/test/harness/org/jpype/test/functional/ExtendsFunctional.java similarity index 95% rename from test/harness/jpype/functional/ExtendsFunctional.java rename to test/harness/org/jpype/test/functional/ExtendsFunctional.java index 853091a4d..a79cca4c4 100644 --- a/test/harness/jpype/functional/ExtendsFunctional.java +++ b/test/harness/org/jpype/test/functional/ExtendsFunctional.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.functional; +package org.jpype.test.functional; public interface ExtendsFunctional extends NonAnnotated { diff --git a/test/harness/jpype/functional/ExtendsNonFunctional.java b/test/harness/org/jpype/test/functional/ExtendsNonFunctional.java similarity index 95% rename from test/harness/jpype/functional/ExtendsNonFunctional.java rename to test/harness/org/jpype/test/functional/ExtendsNonFunctional.java index 6b88e7365..842c151cc 100644 --- a/test/harness/jpype/functional/ExtendsNonFunctional.java +++ b/test/harness/org/jpype/test/functional/ExtendsNonFunctional.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.functional; +package org.jpype.test.functional; public interface ExtendsNonFunctional extends NonAnnotated { diff --git a/test/harness/jpype/functional/NonAnnotated.java b/test/harness/org/jpype/test/functional/NonAnnotated.java similarity index 95% rename from test/harness/jpype/functional/NonAnnotated.java rename to test/harness/org/jpype/test/functional/NonAnnotated.java index 973dda077..6d71f281f 100644 --- a/test/harness/jpype/functional/NonAnnotated.java +++ b/test/harness/org/jpype/test/functional/NonAnnotated.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.functional; +package org.jpype.test.functional; public interface NonAnnotated { diff --git a/test/harness/jpype/functional/NonAnnotatedWithObjectMethods.java b/test/harness/org/jpype/test/functional/NonAnnotatedWithObjectMethods.java similarity index 96% rename from test/harness/jpype/functional/NonAnnotatedWithObjectMethods.java rename to test/harness/org/jpype/test/functional/NonAnnotatedWithObjectMethods.java index 72b275834..ceb3a6b56 100644 --- a/test/harness/jpype/functional/NonAnnotatedWithObjectMethods.java +++ b/test/harness/org/jpype/test/functional/NonAnnotatedWithObjectMethods.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.functional; +package org.jpype.test.functional; public interface NonAnnotatedWithObjectMethods { diff --git a/test/harness/jpype/functional/RedeclaresAnnotated.java b/test/harness/org/jpype/test/functional/RedeclaresAnnotated.java similarity index 95% rename from test/harness/jpype/functional/RedeclaresAnnotated.java rename to test/harness/org/jpype/test/functional/RedeclaresAnnotated.java index ac75b25f6..cfe988976 100644 --- a/test/harness/jpype/functional/RedeclaresAnnotated.java +++ b/test/harness/org/jpype/test/functional/RedeclaresAnnotated.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.functional; +package org.jpype.test.functional; public interface RedeclaresAnnotated extends Annotated { diff --git a/test/harness/jpype/functional/RedeclaresNonAnnotated.java b/test/harness/org/jpype/test/functional/RedeclaresNonAnnotated.java similarity index 95% rename from test/harness/jpype/functional/RedeclaresNonAnnotated.java rename to test/harness/org/jpype/test/functional/RedeclaresNonAnnotated.java index 038cdfe70..84f0c49bf 100644 --- a/test/harness/jpype/functional/RedeclaresNonAnnotated.java +++ b/test/harness/org/jpype/test/functional/RedeclaresNonAnnotated.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.functional; +package org.jpype.test.functional; public interface RedeclaresNonAnnotated extends NonAnnotated { diff --git a/project/jars/late/src/org/jpype/late/Test.java b/test/harness/org/jpype/test/late/Test.java similarity index 76% rename from project/jars/late/src/org/jpype/late/Test.java rename to test/harness/org/jpype/test/late/Test.java index c8ed153fd..e10880cd9 100644 --- a/project/jars/late/src/org/jpype/late/Test.java +++ b/test/harness/org/jpype/test/late/Test.java @@ -1,4 +1,4 @@ -package org.jpype.late; +package org.jpype.test.late; public class Test { diff --git a/project/jars/late/src/org/jpype/late2/Test.java b/test/harness/org/jpype/test/late2/Test.java similarity index 75% rename from project/jars/late/src/org/jpype/late2/Test.java rename to test/harness/org/jpype/test/late2/Test.java index 26041d871..220a1e629 100644 --- a/project/jars/late/src/org/jpype/late2/Test.java +++ b/test/harness/org/jpype/test/late2/Test.java @@ -1,4 +1,4 @@ -package org.jpype.late2; +package org.jpype.test.late2; public class Test { diff --git a/test/harness/jpype/mro/A.java b/test/harness/org/jpype/test/mro/A.java similarity index 96% rename from test/harness/jpype/mro/A.java rename to test/harness/org/jpype/test/mro/A.java index 620d46607..5baf00d5f 100644 --- a/test/harness/jpype/mro/A.java +++ b/test/harness/org/jpype/test/mro/A.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.mro; +package org.jpype.test.mro; interface A extends E, F { diff --git a/test/harness/jpype/mro/B.java b/test/harness/org/jpype/test/mro/B.java similarity index 96% rename from test/harness/jpype/mro/B.java rename to test/harness/org/jpype/test/mro/B.java index bff3944c7..d47e0b7c9 100644 --- a/test/harness/jpype/mro/B.java +++ b/test/harness/org/jpype/test/mro/B.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.mro; +package org.jpype.test.mro; interface B extends D, A { diff --git a/test/harness/jpype/mro/C.java b/test/harness/org/jpype/test/mro/C.java similarity index 96% rename from test/harness/jpype/mro/C.java rename to test/harness/org/jpype/test/mro/C.java index 2a61502be..e59faa398 100644 --- a/test/harness/jpype/mro/C.java +++ b/test/harness/org/jpype/test/mro/C.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.mro; +package org.jpype.test.mro; public class C implements A, B { diff --git a/test/harness/jpype/mro/D.java b/test/harness/org/jpype/test/mro/D.java similarity index 96% rename from test/harness/jpype/mro/D.java rename to test/harness/org/jpype/test/mro/D.java index 08c4caecd..8c943a123 100644 --- a/test/harness/jpype/mro/D.java +++ b/test/harness/org/jpype/test/mro/D.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.mro; +package org.jpype.test.mro; interface D { diff --git a/test/harness/jpype/mro/E.java b/test/harness/org/jpype/test/mro/E.java similarity index 96% rename from test/harness/jpype/mro/E.java rename to test/harness/org/jpype/test/mro/E.java index 28b8d50e6..ad86e674f 100644 --- a/test/harness/jpype/mro/E.java +++ b/test/harness/org/jpype/test/mro/E.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.mro; +package org.jpype.test.mro; interface E { diff --git a/test/harness/jpype/mro/F.java b/test/harness/org/jpype/test/mro/F.java similarity index 96% rename from test/harness/jpype/mro/F.java rename to test/harness/org/jpype/test/mro/F.java index 98a6d40aa..a83916b1e 100644 --- a/test/harness/jpype/mro/F.java +++ b/test/harness/org/jpype/test/mro/F.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.mro; +package org.jpype.test.mro; interface F { diff --git a/test/harness/jpype/mro/MultipleInterfaces.java b/test/harness/org/jpype/test/mro/MultipleInterfaces.java similarity index 97% rename from test/harness/jpype/mro/MultipleInterfaces.java rename to test/harness/org/jpype/test/mro/MultipleInterfaces.java index 43f7a9a24..b53c3e62b 100644 --- a/test/harness/jpype/mro/MultipleInterfaces.java +++ b/test/harness/org/jpype/test/mro/MultipleInterfaces.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.mro; +package org.jpype.test.mro; interface IA { diff --git a/test/harness/jpype/numeric/NumericTest.java b/test/harness/org/jpype/test/numeric/NumericTest.java similarity index 96% rename from test/harness/jpype/numeric/NumericTest.java rename to test/harness/org/jpype/test/numeric/NumericTest.java index e2d91b63c..ac56a3737 100644 --- a/test/harness/jpype/numeric/NumericTest.java +++ b/test/harness/org/jpype/test/numeric/NumericTest.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.numeric; +package org.jpype.test.numeric; public class NumericTest { diff --git a/test/harness/jpype/objectwrapper/Static.java b/test/harness/org/jpype/test/objectwrapper/Static.java similarity index 95% rename from test/harness/jpype/objectwrapper/Static.java rename to test/harness/org/jpype/test/objectwrapper/Static.java index 9905940d9..dbaac1475 100644 --- a/test/harness/jpype/objectwrapper/Static.java +++ b/test/harness/org/jpype/test/objectwrapper/Static.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.objectwrapper; +package org.jpype.test.objectwrapper; class StaticTest { diff --git a/test/harness/jpype/objectwrapper/Test1.java b/test/harness/org/jpype/test/objectwrapper/Test1.java similarity index 96% rename from test/harness/jpype/objectwrapper/Test1.java rename to test/harness/org/jpype/test/objectwrapper/Test1.java index 67a800b43..ba96f2841 100644 --- a/test/harness/jpype/objectwrapper/Test1.java +++ b/test/harness/org/jpype/test/objectwrapper/Test1.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.objectwrapper; +package org.jpype.test.objectwrapper; public class Test1 { diff --git a/test/harness/jpype/overloads/DerivedTest.java b/test/harness/org/jpype/test/overloads/DerivedTest.java similarity index 97% rename from test/harness/jpype/overloads/DerivedTest.java rename to test/harness/org/jpype/test/overloads/DerivedTest.java index 73d992dd4..1f1b5304a 100644 --- a/test/harness/jpype/overloads/DerivedTest.java +++ b/test/harness/org/jpype/test/overloads/DerivedTest.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.overloads; +package org.jpype.test.overloads; /** Test to see that using a derived type rather than a base class will * not alter the method resolution process. diff --git a/test/harness/jpype/overloads/Test1.java b/test/harness/org/jpype/test/overloads/Test1.java similarity index 99% rename from test/harness/jpype/overloads/Test1.java rename to test/harness/org/jpype/test/overloads/Test1.java index d731dafa3..8cacaf7d4 100644 --- a/test/harness/jpype/overloads/Test1.java +++ b/test/harness/org/jpype/test/overloads/Test1.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.overloads; +package org.jpype.test.overloads; import java.util.List; diff --git a/test/harness/jpype/overloads/Test2.java b/test/harness/org/jpype/test/overloads/Test2.java similarity index 97% rename from test/harness/jpype/overloads/Test2.java rename to test/harness/org/jpype/test/overloads/Test2.java index 304e34418..95546bd2a 100644 --- a/test/harness/jpype/overloads/Test2.java +++ b/test/harness/org/jpype/test/overloads/Test2.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.overloads; +package org.jpype.test.overloads; import java.util.List; diff --git a/test/harness/jpype/override/A.java b/test/harness/org/jpype/test/override/A.java similarity index 96% rename from test/harness/jpype/override/A.java rename to test/harness/org/jpype/test/override/A.java index eebc61328..dd9e5256d 100644 --- a/test/harness/jpype/override/A.java +++ b/test/harness/org/jpype/test/override/A.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.override; +package org.jpype.test.override; public class A { diff --git a/test/harness/jpype/override/B.java b/test/harness/org/jpype/test/override/B.java similarity index 96% rename from test/harness/jpype/override/B.java rename to test/harness/org/jpype/test/override/B.java index 1bcc3fe54..cf5e40a16 100644 --- a/test/harness/jpype/override/B.java +++ b/test/harness/org/jpype/test/override/B.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.override; +package org.jpype.test.override; public class B extends A { diff --git a/test/harness/jpype/properties/TestBean.java b/test/harness/org/jpype/test/properties/TestBean.java similarity index 98% rename from test/harness/jpype/properties/TestBean.java rename to test/harness/org/jpype/test/properties/TestBean.java index 6447551f6..71da49ae8 100644 --- a/test/harness/jpype/properties/TestBean.java +++ b/test/harness/org/jpype/test/properties/TestBean.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.properties; +package org.jpype.test.properties; public class TestBean { diff --git a/test/harness/jpype/proxy/ProxyExecutor.java b/test/harness/org/jpype/test/proxy/ProxyExecutor.java similarity index 99% rename from test/harness/jpype/proxy/ProxyExecutor.java rename to test/harness/org/jpype/test/proxy/ProxyExecutor.java index cd6ea1af4..2b365e8ed 100644 --- a/test/harness/jpype/proxy/ProxyExecutor.java +++ b/test/harness/org/jpype/test/proxy/ProxyExecutor.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.proxy; +package org.jpype.test.proxy; import java.util.ArrayList; import java.util.Collection; diff --git a/test/harness/jpype/proxy/ProxyTriggers.java b/test/harness/org/jpype/test/proxy/ProxyTriggers.java similarity index 98% rename from test/harness/jpype/proxy/ProxyTriggers.java rename to test/harness/org/jpype/test/proxy/ProxyTriggers.java index 03427acd5..4f49d0cfd 100644 --- a/test/harness/jpype/proxy/ProxyTriggers.java +++ b/test/harness/org/jpype/test/proxy/ProxyTriggers.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.proxy; +package org.jpype.test.proxy; import java.util.LinkedList; import java.util.List; diff --git a/test/harness/jpype/proxy/ReturnObject.java b/test/harness/org/jpype/test/proxy/ReturnObject.java similarity index 96% rename from test/harness/jpype/proxy/ReturnObject.java rename to test/harness/org/jpype/test/proxy/ReturnObject.java index fc3d4db76..7419fe53f 100644 --- a/test/harness/jpype/proxy/ReturnObject.java +++ b/test/harness/org/jpype/test/proxy/ReturnObject.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.proxy; +package org.jpype.test.proxy; public class ReturnObject { diff --git a/test/harness/jpype/proxy/TestInterface1.java b/test/harness/org/jpype/test/proxy/TestInterface1.java similarity index 96% rename from test/harness/jpype/proxy/TestInterface1.java rename to test/harness/org/jpype/test/proxy/TestInterface1.java index 00985e31c..050380fd4 100644 --- a/test/harness/jpype/proxy/TestInterface1.java +++ b/test/harness/org/jpype/test/proxy/TestInterface1.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.proxy; +package org.jpype.test.proxy; public interface TestInterface1 { diff --git a/test/harness/jpype/proxy/TestInterface2.java b/test/harness/org/jpype/test/proxy/TestInterface2.java similarity index 96% rename from test/harness/jpype/proxy/TestInterface2.java rename to test/harness/org/jpype/test/proxy/TestInterface2.java index c476752fb..67a5fde08 100644 --- a/test/harness/jpype/proxy/TestInterface2.java +++ b/test/harness/org/jpype/test/proxy/TestInterface2.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.proxy; +package org.jpype.test.proxy; public interface TestInterface2 { diff --git a/test/harness/jpype/proxy/TestInterface3.java b/test/harness/org/jpype/test/proxy/TestInterface3.java similarity index 96% rename from test/harness/jpype/proxy/TestInterface3.java rename to test/harness/org/jpype/test/proxy/TestInterface3.java index 1a21a4ffb..b06d4c86d 100644 --- a/test/harness/jpype/proxy/TestInterface3.java +++ b/test/harness/org/jpype/test/proxy/TestInterface3.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.proxy; +package org.jpype.test.proxy; public interface TestInterface3 extends TestInterface2 { diff --git a/test/harness/jpype/proxy/TestInterface4.java b/test/harness/org/jpype/test/proxy/TestInterface4.java similarity index 96% rename from test/harness/jpype/proxy/TestInterface4.java rename to test/harness/org/jpype/test/proxy/TestInterface4.java index 58ba109e3..46e220c66 100644 --- a/test/harness/jpype/proxy/TestInterface4.java +++ b/test/harness/org/jpype/test/proxy/TestInterface4.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.proxy; +package org.jpype.test.proxy; import java.util.List; diff --git a/test/harness/jpype/proxy/TestInterface5.java b/test/harness/org/jpype/test/proxy/TestInterface5.java similarity index 96% rename from test/harness/jpype/proxy/TestInterface5.java rename to test/harness/org/jpype/test/proxy/TestInterface5.java index de9427dd0..8dc6e3fef 100644 --- a/test/harness/jpype/proxy/TestInterface5.java +++ b/test/harness/org/jpype/test/proxy/TestInterface5.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.proxy; +package org.jpype.test.proxy; public interface TestInterface5 { diff --git a/test/harness/jpype/proxy/TestThreadCallback.java b/test/harness/org/jpype/test/proxy/TestThreadCallback.java similarity index 96% rename from test/harness/jpype/proxy/TestThreadCallback.java rename to test/harness/org/jpype/test/proxy/TestThreadCallback.java index b7397cd27..f18653220 100644 --- a/test/harness/jpype/proxy/TestThreadCallback.java +++ b/test/harness/org/jpype/test/proxy/TestThreadCallback.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.proxy; +package org.jpype.test.proxy; public interface TestThreadCallback { diff --git a/test/harness/jpype/reflect/Annotation.java b/test/harness/org/jpype/test/reflect/Annotation.java similarity index 97% rename from test/harness/jpype/reflect/Annotation.java rename to test/harness/org/jpype/test/reflect/Annotation.java index 1a2412d98..e494f5be0 100644 --- a/test/harness/jpype/reflect/Annotation.java +++ b/test/harness/org/jpype/test/reflect/Annotation.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.reflect; +package org.jpype.test.reflect; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/test/harness/jpype/reflect/ReflectionTest.java b/test/harness/org/jpype/test/reflect/ReflectionTest.java similarity index 97% rename from test/harness/jpype/reflect/ReflectionTest.java rename to test/harness/org/jpype/test/reflect/ReflectionTest.java index 4cbf2ad63..252548151 100644 --- a/test/harness/jpype/reflect/ReflectionTest.java +++ b/test/harness/org/jpype/test/reflect/ReflectionTest.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.reflect; +package org.jpype.test.reflect; public class ReflectionTest { diff --git a/test/harness/jpype/serial/SerializationTest.java b/test/harness/org/jpype/test/serial/SerializationTest.java similarity index 96% rename from test/harness/jpype/serial/SerializationTest.java rename to test/harness/org/jpype/test/serial/SerializationTest.java index 45cf07b4c..0f0833063 100644 --- a/test/harness/jpype/serial/SerializationTest.java +++ b/test/harness/org/jpype/test/serial/SerializationTest.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.serial; +package org.jpype.test.serial; public class SerializationTest implements java.io.Serializable { diff --git a/test/harness/jpype/startup/TestSystemClassLoader.java b/test/harness/org/jpype/test/startup/TestSystemClassLoader.java similarity index 97% rename from test/harness/jpype/startup/TestSystemClassLoader.java rename to test/harness/org/jpype/test/startup/TestSystemClassLoader.java index 2ac41e614..2c030ec4a 100644 --- a/test/harness/jpype/startup/TestSystemClassLoader.java +++ b/test/harness/org/jpype/test/startup/TestSystemClassLoader.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.startup; +package org.jpype.test.startup; import java.net.URL; import java.net.URLClassLoader; diff --git a/test/harness/jpype/str/StringFunction.java b/test/harness/org/jpype/test/str/StringFunction.java similarity index 96% rename from test/harness/jpype/str/StringFunction.java rename to test/harness/org/jpype/test/str/StringFunction.java index ccbb8d7a8..4ef9a70e0 100644 --- a/test/harness/jpype/str/StringFunction.java +++ b/test/harness/org/jpype/test/str/StringFunction.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.str; +package org.jpype.test.str; public interface StringFunction { diff --git a/test/harness/jpype/str/Test.java b/test/harness/org/jpype/test/str/Test.java similarity index 97% rename from test/harness/jpype/str/Test.java rename to test/harness/org/jpype/test/str/Test.java index 5803b15f7..654110f5e 100644 --- a/test/harness/jpype/str/Test.java +++ b/test/harness/org/jpype/test/str/Test.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.str; +package org.jpype.test.str; public class Test { diff --git a/test/harness/jpype/types/InnerTest.java b/test/harness/org/jpype/test/types/InnerTest.java similarity index 96% rename from test/harness/jpype/types/InnerTest.java rename to test/harness/org/jpype/test/types/InnerTest.java index 50c72060c..1f7395248 100644 --- a/test/harness/jpype/types/InnerTest.java +++ b/test/harness/org/jpype/test/types/InnerTest.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.types; +package org.jpype.test.types; public class InnerTest { diff --git a/test/harness/jpype/types/Outer.java b/test/harness/org/jpype/test/types/Outer.java similarity index 96% rename from test/harness/jpype/types/Outer.java rename to test/harness/org/jpype/test/types/Outer.java index 45c0aca84..e3bd130dc 100644 --- a/test/harness/jpype/types/Outer.java +++ b/test/harness/org/jpype/test/types/Outer.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.types; +package org.jpype.test.types; public interface Outer { diff --git a/test/harness/jpype/types/VirtualTest.java b/test/harness/org/jpype/test/types/VirtualTest.java similarity index 99% rename from test/harness/jpype/types/VirtualTest.java rename to test/harness/org/jpype/test/types/VirtualTest.java index 434c614de..5ccf696dd 100755 --- a/test/harness/jpype/types/VirtualTest.java +++ b/test/harness/org/jpype/test/types/VirtualTest.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.types; +package org.jpype.test.types; public class VirtualTest { diff --git a/test/harness/jpype/utf8/Utf8Test.java b/test/harness/org/jpype/test/utf8/Utf8Test.java similarity index 99% rename from test/harness/jpype/utf8/Utf8Test.java rename to test/harness/org/jpype/test/utf8/Utf8Test.java index 416dd8431..56e8b8536 100644 --- a/test/harness/jpype/utf8/Utf8Test.java +++ b/test/harness/org/jpype/test/utf8/Utf8Test.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.utf8; +package org.jpype.test.utf8; public class Utf8Test { diff --git a/test/harness/jpype/varargs/VarArgs.java b/test/harness/org/jpype/test/varargs/VarArgs.java similarity index 98% rename from test/harness/jpype/varargs/VarArgs.java rename to test/harness/org/jpype/test/varargs/VarArgs.java index 7bc38a4fc..969b37b16 100644 --- a/test/harness/jpype/varargs/VarArgs.java +++ b/test/harness/org/jpype/test/varargs/VarArgs.java @@ -13,7 +13,7 @@ See NOTICE file for details. **************************************************************************** */ -package jpype.varargs; +package org.jpype.test.varargs; import java.util.Map; diff --git a/test/jpypetest/common.py b/test/jpypetest/common.py index 8494ff568..aa46ef424 100644 --- a/test/jpypetest/common.py +++ b/test/jpypetest/common.py @@ -15,12 +15,9 @@ # See NOTICE file for details. # # ***************************************************************************** -from functools import lru_cache - import pytest import _jpype import jpype -import logging from os import path import unittest # Extensively used as common.unittest. @@ -91,53 +88,10 @@ def __exit__(self, exception_type, exception_value, traceback): setattr(self.obj, self.attr, self.orig) -@pytest.mark.usefixtures("common_opts") +@pytest.mark.usefixtures("start_test_jvm_per_session") class JPypeTestCase(unittest.TestCase): def setUp(self): - if not jpype.isJVMStarted(): - try: - import faulthandler - faulthandler.enable() - faulthandler.disable() - except: - pass - root = path.dirname(path.abspath(path.dirname(__file__))) - jpype.addClassPath(path.join(root, 'classes')) - jvm_path = jpype.getDefaultJVMPath() - logger = logging.getLogger(__name__) - logger.info("Running testsuite using JVM %s" % jvm_path) - classpath_arg = "-Djava.class.path=%s" - args = ["-ea", "-Xmx256M", "-Xms16M"] - if self._checkjni: - args.append("-Xcheck:jni") - # TODO: enabling this check crashes the JVM with: FATAL ERROR in native method: Bad global or local ref passed to JNI - # "-Xcheck:jni", - if self._classpath: - from pathlib import Path - import warnings - # This needs to be relative to run location - jpype.addClassPath(Path(self._classpath).resolve()) - warnings.warn("using jar instead of thunks") - if self._convertStrings: - import warnings - warnings.warn("using deprecated convertStrings") - if self._jacoco: - import warnings - args.append( - "-javaagent:lib/org.jacoco.agent-0.8.5-runtime.jar=destfile=build/coverage/jacoco.exec,includes=org.jpype.*") - warnings.warn("using JaCoCo") - jpype.addClassPath(path.join(root, "../lib/*")) - jpype.addClassPath(path.join(root, "jar/*")) - classpath_arg %= jpype.getClassPath() - args.append(classpath_arg) - _jpype.enableStacktraces(True) - #JPypeTestCase.str_conversion = eval(os.getenv('JPYPE_STR_CONVERSION', 'True')) - jpype.startJVM(jvm_path, *args, - convertStrings=self._convertStrings) - self.jpype = jpype.JPackage('jpype') - - def tearDown(self): - pass + self.jpype = jpype.JPackage('org.jpype') def assertElementsEqual(self, a, b): self.assertEqual(len(a), len(b)) @@ -152,15 +106,3 @@ def assertElementsAlmostEqual(self, a, b, places=None, msg=None, def useEqualityFunc(self, func): return UseFunc(self, func, 'assertEqual') - - -@lru_cache(1) -def java_version(): - import subprocess - import sys - java_version = str(subprocess.check_output([sys.executable, "-c", - "import jpype; jpype.startJVM(); " - "print(jpype.java.lang.System.getProperty('java.version'))"]), - encoding='ascii') - # todo: make this robust for version "numbers" containing strings (e.g.) 22.1-internal - return tuple(map(int, java_version.split("."))) diff --git a/test/jpypetest/conftest.py b/test/jpypetest/conftest.py index e613f87d9..0e3a88f4d 100755 --- a/test/jpypetest/conftest.py +++ b/test/jpypetest/conftest.py @@ -15,23 +15,24 @@ # See NOTICE file for details. # # ***************************************************************************** - import pytest import common +my_options = {} + def pytest_addoption(parser): parser.addoption('--classpath', action="store", default=None, - help="Use a jar rather than the thunks") + help="Use a jar rather than the thunks.") parser.addoption('--convertStrings', action="store_true", - default=False, help="Give convert strings to startJVMs") + default=False, help="Give convert strings to startJVM.") parser.addoption('--jacoco', action="store_true", - default=False, help="Add Java coverage tool") + default=False, help="Add Java coverage tool.") parser.addoption('--checkjni', action="store_true", - default=False, help="Enable JNI checking") + default=False, help="Enable JNI checking.") parser.addoption('--fast', action="store_true", - default=False, help="Skip subrun tests") + default=False, help="Skip subrun, jedi and SQL tests.") def pytest_collection_modifyitems(config, items): @@ -39,9 +40,63 @@ def pytest_collection_modifyitems(config, items): common.fast = True -@pytest.fixture(scope="class") -def common_opts(request): - request.cls._classpath = request.config.getoption("--classpath") - request.cls._convertStrings = request.config.getoption("--convertStrings") - request.cls._jacoco = request.config.getoption("--jacoco") - request.cls._checkjni = request.config.getoption("--checkjni") +def start_test_jvm(checkjni=False, classpath=None, convertStrings=False, jacoco=False): + """Starts a JVM with testing arguments.""" + import jpype + import _jpype + from pathlib import Path + + import logging + try: + import faulthandler + faulthandler.enable() + faulthandler.disable() + except: ## tODO: too broad exception handling + pass + root = Path(__file__).parent.parent + test_java_classes = root / "classes" + assert test_java_classes.exists() + jpype.addClassPath(test_java_classes.absolute()) + jvm_path = jpype.getDefaultJVMPath() + + logger = logging.getLogger(__name__) + logger.info("Running testsuite using JVM %s" % jvm_path) + classpath_arg = "-Djava.class.path=%s" + args = ["-ea", "-Xmx256M", "-Xms16M"] + if checkjni: + args.append("-Xcheck:jni") + if classpath: + import warnings + # This needs to be relative to run location + jpype.addClassPath(Path(classpath).resolve()) + warnings.warn("using jar instead of thunks") + if convertStrings: + import warnings + warnings.warn("using deprecated convertStrings") + if jacoco: + import warnings + args.append( + "-javaagent:lib/org.jacoco.agent-0.8.5-runtime.jar=destfile=build/coverage/jacoco.exec,includes=org.jpype.*") + warnings.warn("using JaCoCo") + jpype.addClassPath(root / "../lib/*") + jpype.addClassPath(root / "jar/*") + classpath_arg %= jpype.getClassPath() + args.append(classpath_arg) + _jpype.enableStacktraces(True) + jpype.startJVM(jvm_path, *args, + convertStrings=convertStrings) + +@pytest.fixture(scope="session") +def start_test_jvm_per_session(request): + """Passes the custom pytest arguments for classpath etc. to the testing session JVM.""" + classpath = request.config.getoption("--classpath") + convertStrings = request.config.getoption("--convertStrings") + jacoco = request.config.getoption("--jacoco") + checkjni = request.config.getoption("--checkjni") + + my_options["classpath"] = classpath + my_options["convertStrings"] = convertStrings + my_options["jacoco"] = jacoco + my_options["checkjni"] = checkjni + + start_test_jvm(checkjni=checkjni, classpath=classpath, convertStrings=convertStrings, jacoco=jacoco) diff --git a/test/jpypetest/subrun.py b/test/jpypetest/subrun.py index 41a51f181..371645daf 100644 --- a/test/jpypetest/subrun.py +++ b/test/jpypetest/subrun.py @@ -26,6 +26,9 @@ from contextlib import redirect_stdout import io +import conftest +import jpype + _modules = {} # type: ignore[var-annotated] @@ -76,7 +79,7 @@ def start(self): self.outQueue = ctx.Queue() self.process = ctx.Process(target=_execute, args=(self.inQueue, self.outQueue), daemon=True) self.process.start() - self.timeout = 20 + self.timeout = 3 def execute(self, function, *args, **kwargs): self.inQueue.put([function.__name__, os.path.abspath( @@ -148,6 +151,9 @@ def setUpClass(cls): def setUp(self): if common.fast: raise unittest.SkipTest("fast") + if not jpype.isJVMStarted(): + conftest.start_test_jvm() + if individual: ProxyClass._client.restart() ProxyClass._client.execute(_hook, filename, clsname, '_setUp') diff --git a/test/jpypetest/test_array.py b/test/jpypetest/test_array.py index 7cad97eb9..6605a3fc6 100644 --- a/test/jpypetest/test_array.py +++ b/test/jpypetest/test_array.py @@ -203,7 +203,7 @@ def testJArrayConvertToPythonObject(self): jl.get(0) def testReadArray(self): - t = JClass("jpype.array.TestArray")() + t = JClass("org.jpype.test.array.TestArray")() self.assertNotIsInstance(t, JPackage) self.assertCountEqual(self.VALUES, t.i) @@ -212,13 +212,13 @@ def testReadArray(self): self.assertCountEqual(self.VALUES[1:-2], t.i[1:-2]) def testEmptyObjectArray(self): - ''' Test for strange crash reported in bug #1089302''' - Test2 = jpype.JPackage('jpype.array').Test2 + """Test for strange crash reported in bug #1089302""" + Test2 = jpype.JPackage('org.jpype.test.array').Test2 test = Test2() test.test(test.getValue()) def testWriteArray(self): - t = JClass("jpype.array.TestArray")() + t = JClass("org.jpype.test.array.TestArray")() self.assertNotIsInstance(t, JPackage) t.i[0] = 32 @@ -236,19 +236,19 @@ def testObjectArraySimple(self): self.assertEqual("Foo", a[1]) def testIterateArray(self): - t = JClass("jpype.array.TestArray")() + t = JClass("org.jpype.test.array.TestArray")() self.assertFalse(isinstance(t, JPackage)) for i in t.i: self.assertNotEqual(i, 0) def testGetSubclass(self): - t = JClass("jpype.array.TestArray")() + t = JClass("org.jpype.test.array.TestArray")() v = t.getSubClassArray() self.assertTrue(isinstance(v[0], jpype.java.lang.Integer)) def testGetArrayAsObject(self): - t = JClass("jpype.array.TestArray")() + t = JClass("org.jpype.test.array.TestArray")() v = t.getArrayAsObject() def testJArrayPythonTypes(self): diff --git a/test/jpypetest/test_attr.py b/test/jpypetest/test_attr.py index 266fdd80e..a5099b1dc 100755 --- a/test/jpypetest/test_attr.py +++ b/test/jpypetest/test_attr.py @@ -23,11 +23,9 @@ class AttributeTestCase(common.JPypeTestCase): - def setUp(self): - common.JPypeTestCase.setUp(self) def testWithBufferStrategy(self): - j = JClass("jpype.attr.ClassWithBuffer") + j = JClass("org.jpype.test.attr.ClassWithBuffer") self.assertIsNone(j().bufferStrategy) def testCallOverloadedMethodWithCovariance(self): @@ -36,60 +34,60 @@ def testCallOverloadedMethodWithCovariance(self): h.delete(0, 0) def testCallStaticString(self): - h = JClass('jpype.attr.Test1')() + h = JClass('org.jpype.test.attr.Test1')() v = h.testString(JString("abcd"), JString("efghi")) self.assertEqual(v[0], 'abcd') self.assertEqual(v[1], 'efghi') def testCallStaticUnicodeString(self): - h = JClass('jpype.attr.Test1')() + h = JClass('org.jpype.test.attr.Test1')() v = h.testString(JString(u"abcd"), JString(u"efghi")) self.assertEqual(v[0], 'abcd') self.assertEqual(v[1], 'efghi') def testCallString(self): - v = JClass('jpype.attr.Test1').testStaticString("a", "b") + v = JClass('org.jpype.test.attr.Test1').testStaticString("a", "b") self.assertEqual(v[0], 'a') self.assertEqual(v[1], 'b') def testCallUnicodeString(self): - v = JClass('jpype.attr.Test1').testStaticString(u"a", u"b") + v = JClass('org.jpype.test.attr.Test1').testStaticString(u"a", u"b") self.assertEqual(v[0], 'a') self.assertEqual(v[1], 'b') def testCallStringWithNone(self): - v = JClass('jpype.attr.Test1').testStaticString("a", None) + v = JClass('org.jpype.test.attr.Test1').testStaticString("a", None) self.assertEqual(v[0], 'a') self.assertIsNone(v[1]) def testWithHolder(self): - holder = JClass('jpype.attr.Holder')() + holder = JClass('org.jpype.test.attr.Holder')() holder.f = "ffff" self.assertEqual(holder.f, 'ffff') - result = JClass('jpype.attr.Test1').testStaticHolder(holder) + result = JClass('org.jpype.test.attr.Test1').testStaticHolder(holder) self.assertEqual(result, 'ffff') def testWithSubHolder(self): - h2 = JClass('jpype.attr.SubHolder')() + h2 = JClass('org.jpype.test.attr.SubHolder')() h2.f = "subholder" - result = JClass('jpype.attr.Test1').testStaticHolder(h2) + result = JClass('org.jpype.test.attr.Test1').testStaticHolder(h2) self.assertEqual(result, 'subholder') def testCallWithArray(self): - h2 = JClass('jpype.attr.Test1')() + h2 = JClass('org.jpype.test.attr.Test1')() StringArray = JArray(JString) v = StringArray(["Foo", "bar"]) - t = JClass('jpype.attr.Test1')() + t = JClass('org.jpype.test.attr.Test1')() result = t.testStringArray(v) self.assertSequenceEqual(["Foo", "bar"], result) def testCallWithArrayMismatch(self): - h2 = JClass('jpype.attr.Test1')() + h2 = JClass('org.jpype.test.attr.Test1')() StringArray = JArray(JString) v = StringArray(["Foo", "bar"]) - t = JClass('jpype.attr.Test1')() + t = JClass('org.jpype.test.attr.Test1')() result = t.testStringArray(v) self.assertFalse([1, 2] == result) self.assertFalse(result == [1, 2]) @@ -97,42 +95,42 @@ def testCallWithArrayMismatch(self): self.assertTrue(result != [1, 2]) def testGetStaticValue(self): - self.assertEqual(str(JClass('jpype.attr.Test1').objectValue), "234") + self.assertEqual(str(JClass('org.jpype.test.attr.Test1').objectValue), "234") def testGetStaticByInstance(self): - h = JClass('jpype.attr.Test1')() + h = JClass('org.jpype.test.attr.Test1')() self.assertEqual(str(h.objectValue), "234") def testGetNonStatic(self): - h = JClass('jpype.attr.Test1')() + h = JClass('org.jpype.test.attr.Test1')() self.assertEqual(h.stringValue, "Foo") def testSetStaticValue(self): - JClass('jpype.attr.Test1').objectValue = java.lang.Integer(43) - self.assertEqual(str(JClass('jpype.attr.Test1').objectValue), "43") - JClass('jpype.attr.Test1').reset() + JClass('org.jpype.test.attr.Test1').objectValue = java.lang.Integer(43) + self.assertEqual(str(JClass('org.jpype.test.attr.Test1').objectValue), "43") + JClass('org.jpype.test.attr.Test1').reset() def testSetNonStaticValue(self): - h = JClass('jpype.attr.Test1')() + h = JClass('org.jpype.test.attr.Test1')() h.stringValue = "bar" self.assertEqual(h.stringValue, "bar") def testReturnSubClass(self): - h = JClass('jpype.attr.Test1')() + h = JClass('org.jpype.test.attr.Test1')() v = h.getSubClass() - self.assertIsInstance(v, JClass('jpype.attr.SubHolder')) + self.assertIsInstance(v, JClass('org.jpype.test.attr.SubHolder')) def testCallWithClass(self): - h = JClass('jpype.attr.Test1')() + h = JClass('org.jpype.test.attr.Test1')() h.callWithClass(java.lang.Comparable) def testCallSuperclassMethod(self): - h = JClass('jpype.attr.Test2')() + h = JClass('org.jpype.test.attr.Test2')() h.test2Method() h.test1Method() def testCallWithLong(self): - h = JClass('jpype.attr.Test1')() + h = JClass('org.jpype.test.attr.Test1')() if sys.version > '3': l = int(123) else: @@ -148,7 +146,7 @@ def testCallWithLong(self): self.assertEqual(l, h.mLongValue) def testCallWithBigLong(self): - h = JClass('jpype.attr.Test1')() + h = JClass('org.jpype.test.attr.Test1')() if sys.version > '3': l = int(4398046511103) else: @@ -161,7 +159,7 @@ def testCallWithBigLong(self): self.assertEqual(l, h.mLongValue) def testCallWithBigInt(self): - h = JClass('jpype.attr.Test1')() + h = JClass('org.jpype.test.attr.Test1')() if sys.version > '3' or sys.maxint > 2**31: l = int(4398046511103) else: @@ -174,7 +172,7 @@ def testCallWithBigInt(self): self.assertEqual(l, h.mLongValue) def testSetBoolean(self): - h = JClass('jpype.attr.Test1')() + h = JClass('org.jpype.test.attr.Test1')() self.assertEqual(False, h.mBooleanValue) h.setBoolean(True) self.assertEqual(True, h.mBooleanValue) @@ -203,7 +201,7 @@ def testCreateDate(self): self.assertEqual(1448799485000, d.getTime()) def testCharAttribute(self): - h = JClass('jpype.attr.Test1')() + h = JClass('org.jpype.test.attr.Test1')() h.charValue = u'b' self.assertEqual(h.charValue, 'b') @@ -218,27 +216,27 @@ def testGetPrimitiveType(self): intType = Integer.TYPE def testDifferentiateClassAndObject(self): - h = JClass('jpype.attr.Test1')() + h = JClass('org.jpype.test.attr.Test1')() self.assertEqual(h.callWithSomething( - JClass('jpype.attr.Test1')), u"Class") - result = h.callWithSomething(jpype.JObject(JClass('jpype.attr.Test1'), + JClass('org.jpype.test.attr.Test1')), u"Class") + result = h.callWithSomething(jpype.JObject(JClass('org.jpype.test.attr.Test1'), jpype.java.lang.Object)) self.assertEqual(result, u"Object") def testToString(self): - h = JClass('jpype.attr.Test1')() + h = JClass('org.jpype.test.attr.Test1')() self.assertEqual(str(h), 'aaa') def testSuperToString(self): - h = JClass('jpype.attr.Test2')() + h = JClass('org.jpype.test.attr.Test2')() self.assertEqual(str(h), 'aaa') # def testStringToConversion(self): # try: # jpype.ConversionConfig.string = False # for i in range(1): -# h = JClass('jpype.attr.Test1')() +# h = JClass('org.jpype.test.attr.Test1')() # # start = time.time(); # for j in range(10): @@ -261,7 +259,7 @@ def testSuperToString(self): # jpype.ConversionConfig.string = True def testComplexMethodOvlerloading(self): - c = JClass('jpype.attr.TestOverloadC')() + c = JClass('org.jpype.test.attr.TestOverloadC')() self.assertEqual(c.foo(1), "foo(int) in C: 1") self.assertEqual(c.foo(), "foo() in A") @@ -271,7 +269,7 @@ def testPassedObjectGetsCleanedUp(self): raise common.unittest.SkipTest( 'PyPy memory model does not pass test') - h = JClass('jpype.attr.Test1')() + h = JClass('org.jpype.test.attr.Test1')() block_size = 1024 * 1024 * 10 def allocate_then_free(): @@ -285,5 +283,5 @@ def allocate_then_free(): allocate_then_free() def testSyntheticMethod(self): - h = jpype.JClass('jpype.attr.SyntheticMethods$GenericImpl')() + h = jpype.JClass('org.jpype.test.attr.SyntheticMethods$GenericImpl')() h.foo(jpype.java.util.ArrayList()) diff --git a/test/jpypetest/test_boxed.py b/test/jpypetest/test_boxed.py index a55b7aae8..b1faa1ca2 100644 --- a/test/jpypetest/test_boxed.py +++ b/test/jpypetest/test_boxed.py @@ -33,7 +33,7 @@ class BoxedTestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) - self.TestBoxed = jpype.JClass('jpype.boxed.Boxed') + self.TestBoxed = jpype.JClass('org.jpype.test.boxed.Boxed') self.Number = jpype.JClass('java.lang.Number') self.Comparable = jpype.JClass('java.lang.Comparable') @@ -182,7 +182,7 @@ def testBooleanBad(self): self.assertTrue(java.lang.Boolean(set(['a', 'b']))) # Implicit does not automatically cast - fixture = JClass('jpype.common.Fixture')() + fixture = JClass('org.jpype.test.common.Fixture')() with self.assertRaises(TypeError): fixture.callBoxedBoolean(tuple()) with self.assertRaises(TypeError): diff --git a/test/jpypetest/test_caller_sensitive.py b/test/jpypetest/test_caller_sensitive.py index ca97a6af8..6e0b0ce1c 100644 --- a/test/jpypetest/test_caller_sensitive.py +++ b/test/jpypetest/test_caller_sensitive.py @@ -33,17 +33,17 @@ class JCallerSensitiveCase(common.JPypeTestCase): called with (nothing, object, primitive, many, varargs) Unfortunately, the actual problematic method in Java is private, - so we can't get to it directly. Thus will will perform indirect tests. + so we can't get to it directly. Thus will perform indirect tests. For now we do not support caller sensitive constructors. """ def setUp(self): - common.JPypeTestCase.setUp(self) + super().setUp() if not jpype.getJVMVersion() > (1, 8, 0): raise common.unittest.SkipTest - self.Class = jpype.JClass("jpype.method.Caller") + self.Class = jpype.JClass("org.jpype.test.method.Caller") self.obj = self.Class() def testCallStatic(self): diff --git a/test/jpypetest/test_classhints.py b/test/jpypetest/test_classhints.py index d200d798a..3b47f507a 100644 --- a/test/jpypetest/test_classhints.py +++ b/test/jpypetest/test_classhints.py @@ -44,10 +44,10 @@ class ClassHintsTestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) - self.Custom = jpype.JClass("jpype.classhints.Custom") - self.ClassHintsTest = jpype.JClass("jpype.classhints.ClassHintsTest") + self.Custom = jpype.JClass("org.jpype.test.classhints.Custom") + self.ClassHintsTest = jpype.JClass("org.jpype.test.classhints.ClassHintsTest") - @jpype.JImplements("jpype.classhints.Custom") + @jpype.JImplements("org.jpype.test.classhints.Custom") class MyCustom(object): def __init__(self, arg): self.arg = arg diff --git a/test/jpypetest/test_closeable.py b/test/jpypetest/test_closeable.py index d8f58a874..298f79d01 100644 --- a/test/jpypetest/test_closeable.py +++ b/test/jpypetest/test_closeable.py @@ -21,11 +21,8 @@ class CloseableTestCase(common.JPypeTestCase): - def setUp(self): - common.JPypeTestCase.setUp(self) - def testCloseable(self): - CloseableTest = jpype.JClass("jpype.closeable.CloseableTest") + CloseableTest = jpype.JClass("org.jpype.test.closeable.CloseableTest") CloseableTest.reset() self.assertFalse(CloseableTest.closed) with CloseableTest() as myFile: @@ -34,7 +31,7 @@ def testCloseable(self): self.assertTrue(CloseableTest.closed) def testCloseableFail(self): - CloseableTest = jpype.JClass("jpype.closeable.CloseableTest") + CloseableTest = jpype.JClass("org.jpype.test.closeable.CloseableTest") CloseableTest.reset() CloseableTest.willfail = True self.assertFalse(CloseableTest.closed) @@ -53,7 +50,7 @@ def testCloseableFail(self): self.assertTrue(CloseableTest.closed) def testCloseablePyExcept(self): - CloseableTest = jpype.JClass("jpype.closeable.CloseableTest") + CloseableTest = jpype.JClass("org.jpype.test.closeable.CloseableTest") CloseableTest.reset() self.assertFalse(CloseableTest.closed) try: @@ -67,7 +64,7 @@ def testCloseablePyExcept(self): self.assertTrue(CloseableTest.closed) def testCloseablePyExceptFail(self): - CloseableTest = jpype.JClass("jpype.closeable.CloseableTest") + CloseableTest = jpype.JClass("org.jpype.test.closeable.CloseableTest") CloseableTest.reset() CloseableTest.willfail = True self.assertFalse(CloseableTest.closed) @@ -83,7 +80,7 @@ def testCloseablePyExceptFail(self): self.assertTrue(CloseableTest.failed) def testCloseableJExcept(self): - CloseableTest = jpype.JClass("jpype.closeable.CloseableTest") + CloseableTest = jpype.JClass("org.jpype.test.closeable.CloseableTest") CloseableTest.reset() self.assertFalse(CloseableTest.closed) try: @@ -99,7 +96,7 @@ def testCloseableJExcept(self): self.assertTrue(CloseableTest.closed) def testCloseableJExceptFail(self): - CloseableTest = jpype.JClass("jpype.closeable.CloseableTest") + CloseableTest = jpype.JClass("org.jpype.test.closeable.CloseableTest") CloseableTest.reset() CloseableTest.willfail = True self.assertFalse(CloseableTest.closed) diff --git a/test/jpypetest/test_closed.py b/test/jpypetest/test_closed.py index 56385750f..070bd99aa 100644 --- a/test/jpypetest/test_closed.py +++ b/test/jpypetest/test_closed.py @@ -20,8 +20,6 @@ class ClosedTestCase(common.JPypeTestCase): - def setUp(self): - common.JPypeTestCase.setUp(self) def testObjects(self): from jpype import java @@ -48,7 +46,7 @@ def testArrays(self): raise AssertionError("AttributeError not raised") def testStatic(self): - static = jpype.JClass('jpype.objectwrapper.StaticTest') + static = jpype.JClass('org.jpype.test.objectwrapper.StaticTest') self.assertEqual(static.i, 1) self.assertEqual(static.d, 1.2345) self.assertEqual(static.s, "hello") diff --git a/test/jpypetest/test_collection.py b/test/jpypetest/test_collection.py index eedd8916c..a49416158 100644 --- a/test/jpypetest/test_collection.py +++ b/test/jpypetest/test_collection.py @@ -206,7 +206,7 @@ def testMapEntry(self): self.assertEqual(len(h.iterator().next()), 2) def testEnumMap(self): - enumclass = JClass('jpype.collection.TestEnum') + enumclass = JClass('org.jpype.test.collection.TestEnum') enummap = JClass('java.util.EnumMap')(enumclass) enummap.put(enumclass.A, 'ABC') enummap.put(enumclass.B, 'DEF') diff --git a/test/jpypetest/test_conversion.py b/test/jpypetest/test_conversion.py index a169691fe..e966cc756 100644 --- a/test/jpypetest/test_conversion.py +++ b/test/jpypetest/test_conversion.py @@ -29,12 +29,12 @@ def setUp(self): self.jc2 = jpype.JClass("java.lang.Integer") def testList(self): - cls = JClass('jpype.collection.CollectionTest') + cls = JClass('org.jpype.test.collection.CollectionTest') self.assertIsInstance(cls.testList( [1, 2, 3]), JClass('java.util.List')) def testMap(self): - cls = JClass('jpype.collection.CollectionTest') + cls = JClass('org.jpype.test.collection.CollectionTest') self.assertIsInstance(cls.testMap( {'a': 1, 'b': 2}), JClass('java.util.Map')) @@ -69,7 +69,7 @@ def testConvertNone(self): self.jc1._convertToJava(1) def testUnbox(self): - jf = JClass('jpype.common.Fixture') + jf = JClass('org.jpype.test.common.Fixture') java = jpype.java jf.static_bool_field = java.lang.Boolean(True) self.assertEqual(jf.static_bool_field, True) diff --git a/test/jpypetest/test_conversionInt.py b/test/jpypetest/test_conversionInt.py index 8c9721c51..efd713a3a 100644 --- a/test/jpypetest/test_conversionInt.py +++ b/test/jpypetest/test_conversionInt.py @@ -34,7 +34,7 @@ def haveNumpy(): class ConversionIntTestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) - self.Test = jpype.JClass("jpype.common.Fixture")() + self.Test = jpype.JClass("org.jpype.test.common.Fixture")() def testIntFromInt(self): self.assertEqual(self.Test.callInt(int(123)), 123) diff --git a/test/jpypetest/test_conversionLong.py b/test/jpypetest/test_conversionLong.py index 256b4ed0c..ba4227a03 100644 --- a/test/jpypetest/test_conversionLong.py +++ b/test/jpypetest/test_conversionLong.py @@ -34,7 +34,7 @@ def haveNumpy(): class ConversionLongTestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) - self.Test = jpype.JClass("jpype.common.Fixture")() + self.Test = jpype.JClass("org.jpype.test.common.Fixture")() def testLongFromInt(self): self.assertEqual(self.Test.callLong(int(123)), 123) diff --git a/test/jpypetest/test_conversionShort.py b/test/jpypetest/test_conversionShort.py index 0c3d072c8..bee9b9d54 100644 --- a/test/jpypetest/test_conversionShort.py +++ b/test/jpypetest/test_conversionShort.py @@ -34,7 +34,7 @@ def haveNumpy(): class ConversionShortTestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) - self.Test = jpype.JClass("jpype.common.Fixture")() + self.Test = jpype.JClass("org.jpype.test.common.Fixture")() def testShortFromInt(self): self.assertEqual(self.Test.callShort(int(123)), 123) diff --git a/test/jpypetest/test_coverage.py b/test/jpypetest/test_coverage.py index 6921f80ee..5420ef32b 100644 --- a/test/jpypetest/test_coverage.py +++ b/test/jpypetest/test_coverage.py @@ -19,7 +19,6 @@ import jpype.imports import common import sys -import os import importlib import pytest from unittest import mock @@ -128,7 +127,9 @@ def testJBooleanFail(self): def testJStringAppend(self): js = jpype.JString("foo") self.assertEqual(js + "bar", "foobar") - if not self._convertStrings: + + from conftest import my_options + if not my_options["convertStrings"]: self.assertIsInstance(js + "bar", jpype.java.lang.String) def testJStringNE(self): diff --git a/test/jpypetest/test_customizer.py b/test/jpypetest/test_customizer.py index c85412eed..9aa67e2f6 100644 --- a/test/jpypetest/test_customizer.py +++ b/test/jpypetest/test_customizer.py @@ -29,18 +29,18 @@ class CustomizerTestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) - self.fixture = JClass('jpype.common.Fixture')() + self.fixture = JClass('org.jpype.test.common.Fixture')() def testSticky(self): - @jpype.JImplementationFor("jpype.override.A") + @jpype.JImplementationFor("org.jpype.test.override.A") class _A: @jpype.JOverride(sticky=True, rename="remove_") def remove(self, obj): pass - A = jpype.JClass("jpype.override.A") - B = jpype.JClass("jpype.override.B") + A = jpype.JClass("org.jpype.test.override.A") + B = jpype.JClass("org.jpype.test.override.B") self.assertEqual(A.remove, _A.remove) self.assertEqual(B.remove, _A.remove) - self.assertEqual(str(A.remove_), "jpype.override.A.remove") - self.assertEqual(str(B.remove_), "jpype.override.B.remove") + self.assertEqual(str(A.remove_), "org.jpype.test.override.A.remove") + self.assertEqual(str(B.remove_), "org.jpype.test.override.B.remove") diff --git a/test/jpypetest/test_directbuffer.py b/test/jpypetest/test_directbuffer.py index 228094bf3..3c7796fca 100644 --- a/test/jpypetest/test_directbuffer.py +++ b/test/jpypetest/test_directbuffer.py @@ -16,10 +16,8 @@ # # ***************************************************************************** import _jpype -import jpype import _jpype from jpype.types import * -from jpype import java import common try: import numpy as np @@ -28,12 +26,11 @@ class JBufferTestCase(common.JPypeTestCase): - """ Test for direct buffers. - """ + """ Test for direct buffers.""" def setUp(self): common.JPypeTestCase.setUp(self) - self.fixture = JClass('jpype.common.Fixture')() + self.fixture = JClass('org.jpype.test.common.Fixture')() self.bo = JClass("java.nio.ByteOrder") self.cls = JClass("java.nio.ByteBuffer") diff --git a/test/jpypetest/test_exc.py b/test/jpypetest/test_exc.py index 02700d690..c56bccd3e 100644 --- a/test/jpypetest/test_exc.py +++ b/test/jpypetest/test_exc.py @@ -26,12 +26,12 @@ def throwIOException(): def throwByJavaException(): - JClass('jpype.exc.ExceptionTest').throwIOException() + JClass('org.jpype.test.exc.ExceptionTest').throwIOException() class ExceptionTestCase(common.JPypeTestCase): def testExceptionThrown(self): - ext = JClass('jpype.exc.ExceptionTest') + ext = JClass('org.jpype.test.exc.ExceptionTest') try: ext.throwRuntime() self.fail() @@ -43,7 +43,7 @@ def testExceptionThrown(self): 'java.lang.RuntimeException: Foo')) def testExceptionByJavaClass(self): - ext = JClass('jpype.exc.ExceptionTest') + ext = JClass('org.jpype.test.exc.ExceptionTest') try: ext.throwRuntime() self.fail() @@ -55,15 +55,15 @@ def testExceptionByJavaClass(self): 'java.lang.RuntimeException: Foo')) def testThrowException(self): - exthrow = JClass('jpype.exc.ExceptionThrower') - extest = JClass('jpype.exc.ExceptionTest') + exthrow = JClass('org.jpype.test.exc.ExceptionThrower') + extest = JClass('org.jpype.test.exc.ExceptionTest') d = {"throwIOException": throwIOException, } p = JProxy(exthrow, dict=d) self.assertTrue(extest.delegateThrow(p)) def testThrowException3(self): - exthrow = JClass('jpype.exc.ExceptionThrower') - extest = JClass('jpype.exc.ExceptionTest') + exthrow = JClass('org.jpype.test.exc.ExceptionThrower') + extest = JClass('org.jpype.test.exc.ExceptionTest') d = {"throwIOException": throwByJavaException, } p = JProxy(exthrow, dict=d) @@ -71,27 +71,27 @@ def testThrowException3(self): # This test is problematic as __name__ is a class property not an object property # def testExceptionPYEXCName(self): -# e = self.jpype.exc.ChildTestException() -# name = "jpype.exc.ChildTestException" +# e = self.jpype.test.exc.ChildTestException() +# name = "org.jpype.test.exc.ChildTestException" # self.assertEqual(name, e.__name__) def testExceptionInstanceof(self): - e = self.jpype.exc.ChildTestException() - self.assertIsInstance(e, self.jpype.exc.ParentTestException) + e = self.jpype.test.exc.ChildTestException() + self.assertIsInstance(e, self.jpype.test.exc.ParentTestException) def testExceptionPYEXCInstanceof(self): - e = self.jpype.exc.ChildTestException - self.assertTrue(issubclass(e, self.jpype.exc.ParentTestException)) + e = self.jpype.test.exc.ChildTestException + self.assertTrue(issubclass(e, self.jpype.test.exc.ParentTestException)) def testThrowChildExceptionFromCatchJExceptionParentClass(self): try: - self.jpype.exc.ExceptionTest.throwChildTestException() + self.jpype.test.exc.ExceptionTest.throwChildTestException() self.fail() - except self.jpype.exc.ParentTestException as ex: - self.assertIsInstance(ex, self.jpype.exc.ChildTestException) + except self.jpype.test.exc.ParentTestException as ex: + self.assertIsInstance(ex, self.jpype.test.exc.ChildTestException) def testCause(self): - cls = jpype.JClass("jpype.exc.ExceptionTest") + cls = jpype.JClass("org.jpype.test.exc.ExceptionTest") try: cls.throwChain() except Exception as ex: @@ -100,9 +100,9 @@ def testCause(self): self.assertEqual(str(ex1.__cause__), "Java Exception") frame = ex1.__cause__.__traceback__ expected = [ - 'jpype.exc.ExceptionTest.throwChain', - 'jpype.exc.ExceptionTest.method1', - 'jpype.exc.ExceptionTest.method2', + 'org.jpype.test.exc.ExceptionTest.throwChain', + 'org.jpype.test.exc.ExceptionTest.method1', + 'org.jpype.test.exc.ExceptionTest.method2', ] i = 0 while (frame): @@ -120,7 +120,7 @@ def testValueError(self): js.substring(0) def testExcCtor(self): - WE = jpype.JClass("jpype.exc.WierdException") + WE = jpype.JClass("org.jpype.test.exc.WierdException") with self.assertRaises(WE): WE.testThrow() try: @@ -132,7 +132,7 @@ def testExcCtor(self): def testExcCauseChained1(self): import jpype.imports try: - from org.jpype.fail import BadInitializer # type: ignore + from org.jpype.test.fail import BadInitializer # type: ignore except Exception as ex: ex1 = ex self.assertIsInstance(ex1, ImportError) @@ -145,7 +145,7 @@ def testExcCauseChained1(self): def testExcCauseChained2(self): try: - JClass('org.jpype.fail.BadInitializer2') + JClass('org.jpype.test.fail.BadInitializer2') except Exception as ex: ex1 = ex self.assertIsInstance(ex1, JClass( diff --git a/test/jpypetest/test_fault.py b/test/jpypetest/test_fault.py index 79487972d..6227b3dc7 100644 --- a/test/jpypetest/test_fault.py +++ b/test/jpypetest/test_fault.py @@ -80,7 +80,7 @@ def f(): @common.requireInstrumentation def testJPObject_null(self): - Fixture = JClass("jpype.common.Fixture") + Fixture = JClass("org.jpype.test.common.Fixture") _jpype.fault("PyJPObject_init.null") null = Fixture() with self.assertRaisesRegex(TypeError, 'Not a Java value'): @@ -478,7 +478,7 @@ def testJPObject_setattro(self): @common.requireInstrumentation def testJPField(self): - jf = JClass("jpype.common.Fixture") + jf = JClass("org.jpype.test.common.Fixture") jfi = jf() with self.assertRaises(AttributeError): jf.final_static_int_field = 2 @@ -522,8 +522,8 @@ def testConvertString(self): @common.requireInstrumentation def testJPObject(self): - jf = JClass("jpype.common.Fixture") - jfi = JClass("jpype.common.Fixture")() + jf = JClass("org.jpype.test.common.Fixture") + jfi = JClass("org.jpype.test.common.Fixture")() _jpype.fault("JPClass::setStaticField") with self.assertRaisesRegex(SystemError, "fault"): jf.static_object_field = None @@ -622,7 +622,7 @@ def testJPJavaFrame(self): @common.requireInstrumentation def testJPJavaFrameByteField(self): - fields = JClass("jpype.common.Fixture")() + fields = JClass("org.jpype.test.common.Fixture")() _jpype.fault("JPJavaFrame::GetStaticByteField") with self.assertRaisesRegex(SystemError, "fault"): print(fields.static_byte_field) @@ -638,7 +638,7 @@ def testJPJavaFrameByteField(self): @common.requireInstrumentation def testJPJavaFrameByteMethods(self): - cls = JClass("jpype.common.Fixture") + cls = JClass("org.jpype.test.common.Fixture") obj = cls() _jpype.fault("JPJavaFrame::CallStaticByteMethodA") with self.assertRaisesRegex(SystemError, "fault"): @@ -652,7 +652,7 @@ def testJPJavaFrameByteMethods(self): @common.requireInstrumentation def testJPJavaFrameShortField(self): - fields = JClass("jpype.common.Fixture")() + fields = JClass("org.jpype.test.common.Fixture")() _jpype.fault("JPJavaFrame::GetStaticShortField") with self.assertRaisesRegex(SystemError, "fault"): print(fields.static_short_field) @@ -668,7 +668,7 @@ def testJPJavaFrameShortField(self): @common.requireInstrumentation def testJPJavaFrameShortMethod(self): - cls = JClass("jpype.common.Fixture") + cls = JClass("org.jpype.test.common.Fixture") obj = cls() _jpype.fault("JPJavaFrame::CallStaticShortMethodA") with self.assertRaisesRegex(SystemError, "fault"): @@ -682,7 +682,7 @@ def testJPJavaFrameShortMethod(self): @common.requireInstrumentation def testJPJavaFrameIntField(self): - fields = JClass("jpype.common.Fixture")() + fields = JClass("org.jpype.test.common.Fixture")() _jpype.fault("JPJavaFrame::GetStaticIntField") with self.assertRaisesRegex(SystemError, "fault"): print(fields.static_int_field) @@ -698,7 +698,7 @@ def testJPJavaFrameIntField(self): @common.requireInstrumentation def testJPJavaFrameIntMethod(self): - cls = JClass("jpype.common.Fixture") + cls = JClass("org.jpype.test.common.Fixture") obj = cls() _jpype.fault("JPJavaFrame::CallStaticIntMethodA") with self.assertRaisesRegex(SystemError, "fault"): @@ -712,7 +712,7 @@ def testJPJavaFrameIntMethod(self): @common.requireInstrumentation def testJPJavaFrameLongField(self): - fields = JClass("jpype.common.Fixture")() + fields = JClass("org.jpype.test.common.Fixture")() _jpype.fault("JPJavaFrame::GetStaticLongField") with self.assertRaisesRegex(SystemError, "fault"): print(fields.static_long_field) @@ -728,7 +728,7 @@ def testJPJavaFrameLongField(self): @common.requireInstrumentation def testJPJavaFrameLongMethod(self): - cls = JClass("jpype.common.Fixture") + cls = JClass("org.jpype.test.common.Fixture") obj = cls() _jpype.fault("JPJavaFrame::CallStaticLongMethodA") with self.assertRaisesRegex(SystemError, "fault"): @@ -742,7 +742,7 @@ def testJPJavaFrameLongMethod(self): @common.requireInstrumentation def testJPJavaFrameFloatField(self): - fields = JClass("jpype.common.Fixture")() + fields = JClass("org.jpype.test.common.Fixture")() _jpype.fault("JPJavaFrame::GetStaticFloatField") with self.assertRaisesRegex(SystemError, "fault"): print(fields.static_float_field) @@ -758,7 +758,7 @@ def testJPJavaFrameFloatField(self): @common.requireInstrumentation def testJPJavaFrameFloatMethod(self): - cls = JClass("jpype.common.Fixture") + cls = JClass("org.jpype.test.common.Fixture") obj = cls() _jpype.fault("JPJavaFrame::CallStaticFloatMethodA") with self.assertRaisesRegex(SystemError, "fault"): @@ -772,7 +772,7 @@ def testJPJavaFrameFloatMethod(self): @common.requireInstrumentation def testJPJavaFrameDoubleField(self): - fields = JClass("jpype.common.Fixture")() + fields = JClass("org.jpype.test.common.Fixture")() _jpype.fault("JPJavaFrame::GetStaticDoubleField") with self.assertRaisesRegex(SystemError, "fault"): print(fields.static_double_field) @@ -788,7 +788,7 @@ def testJPJavaFrameDoubleField(self): @common.requireInstrumentation def testJPJavaFrameDoubleMethod(self): - cls = JClass("jpype.common.Fixture") + cls = JClass("org.jpype.test.common.Fixture") obj = cls() _jpype.fault("JPJavaFrame::CallStaticDoubleMethodA") with self.assertRaisesRegex(SystemError, "fault"): @@ -802,7 +802,7 @@ def testJPJavaFrameDoubleMethod(self): @common.requireInstrumentation def testJPJavaFrameCharField(self): - fields = JClass("jpype.common.Fixture")() + fields = JClass("org.jpype.test.common.Fixture")() _jpype.fault("JPJavaFrame::GetStaticCharField") with self.assertRaisesRegex(SystemError, "fault"): print(fields.static_char_field) @@ -818,7 +818,7 @@ def testJPJavaFrameCharField(self): @common.requireInstrumentation def testJPJavaFrameCharMethod(self): - cls = JClass("jpype.common.Fixture") + cls = JClass("org.jpype.test.common.Fixture") obj = cls() _jpype.fault("JPJavaFrame::CallStaticCharMethodA") with self.assertRaisesRegex(SystemError, "fault"): @@ -832,7 +832,7 @@ def testJPJavaFrameCharMethod(self): @common.requireInstrumentation def testJPJavaFrameBooleanField(self): - fields = JClass("jpype.common.Fixture")() + fields = JClass("org.jpype.test.common.Fixture")() _jpype.fault("JPJavaFrame::GetStaticBooleanField") with self.assertRaisesRegex(SystemError, "fault"): print(fields.static_bool_field) @@ -848,7 +848,7 @@ def testJPJavaFrameBooleanField(self): @common.requireInstrumentation def testJPJavaFrameBooleanMethod(self): - cls = JClass("jpype.common.Fixture") + cls = JClass("org.jpype.test.common.Fixture") obj = cls() _jpype.fault("JPJavaFrame::CallStaticBooleanMethodA") with self.assertRaisesRegex(SystemError, "fault"): @@ -862,7 +862,7 @@ def testJPJavaFrameBooleanMethod(self): @common.requireInstrumentation def testJPJavaFrameObjectField(self): - fields = JClass("jpype.common.Fixture")() + fields = JClass("org.jpype.test.common.Fixture")() _jpype.fault("JPJavaFrame::GetStaticObjectField") with self.assertRaisesRegex(SystemError, "fault"): print(fields.static_object_field) @@ -878,7 +878,7 @@ def testJPJavaFrameObjectField(self): @common.requireInstrumentation def testJPJavaFrameObjectMethod(self): - cls = JClass("jpype.common.Fixture") + cls = JClass("org.jpype.test.common.Fixture") obj = cls() _jpype.fault("JPJavaFrame::CallStaticObjectMethodA") with self.assertRaisesRegex(SystemError, "fault"): @@ -1137,7 +1137,7 @@ def __foo__(self): def _ATestConversion(jcls, obj): return java.lang.Integer(123) - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() _jpype.fault("JPPythonConversion::convert") with self.assertRaisesRegex(SystemError, "fault"): fixture.callNumber(CTest()) @@ -1160,7 +1160,7 @@ def f(jcls, obj): @common.requireInstrumentation def testConversionFaults(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() _jpype.fault("JPConversionCharArray::matches") with self.assertRaisesRegex(SystemError, "fault"): fixture.callCharArray(object()) diff --git a/test/jpypetest/test_fields.py b/test/jpypetest/test_fields.py index 9c106ee8d..0a0aff7a5 100644 --- a/test/jpypetest/test_fields.py +++ b/test/jpypetest/test_fields.py @@ -25,7 +25,7 @@ class FieldsTestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) - self.cls = JClass("jpype.common.Fixture") + self.cls = JClass("org.jpype.test.common.Fixture") self.obj = self.cls() def testBoolean(self): diff --git a/test/jpypetest/test_forname.py b/test/jpypetest/test_forname.py index 5d83ef46f..3e4a21d5d 100644 --- a/test/jpypetest/test_forname.py +++ b/test/jpypetest/test_forname.py @@ -22,21 +22,18 @@ class ForNameTestCase(common.JPypeTestCase): - def setUp(self): - common.JPypeTestCase.setUp(self) - def testForName(self): cls = jpype.JClass('java.lang.Class') - test = cls.forName('jpype.overloads.Test1') + test = cls.forName('org.jpype.test.overloads.Test1') # Should return a java.lang.Class, rather than the python wrapper for java.lang.Class self.assertTrue(type(test) == type(cls.class_)) - self.assertEqual(test.getName(), 'jpype.overloads.Test1') + self.assertEqual(test.getName(), 'org.jpype.test.overloads.Test1') def testForName2(self): cls = jpype.JClass('java.lang.Class') clsloader = jpype.JClass( 'java.lang.ClassLoader').getSystemClassLoader() - test = cls.forName('jpype.overloads.Test1', True, clsloader) + test = cls.forName('org.jpype.test.overloads.Test1', True, clsloader) # Should return a java.lang.Class, rather than the python wrapper for java.lang.Class self.assertTrue(type(test) == type(cls.class_)) - self.assertEqual(test.getName(), 'jpype.overloads.Test1') + self.assertEqual(test.getName(), 'org.jpype.test.overloads.Test1') diff --git a/test/jpypetest/test_functional.py b/test/jpypetest/test_functional.py index 1752fb511..4919f6858 100644 --- a/test/jpypetest/test_functional.py +++ b/test/jpypetest/test_functional.py @@ -20,16 +20,15 @@ def callFunctional(cls, i): - fun = cls @(lambda x: x) + fun = cls @ (lambda x: x) return fun.call(i) class FunctionalTestCase(common.JPypeTestCase): - def _checkValidFunctional(self, name, value): - cls = jpype.JClass("jpype.functional." + name) + cls = jpype.JClass("org.jpype.test.functional." + name) self.assertEqual(callFunctional(cls, value), value) - + def testAnnotated(self): self._checkValidFunctional("Annotated", 0) @@ -42,7 +41,7 @@ def testExtendsFunctional(self): def testExtendsNonFunctional(self): with self.assertRaises(TypeError): self._checkValidFunctional("ExtendsNonFunctional", 3) - + def testAnnotatedWithObjectMethods(self): self._checkValidFunctional("AnnotatedWithObjectMethods", 4) diff --git a/test/jpypetest/test_imports.py b/test/jpypetest/test_imports.py index e0828be71..20a9f4d3f 100644 --- a/test/jpypetest/test_imports.py +++ b/test/jpypetest/test_imports.py @@ -16,9 +16,6 @@ # # ***************************************************************************** import jpype -import sys -import logging -import time import common import subrun @@ -40,47 +37,43 @@ def isJavaEnum(tp): class ImportsTestCase(common.JPypeTestCase): - def setUp(self): - # logger = logging.getLogger(__name__) - # logger.info("TEST:JImports") - common.JPypeTestCase.setUp(self) @common.unittest.skipUnless(haveJImports(), "jpype.imports not available") def testImportPackage(self): import java.lang - self.assertTrue(isJavaClass(java.lang.String)) + assert isJavaClass(java.lang.String) @common.unittest.skipUnless(haveJImports(), "jpype.imports not available") def testImportClass(self): from java.lang import String - self.assertTrue(isJavaClass(String)) + assert isJavaClass(String) @common.unittest.skipUnless(haveJImports(), "jpype.imports not available") def testImportClassAs(self): from java.lang import String as Str - self.assertTrue(isJavaClass(Str)) + assert isJavaClass(Str) @common.unittest.skipUnless(haveJImports(), "jpype.imports not available") def testImportClassMultiple(self): from java.lang import Number, Integer, Double - self.assertTrue(isJavaClass(Number)) - self.assertTrue(isJavaClass(Integer)) - self.assertTrue(isJavaClass(Double)) + assert isJavaClass(Number) + assert isJavaClass(Integer) + assert isJavaClass(Double) @common.unittest.skipUnless(haveJImports(), "jpype.imports not available") def testImportStatic(self): from java.lang.ProcessBuilder import Redirect - self.assertTrue(isJavaClass(Redirect)) + assert isJavaClass(Redirect) @common.unittest.skipUnless(haveJImports(), "jpype.imports not available") def testImportInner(self): from java.lang import Character - self.assertTrue(isJavaClass(Character.UnicodeScript)) + assert isJavaClass(Character.UnicodeScript) @common.unittest.skipUnless(haveJImports(), "jpype.imports not available") def testImportInnerEnum(self): from java.lang import Character - self.assertTrue(isJavaEnum(Character.UnicodeScript)) + assert isJavaEnum(Character.UnicodeScript) def testImportFail(self): with self.assertRaises(ImportError): @@ -88,13 +81,13 @@ def testImportFail(self): def testAlias1(self): jpype.imports.registerDomain("jpypex", alias="jpype") - from jpypex.common import Fixture # type: ignore - self.assertEqual(Fixture, jpype.JClass("jpype.common.Fixture")) + from jpypex.test.common import Fixture # type: ignore + self.assertEqual(Fixture, jpype.JClass("org.jpype.test.common.Fixture")) def testAlias2(self): - jpype.imports.registerDomain("commonx", alias="jpype.common") + jpype.imports.registerDomain("commonx", alias="org.jpype.test.common") from commonx import Fixture as Fixture2 # type: ignore - self.assertEqual(Fixture2, jpype.JClass("jpype.common.Fixture")) + self.assertEqual(Fixture2, jpype.JClass("org.jpype.test.common.Fixture")) def testAliasBad(self): jpype.imports.registerDomain("brokenx", alias="jpype.broken") @@ -105,44 +98,47 @@ def testIsPackage(self): import java.lang self.assertIsInstance(java, jpype.JPackage) self.assertIsInstance(java.lang, jpype.JPackage) - self.assertFalse(isinstance(java.lang.Class, jpype.JPackage)) - self.assertTrue(issubclass(type(java.lang), jpype.JPackage)) + assert not isinstance(java.lang.Class, jpype.JPackage) + assert issubclass(type(java.lang), jpype.JPackage) def testMRJar(self): import org.jpype.mrjar as mrjar # type: ignore u = dir(mrjar) - self.assertTrue("A" in u) - self.assertTrue("B" in u) - self.assertTrue("sub" in u) + assert "A" in u + assert "B" in u + assert "sub" in u def testAddClassPath(self): import pathlib import org.jpype as ojp - self.assertFalse("late" in dir(ojp)) + assert not "late" in dir(ojp) with self.assertRaises(ImportError): import org.jpype.late as late # type: ignore - - jpype.addClassPath(pathlib.Path("test/jar/late/late.jar").absolute()) - import org.jpype.late as late - self.assertTrue("Test" in dir(late)) - t = late.Test() - self.assertTrue(t.field == 5) - self.assertTrue(t.method() == "Yes") + jar = pathlib.Path(__file__).parent.parent / "jar/late/late.jar" + assert jar.exists() + jpype.addClassPath(jar.absolute()) + import org.jpype.test.late as late + assert "Test" in dir(late) + #t = late.Test() + assert t.field == 5 + assert t.method() == "Yes" def testStar(self): - import importstar + pass + # fixme: this has the side-effect of loading late and late2 jars, should it go to a subrun test? + #import importstar def testMissing(self): import org - self.assertTrue("missing" in dir(org.jpype)) + assert "missing" in dir(org.jpype) @subrun.TestCase class ImportsBeforeCase(common.unittest.TestCase): - def setUp(self): - self.jvmpath = jpype.getDefaultJVMPath() + """JVM not yet started, e.g. we do not derive from JPypeTestCase.""" def testPre(self): + assert not jpype.isJVMStarted() with self.assertRaises(ImportError): import java with self.assertRaises(ImportError): diff --git a/test/jpypetest/test_javacoverage.py b/test/jpypetest/test_javacoverage.py index fbffb9c90..a21948498 100644 --- a/test/jpypetest/test_javacoverage.py +++ b/test/jpypetest/test_javacoverage.py @@ -26,7 +26,7 @@ class JavaCoverageTestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) - self.fixture = JClass('jpype.common.Fixture')() + self.fixture = JClass('org.jpype.test.common.Fixture')() JPypeContext = JClass('org.jpype.JPypeContext') self.inst = JPypeContext.getInstance() diff --git a/test/jpypetest/test_javadoc.py b/test/jpypetest/test_javadoc.py index a17f11d03..599390f5b 100644 --- a/test/jpypetest/test_javadoc.py +++ b/test/jpypetest/test_javadoc.py @@ -23,9 +23,6 @@ class HtmlTestCase(common.JPypeTestCase): - def setUp(self): - common.JPypeTestCase.setUp(self) - def testEntities(self): html = JClass("org.jpype.html.Html") for k, v in html.ENTITIES.items(): @@ -35,7 +32,7 @@ def testEntities(self): self.assertEqual(ord(u[0][0]), v) def testClass(self): - JC = jpype.JClass("jpype.doc.Test") + JC = jpype.JClass("org.jpype.test.doc.Test") jd = JC.__doc__ self.assertIsInstance(jd, str) # Disabled this test for now. Java needs a better API for accessing Java doc. @@ -43,7 +40,7 @@ def testClass(self): #self.assertRegex(jd, "random stuff") def testMethod(self): - JC = jpype.JClass("jpype.doc.Test") + JC = jpype.JClass("org.jpype.test.doc.Test") jd = JC.methodOne.__doc__ self.assertIsInstance(jd, str) # Disabling this test for now. Something fails in Linux but I can't replicate it. diff --git a/test/jpypetest/test_jboolean.py b/test/jpypetest/test_jboolean.py index b27c63fd0..9196ad043 100644 --- a/test/jpypetest/test_jboolean.py +++ b/test/jpypetest/test_jboolean.py @@ -31,7 +31,7 @@ class JBooleanTestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) - self.Test = jpype.JClass("jpype.common.Fixture")() + self.Test = jpype.JClass("org.jpype.test.common.Fixture")() @common.requireInstrumentation def testJPBoolean_str(self): @@ -50,7 +50,7 @@ def testJPBooleanType(self): ja[1:3] = [0, 0] with self.assertRaises(TypeError): ja[1] = object() - jf = JClass("jpype.common.Fixture") + jf = JClass("org.jpype.test.common.Fixture") with self.assertRaises(TypeError): jf.static_bool_field = object() with self.assertRaises(TypeError): diff --git a/test/jpypetest/test_jbyte.py b/test/jpypetest/test_jbyte.py index a4b995c9b..68f4d9e09 100644 --- a/test/jpypetest/test_jbyte.py +++ b/test/jpypetest/test_jbyte.py @@ -32,7 +32,7 @@ class JByteTestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) - self.fixture = jpype.JClass("jpype.common.Fixture")() + self.fixture = jpype.JClass("org.jpype.test.common.Fixture")() @common.requireInstrumentation def testConversionFault(self): @@ -141,7 +141,7 @@ def testByteFromNone(self): self.fixture.callByte(None) def testByteArrayAsString(self): - t = JClass("jpype.array.TestArray")() + t = JClass("org.jpype.test.array.TestArray")() v = t.getByteArray() self.assertEqual(str(v), 'avcd') @@ -171,7 +171,7 @@ def testFromObject(self): ja = JArray(JByte)(5) with self.assertRaises(TypeError): ja[1] = object() - jf = JClass("jpype.common.Fixture") + jf = JClass("org.jpype.test.common.Fixture") with self.assertRaises(TypeError): jf.static_byte_field = object() with self.assertRaises(TypeError): diff --git a/test/jpypetest/test_jchar.py b/test/jpypetest/test_jchar.py index 32dc9bdfa..8a1bbddb5 100644 --- a/test/jpypetest/test_jchar.py +++ b/test/jpypetest/test_jchar.py @@ -99,19 +99,19 @@ def testFromObject(self): ja = JArray(JChar)(5) with self.assertRaises(TypeError): ja[1] = object() - jf = JClass("jpype.common.Fixture") + jf = JClass("org.jpype.test.common.Fixture") with self.assertRaises(TypeError): jf.static_char_field = object() with self.assertRaises(TypeError): jf().char_field = object() def testCharArrayAsString(self): - t = JClass("jpype.array.TestArray")() + t = JClass("org.jpype.test.array.TestArray")() v = t.getCharArray() self.assertEqual(str(v), 'avcd') def testArrayConversionChar(self): - t = JClass("jpype.array.TestArray")() + t = JClass("org.jpype.test.array.TestArray")() v = t.getCharArray() self.assertEqual(str(v[:]), 'avcd') @@ -201,7 +201,7 @@ def testXor(self): self.assertIsInstance(self.nc ^ 1, int) def testPass(self): - fixture = jpype.JClass('jpype.common.Fixture')() + fixture = jpype.JClass('org.jpype.test.common.Fixture')() self.assertEqual(type(fixture.callChar(self.nc)), JChar) self.assertEqual(type(fixture.callObject(self.nc)), jpype.java.lang.Character) @@ -326,7 +326,7 @@ def testBool(self): self.assertFalse(bool(JChar(0))) def testPass(self): - fixture = jpype.JClass('jpype.common.Fixture')() + fixture = jpype.JClass('org.jpype.test.common.Fixture')() self.assertEqual(type(fixture.callObject(self.nc)), type(self.nc)) def check(self, u, v0, v1, v2): @@ -470,7 +470,7 @@ def testEq(self): self.assertFalse(self.nc != self.nc) def testPass(self): - fixture = jpype.JClass('jpype.common.Fixture')() + fixture = jpype.JClass('org.jpype.test.common.Fixture')() self.assertEqual(fixture.callObject(self.nc), None) diff --git a/test/jpypetest/test_jclass.py b/test/jpypetest/test_jclass.py index 9907062cd..5a860de8d 100644 --- a/test/jpypetest/test_jclass.py +++ b/test/jpypetest/test_jclass.py @@ -31,9 +31,6 @@ class JClassTestCase(common.JPypeTestCase): - ``mro`` """ - def setUp(self): - common.JPypeTestCase.setUp(self) - def testGetAttrPyMethod(self): cls = JClass('java.util.Iterator') obj = JClass('java.util.ArrayList')() @@ -86,76 +83,76 @@ def testSetAttrProperty(self): cls.args = 1 def testGetAttrStaticField_2(self): - cls = JClass('jpype.common.Fixture') + cls = JClass('org.jpype.test.common.Fixture') cls.static_object_field = "fred" self.assertEqual(cls.static_object_field, "fred") def testSetAttrStaticField_3(self): - cls = JClass('jpype.common.Fixture') + cls = JClass('org.jpype.test.common.Fixture') cls.static_object_field = "fred" def testGetAttrField(self): - cls = JClass('jpype.common.Fixture') + cls = JClass('org.jpype.test.common.Fixture') with self.assertRaises(AttributeError): v = cls.object_field def testSetAttrField(self): - cls = JClass('jpype.common.Fixture') + cls = JClass('org.jpype.test.common.Fixture') with self.assertRaises(AttributeError): cls.object_field = "fred" def testGetAttrPrivateField(self): - cls = JClass('jpype.common.Fixture') + cls = JClass('org.jpype.test.common.Fixture') with self.assertRaises(AttributeError): v = cls.privateObjectField def testSetAttrPrivateField(self): - cls = JClass('jpype.common.Fixture') + cls = JClass('org.jpype.test.common.Fixture') with self.assertRaises(AttributeError): cls.private_object_field = "fred" def testGetAttrFinalField(self): - cls = JClass('jpype.common.Fixture') + cls = JClass('org.jpype.test.common.Fixture') with self.assertRaises(AttributeError): v = cls.final_object_field def testSetAttrFinalField(self): - cls = JClass('jpype.common.Fixture') + cls = JClass('org.jpype.test.common.Fixture') with self.assertRaises(AttributeError): cls.final_object_field = "fred" def testGetAttrStaticFinalField(self): - cls = JClass('jpype.common.Fixture') + cls = JClass('org.jpype.test.common.Fixture') self.assertEqual(cls.final_static_object_field, "final static object field") def testSetAttrStaticFinalField(self): - cls = JClass('jpype.common.Fixture') + cls = JClass('org.jpype.test.common.Fixture') with self.assertRaises(AttributeError): cls.final_static_object_field = "bar" def testStaticMethod(self): - cls = JClass('jpype.common.Fixture') + cls = JClass('org.jpype.test.common.Fixture') cls.callStaticObject(JObject()) def testPrivateStaticMethod(self): - cls = JClass('jpype.common.Fixture') + cls = JClass('org.jpype.test.common.Fixture') with self.assertRaises(AttributeError): cls.callPrivateStaticObject(JObject()) def testMethod(self): - cls = JClass('jpype.common.Fixture') + cls = JClass('org.jpype.test.common.Fixture') with self.assertRaises(TypeError): cls.callObject(JObject()) cls.callObject(cls(), JObject()) def testPrivateMethod(self): - cls = JClass('jpype.common.Fixture') + cls = JClass('org.jpype.test.common.Fixture') with self.assertRaises(AttributeError): cls.callPrivateObject(JObject()) def testProtectedMethod(self): - cls = JClass('jpype.common.Fixture') + cls = JClass('org.jpype.test.common.Fixture') with self.assertRaises(AttributeError): cls.callProtectedObject(JObject()) @@ -201,7 +198,7 @@ def testInnerClass(self): # This tests for problems when the inner class implements the # outer interface which creates a race condition. Success is # not throwing an exception - test = JClass("jpype.types.InnerTest")() + test = JClass("org.jpype.test.types.InnerTest")() test.test() def testLookupGeneric(self): diff --git a/test/jpypetest/test_jdouble.py b/test/jpypetest/test_jdouble.py index bd7471e77..bb23cabca 100644 --- a/test/jpypetest/test_jdouble.py +++ b/test/jpypetest/test_jdouble.py @@ -33,7 +33,7 @@ class JDoubleTestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) self.value = 1.0 + 1.0 / 65536 - self.cls = JClass("jpype.common.Fixture") + self.cls = JClass("org.jpype.test.common.Fixture") self.fixture = self.cls() def compareDoubleEqual(self, x, y, msg=None): @@ -202,7 +202,7 @@ def testFromObject(self): ja = JArray(JDouble)(5) with self.assertRaises(TypeError): ja[1] = object() - jf = JClass("jpype.common.Fixture") + jf = JClass("org.jpype.test.common.Fixture") with self.assertRaises(TypeError): jf.static_double_field = object() with self.assertRaises(TypeError): diff --git a/test/jpypetest/test_jfloat.py b/test/jpypetest/test_jfloat.py index 4080598bc..ac311867e 100644 --- a/test/jpypetest/test_jfloat.py +++ b/test/jpypetest/test_jfloat.py @@ -34,7 +34,7 @@ class JFloatTestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) self.value = 1.0 + 1.0 / 65536 - self.cls = JClass("jpype.common.Fixture") + self.cls = JClass("org.jpype.test.common.Fixture") self.fixture = self.cls() def compareFloatEqual(self, x, y, msg=None): @@ -211,7 +211,7 @@ def testFromObject(self): ja = JArray(JFloat)(5) with self.assertRaises(TypeError): ja[1] = object() - jf = JClass("jpype.common.Fixture") + jf = JClass("org.jpype.test.common.Fixture") with self.assertRaises(TypeError): jf.static_float_field = object() with self.assertRaises(TypeError): diff --git a/test/jpypetest/test_jint.py b/test/jpypetest/test_jint.py index b9511b84a..f33266cb3 100644 --- a/test/jpypetest/test_jint.py +++ b/test/jpypetest/test_jint.py @@ -34,7 +34,7 @@ class JIntTestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) - self.cls = JClass("jpype.common.Fixture") + self.cls = JClass("org.jpype.test.common.Fixture") self.fixture = self.cls() @common.requireInstrumentation @@ -189,7 +189,7 @@ def testFromObject(self): ja = JArray(JInt)(5) with self.assertRaises(TypeError): ja[1] = object() - jf = JClass("jpype.common.Fixture") + jf = JClass("org.jpype.test.common.Fixture") with self.assertRaises(TypeError): jf.static_int_field = object() with self.assertRaises(TypeError): diff --git a/test/jpypetest/test_jlong.py b/test/jpypetest/test_jlong.py index 5f4178f08..4e30717bc 100644 --- a/test/jpypetest/test_jlong.py +++ b/test/jpypetest/test_jlong.py @@ -34,7 +34,7 @@ class JLongTestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) - self.cls = JClass("jpype.common.Fixture") + self.cls = JClass("org.jpype.test.common.Fixture") self.fixture = self.cls() @common.requireInstrumentation @@ -189,7 +189,7 @@ def testFromObject(self): ja = JArray(JLong)(5) with self.assertRaises(TypeError): ja[1] = object() - jf = JClass("jpype.common.Fixture") + jf = JClass("org.jpype.test.common.Fixture") with self.assertRaises(TypeError): jf.static_long_field = object() with self.assertRaises(TypeError): diff --git a/test/jpypetest/test_jmethod.py b/test/jpypetest/test_jmethod.py index 8216a67ab..56e531e3a 100644 --- a/test/jpypetest/test_jmethod.py +++ b/test/jpypetest/test_jmethod.py @@ -163,21 +163,21 @@ def testMethodHelp(self): @common.requireInstrumentation def testJMethod_get(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() _jpype.fault("PyJPMethod_get") with self.assertRaisesRegex(SystemError, "fault"): fixture.callInt(1) @common.requireInstrumentation def testJMethod_str(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() _jpype.fault("PyJPMethod_get") with self.assertRaisesRegex(SystemError, "fault"): str(fixture.callInt) @common.requireInstrumentation def testJMethod_str_2(self): - Fixture = JClass("jpype.common.Fixture") + Fixture = JClass("org.jpype.test.common.Fixture") fixture = Fixture() _jpype.fault("PyJPMethod_get") with self.assertRaisesRegex(SystemError, "fault"): @@ -187,35 +187,35 @@ def testJMethod_str_2(self): @common.requireInstrumentation def testJMethod_selfFault(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() _jpype.fault("PyJPMethod_getSelf") with self.assertRaisesRegex(SystemError, "fault"): fixture.callInt.__self__ @common.requireInstrumentation def testJMethod_nameFault(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() _jpype.fault("PyJPMethod_getName") with self.assertRaisesRegex(SystemError, "fault"): fixture.callInt.__name__ @common.requireInstrumentation def testJMethod_qualnameFault(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() _jpype.fault("PyJPMethod_getQualName") with self.assertRaisesRegex(SystemError, "fault"): fixture.callInt.__qualname__ @common.requireInstrumentation def testJMethod_annotationsFault(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() _jpype.fault("PyJPMethod_getAnnotations") with self.assertRaisesRegex(SystemError, "fault"): fixture.callInt.__annotations__ @common.requireInstrumentation def testJMethod_docFault(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() _jpype.fault("PyJPMethod_getDoc") with self.assertRaisesRegex(SystemError, "fault"): fixture.callInt.__doc__ @@ -225,14 +225,14 @@ def testJMethod_docFault(self): @common.requireInstrumentation def testJMethod_docFault_2(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() _jpype.fault("PyJPMethod_getCodeAttr") with self.assertRaisesRegex(SystemError, "fault"): fixture.callFloat.__code__ @common.requireInstrumentation def testJMethod_beansFault(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() _jpype.fault("PyJPMethod_isBeanAccessor") with self.assertRaisesRegex(SystemError, "fault"): fixture.callInt._isBeanAccessor() @@ -242,68 +242,68 @@ def testJMethod_beansFault(self): @common.requireInstrumentation def testJMethod_diagnosticsFault(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() _jpype.fault("PyJPMethod_matchReport") with self.assertRaisesRegex(SystemError, "fault"): fixture.callInt.matchReport() @common.requireInstrumentation def testJMethod_callFault(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() _jpype.fault("PyJPMethod_call") with self.assertRaisesRegex(SystemError, "fault"): fixture.callInt(1) def testJMethod_self(self): - Fixture = JClass("jpype.common.Fixture") - fixture = JClass("jpype.common.Fixture")() + Fixture = JClass("org.jpype.test.common.Fixture") + fixture = JClass("org.jpype.test.common.Fixture")() self.assertEqual(fixture.callInt.__self__, fixture) self.assertEqual(Fixture.callStaticInt.__self__, None) def testJMethod_name(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() self.assertIsInstance(fixture.callInt.__name__, str) self.assertEqual(fixture.callInt.__name__, 'callInt') def testJMethod_doc(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() self.assertIsInstance(fixture.callInt.__doc__, str) def testJMethod_annotations(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() self.assertIsInstance(fixture.callInt.__annotations__, dict) ann = fixture.callInt.__annotations__ expected = {'arg0': JInt, 'return': JInt} self.assertEqual(ann, expected) def testJMethod_closure(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() self.assertNotEqual(fixture.callInt.__closure__, None) def testJMethod_code(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() def f(): pass self.assertIsInstance(fixture.callInt.__code__, type(f.__code__)) def testJMethod_defaults(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() self.assertEqual(fixture.callInt.__defaults__, None) def testJMethod_kwdefaults(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() self.assertEqual(fixture.callInt.__kwdefaults__, None) def testJMethod_globals(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() self.assertIsInstance(fixture.callInt.__globals__, dict) def testJMethod_qualname(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() self.assertIsInstance(fixture.callInt.__qualname__, str) self.assertEqual(fixture.callInt.__qualname__, - 'jpype.common.Fixture.callInt') + 'org.jpype.test.common.Fixture.callInt') def testMatches(self): js = JClass("java.lang.String")() diff --git a/test/jpypetest/test_jobject.py b/test/jpypetest/test_jobject.py index bf5e78e37..9926e8cb3 100644 --- a/test/jpypetest/test_jobject.py +++ b/test/jpypetest/test_jobject.py @@ -38,7 +38,7 @@ class JClassTestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) - self.fixture = JClass('jpype.common.Fixture')() + self.fixture = JClass('org.jpype.test.common.Fixture')() def testSetAttrPythonField(self): cls = JClass('java.lang.String') @@ -223,7 +223,7 @@ def testSetAttrFail(self): setattr(jo, object(), 1) def testSetAttrFail2(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() with self.assertRaisesRegex(AttributeError, "is not settable"): setattr(fixture, "callObject", 4) diff --git a/test/jpypetest/test_jshort.py b/test/jpypetest/test_jshort.py index cb6b679a5..938d411f5 100644 --- a/test/jpypetest/test_jshort.py +++ b/test/jpypetest/test_jshort.py @@ -34,7 +34,7 @@ class JShortTestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) - self.cls = JClass("jpype.common.Fixture") + self.cls = JClass("org.jpype.test.common.Fixture") self.fixture = self.cls() @common.requireInstrumentation @@ -179,7 +179,7 @@ def testFromObject(self): ja = JArray(JShort)(5) with self.assertRaises(TypeError): ja[1] = object() - jf = JClass("jpype.common.Fixture") + jf = JClass("org.jpype.test.common.Fixture") with self.assertRaises(TypeError): jf.static_short_field = object() with self.assertRaises(TypeError): diff --git a/test/jpypetest/test_keywords.py b/test/jpypetest/test_keywords.py index debe4f8ac..0ca3b07a0 100644 --- a/test/jpypetest/test_keywords.py +++ b/test/jpypetest/test_keywords.py @@ -59,6 +59,6 @@ def testPySafe__NotKeywords(identifier): class AttributeTestCase(common.JPypeTestCase): def testPySafe(self): - cls = jpype.JPackage("jpype").attr.TestKeywords + cls = jpype.JPackage("org.jpype").test.attr.TestKeywords self.assertTrue(hasattr(cls, "__leading_double_underscore")) self.assertFalse(hasattr(cls, "__dunder_name__")) diff --git a/test/jpypetest/test_leak2.py b/test/jpypetest/test_leak2.py index 528e0c198..2e8ce27c3 100644 --- a/test/jpypetest/test_leak2.py +++ b/test/jpypetest/test_leak2.py @@ -54,7 +54,7 @@ class Leak2TestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) - self.fixture = JClass('jpype.common.Fixture')() + self.fixture = JClass('org.jpype.test.common.Fixture')() Tracer.reset() def testArrayCall(self): diff --git a/test/jpypetest/test_legacy.py b/test/jpypetest/test_legacy.py index e0708d0b3..64a714176 100644 --- a/test/jpypetest/test_legacy.py +++ b/test/jpypetest/test_legacy.py @@ -15,6 +15,8 @@ # See NOTICE file for details. # # ***************************************************************************** +import pathlib + import jpype import common import subrun @@ -34,12 +36,12 @@ class LegacyTestCase(unittest.TestCase): @classmethod def setUpClass(cls): # Run with automatic string conversion - jpype.startJVM(classpath=os.path.abspath( - "test/classes"), convertStrings=True) + jpype.startJVM(classpath=pathlib.Path(__file__).parent.parent / "classes", + convertStrings=True) def setUp(self): - self._test = jpype.JClass("jpype.str.Test") - self._intf = jpype.JClass("jpype.str.StringFunction") + self._test = jpype.JClass("org.jpype.test.str.Test") + self._intf = jpype.JClass("org.jpype.test.str.StringFunction") def testStaticField(self): s = self._test.staticField diff --git a/test/jpypetest/test_mro.py b/test/jpypetest/test_mro.py index 070a2a9ca..d9405c924 100644 --- a/test/jpypetest/test_mro.py +++ b/test/jpypetest/test_mro.py @@ -23,8 +23,8 @@ class MroTestCase(common.JPypeTestCase): def testMro(self): - C = JClass('jpype.mro.C') + C = JClass('org.jpype.test.mro.C') def testMultipleInterfaces(self): - j = JClass("jpype.mro.MultipleInterfaces") + j = JClass("org.jpype.test.mro.MultipleInterfaces") myinstance = j() diff --git a/test/jpypetest/test_number.py b/test/jpypetest/test_number.py index df6f1edbb..46ecd98d0 100644 --- a/test/jpypetest/test_number.py +++ b/test/jpypetest/test_number.py @@ -32,7 +32,7 @@ class JNumberTestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) - self.cls = JClass("jpype.common.Fixture") + self.cls = JClass("org.jpype.test.common.Fixture") self.fixture = self.cls() def testJavaPrimitives(self): diff --git a/test/jpypetest/test_numeric.py b/test/jpypetest/test_numeric.py index 2afbd71ba..e409436b2 100644 --- a/test/jpypetest/test_numeric.py +++ b/test/jpypetest/test_numeric.py @@ -28,7 +28,7 @@ def testMathAbs(self): def testDoubleConversion(self): f = java.lang.Float.MAX_VALUE * 2 - self.assertTrue(JClass("jpype.numeric.NumericTest").doubleIsTwiceMaxFloat(f)) + self.assertTrue(JClass("org.jpype.test.numeric.NumericTest").doubleIsTwiceMaxFloat(f)) def testDoubleIsProperlyConverted(self): self.assertTrue(java.lang.Double.POSITIVE_INFINITY != 0.0) diff --git a/test/jpypetest/test_objectwrapper.py b/test/jpypetest/test_objectwrapper.py index f6a64cf85..a373faddd 100644 --- a/test/jpypetest/test_objectwrapper.py +++ b/test/jpypetest/test_objectwrapper.py @@ -19,14 +19,12 @@ from jpype.types import * from jpype import java import common -#import os -#import sys class ObjectWrapperTestCase(common.JPypeTestCase): def testCallOverloads(self): # build the harness - h = JClass("jpype.objectwrapper.Test1")() + h = JClass("org.jpype.test.objectwrapper.Test1")() o = java.lang.Integer(1) self.assertEqual(h.Method1(JObject(o, java.lang.Number)), 1) @@ -46,7 +44,7 @@ def testDefaultTypeNameBoolean(self): jpype.JClass("java.lang.Boolean")) def testPassingClassTypeSucceeds(self): - h = JClass("jpype.objectwrapper.Test1")() + h = JClass("org.jpype.test.objectwrapper.Test1")() # Select a convenient java.lang.Class object class_obj = h.getClass() diff --git a/test/jpypetest/test_overloads.py b/test/jpypetest/test_overloads.py index bde5948ec..8152015cd 100644 --- a/test/jpypetest/test_overloads.py +++ b/test/jpypetest/test_overloads.py @@ -71,21 +71,21 @@ def fun4(a): class OverloadTestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) - self.__jp = self.jpype.overloads - self._aclass = JClass('jpype.overloads.Test1$A') - self._bclass = JClass('jpype.overloads.Test1$B') - self._cclass = JClass('jpype.overloads.Test1$C') + self.__jp = self.jpype.test.overloads + self._aclass = JClass('org.jpype.test.overloads.Test1$A') + self._bclass = JClass('org.jpype.test.overloads.Test1$B') + self._cclass = JClass('org.jpype.test.overloads.Test1$C') self._a = self._aclass() self._b = self._bclass() self._c = self._cclass() - self._i1impl = JClass('jpype.overloads.Test1$I1Impl')() - self._i2impl = JClass('jpype.overloads.Test1$I2Impl')() - self._i3impl = JClass('jpype.overloads.Test1$I3Impl')() - self._i4impl = JClass('jpype.overloads.Test1$I4Impl')() - self._i5impl = JClass('jpype.overloads.Test1$I5Impl')() - self._i6impl = JClass('jpype.overloads.Test1$I6Impl')() - self._i7impl = JClass('jpype.overloads.Test1$I7Impl')() - self._i8impl = JClass('jpype.overloads.Test1$I8Impl')() + self._i1impl = JClass('org.jpype.test.overloads.Test1$I1Impl')() + self._i2impl = JClass('org.jpype.test.overloads.Test1$I2Impl')() + self._i3impl = JClass('org.jpype.test.overloads.Test1$I3Impl')() + self._i4impl = JClass('org.jpype.test.overloads.Test1$I4Impl')() + self._i5impl = JClass('org.jpype.test.overloads.Test1$I5Impl')() + self._i6impl = JClass('org.jpype.test.overloads.Test1$I6Impl')() + self._i7impl = JClass('org.jpype.test.overloads.Test1$I7Impl')() + self._i8impl = JClass('org.jpype.test.overloads.Test1$I8Impl')() def testMostSpecificInstanceMethod(self): test1 = self.__jp.Test1() @@ -103,11 +103,11 @@ def testForceOverloadResolution(self): # JObject wrapper forces exact matches #self.assertRaisesRegex(TypeError, 'No matching overloads found', test1.testMostSpecific, JObject(self._c, self._cclass)) self.assertEqual('A', test1.testMostSpecific( - JObject(self._c, 'jpype.overloads.Test1$A'))) + JObject(self._c, 'org.jpype.test.overloads.Test1$A'))) self.assertEqual('B', test1.testMostSpecific( - JObject(self._c, 'jpype.overloads.Test1$B'))) + JObject(self._c, 'org.jpype.test.overloads.Test1$B'))) # JObject wrapper forces exact matches - #self.assertRaisesRegex(TypeError, 'No matching overloads found', test1.testMostSpecific, JObject(self._c, 'jpype.overloads.Test1$C')) + #self.assertRaisesRegex(TypeError, 'No matching overloads found', test1.testMostSpecific, JObject(self._c, 'org.jpype.test.overloads.Test1$C')) def testVarArgsCall(self): test1 = self.__jp.Test1() @@ -165,17 +165,17 @@ def testInterfaces1(self): self.assertRaisesRegex( TypeError, 'Ambiguous overloads found', test1.testInterfaces1, self._i4impl) self.assertEqual('I2', test1.testInterfaces1( - JObject(self._i4impl, 'jpype.overloads.Test1$I2'))) + JObject(self._i4impl, 'org.jpype.test.overloads.Test1$I2'))) self.assertEqual('I3', test1.testInterfaces1( - JObject(self._i4impl, 'jpype.overloads.Test1$I3'))) + JObject(self._i4impl, 'org.jpype.test.overloads.Test1$I3'))) def testInterfaces2(self): test1 = self.__jp.Test1() self.assertEqual('I4', test1.testInterfaces2(self._i4impl)) self.assertEqual('I2', test1.testInterfaces2( - JObject(self._i4impl, 'jpype.overloads.Test1$I2'))) + JObject(self._i4impl, 'org.jpype.test.overloads.Test1$I2'))) self.assertEqual('I3', test1.testInterfaces2( - JObject(self._i4impl, 'jpype.overloads.Test1$I3'))) + JObject(self._i4impl, 'org.jpype.test.overloads.Test1$I3'))) def testInterfaces3(self): test1 = self.__jp.Test1() @@ -203,9 +203,9 @@ def testClassVsObject(self): self.assertEqual('Object', test1.testClassVsObject(1)) self.assertEqual('Class', test1.testClassVsObject(None)) self.assertEqual('Class', test1.testClassVsObject( - JClass('jpype.overloads.Test1$I4Impl'))) + JClass('org.jpype.test.overloads.Test1$I4Impl'))) self.assertEqual('Class', test1.testClassVsObject( - JClass('jpype.overloads.Test1$I3'))) + JClass('org.jpype.test.overloads.Test1$I3'))) def testStringArray(self): test1 = self.__jp.Test1() @@ -229,7 +229,7 @@ def testListVSArray(self): def testDefaultMethods(self): try: - testdefault = JClass('jpype.overloads.Test1$DefaultC')() + testdefault = JClass('org.jpype.test.overloads.Test1$DefaultC')() except: pass else: @@ -287,7 +287,7 @@ def testRunnable(self): def testDerivedStatic(self): Boolean = jpype.JClass("java.lang.Boolean") Object = jpype.JClass("java.lang.Object") - DerivedTest = JClass("jpype.overloads.DerivedTest") + DerivedTest = JClass("org.jpype.test.overloads.DerivedTest") Base = DerivedTest.Base() Derived = DerivedTest.Derived() self.assertEqual(DerivedTest.testStatic(True, Base), 1) @@ -302,7 +302,7 @@ def testDerivedStatic(self): def testDerivedMember(self): Boolean = jpype.JClass("java.lang.Boolean") Object = jpype.JClass("java.lang.Object") - DerivedTest = JClass("jpype.overloads.DerivedTest") + DerivedTest = JClass("org.jpype.test.overloads.DerivedTest") Base = DerivedTest.Base() Derived = DerivedTest.Derived() obj = DerivedTest() @@ -318,7 +318,7 @@ def testDerivedMember(self): def testDerivedSub(self): Boolean = jpype.JClass("java.lang.Boolean") Object = jpype.JClass("java.lang.Object") - DerivedTest = JClass("jpype.overloads.DerivedTest") + DerivedTest = JClass("org.jpype.test.overloads.DerivedTest") Base = DerivedTest.Base() Derived = DerivedTest.Derived() obj = DerivedTest.Sub() diff --git a/test/jpypetest/test_properties.py b/test/jpypetest/test_properties.py index ce105a58d..bbaa29b57 100644 --- a/test/jpypetest/test_properties.py +++ b/test/jpypetest/test_properties.py @@ -15,6 +15,7 @@ # See NOTICE file for details. # # ***************************************************************************** +import conftest import subrun import unittest import jpype @@ -25,11 +26,11 @@ class PropertiesTestCase(unittest.TestCase): @classmethod def setUpClass(cls): + conftest.start_test_jvm() import jpype.beans - jpype.startJVM(classpath="test/classes", convertStrings=False) def setUp(self): - self._bean = jpype.JClass('jpype.properties.TestBean')() + self._bean = jpype.JClass('org.jpype.test.properties.TestBean')() def testPropertyPublicMethodOverlap(self): self._bean.setProperty1("val") @@ -84,7 +85,7 @@ def testProertyDifferentAttributeSet(self): self.assertEqual("setval", self._bean.property7) def testHasProperties(self): - cls = jpype.JClass("jpype.properties.TestBean") + cls = jpype.JClass("org.jpype.test.properties.TestBean") obj = cls() self.assertTrue(isinstance(cls.__dict__['propertyMember'], property)) self.assertTrue(isinstance(cls.__dict__['readOnly'], property)) @@ -92,19 +93,19 @@ def testHasProperties(self): self.assertTrue(isinstance(cls.__dict__['with_'], property)) def testPropertyMember(self): - obj = jpype.JClass("jpype.properties.TestBean")() + obj = jpype.JClass("org.jpype.test.properties.TestBean")() obj.propertyMember = "q" self.assertEqual(obj.propertyMember, "q") def testPropertyKeyword(self): - obj = jpype.JClass("jpype.properties.TestBean")() + obj = jpype.JClass("org.jpype.test.properties.TestBean")() obj.with_ = "a" self.assertEqual(obj.with_, "a") self.assertEqual(obj.m5, "a") def testPropertyReadOnly(self): # Test readonly - obj = jpype.JClass("jpype.properties.TestBean")() + obj = jpype.JClass("org.jpype.test.properties.TestBean")() obj.m3 = "b" self.assertEqual(obj.readOnly, "b") with self.assertRaises(AttributeError): @@ -112,14 +113,14 @@ def testPropertyReadOnly(self): def testPropertyWriteOnly(self): # Test writeonly - obj = jpype.JClass("jpype.properties.TestBean")() + obj = jpype.JClass("org.jpype.test.properties.TestBean")() obj.writeOnly = "c" self.assertEqual(obj.m4, "c") with self.assertRaises(AttributeError): x = obj.writeOnly def testNoProperties(self): - cls = jpype.JClass("jpype.properties.TestBean") + cls = jpype.JClass("org.jpype.test.properties.TestBean") with self.assertRaises(KeyError): cls.__dict__['failure1'] with self.assertRaises(KeyError): diff --git a/test/jpypetest/test_proxy.py b/test/jpypetest/test_proxy.py index ff86726ec..257c05a59 100644 --- a/test/jpypetest/test_proxy.py +++ b/test/jpypetest/test_proxy.py @@ -62,7 +62,7 @@ class ProxyTestCase(common.JPypeTestCase): def setUp(self): super(ProxyTestCase, self).setUp() - self.package = JPackage("jpype.proxy") + self.package = JPackage("org.jpype.test.proxy") self._triggers = self.package.ProxyTriggers def testProxyDecl(self): @@ -75,8 +75,8 @@ def testProxyDecl(self): proxy = JProxy(itf1, dict=d) proxy = JProxy([itf1], dict=d) proxy = JProxy([itf1, itf2], dict=d) - proxy = JProxy("jpype.proxy.TestInterface1", dict=d) - proxy = JProxy(["jpype.proxy.TestInterface1"], dict=d) + proxy = JProxy("org.jpype.test.proxy.TestInterface1", dict=d) + proxy = JProxy(["org.jpype.test.proxy.TestInterface1"], dict=d) def testNotImplemented(self): itf1 = self.package.TestInterface1 @@ -183,14 +183,14 @@ def write(self): pass def testProxyImplementsForm3(self): - @JImplements("jpype.proxy.TestInterface1") + @JImplements("org.jpype.test.proxy.TestInterface1") class MyImpl(object): @JOverride def testMethod1(self): pass def testProxyImplementsForm4(self): - @JImplements("jpype.proxy.TestInterface1", "jpype.proxy.TestInterface2") + @JImplements("org.jpype.test.proxy.TestInterface1", "org.jpype.test.proxy.TestInterface2") class MyImpl(object): @JOverride def testMethod1(self): @@ -225,7 +225,7 @@ def testMethod1(self): def testProxyImplementsFail3(self): with self.assertRaisesRegex(NotImplementedError, "requires method"): # Missing implementation - @JImplements("jpype.proxy.TestInterface1") + @JImplements("org.jpype.test.proxy.TestInterface1") class MyImpl(object): def testMethod1(self): pass @@ -339,8 +339,8 @@ def run(self): def testProxyConvert(self): # This was tests that arguments and "self" both # convert to the same object - TestInterface5 = JClass("jpype.proxy.TestInterface5") - ProxyTriggers = JClass("jpype.proxy.ProxyTriggers") + TestInterface5 = JClass("org.jpype.test.proxy.TestInterface5") + ProxyTriggers = JClass("org.jpype.test.proxy.ProxyTriggers") @JImplements(TestInterface5) class Bomb(object): @@ -429,7 +429,7 @@ def equals(self, _obj): java.util.Arrays.sort(arr, TooFewParams()) def testUnwrap(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() @JImplements("java.io.Serializable") class Q(object): @@ -449,7 +449,7 @@ class R(object): self.assertEqual(JProxy.unwrap(s2), r) def testConvert(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() class R(object): pass @@ -467,7 +467,7 @@ class R(object): self.assertEqual(s2, r) def testMethods(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() @JImplements("java.io.Serializable") class R(object): @@ -481,7 +481,7 @@ class R(object): self.assertIsInstance(s.hashCode(), int) def testMethods2(self): - fixture = JClass("jpype.common.Fixture")() + fixture = JClass("org.jpype.test.common.Fixture")() class R(object): pass diff --git a/test/jpypetest/test_proxy_multithreaded.py b/test/jpypetest/test_proxy_multithreaded.py index 0184c5279..9ebcc8c48 100644 --- a/test/jpypetest/test_proxy_multithreaded.py +++ b/test/jpypetest/test_proxy_multithreaded.py @@ -49,7 +49,7 @@ class ProxyMultiThreadedTestCase(common.JPypeTestCase): def setUp(self): super(ProxyMultiThreadedTestCase, self).setUp() - self.package = JPackage("jpype.proxy") + self.package = JPackage("org.jpype.test.proxy") self.executor = None def tearDown(self): diff --git a/test/jpypetest/test_ref.py b/test/jpypetest/test_ref.py index a5dc1cd71..b28e6f31c 100644 --- a/test/jpypetest/test_ref.py +++ b/test/jpypetest/test_ref.py @@ -38,8 +38,8 @@ def testRunning(self): self.assertTrue(self.refqueue.isRunning()) def testRefs(self): - # This routine will exercise each of the clean up paths once - fixture = JClass("jpype.common.Fixture")() + # This routine will exercise each of the cleanup paths once. + fixture = JClass("org.jpype.test.common.Fixture")() def f(): # Create a proxy to test the proxy path diff --git a/test/jpypetest/test_reflect.py b/test/jpypetest/test_reflect.py index e13f8472e..6b11dd866 100644 --- a/test/jpypetest/test_reflect.py +++ b/test/jpypetest/test_reflect.py @@ -25,9 +25,9 @@ class ReflectCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) - self.test1 = jpype.JClass('jpype.overloads.Test1')() - self.Reflect = jpype.JClass('jpype.reflect.ReflectionTest') - self.Annotation = jpype.JClass('jpype.reflect.Annotation') + self.test1 = jpype.JClass('org.jpype.test.overloads.Test1')() + self.Reflect = jpype.JClass('org.jpype.test.reflect.ReflectionTest') + self.Annotation = jpype.JClass('org.jpype.test.reflect.Annotation') def testClass(self): t = jpype.JClass('java.lang.Object') diff --git a/test/jpypetest/test_serial.py b/test/jpypetest/test_serial.py index 806206010..fded4f36f 100644 --- a/test/jpypetest/test_serial.py +++ b/test/jpypetest/test_serial.py @@ -33,7 +33,7 @@ def tearDown(self): os.remove(self.tempname) def testSerialize(self): - o = JClass("jpype.serial.SerializationTest")() + o = JClass("org.jpype.test.serial.SerializationTest")() tmp = self.tempname fos = java.io.FileOutputStream(tmp) oos = java.io.ObjectOutputStream(fos) diff --git a/test/jpypetest/test_signals.py b/test/jpypetest/test_signals.py index dddf42a0c..1905d78a3 100644 --- a/test/jpypetest/test_signals.py +++ b/test/jpypetest/test_signals.py @@ -24,6 +24,7 @@ import subrun +@unittest.skipIf(sys.platform == "win32", "signals test not applicable on windows") @subrun.TestCase class SignalsTest(unittest.TestCase): @@ -46,8 +47,6 @@ def sigterm_handler(sig, frame): jpype.startJVM(interrupt=False) def setUp(self): - if sys.platform == "win32": - raise unittest.SkipTest("signals test not applicable on windows") self.sigint_event.clear() self.sigterm_event.clear() diff --git a/test/jpypetest/test_sql_h2.py b/test/jpypetest/test_sql_h2.py index 9c984cdb8..2fb91e791 100644 --- a/test/jpypetest/test_sql_h2.py +++ b/test/jpypetest/test_sql_h2.py @@ -22,8 +22,7 @@ db_name = "jdbc:h2:mem:testdb" def setUpModule(module): - from common import java_version - version = java_version() + version = jpype.getJVMVersion() if version[0] == 1 and version[1] == 8: pytest.skip("jdk8 unsupported", allow_module_level=True) diff --git a/test/jpypetest/test_sql_hsqldb.py b/test/jpypetest/test_sql_hsqldb.py index c51950785..186fd61e0 100644 --- a/test/jpypetest/test_sql_hsqldb.py +++ b/test/jpypetest/test_sql_hsqldb.py @@ -6,7 +6,7 @@ from jpype import java import jpype.dbapi2 as dbapi2 import common -import time +import pytest import datetime import decimal import threading @@ -25,9 +25,7 @@ def setUpModule(module): - from common import java_version - import pytest - version = java_version() + version = jpype.getJVMVersion() if version[0] == 1 and version[1] == 8: pytest.skip("jdk8 unsupported", allow_module_level=True) diff --git a/test/jpypetest/test_sql_sqlite.py b/test/jpypetest/test_sql_sqlite.py index 2de96715c..728b6c4a7 100644 --- a/test/jpypetest/test_sql_sqlite.py +++ b/test/jpypetest/test_sql_sqlite.py @@ -21,8 +21,7 @@ db_name = "jdbc:sqlite::memory:" def setUpModule(module): - from common import java_version - version = java_version() + version = jpype.getJVMVersion() if version[0] == 1 and version[1] == 8: pytest.skip("jdk8 unsupported", allow_module_level=True) diff --git a/test/jpypetest/test_startup.py b/test/jpypetest/test_startup.py index ce6156bcf..5c13a1708 100644 --- a/test/jpypetest/test_startup.py +++ b/test/jpypetest/test_startup.py @@ -22,13 +22,19 @@ import unittest import common -root = os.path.dirname(os.path.abspath(os.path.dirname(__file__))) -cp = os.path.join(root, 'classes').replace('\\', '/') +root = Path(__file__).parent.parent +cp = (root / "classes").absolute() + +unicode_sample_jar = (root / "jar/unicode_à😎/sample_package.jar").absolute() +unicode_service_jar = (root / "jar/unicode_à😎/service.jar").absolute() +assert unicode_sample_jar.exists() and unicode_sample_jar.is_file() +assert unicode_service_jar.exists() and unicode_service_jar.is_file() @subrun.TestCase(individual=True) class StartJVMCase(unittest.TestCase): def setUp(self): + assert not jpype.isJVMStarted() self.jvmpath = jpype.getDefaultJVMPath() def testStartup(self): @@ -58,33 +64,33 @@ def testInvalidArgsTrue(self): def testClasspathArgKeyword(self): jpype.startJVM(classpath=cp, convertStrings=False) - assert jpype.JClass('jpype.array.TestArray') is not None + assert jpype.JClass('org.jpype.test.array.TestArray') is not None def testClasspathArgList(self): jpype.startJVM( classpath=[cp], convertStrings=False, ) - assert jpype.JClass('jpype.array.TestArray') is not None + assert jpype.JClass('org.jpype.test.array.TestArray') is not None def testClasspathArgListEmpty(self): jpype.startJVM( classpath=[cp, ''], convertStrings=False, ) - assert jpype.JClass('jpype.array.TestArray') is not None + assert jpype.JClass('org.jpype.test.array.TestArray') is not None def testClasspathArgDef(self): jpype.startJVM('-Djava.class.path=%s' % cp, convertStrings=False) - assert jpype.JClass('jpype.array.TestArray') is not None + assert jpype.JClass('org.jpype.test.array.TestArray') is not None def testClasspathArgPath(self): jpype.startJVM(classpath=Path(cp), convertStrings=False) - assert jpype.JClass('jpype.array.TestArray') is not None + assert jpype.JClass('org.jpype.test.array.TestArray') is not None def testClasspathArgPathList(self): jpype.startJVM(classpath=[Path(cp)], convertStrings=False) - assert jpype.JClass('jpype.array.TestArray') is not None + assert jpype.JClass('org.jpype.test.array.TestArray') is not None def testClasspathArgGlob(self): jpype.startJVM(classpath=os.path.join(cp, '..', 'jar', 'mrjar*')) @@ -101,7 +107,7 @@ def testClasspathBadType(self): def testJVMPathArg_Str(self): jpype.startJVM(self.jvmpath, classpath=cp, convertStrings=False) - assert jpype.JClass('jpype.array.TestArray') is not None + assert jpype.JClass('org.jpype.test.array.TestArray') is not None def testJVMPathArg_None(self): # It is allowed to pass None as a JVM path @@ -109,13 +115,13 @@ def testJVMPathArg_None(self): None, # type: ignore classpath=cp, ) - assert jpype.JClass('jpype.array.TestArray') is not None + assert jpype.JClass('org.jpype.test.array.TestArray') is not None def testJVMPathArg_NoArgs(self): jpype.startJVM( classpath=cp, ) - assert jpype.JClass('jpype.array.TestArray') is not None + assert jpype.JClass('org.jpype.test.array.TestArray') is not None def testJVMPathArg_Path(self): with self.assertRaises(TypeError): @@ -133,11 +139,11 @@ def testJVMPathKeyword_str(self): jvmpath=self.jvmpath, convertStrings=False, ) - assert jpype.JClass('jpype.array.TestArray') is not None + assert jpype.JClass('org.jpype.test.array.TestArray') is not None def testJVMPathKeyword_Path(self): jpype.startJVM(jvmpath=Path(self.jvmpath), classpath=cp, convertStrings=False) - assert jpype.JClass('jpype.array.TestArray') is not None + assert jpype.JClass('org.jpype.test.array.TestArray') is not None def testPathTwice(self): with self.assertRaises(TypeError): @@ -151,60 +157,60 @@ def testNonASCIIPath(self): """Test that paths with non-ASCII characters are handled correctly. Regression test for https://github.com/jpype-project/jpype/issues/1194 """ - jpype.startJVM(jvmpath=Path(self.jvmpath), classpath="test/jar/unicode_à😎/sample_package.jar") + jpype.startJVM(jvmpath=Path(self.jvmpath), classpath=str(unicode_sample_jar)) cl = jpype.JClass("java.lang.ClassLoader").getSystemClassLoader() self.assertEqual(type(cl), jpype.JClass("org.jpype.JPypeClassLoader")) - assert dir(jpype.JPackage('org.jpype.sample_package')) == ['A', 'B'] + assert dir(jpype.JPackage('org.jpype.test.sample_package')) == ['A', 'B'] def testOldStyleNonASCIIPath(self): """Test that paths with non-ASCII characters are handled correctly. Regression test for https://github.com/jpype-project/jpype/issues/1194 """ - jpype.startJVM("-Djava.class.path=test/jar/unicode_à😎/sample_package.jar", jvmpath=Path(self.jvmpath)) + jpype.startJVM(f"-Djava.class.path={unicode_sample_jar}", jvmpath=Path(self.jvmpath)) cl = jpype.JClass("java.lang.ClassLoader").getSystemClassLoader() self.assertEqual(type(cl), jpype.JClass("org.jpype.JPypeClassLoader")) - assert dir(jpype.JPackage('org.jpype.sample_package')) == ['A', 'B'] + assert dir(jpype.JPackage('org.jpype.test.sample_package')) == ['A', 'B'] def testNonASCIIPathWithSystemClassLoader(self): with self.assertRaises(ValueError): jpype.startJVM( - "-Djava.system.class.loader=jpype.startup.TestSystemClassLoader", + "-Djava.system.class.loader=org.jpype.test.startup.TestSystemClassLoader", jvmpath=Path(self.jvmpath), - classpath="test/jar/unicode_à😎/sample_package.jar" + classpath=str(unicode_sample_jar.absolute()) ) def testOldStyleNonASCIIPathWithSystemClassLoader(self): with self.assertRaises(ValueError): jpype.startJVM( self.jvmpath, - "-Djava.system.class.loader=jpype.startup.TestSystemClassLoader", - "-Djava.class.path=test/jar/unicode_à😎/sample_package.jar" + "-Djava.system.class.loader=org.jpype.test.startup.TestSystemClassLoader", + f"-Djava.class.path={unicode_sample_jar.absolute()}", ) @common.requireAscii def testASCIIPathWithSystemClassLoader(self): jpype.startJVM( - "-Djava.system.class.loader=jpype.startup.TestSystemClassLoader", + "-Djava.system.class.loader=org.jpype.test.startup.TestSystemClassLoader", jvmpath=Path(self.jvmpath), - classpath=f"test/classes" + classpath=cp ) classloader = jpype.JClass("java.lang.ClassLoader").getSystemClassLoader() - test_classLoader = jpype.JClass("jpype.startup.TestSystemClassLoader") + test_classLoader = jpype.JClass("org.jpype.test.startup.TestSystemClassLoader") self.assertEqual(type(classloader), test_classLoader) - assert dir(jpype.JPackage('jpype.startup')) == ['TestSystemClassLoader'] + assert dir(jpype.JPackage('org.jpype.test.startup')) == ['TestSystemClassLoader'] @common.requireAscii def testOldStyleASCIIPathWithSystemClassLoader(self): jpype.startJVM( self.jvmpath, - "-Djava.system.class.loader=jpype.startup.TestSystemClassLoader", - "-Djava.class.path=test/classes" + "-Djava.system.class.loader=org.jpype.test.startup.TestSystemClassLoader", + f"-Djava.class.path={cp}", ) classloader = jpype.JClass("java.lang.ClassLoader").getSystemClassLoader() - test_classLoader = jpype.JClass("jpype.startup.TestSystemClassLoader") + test_classLoader = jpype.JClass("org.jpype.test.startup.TestSystemClassLoader") self.assertEqual(type(classloader), test_classLoader) - assert dir(jpype.JPackage('jpype.startup')) == ['TestSystemClassLoader'] + assert dir(jpype.JPackage('org.jpype.test.startup')) == ['TestSystemClassLoader'] @common.requireAscii def testDefaultSystemClassLoader(self): @@ -217,7 +223,7 @@ def testServiceWithNonASCIIPath(self): jpype.startJVM( self.jvmpath, "-Djava.locale.providers=SPI,CLDR", - classpath="test/jar/unicode_à😎/service.jar", + classpath=unicode_service_jar ) ZoneId = jpype.JClass("java.time.ZoneId") ZoneRulesException = jpype.JClass("java.time.zone.ZoneRulesException") diff --git a/test/jpypetest/test_thread.py b/test/jpypetest/test_thread.py index 1ad3c2b4a..81eb3d057 100644 --- a/test/jpypetest/test_thread.py +++ b/test/jpypetest/test_thread.py @@ -23,8 +23,6 @@ class ThreadTestCase(common.JPypeTestCase): - def setUp(self): - common.JPypeTestCase.setUp(self) @pytest.mark.filterwarnings("ignore::DeprecationWarning") def testAttach(self): diff --git a/test/jpypetest/test_utf8.py b/test/jpypetest/test_utf8.py index c1e88453c..f1d8795ad 100644 --- a/test/jpypetest/test_utf8.py +++ b/test/jpypetest/test_utf8.py @@ -70,7 +70,7 @@ def setUp(self): common.JPypeTestCase.setUp(self) # Java IO test class - self.Utf8Test = JClass('jpype.utf8.Utf8Test') + self.Utf8Test = JClass('org.jpype.test.utf8.Utf8Test') # Test strings # IMPORTANT: they should be identical, and in the same order, as the test strings difned in the diff --git a/test/jpypetest/test_varargs.py b/test/jpypetest/test_varargs.py index 2577adeb4..422da4a8b 100644 --- a/test/jpypetest/test_varargs.py +++ b/test/jpypetest/test_varargs.py @@ -32,7 +32,7 @@ def compareList(l1, l2): class VarArgsTestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) - self.VarArgs = jpype.JClass('jpype.varargs.VarArgs') + self.VarArgs = jpype.JClass('org.jpype.test.varargs.VarArgs') self.Object = jpype.JClass('java.lang.Object') self.ObjectA = jpype.JArray(self.Object) self.Integer = jpype.JClass('java.lang.Integer') diff --git a/test/jpypetest/test_virtual.py b/test/jpypetest/test_virtual.py index a76ded2e8..d25f492e1 100644 --- a/test/jpypetest/test_virtual.py +++ b/test/jpypetest/test_virtual.py @@ -29,7 +29,7 @@ class VirtualsTestCase(common.JPypeTestCase): def setUp(self): common.JPypeTestCase.setUp(self) - self.vt = jpype.JClass('jpype.types.VirtualTest') + self.vt = jpype.JClass('org.jpype.test.types.VirtualTest') def testCallBooleanImplements(self): v1 = self.vt.getBooleanImplements() diff --git a/test/jpypetest/test_zzz.py b/test/jpypetest/test_zzz.py index c815176e2..eeac1c680 100644 --- a/test/jpypetest/test_zzz.py +++ b/test/jpypetest/test_zzz.py @@ -15,28 +15,17 @@ # See NOTICE file for details. # # ***************************************************************************** -import sys import _jpype import jpype -from jpype.types import * -from jpype import JPackage, java import common -import pytest -try: - import numpy as np -except ImportError: - pass class ZZZTestCase(common.JPypeTestCase): - def setUp(self): - common.JPypeTestCase.setUp(self) - def testShutdown(self): # Install a coverage hook - instance = JClass("org.jpype.JPypeContext").getInstance() - JClass("jpype.common.OnShutdown").addCoverageHook(instance) + instance = jpype.JClass("org.jpype.JPypeContext").getInstance() + jpype.JClass("org.jpype.test.common.OnShutdown").addCoverageHook(instance) # Shutdown jpype.shutdownJVM()