Package org.omg.CORBA

Examples of org.omg.CORBA.TCKind


    */
   public void testAccessStructMembers ()
   {
      String msg;
      String memberName = null;
      TCKind memberKind = null;
      org.omg.CORBA.TypeCode tc = null;
      org.omg.DynamicAny.DynStruct dynAny = null;

      tc = NonEmptyExceptionHelper.type ();
      dynAny = createDynAnyFromTypeCode (tc);

      // test getting the name of the current member
      msg = "Failed to get the correct name of the first member using ";
      msg += "DynStruct::current_member_name operation";
      try
      {
         memberName = dynAny.current_member_name ();

         assertEquals (msg, "field1", memberName); // specific to IDL
      }
      catch (AssertionFailedError ex)
      {
         throw ex;
      }
      catch (Throwable ex)
      {
         fail (msg + ": " + ex);
      }

      // test getting the kind of the current member
      msg = "Failed to get the correct kind of the first member using ";
      msg += "DynStruct::current_member_kind operation";
      try
      {
         memberKind = dynAny.current_member_kind ();

         // specific to IDL
         assertEquals (msg, TCKind._tk_long, memberKind.value ());
      }
      catch (AssertionFailedError ex)
      {
         throw ex;
      }
      catch (Throwable ex)
      {
         fail (msg + ": " + ex);
      }

      // move to the next position
      dynAny.next ();

      // test getting the name of the current member
      msg = "Failed to get the correct name of the second member using ";
      msg += "DynStruct::current_member_name operation";
      try
      {
         memberName = dynAny.current_member_name ();

         assertEquals (msg, "field2", memberName); // specific to IDL
      }
      catch (AssertionFailedError ex)
      {
         throw ex;
      }
      catch (Throwable ex)
      {
         fail (msg + ": " + ex);
      }

      // test getting the kind of the current member
      msg = "Failed to get the correct kind of the second member using ";
      msg += "DynStruct::current_member_kind operation";
      try
      {
         memberKind = dynAny.current_member_kind ();

         // specific to IDL
         assertEquals (msg, TCKind._tk_string, memberKind.value ());
      }
      catch (AssertionFailedError ex)
      {
         throw ex;
      }
View Full Code Here


    * Test accessing the discriminator of a DynUnion object.
    */
   public void testAccessUnionDisc ()
   {
      String msg;
      TCKind discKind = null;
      org.omg.CORBA.TypeCode tc = null;
      org.omg.DynamicAny.DynUnion dynAny = null;
      org.omg.DynamicAny.DynAny disc = null;
      org.omg.DynamicAny.DynAny invalidDisc = null;

      tc = UnionDefaultShortTypeHelper.type ();
      dynAny = createDynAnyFromTypeCode (tc);

      // test setting the discriminator
      tc = orb.get_primitive_tc (TCKind.tk_short);
      try
      {
         disc = factory.create_dyn_any_from_type_code (tc);
      }
      catch (Throwable ex)
      {
         fail ("Failed to create DynAny with correct TypeCode: " + ex);
      }

      try
      {
         disc.insert_short ((short) 1); // specific to IDL
      }
      catch (Throwable ex)
      {
         fail ("Failed to set value of discriminator: " + ex);
      }

      try
      {
         dynAny.set_discriminator (disc);
      }
      catch (Throwable ex)
      {
         msg = "Failed to set the value of the discriminator using the ";
         msg += "DynUnion::set_discriminator operation";
         fail (msg + ": " + ex);
      }

      // test getting the discriminator
      msg = "Failed to get the correct value of the discriminator using the ";
      msg += "DynUnion::get_discriminator operation";
      disc = dynAny.get_discriminator ();

      // specific to IDL
      assertEquals (msg, (short) 1, disc.to_any ().extract_short ());

      // test getting the kind of the discriminator
      msg = "Failed to get the correct kind of the discriminator using ";
      msg += "DynUnion::discriminator_kind operation";
      discKind = dynAny.discriminator_kind ();

      // specific to IDL
      assertEquals (msg, TCKind._tk_short, discKind.value ());

      // test setting an invalid discriminator
      tc = orb.get_primitive_tc (TCKind.tk_boolean);
      try
      {
View Full Code Here

   public void testAccessNamedUnionMember ()
   {
      String msg;
      int testVal = 10;
      UnionDefaultShortType type;
      TCKind memberKind = null;
      String memberName = null;
      int memberVal = -1;
      org.omg.CORBA.Any any = null;
      org.omg.DynamicAny.DynUnion dynAny = null;
      org.omg.DynamicAny.DynAny member = null; // specific to IDL

      type = new UnionDefaultShortType ();
      type.win (testVal);
      any = orb.create_any ();
      UnionDefaultShortTypeHelper.insert (any, type);
      dynAny = createDynAnyFromAny (any);

      // test getting the kind of the active member
      msg = "Failed to get the correct kind of the active member using ";
      msg += "DynUnion::member_kind operation";
      try
      {
         memberKind = dynAny.member_kind ();
      }
      catch (Throwable ex)
      {
         fail (msg + ": " + ex);
      }

      // specific to IDL
      assertEquals (msg, TCKind._tk_long, memberKind.value ());

      // test getting the name of the active member
      msg = "Failed to get the correct name of the active member using ";
      msg += "DynUnion::member_name operation";
      try
View Full Code Here

    protected String convertType(TypeCode tc)
    {
  String result = null;

  TCKind kind = tc.kind();
  if (kind == TCKind.tk_sequence) {
      try {
    TypeCode elemTC = tc.content_type();
    kind = elemTC.kind();
    result = "sequence<" + convertKind(kind) + ">";
View Full Code Here

/*  61 */     return this.typeCode;
/*     */   }
/*     */
/*     */   static LocalIDLType getIDLType(TypeCode typeCode, RepositoryImpl repository)
/*     */   {
/*  71 */     TCKind tcKind = typeCode.kind();
/*     */
/*  73 */     if (PrimitiveDefImpl.isPrimitiveTCKind(tcKind)) {
/*  74 */       return new PrimitiveDefImpl(typeCode, repository);
/*     */     }
/*  76 */     if (tcKind == TCKind.tk_sequence) {
/*  77 */       return repository.getSequenceImpl(typeCode);
/*     */     }
/*  79 */     if ((tcKind == TCKind.tk_value) || (tcKind == TCKind.tk_value_box) || (tcKind == TCKind.tk_alias) || (tcKind == TCKind.tk_struct) || (tcKind == TCKind.tk_union) || (tcKind == TCKind.tk_enum) || (tcKind == TCKind.tk_objref))
/*     */     {
/*     */       try
/*     */       {
/*  84 */         return (LocalIDLType)repository._lookup_id(typeCode.id());
/*     */       } catch (BadKind ex) {
/*  86 */         throw new RuntimeException("Bad kind for TypeCode.id()");
/*     */       }
/*     */     }
/*     */
/*  90 */     throw new RuntimeException("TODO: tcKind=" + tcKind.value());
/*     */   }
View Full Code Here

    */
    @Test
    public void testAccessUnionDisc ()
   {
      String msg;
      TCKind discKind = null;
      org.omg.CORBA.TypeCode tc = null;
      org.omg.DynamicAny.DynUnion dynAny = null;
      org.omg.DynamicAny.DynAny disc = null;
      org.omg.DynamicAny.DynAny invalidDisc = null;

      tc = UnionDefaultShortTypeHelper.type ();
      dynAny = createDynAnyFromTypeCode (tc);

      // test setting the discriminator
      tc = orb.get_primitive_tc (TCKind.tk_short);
      try
      {
         disc = factory.create_dyn_any_from_type_code (tc);
      }
      catch (Throwable ex)
      {
         fail ("Failed to create DynAny with correct TypeCode: " + ex);
      }

      try
      {
         disc.insert_short ((short) 1); // specific to IDL
      }
      catch (Throwable ex)
      {
         fail ("Failed to set value of discriminator: " + ex);
      }

      try
      {
         dynAny.set_discriminator (disc);
      }
      catch (Throwable ex)
      {
         msg = "Failed to set the value of the discriminator using the ";
         msg += "DynUnion::set_discriminator operation";
         fail (msg + ": " + ex);
      }

      // test getting the discriminator
      msg = "Failed to get the correct value of the discriminator using the ";
      msg += "DynUnion::get_discriminator operation";
      disc = dynAny.get_discriminator ();

      // specific to IDL
      assertEquals (msg, (short) 1, disc.to_any ().extract_short ());

      // test getting the kind of the discriminator
      msg = "Failed to get the correct kind of the discriminator using ";
      msg += "DynUnion::discriminator_kind operation";
      discKind = dynAny.discriminator_kind ();

      // specific to IDL
      assertEquals (msg, TCKind._tk_short, discKind.value ());

      // test setting an invalid discriminator
      tc = orb.get_primitive_tc (TCKind.tk_boolean);
      try
      {
View Full Code Here

    public void testAccessNamedUnionMember ()
   {
      String msg;
      int testVal = 10;
      UnionDefaultShortType type;
      TCKind memberKind = null;
      String memberName = null;
      int memberVal = -1;
      org.omg.CORBA.Any any = null;
      org.omg.DynamicAny.DynUnion dynAny = null;
      org.omg.DynamicAny.DynAny member = null; // specific to IDL

      type = new UnionDefaultShortType ();
      type.win (testVal);
      any = orb.create_any ();
      UnionDefaultShortTypeHelper.insert (any, type);
      dynAny = createDynAnyFromAny (any);

      // test getting the kind of the active member
      msg = "Failed to get the correct kind of the active member using ";
      msg += "DynUnion::member_kind operation";
      try
      {
         memberKind = dynAny.member_kind ();
      }
      catch (Throwable ex)
      {
         fail (msg + ": " + ex);
      }

      // specific to IDL
      assertEquals (msg, TCKind._tk_long, memberKind.value ());

      // test getting the name of the active member
      msg = "Failed to get the correct name of the active member using ";
      msg += "DynUnion::member_name operation";
      try
View Full Code Here

    */
    @Test
    public void testAccessUnionDisc ()
   {
      String msg;
      TCKind discKind = null;
      org.omg.CORBA.TypeCode tc = null;
      org.omg.DynamicAny.DynUnion dynAny = null;
      org.omg.DynamicAny.DynEnum disc = null;
      org.omg.DynamicAny.DynAny invalidDisc = null;

      tc = UnionDefaultTypeHelper.type ();
      dynAny = createDynAnyFromTypeCode (tc);

      // test setting the discriminator
      try
      {
         disc = (org.omg.DynamicAny.DynEnum)
            factory.create_dyn_any_from_type_code (EnumTypeHelper.type ());
      }
      catch (Throwable ex)
      {
         fail ("Failed to create DynAny with correct TypeCode: " + ex);
      }

      try
      {
         disc.set_as_string ("second"); // specific to IDL
      }
      catch (Throwable ex)
      {
         fail ("Failed to set value of discriminator: " + ex);
      }

      try
      {
         dynAny.set_discriminator (disc);
      }
      catch (Throwable ex)
      {
         msg = "Failed to set the value of the discriminator using the ";
         msg += "DynUnion::set_discriminator operation";
         fail (msg + ": " + ex);
      }

      // test getting the discriminator
      msg = "Failed to get the correct value of the discriminator using the ";
      msg += "DynUnion::get_discriminator operation";
      disc = (org.omg.DynamicAny.DynEnum) dynAny.get_discriminator ();

      // specific to IDL
      assertEquals (msg, EnumType.second.value (), disc.get_as_ulong ());

      // test getting the kind of the discriminator
      msg = "Failed to get the correct kind of the discriminator using ";
      msg += "DynUnion::discriminator_kind operation";
      discKind = dynAny.discriminator_kind ();

      // specific to IDL
      assertEquals (msg, TCKind._tk_enum, discKind.value ());

      // test setting an invalid discriminator
      tc = orb.get_primitive_tc (TCKind.tk_long);
      try
      {
View Full Code Here

    public void testAccessNamedUnionMember ()
   {
      String msg;
      int testVal = 10;
      UnionDefaultType type;
      TCKind memberKind = null;
      String memberName = null;
      int memberVal = -1;
      org.omg.CORBA.Any any = null;
      org.omg.DynamicAny.DynUnion dynAny = null;
      org.omg.DynamicAny.DynAny member = null; // specific to IDL

      type = new UnionDefaultType ();
      type.win (testVal);
      any = orb.create_any ();
      UnionDefaultTypeHelper.insert (any, type);
      dynAny = createDynAnyFromAny (any);

      // test getting the kind of the active member
      msg = "Failed to get the correct kind of the active member using ";
      msg += "DynUnion::member_kind operation";
      try
      {
         memberKind = dynAny.member_kind ();
      }
      catch (Throwable ex)
      {
         fail (msg + ": " + ex);
      }

      // specific to IDL
      assertEquals (msg, TCKind._tk_long, memberKind.value ());

      // test getting the name of the active member
      msg = "Failed to get the correct name of the active member using ";
      msg += "DynUnion::member_name operation";
      try
View Full Code Here

    @Test
    public void testAccessStructMembers () throws Exception
   {
      String msg;
      String memberName = null;
      TCKind memberKind = null;
      org.omg.CORBA.TypeCode tc = null;
      org.omg.DynamicAny.DynStruct dynAny = null;

      tc = StructTypeHelper.type ();
      dynAny = createDynAnyFromTypeCode (tc);

      // test getting the name of the current member
      msg = "Failed to get the correct name of the first member using ";
      msg += "DynStruct::current_member_name operation";
      memberName = dynAny.current_member_name ();

      assertEquals (msg, "field1", memberName); // specific to IDL

      // test getting the kind of the current member
      msg = "Failed to get the correct kind of the first member using ";
      msg += "DynStruct::current_member_kind operation";
      memberKind = dynAny.current_member_kind ();

      // specific to IDL
      assertEquals (msg, TCKind._tk_long, memberKind.value ());

      // move to the next position
      dynAny.next ();

      // test getting the name of the current member
      msg = "Failed to get the correct name of the second member using ";
      msg += "DynStruct::current_member_name operation";

      memberName = dynAny.current_member_name ();

      assertEquals (msg, "field2", memberName); // specific to IDL

      // test getting the kind of the current member
      msg = "Failed to get the correct kind of the second member using ";
      msg += "DynStruct::current_member_kind operation";

      memberKind = dynAny.current_member_kind ();

      // specific to IDL
      assertEquals (msg, TCKind._tk_string, memberKind.value ());

      // move to an invalid position
      dynAny.seek (-1);

      // test getting the name of the current member
View Full Code Here

TOP

Related Classes of org.omg.CORBA.TCKind

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.