Example #1
0
  /**
   * Test that jacorb handles some self-constructed broken typecodes well. The constructed typecode
   * is in principal recursive, but not flagged as such.
   */
  public void testBrokenRecursiveTypecode() {
    Any innerAny = orb.create_any();
    innerAny.insert_long(4711);

    StructMember[] members = {new StructMember("myAny", innerAny.type(), null)};

    TypeCode innerTc =
        orb.create_struct_tc(
            "IDL:Anonymous:1.0", // repository ID
            "Anonymous", // Struct name
            members);

    TypeCode outerTc =
        orb.create_struct_tc(
            "IDL:Anonymous:1.0", // repository ID
            "Anonymous", // Struct name
            new StructMember[] {new StructMember("foo", innerTc, null)});

    org.jacorb.orb.CDROutputStream out = new org.jacorb.orb.CDROutputStream(orb);
    out.write_TypeCode(outerTc);
    org.jacorb.orb.CDRInputStream in = new org.jacorb.orb.CDRInputStream(orb, out.getBufferCopy());

    out = new org.jacorb.orb.CDROutputStream(orb);

    // need to write out typecode, to check it's consistency completely
    out.write_TypeCode(in.read_TypeCode());
  }
Example #2
0
  public Object clone() throws CloneNotSupportedException {
    Concatenate c = (Concatenate) super.clone();

    c.op1_ = op1_.cloneAny();
    c.op2_ = op2_.cloneAny();

    c.temp_ = (AnyString) temp_.cloneAny();

    return c;
  }
Example #3
0
File: Sum.java Project: inqwell/inq
 private Any doAvg(Any sum, int count) {
   count_ = count;
   sum_ = sum;
   sum_.accept(this);
   // avg is left in sum_
   return sum_;
 }
Example #4
0
  public Object clone() throws CloneNotSupportedException {
    Stdout s = (Stdout) super.clone();

    s.any_ = any_.cloneAny();

    return s;
  }
Example #5
0
File: Sum.java Project: inqwell/inq
  public Object clone() throws CloneNotSupportedException {
    Sum s = (Sum) super.clone();

    s.sumRoot_ = sumRoot_.cloneAny();

    return s;
  }
