KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > test > orb > dynany > DynAnyArrayTest


1 package org.jacorb.test.orb.dynany;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1997-2001 Gerald Brose.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22
23 import junit.framework.*;
24 import junit.extensions.TestSetup;
25 import org.omg.CORBA.TCKind JavaDoc;
26
27 import org.jacorb.test.common.ORBSetup;
28 import org.jacorb.test.Bound;
29 import org.jacorb.test.ArrayTypeHelper;
30
31 /**
32  * DynAnyArrayTest.java
33  *
34  * DynAny tests for array types.
35  *
36  */

37
38 public class DynAnyArrayTest extends TestCase
39 {
40    private static org.omg.DynamicAny.DynAnyFactory JavaDoc factory = null;
41    private static org.omg.CORBA.ORB JavaDoc orb = null;
42
43    public DynAnyArrayTest (String JavaDoc name)
44    {
45       super (name);
46    }
47
48
49    public static Test suite ()
50    {
51       TestSuite suite = new TestSuite ("DynArray Tests");
52       Setup setup = new Setup (suite);
53       ORBSetup osetup = new ORBSetup (setup);
54
55       suite.addTest (new DynAnyArrayTest ("testFactoryCreateFromAny"));
56       suite.addTest (new DynAnyArrayTest ("testFactoryCreateFromTypeCode"));
57       suite.addTest (new DynAnyArrayTest ("testFactoryCreateFromIDLTypeCode"));
58       suite.addTest (new DynAnyArrayTest ("testCompareDynAny"));
59       suite.addTest (new DynAnyArrayTest ("testIterateDynAny"));
60       suite.addTest (new DynAnyArrayTest ("testAccessArrayElements"));
61       suite.addTest (new DynAnyArrayTest ("testAccessArrayDynAnyElements"));
62       suite.addTest (new DynAnyArrayTest ("testAccessArrayElementsEx"));
63       suite.addTest (new DynAnyArrayTest ("testDynAnyTypeCode"));
64       suite.addTest (new DynAnyArrayTest ("testInitDynAnyFromDynAny"));
65       suite.addTest (new DynAnyArrayTest ("testInitDynAnyFromAny"));
66       suite.addTest (new DynAnyArrayTest ("testInitFromAnyTypeMismatchEx"));
67       suite.addTest (new DynAnyArrayTest ("testGenerateAnyFromDynAny"));
68       suite.addTest (new DynAnyArrayTest ("testDestroyDynAny"));
69       suite.addTest (new DynAnyArrayTest ("testDestroyComponent"));
70       suite.addTest (new DynAnyArrayTest ("testCopyDynAny"));
71
72       return osetup;
73    }
74
75
76    /**
77     * Tests creating a DynAny object from an Any object using the
78     * DynAnyFactory object.
79     */

80    public void testFactoryCreateFromAny ()
81    {
82       int [] type = null;
83       org.omg.CORBA.Any JavaDoc any = null;
84
85       type = getIntArray ();
86       any = orb.create_any ();
87       ArrayTypeHelper.insert (any, type);
88
89       createDynAnyFromAny (any);
90    }
91
92
93    /**
94     * Tests creating a DynAny object from a TypeCode object using the
95     * DynAnyFactory object.
96     */

97    public void testFactoryCreateFromTypeCode ()
98    {
99       org.omg.CORBA.TypeCode JavaDoc tc = null;
100
101       tc = orb.get_primitive_tc (TCKind.tk_long);
102       tc = orb.create_array_tc (Bound.value, tc);
103       createDynAnyFromTypeCode (tc);
104    }
105
106
107    /**
108     * Tests creating a DynAny object from a TypeCode object generated from
109     * IDL using the DynAnyFactory object.
110     */

111    public void testFactoryCreateFromIDLTypeCode ()
112    {
113       org.omg.CORBA.TypeCode JavaDoc tc = null;
114
115       tc = ArrayTypeHelper.type ();
116       createDynAnyFromTypeCode (tc);
117    }
118
119
120    /**
121     * Test comparing DynAny values.
122     */

123    public void testCompareDynAny ()
124    {
125       String JavaDoc msg;
126       int [] type;
127       org.omg.CORBA.Any JavaDoc any = null;
128       org.omg.DynamicAny.DynArray JavaDoc dynAny = null;
129       org.omg.DynamicAny.DynArray JavaDoc dynAny2 = null;
130
131       type = getIntArray ();
132       any = orb.create_any ();
133       ArrayTypeHelper.insert (any, type);
134       dynAny = createDynAnyFromAny (any);
135       dynAny2 = createDynAnyFromAny (any);
136
137       msg = "Comparing two equal DynAny values using DynAny::equal failed";
138       assertTrue (msg, dynAny.equal (dynAny2));
139    }
140
141
142    /**
143     * Test iterating through components of a DynAny.
144     */

145    public void testIterateDynAny ()
146    {
147       String JavaDoc msg;
148       int [] type;
149       int compCount = -1;
150       boolean seek;
151       org.omg.CORBA.Any JavaDoc any = null;
152       org.omg.CORBA.TypeCode JavaDoc tc = null;
153       org.omg.DynamicAny.DynArray JavaDoc dynAny = null;
154       org.omg.DynamicAny.DynAny JavaDoc compSeek = null;
155       org.omg.DynamicAny.DynAny JavaDoc compRewind = null;
156
157       type = getIntArray ();
158       any = orb.create_any ();
159       ArrayTypeHelper.insert (any, type);
160       dynAny = createDynAnyFromAny (any);
161
162       // test the component count
163
msg = "The number of components returned from the ";
164       msg += "DynAny::component_count method is incorrect";
165       try
166       {
167          compCount = dynAny.component_count ();
168       }
169       catch (Throwable JavaDoc ex)
170       {
171          // should not be needed, but it prevents compiler errors
172
fail ("Unexpected error raised by DynAny::component_count operation");
173       }
174       assertEquals (msg, Bound.value, compCount);
175
176       // seek an invalid position
177
msg = "The DynAny::seek operation indicates a valid current position ";
178       msg += "when the current position should be invalid";
179       seek = dynAny.seek (-1);
180       assertTrue (msg, !seek);
181
182       // seek the first position
183
msg = "The DynAny::seek operation indicates an invalid current position ";
184       msg += "when the current position should be valid";
185       seek = dynAny.seek (0);
186       assertTrue (msg, seek);
187
188       // extract a value from the current position
189
try
190       {
191          compSeek = dynAny.current_component ();
192       }
193       catch (Throwable JavaDoc ex)
194       {
195          msg = "Failed to get the current component using the ";
196          msg += "DynAny::current_component operation after calling the ";
197          msg += "DynAny::seek operation";
198          fail (msg + ": " + ex);
199       }
200
201       // seek the next position
202
msg = "The DynAny::next operation indicates an invalid current position ";
203       msg += "when the current position should be valid";
204       seek = dynAny.next ();
205       assertTrue (msg, seek);
206
207       // return to the first position
208
dynAny.rewind ();
209
210       // extract a value from the current position
211
try
212       {
213          compRewind = dynAny.current_component ();
214       }
215       catch (Throwable JavaDoc ex)
216       {
217          msg = "Failed to get the current component using the ";
218          msg += "DynAny::current_component operation after calling the ";
219          msg += "DynAny::rewind operation";
220          fail (msg + ": " + ex);
221       }
222       msg = "The component at DynAny::seek(0) is not equal to the ";
223       msg += "component at DynAny::rewind";
224       assertTrue (msg, compSeek.equal (compRewind));
225    }
226
227
228    /**
229     * Test accessing the elements in a DynArray object.
230     */

231    public void testAccessArrayElements ()
232    {
233       String JavaDoc msg;
234       int len;
235       int curVal;
236       boolean next;
237       org.omg.CORBA.TypeCode JavaDoc tc = null;
238       org.omg.DynamicAny.DynArray JavaDoc dynAny = null;
239       org.omg.CORBA.Any JavaDoc [] anys = null;
240
241       tc = ArrayTypeHelper.type ();
242       dynAny = createDynAnyFromTypeCode (tc);
243
244       // test setting the elements
245
len = Bound.value;
246       anys = new org.omg.CORBA.Any JavaDoc [len];
247       for (int i = 0; i < len; i++)
248       {
249          anys [i] = orb.create_any ();
250          anys [i].insert_long (i);
251       }
252
253       try
254       {
255          dynAny.set_elements (anys);
256       }
257       catch (Throwable JavaDoc ex)
258       {
259          msg = "Failed to set the elements using the DynArray::set_elements ";
260          msg += "operation";
261          fail (msg + ": " + ex);
262       }
263
264       // test getting the elements
265
anys = dynAny.get_elements ();
266       for (int i = 0; i < anys.length; i++)
267       {
268          msg = "Failed to get the correct value of the DynArray at ";
269          msg += "position " + i + " when array element is returned using ";
270          msg += "DynArray::get_elements operation";
271          curVal = anys [i].extract_long ();
272          assertEquals (msg, i, curVal);
273       }
274    }
275
276
277    /**
278     * Test accessing the elements in a DynArray object as DynAnys.
279     */

280    public void testAccessArrayDynAnyElements ()
281    {
282       String JavaDoc msg;
283       int len;
284       int curVal;
285       boolean next;
286       org.omg.CORBA.TypeCode JavaDoc tc = null;
287       org.omg.DynamicAny.DynArray JavaDoc dynAny = null;
288       org.omg.DynamicAny.DynAny JavaDoc [] dynAnys = null;
289
290       tc = ArrayTypeHelper.type ();
291       dynAny = createDynAnyFromTypeCode (tc);
292
293       // test setting the elements
294
len = Bound.value;
295       dynAnys = new org.omg.DynamicAny.DynAny JavaDoc [len];
296       tc = orb.get_primitive_tc (TCKind.tk_long);
297       for (int i = 0; i < len; i++)
298       {
299          try
300          {
301             dynAnys [i] = factory.create_dyn_any_from_type_code (tc);
302          }
303          catch (Throwable JavaDoc ex)
304          {
305             fail ("Failed to create a DynAny at position " + i + ": " + ex);
306          }
307
308          try
309          {
310             dynAnys [i].insert_long (i);
311          }
312          catch (Throwable JavaDoc ex)
313          {
314             msg = "Failed to insert a value into a DynAny at position " + i;
315             msg += ": " + ex;
316             fail (msg);
317          }
318       }
319
320       try
321       {
322          dynAny.set_elements_as_dyn_any (dynAnys);
323       }
324       catch (Throwable JavaDoc ex)
325       {
326          msg = "Failed to set the elements using the ";
327          msg += "DynArray::set_elements_as_dyn_any operation";
328          fail (msg + ": " + ex);
329       }
330
331       // test getting the elements
332
dynAnys = dynAny.get_elements_as_dyn_any ();
333       for (int i = 0; i < dynAnys.length; i++)
334       {
335          msg = "Failed to get the correct value of the DynArray at ";
336          msg += "position " + i + " when array element is returned using ";
337          msg += "DynArray::get_elements_as_dyn_any operation";
338          curVal = -1;
339          try
340          {
341             curVal = dynAnys [i].get_long ();
342          }
343          catch (Throwable JavaDoc ex)
344          {
345             fail (msg + ": " + ex);
346          }
347          assertEquals (msg, i, curVal);
348       }
349    }
350
351
352    /**
353     * Test that the correct exceptions are raised when accessing the elements
354     * in a DynArray object incorrectly.
355     */

356    public void testAccessArrayElementsEx ()
357    {
358       String JavaDoc msg;
359       int len;
360       org.omg.CORBA.TypeCode JavaDoc tc = null;
361       org.omg.DynamicAny.DynArray JavaDoc dynAny = null;
362       org.omg.CORBA.Any JavaDoc [] anys = null;
363
364       tc = ArrayTypeHelper.type ();
365       dynAny = createDynAnyFromTypeCode (tc);
366
367       // test setting the elements with components of an invalid type
368
len = Bound.value;
369       anys = new org.omg.CORBA.Any JavaDoc [len];
370       for (int i = 0; i < len; i++)
371       {
372          anys [i] = orb.create_any ();
373          anys [i].insert_string ("BadType");
374       }
375
376       msg = "Failed to raise a TypeMismatch exception when setting a ";
377       msg += "DynArray object with components of the wrong type using ";
378       msg += "DynArray::set_elements";
379       try
380       {
381          dynAny.set_elements (anys);
382
383          fail (msg);
384       }
385       catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch JavaDoc ex)
386       {
387          // success
388
}
389       catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue JavaDoc ex)
390       {
391          fail (msg + ": " + ex);
392       }
393
394       // test setting the elements with an incorrect number of elements
395
len = Bound.value + 1;
396       anys = new org.omg.CORBA.Any JavaDoc [len];
397       for (int i = 0; i < len; i++)
398       {
399          anys [i] = orb.create_any ();
400          anys [i].insert_long (i);
401       }
402
403       msg = "Failed to raise an InvalidValue exception when setting a ";
404       msg += "DynArray object with an incorrect number of elements using ";
405       msg += "DynArray::set_elements";
406       try
407       {
408          dynAny.set_elements (anys);
409       }
410       catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue JavaDoc ex)
411       {
412          // success
413
}
414       catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch JavaDoc ex)
415       {
416          fail (msg + ": " + ex);
417       }
418    }
419
420
421    /**
422     * Test obtaining the TypeCode associated with a DynAny object.
423     */

