Package net.jini.jeri

Examples of net.jini.jeri.OutboundRequest


            e.newRequest(InvocationConstraints.EMPTY);
        int response = 0;
        while (ori.hasNext()) {
            //Verify that the outbound request can be used to communicate
            //with the server side of the connection
            OutboundRequest or = ori.next();
            ObjectOutputStream oos =
                new ObjectOutputStream(or.getRequestOutputStream());
            oos.writeInt(this.hashCode());
            oos.close();
            ObjectInputStream ois = new ObjectInputStream(
                or.getResponseInputStream());
            response = ois.readInt();
            ois.close();
            //Verify UnsupportedOperationException
            ArrayList al = new ArrayList();
            al.add(new Object());
            Collection uc = Collections.unmodifiableCollection(al);
            exceptionThrown = false;
            try {
                uc.add(new Object());
                //This is an implementation specific check
                //comment code line above this comment if implementation
                //is expected to populate the passed in context
                or.populateContext(uc);
            } catch (UnsupportedOperationException uoe) {
                //This exception would only occur if one of the
                //JERI layers attempts to write context information
                //to the collection
                exceptionThrown = true;
            }
            if (!exceptionThrown){
                throw new TestException("Passing an unmodifiable"
                    + " collection to populateContext does not result"
                    + " in UnsupportedOperationException");
            }
            //Verify idempotency of input/output streams
            InputStream i1 = or.getResponseInputStream();
            InputStream i2 = or.getResponseInputStream();
            OutputStream o1 = or.getRequestOutputStream();
            OutputStream o2 = or.getRequestOutputStream();
            if (o1!=o2||i1!=i2) {
                throw new TestException("Idempotency of streams"
                    + " is not maintained");
            }
        }

        //Verify NoSuchElementException
        exceptionThrown = false;
        try {
            ori.next();
        } catch (NoSuchElementException nse) {
            exceptionThrown = true;
        }
        if (!exceptionThrown) {
            throw new TestException("Calling next on an iterator"
                + " that has returned false from hasNext does not throw"
                + " NoSuchElementException");
        }

        Iterator it = endpoints.iterator();
        while(it.hasNext()) {
            EndpointHolder eph = (EndpointHolder) it.next();
            SETRequestHandler rh = (SETRequestHandler)
                eph.getRequestHandler();
            if (response != rh.hashCode()){
                throw new TestException("The response received"
                    + "does not match the response sent by the server"
                    + "side of the connection.  Server sent "
                    + rh.hashCode() + ", but the client got " + response);
            }
            ArrayList requests = rh.getRequests();
            if (requests.size()!=1){
                throw new TestException("The RequestDisptcher"
                    + " received the incorrect number of requests.  "
                    + "Expected 1 and received " + requests.size());
            }
            Iterator requestIterator = requests.iterator();
            while (requestIterator.hasNext()){
                Integer value = (Integer) requestIterator.next();
                if (value.intValue()!=this.hashCode()){
                    throw new TestException("The data read from"
                        + " the InboundRequest does not match the data"
                        + " written to the OutboundRequest.  Wrote "
                        + this.hashCode() + " read " + value);
                }
            }
            ServerEndpoint.ListenHandle lh = eph.getListenHandle();
            //Close the listen operation
            lh.close();
        }
        //Verify that new requests are not received after close has
        //been called on the ListenHandle
        try {
            ori = e.newRequest(InvocationConstraints.EMPTY);
            while (ori.hasNext()) {
                OutboundRequest or = ori.next();
                ObjectOutputStream oos =
                    new ObjectOutputStream(or.getRequestOutputStream());
                oos.writeInt(this.hashCode());
                oos.close();
            }
            it = endpoints.iterator();
            while(it.hasNext()) {
View Full Code Here


        boolean exceptionThrown = false;
        try {
            OutboundRequestIterator it = endpoint
                .newRequest(conflictingConstraints);
            while (it.hasNext()) {
                OutboundRequest or = it.next();
                log.finest("Obtained " + or + " from " + endpoint);
            }
        } catch (UnsupportedConstraintException e){
            exceptionThrown = true;
        }
        if (!exceptionThrown) {
            throw new TestException("Conflicting constraints"
                + " did not generate an UnsupportedConstraintsException"
                + " for " + endpoint + ".newRequest()");
        }
        //Verify unsupported constraints
        exceptionThrown = false;
        try {
            OutboundRequestIterator it = endpoint
                .newRequest(conflictingConstraints);
            while (it.hasNext()) {
                OutboundRequest or = it.next();
                log.finest("Obtained " + or + " from " + endpoint);
            }
        } catch (UnsupportedConstraintException e){
            exceptionThrown = true;
        }
View Full Code Here

        Thread t = new Thread(new Runnable() {
            public void run() {
                try {
                    OutboundRequestIterator it = ep.newRequest(
                        InvocationConstraints.EMPTY);
                    OutboundRequest or = it.next();
                    final InputStream is = or.getResponseInputStream();
                    //read input from the test server
                    Thread input = new Thread(new Runnable() {
                        public void run() {
                            try {
                                byte[] bytes = new byte[2];
                                is.read(bytes);
                                received[0] = bytes[0];
                                received[1] = bytes[1];
                                is.close();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    });
                    input.start();
                    //Send out data bytes through the mux connection
                    OutputStream os = or.getRequestOutputStream();
                    byte[] bytes = new byte[expectedBytes];
                    Arrays.fill(bytes,(byte)0x88);
                    os.write(bytes);
                    os.close();
                } catch (IOException e) {
View Full Code Here

TOP

Related Classes of net.jini.jeri.OutboundRequest

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.