1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.jdtaus.core.lang.spi.it;
22
23 import junit.framework.Assert;
24 import org.jdtaus.core.lang.it.RuntimeTest;
25 import org.jdtaus.core.lang.spi.MemoryManager;
26
27
28
29
30
31
32
33 public class MemoryManagerTest extends RuntimeTest
34 {
35
36
37
38 private MemoryManager manager;
39
40
41
42
43
44
45
46 public MemoryManager getMemoryManager()
47 {
48 return this.manager;
49 }
50
51
52
53
54
55
56
57 public final void setMemoryManager( final MemoryManager value )
58 {
59 this.manager = value;
60 this.setRuntime( value );
61 }
62
63
64
65
66
67
68
69
70 public void testIllegalArguments() throws Exception
71 {
72 assert this.getMemoryManager() != null;
73
74 try
75 {
76 this.getMemoryManager().allocateBoolean( Integer.MIN_VALUE );
77 throw new AssertionError();
78 }
79 catch ( IllegalArgumentException e )
80 {
81 Assert.assertNotNull( e.getMessage() );
82 System.out.println( e.toString() );
83 }
84
85 try
86 {
87 this.getMemoryManager().allocateBytes( Integer.MIN_VALUE );
88 throw new AssertionError();
89 }
90 catch ( IllegalArgumentException e )
91 {
92 Assert.assertNotNull( e.getMessage() );
93 System.out.println( e.toString() );
94 }
95
96 try
97 {
98 this.getMemoryManager().allocateChars( Integer.MIN_VALUE );
99 throw new AssertionError();
100 }
101 catch ( IllegalArgumentException e )
102 {
103 Assert.assertNotNull( e.getMessage() );
104 System.out.println( e.toString() );
105 }
106
107 try
108 {
109 this.getMemoryManager().allocateDoubles( Integer.MIN_VALUE );
110 throw new AssertionError();
111 }
112 catch ( IllegalArgumentException e )
113 {
114 Assert.assertNotNull( e.getMessage() );
115 System.out.println( e.toString() );
116 }
117
118 try
119 {
120 this.getMemoryManager().allocateFloats( Integer.MIN_VALUE );
121 throw new AssertionError();
122 }
123 catch ( IllegalArgumentException e )
124 {
125 Assert.assertNotNull( e.getMessage() );
126 System.out.println( e.toString() );
127 }
128
129 try
130 {
131 this.getMemoryManager().allocateIntegers( Integer.MIN_VALUE );
132 throw new AssertionError();
133 }
134 catch ( IllegalArgumentException e )
135 {
136 Assert.assertNotNull( e.getMessage() );
137 System.out.println( e.toString() );
138 }
139
140 try
141 {
142 this.getMemoryManager().allocateLongs( Integer.MIN_VALUE );
143 throw new AssertionError();
144 }
145 catch ( IllegalArgumentException e )
146 {
147 Assert.assertNotNull( e.getMessage() );
148 System.out.println( e.toString() );
149 }
150
151 try
152 {
153 this.getMemoryManager().allocateShorts( Integer.MIN_VALUE );
154 throw new AssertionError();
155 }
156 catch ( IllegalArgumentException e )
157 {
158 Assert.assertNotNull( e.getMessage() );
159 System.out.println( e.toString() );
160 }
161
162 }
163
164
165 }