424    public void testDynAnyTypeCode ()
425    {
426       String JavaDoc msg;
427       org.omg.CORBA.TypeCode JavaDoc tc = null;
428       org.omg.DynamicAny.DynArray JavaDoc dynAny = null;
429
430       tc = orb.get_primitive_tc (TCKind.tk_long);
431       tc = orb.create_array_tc (Bound.value, tc);
432       dynAny = createDynAnyFromTypeCode (tc);
433
434       msg = "Incorrect TypeCode retrieved from DynAny::type operation";
435       assertTrue (msg, dynAny.type ().equal (tc));
436    }
437
438
439    /**
440     * Test initializing a DynAny object from another DynAny object.
441     */

442    public void testInitDynAnyFromDynAny ()
443    {
444       String JavaDoc msg;
445       int [] type;
446       org.omg.CORBA.Any JavaDoc any = null;
447       org.omg.CORBA.TypeCode JavaDoc tc = null;
448       org.omg.DynamicAny.DynArray JavaDoc dynAny = null;
449       org.omg.DynamicAny.DynArray JavaDoc dynAny2 = null;
450
451       tc = ArrayTypeHelper.type ();
452       dynAny = createDynAnyFromTypeCode (tc);
453
454       type = getIntArray ();
455       any = orb.create_any ();
456       ArrayTypeHelper.insert (any, type);
457       dynAny2 = createDynAnyFromAny (any);
458
459       msg = "Failed to initialize a DynAny object from another DynAny ";
460       msg += "object using the DynAny::assign operation";
461       try
462       {
463          dynAny.assign (dynAny2);
464       }
465       catch (Throwable JavaDoc ex)
466       {
467          fail (msg + ": " + ex);
468       }
469       assertTrue (msg, dynAny.equal (dynAny2));
470    }
471
472
473    /**
474     * Test initializing a DynAny object from an Any value.
475     */

