~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/libs/jgdi/test/com/sun/grid/jgdi/util/shell/editor/GEObjectEditorTest.java

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//*___INFO__MARK_BEGIN__*/
 
2
/*************************************************************************
 
3
 *
 
4
 *  The Contents of this file are made available subject to the terms of
 
5
 *  the Sun Industry Standards Source License Version 1.2
 
6
 *
 
7
 *  Sun Microsystems Inc., March, 2001
 
8
 *
 
9
 *
 
10
 *  Sun Industry Standards Source License Version 1.2
 
11
 *  =================================================
 
12
 *  The contents of this file are subject to the Sun Industry Standards
 
13
 *  Source License Version 1.2 (the "License"); You may not use this file
 
14
 *  except in compliance with the License. You may obtain a copy of the
 
15
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 
16
 *
 
17
 *  Software provided under this License is provided on an "AS IS" basis,
 
18
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 
19
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 
20
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 
21
 *  See the License for the specific provisions governing your rights and
 
22
 *  obligations concerning the Software.
 
23
 *
 
24
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
25
 *
 
26
 *   Copyright: 2001 by Sun Microsystems, Inc.
 
27
 *
 
28
 *   All Rights Reserved.
 
29
 *
 
30
 ************************************************************************/
 
31
/*___INFO__MARK_END__*/
 
32
 
 
33
package com.sun.grid.jgdi.util.shell.editor;
 
34
 
 
35
import java.util.Arrays;
 
36
import java.util.Collections;
 
37
import java.util.Comparator;
 
38
import junit.framework.*;
 
39
import com.sun.grid.jgdi.configuration.*;
 
40
import java.util.ArrayList;
 
41
import java.util.HashMap;
 
42
import java.util.Iterator;
 
43
import java.util.List;
 
44
import java.util.Map;
 
45
 
 
46
/**
 
47
 *
 
48
 */
 
