Package net.jini.core.constraint

Examples of net.jini.core.constraint.InvocationConstraint


      boolean supported = false;
      long maxConnectDeadline = Long.MIN_VALUE;
      Collection unfulfilledAlts = null; // lazily created
      boolean forgetUnfulfilled = false;
      for (Iterator i = alts.iterator(); i.hasNext();) {
    InvocationConstraint c = (InvocationConstraint) i.next();

    // nested ConstraintAlternatives not allowed
    int support = getSupport(c);
    if (support == NO_SUPPORT ||
        (!relativeOK && c instanceof RelativeTimeConstraint))
View Full Code Here


  throws UnsupportedConstraintException
    {
  boolean integrity = false;
  for (Iterator i = constraints.requirements().iterator(); i.hasNext(); )
  {
      InvocationConstraint c = (InvocationConstraint) i.next();
      if (c == Integrity.YES) {
    integrity = true;
      } else if (!(c instanceof Integrity)) {
    throw new UnsupportedConstraintException(
        "cannot satisfy constraint: " + c);
View Full Code Here

      boolean supported = false;
      long maxConnectDeadline = Long.MIN_VALUE;
      Collection unfulfilledAlts = null; // lazily created
      boolean forgetUnfulfilled = false;
      for (Iterator i = alts.iterator(); i.hasNext();) {
    InvocationConstraint c = (InvocationConstraint) i.next();

    // nested ConstraintAlternatives not allowed
    int support = getSupport(c);
    if (support == NO_SUPPORT ||
        (!relativeOK && c instanceof RelativeTimeConstraint))
View Full Code Here

    public void run() throws Exception {
        logger.log(Level.INFO, "======================================");
       
        // 1
        String name = "someMethod";
        InvocationConstraint ic = Delegation.YES;
        InvocationConstraints constraints = new InvocationConstraints(
                ic, null);
        MethodDesc methodDesc1 = new MethodDesc(name, constraints);
        MethodDesc methodDesc2 = new MethodDesc(constraints);
        MethodDesc [] descs = {methodDesc1, methodDesc2};
        BasicMethodConstraints bmc1 = new BasicMethodConstraints(descs);
        BasicMethodConstraints bmc2 = new BasicMethodConstraints(descs);
        if (!bmc1.equals(bmc2)) {
            throw new TestException(
                    "equals method should return true");
        }
       
        // 2
        bmc1 = new BasicMethodConstraints(constraints);
        bmc2 = new BasicMethodConstraints(constraints);
        if (!bmc1.equals(bmc2)) {
            throw new TestException(
                    "equals method should return true");
        }
       
        // 3
        MethodDesc [] simpleDescs = {methodDesc2};
        bmc1 = new BasicMethodConstraints(constraints);
        bmc2 = new BasicMethodConstraints(simpleDescs);
        if (!bmc1.equals(bmc2) || !bmc2.equals(bmc1)) {
            throw new TestException(
                    "equals method should return true");
        }
       
        // 4
        String name2 = "someDifferentMethod";
        MethodDesc methodDesc3 = new MethodDesc(name2, constraints);
        MethodDesc [] descs2 = {methodDesc3, methodDesc2};
        bmc1 = new BasicMethodConstraints(descs);
        bmc2 = new BasicMethodConstraints(descs2);
        if (bmc1.equals(bmc2)) {
            throw new TestException(
                    "equals method should return false");
        }
       
        // 5
        InvocationConstraint ic2 = Integrity.YES;
        InvocationConstraints constraints2 = new InvocationConstraints(
                ic2, null);
        bmc1 = new BasicMethodConstraints(constraints);
        bmc2 = new BasicMethodConstraints(constraints2);
        if (bmc1.equals(bmc2)) {
View Full Code Here

        // Testing ConstraintAlternatives.create(Collection) method
        logger.log(Level.FINE,
                "+++ Testing ConstraintAlternatives.create(Collection) ...");

        try {
            InvocationConstraint res = ConstraintAlternatives.create(argC);
            logger.log(Level.FINE, "Returned InvocationConstraint:: " + res);
           
            // Compare with the expected InvocationConstraint object
            if (!res.equals(ic)) {
                logger.log(Level.FINE,
                        "Returned InvocationConstraint object"
                        + " isn't equal to the expected one!");
                return false;
            }

            // Verify that the argument hasn't been modified
            if (!argC.equals(c)) {
                logger.log(Level.FINE, "The argument has been modified!");
                return false;
            }

            // Verify that the argument isn't retained, i.e. subsequent changes
            // to the argument have no effect on the instance created
            argC.clear();

            if (!res.equals(ic)) {
                logger.log(Level.FINE,
                        "The argument is retained, i.e. subsequent changes to"
                        + " the argument have an effect on the instance"
                        + " created");
                return false;
            }
        } catch (Exception e) {
            logger.log(Level.FINE,
                    "Exception has been thrown while invoking"
                    + " ConstraintAlternatives.create(Collection) method: "
                    + e);
            return false;
        }

        // Testing ConstraintAlternatives.create(InvocationConstraint[]) method
        logger.log(Level.FINE,
                "+++ Testing"
                + " ConstraintAlternatives.create(InvocationConstraint[]) ...");

        try {
            InvocationConstraint res = ConstraintAlternatives.create(argA);
            logger.log(Level.FINE, "Returned InvocationConstraint:: " + res);
           
            // Compare with the expected InvocationConstraint object
            if (!res.equals(ic)) {
                logger.log(Level.FINE,
                        "Returned InvocationConstraint object"
                        + " isn't equal to the expected one!");
                return false;
            }

            // Verify that the argument hasn't been modified
            if (!Arrays.equals(argA, argACopy)) {
                logger.log(Level.FINE, "The argument has been modified!");
                return false;
            }

            // Verify that the argument isn't retained, i.e. subsequent changes
            // to the argument have no effect on the instance created
            Arrays.fill(argA, null);

            if (!res.equals(ic)) {
                logger.log(Level.FINE,
                        "The argument is retained, i.e. subsequent changes to"
                        + " the argument have an effect on the instance"
                        + " created");
                return false;
View Full Code Here

    public void run() throws Exception {
        logger.log(Level.INFO, "======================================");
       
        // 1
        String name = "someMethod";
        InvocationConstraint ic = Delegation.YES;
        InvocationConstraints constraints = new InvocationConstraints(
                ic, null);
        MethodDesc methodDesc1 = new MethodDesc(name, constraints);
        MethodDesc methodDesc2 = new MethodDesc(constraints);
        MethodDesc [] descs = {methodDesc1, methodDesc2};
View Full Code Here

            logger.log(Level.INFO, "--> " + testCase);
           
            // 1
            String name = "someMethod";
            Class[] types = new Class[] {int.class, Object.class};
            InvocationConstraint ic = Delegation.YES;
            InvocationConstraints constraints = new InvocationConstraints(
                    ic, null);
            MethodDesc md = callConstructor(testCase, name, types, constraints);
            md.hashCode();
           
View Full Code Here

         * subsequent changes to that argument have no effect on the instance
         * created. Create ConstraintAlternatives object using create() method
         * and compare it with the ConstraintAlternatives object created with
         * constructor.
         */
        InvocationConstraint constraintBefore = null;

        try {
            constraintBefore =
                    ConstraintAlternatives.create((InvocationConstraint[]) ic);
        } catch (Exception e) {
View Full Code Here

         * subsequent changes to that argument have no effect on the instance
         * created. Create ConstraintAlternatives object using create() method
         * and compare it with the ConstraintAlternatives object created with
         * constructor.
         */
        InvocationConstraint constraintBefore = null;

        try {
            constraintBefore = ConstraintAlternatives.create((Collection) c);
        } catch (Exception e) {
            throw new TestException("Exception is thrown while invoking"
View Full Code Here

            logger.log(Level.INFO, "--> " + testCase);
           
            // 1
            String name = "someMethod";
            Class[] types = new Class[] {int.class, Object.class};
            InvocationConstraint ic = Delegation.YES;
            InvocationConstraints constraints = new InvocationConstraints(
                    ic, null);
            MethodDesc md = callConstructor(testCase, name, types, constraints);
            InvocationConstraints resultConstraints = md.getConstraints();
            if (!resultConstraints.equals(constraints)) {
View Full Code Here

TOP

Related Classes of net.jini.core.constraint.InvocationConstraint

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.