476    public void testInitDynAnyFromAny ()
477    {
478       String JavaDoc msg;
479       int [] type;
480       org.omg.CORBA.Any JavaDoc any = null;
481       org.omg.CORBA.TypeCode JavaDoc tc = null;
482       org.omg.DynamicAny.DynArray JavaDoc dynAny = null;
483       org.omg.DynamicAny.DynArray JavaDoc dynAny2 = null;
484
485       tc = ArrayTypeHelper.type ();
486       dynAny = createDynAnyFromTypeCode (tc);
487
488       type = getIntArray ();
489       any = orb.create_any ();
490       ArrayTypeHelper.insert (any, type);
491       dynAny2 = createDynAnyFromAny (any);
492
493       msg = "Failed to initialize a DynAny object from an Any object ";
494       msg += "using the DynAny::from_any operation";
495       try
496       {
497          dynAny.from_any (any);
498       }
499       catch (Throwable JavaDoc ex)
500       {
501          fail (msg + ": " + ex);
502       }
503       assertTrue (msg, dynAny.equal (dynAny2));
504    }
505
506
507    /**
508     * Test that a TypeMismatch exception is raised if there is a type
509     * mismatch between the DynAny and Any types in an assignment.
510     */

511    public void testInitFromAnyTypeMismatchEx ()
512    {
513       String JavaDoc msg;
514       org.omg.CORBA.Any JavaDoc any = null;
515       org.omg.CORBA.TypeCode JavaDoc tc = null;
516       org.omg.DynamicAny.DynArray JavaDoc dynAny = null;
517
518       any = orb.create_any ();
519       any.insert_string ("Hello");
520
521       tc = orb.get_primitive_tc (TCKind.tk_long);
522       tc = orb.create_array_tc (Bound.value, tc);
523       dynAny = createDynAnyFromTypeCode (tc);
524
525       msg = "TypeMismatch exception not thrown by DynAny::from_any ";
526       msg += "operation when DynAny and Any operands have different types";
527       try
528       {
529          dynAny.from_any (any);
530
531          fail (msg);
532       }
533       catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch JavaDoc ex)
534       {
535          // success
536
}
537       catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue JavaDoc ex)
538       {
539          fail (msg + ": " + ex);
540       }
541    }
542
543
544    /**
545     * Test generating an Any value from a DynAny object.
546     */

