--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/JavaLookupTests.st Thu Nov 15 22:10:02 2012 +0000
@@ -0,0 +1,371 @@
+"
+ Copyright (c) 2010-2011 Jan Vrany, Jan Kurs & Marcel Hlopko,
+ SWING Research Group, Czech Technical University
+ in Prague
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the 'Software'), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+"
+"{ Package: 'stx:libjava' }"
+
+TestCase subclass:#JavaLookupTests
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Languages-Java-Tests-Interop'
+!
+
+!JavaLookupTests class methodsFor:'documentation'!
+
+copyright
+"
+ Copyright (c) 2010-2011 Jan Vrany, Jan Kurs & Marcel Hlopko,
+ SWING Research Group, Czech Technical University
+ in Prague
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the 'Software'), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+
+"
+!
+
+documentation
+"
+ This testcase tests the java-smalltalk interop lookup
+ (JavaLookup)
+
+ [author:]
+ Jan Vrany <jan.vrany@fit.cvut.cz>
+
+ [instance variables:]
+
+ [class variables:]
+
+ [see also:]
+
+"
+! !
+
+!JavaLookupTests class methodsFor:'resources'!
+
+resources
+ ^ Array with: JavaLookupTestsResource.
+
+ "Created: / 11-04-2011 / 19:38:11 / kursjan <kursjan@fit.cvut.cz>"
+ "Modified: / 29-08-2011 / 23:35:06 / Jan Kurs <kursjan@fit.cvut.cz>"
+ "Modified: / 29-10-2012 / 07:47:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaLookupTests methodsFor:'support'!
+
+javaTestClass
+ ^ Java classForName: 'cz.cvut.fit.swing.methodLookup.Object'
+
+ "Created: / 05-09-2011 / 20:13:48 / Jan Kurs <kursjan@fit.cvut.cz>"
+!
+
+personManipulatorClass
+ "Person Manipulator can interact with Person class defined in Java"
+ ^ Java classForName: 'cz.cvut.fit.swing.methodLookup.PersonManipulator'
+
+ "Created: / 06-09-2011 / 21:48:16 / Jan Kurs <kursjan@fit.cvut.cz>"
+!
+
+setManipulatorClass
+ "Person Manipulator can interact with Person class defined in Java"
+ ^ Java classForName: 'cz.cvut.fit.swing.methodLookup.SetManipulator'
+
+ "Created: / 25-09-2011 / 16:41:02 / Jan Kurs <kursjan@fit.cvut.cz>"
+! !
+
+!JavaLookupTests methodsFor:'tests - java lookup'!
+
+test3
+ "I am not sure with this test :)"
+ self shouldnt: [(Java classForName: 'cz.cvut.fit.swing.methodLookup.Object') new isNumber] raise: Exception.
+ self assert: (Java classForName: 'cz.cvut.fit.swing.methodLookup.Object') new isNumber = false.
+
+ "Created: / 11-04-2011 / 19:43:37 / kursjan <kursjan@fit.cvut.cz>"
+!
+
+testBasic
+ self
+ shouldnt:[ (Java classForName:'java.lang.Object') new hash ]
+ raise:Exception.
+ self
+ shouldnt:[ (Java classForName:'java.lang.Object') new toString ]
+ raise:Exception.
+
+ "Created: / 11-04-2011 / 19:22:07 / kursjan <kursjan@fit.cvut.cz>"
+!
+
+testBoolean
+ self assert: (self javaTestClass new getTrue) = true.
+
+ "Created: / 11-04-2011 / 19:32:51 / kursjan <kursjan@fit.cvut.cz>"
+ "Created: / 05-09-2011 / 21:06:13 / Jan Kurs <kursjan@fit.cvut.cz>"
+!
+
+testBoolean2
+ self assert: (self javaTestClass new getFalse) = false.
+
+ "Created: / 11-04-2011 / 19:32:51 / kursjan <kursjan@fit.cvut.cz>"
+ "Created: / 05-09-2011 / 21:06:25 / Jan Kurs <kursjan@fit.cvut.cz>"
+!
+
+testBoolean3
+ self assert: (self javaTestClass new getTruePrim) = true.
+
+ "Created: / 11-04-2011 / 19:32:51 / kursjan <kursjan@fit.cvut.cz>"
+ "Created: / 05-09-2011 / 21:07:29 / Jan Kurs <kursjan@fit.cvut.cz>"
+!
+
+testBoolean4
+ self assert: (self javaTestClass new getFalsePrim) = false.
+
+ "Created: / 11-04-2011 / 19:32:51 / kursjan <kursjan@fit.cvut.cz>"
+ "Created: / 05-09-2011 / 21:07:38 / Jan Kurs <kursjan@fit.cvut.cz>"
+!
+
+testBoolean5
+ self assert: (self javaTestClass new getFalseWithConversion) = false.
+
+ "Created: / 11-04-2011 / 19:32:51 / kursjan <kursjan@fit.cvut.cz>"
+ "Created: / 25-09-2011 / 19:23:36 / Jan Kurs <kursjan@fit.cvut.cz>"
+!
+
+testBoolean6
+ self assert: (self javaTestClass new getFalseFromBooleanValueOf) = false.
+
+ "Created: / 11-04-2011 / 19:32:51 / kursjan <kursjan@fit.cvut.cz>"
+ "Created: / 25-09-2011 / 19:40:22 / Jan Kurs <kursjan@fit.cvut.cz>"
+!
+
+testClass
+ self assert: ((Java classForName: 'java.lang.Object') isKindOf: JavaClass).
+ self assert: ((Java classForName: 'java.lang.Object') new isKindOf: JavaObject)
+
+
+ "Created: / 11-04-2011 / 19:22:07 / kursjan <kursjan@fit.cvut.cz>"
+!
+
+testDoesNotUnderstand
+ self
+ should:[ (Java classForName:'java.lang.Object') new bafickyBaf ]
+ raise:MessageNotUnderstood.
+
+ "Created: / 11-04-2011 / 19:22:07 / kursjan <kursjan@fit.cvut.cz>"
+ "Created: / 30-08-2011 / 22:06:16 / Jan Kurs <kursjan@fit.cvut.cz>"
+!
+
+testMultipleParameters
+ "test multiple parameters"
+
+ self
+ assert: (self javaTestClass new foo) = 0
+
+ "Created: / 11-04-2011 / 19:48:54 / kursjan <kursjan@fit.cvut.cz>"
+ "Modified: / 05-09-2011 / 20:18:03 / Jan Kurs <kursjan@fit.cvut.cz>"
+!
+
+testMultipleParameters1
+ "test multiple parameters"
+
+ self
+ assert: (self javaTestClass new foo: 1) = 1
+
+ "Created: / 11-04-2011 / 19:48:54 / kursjan <kursjan@fit.cvut.cz>"
+ "Created: / 05-09-2011 / 20:18:14 / Jan Kurs <kursjan@fit.cvut.cz>"
+!
+
+testMultipleParameters2
+ "test multiple parameters"
+
+ self
+ assert: (self javaTestClass new foo: 1 and: 2) = 2
+
+ "Created: / 11-04-2011 / 19:48:54 / kursjan <kursjan@fit.cvut.cz>"
+ "Created: / 05-09-2011 / 20:18:30 / Jan Kurs <kursjan@fit.cvut.cz>"
+!
+
+testSayHello
+ self assert: (self javaTestClass new sayHello = 'hello').
+
+ "Created: / 11-04-2011 / 19:32:51 / kursjan <kursjan@fit.cvut.cz>"
+ "Modified: / 05-09-2011 / 21:05:40 / Jan Kurs <kursjan@fit.cvut.cz>"
+!
+
+testSayHelloStatic
+ self assert: self javaTestClass staticSayHello = 'static hello'.
+
+ "Created: / 11-04-2011 / 19:32:51 / kursjan <kursjan@fit.cvut.cz>"
+ "Created: / 05-09-2011 / 20:26:44 / Jan Kurs <kursjan@fit.cvut.cz>"
+!
+
+testTypeOverloading
+ "test type overloading"
+
+ self
+ assert:(self javaTestClass new overloadedMethod: 1) = 4
+
+ "Created: / 11-04-2011 / 20:02:54 / kursjan <kursjan@fit.cvut.cz>"
+ "Modified: / 05-09-2011 / 21:37:53 / Jan Kurs <kursjan@fit.cvut.cz>"
+!
+
+testTypeOverloading2
+ "test type overloading"
+
+ self
+ assert:(self javaTestClass new overloadedMethod: 'Hi') = 3.
+
+ "Created: / 11-04-2011 / 20:02:54 / kursjan <kursjan@fit.cvut.cz>"
+ "Created: / 05-09-2011 / 21:37:57 / Jan Kurs <kursjan@fit.cvut.cz>"
+! !
+
+!JavaLookupTests methodsFor:'tests - obsolete'!
+
+_testSetManipulator_add
+ "test interaction of smalltalk Set and java.util.Set"
+ | aSet anObject |
+ self breakPoint: #jk info: 'using SetSample, because it contains DNU hook - this is workaround'.
+ aSet := SetSample new.
+ anObject := Object new.
+
+ self setManipulatorClass new addElement: aSet and: anObject.
+ self assert: aSet size = 1.
+ self assert:(self setManipulatorClass new getSize: aSet) = 1.
+ self assert:(aSet contains: [:e | e = anObject ]).
+
+ "Created: / 29-10-2012 / 07:17:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_testSetManipulator_contains
+ "test interaction of smalltalk Set and java.util.Set"
+ | aSet anObject |
+ self breakPoint: #jk info: 'using SetSample, because it contains DNU hook - this is workaround'.
+ aSet := SetSample new.
+ anObject := Object new.
+
+ self assert: (self setManipulatorClass new contains: aSet and: anObject) = false.
+ aSet add: anObject.
+ self assert: (self setManipulatorClass new contains: aSet and: anObject) = true.
+
+ "Created: / 29-10-2012 / 07:18:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_testSetManipulator_getSize
+ "test interaction of smalltalk Set and java.util.Set"
+ | aSet |
+ self breakPoint: #jk info: 'using SetSample, because it contains DNU hook - this is workaround'.
+ aSet := SetSample new.
+
+ self assert:(self setManipulatorClass new getSize: aSet) = 0.
+ aSet add: Object new.
+ self assert:(self setManipulatorClass new getSize: aSet) = 1.
+
+ "Created: / 29-10-2012 / 07:17:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_testSetManipulator_isEmpty
+ "test interaction of smalltalk Set and java.util.Set"
+ | aSet |
+ self breakPoint: #jk info: 'using SetSample, because it contains DNU hook - this is workaround'.
+ aSet := SetSample new.
+
+ self assert: (self setManipulatorClass new isEmpty:aSet).
+ aSet add: Object new.
+ self assert: (self setManipulatorClass new isEmpty:aSet) not.
+
+ "Created: / 29-10-2012 / 07:17:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_testSetManipulator_remove
+ "test interaction of smalltalk Set and java.util.Set"
+ | aSet anObject |
+ self breakPoint: #jk info: 'using SetSample, because it contains DNU hook - this is workaround'.
+ aSet := SetSample new.
+ anObject := Object new.
+
+
+ aSet add: anObject.
+ self setManipulatorClass new remove: aSet and: anObject.
+ self assert: aSet size = 0.
+ self assert:(self setManipulatorClass new getSize: aSet) = 0.
+ self assert:(aSet contains: [:e | e = anObject ]) not.
+
+ "Created: / 29-10-2012 / 07:17:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaLookupTests methodsFor:'tests - smalltalk lookup'!
+
+testPersonManipulator_getAge
+ "test interaction of Smalltallk objects with Java code"
+ | person |
+ person := PersonSample new.
+
+ person name: 'Anne'.
+ person age: 18.
+
+ self
+ assert:(self personManipulatorClass new getPersonAge: person) = 18.
+
+ "Created: / 11-04-2011 / 20:02:54 / kursjan <kursjan@fit.cvut.cz>"
+ "Created: / 25-09-2011 / 17:27:45 / Jan Kurs <kursjan@fit.cvut.cz>"
+!
+
+testPersonManipulator_getName
+ "test interaction of Smalltallk objects with Java code"
+ | person |
+ person := PersonSample new.
+
+ person name: 'Anne'.
+ person age: 18.
+
+ self
+ assert:(self personManipulatorClass new getPersonName: person) = 'Anne'.
+
+ "Created: / 11-04-2011 / 20:02:54 / kursjan <kursjan@fit.cvut.cz>"
+ "Created: / 25-09-2011 / 17:27:34 / Jan Kurs <kursjan@fit.cvut.cz>"
+! !
+
+!JavaLookupTests class methodsFor:'documentation'!
+
+version_SVN
+ ^ '$Id$'
+! !