Package net.jini.core.constraint

Examples of net.jini.core.constraint.InvocationConstraint


            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);
            String result = md.getName();
            if (testCase == case1arg) {
View Full Code Here


        for (int i = 0; i < cases.length; ++i) {
            int testCase = cases[i];
            logger.log(Level.INFO, "--> " + testCase);
            String name = "someMethod";
            Class[] types = new Class[] {int.class, Object.class};
            InvocationConstraint ic = Delegation.YES;
            InvocationConstraints constraints = new InvocationConstraints(
                    ic, null);
            MethodDesc md = null;
            Class[] returnedTypes = null;
           
View Full Code Here

            logger.log(Level.INFO, "--> " + testCase);
           
            // 1
            String name1 = "someMethod";
            Class[] types1 = new Class[] {int.class, Object.class};
            InvocationConstraint ic = Delegation.YES;
            InvocationConstraints constraints1 = new InvocationConstraints(
                    ic, null);
            String name2 = "someMethod";
            Class[] types2 = new Class[] {int.class, Object.class};
            InvocationConstraints constraints2 = new InvocationConstraints(
                    ic, null);
            MethodDesc md1 = callConstructor(testCase, name1, types1,
                    constraints1);
            MethodDesc md2 = callConstructor(testCase, name2, types2,
                    constraints2);
            if (!md1.equals(md2)) {
                throw new TestException(
                        "MethodDesc objects should be equal");
            }
           
            // 2
            if ((testCase == case2arg) || (testCase == case3arg)) {
                String name2diff = "anotherMethod";
                md1 = callConstructor(testCase, name1, types1,
                        constraints1);
                md2 = callConstructor(testCase, name2diff, types2,
                        constraints2);
                if (md1.equals(md2)) {
                    throw new TestException(
                            "MethodDesc objects should not be equal");
                }
            }
           
            // 3
            if (testCase == case3arg) {
                Class[] types2diff = new Class[] {long.class, Object.class};
                md1 = callConstructor(testCase, name1, types1,
                        constraints1);
                md2 = callConstructor(testCase, name2, types2diff,
                        constraints2);
                if (md1.equals(md2)) {
                    throw new TestException(
                            "MethodDesc objects should not be equal");
                }
            }
           
            // 4
            if ((testCase == case2arg) || (testCase == case3arg)) {
                InvocationConstraint ic2diff = Delegation.NO;
                InvocationConstraints constraints2diff =
                        new InvocationConstraints(ic2diff, null);
                Class[] types2diff = new Class[] {long.class, Object.class};
                md1 = callConstructor(testCase, name1, types1,
                        constraints1);
View Full Code Here

                || tc == CL_MAX_PR_TYPE__ARRAY
                || tc == CL_MIN_PR_TYPE__ARRAY) {
            cl_copy = new Class[cl.length];
            System.arraycopy(cl, 0, cl_copy, 0, cl.length);
        }
        InvocationConstraint ic = null;

        try {
            if (       tc == CL_MAX_PR_TYPE__CLASS
                    || tc == CL_MAX_PR_TYPE__CLASS__NULL) {
                // Invoking ClientMaxPrincipalType(Class clazz) constructor
                ic = new ClientMaxPrincipalType((Class) cl[0]);
            } else if (tc == CL_MIN_PR_TYPE__CLASS
                    || tc == CL_MIN_PR_TYPE__CLASS__NULL) {
                // Invoking ClientMinPrincipalType(Class clazz) constructor
                ic = new ClientMinPrincipalType((Class) cl[0]);
            } else if (tc == CL_MAX_PR_TYPE__ARRAY
                    || tc == CL_MAX_PR_TYPE__ARRAY__NULL
                    || tc == CL_MAX_PR_TYPE__ARRAY__NULL_EL
                    || tc == CL_MAX_PR_TYPE__ARRAY__EMPTY
                    || tc == CL_MAX_PR_TYPE__ARRAY__PRIM_TYPE
                    || tc == CL_MAX_PR_TYPE__ARRAY__ARRAY_TYPE
                    || tc == CL_MAX_PR_TYPE__ARRAY__NOT_PRINCIPAL) {
                // Invoking ClientMaxPrincipalType(Class[] classes) constructor
                ic = new ClientMaxPrincipalType((Class[]) cl);
            } else if (tc == CL_MIN_PR_TYPE__ARRAY
                    || tc == CL_MIN_PR_TYPE__ARRAY__NULL
                    || tc == CL_MIN_PR_TYPE__ARRAY__NULL_EL
                    || tc == CL_MIN_PR_TYPE__ARRAY__EMPTY
                    || tc == CL_MIN_PR_TYPE__ARRAY__PRIM_TYPE
                    || tc == CL_MIN_PR_TYPE__ARRAY__ARRAY_TYPE
                    || tc == CL_MIN_PR_TYPE__ARRAY__NOT_PRINCIPAL) {
                // Invoking ClientMinPrincipalType(Class[] classes) constructor
                ic = new ClientMinPrincipalType((Class[]) cl);
            }

            // If some Exception is expected
            if (       tc == CL_MAX_PR_TYPE__CLASS__NULL
                    || tc == CL_MIN_PR_TYPE__CLASS__NULL
                    || tc == CL_MAX_PR_TYPE__ARRAY__NULL
                    || tc == CL_MAX_PR_TYPE__ARRAY__NULL_EL
                    || tc == CL_MAX_PR_TYPE__ARRAY__EMPTY
                    || tc == CL_MAX_PR_TYPE__ARRAY__PRIM_TYPE
                    || tc == CL_MAX_PR_TYPE__ARRAY__ARRAY_TYPE
                    || tc == CL_MAX_PR_TYPE__ARRAY__NOT_PRINCIPAL
                    || tc == CL_MIN_PR_TYPE__ARRAY__NULL
                    || tc == CL_MIN_PR_TYPE__ARRAY__NULL_EL
                    || tc == CL_MIN_PR_TYPE__ARRAY__EMPTY
                    || tc == CL_MIN_PR_TYPE__ARRAY__PRIM_TYPE
                    || tc == CL_MIN_PR_TYPE__ARRAY__ARRAY_TYPE
                    || tc == CL_MIN_PR_TYPE__ARRAY__NOT_PRINCIPAL) {
                logger.log(Level.FINE, "Expected Exception type:: " + ex);
                throw new TestException("Instead of " + ex + " no Exception"
                        + " has been thrown while invoking constructor");
            }
        } catch (Exception e) {
            logger.log(Level.FINE, "Exception while invoking constructor " + e);
            // If no Exception is expected
            if (       tc == CL_MAX_PR_TYPE__CLASS
                    || tc == CL_MIN_PR_TYPE__CLASS
                    || tc == CL_MAX_PR_TYPE__ARRAY
                    || tc == CL_MIN_PR_TYPE__ARRAY) {
                throw new TestException("Exception while invoking constructor ",
                        e);
            }

            // If some Exception is expected
            if (!ex.equals(e.getClass())) {
                logger.log(Level.FINE, "Expected Exception:: " + ex);
                logger.log(Level.FINE, "Thrown   Exception:: " + e.getClass());
                throw new TestException("Instead of " + ex + " "
                        + e.getClass() + " has been thrown while"
                        + " invoking constructor");
            } else {
                return;
            }
        }

        // logger.log(Level.INFO, "Returned object: " + ic.toString());

        /*
         * Verify that the corresponding constraint object is created.
         */
        if (ic == null) {
            logger.log(Level.FINE, "Constraint object hasn't been created");
            throw new TestException("Constraint object hasn't been created");
        }

        if (       (tc == CL_MAX_PR_TYPE__CLASS
                 || tc == CL_MAX_PR_TYPE__ARRAY)
                && !(ic instanceof ClientMaxPrincipalType)) {
            logger.log(Level.FINE,
                    "Instead of ClientMaxPrincipalType " + ic.getClass()
                    + " object is returned");
            throw new TestException("Instead of ClientMaxPrincipalType "
                    + ic.getClass() + " object is returned");
        } else if ((tc == CL_MIN_PR_TYPE__CLASS
                 || tc == CL_MIN_PR_TYPE__ARRAY)
                && !(ic instanceof ClientMinPrincipalType)) {
            logger.log(Level.FINE,
                    "Instead of ClientMinPrincipalType " + ic.getClass()
                    + " object is returned");
            throw new TestException("Instead of ClientMinPrincipalType "
                    + ic.getClass() + " object is returned");
        }

        /*
         * Verify that the argument passed to the constructor isn't modified.
         * Compare argument for the constructor before and after invoking the
         * constructor.
         */

        // logger.log(Level.INFO, "Argument before invoking the constructor:");
        // for (int i = 0; i < cl_copy.length; i++) {
        // logger.log(Level.INFO, "cl_copy[" + i + "]:: " + cl_copy[i]);
        // }
        // logger.log(Level.INFO, "Argument after invoking the constructor :");
        // for (int i = 0; i < cl.length; i++) {
        // logger.log(Level.INFO, "cl[" + i + "]:: " + cl[i]);
        // }
        if (!Arrays.equals(cl, cl_copy)) {
            logger.log(Level.FINE,
                    "The argument passed to the constructor is modified");
            throw new TestException("The argument passed to the constructor"
                    + " is modified");
        }
        logger.log(Level.FINE,
                "The argument passed to the constructor isn't modified");

        /*
         * Verify that the argument passed to the constructor isn't retained;
         * subsequent changes to that argument have no effect on the instance
         * created. Compare set of all of the classes from the created
         * object before and after changing the argument.
         */
        Set icSet_before = null;

        try {
            Class icClass = ic.getClass();
            Method elementsMethod = icClass.getMethod("elements", null);
            // Get set of classes from the created constraint
            icSet_before = (Set) elementsMethod.invoke(ic, null);

            /*
 
View Full Code Here

        ArrayList cl_copy = null;
        if (       tc == CL_MAX_PR_TYPE__COLL
                || tc == CL_MIN_PR_TYPE__COLL) {
            cl_copy = new ArrayList(cl);
        }
        InvocationConstraint ic = null;

        try {
            if (       tc == CL_MAX_PR_TYPE__COLL
                    || tc == CL_MAX_PR_TYPE__COLL__NULL
                    || tc == CL_MAX_PR_TYPE__COLL__NULL_EL
                    || tc == CL_MAX_PR_TYPE__COLL__EMPTY
                    || tc == CL_MAX_PR_TYPE__COLL__ILL_EL
                    || tc == CL_MAX_PR_TYPE__COLL__PRIM_TYPE
                    || tc == CL_MAX_PR_TYPE__COLL__ARRAY_TYPE
                    || tc == CL_MAX_PR_TYPE__COLL__NOT_PRINCIPAL) {
                // Invoking ClientMaxPrincipalType(Collection classes) constructor
                ic = new ClientMaxPrincipalType((Collection) cl);
            } else if (tc == CL_MIN_PR_TYPE__COLL
                    || tc == CL_MIN_PR_TYPE__COLL__NULL
                    || tc == CL_MIN_PR_TYPE__COLL__NULL_EL
                    || tc == CL_MIN_PR_TYPE__COLL__EMPTY
                    || tc == CL_MIN_PR_TYPE__COLL__ILL_EL
                    || tc == CL_MIN_PR_TYPE__COLL__PRIM_TYPE
                    || tc == CL_MIN_PR_TYPE__COLL__ARRAY_TYPE
                    || tc == CL_MIN_PR_TYPE__COLL__NOT_PRINCIPAL) {
                // Invoking ClientMinPrincipalType(Collection classes) constructor
                ic = new ClientMinPrincipalType((Collection) cl);
            }

            // If some Exception is expected
            if (       tc == CL_MAX_PR_TYPE__COLL__NULL
                    || tc == CL_MAX_PR_TYPE__COLL__NULL_EL
                    || tc == CL_MAX_PR_TYPE__COLL__EMPTY
                    || tc == CL_MAX_PR_TYPE__COLL__ILL_EL
                    || tc == CL_MAX_PR_TYPE__COLL__PRIM_TYPE
                    || tc == CL_MAX_PR_TYPE__COLL__ARRAY_TYPE
                    || tc == CL_MAX_PR_TYPE__COLL__NOT_PRINCIPAL
                    || tc == CL_MIN_PR_TYPE__COLL__NULL
                    || tc == CL_MIN_PR_TYPE__COLL__NULL_EL
                    || tc == CL_MIN_PR_TYPE__COLL__EMPTY
                    || tc == CL_MIN_PR_TYPE__COLL__ILL_EL
                    || tc == CL_MIN_PR_TYPE__COLL__PRIM_TYPE
                    || tc == CL_MIN_PR_TYPE__COLL__ARRAY_TYPE
                    || tc == CL_MIN_PR_TYPE__COLL__NOT_PRINCIPAL) {
                logger.log(Level.FINE, "Expected Exception type:: " + ex);
                throw new TestException("Instead of " + ex + " no Exception"
                        + " has been thrown while invoking constructor");
            }
        } catch (Exception e) {
            logger.log(Level.FINE, "Exception while invoking constructor: " + e);
            // If no Exception is expected
            if (       tc == CL_MAX_PR_TYPE__COLL
                    || tc == CL_MIN_PR_TYPE__COLL) {
                throw new TestException(
                        "Exception while invoking constructor", e);
            }

            // If some Exception is expected
            if (!ex.equals(e.getClass())) {
                logger.log(Level.FINE, "Expected Exception:: " + ex);
                logger.log(Level.FINE, "Thrown   Exception:: " + e.getClass());
                throw new TestException("Instead of " + ex + " "
                        + e.getClass() + " has been thrown while"
                        + " invoking constructor");
            } else {
                return;
            }
        }

        // logger.log(Level.INFO, "Returned object: " + ic.toString());

        /*
         * Verify that the corresponding constraint object is created.
         */
        if (ic == null) {
            logger.log(Level.FINE, "Constraint object hasn't been created");
            throw new TestException("Constraint object hasn't been created");
        }

        if (       tc == CL_MAX_PR_TYPE__COLL
                && !(ic instanceof ClientMaxPrincipalType)) {
            logger.log(Level.FINE,
                    "Instead of ClientMaxPrincipalType " + ic.getClass()
                    + " object is returned");
            throw new TestException("Instead of ClientMaxPrincipalType "
                    + ic.getClass() + " object is returned");
        } else if (tc == CL_MIN_PR_TYPE__COLL
                && !(ic instanceof ClientMinPrincipalType)) {
            logger.log(Level.FINE,
                    "Instead of ClientMinPrincipalType " + ic.getClass()
                    + " object is returned");
            throw new TestException("Instead of ClientMinPrincipalType "
                    + ic.getClass() + " object is returned");
        }

        /*
         * Verify that the argument passed to the constructor isn't modified.
         * Compare argument for the constructor before and after invoking the
         * constructor.
         */

        // logger.log(Level.INFO, "Argument before invoking the constructor: "
        // + cl_copy);
        // logger.log(Level.INFO, "Argument after invoking the constructor : "
        // + cl);
        if (!cl.equals(cl_copy)) {
            logger.log(Level.FINE,
                    "The argument passed to the constructor is modified");
            throw new TestException("The argument passed to the constructor"
                    + " is modified");
        }
        logger.log(Level.FINE,
                "The argument passed to the constructor isn't modified");

        /*
         * Verify that the argument passed to the constructor isn't retained;
         * subsequent changes to that argument have no effect on the instance
         * created. Compare set of all of the classes from the created
         * object before and after changing the argument.
         */
        Set icSet_before = null;

        try {
            Class icClass = ic.getClass();
            Method elementsMethod = icClass.getMethod("elements", null);
            // Get set of classes from the created constraint
            icSet_before = (Set) elementsMethod.invoke(ic, null);

            /*
 
View Full Code Here

            /*
             * Try to call the constructor
             */
            long retTime = (long) -1;
            InvocationConstraint constraint = null;

            try {
               
                if (       constructorType == CONNECTION_ABSOLUTE_TIME) {
                    constraint = new ConnectionAbsoluteTime(argument);
View Full Code Here

                    "Expected type of exception:: " + expExceptionClass);

            /*
             * Try to call the constructor
             */
            InvocationConstraint constraint = null;

            try {
               
                if (       constructorType == DELEGATION_ABSOLUTE_TIME__DATE) {
                    Date minStartDate = (minStart == Long.MIN_VALUE) ?
                                        null : new Date(minStart);
                    Date maxStartDate = (maxStart == Long.MIN_VALUE) ?
                                        null : new Date(maxStart);
                    Date minStopDate = (minStop == Long.MIN_VALUE) ?
                                        null : new Date(minStop);
                    Date maxStopDate  = (maxStop == Long.MIN_VALUE) ?
                                        null : new Date(maxStop);
                    logger.log(Level.FINE,"\tminStart:: " + minStartDate);
                    logger.log(Level.FINE,"\tmaxStart:: " + maxStartDate);
                    logger.log(Level.FINE,"\tminStop :: " + minStopDate);
                    logger.log(Level.FINE,"\tmaxStop :: " + maxStopDate);
                    constraint = new DelegationAbsoluteTime(minStartDate,
                                                            maxStartDate,
                                                            minStopDate,
                                                            maxStopDate);
                } else if (constructorType == DELEGATION_ABSOLUTE_TIME__LONG) {
                    constraint = new DelegationAbsoluteTime(minStart, maxStart,
                                                            minStop, maxStop);
                } else if (constructorType == DELEGATION_RELATIVE_TIME__LONG) {
                    constraint = new DelegationRelativeTime(minStart, maxStart,
                                                            minStop, maxStop);
                }
                logger.log(Level.INFO, "Created constraint: " + constraint);
            } catch (Exception e) {
                logger.log(Level.FINE,
                        "Exception while invoking the constructor: " + e);
                // If no exception is expected
                if (expExceptionClass == null) {
                    throw new TestException("No exception is expected, but"
                            + " really " + e + " exception has been thrown"
                            + " while invoking the constructor");
                }

                // An exception is expected
                if (!(e.getClass()).equals(expExceptionClass)) {
                    throw new TestException("Instead of exception of "
                            + expExceptionClass + " exception of " + e.getClass()
                            + " has been thrown");
                }
                return;
            }

            // If an exception is expected
            if (expExceptionClass != null) {
                throw new TestException("Exception of type "
                        + expExceptionClass + " is expected, but really no"
                        + " exception has been thrown while invoking the"
                        + " constructor");
            }

            // No exception is expected
            try {
                Class cl = constraint.getClass();
                Method getMinStartMethod = cl.getMethod("getMinStart", null);
                Method getMaxStartMethod = cl.getMethod("getMaxStart", null);
                Method getMinStopMethod = cl.getMethod("getMinStop", null);
                Method getMaxStopMethod = cl.getMethod("getMaxStop", null);
                // Get the values from the created constraint and verify them
View Full Code Here

  if (constraints == null) {
      return;
  }
  for (Iterator i = constraints.requirements().iterator(); i.hasNext(); )
  {
      InvocationConstraint c = (InvocationConstraint) i.next();
      if (!supported(c)) {
    throw new UnsupportedConstraintException(
            "unsupported constraint: " + c);
      }
  }
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

    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

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.