--- a/src/JavaInterfaceMethodRefTests.st Mon May 23 15:27:40 2011 +0000
+++ b/src/JavaInterfaceMethodRefTests.st Mon May 23 16:05:45 2011 +0000
@@ -128,219 +128,22 @@
!JavaInterfaceMethodRefTests methodsFor:'permission tests'!
-testAccessingPrivateFromOutside
- | javaClassRef javaMethodRef initString throwedException |
-
- self enableMockedExceptionThrowing.
-
- [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
- javaClassRef := self getClassRefFor: initString.
- javaClassRef owner: (Java classForName: 'java.lang.Object').
- javaMethodRef := JavaMethodRef2 in: nil
- namedAndTyped: (self getName: 'privateMethod'
- descriptor: '()Ljava/lang/String;')
- inClassIdentifiedByRef: javaClassRef.
- javaMethodRef resolve. ] on: Error
- do: [:e | throwedException := e ].
- self assertTrue: (throwedException notNil
- and: [ throwedException messageText = 'IllegalAccessError' ]).
- self disableMockedExceptionThrowing.
-
- "Created: / 13-04-2011 / 14:44:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 10-05-2011 / 16:22:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-!
-
-testAccessingPrivateFromOutsideInNonPublic
- | javaClassRef javaMethodRef initString throwedException |
-
- self enableMockedExceptionThrowing.
-
- [ initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
- javaClassRef := self getClassRefFor: initString.
- javaClassRef owner: (Java classForName: 'java.lang.Object').
- javaMethodRef := JavaMethodRef2 in: nil
- namedAndTyped: (self getName: 'privateMethod'
- descriptor: '()Ljava/lang/String;')
- inClassIdentifiedByRef: javaClassRef.
- javaMethodRef resolve. ] on: Error
- do: [:e | throwedException := e ].
- self assertTrue: (throwedException notNil
- and: [ throwedException messageText = 'IllegalAccessError' ]).
- self disableMockedExceptionThrowing.
-
- "Created: / 13-04-2011 / 14:47:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 10-05-2011 / 16:22:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-!
-
-testAccessingPrivateFromSubclass
- | javaClassRef javaMethodRef initString throwedException |
-
- self enableMockedExceptionThrowing.
-
- [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
- javaClassRef := self getClassRefFor: initString.
- javaClassRef owner: (Java classForName: 'java.lang.SubclassOfPublicClass').
- javaMethodRef := JavaMethodRef2 in: nil
- namedAndTyped: (self getName: 'privateMethod'
- descriptor: '()Ljava/lang/String;')
- inClassIdentifiedByRef: javaClassRef.
- javaMethodRef resolve. ] on: Error
- do: [:e | throwedException := e ].
- self assertTrue: (throwedException notNil
- and: [ throwedException messageText = 'IllegalAccessError' ]).
- self disableMockedExceptionThrowing.
-
- "Created: / 13-04-2011 / 14:49:32 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 10-05-2011 / 16:22:43 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-!
-
-testAccessingProtectedFromOutside
- | javaClassRef javaMethodRef initString throwedException |
-
- self enableMockedExceptionThrowing.
-
- [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
- javaClassRef := self getClassRefFor: initString.
- javaClassRef owner: (Java classForName: 'java.lang.Object').
- javaMethodRef := JavaMethodRef2 in: nil
- namedAndTyped: (self getName: 'protectedMethod'
- descriptor: '()Ljava/lang/String;')
- inClassIdentifiedByRef: javaClassRef.
- javaMethodRef resolve. ] on: Error
- do: [:e | throwedException := e ].
- self assertTrue: (throwedException notNil
- and: [ throwedException messageText = 'IllegalAccessError' ]).
- self disableMockedExceptionThrowing.
-
- "Created: / 13-04-2011 / 14:44:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 10-05-2011 / 16:22:45 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-!
-
-testAccessingProtectedFromOutsideInNonPublic
- | javaClassRef javaMethodRef initString throwedException |
+testAccessingPublicFromSubclass
+ | javaMethodRef initString |
- self enableMockedExceptionThrowing.
-
- [ initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
- javaClassRef := self getClassRefFor: initString.
- javaClassRef owner: (Java classForName: 'java.lang.Object').
- javaMethodRef := JavaMethodRef2 in: nil
- namedAndTyped: (self getName: 'protectedMethod'
- descriptor: '()Ljava/lang/String;')
- inClassIdentifiedByRef: javaClassRef.
- javaMethodRef resolve. ] on: Error
- do: [:e | throwedException := e ].
- self assertTrue: (throwedException notNil
- and: [ throwedException messageText = 'IllegalAccessError' ]).
- self disableMockedExceptionThrowing.
-
- "Created: / 13-04-2011 / 14:47:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 10-05-2011 / 16:22:47 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-!
-
-testAccessingProtectedFromSubclass
- | javaClassRef javaMethodRef initString throwedException |
-
- self enableMockedExceptionThrowing.
-
- [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
- javaClassRef := self getClassRefFor: initString.
- javaClassRef
- owner: (Java classForName: 'stx.libjava.tests.mocks.SubclassOfPublicClass').
- javaMethodRef := JavaMethodRef2 in: nil
- namedAndTyped: (self getName: 'protectedMethod'
- descriptor: '()Ljava/lang/String;')
- inClassIdentifiedByRef: javaClassRef.
- javaMethodRef resolve. ] on: Error
- do: [:e | throwedException := e ].
- self assertTrue: (throwedException isNil).
- self disableMockedExceptionThrowing.
-
- "Created: / 13-04-2011 / 14:49:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 10-05-2011 / 16:22:50 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-!
-
-testAccessingPublic
- | javaClassRef javaMethodRef initString |
-
- self enableMockedExceptionThrowing.
- self shouldnt:
- [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
- javaClassRef := self getClassRefFor: initString.
- javaClassRef owner: (Java classForName: 'java.lang.Object').
- javaMethodRef := JavaMethodRef2 in: nil
- namedAndTyped: (self getName: 'publicMethod'
- descriptor: '()Ljava/lang/String;')
- inClassIdentifiedByRef: javaClassRef.
+ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
+ self
+ should:
+ [ javaMethodRef := self
+ getInterfaceMethodRefNamed: 'publicMethod'
+ typed: '()Ljava/lang/String;'
+ inClass: initString.
javaMethodRef resolve. ]
- raise: Error.
- self disableMockedExceptionThrowing.
-
- "Created: / 13-04-2011 / 14:44:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 10-05-2011 / 16:22:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-!
-
-testAccessingPublicFromOutside
- | javaClassRef javaMethodRef initString |
-
- self enableMockedExceptionThrowing.
- self shouldnt:
- [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
- javaClassRef := self getClassRefFor: initString.
- javaClassRef owner: (Java classForName: 'java.lang.Object').
- javaMethodRef := JavaMethodRef2 in: nil
- namedAndTyped: (self getName: 'publicMethod'
- descriptor: '()Ljava/lang/String;')
- inClassIdentifiedByRef: javaClassRef.
- javaMethodRef resolve. ]
- raise: Error.
- self disableMockedExceptionThrowing.
-
- "Created: / 13-04-2011 / 14:44:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 10-05-2011 / 16:22:55 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-!
-
-testAccessingPublicFromOutsideInNonPublic
- | javaClassRef javaMethodRef initString throwedException |
-
- self enableMockedExceptionThrowing.
-
- [ initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
- javaClassRef := self getClassRefFor: initString.
- javaClassRef owner: (Java classForName: 'java.lang.Object').
- javaMethodRef := JavaMethodRef2 in: nil
- namedAndTyped: (self getName: 'publicMethod'
- descriptor: '()Ljava/lang/String;')
- inClassIdentifiedByRef: javaClassRef.
- javaMethodRef resolve. ] on: Error
- do: [:e | throwedException := e ].
- self assertTrue: (throwedException notNil
- and: [ throwedException messageText = 'IllegalAccessError' ]).
- self disableMockedExceptionThrowing.
-
- "Created: / 13-04-2011 / 14:48:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 10-05-2011 / 16:22:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-!
-
-testAccessingPublicFromSubclass
- | javaClassRef javaMethodRef initString throwedException |
-
- self enableMockedExceptionThrowing.
-
- [ initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
- javaClassRef := self getClassRefFor: initString.
- javaClassRef owner: (Java classForName: 'java.lang.SubclassOfPublicClass').
- javaMethodRef := JavaMethodRef2 in: nil
- namedAndTyped: (self getName: 'publicMethod'
- descriptor: '()Ljava/lang/String;')
- inClassIdentifiedByRef: javaClassRef.
- javaMethodRef resolve. ] on: Error
- do: [:e | throwedException := e ].
- self assertTrue: (throwedException isNil).
- self disableMockedExceptionThrowing.
+ raise: Error
+ suchThat: [:e | e messageText = 'IncompatibleClassChangeError' ].
"Created: / 13-04-2011 / 14:49:11 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 10-05-2011 / 16:22:59 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 23-05-2011 / 17:54:12 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaInterfaceMethodRefTests class methodsFor:'documentation'!