Example #6
0
 /** Adds a set of children to an object, using its best guess as to where to put them. */
 public static void addChildren(ElementDef parent, NodeDef[] children) throws XOMException {
   if (parent instanceof GenericDef) {
     GenericDef xmlGeneric = (GenericDef) parent;
     for (int i = 0; i < children.length; i++) {
       xmlGeneric.addChild(children[i]);
     }
   } else if (parent instanceof Any) {
     Any any = (Any) parent;
     NodeDef[] currentChildren = any.getChildren();
     if (currentChildren == null) {
       if (children instanceof ElementDef[]) {
         currentChildren = new ElementDef[0];
       } else {
         currentChildren = new NodeDef[0];
       }
     }
     NodeDef[] newChildren = (NodeDef[]) concatenate(currentChildren, children);
     any.setChildren(newChildren);
   } else {
     // Use reflection. We presume that the children are stored in the
     // first array field.
     Field field = null;
     Field[] fields = parent.getClass().getFields();
     for (int i = 0; i < fields.length; i++) {
       if (fields[i].getType().isArray()) {
         field = fields[i];
         break;
       }
     }
     if (field == null) {
       throw new XOMException(
           "cannot add field to " + parent.getClass() + ": it has no array field");
     }
     try {
       Object[] a = (Object[]) field.get(parent);
       Object[] b = concatenate(a, children);
       field.set(parent, b);
     } catch (IllegalAccessException e) {
       throw new XOMException(e, "in XOMUtil.getChildren");
     }
   }
 }
  public void receive_request_service_contexts(ServerRequestInfo ri) {
    try {
      //
      // Test: get operation name
      //
      String op = ri.operation();

      boolean oneway = (op.equals("noargs_oneway"));

      //
      // Test: Arguments should not be available
      //
      try {
        org.omg.Dynamic.Parameter[] args = ri.arguments();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      // TODO: test operation_context

      //
      // Test: result is not available
      //
      try {
        Any result = ri.result();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: exceptions
      //
      try {
        TypeCode[] exceptions = ri.exceptions();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: response expected and oneway should be equivalent
      //
      TEST((oneway && !ri.response_expected()) || (!oneway && ri.response_expected()));

      // TODO: test sync scope

      //
      // Test: reply status is not available
      //
      try {
        ri.reply_status();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: forward reference is not available
      //
      try {
        org.omg.CORBA.Object ior = ri.forward_reference();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: object id is not available
      //
      try {
        byte[] id = ri.object_id();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: adapter id is not available
      //
      try {
        byte[] id = ri.adapter_id();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: servant_most_derived_interface is not available
      //
      try {
        String mdi = ri.target_most_derived_interface();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: server id is not available
      //
      try {
        String id = ri.server_id();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: orb id is not available
      //
      try {
        String id = ri.orb_id();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: adapter name is not available
      //
      try {
        String[] name = ri.adapter_name();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: servant_is_a is not available
      //
      try {
        ri.target_is_a("");
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      if (op.equals("test_service_context")) {
        //
        // Test: get_request_service_context
        //
        try {
          org.omg.IOP.ServiceContext sc = ri.get_request_service_context(REQUEST_CONTEXT_ID.value);
          TEST(sc.context_id == REQUEST_CONTEXT_ID.value);
          byte[] data = new byte[sc.context_data.length];
          System.arraycopy(sc.context_data, 0, data, 0, sc.context_data.length);

          Any any = null;
          try {
            any = cdrCodec_.decode_value(data, RequestContextHelper.type());
          } catch (org.omg.IOP.CodecPackage.FormatMismatch ex) {
            TEST(false);
          } catch (org.omg.IOP.CodecPackage.TypeMismatch ex) {
            TEST(false);
          }
          RequestContext context = RequestContextHelper.extract(any);
          TEST(context.data.equals("request"));
          TEST(context.val == 10);

          //
          // Test: PortableInterceptor::Current
          //
          Any slotData = orb_.create_any();
          slotData.insert_long(context.val);
          try {
            ri.set_slot(0, slotData);
          } catch (InvalidSlot ex) {
            TEST(false);
          }
        } catch (BAD_PARAM ex) {
          TEST(false);
        }

        //
        // Test: add_reply_service_context
        //
        ReplyContext context = new ReplyContext();
        context.data = "reply1";
        context.val = 101;
        Any any = orb_.create_any();
        ReplyContextHelper.insert(any, context);
        byte[] data = null;
        try {
          data = cdrCodec_.encode_value(any);
        } catch (org.omg.IOP.CodecPackage.InvalidTypeForEncoding ex) {
          TEST(false);
        }

        org.omg.IOP.ServiceContext sc = new org.omg.IOP.ServiceContext();
        sc.context_id = REPLY_CONTEXT_1_ID.value;
        sc.context_data = new byte[data.length];
        System.arraycopy(data, 0, sc.context_data, 0, data.length);

        try {
          ri.add_reply_service_context(sc, false);
        } catch (BAD_INV_ORDER ex) {
          TEST(false);
        }

        //
        // Test: add same context again (no replace)
        //
        try {
          ri.add_reply_service_context(sc, false);
          TEST(false);
        } catch (BAD_INV_ORDER ex) {
          // Expected
        }

        //
        // Test: add same context again (replace)
        //
        try {
          ri.add_reply_service_context(sc, true);
        } catch (BAD_INV_ORDER ex) {
          TEST(false);
        }

        //
        // Test: add second context
        //
        context.data = "reply4";
        context.val = 104;
        ReplyContextHelper.insert(any, context);
        try {
          data = cdrCodec_.encode_value(any);
        } catch (org.omg.IOP.CodecPackage.InvalidTypeForEncoding ex) {
          TEST(false);
        }

        sc.context_id = REPLY_CONTEXT_4_ID.value;
        sc.context_data = new byte[data.length];
        System.arraycopy(data, 0, sc.context_data, 0, data.length);

        // try
        // {
        ri.add_reply_service_context(sc, false);
        // }
        // catch(BAD_INV_ORDER ex)
        // {
        // TEST(false);
        // }
      } else {
        //
        // Test: get_request_service_context
        //
        try {
          org.omg.IOP.ServiceContext sc = ri.get_request_service_context(REQUEST_CONTEXT_ID.value);
          TEST(false);
        } catch (BAD_PARAM ex) {
          // Expected
        }
      }

      //
      // Test: get_reply_service_context
      //
      try {
        org.omg.IOP.ServiceContext sc = ri.get_reply_service_context(REPLY_CONTEXT_1_ID.value);
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: sending exception is not available
      //
      try {
        Any any = ri.sending_exception();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: get_server_policy
      //
      Policy policy = ri.get_server_policy(MY_SERVER_POLICY_ID.value);
      MyServerPolicy myServerPolicy = MyServerPolicyHelper.narrow(policy);
      TEST(myServerPolicy != null);
      TEST(myServerPolicy.value() == 10);

      try {
        policy = ri.get_server_policy(1013);
        TEST(false);
      } catch (INV_POLICY ex) {
        // Expected
      }
    } catch (test.common.TestException ex) {
      ex.printStackTrace();
      throw ex;
    }
  }
  public void send_exception(ServerRequestInfo ri) {
    try {
      //
      // Test: get operation name
      //
      String op = ri.operation();

      TEST(op.equals("systemexception") || op.equals("userexception") || op.equals("deactivate"));

      boolean user = op.equals("userexception");

      //
      // If "deactivate" then we're done
      //
      if (op.equals("deactivate")) return;

      //
      // Test: Arguments should not be available
      //
      try {
        org.omg.Dynamic.Parameter[] parameters = ri.arguments();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      // TODO: test operation_context

      //
      // Test: result is not available
      //
      try {
        Any result = ri.result();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: exceptions
      //
      try {
        TypeCode[] exceptions = ri.exceptions();
        if (op.equals("userexception")) {
          TEST(exceptions.length == 1);
          TEST(exceptions[0].equal(userHelper.type()));
        } else {
          TEST(exceptions.length == 0);
        }
      } catch (BAD_INV_ORDER ex) {
        TEST(false);
      } catch (NO_RESOURCES ex) {
        // Expected (if servant is DSI)
      }

      //
      // Test: response expected should be true
      //
      TEST(ri.response_expected());

      // TODO: test sync scope

      //
      // Test: reply status is available
      //
      if (user) TEST(ri.reply_status() == USER_EXCEPTION.value);
      else TEST(ri.reply_status() == SYSTEM_EXCEPTION.value);

      //
      // Test: forward reference is not available
      //
      try {
        org.omg.CORBA.Object ior = ri.forward_reference();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: get_request_service_context
      // Test: get_reply_service_context
      //
      testServiceContext(op, ri, false);

      //
      // Test: sending exception is available
      //
      try {
        Any any = ri.sending_exception();
        if (!user) {
          SystemException ex =
              org.apache.yoko.orb.OB.Util.unmarshalSystemException(any.create_input_stream());
        } else {
          user ex = userHelper.extract(any);
        }
      } catch (BAD_INV_ORDER ex) {
        TEST(false);
      } catch (NO_RESOURCES ex) // TODO: remove this!
      {
      }

      //
      // Test: object id is correct
      //
      byte[] oid = ri.object_id();
      TEST(
          (oid.length == 4 && (new String(oid)).equals("test"))
              || (oid.length == 7 && (new String(oid)).equals("testDSI")));

      //
      // Test: adapter id is correct (this is a tough one to test)
      //
      byte[] adapterId = ri.adapter_id();
      TEST(adapterId.length != 0);

      //
      // Test: target_most_derived_interface raises BAD_INV_ORDER
      //
      try {
        String mdi = ri.target_most_derived_interface();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: server id is correct
      //
      String serverId = ri.server_id();
      TEST(serverId.equals(""));

      //
      // Test: orb id is correct
      //
      String orbId = ri.orb_id();
      TEST(orbId.equals("myORB"));

      //
      // Test: adapter name is correct
      //
      String[] adapterName = ri.adapter_name();
      TEST(adapterName.length == 1 && adapterName[0].equals("persistent"));

      //
      // Test: target_is_a raises BAD_INV_ORDER
      //
      try {
        ri.target_is_a("IDL:TestInterface:1.0");
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: get_server_policy
      //
      Policy policy = ri.get_server_policy(MY_SERVER_POLICY_ID.value);
      MyServerPolicy myServerPolicy = MyServerPolicyHelper.narrow(policy);
      TEST(myServerPolicy != null);
      TEST(myServerPolicy.value() == 10);

      try {
        policy = ri.get_server_policy(1013);
        TEST(false);
      } catch (INV_POLICY ex) {
        // Expected
      }
    } catch (test.common.TestException ex) {
      ex.printStackTrace();
      throw ex;
    }
  }
Example #9
0
File: Sum.java Project: inqwell/inq
  public Any exec(Any a) throws AnyException {
    Transaction t = getTransaction();

    Composite sumRoot = (Composite) EvalExpr.evalFunc(t, a, sumRoot_, Composite.class);

    if (sumRoot == null) nullOperand(sumRoot_);

    Any expression = null;
    Any sum = null;
    Any tmp = null;
    Adder adder = null;

    if (takeAverage_ && sumRoot.entries() == 0) return null;

    Iter i = sumRoot.createIterator();

    Any loop = t.getLoop();

    try {
      while (i.hasNext()) {
        Any child = i.next();

        // Set $loop
        t.setLoop(child);

        // Lazy clone of expression
        if (expression == null) {
          expression = expression_.cloneAny();
        }

        if (sum == null) {
          sum = EvalExpr.evalFunc(t, a, expression);

          if (sum == null)
            throw new NullPointerException("Failed to resolve " + expression_ + "during summation");

          // To save on the creation of temporaries, the first sum
          // item is used as the prototype for the result.  The
          // remaining items, if not the same, must be convertible to it.
          adder = new Adder(sum);
          sum = adder.add(sum);
          tmp = sum.buildNew(null);
          adder.setTmp(tmp);
        } else {
          Any next = EvalExpr.evalFunc(t, a, expression);
          if (next == null)
            throw new NullPointerException("Failed to resolve " + expression_ + "during summation");

          adder.add(next);
        }

        // No point in continuing the iteration if we hit a null
        if (adder.isNull()) break;
      }

      if (adder != null && adder.isNull()) return AnyNull.instance();

      if (takeAverage_ && sum != null) return adder.doAvg(sum, sumRoot.entries());

      return sum == null ? AnyNull.instance() : sum;
    } finally {
      t.setLoop(loop);
    }
  }
Example #10
0
File: Sum.java Project: inqwell/inq
    private Any add(Any toAdd) {
      if (tmp_ != null) tmp_.copyFrom(toAdd); // here's where we get auto type conversion

      sum_.accept(this);
      return sum_;
    }
 /*    */ public static SetOverrideType extract(Any paramAny) /*    */ {
   /* 51 */ return read(paramAny.create_input_stream());
   /*    */ }
 /** Extract the Visibility from the given Any. Uses {@link Any#extract_short}. */
 public static short extract(Any any) {
   return any.extract_short();
 }
 /** Insert the Visibility into the given Any. Uses {@link Any#insert_short}. */
 public static void insert(Any any, short that) {
   any.insert_short(that);
 }
Example #14
0
  public synchronized void update(RtecEventComm.Event event) {

    // System.out.println ("in NavWeapDataHandler.update");

    Any any_value;
    PersianRecursion.Data persian_recursion_data;

    any_value = event.data.any_value;

    if (any_value.type().equal(PersianRecursion.DataHelper.type())) {
      //        System.out.println ("type matched PersianRecursion.Data");

      try {
        persian_recursion_data = PersianRecursion.DataHelper.extract(any_value);
      } catch (Exception e) {
        System.err.println(e.getMessage() + "\nThe stack trace is:\n");
        e.printStackTrace();
        return;
      }

      //       System.out.println ("extracted any");

      if (persian_recursion_data.criticality_level.equals(
              RtecScheduler.Criticality_t.HIGH_CRITICALITY)
          || persian_recursion_data.criticality_level.equals(
              RtecScheduler.Criticality_t.VERY_HIGH_CRITICALITY)) {
        //            System.out.println ("obtaining high priority persian recursion observable");

        PersianObservable pobs_hi =
            (PersianObservable) ObservablesTable.get("High Consumer Persian Recursion");

        //            System.out.println ("updating high priority persian recursion observable");

        pobs_hi.updatePersianData(persian_recursion_data);

        // LatencyObservable lobs_hi =
        // (LatencyObservable) ObservablesTable.get ("High Consumer Execution Time (100 ns)");

        // lobs_hi.updateLatency (persian_recursion_data.computation_time);
      } else {
        //            System.out.println ("obtaining low priority persian recursion observable");
        PersianObservable pobs_lo =
            (PersianObservable) ObservablesTable.get("Low Consumer Persian Recursion");

        //            System.out.println ("obtained low priority persian recursion observable");
        // System.out.println ("updating low priority persian recursion observable");

        pobs_lo.updatePersianData(persian_recursion_data);

        //            System.out.println ("updated low priority persian recursion observable");

        // LatencyObservable lobs_lo =
        // (LatencyObservable) ObservablesTable.get ("Low Consumer Execution Time (100 ns)");

        // lobs_lo.updateLatency (persian_recursion_data.computation_time);
      }

      //        System.out.println ("done updating PersianObservables");

      received_events_++;

      //        System.out.println ("total events received: " + received_events_);
    } else if (any_value.type().equal(NavigationHelper.type())) {
      Navigation navigation_ = NavigationHelper.extract(any_value);

      // if the navigation data structure's update data flag is set,
      // update its scheduling data with actual values from the EC
      if (navigation_.update_data > 0) {
        navigation_.arrival_time = event.header.creation_time;
        navigation_.completion_time = event.header.ec_send_time;
        navigation_.deadline_time += event.header.creation_time;
      }

      NavigationObservable nobs = (NavigationObservable) ObservablesTable.get("Navigation");
      nobs.updateNavigation(navigation_);
      Cpu_UsageObservable cobs = (Cpu_UsageObservable) ObservablesTable.get("CPU Usage");
      cobs.updateCpu_Usage(navigation_.utilization);
      OverheadObservable oobs = (OverheadObservable) ObservablesTable.get("Overhead");
      oobs.updateOverhead(navigation_.overhead);
      JitterObservable jobs = (JitterObservable) ObservablesTable.get("Latency Jitter (100 ns)");
      jobs.updateJitter(
          navigation_.completion_time, navigation_.computation_time, navigation_.arrival_time);
      JitterObservable njobs =
          (JitterObservable) ObservablesTable.get("Navigation Latency Jitter (100 ns)");
      njobs.updateJitter(
          navigation_.completion_time, navigation_.computation_time, navigation_.arrival_time);
      DeadlinesObservable dobs = (DeadlinesObservable) ObservablesTable.get("Missed Deadlines");
      dobs.updateDeadlines(navigation_.deadline_time, navigation_.completion_time);
      CriticalDeadlinesObservable cdobs =
          (CriticalDeadlinesObservable) ObservablesTable.get("Missed Critical Deadlines");
      cdobs.updateDeadlines(
          navigation_.deadline_time, navigation_.completion_time, navigation_.criticality);
      LatencyObservable lobs = (LatencyObservable) ObservablesTable.get("Latency (100 ns)");
      lobs.updateLatency(
          navigation_.completion_time, navigation_.computation_time, navigation_.arrival_time);
      LatencyObservable nlobs =
          (LatencyObservable) ObservablesTable.get("Navigation Latency (100 ns)");
      nlobs.updateLatency(
          navigation_.completion_time, navigation_.computation_time, navigation_.arrival_time);
      received_events_++;
    } else if (any_value.type().equal(WeaponsHelper.type())) {
      Weapons weapons_ = WeaponsHelper.extract(any_value);

      // if the weapons structure's update data flag is set, update
      // itss scheduling data with actual values from the EC
      if (weapons_.update_data > 0) {
        weapons_.arrival_time = event.header.creation_time;
        weapons_.completion_time = event.header.ec_send_time;
        weapons_.deadline_time += event.header.creation_time;
      }

      WeaponsObservable wobs = (WeaponsObservable) ObservablesTable.get("Weapons");
      ;
      wobs.updateWeapons(weapons_);
      Cpu_UsageObservable cobs = (Cpu_UsageObservable) ObservablesTable.get("CPU Usage");
      cobs.updateCpu_Usage(weapons_.utilization);
      OverheadObservable oobs = (OverheadObservable) ObservablesTable.get("Overhead");
      oobs.updateOverhead(weapons_.overhead);
      JitterObservable jobs = (JitterObservable) ObservablesTable.get("Latency Jitter (100 ns)");
      jobs.updateJitter(weapons_.completion_time, weapons_.computation_time, weapons_.arrival_time);
      JitterObservable wjobs =
          (JitterObservable) ObservablesTable.get("Weapons Latency Jitter (100 ns)");
      wjobs.updateJitter(
          weapons_.completion_time, weapons_.computation_time, weapons_.arrival_time);
      DeadlinesObservable dobs = (DeadlinesObservable) ObservablesTable.get("Missed Deadlines");
      dobs.updateDeadlines(weapons_.deadline_time, weapons_.completion_time);
      CriticalDeadlinesObservable cdobs =
          (CriticalDeadlinesObservable) ObservablesTable.get("Missed Critical Deadlines");
      cdobs.updateDeadlines(weapons_.deadline_time, weapons_.completion_time, weapons_.criticality);
      LatencyObservable lobs = (LatencyObservable) ObservablesTable.get("Latency (100 ns)");
      lobs.updateLatency(
          weapons_.completion_time, weapons_.computation_time, weapons_.arrival_time);
      LatencyObservable wlobs =
          (LatencyObservable) ObservablesTable.get("Weapons Latency (100 ns)");
      wlobs.updateLatency(
          weapons_.completion_time, weapons_.computation_time, weapons_.arrival_time);
      received_events_++;
    } else {
      System.out.println("Received wrong type information");

      System.out.println("Received any_value.type (): [" + any_value.type() + "]");

      System.out.println("Expected NavigationHelper.type (): [" + NavigationHelper.type() + "]");

      System.out.println("OR WeaponsHelper.type (): [" + WeaponsHelper.type() + "]");

      System.out.println(
          "OR PersianRecursion.DataHelper.type (): [" + PersianRecursion.DataHelper.type() + "]");
    }
  }
Example #15
0
 public static org.omg.CORBA.Object extract(Any any) {
   return any.extract_Object();
 }
  private void testArgs(ServerRequestInfo ri, boolean resultAvail) {
    String op = ri.operation();
    org.omg.Dynamic.Parameter[] args = ri.arguments();
    if (op.startsWith("_set_") || op.startsWith("_get_")) {
      boolean isstr; // struct or string?
      isstr = (op.indexOf("string") != -1);
      if (op.startsWith("_get_")) {
        TEST(args.length == 0);
        if (resultAvail) {
          //
          // Test: result
          //
          Any result = ri.result();
          if (isstr) {
            String str = result.extract_string();
            TEST(str.startsWith("TEST"));
          } else {
            s sp = sHelper.extract(result);
            TEST(sp.sval.startsWith("TEST"));
          }
        }
      } else {
        TEST(args.length == 1);
        TEST(args[0].mode == org.omg.CORBA.ParameterMode.PARAM_IN);
        if (resultAvail) {
          if (isstr) {
            String str = args[0].argument.extract_string();
            TEST(str.startsWith("TEST"));
          } else {
            s sp = sHelper.extract(args[0].argument);
            TEST(sp.sval.startsWith("TEST"));
          }
        }
      }
    } else if (op.startsWith("one_")) {
      String which = op.substring(4); // Which operation?
      boolean isstr; // struct or string?
      ParameterMode mode; // The parameter mode

      if (which.startsWith("string")) isstr = true;
      else
        // if which.startsWith("struct"))
        isstr = false;

      which = which.substring(7); // Skip <string|struct>_

      if (which.equals("return")) {
        TEST(args.length == 0);
        if (resultAvail) {
          //
          // Test: result
          //
          Any result = ri.result();
          if (isstr) {
            String str = result.extract_string();
            TEST(str.startsWith("TEST"));
          } else {
            s sp = sHelper.extract(result);
            TEST(sp.sval.startsWith("TEST"));
          }
        }
      } else {
        TEST(args.length == 1);
        if (which.equals("in")) mode = org.omg.CORBA.ParameterMode.PARAM_IN;
        else if (which.equals("inout")) mode = org.omg.CORBA.ParameterMode.PARAM_INOUT;
        else
          // if(which.equals("out"))
          mode = org.omg.CORBA.ParameterMode.PARAM_OUT;

        TEST(mode == args[0].mode);

        if (mode != org.omg.CORBA.ParameterMode.PARAM_OUT || resultAvail) {
          if (isstr) {
            String str = args[0].argument.extract_string();
            TEST(str.startsWith("TEST"));
          } else {
            s sp = sHelper.extract(args[0].argument);
            TEST(sp.sval.startsWith("TEST"));
          }

          if (resultAvail) {
            //
            // Test: result
            //
            Any result = ri.result();
            TypeCode tc = result.type();
            TEST(tc.kind() == TCKind.tk_void);
          }
        }
      }
    } else {
      TEST(args.length == 0);
    }

    if (!resultAvail) {
      //
      // Test: result is not available
      //
      try {
        Any result = ri.result();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }
    }
  }
  public void send_reply(ServerRequestInfo ri) {
    try {
      //
      // Test: get operation name
      //
      String op = ri.operation();

      //
      // If "deactivate" then we're done
      //
      if (op.equals("deactivate")) return;

      boolean oneway = op.equals("noargs_oneway");

      //
      // Test: Arguments should be available
      //
      testArgs(ri, true);

      // TODO: test operation_context

      //
      // Test: exceptions
      //
      try {
        TypeCode[] exceptions = ri.exceptions();
        if (op.equals("userexception")) {
          TEST(exceptions.length == 1);
          TEST(exceptions[0].equal(userHelper.type()));
        } else {
          TEST(exceptions.length == 0);
        }
      } catch (NO_RESOURCES ex) {
        // Expected (if servant is DSI)
      }

      //
      // Test: response expected and oneway should be equivalent
      //
      TEST((oneway && !ri.response_expected()) || (!oneway && ri.response_expected()));

      // TODO: test sync scope

      //
      // Test: reply status is available
      //
      TEST(ri.reply_status() == SUCCESSFUL.value);

      //
      // Test: forward reference is not available
      //
      try {
        org.omg.CORBA.Object ior = ri.forward_reference();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: get_request_service_context
      // Test: get_reply_service_context
      // Test: add_reply_service_context
      //
      testServiceContext(op, ri, true);

      //
      // Test: sending exception is not available
      //
      try {
        Any any = ri.sending_exception();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: object id is correct
      //
      byte[] oid = ri.object_id();
      TEST(
          (oid.length == 4 && (new String(oid)).equals("test"))
              || (oid.length == 7 && (new String(oid)).equals("testDSI")));

      //
      // Test: adapter id is correct (this is a tough one to test)
      //
      byte[] adapterId = ri.adapter_id();
      TEST(adapterId.length != 0);

      //
      // Test: target_most_derived_interface raises BAD_INV_ORDER
      //
      try {
        String mdi = ri.target_most_derived_interface();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: server id is correct
      //
      String serverId = ri.server_id();
      TEST(serverId.equals(""));

      //
      // Test: orb id is correct
      //
      String orbId = ri.orb_id();
      TEST(orbId.equals("myORB"));

      //
      // Test: adapter name is correct
      //
      String[] adapterName = ri.adapter_name();
      TEST(adapterName.length == 1 && adapterName[0].equals("persistent"));

      //
      // Test: target_is_a raises BAD_INV_ORDER
      //
      try {
        ri.target_is_a("IDL:TestInterface:1.0");
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: get_server_policy
      //
      Policy policy = ri.get_server_policy(MY_SERVER_POLICY_ID.value);
      MyServerPolicy myServerPolicy = MyServerPolicyHelper.narrow(policy);
      TEST(myServerPolicy != null);
      TEST(myServerPolicy.value() == 10);

      try {
        policy = ri.get_server_policy(1013);
        TEST(false);
      } catch (INV_POLICY ex) {
        // Expected
      }

      //
      // Test: get_slot
      //
      if (op.equals("test_service_context")) {
        int val;
        Any slotData = null;
        try {
          slotData = ri.get_slot(0);
        } catch (InvalidSlot ex) {
          TEST(false);
        }
        val = slotData.extract_long();
        TEST(val == 20);
      }
    } catch (test.common.TestException ex) {
      ex.printStackTrace();
      throw ex;
    }
  }
Example #18
0
 public Object clone() throws CloneNotSupportedException {
   Contains c = (Contains) super.clone();
   c.container_ = container_.cloneAny();
   c.contained_ = contained_.cloneAny();
   return c;
 }
Example #19
0
 public void visitUnknown(Any o) {
   result_ = getBooleanResult(o.equals(op2_));
 }
 /*    */ public static void insert(Any paramAny, SetOverrideType paramSetOverrideType) /*    */ {
   /* 43 */ OutputStream localOutputStream = paramAny.create_output_stream();
   /* 44 */ paramAny.type(type());
   /* 45 */ write(localOutputStream, paramSetOverrideType);
   /* 46 */ paramAny.read_value(localOutputStream.create_input_stream(), type());
   /*    */ }