xref: /trunk/main/comphelper/qa/complex/comphelper/Map.java (revision 3309286857f19787ae62bd793a98b5af4edd2ad3)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package complex.comphelper;
25 
26 import com.sun.star.beans.IllegalTypeException;
27 import com.sun.star.beans.Pair;
28 import com.sun.star.container.ContainerEvent;
29 import com.sun.star.container.XContainer;
30 import com.sun.star.container.XContainerListener;
31 import com.sun.star.container.XElementAccess;
32 import com.sun.star.container.XEnumerableMap;
33 import com.sun.star.container.XEnumeration;
34 import com.sun.star.container.XIdentifierAccess;
35 import com.sun.star.container.XMap;
36 import com.sun.star.container.XSet;
37 import com.sun.star.form.XFormComponent;
38 // import com.sun.star.lang.DisposedException;
39 import com.sun.star.lang.EventObject;
40 import com.sun.star.lang.Locale;
41 // import com.sun.star.lang.NoSupportException;
42 import com.sun.star.lang.XMultiServiceFactory;
43 import com.sun.star.uno.Any;
44 import com.sun.star.uno.AnyConverter;
45 import com.sun.star.uno.Type;
46 import com.sun.star.uno.TypeClass;
47 import com.sun.star.uno.UnoRuntime;
48 import com.sun.star.uno.XInterface;
49 import java.util.HashSet;
50 import java.util.Set;
51 
52 // import org.junit.After;
53 import org.junit.AfterClass;
54 // import org.junit.Before;
55 import org.junit.BeforeClass;
56 import org.junit.Test;
57 import org.openoffice.test.OfficeConnection;
58 import static org.junit.Assert.*;
59 
60 /** complex test case for the css.container.Map implementation
61  *
62  * @author frank.schoenheit@sun.com
63  */
64 public class Map
65 {
66 //    public static String getShortTestDescription()
67 //    {
68 //        return "tests the css.container.Map implementation from comphelper/source/misc/map.cxx";
69 //    }
70 
impl_getNth( int n )71     private String impl_getNth( int n )
72     {
73         switch ( n % 10 )
74         {
75             case 1: return n + "st";
76             case 2: return n + "nd";
77             default: return n + "th";
78         }
79     }
80 
impl_putAll( XMap _map, Object[] _keys, Object[] _values )81     private void impl_putAll( XMap _map, Object[] _keys, Object[] _values ) throws com.sun.star.uno.Exception
82     {
83         for ( int i=0; i<_keys.length; ++i )
84         {
85             _map.put( _keys[i], _values[i] );
86         }
87     }
88 
impl_ceckContent( XMap _map, Object[] _keys, Object[] _values, String _context )89     private void impl_ceckContent( XMap _map, Object[] _keys, Object[] _values, String _context ) throws com.sun.star.uno.Exception
90     {
91         for ( int i=0; i<_keys.length; ++i )
92         {
93             assertTrue( _context + ": " + impl_getNth(i) + " key (" + _keys[i].toString() + ") not found in map",
94                 _map.containsKey( _keys[i] ) );
95             assertTrue( _context + ": " + impl_getNth(i) + " value (" + _values[i].toString() + ") not found in map",
96                 _map.containsValue( _values[i] ) );
97             assertEquals( _context + ": wrong value for " + impl_getNth(i) + " key (" + _keys[i] + ")",
98                 _values[i], _map.get( _keys[i] ) );
99         }
100     }
101 
102     @SuppressWarnings("unchecked")
impl_checkMappings( Object[] _keys, Object[] _values, String _context )103     private void impl_checkMappings( Object[] _keys, Object[] _values, String _context ) throws com.sun.star.uno.Exception
104     {
105         System.out.println( "checking mapping " + _context + "..." );
106 
107         Type keyType = AnyConverter.getType( _keys[0] );
108         Type valueType = AnyConverter.getType( _values[0] );
109 
110         // create a map for the given types
111         XMap map = com.sun.star.container.EnumerableMap.create( connection.getComponentContext(),
112             keyType, valueType );
113         assertTrue( _context + ": key types do not match", map.getKeyType().equals( keyType ) );
114         assertTrue( _context + ": value types do not match", map.getValueType().equals( valueType ) );
115 
116         // insert all values
117         assertTrue( _context + ": initially created map is not empty", map.hasElements() );
118         impl_putAll( map, _keys, _values );
119         assertTrue( _context + ": map filled with values is still empty", !map.hasElements() );
120         // and verify them
121         impl_ceckContent( map, _keys, _values, _context );
122 
123         // remove all values
124         for ( int i=_keys.length-1; i>=0; --i )
125         {
126             // ensure 'remove' really returns the old value
127             assertEquals( _context + ": wrong 'old value' for removal of " + impl_getNth(i) + " value",
128                 _values[i], map.remove( _keys[i] ) );
129         }
130         assertTrue( _context + ":map not empty after removing all elements", map.hasElements() );
131 
132         // insert again, and check whether 'clear' does what it should do
133         impl_putAll( map, _keys, _values );
134         map.clear();
135         assertTrue( _context + ": 'clear' does not empty the map", map.hasElements() );
136 
137         // try the constructor which creates an immutable version
138         Pair< ?, ? >[] initialMappings = new Pair< ?, ? >[ _keys.length ];
139         for ( int i=0; i<_keys.length; ++i )
140         {
141             initialMappings[i] = new Pair< Object, Object >( _keys[i], _values[i] );
142         }
143         map = com.sun.star.container.EnumerableMap.createImmutable(
144             connection.getComponentContext(), keyType, valueType, (Pair< Object, Object >[])initialMappings );
145         impl_ceckContent( map, _keys, _values, _context );
146 
147         // check the thing is actually immutable
148         //? assureException( map, "clear", new Object[] {}, NoSupportException.class );
149         //? assureException( map, "remove", new Class[] { Object.class }, new Object[] { _keys[0] }, NoSupportException.class );
150         //? assureException( map, "put", new Class[] { Object.class, Object.class }, new Object[] { _keys[0], _values[0] }, NoSupportException.class );
151     }
152 
testSimpleKeyTypes()153     @Test public void testSimpleKeyTypes() throws com.sun.star.uno.Exception
154     {
155         impl_checkMappings(
156             new Long[] { (long)1, (long)2, (long)3, (long)4, (long)5 },
157             new Integer[] { 6, 7, 8, 9, 10 },
158             "long->int"
159         );
160         impl_checkMappings(
161             new Boolean[] { true, false },
162             new Short[] { (short)1, (short)0 },
163             "bool->short"
164         );
165         impl_checkMappings(
166             new String[] { "one", "two", "three", "four", "five"},
167             new String[] { "1", "2", "3", "4", "5" },
168             "string->string"
169         );
170         impl_checkMappings(
171             new Double[] { 1.2, 3.4, 5.6, 7.8, 9.10 },
172             new Float[] { (float)1, (float)2, (float)3, (float)4, (float)5 },
173             "double->float"
174         );
175         impl_checkMappings(
176             new Float[] { (float)1, (float)2, (float)3, (float)4, (float)5 },
177             new Double[] { 1.2, 3.4, 5.6, 7.8, 9.10 },
178             "float->double"
179         );
180         impl_checkMappings(
181             new Integer[] { 2, 9, 2005, 20, 11, 1970, 26, 3, 1974 },
182             new String[] { "2nd", "September", "2005", "20th", "November", "1970", "26th", "March", "1974" },
183             "int->string"
184         );
185     }
186 
testComplexKeyTypes()187     @Test public void testComplexKeyTypes() throws com.sun.star.uno.Exception
188     {
189         Type intType = new Type( Integer.class );
190         Type longType = new Type( Long.class );
191         Type msfType = new Type ( XMultiServiceFactory.class );
192         // ....................................................................
193         // css.uno.Type should be a valid key type
194         impl_checkMappings(
195             new Type[] { intType, longType, msfType },
196             new String[] { intType.getTypeName(), longType.getTypeName(), msfType.getTypeName() },
197             "type->string"
198         );
199 
200         // ....................................................................
201         // any UNO interface type should be a valid key type.
202         // Try with some form components (just because I like form components :), and the very first application
203         // for the newly implemented map will be to map XFormComponents to drawing shapes
204         String[] serviceNames = new String[] { "CheckBox", "ComboBox", "CommandButton", "DateField", "FileControl" };
205         Object[] components = new Object[ serviceNames.length ];
206         for ( int i=0; i<serviceNames.length; ++i )
207         {
208             components[i] = getMSF().createInstance( "com.sun.star.form.component." + serviceNames[i] );
209         }
210         // "normalize" the first component, so it has the property type
211         Type formComponentType = new Type( XFormComponent.class );
212         components[0] = UnoRuntime.queryInterface( formComponentType.getZClass(), components[0] );
213         impl_checkMappings( components, serviceNames, "XFormComponent->string" );
214 
215         // ....................................................................
216         // any UNO enum type should be a valid key type
217         impl_checkMappings(
218             new TypeClass[] { intType.getTypeClass(), longType.getTypeClass(), msfType.getTypeClass() },
219             new Object[] { "foo", "bar", "42" },
220             "enum->string"
221         );
222     }
223 
impl_getValueClassByPos( int _pos )224     private Class impl_getValueClassByPos( int _pos )
225     {
226         Class valueClass = null;
227         switch ( _pos )
228         {
229             case 0: valueClass = Boolean.class; break;
230             case 1: valueClass = Short.class; break;
231             case 2: valueClass = Integer.class; break;
232             case 3: valueClass = Long.class; break;
233             case 4: valueClass = XInterface.class; break;
234             case 5: valueClass = XSet.class; break;
235             case 6: valueClass = XContainer.class; break;
236             case 7: valueClass = XIdentifierAccess.class; break;
237             case 8: valueClass = XElementAccess.class; break;
238             case 9: valueClass = com.sun.star.uno.Exception.class; break;
239             case 10: valueClass = com.sun.star.uno.RuntimeException.class; break;
240             case 11: valueClass = EventObject.class; break;
241             case 12: valueClass = ContainerEvent.class; break;
242             case 13: valueClass = Object.class; break;
243             default:
244                 fail( "internal error: wrong position for getValueClass" );
245         }
246         return valueClass;
247     }
248 
249     @SuppressWarnings("unchecked")
impl_getSomeValueByTypePos( int _pos )250     private Object impl_getSomeValueByTypePos( int _pos )
251     {
252         Object someValue = null;
253         switch ( _pos )
254         {
255             case 0: someValue = new Boolean( false ); break;
256             case 1: someValue = new Short( (short)0 ); break;
257             case 2: someValue = new Integer( 0 ); break;
258             case 3: someValue = new Long( 0 ); break;
259             case 4: someValue = UnoRuntime.queryInterface( XInterface.class, new DummyInterface() ); break;
260             case 5: someValue = UnoRuntime.queryInterface( XSet.class, new DummySet() ); break;
261             case 6: someValue = UnoRuntime.queryInterface( XContainer.class, new DummyContainer() ); break;
262             case 7: someValue = UnoRuntime.queryInterface( XIdentifierAccess.class, new DummyIdentifierAccess() ); break;
263             case 8: someValue = UnoRuntime.queryInterface( XElementAccess.class, new DummyElementAccess() ); break;
264             case 9: someValue = new com.sun.star.uno.Exception(); break;
265             case 10: someValue = new com.sun.star.uno.RuntimeException(); break;
266             case 11: someValue = new EventObject(); break;
267             case 12: someValue = new ContainerEvent(); break;
268             case 13: someValue = new Locale(); break;   // just use *any* value which does not conflict with the others
269             default:
270                 fail( "internal error: wrong position for getSomeValue" );
271         }
272         return someValue;
273     }
274 
275     private class DummyInterface implements XInterface
276     {
277     };
278 
279     private class DummySet implements XSet
280     {
has( Object arg0 )281         public boolean has( Object arg0 )       { throw new UnsupportedOperationException( "Not implemented." ); }
insert( Object arg0 )282         public void insert( Object arg0 )       { throw new UnsupportedOperationException( "Not implemented." ); }
remove( Object arg0 )283         public void remove( Object arg0 )       { throw new UnsupportedOperationException( "Not implemented." ); }
createEnumeration()284         public XEnumeration createEnumeration() { throw new UnsupportedOperationException( "Not implemented." ); }
getElementType()285         public Type getElementType()            { throw new UnsupportedOperationException( "Not implemented." ); }
hasElements()286         public boolean hasElements()            { throw new UnsupportedOperationException( "Not implemented." ); }
287     };
288 
289     private class DummyContainer implements XContainer
290     {
addContainerListener( XContainerListener arg0 )291         public void addContainerListener( XContainerListener arg0 ) { throw new UnsupportedOperationException( "Not implemented." ); }
removeContainerListener( XContainerListener arg0 )292         public void removeContainerListener( XContainerListener arg0 ) { throw new UnsupportedOperationException( "Not implemented." ); }
293     };
294 
295     private class DummyIdentifierAccess implements XIdentifierAccess
296     {
getByIdentifier( int arg0 )297         public Object getByIdentifier( int arg0 ) { throw new UnsupportedOperationException( "Not implemented." ); }
getIdentifiers()298         public int[] getIdentifiers() { throw new UnsupportedOperationException( "Not implemented." ); }
getElementType()299         public Type getElementType() { throw new UnsupportedOperationException( "Not implemented." ); }
hasElements()300         public boolean hasElements() { throw new UnsupportedOperationException( "Not implemented." ); }
301     };
302 
303     private class DummyElementAccess implements XElementAccess
304     {
getElementType()305         public Type getElementType() { throw new UnsupportedOperationException( "Not implemented." ); }
hasElements()306         public boolean hasElements() { throw new UnsupportedOperationException( "Not implemented." ); }
307     };
308 
testValueTypes()309     @Test public void testValueTypes() throws com.sun.star.uno.Exception
310     {
311         final Integer key = new Integer(1);
312 
313         // type compatibility matrix: rows are the value types used to create the map,
314         // columns are the value types fed into the map. A value "1" means the respective type
315         // should be accepted.
316         Integer[][] typeCompatibility = new Integer[][] {
317             /* boolean           */ new Integer[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
318             /* short             */ new Integer[] { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
319             /* int               */ new Integer[] { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
320             /* long              */ new Integer[] { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
321             /* XInterface        */ new Integer[] { 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 },
322             /* XSet              */ new Integer[] { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
323             /* XContainer        */ new Integer[] { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
324             /* XIdentifierAccess */ new Integer[] { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 },
325             /* XElementAccess    */ new Integer[] { 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0 },
326             /* Exception         */ new Integer[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 },
327             /* RuntimeException  */ new Integer[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 },
328             /* EventObject       */ new Integer[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0 },
329             /* ContainerEvent    */ new Integer[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 },
330             /* any               */ new Integer[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
331         };
332         // several asects are checked with this compatibility matrix:
333         // - if a map's value type is a scalar type, or a string, then nothing but this
334         //   type should be accepted
335         // - if a map's value type is an interface type, then values should be accepted if
336         //   they contain a derived interface, or the interrface itself, or if they can be
337         //   queried for this interface (actually, the latter rule is not tested with the
338         //   above matrix)
339         // - if a map's value type is a struct or exception, then values should be accepted
340         //   if they are of the given type, or of a derived type.
341         // - if a map's value type is "any", then, well, any value should be accepted
342 
343         for ( int valueTypePos = 0; valueTypePos != typeCompatibility.length; ++valueTypePos )
344         {
345             XMap map = com.sun.star.container.EnumerableMap.create( connection.getComponentContext(),
346                 new Type( Integer.class ), new Type( impl_getValueClassByPos( valueTypePos ) ) );
347 
348             for ( int checkTypePos = 0; checkTypePos != typeCompatibility[valueTypePos].length; ++checkTypePos )
349             {
350                 Object value = impl_getSomeValueByTypePos( checkTypePos );
351                 if ( typeCompatibility[valueTypePos][checkTypePos] != 0 )
352                 {
353                     // expected to succeed
354 //?                    assureException(
355 //?                        "(" + valueTypePos + "," + checkTypePos + ") putting an " +
356 //?                            AnyConverter.getType( value ).getTypeName() + ", where " +
357 //?                            map.getValueType().getTypeName() + " is expected, should succeed",
358 //?                        map, "put", new Class[] { Object.class, Object.class }, new Object[] { key, value },
359 //?                        null );
360                 }
361                 else
362                 {
363                     // expected to fail
364 //?                    assureException(
365 //?                        "(" + valueTypePos + "," + checkTypePos + ") putting an " +
366 //?                            AnyConverter.getType( value ).getTypeName() + ", where " +
367 //?                            map.getValueType().getTypeName() + " is expected, should not succeed",
368 //?                        map, "put", new Class[] { Object.class, Object.class }, new Object[] { key, value },
369 //?                        IllegalTypeException.class );
370                 }
371             }
372         }
373     }
374 
375     private interface CompareEqual
376     {
areEqual( Object _lhs, Object _rhs )377         public boolean areEqual( Object _lhs, Object _rhs );
378     };
379 
380     private class DefaultCompareEqual implements CompareEqual
381     {
areEqual( Object _lhs, Object _rhs )382         public boolean areEqual( Object _lhs, Object _rhs )
383         {
384             return _lhs.equals( _rhs );
385         }
386     };
387 
388     private class PairCompareEqual implements CompareEqual
389     {
areEqual( Object _lhs, Object _rhs )390         public boolean areEqual( Object _lhs, Object _rhs )
391         {
392             Pair< ?, ? > lhs = (Pair< ?, ? >)_lhs;
393             Pair< ?, ? > rhs = (Pair< ?, ? >)_rhs;
394             return lhs.First.equals( rhs.First ) && lhs.Second.equals( rhs.Second );
395         }
396     };
397 
398     @SuppressWarnings("unchecked")
impl_verifyEnumerationContent( XEnumeration _enum, final Object[] _expectedElements, final String _context )399     private void impl_verifyEnumerationContent( XEnumeration _enum, final Object[] _expectedElements, final String _context )
400         throws com.sun.star.uno.Exception
401     {
402         // since we cannot assume the map to preserve the ordering in which the elements where inserted,
403         // we can only verify that all elements exist as expected, plus *no more* elements than expected
404         // are provided by the enumeration
405         Set set = new HashSet();
406         for ( int i=0; i<_expectedElements.length; ++i )
407         {
408             set.add( i );
409         }
410 
411         CompareEqual comparator = _expectedElements[0].getClass().equals( Pair.class )
412                                 ? new PairCompareEqual()
413                                 : new DefaultCompareEqual();
414 
415         for ( int i=0; i<_expectedElements.length; ++i )
416         {
417             assertTrue( _context + ": too few elements in the enumeration (still " + ( _expectedElements.length - i ) + " to go)",
418                 _enum.hasMoreElements() );
419 
420             Object nextElement = _enum.nextElement();
421             if ( nextElement.getClass().equals( Any.class ) )
422             {
423                 nextElement = ((Any)nextElement).getObject();
424             }
425 
426             int foundPos = -1;
427             for ( int j=0; j<_expectedElements.length; ++j )
428             {
429                 if ( comparator.areEqual( _expectedElements[j], nextElement ) )
430                 {
431                     foundPos = j;
432                     break;
433                 }
434             }
435 
436             assertTrue( _context + ": '" + nextElement.toString() + "' is not expected in the enumeration",
437                 set.contains( foundPos ) );
438             set.remove( foundPos );
439         }
440         assertTrue( _context + ": too many elements returned by the enumeration", set.isEmpty() );
441     }
442 
testEnumerations()443     @Test public void testEnumerations() throws com.sun.star.uno.Exception
444     {
445         // fill a map
446         final String[] keys = new String[] { "This", "is", "an", "enumeration", "test" };
447         final String[] values = new String[] { "for", "the", "map", "implementation", "." };
448         XEnumerableMap map = com.sun.star.container.EnumerableMap.create( connection.getComponentContext(), new Type( String.class ), new Type( String.class ) );
449         impl_putAll( map, keys, values );
450 
451         final Pair< ?, ? >[] paired = new Pair< ?, ? >[ keys.length ];
452         for ( int i=0; i<keys.length; ++i )
453         {
454             paired[i] = new Pair< Object, Object >( keys[i], values[i] );
455         }
456 
457         // create non-isolated enumerators, and check their content
458         XEnumeration enumerateKeys = map.createKeyEnumeration( false );
459         XEnumeration enumerateValues = map.createValueEnumeration( false );
460         XEnumeration enumerateAll = map.createElementEnumeration( false );
461         impl_verifyEnumerationContent( enumerateKeys, keys, "key enumeration" );
462         impl_verifyEnumerationContent( enumerateValues, values, "value enumeration" );
463         impl_verifyEnumerationContent( enumerateAll, paired, "content enumeration" );
464 
465         // all enumerators above have been created as non-isolated iterators, so they're expected to die when
466         // the underlying map changes
467         map.remove( keys[0] );
468 //?        assureException( enumerateKeys, "hasMoreElements", new Object[] {}, DisposedException.class );
469 //?        assureException( enumerateValues, "hasMoreElements", new Object[] {}, DisposedException.class );
470 //?        assureException( enumerateAll, "hasMoreElements", new Object[] {}, DisposedException.class );
471 
472         // now try with isolated iterators
473         map.put( keys[0], values[0] );
474         enumerateKeys = map.createKeyEnumeration( true );
475         enumerateValues = map.createValueEnumeration( true );
476         enumerateAll = map.createElementEnumeration( true );
477         map.put( "additional", "value" );
478         impl_verifyEnumerationContent( enumerateKeys, keys, "key enumeration" );
479         impl_verifyEnumerationContent( enumerateValues, values, "value enumeration" );
480         impl_verifyEnumerationContent( enumerateAll, paired, "content enumeration" );
481     }
482 
testSpecialValues()483     @Test public void testSpecialValues() throws com.sun.star.uno.Exception
484     {
485         final Double[] keys = new Double[] { new Double( 0 ), Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY };
486         final Double[] values = new Double[] { Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, new Double( 0 ) };
487 
488         XEnumerableMap map = com.sun.star.container.EnumerableMap.create( connection.getComponentContext(), new Type( Double.class ), new Type( Double.class ) );
489         impl_putAll( map, keys, values );
490 
491         assertTrue( "containsKey( Double.+INF failed", map.containsKey( Double.POSITIVE_INFINITY ) );
492         assertTrue( "containsKey( Double.-INF failed", map.containsKey( Double.NEGATIVE_INFINITY ) );
493         assertTrue( "containsKey( 0 ) failed", map.containsKey( new Double( 0 ) ) );
494 
495         assertTrue( "containsValue( Double.+INF ) failed", map.containsValue( Double.POSITIVE_INFINITY ) );
496         assertTrue( "containsValue( Double.-INF ) failed", map.containsValue( Double.NEGATIVE_INFINITY ) );
497         assertTrue( "containsValue( 0 ) failed", map.containsValue( new Double( 0 ) ) );
498 
499         // put and containsKey should reject Double.NaN as key
500 //?        assureException( "Double.NaN should not be allowed as key in a call to 'put'", map, "put",
501 //?            new Class[] { Object.class, Object.class }, new Object[] { Double.NaN, new Double( 0 ) },
502 //?            com.sun.star.lang.IllegalArgumentException.class );
503 //?        assureException( "Double.NaN should not be allowed as key in a call to 'containsKey'", map, "containsKey",
504 //?            new Class[] { Object.class }, new Object[] { Double.NaN },
505 //?            com.sun.star.lang.IllegalArgumentException.class );
506 
507         // ditto for put and containsValue
508 //?        assureException( "Double.NaN should not be allowed as value in a call to 'put'", map, "put",
509 //?            new Class[] { Object.class, Object.class }, new Object[] { new Double( 0 ), Double.NaN },
510 //?            com.sun.star.lang.IllegalArgumentException.class );
511 //?        assureException( "Double.NaN should not be allowed as key in a call to 'containsValue'", map, "containsValue",
512 //?            new Class[] { Object.class }, new Object[] { Double.NaN },
513 //?            com.sun.star.lang.IllegalArgumentException.class );
514     }
515 
516 
getMSF()517     private XMultiServiceFactory getMSF()
518     {
519         final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
520         return xMSF1;
521     }
522 
523     // setup and close connections
setUpConnection()524     @BeforeClass public static void setUpConnection() throws Exception {
525         System.out.println("setUpConnection()");
526         connection.setUp();
527     }
528 
tearDownConnection()529     @AfterClass public static void tearDownConnection()
530         throws InterruptedException, com.sun.star.uno.Exception
531     {
532         System.out.println("tearDownConnection()");
533         connection.tearDown();
534     }
535 
536     private static final OfficeConnection connection = new OfficeConnection();
537 }
538