public AdminPropertySet(Configuration config) { super(); try { int _maxConsumersDefault = config.getAttributeAsInteger( Attributes.MAX_NUMBER_CONSUMERS, Default.DEFAULT_MAX_NUMBER_CONSUMERS); Any _maxConsumersDefaultAny = sORB.create_any(); _maxConsumersDefaultAny.insert_long(_maxConsumersDefault); ////////////////////////////// int _maxSuppliersDefault = config.getAttributeAsInteger( Attributes.MAX_NUMBER_SUPPLIERS, Default.DEFAULT_MAX_NUMBER_SUPPLIERS); Any _maxSuppliersDefaultAny = sORB.create_any(); _maxSuppliersDefaultAny.insert_long(_maxSuppliersDefault); ////////////////////////////// int _maxQueueLength = config.getAttributeAsInteger( Attributes.MAX_QUEUE_LENGTH, Default.DEFAULT_MAX_QUEUE_LENGTH); Any _maxQueueLengthAny = sORB.create_any(); _maxQueueLengthAny.insert_long(_maxQueueLength); ////////////////////////////// boolean _rejectNewEvents = config .getAttribute(Attributes.REJECT_NEW_EVENTS, Default.DEFAULT_REJECT_NEW_EVENTS) .equals("on"); Any _rejectNewEventsAny = sORB.create_any(); _rejectNewEventsAny.insert_boolean(_rejectNewEvents); ////////////////////////////// defaultProperties_ = new Property[] { new Property(MaxConsumers.value, _maxConsumersDefaultAny), new Property(MaxSuppliers.value, _maxSuppliersDefaultAny), new Property(MaxQueueLength.value, _maxQueueLengthAny), new Property(RejectNewEvents.value, _rejectNewEventsAny) }; set_admin(defaultProperties_); } catch (ConfigurationException ex) { throw new INTERNAL("Configuration exception" + ex); } }
/** * 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()); }
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; } }