49
public class GEObjectEditorTest extends TestCase {
 
50
    private TestGEObject geObj;
 
51
    
 
52
    private static String HGRP_1  = "@hostgroupA";
 
53
    private static String HGRP_2  = "@hostgroupB";
 
54
    
 
55
    
 
56
    //String
 
57
    private String[] passStringOnlyValues =
 
58
    {
 
59
        ",fsd",
 
60
        "aaa,",
 
61
        "aaa,bbb",
 
62
    };
 
63
    
 
64
    private String[] passStringValues =
 
65
    {
 
66
        "val",
 
67
        "val*/.\\nb`3432'",
 
68
        " 12fds",
 
69
        "\"quote\""
 
70
    };
 
71
    private String[] failStringValues =
 
72
    {
 
73
        "value with spaces",    //" " is a separator =>  3 values
 
74
        "\"long quote\""        //" " is a separator =>  2 values
 
75
    };
 
76
    
 
77
    //Long
 
78
    private String[] passLongValues =
 
79
    {
 
80
        "1",
 
81
        "002",
 
82
        " 123",
 
83
        " 004 ",
 
84
        "123456789",
 
85
        String.valueOf(Long.MAX_VALUE),
 
86
        //TODO LP All negative values should probably fail?
 
87
        String.valueOf(Long.MIN_VALUE)
 
88
    };
 
89
    private String[] failLongValues =
 
90
    {
 
91
        "1.2",
 
92
        "1,2",
 
93
        "1 2",
 
94
        ".5",
 
95
        ",005 ",
 
96
        "005,,",
 
97
        "10000000000000000000000000000000.11",
 
98
        "-5.5"
 
99
    };
 
100
    
 
101
    //Double
 
102
    private String[] passDoubleValues =
 
103
    {
 
104
        "1.0",
 
105
        " 004.61656516516516514456564654564564654654654654465654564564 ",
 
106
        "123456789123456789.12345687",
 
107
        ".5",
 
108
        String.valueOf(Double.MAX_VALUE),
 
109
        //TODO LP All negative values should probably fail?
 
110
        String.valueOf(Double.MIN_VALUE)
 
111
    };
 
112
    private String[] failDoubleValues =
 
113
    {
 
114
        "1.2.0",
 
115
        "1,2,0",
 
116
        "1 2",
 
117
        "002,231.52",
 
118
        " 123,2.52",
 
119
        ",005 ",
 
120
        "005,,",
 
121
        ",005.14",
 
122
        "90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.11,123321"
 
123
    };
 
124
    
 
125
    //StringList
 
126
    private static Map passStringListValues;
 
127
    static {
 
128
        passStringListValues = new HashMap();
 
129
        passStringListValues.put("*/.\\ nb`3432'", Arrays.asList(new Object[] {"*/.\\", "nb`3432'"}));
 
130
        passStringListValues.put(" 12 fds", Arrays.asList(new Object[] {"12", "fds"}));
 
131
        passStringListValues.put(" 12 fds", Arrays.asList(new Object[] {"12", "fds"}));
 
132
        passStringListValues.put(",aa aaa", Arrays.asList(new Object[] {"aa", "aaa"}));//TODO LP Or should this be ",aa" "aaa"?
 
133
        passStringListValues.put("aaa,bb b", Arrays.asList(new Object[] {"aaa", "bb", "b"}));
 
134
        passStringListValues.put("\"quote\"", Arrays.asList(new Object[] {"\"quote\""}));
 
135
        passStringListValues.put("value with spaces", Arrays.asList(new Object[] {"value", "with", "spaces"}));
 
136
        passStringListValues.put("\"long quote\"", Arrays.asList(new Object[] {"\"long", "quote\""}));
 
137
        passStringListValues.put("a=b c=d", Arrays.asList(new Object[] {"a=b", "c=d"}));
 
138
        passStringListValues.put("a=b=,c", Arrays.asList(new Object[] {"a=b=", "c"}));
 
139
        passStringListValues.put("a b \n\n", Arrays.asList(new Object[] {"a",  "b"}));
 
140
    };
 
141
    
 
142
    private static Map failStringListValues;
 
143
    static {
 
144
        failStringListValues = new HashMap();
 
145
        failStringListValues.put("a b \n c", "Expected at least 2 tokens name and value got: \"c\"");
 
146
    };
 
147
    
 
148
    //Map
 
149
    private static Map passStringMapValues;
 
150
    static {
 
151
        passStringMapValues = new HashMap();
 
152
        HashMap temp = new HashMap();
 
153
        temp.put("@/", "val");
 
154
        passStringMapValues.put("val", temp);
 
155
        passStringMapValues.put("val ", temp);
 
156
        passStringMapValues.put("[@/=val]", temp);
 
157
        passStringMapValues.put("[@/ = val  ]  ", temp);
 
158
        
 
159
        temp = new HashMap();
 
160
        temp.put("@/", "val");
 
161
        temp.put(HGRP_1, "hval");
 
162
        passStringMapValues.put("val,["+HGRP_1+"=hval]", temp);
 
163
        passStringMapValues.put("val ["+HGRP_1+" = hval]", temp);
 
164
        passStringMapValues.put("[@/ = val] , ["+HGRP_1+" = hval]", temp);
 
165
        passStringMapValues.put("[@/=val] ["+HGRP_1+"= hval]", temp);
 
166
        
 
167
        temp = new HashMap();
 
168
        temp.put("@/", "val");
 
169
        temp.put(HGRP_1, "hval");
 
170
        temp.put(HGRP_2, "hval2");
 
171
        passStringMapValues.put("val,["+HGRP_1+"= hval],["+HGRP_2+"= hval2]", temp);
 
172
        passStringMapValues.put("val ["+HGRP_1+"=hval] ["+HGRP_2+"=hval2]", temp);
 
173
        passStringMapValues.put("val ["+HGRP_1+"=hval],["+HGRP_2+"=hval2]", temp);
 
174
        passStringMapValues.put("val,["+HGRP_1+"=hval] ["+HGRP_2+"=hval2]", temp);
 
175
        passStringMapValues.put("[@/=val],["+HGRP_1+"=hval],["+HGRP_2+"=hval2]", temp);
 
176
        passStringMapValues.put("[@/ =val] ["+HGRP_1+"=hval] ["+HGRP_2+" = hval2]", temp);
 
177
        passStringMapValues.put("[@/= val] ["+HGRP_1+" = hval],["+HGRP_2+"=hval2]", temp);
 
178
        passStringMapValues.put("[@/ = val],["+HGRP_1+"=hval] ["+HGRP_2+"=hval2]", temp);
 
179
    };
 
180
    
 
181
    private static Map failStringMapValues;
 
182
    static {
 
183
        failStringMapValues = new HashMap();
 
184
        failStringMapValues.put("val val2", "Expected [key=val] elements got: [@/=val val2]");
 
185
        failStringMapValues.put("val,val2", "Expected [key=val] elements got: [@/=val val2]");
 
186
        failStringMapValues.put("val = val2", "Expected [key=val] elements got: [@/=val = val2]");
 
187
        failStringMapValues.put("[@/=val val2]", "Expected [key=val] elements got: [@/=val val2]");
 
188
        failStringMapValues.put("[@/=val,val2  ]  ", "Expected [key=val] elements got: [@/=val val2]");
 
189
        failStringMapValues.put("[@/=val = val2  ]  ", "Expected [key=val] elements got: [@/=val = val2]");
 
190
        
 
191
        failStringMapValues.put("val,["+HGRP_1+"=hval=cont]", "Expected [key=val] elements got: ["+HGRP_1+"=hval=cont]");
 
192
        failStringMapValues.put("val=cont ["+HGRP_1+"=hval]", "Expected [key=val] elements got: [@/=val=cont]");
 
193
        failStringMapValues.put("[@/=val],["+HGRP_1+"=hval=cont]", "Expected [key=val] elements got: ["+HGRP_1+"=hval=cont]");
 
194
        failStringMapValues.put("[@/=val=cont] ["+HGRP_1+" hval]", "Expected [key=val] elements got: [@/=val=cont]");
 
195
    };
 
196
    
 
197
    //MapList
 
198
    private static Map passStringMapListValues;
 
199
    static {
 
200
        passStringMapListValues = new HashMap();
 
201
        HashMap keyMap = new HashMap();
 
202
        HashMap valueMap = new HashMap();
 
203
        valueMap.put("key1", "val1");
 
204
        valueMap.put("key2", "val2");
 
205
        valueMap.put("key3", "val3");
 
206
        keyMap.put("@/", valueMap);
 
207
        passStringMapListValues.put("key1=val1 key2=val2 key3=val3", keyMap);
 
208
        passStringMapListValues.put("key1=val1,key2=val2,key3=val3", keyMap);
 
209
        passStringMapListValues.put("key1=val1 , key2=val2 ,key3=val3", keyMap);
 
210
        passStringMapListValues.put("key1=val1   key2=val2  ,  key3=val3", keyMap);
 
211
        passStringMapListValues.put("key1=val1 ,,,, key2=val2 key3=val3", keyMap);
 
212
        passStringMapListValues.put("[@/=key1=val1 key2=val2 key3=val3]", keyMap);
 
213
        passStringMapListValues.put(" [ @/ = key1=val1, key2=val2 key3=val3 ]", keyMap);
 
214
        passStringMapListValues.put("[@/ =key1=val1,  key2=val2 , key3=val3\t]", keyMap);
 
215
        passStringMapListValues.put("[\t@/\t=\tkey1=val1   key2=val2  ,  key3=val3\t]", keyMap);
 
216
        passStringMapListValues.put("[@/=key1=val1 ,,,,  key2=val2 , key3=val3]", keyMap);
 
217
    };
 
218
     /*          "key=val1 val2 val3,["+HGRP_1+"=key=hval1 hval2 hval3]",
 
219
               "key=val1,val2,val3,["+HGRP_1+"=key=hval1,hval2 hval3]",
 
220
               "key=val1 val2,val3,["+HGRP_1+"=key=hval1 hval2,hval3]",
 
221
               "key=val1 , val2, val3,["+HGRP_1+"=key=hval1 , hval2, hval3]",
 
222
               "key=val1 , val2, ,, , val3,["+HGRP_1+"=key=hval1 , hval2,  ,, , ,hval3]",
 
223
               "key=val1 , val2, val3 ["+HGRP_1+"=key=hval1 , hval2, hval3]",
 
224
      
 
225
               "[@/=key=val1 val2 val3]",
 
226
               "[@/=key=val1,val2,val3]",
 
227
               "[@/=key=val1 val2,val3]",
 
228
               "[@/=key=val1 , val2, val3]",
 
229
      
 
230
               "[@/=key=val1 val2 val3],["+HGRP_1+"=key=hval1 hval2 hval3]",
 
231
               "[@/=key=val1,val2,val3],["+HGRP_1+"=key=hval1,hval2 hval3]",
 
232
               "[@/=key=val1 val2,val3],["+HGRP_1+"=key=hval1 hval2,hval3]",
 
233
               "[@/=key=val1 , val2, val3],["+HGRP_1+"=key=hval1 , hval2, hval3]",
 
234
               "[@/=key=val1 , val2, val3,],,[,"+HGRP_1+"=key=hval1, ,, hval2, hval3],",
 
235
               "[@/=key=val1 , val2, val3] ["+HGRP_1+"=key=hval1 , hval2, hval3]",
 
236
            };*/
 
237
    private static Map failStringMapListValues;
 
238
    static {
 
239
        failStringMapListValues = new HashMap();
 
240
        //failStringMapListValues.put("key val1 val2 val3",""); //Should this really fail
 
241
        failStringMapListValues.put("key=val1,val2,val3=val4", "Expected all elements to be of a same kind. First elements were a Map current element \"val2\" is not.");
 
242
        failStringMapListValues.put("key=val1,val2,val3=val4", "Expected all elements to be of a same kind. First elements were a Map current element \"val2\" is not.");
 
243
        failStringMapListValues.put("key=val1 val2[,val3,", "Expected all elements to be of a same kind. First elements were a Map current element \"val2\" is not.");
 
244
        failStringMapListValues.put("key=val1 , [val2], val3", "Expected [key=val1 val2] elements got: [val2]");
 
245
        failStringMapListValues.put("key=val1 , [val2, val3]", "Expected [key=val1 val2] elements got: [val2 val3]");
 
246
    };
 
247
    
 
248
      /*         "key=val1=val2 val3,["+HGRP_1+"=key=hval1 hval2= hval3]",
 
249
               "key=val1,val2,val3,["+HGRP_1+"=key=hval1,hval2 hval3]",
 
250
               "key=val1 [val2,val3],["+HGRP_1+"=key=hval1 hval2,hval3]",
 
251
               "key=val1 , val2, val3,[["+HGRP_1+"=key=hval1 , hval2, hval3]]",
 
252
               "key=val1 , val2, val3 ["+HGRP_1+"=key=hval1 , [hval2=hval3]]",
 
253
       
 
254
               "[@/=key=val1 val2=val3]",
 
255
       
 
256
               "[@/=key=val1 val2 val3],["+HGRP_1+"=key=hval1 [hval2 hval3]]",
 
257
               "[@/=key=val1,val2,val3],["+HGRP_1+"=key=hval1,[hval2=hval3]]",
 
258
               "[@/=key=val1 val2,val3],["+HGRP_1+"=key=hval1 hval2,hval3]",
 
259
               "[[@/=key=val1 , val2, val3],["+HGRP_1+"=key=hval1 , hval2, hval3]]",
 
260
               "[[@/=key=val1 , val2, val3] ["+HGRP_1+"=key=hval1 , hval2, hval3]",
 
261
            };*/
 
262
    
 
263
    
 
264
    public GEObjectEditorTest(String testName) {
 
265
        super(testName);
 
266
    }
 
267
    
 
268
    protected synchronized void setUp() throws Exception {
 
269
        geObj = new TestGEObject();
 
270
        Util.addDescriptor(geObj.getClass(), new TestGEObjectDescriptor());
 
271
    }
 
272
    
 
273
    protected void tearDown() throws Exception {
 
274
        geObj = null;
 
275
    }
 
276
    
 
277
    
 
278
    private void updateSimpleValue(String testName, String[] values, String propertyName, boolean shouldFail) {
 
279
        for (int i=0; i< values.length; i++) {
 
280
            String str = values[i];
 
281
            System.out.print(testName+"(\""+str+"\")");
 
282
            try {
 
283
                GEObjectEditor.updateObjectWithText(geObj,propertyName+" "+str);
 
284
                if (shouldFail) {
 
285
                    System.out.println(" - FAILED");
 
286
                    fail("Expecting failure for "+testName+"(\""+str+"\"), but test passed.");
 
287
                }
 
288
                simpleAssert(propertyName, str, geObj);
 
289
                System.out.println(" - OK");
 
290
            } catch (Exception ex) {
 
291
                if (!shouldFail) {
 
292
                    System.out.println(" - FAILED");
 
293
                    fail("Got unexpected exception "+ex.getMessage());
 
294
                }
 
295
                System.out.println(" - OK "+ex.getMessage());
 
296
            }
 
297
        }
 
298
    }
 
299
    
 
300
    private void simpleAssert(String propertyName, String str, TestGEObject geObj) {
 
301
        if (propertyName.equals("name")) {
 
302
            assertEquals("Setting value \""+str+"\" failed.", str.trim(), geObj.getName());
 
303
        } else if (propertyName.equals("long")) {
 
304
            assertEquals("Setting value \""+str+"\" failed.", Long.parseLong(str.trim()), geObj.getLong());
 
305
        } else if (propertyName.equals("double")) {
 
306
            assertEquals("Setting value \""+str+"\" failed.", Double.parseDouble(str.trim()), geObj.getDouble(),0);
 
307
        } else if (propertyName.equals("string_list")) {
 
308
            assertEquals("Setting value \""+str+"\" failed.", 1, geObj.getStringList().size());
 
309
            assertEquals("Setting value \""+str+"\" failed.", str.trim(), (String)geObj.getStringList().get(0));
 
310
        } else if (propertyName.equals("string_map")) {
 
311
            assertEquals(1, geObj.getStringMapKeys().size());
 
312
            assertEquals("Setting value \""+str+"\" failed.", str.trim(), geObj.getStringMap("@/"));
 
313
        } else if (propertyName.equals("string_map_list")) {
 
314
            assertEquals(1, geObj.getStringMapListKeys().size());
 
315
            assertEquals(1, geObj.getStringMapListList("@/").size());
 
316
            assertEquals("Setting value \""+str+"\" failed.", str.trim(), (String)geObj.getStringMapListList("@/").get(0));
 
317
        } else {
 
318
            throw new IllegalArgumentException("simpleAssert: Unknown attribute \""+propertyName+"\"");
 
319
        }
 
320
    }
 
321
    
 
322
    //STRING
 
323
    public void testPassString() {
 
324
        updateSimpleValue("testPassString", passStringOnlyValues, "name", false);
 
325
        updateSimpleValue("testPassString", passStringValues, "name", false);
 
326
    }
 
327
    
 
328
    public void testPassStringWithLongValues() {
 
329
        updateSimpleValue("testPassStringWithLongValues", passLongValues, "name", false);
 
330
    }
 
331
    
 
332
    public void testPassStringWithDoubleValues() {
 
333
        updateSimpleValue("testPassStringWithDoubleValues", passDoubleValues, "name", false);
 
334
    }
 
335
    
 
336
    public void testFailString() {
 
337
        for (int i=0; i< failStringValues.length; i++) {
 
338
            String str = failStringValues[i];
 
339
            System.out.print("testFailString(\""+str+"\") - ");
 
340
            try {
 
341
                GEObjectEditor.updateObjectWithText(geObj,"name "+str);
 
342
                System.out.println("FAILED");
 
343
                fail("Setting value \""+str+"\" should have failed.");
 
344
            } catch (IllegalArgumentException ex) {
 
345
                System.out.println("OK "+ex.getMessage());
 
346
            }
 
347
        }
 
348
    }
 
349
    
 
350
    
 
351
    //LONG
 
352
    public void testPassLong() {
 
353
        updateSimpleValue("testPassLong", passLongValues, "long", false);
 
354
    }
 
355
    
 
356
    public void testFailLongWithDouble() {
 
357
        updateSimpleValue("testFailLongWithDouble", passDoubleValues, "long", true);
 
358
    }
 
359
    
 
360
    public void testFailLongWithString() {
 
361
        updateSimpleValue("testFailLongWithString", passStringValues, "long", true);
 
362
    }
 
363
    
 
364
    public void testFailLong() {
 
365
        for (int i=0; i< failLongValues.length; i++) {
 
366
            String str = failLongValues[i];
 
367
            System.out.print("testFailLong(\""+str+"\") - ");
 
368
            try {
 
369
                GEObjectEditor.updateObjectWithText(geObj,"long "+str);
 
370
                System.out.println("FAILED");
 
371
                fail("Setting value \""+str+"\" should have failed.");
 
372
            } catch (IllegalArgumentException ex) {
 
373
                System.out.println("OK got: "+ex.getMessage());
 
374
            }
 
375
        }
 
376
    }
 
377
    
 
378
    
 
379
    //DOUBLE
 
380
    public void testPassDouble() {
 
381
        updateSimpleValue("testPassDouble", passDoubleValues, "double", false);
 
382
    }
 
383
    
 
384
    public void testPassDoubleWithLong() {
 
385
        updateSimpleValue("testPassDoubleWithLong", passLongValues, "double", false);
 
386
    }
 
387
    
 
388
    public void testFailDoubleWithString() {
 
389
        updateSimpleValue("testPassDoubleWithLong", passStringValues, "double", true);
 
390
    }
 
391
    
 
392
    public void testFailDouble() {
 
393
        for (int i=0; i< failDoubleValues.length; i++) {
 
394
            String str = failDoubleValues[i];
 
395
            System.out.print("testFailDouble(\""+str+"\") - ");
 
396
            try {
 
397
                GEObjectEditor.updateObjectWithText(geObj,"double "+str);
 
398
                System.out.println("FAILED");
 
399
                fail("Setting value \""+str+"\" should have failed.");
 
400
            } catch (IllegalArgumentException ex) {
 
401
                System.out.println("OK got: "+ex.getMessage());
 
402
            }
 
403
        }
 
404
    }
 
405
    
 
406
    //STRING_LIST
 
407
    public void testPassStringList() {
 
408
        for (Iterator iter = passStringListValues.keySet().iterator(); iter.hasNext();) {
 
409
            String str = (String)iter.next();
 
410
            System.out.println("testPassStringList(\""+str+"\")");
 
411
            GEObjectEditor.updateObjectWithText(geObj,"string_list "+str);
 
412
            assertEquals("Setting value \""+str+"\" failed.", (List)passStringListValues.get(str), geObj.getStringList());
 
413
        }
 
414
    }
 
415
    
 
416
    public void testPassStringListWithLong() {
 
417
        updateSimpleValue("testPassStringListWithLong", passLongValues, "string_list", false);
 
418
    }
 
419
    
 
420
    public void testPassStringListWithDouble() {
 
421
        updateSimpleValue("testPassStringListWithDouble", passDoubleValues, "string_list", false);
 
422
    }
 
423
    
 
424
    public void testPassStringListWithString() {
 
425
        updateSimpleValue("testPassStringListWithString", passStringValues, "string_list", false);
 
426
    }
 
427
    
 
428
    public void testFailStringList() {
 
429
        for (Iterator iter = failStringListValues.keySet().iterator(); iter.hasNext();) {
 
430
            String str = (String)iter.next();
 
431
            System.out.print("testFailStringList(\""+str+"\") - ");
 
432
            try {
 
433
                GEObjectEditor.updateObjectWithText(geObj,"string_list "+str);
 
434
                System.out.println("FAILED");
 
435
                fail("Setting value \""+str+"\" should have failed.");
 
436
            } catch (IllegalArgumentException ex) {
 
437
                String msg = ex.getMessage();
 
438
                String exp = (String)failStringListValues.get(str);
 
439
                if (msg.equals(exp)) {
 
440
                    System.out.println("OK got: "+msg);
 
441
                } else {
 
442
                    System.out.println("FAILED");
 
443
                    fail("Expected exception with \""+exp+"\" text got: \""+msg+"\"");
 
444
                }
 
445
            }
 
446
        }
 
447
    }
 
448
    
 
449
    //STRING_MAP
 
450
    public void testPassStringMap() {
 
451
        for (Iterator iter = passStringMapValues.keySet().iterator(); iter.hasNext();) {
 
452
            String str = (String)iter.next();
 
453
            System.out.println("testPassStringMap(\""+str+"\")");
 
454
            GEObjectEditor.updateObjectWithText(geObj,"string_map "+str);
 
455
            Map valMap = (HashMap)passStringMapValues.get(str);
 
456
            assertEquals(valMap.keySet().size(), geObj.getStringMapKeys().size());
 
457
            for (Iterator iter2 = valMap.keySet().iterator(); iter2.hasNext();) {
 
458
                String key = (String)iter2.next();
 
459
                assertEquals("Setting value \""+str+"\" failed.", valMap.get(key), geObj.getStringMap(key));
 
460
            }
 
461
        }
 
462
    }
 
463
    
 
464
    public void testPassStringMapWithLong() {
 
465
        updateSimpleValue("testPassStringMapWithLong", passLongValues, "string_map", false);
 
466
    }
 
467
    
 
468
    public void testPassStringMapWithDouble() {
 
469
        updateSimpleValue("testPassStringMapWithDouble", passDoubleValues, "string_map", false);
 
470
    }
 
471
    
 
472
    public void testPassStringMapWithString() {
 
473
        updateSimpleValue("testPassStringMapWithString", passStringValues, "string_map", false);
 
474
    }
 
475
    
 
476
    public void testFailStringMap() {
 
477
        for (Iterator iter = failStringMapValues.keySet().iterator(); iter.hasNext();) {
 
478
            String str = (String)iter.next();
 
479
            System.out.print("testFailStringMap(\""+str+"\") - ");
 
480
            try {
 
481
                GEObjectEditor.updateObjectWithText(geObj,"string_map "+str);
 
482
                System.out.println("FAILED");
 
483
                fail("Setting value \""+str+"\" should have failed.");
 
484
            } catch (IllegalArgumentException ex) {
 
485
                String msg = ex.getMessage();
 
486
                String exp = (String)failStringMapValues.get(str);
 
487
                if (msg.equals(exp)) {
 
488
                    System.out.println("OK got: "+msg);
 
489
                } else {
 
490
                    System.out.println("FAILED");
 
491
                    fail("Expected exception with \""+exp+"\" text got: \""+msg+"\"");
 
492
                }
 
493
            }
 
494
        }
 
495
    }
 
496
    
 
497
    //STRING_MAP_LIST
 
498
    public void testPassStringMapList() {
 
499
        for (Iterator iter = passStringMapListValues.keySet().iterator(); iter.hasNext();) {
 
500
            String str = (String)iter.next();
 
501
            System.out.print("testPassStringMap(\""+str+"\")");
 
502
            GEObjectEditor.updateObjectWithText(geObj,"string_map_list "+str);
 
503
            Map valMap = (HashMap)passStringMapListValues.get(str);
 
504
            assertEquals(valMap.keySet().size(), geObj.getStringMapListKeys().size());
 
505
            for (Iterator iter2 = valMap.keySet().iterator(); iter2.hasNext();) {
 
506
                String key = (String)iter2.next();
 
507
                List list = new ArrayList();
 
508
                Map m = (HashMap)valMap.get(key);
 
509
                for (Iterator iter3 = m.keySet().iterator(); iter3.hasNext();) {
 
510
                    String k = (String)iter3.next();
 
511
                    list.add(k+"="+m.get(k));
 
512
                }
 
513
                Collections.sort(list, new Comparator() {
 
514
                    public int compare(Object o1, Object o2) {
 
515
                        if (o1 == null && o2 == null) {
 
516
                            return 0;
 
517
                        }
 
518
                        if (o1 ==null) {
 
519
                            return -1;
 
520
                        }
 
521
                        if (o2 == null) {
 
522
                            return 1;
 
523
                        }
 
524
                        return ((String)o1).compareTo((String)o2);
 
525
                    }
 
526
                });
 
527
                assertEquals("Setting value \""+str+"\" failed.", list, geObj.getStringMapListList(key));
 
528
            }
 
529
        }
 
530
    }
 
531
    
 
532
    public void testPassStringMapListWithLong() {
 
533
        updateSimpleValue("testFailStringMapListWithLong", passLongValues, "string_map_list", false);
 
534
    }
 
535
    
 
536
    public void testPassStringMapListWithDouble() {
 
537
        updateSimpleValue("testFailStringMapListWithDouble", passDoubleValues, "string_map_list", false);
 
538
    }
 
539
    
 
540
    public void testPassStringMapListWithString() {
 
541
        updateSimpleValue("testFailStringMapListWithString", passStringValues, "string_map_list", false);
 
542
    }
 
543
    
 
544
    public void testFailStringMapList() {
 
545
        for (Iterator iter = failStringMapListValues.keySet().iterator(); iter.hasNext();) {
 
546
            String str = (String)iter.next();
 
547
            System.out.print("testFailStringMapList(\""+str+"\") - ");
 
548
            try {
 
549
                GEObjectEditor.updateObjectWithText(geObj,"string_map_list "+str);
 
550
                System.out.println("FAILED");
 
551
                fail("Setting value \""+str+"\" should have failed.");
 
552
            } catch (IllegalArgumentException ex) {
 
553
                String msg = ex.getMessage();
 
554
                String exp = (String)failStringMapListValues.get(str);
 
555
                if (msg.equals(exp)) {
 
556
                    System.out.println("OK got: "+msg);
 
557
                } else {
 
558
                    System.out.println("FAILED");
 
559
                    fail("Expected exception with \""+exp+"\" text got: \""+msg+"\"");
 
560
                }
 
561
            }
 
562
        }
 
563
    }
 
564
}