Package net.jini.constraint.BasicMethodConstraints

Examples of net.jini.constraint.BasicMethodConstraints.MethodDesc


    static MethodDesc desc(String n) {
  return new MethodDesc(n, sc);
    }

    static MethodDesc desc(String n, Class[] t) {
  return new MethodDesc(n, t, sc);
    }
View Full Code Here


  match(m, desc("length"));
  match(m, desc("*length"));
  match(m, desc("length*"));
  match(m, desc("*th"));
  match(m, desc("le*"));
  match(m, new MethodDesc(sc));
  nomatch(m, desc("lengt", new Class[0]));
  nomatch(m, desc("ength", new Class[0]));
  nomatch(m, desc("length", new Class[]{String.class}));
  nomatch(m, desc("get*"));
  nomatch(m, desc("*bar"));
  Class[] t = new Class[]{int.class, String.class, int.class, int.class};
  m = String.class.getMethod("regionMatches", t);
  match(m, desc("regionMatches", t));
  match(m, desc("regionMatches"));
  match(m, desc("*Matches"));
  match(m, desc("region*"));
  match(m, new MethodDesc(sc));
  nomatch(m, desc("regionMatches", new Class[0]));
  nomatch(m, desc("regionMatches",
      new Class[]{boolean.class, String.class,
            int.class, int.class}));
    }
View Full Code Here

        // 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(
View Full Code Here

        // 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};
        new BasicMethodConstraints(descs);

        // 2
        MethodDesc [] storedDescs = {methodDesc1, methodDesc2};
        MethodDesc [] passedDescs = {methodDesc1, methodDesc2};
        new BasicMethodConstraints(passedDescs);
        for (int j = 0; j < passedDescs.length; ++j) {
            if (storedDescs[j] != passedDescs[j]) {
                throw new TestException(
                        "MethodDesc array was modified");
            }
        }

        // 3
        String name2 = "*someMethod";
        MethodDesc methodDesc3 = new MethodDesc(name2, constraints);
        MethodDesc [] descs1 = {methodDesc1, methodDesc2};
        MethodDesc [] descs2 = {methodDesc1, methodDesc2};
        BasicMethodConstraints bmc1 = new BasicMethodConstraints(descs1);
        BasicMethodConstraints bmc2 = new BasicMethodConstraints(descs2);
        descs2[1] = methodDesc3;
View Full Code Here

                new InvocationConstraints(Integrity.YES, null),
                new InvocationConstraints(Delegation.YES, null),
                new InvocationConstraints(Integrity.NO, null),
                new InvocationConstraints(Delegation.NO, null) };
        String name0 = "equals";
        MethodDesc methodDesc0 = new MethodDesc(name0, ics[0]);

        String name1 = "hashCode";
        MethodDesc methodDesc1 = new MethodDesc(name1,
                new Class[] { Object.class }, ics[1]);

        String name2 = "*ashCode";
        MethodDesc methodDesc2 = new MethodDesc(name2, ics[2]);

        MethodDesc methodDesc3 = new MethodDesc(ics[3]);

        MethodDesc [] descs = {methodDesc0, methodDesc1, methodDesc2,
                methodDesc3};

        BasicMethodConstraints bmc = new BasicMethodConstraints(descs);
View Full Code Here

            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();
           
            // 2
            if (testCase == case2arg) {
                name = "*someMethod";
                md = callConstructor(testCase, name, types, constraints);
                md.hashCode();

                name = "*5someMethod";
                md = callConstructor(testCase, name, types, constraints);
                md.hashCode();
            }
           
            // 3
            if (testCase == case2arg) {
                name = "someMethod*";
                md = callConstructor(testCase, name, types, constraints);
                md.hashCode();
            }
        }
    }
View Full Code Here

            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)) {
                throw new TestException(
                        "invalid result constraints");
            }
           
            // 2
            if (testCase == case2arg) {
                name = "*someMethod";
                md = callConstructor(testCase, name, types, constraints);
                resultConstraints = md.getConstraints();
                if (!resultConstraints.equals(constraints)) {
                    throw new TestException(
                            "invalid result constraints");
                }

                name = "*5someMethod";
                md = callConstructor(testCase, name, types, constraints);
                resultConstraints = md.getConstraints();
                if (!resultConstraints.equals(constraints)) {
                    throw new TestException(
                            "invalid result constraints");
                }
            }
           
            // 3
            if (testCase == case2arg) {
                name = "someMethod*";
                md = callConstructor(testCase, name, types, constraints);
                resultConstraints = md.getConstraints();
                if (!resultConstraints.equals(constraints)) {
                    throw new TestException(
                            "invalid result constraints");
                }
            }
           
            // 4
            InvocationConstraints emptyConstraints = new InvocationConstraints(
                    (InvocationConstraint) null, null);
            name = "someMethod";
            md = callConstructor(testCase, name, types, null);
            resultConstraints = md.getConstraints();
            if (!resultConstraints.equals(emptyConstraints)) {
                throw new TestException(
                        "invalid result constraints");
            }
        }
