Policy[] origPolicies = pm.get_policy_overrides(policyTypes);
{
try {
Policy[] pl = new Policy[1];
Any any = orb.create_any();
any.insert_short(org.apache.yoko.orb.OB.RETRY_ALWAYS.value);
pl[0] = orb.create_policy(
org.apache.yoko.orb.OB.RETRY_POLICY_ID.value, any);
pm.set_policy_overrides(pl, SetOverrideType.ADD_OVERRIDE);
} catch (PolicyError ex) {
TEST(false);
} catch (InvalidPolicies ex) {
TEST(false);
}
policyTypes = new int[1];
policyTypes[0] = org.apache.yoko.orb.OB.RETRY_POLICY_ID.value;
Policy[] policy = pm.get_policy_overrides(policyTypes);
TEST(policy.length == 1
&& policy[0].policy_type() == org.apache.yoko.orb.OB.RETRY_POLICY_ID.value);
RetryPolicy p = RetryPolicyHelper.narrow(policy[0]);
TEST(p.retry_mode() == org.apache.yoko.orb.OB.RETRY_ALWAYS.value);
}
{
try {
Policy[] pl = new Policy[2];
Any any = orb.create_any();
any.insert_short(org.apache.yoko.orb.OB.RETRY_STRICT.value);
pl[0] = orb.create_policy(
org.apache.yoko.orb.OB.RETRY_POLICY_ID.value, any);
any = orb.create_any();
any.insert_ulong(3000);
pl[1] = orb.create_policy(
org.apache.yoko.orb.OB.TIMEOUT_POLICY_ID.value, any);
pm.set_policy_overrides(pl, SetOverrideType.ADD_OVERRIDE);
} catch (PolicyError ex) {
TEST(false);
} catch (InvalidPolicies ex) {
TEST(false);
}
policyTypes = new int[2];
policyTypes[0] = org.apache.yoko.orb.OB.RETRY_POLICY_ID.value;
policyTypes[1] = org.apache.yoko.orb.OB.TIMEOUT_POLICY_ID.value;
Policy[] policies = pm.get_policy_overrides(policyTypes);
TEST(policies.length == 2);
for (int i = 0; i < policies.length; ++i) {
switch (policies[i].policy_type()) {
case org.apache.yoko.orb.OB.RETRY_POLICY_ID.value: {
try {
RetryPolicy policy = RetryPolicyHelper
.narrow(policies[i]);
TEST(policy != null);
TEST(policy.retry_mode() == org.apache.yoko.orb.OB.RETRY_STRICT.value);
} catch (BAD_PARAM ex) {
TEST(false);
}
break;
}
case org.apache.yoko.orb.OB.TIMEOUT_POLICY_ID.value: {
try {
TimeoutPolicy policy = TimeoutPolicyHelper
.narrow(policies[i]);
TEST(policy != null);
TEST(policy.value() == 3000);
} catch (BAD_PARAM ex) {
TEST(false);
}
break;
}
default:
TEST(("org.omg.CORBA.PolicyManager.get_policy_overrides()"
+ " returned policies with unexpected types") == null);
}
}
}
{
try {
Any any = orb.create_any();
any.insert_short(org.apache.yoko.orb.OB.RETRY_ALWAYS.value);
Policy[] pl = new Policy[2];
pl[0] = orb.create_policy(
org.apache.yoko.orb.OB.RETRY_POLICY_ID.value, any);
pl[1] = orb.create_policy(
org.apache.yoko.orb.OB.RETRY_POLICY_ID.value, any);