547    public void testGenerateAnyFromDynAny ()
548    {
549       String JavaDoc msg;
550       org.omg.CORBA.Any JavaDoc any = null;
551       org.omg.CORBA.TypeCode JavaDoc tc = null;
552       org.omg.DynamicAny.DynArray JavaDoc dynAny = null;
553       org.omg.DynamicAny.DynArray JavaDoc dynAny2 = null;
554
555       tc = ArrayTypeHelper.type ();
556       dynAny = createDynAnyFromTypeCode (tc);
557
558       any = orb.create_any ();
559       any = dynAny.to_any ();
560       dynAny2 = createDynAnyFromAny (any);
561
562       msg = "The DynAny::to_any operation failed to create an Any ";
563       msg += "object with the same value as the DynAny object";
564       assertTrue (msg, dynAny.equal (dynAny2));
565    }
566
567
568    /**
569     * Test destroying a DynAny object.
570     */

571    public void testDestroyDynAny ()
572    {
573       String JavaDoc msg;
574       int [] type;
575       org.omg.CORBA.Any JavaDoc any = null;
576       org.omg.DynamicAny.DynArray JavaDoc dynAny = null;
577
578       type = getIntArray ();
579       any = orb.create_any ();
580       ArrayTypeHelper.insert (any, type);
581       dynAny = createDynAnyFromAny (any);
582       dynAny.destroy ();
583
584       try
585       {
586          dynAny.type ();
587
588          msg = "Failed to destroy DynAny using DynAny::destroy operation - ";
589          msg += "calling DynAny::type operation on a destroyed DynAny object ";
590          msg += "did not raise OBJECT_NOT_EXIST exception";
591          fail (msg);
592       }
593       catch (org.omg.CORBA.OBJECT_NOT_EXIST JavaDoc ex)
594       {
595          // success
596
}
597
598       msg = "Failed to destroy DynAny using DynAny::destroy operation - ";
599       msg += "calling DynAny::current_component operation on a destroyed ";
600       msg += "DynAny object did not raise OBJECT_NOT_EXIST exception";
601       try
602       {
603          dynAny.current_component ();
604
605          fail (msg);
606       }
607       catch (org.omg.CORBA.OBJECT_NOT_EXIST JavaDoc ex)
608       {
609          // success
610
}
611       catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch JavaDoc ex)
612       {
613          fail (msg + ": " + ex);
614       }
615    }
616
617
618    /**
619     * Test destroying a component of a DynAny object.
620     */

