| 1 | # ***************************************************************************** |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | # |
| 15 | # See NOTICE file for details. |
| 16 | # |
| 17 | # ***************************************************************************** |
| 18 | import sys |
| 19 | import jpype |
| 20 | import common |
| 21 | |
| 22 | |
| 23 | class ForNameTestCase(common.JPypeTestCase): |
| 24 | |
| 25 | def setUp(self): |
| 26 | common.JPypeTestCase.setUp(self) |
| 27 | |
| 28 | def testForName(self): |
| 29 | cls = jpype.JClass('java.lang.Class') |
| 30 | test = cls.forName('jpype.overloads.Test1') |
| 31 | # Should return a java.lang.Class, rather than the python wrapper for java.lang.Class |
| 32 | self.assertTrue(type(test) == type(cls.class_)) |
| 33 | self.assertEqual(test.getName(), 'jpype.overloads.Test1') |
| 34 | |
| 35 | def testForName2(self): |
| 36 | cls = jpype.JClass('java.lang.Class') |
| 37 | clsloader = jpype.JClass( |
| 38 | 'java.lang.ClassLoader').getSystemClassLoader() |
| 39 | test = cls.forName('jpype.overloads.Test1', True, clsloader) |
| 40 | # Should return a java.lang.Class, rather than the python wrapper for java.lang.Class |
| 41 | self.assertTrue(type(test) == type(cls.class_)) |
| 42 | self.assertEqual(test.getName(), 'jpype.overloads.Test1') |