src/AbstractJavaTestCase.st
author hlopkmar
Fri, 13 May 2011 08:01:14 +0000
branchjk_new_structure
changeset 778 caa3a009f617
parent 777 e6e61412ae43
child 814 68df82c46fb0
permissions -rw-r--r--
refactoring tests and fixing related bugs, added functionality to constantPool
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
773
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
     1
"{ Package: 'stx:libjava' }"
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
     2
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
     3
TestCase subclass:#AbstractJavaTestCase
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
     4
	instanceVariableNames:'exceptionThrowerBackup'
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
     5
	classVariableNames:''
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
     6
	poolDictionaries:''
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
     7
	category:'Languages-Java-Tests-RuntimeConstantPool'
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
     8
!
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
     9
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    10
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    11
!AbstractJavaTestCase class methodsFor:'resources'!
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    12
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    13
resources
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    14
    ^ Array with: JavaInitializedResource with: JavaTestsResource.
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    15
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    16
    "Created: / 26-04-2011 / 13:03:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    17
! !
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    18
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    19
!AbstractJavaTestCase methodsFor:'helpers'!
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    20
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    21
disableMockedExceptionThrowing
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    22
    JavaResolver uniqueInstance exceptionThrower: exceptionThrowerBackup.
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    23
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    24
    "Created: / 13-04-2011 / 14:11:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    25
!
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    26
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    27
enableMockedExceptionThrowing
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    28
    exceptionThrowerBackup := JavaResolver uniqueInstance exceptionThrower.
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    29
    JavaResolver uniqueInstance exceptionThrower: JavaExceptionThrowerMock new.
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    30
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    31
    "Created: / 13-04-2011 / 14:11:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    32
!
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    33
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    34
getClassRefFor: classString
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    35
^ JavaClassRef2 in: (JavaConstantPool with: classString)
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    36
                withNameAt: 1.
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    37
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    38
    "Created: / 10-05-2011 / 15:03:38 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    39
!
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    40
777
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 774
diff changeset
    41
getClassRefIn: aJavaConstantPool withNameAt: nameCPIndex
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 774
diff changeset
    42
^ JavaClassRef2 in: aJavaConstantPool withNameAt: nameCPIndex.
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 774
diff changeset
    43
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 774
diff changeset
    44
    "Created: / 12-05-2011 / 19:14:30 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 774
diff changeset
    45
!
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 774
diff changeset
    46
773
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    47
getCrateClassReadStream
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    48
    ^ ((Filename named: UserPreferences current javaTestsDirectory) 
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    49
        / 'libjava' / 'bin' 
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    50
        / 'stx' / 'libjava' 
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    51
        / 'tests' / 'mocks' 
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    52
        / 'Crate.class') readStream.
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    53
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    54
    "Created: / 10-05-2011 / 12:13:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    55
    "Modified: / 12-05-2011 / 16:26:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    56
!
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    57
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    58
getName: name descriptor: type 
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    59
    ^ JavaNameAndType2 
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    60
        in: (JavaConstantPool with: name with: type)
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    61
        withNameAt: 1
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    62
        andDescriptorAt: 2.
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    63
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
    64
    "Created: / 10-05-2011 / 16:01:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
777
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 774
diff changeset
    65
!
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 774
diff changeset
    66
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 774
diff changeset
    67
getNameAndTypeIn: aJavaConstantPool nameAt: nameCPIndex typeAt: typeCPIndex 
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 774
diff changeset
    68
    ^ JavaNameAndType2 in: aJavaConstantPool withNameAt: nameCPIndex andDescriptorAt: typeCPIndex.
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 774
diff changeset
    69
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 774
diff changeset
    70
    "Created: / 12-05-2011 / 19:15:17 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 774
diff changeset
    71