621    public void testDestroyComponent ()
622    {
623       String JavaDoc msg;
624       int [] type;
625       org.omg.CORBA.Any JavaDoc any = null;
626       org.omg.DynamicAny.DynArray JavaDoc dynAny = null;
627       org.omg.DynamicAny.DynAny JavaDoc comp = null;
628
629       type = getIntArray ();
630       any = orb.create_any ();
631       ArrayTypeHelper.insert (any, type);
632       dynAny = createDynAnyFromAny (any);
633
634       try
635       {
636          comp = dynAny.current_component ();
637       }
638       catch (Throwable JavaDoc ex)
639       {
640          msg = "Failed to get the current component of the DynAny using the ";
641          msg += "DynAny::current_component operation before calling the ";
642          msg += "DynAny::destroy operation";
643          fail (msg + ": " + ex);
644       }
645
646       comp.destroy ();
647       try
648       {
649          comp = dynAny.current_component ();
650       }
651       catch (Throwable JavaDoc ex)
652       {
653          msg = "Failed to get the current component of the DynAny using the ";
654          msg += "DynAny::current_component operation after calling the ";
655          msg += "DynAny::destroy operation";
656          fail (msg + ": " + ex);
657       }
658
659       try
660       {
661          comp.type ();
662       }
663       catch (org.omg.CORBA.OBJECT_NOT_EXIST JavaDoc ex)
664       {
665          msg = "Calling destroy on a component resulted in destroying the ";
666          msg += "component object";
667          fail (msg + ": " + ex);
668       }
669    }
670
671
672    /**
673     * Test creating a copy of a DynAny object.
674     */

