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