!
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 774
diff changeset
    72
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    73
getPrettyBigConstantPool
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    74
    | cp |
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    75
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    76
    cp := JavaConstantPool new: 20.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    77
    cp at: 1 put: 6.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    78
    cp at: 2 put: 'Ljava/lang/Object;'.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    79
    cp at: 3 putClassRefWithNameAt: 2.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    80
    cp 
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    81
        at: 4
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    82
        putMethodRefWithClassAt: 3
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    83
        andNameAndTypeAt: 5.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    84
    cp 
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    85
        at: 5
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    86
        putNameAndTypeWithNameAt: 6
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    87
        andDescriptorAt: 7.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    88
    cp at: 6 put: '<init>'.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    89
    cp at: 7 put: '()V'.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    90
    cp at: 8 put: 'Ljava/lang/String;'.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    91
    cp at: 9 putClassRefWithNameAt: 8.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    92
    cp 
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    93
        at: 10
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    94
        putMethodRefWithClassAt: 9
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    95
        andNameAndTypeAt: 13.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    96
    cp at: 11 put: 'length'.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    97
    cp at: 12 put: '()I'.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    98
    cp 
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    99
        at: 13
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   100
        putNameAndTypeWithNameAt: 11
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   101
        andDescriptorAt: 12.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   102
    cp at: 14 putClassRefWithNameAt: 15.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   103
    cp at: 15 put: 'Ljava/lang/Runnable;'.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   104
    cp at: 16 put: 'run'.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   105
    cp at: 17 put: '()V'.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   106
    cp 
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   107
        at: 18
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   108
        putNameAndTypeWithNameAt: 16
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   109
        andDescriptorAt: 17.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   110
    cp at: 19 putClassRefWithNameAt: 15.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   111
    cp 
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   112
        at: 20
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   113
        putInterfaceMethodRefWithClassAt: 19
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   114
        andNameAndTypeAt: 18.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   115
    ^ cp
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   116
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   117
    "Modified: / 13-05-2011 / 09:53:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   118
!
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   119
777
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 774
diff changeset
   120
javaLangObject
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 774
diff changeset
   121
^Java classForName:'java.lang.Object'.
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 774
diff changeset
   122
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 774
diff changeset
   123
    "Created: / 12-05-2011 / 19:09:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
773
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
   124
! !
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
   125
774
ac54730a2b74 cleaning.. removed JavaConstantPoolContent
hlopkmar
parents: 773
diff changeset
   126
!AbstractJavaTestCase methodsFor:'running'!
ac54730a2b74 cleaning.. removed JavaConstantPoolContent
hlopkmar
parents: 773
diff changeset
   127
ac54730a2b74 cleaning.. removed JavaConstantPoolContent
hlopkmar
parents: 773
diff changeset
   128
setUp
ac54730a2b74 cleaning.. removed JavaConstantPoolContent
hlopkmar
parents: 773
diff changeset
   129
    JavaClassReader useNewClassReader.
777
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 774
diff changeset
   130
    self enableMockedExceptionThrowing.
774
ac54730a2b74 cleaning.. removed JavaConstantPoolContent
hlopkmar
parents: 773
diff changeset
   131
ac54730a2b74 cleaning.. removed JavaConstantPoolContent
hlopkmar
parents: 773
diff changeset
   132
    "Created: / 12-05-2011 / 17:30:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
ac54730a2b74 cleaning.. removed JavaConstantPoolContent
hlopkmar
parents: 773
diff changeset
   133
!
ac54730a2b74 cleaning.. removed JavaConstantPoolContent
hlopkmar
parents: 773
diff changeset
   134
ac54730a2b74 cleaning.. removed JavaConstantPoolContent
hlopkmar
parents: 773
diff changeset
   135
tearDown
ac54730a2b74 cleaning.. removed JavaConstantPoolContent
hlopkmar
parents: 773
diff changeset
   136
    JavaClassReader useOldClassReader.
777
e6e61412ae43 refactoring tests.. and more needed
hlopkmar
parents: 774
diff changeset
   137
    self disableMockedExceptionThrowing.
774
ac54730a2b74 cleaning.. removed JavaConstantPoolContent
hlopkmar
parents: 773
diff changeset
   138
ac54730a2b74 cleaning.. removed JavaConstantPoolContent
hlopkmar
parents: 773
diff changeset
   139
    "Created: / 12-05-2011 / 17:30:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
ac54730a2b74 cleaning.. removed JavaConstantPoolContent
hlopkmar
parents: 773
diff changeset
   140
! !
ac54730a2b74 cleaning.. removed JavaConstantPoolContent
hlopkmar
parents: 773
diff changeset
   141
773
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
   142
!AbstractJavaTestCase class methodsFor:'documentation'!
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
   143
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
   144
version_SVN
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
   145
    ^ '$Id$'
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents:
diff changeset
   146
! !