675    public void testCopyDynAny ()
676    {
677       String JavaDoc msg;
678       org.omg.CORBA.TypeCode JavaDoc tc = null;
679       org.omg.DynamicAny.DynArray JavaDoc dynAny = null;
680       org.omg.DynamicAny.DynArray JavaDoc dynAny2 = null;
681
682       tc = ArrayTypeHelper.type ();
683       dynAny = createDynAnyFromTypeCode (tc);
684       dynAny2 = (org.omg.DynamicAny.DynArray JavaDoc) dynAny.copy ();
685
686       msg = "The DynAny object created with the DynAny::copy operation ";
687       msg += "is not equal to the DynAny object it was copied from";
688       assertTrue (msg, dynAny.equal (dynAny2));
689    }
690
691
692    private static class Setup extends TestSetup
693    {
694       public Setup (Test test)
695       {
696          super (test);
697       }
698
699       protected void setUp ()
700       {
701          org.omg.CORBA.Object JavaDoc obj = null;
702
703          orb = ORBSetup.getORB ();
704          try
705          {
706             obj = orb.resolve_initial_references ("DynAnyFactory");
707          }
708          catch (org.omg.CORBA.ORBPackage.InvalidName JavaDoc ex)
709          {
710             fail ("Failed to resolve DynAnyFactory: " + ex);
711          }
712          try
713          {
714             factory = org.omg.DynamicAny.DynAnyFactoryHelper.narrow (obj);
715          }
716          catch (Throwable JavaDoc ex)
717          {
718             fail ("Failed to narrow to DynAnyFactory: " + ex);
719          }
720       }
721
722       protected void tearDown ()
723       {
724       }
725    }
726
727
728    /**
729     * Create a DynAny object from an Any object.
730     */

731    private static org.omg.DynamicAny.DynArray JavaDoc createDynAnyFromAny
732       (org.omg.CORBA.Any JavaDoc any)
733    {
734       String JavaDoc msg;
735       org.omg.DynamicAny.DynArray JavaDoc dynAny = null;
736
737       try
738       {
739          dynAny = (org.omg.DynamicAny.DynArray JavaDoc) factory.create_dyn_any (any);
740       }
741       catch (Throwable JavaDoc ex)
742       {
743          msg = "Factory failed to create DynAny from Any using ";
744          msg += "DynAny::create_dyn_any operation: " + ex;
745          fail (msg);
746       }
747       return dynAny;
748    }
749
750
751    /**
752     * Create a DynAny object from a TypeCode object.
753     */

754    private static org.omg.DynamicAny.DynArray JavaDoc createDynAnyFromTypeCode
755       (org.omg.CORBA.TypeCode JavaDoc tc)
756    {
757       String JavaDoc msg;
758       org.omg.DynamicAny.DynArray JavaDoc dynAny = null;
759
760       try
761       {
762          dynAny = (org.omg.DynamicAny.DynArray JavaDoc)
763             factory.create_dyn_any_from_type_code (tc);
764       }
765       catch (Throwable JavaDoc ex)
766       {
767          msg = "Factory failed to create DynAny from TypeCode using ";
768          msg += "DynAny::create_dyn_any_from_type_code operation: " + ex;
769          fail (msg);
770       }
771       return dynAny;
772    }
773
774
775    /**
776     * Create an array of integers of fixed length.
777     */

778    private static int [] getIntArray ()
779    {
780       int [] type = new int [Bound.value];
781       for (int i = 0; i < Bound.value; i++)
782       {
783          type [i] = i;
784       }
785       return type;
786    }
787
788 }
789
Popular Tags