Package net.jini.jeri

Examples of net.jini.jeri.BasicInvocationHandler


    }

    // inherit javadoc
    public void run() throws Exception {
        try {
            BasicInvocationHandler handler;
            RemoteMethodControl proxy, newProxy;
            FakeMethodConstraints clientConstraints = new FakeMethodConstraints(
                new InvocationConstraint[] {Integrity.YES});
            FakeMethodConstraints serverConstraints = new FakeMethodConstraints(
                new InvocationConstraint[] {Confidentiality.YES});
            FakeObjectEndpoint oe = new FakeObjectEndpoint();

            logger.log(Level.FINE,"=================================");
            logger.log(Level.FINE,"test case 1: setConstraints(null)");
            logger.log(Level.FINE,"");

            handler = new BasicInvocationHandler(
                new BasicInvocationHandler(oe,serverConstraints),
                clientConstraints);
            proxy = (RemoteMethodControl) Proxy.newProxyInstance(
                this.getClass().getClassLoader(),
                new Class[] {RemoteMethodControl.class}, handler);

            newProxy =
                (RemoteMethodControl) proxy.setConstraints(null);
            handler =
                (BasicInvocationHandler) Proxy.getInvocationHandler(newProxy);
            assertion(handler.getObjectEndpoint() == oe);
            assertion(handler.getClientConstraints() == null);
            assertion(handler.getServerConstraints() == serverConstraints);
            assertion(proxy.getConstraints() == clientConstraints);
            assertion(newProxy.getConstraints() == null);

            logger.log(Level.FINE,"=================================");
            logger.log(Level.FINE,"test case 2: "
                + "setConstraints(MethodConstraints)");
            logger.log(Level.FINE,"");

            handler = new BasicInvocationHandler(
                new BasicInvocationHandler(oe,serverConstraints),
                null);
            proxy = (RemoteMethodControl) Proxy.newProxyInstance(
                this.getClass().getClassLoader(),
                new Class[] {RemoteMethodControl.class}, handler);

            newProxy =
                (RemoteMethodControl) proxy.setConstraints(clientConstraints);
            handler =
                (BasicInvocationHandler) Proxy.getInvocationHandler(newProxy);
            assertion(handler.getObjectEndpoint() == oe);
            assertion(handler.getClientConstraints() == clientConstraints);
            assertion(handler.getServerConstraints() == serverConstraints);
            assertion(proxy.getConstraints() == null);
            assertion(newProxy.getConstraints() == clientConstraints);

            logger.log(Level.FINE,"=================================");
            logger.log(Level.FINE,"test case 3: bad proxy arg");
            logger.log(Level.FINE,"");

            handler = new BasicInvocationHandler(oe,serverConstraints);
            Method m = RemoteMethodControl.class.getMethod(
                "setConstraints",new Class[] {MethodConstraints.class});
            try {
                handler.invoke(new Object(),m,new Object[] {clientConstraints});
                assertion(false);
            } catch (Exception ignore) {
            }

        } catch (Throwable t) {
View Full Code Here


    }

    protected DgcProxy getDgcProxy(Object endpoint) {
  Endpoint e = (Endpoint) endpoint;
  ObjectEndpoint oe = new BasicObjectEndpoint(e, Jeri.DGC_ID, false);
  InvocationHandler ih = new BasicInvocationHandler(oe, null);
  DgcServer proxy =
      (DgcServer) Proxy.newProxyInstance(getClass().getClassLoader(),
                 proxyInterfaces, ih);
  return new DgcProxyImpl(proxy);
    }
View Full Code Here

    public void setup(QAConfig sysConfig) throws Exception {
    }

    // inherit javadoc
    public void run() throws Exception {
        BasicInvocationHandler handler;
        BasicInvocationHandler handler2;
        FakeMethodConstraints clientConstraints =
            new FakeMethodConstraints(null);
        FakeMethodConstraints serverConstraints =
            new FakeMethodConstraints(null);
        FakeObjectEndpoint oe = new FakeObjectEndpoint();

        logger.log(Level.FINE,"=================================");
        logger.log(Level.FINE,"test case 1: null constructor args");
        logger.log(Level.FINE,"");

        try {
            handler = new BasicInvocationHandler(
                (BasicInvocationHandler)null,clientConstraints);
            assertion(false);
        } catch (NullPointerException ignore) {
        }

        try {
            handler = new BasicInvocationHandler(
                (ObjectEndpoint)null,serverConstraints);
            assertion(false);
        } catch (NullPointerException ignore) {
        }

        logger.log(Level.FINE,"=================================");
        logger.log(Level.FINE,"test case 2: "
            + "accessor methods returns constructor args");
        logger.log(Level.FINE,"");

        handler = new BasicInvocationHandler(oe,serverConstraints);
        assertion(handler.getObjectEndpoint() == oe);
        assertion(handler.getClientConstraints() == null);
        assertion(handler.getServerConstraints() == serverConstraints);

        handler2 = new BasicInvocationHandler(handler,clientConstraints);
        assertion(handler2.getObjectEndpoint() == oe);
        assertion(handler2.getClientConstraints() == clientConstraints);
        assertion(handler2.getServerConstraints() == serverConstraints);

        handler2 = new BasicInvocationHandler(handler,null);
        assertion(handler2.getObjectEndpoint() == oe);
        assertion(handler2.getClientConstraints() == null);
        assertion(handler2.getServerConstraints() == serverConstraints);

        handler = new BasicInvocationHandler(oe,null);
        assertion(handler.getObjectEndpoint() == oe);
        assertion(handler.getClientConstraints() == null);
        assertion(handler.getServerConstraints() == null);

        handler2 = new BasicInvocationHandler(handler,clientConstraints);
        assertion(handler2.getObjectEndpoint() == oe);
        assertion(handler2.getClientConstraints() == clientConstraints);
        assertion(handler2.getServerConstraints() == null);

        handler2 = new BasicInvocationHandler(handler,null);
        assertion(handler2.getObjectEndpoint() == oe);
        assertion(handler2.getClientConstraints() == null);
        assertion(handler2.getServerConstraints() == null);
    }
View Full Code Here

    public void run() throws Exception {
        int counter = 1;
        Class[] proxyInterfaces;
        InvocationConstraint[] clientConstraints;
        InvocationConstraint[] serverConstraints;
        BasicInvocationHandler handler1;
        BasicInvocationHandler handler2;
        Object proxy1;
        Object proxy2;

        for (int i = 0; i < cases.length; i++) {
            proxyInterfaces = (Class[])cases[i][0];
            clientConstraints = (InvocationConstraint[])cases[i][1];
            serverConstraints = (InvocationConstraint[])cases[i][2];

            handler1 = new BasicInvocationHandler(
                new BasicInvocationHandler(
                    new FakeObjectEndpoint(i),
                    new FakeMethodConstraints(serverConstraints)),
                new FakeMethodConstraints(clientConstraints));

            proxy1 = Proxy.newProxyInstance(
                this.getClass().getClassLoader(),
                proxyInterfaces, handler1);

            for (int j = 0; j < cases.length; j++) {
                logger.log(Level.FINE,"=================================");
                logger.log(Level.FINE,"test case " + (counter++) + ": ");
                logger.log(Level.FINE,"");

                proxyInterfaces = (Class[])cases[j][0];
                clientConstraints = (InvocationConstraint[])cases[j][1];
                serverConstraints = (InvocationConstraint[])cases[j][2];

                handler2 = new BasicInvocationHandler(
                    new BasicInvocationHandler(
                        new FakeObjectEndpoint(j),
                        new FakeMethodConstraints(serverConstraints)),
                    new FakeMethodConstraints(clientConstraints));

                proxy2 = Proxy.newProxyInstance(
                    this.getClass().getClassLoader(),
                    proxyInterfaces, handler2);

                // verify BasicInvocationHandler.invoke test cases
                assertion(proxy1.toString() != null);
                assertion(proxy2.toString() != null);

                assertion(proxy1.equals(proxy1));
                assertion(proxy2.equals(proxy2));

                if (i == j) {
                    assertion(proxy1.equals(proxy2));
                    assertion(proxy2.equals(proxy1));
                    assertion(proxy1.hashCode() == proxy2.hashCode());
                } else {
                    assertion(! proxy1.equals(proxy2));
                    assertion(! proxy2.equals(proxy1));
                }

                // verify BasicInvocationHandler test cases
                assertion(handler1.toString() != null);
                assertion(handler2.toString() != null);

                assertion(handler1.equals(handler1));
                assertion(handler2.equals(handler2));
                assertion(! handler1.equals(new Object()));

                if (i == j) {
                    assertion(handler1.equals(handler2));
                    assertion(handler2.equals(handler1));
                    assertion(handler1.hashCode() == handler2.hashCode());
                } else {
                    assertion(! handler1.equals(handler2));
                    assertion(! handler2.equals(handler1));
                }
            }//inner for loop
        }//outer for loop
    }
View Full Code Here

TOP

Related Classes of net.jini.jeri.BasicInvocationHandler

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.