View Full Code Here

            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) {
                if (result != null) {
                    throw new TestException(
                            "null should be returned");
                }
            } else {
                if (result != name) {
                    throw new TestException("invalid result");
                }
            }
           
           
            // 2
            if (testCase == case2arg) {
                name = "*someMethod";
                md = callConstructor(testCase, name, types, constraints);
                result = md.getName();
                if (result != name) {
                    throw new TestException("invalid result");
                }

                name = "*5someMethod";
                md = callConstructor(testCase, name, types, constraints);
                result = md.getName();
                if (result != name) {
                    throw new TestException("invalid result");
                }
            }
           
            // 3
            if (testCase == case2arg) {
                name = "someMethod*";
                md = callConstructor(testCase, name, types, constraints);
                result = md.getName();
                if (result != name) {
                    throw new TestException("invalid result");
                }
            }
        }
View Full Code Here

            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;
           
            // 1
            if (testCase == case3arg) {
                md = callConstructor(testCase, name, types, constraints);
                returnedTypes = md.getParameterTypes();
                if (returnedTypes == null) {
                    throw new TestException(
                            "result should not be null");
                }
                for (int j = 0; j < types.length; ++j) {
                    if (returnedTypes[j] != types[j]) {
                        throw new TestException(
                                "invalid result types array");
                    }
                }
            }
           
            // 2
            if ((testCase == case1arg) || (testCase == case2arg)) {
                md = callConstructor(testCase, name, types, constraints);
                returnedTypes = md.getParameterTypes();
                if (returnedTypes != null) {
                    throw new TestException("result should be null");
                }
            }
           
            // 3
            if (testCase == case2arg) {
                name = "*someMethod";
                md = callConstructor(testCase, name, types, constraints);
                returnedTypes = md.getParameterTypes();
                if (returnedTypes != null) {
                    throw new TestException("result should be null");
                }

                name = "*5someMethod";
                md = callConstructor(testCase, name, types, constraints);
                returnedTypes = md.getParameterTypes();
                if (returnedTypes != null) {
                    throw new TestException("result should be null");
                }
            }
           
            // 4
            if (testCase == case2arg) {
                name = "someMethod*";
                md = callConstructor(testCase, name, types, constraints);
                returnedTypes = md.getParameterTypes();
                if (returnedTypes != null) {
                    throw new TestException("result should be null");
                }
            }
           
            // 5
            if (testCase == case3arg) {
                md = callConstructor(testCase, name, types, constraints);
                returnedTypes = md.getParameterTypes();
                Class[] returnedTypes2 = md.getParameterTypes();
                if (returnedTypes == returnedTypes2) {
                    throw new TestException(
                            "should be not the same (new) array");
                }
            }
View Full Code Here

                    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);
                md2 = callConstructor(testCase, name2, types2,
                        constraints2diff);
                if (md1.equals(md2)) {
                    throw new TestException(
                            "MethodDesc objects should not be equal");
                }
            }
           
            // 5
            if ((testCase == case2arg) || (testCase == case3arg)) {
                md1 = callConstructor(case1arg, name1, types1,
                        constraints1);
                md2 = callConstructor(testCase, name2, types2,
                        constraints2);
                if (md1.equals(md2) || md2.equals(md1)) {
                    throw new TestException(
                            "MethodDesc objects should not be equal");
                }
            }
           
            // 6
            if (testCase == case3arg) {
                md1 = callConstructor(case2arg, name1, types1,
                        constraints1);
                md2 = callConstructor(testCase, name2, types2,
                        constraints2);
                if (md1.equals(md2) || md2.equals(md1)) {
                    throw new TestException(
                            "MethodDesc objects should not be equal");
                }
            }
        }
View Full Code Here

TOP

Related Classes of net.jini.constraint.BasicMethodConstraints.MethodDesc

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.