Package net.jini.jeri

Examples of net.jini.jeri.ServerEndpoint


      throw new RuntimeException("TEST FAILED: " +
    "local host name not looked up in name service");
  }
  System.err.println("Local host name is \"" + localName + "\"");

  final ServerEndpoint se = getServerEndpoint();
  final ListenContext lc = new ListenContext() {
      public ListenCookie addListenEndpoint(ListenEndpoint le)
    throws IOException
      {
    return le.listen(new RequestDispatcher() {
        public void dispatch(InboundRequest r) { }
    }).getCookie();
      }
  };

  /*
   * Verify that invoking enumerateListenEndpoints with
   * permission to resolve the local host name throws an
   * UnknownHostException that does contain the local host name
   * in its detail message.
   */
  System.err.println("Trying with permission:");
  try {
      se.enumerateListenEndpoints(lc);
      throw new RuntimeException("TEST FAILED");
  } catch (UnknownHostException e) {
      e.printStackTrace();
      String message = e.getMessage();
      if (message == null || message.indexOf(localName) == -1) {
    throw new RuntimeException("TEST FAILED: " +
        "exception message does not contain local host name");
      }
  }

  /*
   * Verify that invoking enumerateListenEndpoints without
   * permission to resolve the local host name throws an
   * UnknownHostException that does not contain the local host
   * name in its detail message.
   */
  System.err.println("Trying without permission:");
  AccessControlContext acc = new AccessControlContext(
      new ProtectionDomain[] { new ProtectionDomain(null, null) });
  try {
      AccessController.doPrivileged(new PrivilegedExceptionAction() {
    public Object run() throws IOException {
        se.enumerateListenEndpoints(lc);
        throw new RuntimeException("TEST FAILED");
    }
      }, acc);
  } catch (PrivilegedActionException pae) {
      IOException e = (IOException) pae.getCause();
View Full Code Here


public class IllegalArgumentExceptionTest extends AbstractEndpointTest {

    public void run() throws Exception {
        //Obtain a serverEndpoint instance
        ServerEndpoint se = getServerEndpoint();
        IllegalArgumentContext context = new IllegalArgumentContext(null);
        //Call enumerateListenEndpoints and extract cookies
        se.enumerateListenEndpoints(context);
        ArrayList cookies = context.getCookies();
        //Obtain a different server endpoint
        se = (ServerEndpoint) getConfigObject(ServerEndpoint.class,
            "diffEndpoint");
        boolean exceptionThrown = false;
        try {
            se.enumerateListenEndpoints(
                new IllegalArgumentContext(cookies));
        } catch (IllegalArgumentException e) {
            exceptionThrown = true;
        }
        if (!exceptionThrown) {
            throw new TestException("The ServerEndpoint"
                + " implementation does not throw an"
                + " IllegalArgumentException when an invalid"
                + " ListenCookie is returned by the ListenContext");
        }
        //Close listen operation
        ArrayList endpoints = context.getEndpoints();
        Iterator it = endpoints.iterator();
        while (it.hasNext()) {
            ((EndpointHolder) it.next()).getListenHandle().close();
        }
        // wait to make sure resources are released before attempting
        // to reuse endpoint
        Thread.currentThread().sleep(1000 * 30);
        exceptionThrown = false;
        se = getServerEndpoint();
        try {
            se.enumerateListenEndpoints(new NullCookieContext());
        } catch (IllegalArgumentException e) {
            exceptionThrown = true;
        }
        if (!exceptionThrown) {
            throw new TestException("The ServerEndpoint"
View Full Code Here

*/
public class MuxServerTest extends AbstractMuxTest {

    public void run() throws Exception {
        //Setup server side mux connection
        ServerEndpoint se = getServerEndpoint();
        TestService service = new TestServiceImpl();
        int redirectPort = getPort() + 1;
        Redirector rd = new Redirector(getHost(),getPort(),redirectPort);
        ((TestServerEndpoint) se).redirect(redirectPort);
        Thread t = new Thread(rd);
View Full Code Here

import java.util.Iterator;

public class GetDeliveryStatusTest extends AbstractEndpointTest {

    public void run() throws Exception {
        ServerEndpoint se = getServerEndpoint();
        GetDeliveryDispatcher dispatcher = new GetDeliveryDispatcher();
        GetDeliveryContext lc = new GetDeliveryContext(dispatcher);
        Endpoint e =
            se.enumerateListenEndpoints(lc);
        dispatcher.accept();
        OutboundRequestIterator ori =
            e.newRequest(InvocationConstraints.EMPTY);
        OutboundRequest or = null;
        while (ori.hasNext()) {
View Full Code Here

public class EndpointInUseTest extends AbstractEndpointTest {

    public void run() throws Exception {
        //Obtain a server endpoint
        ServerEndpoint se = getServerEndpoint();
        //Call enumerateListenEndpoints to start a listen operation
        //on the endpoint
        se.enumerateListenEndpoints(new SETContext());
        //Call enumerateListenEndpoints while the endpoint is in use
        //and verify that an IOException is thrown
        EIUTContext context = new EIUTContext();
        try {
            se.enumerateListenEndpoints(context);
        } catch (IOException e) {
            //Verify that IOException was thrown in listen calls to
            //ListenEndpoints
            Iterator it = context.getResults().iterator();
            while (it.hasNext()) {
View Full Code Here

    }

    public ServerEndpoint getServerEndpoint() throws ConfigurationException{
//        Configuration config = sysConfig.getConfiguration();
  Configuration config = getConfiguration();
        ServerEndpoint se = (ServerEndpoint)
            config.getEntry(component,seEntry,ServerEndpoint.class);
        log.finest("ServerEndpoint extracted from the configuration is " + se);
        return se;
    }
View Full Code Here

import java.util.Iterator;

public class NullPointerExceptionTest extends AbstractEndpointTest {
    public void run() throws Exception {
        boolean exceptionThrown = false;
        ServerEndpoint endpoint = getServerEndpoint();
        //Verify endpoint.enumerateListenEndpoint(null);
        try {
            log.finest("Testing enumerateListenEndpoint(null)");
            endpoint.enumerateListenEndpoints(null);
        } catch (NullPointerException e) {
            log.finest("enumerateListenEndpoint(null) throws exception");
            exceptionThrown = true;
        }
        if (!exceptionThrown) {
            throw new TestException("Passing in a null"
                + " ListenContext to ServerEndpoint.enumerateListenEnpoints"
                + " does not result in a NulPointerException");
        }

        //Verify ListenEndpoint.listen(null);
        endpoint = getServerEndpoint();
        SETContext context = new SETContext();
        endpoint.enumerateListenEndpoints(context);
        ArrayList endpoints = context.getEndpoints();
        log.finest(endpoints.size() + " endpoints returned");
        Iterator i = endpoints.iterator();
        while (i.hasNext()) {
            EndpointHolder holder = (EndpointHolder) i.next();
            ServerEndpoint.ListenEndpoint le = holder.getListenEndpoint();
            exceptionThrown = false;
            try {
                log.finest("Testing ListenEndpoint.listen(null)");
                le.listen(null);
            } catch (NullPointerException e) {
                holder.getListenHandle().close();
                log.finest("ListenEndpoint.listen(null) throws exception");
                exceptionThrown = true;
            }
            if (!exceptionThrown) {
                throw new TestException("Passing in null to"
                    + " ListenEndpoint.listen does not result in a"
                    + " NullPointerException");
            }
        }
        // wait to make sure resources are released before attempting
        // to reuse endpoint
        Thread.currentThread().sleep(1000 * 30);
        //Verify Endpoint.newRequest(null);
        endpoint = getServerEndpoint();
        context = new SETContext();
        Endpoint ep = endpoint.enumerateListenEndpoints(context);
        exceptionThrown = false;
        try {
            ep.newRequest(null);
        } catch (NullPointerException e) {
            exceptionThrown = true;
        }
        if (!exceptionThrown) {
            throw new TestException("Passing in null to"
                + " Endpoint.newRequest does not result in a"
                + " NullPointerException");
        }

        //Close listen operations
        endpoints = context.getEndpoints();
        i = endpoints.iterator();
        while (i.hasNext()) {
            ((EndpointHolder)i.next()).getListenHandle().close();
        }
        // wait to make sure resources are released before attempting
        // to reuse endpoint
        Thread.currentThread().sleep(1000 * 30);
        //Verify OutboundRequest.populateContext(null)
        endpoint = getServerEndpoint();
        context = new SETContext();
        ep = endpoint.enumerateListenEndpoints(context);
        OutboundRequestIterator it =
            ep.newRequest(InvocationConstraints.EMPTY);
        while (it.hasNext()) {
            exceptionThrown = false;
            try {
View Full Code Here

        try {
            //Call getInstance(0) under the unauthorized subject
            endpoint = Subject.doAsPrivileged(unauthorized,
                new PrivilegedExceptionAction() {
                public Object run() throws Exception {
                    ServerEndpoint endpoint = (ServerEndpoint)
                        getInstance.invoke(c,new Object[]{new Integer(0)});
                    return endpoint.enumerateListenEndpoints(
                        new SETContext());
                }
            },null);
        } catch (SecurityException s) {
            exceptionThrown = true;
View Full Code Here

import java.util.Iterator;

public class RobustnessTest extends AbstractEndpointTest {

    public void run() throws Exception {
        ServerEndpoint se = getServerEndpoint();
        GetDeliveryDispatcher dispatcher = new GetDeliveryDispatcher();
        GetDeliveryContext lc = new GetDeliveryContext(dispatcher);
        Endpoint e =
            se.enumerateListenEndpoints(lc);
        dispatcher.reject();
        try {
            OutboundRequestIterator ori =
                e.newRequest(InvocationConstraints.EMPTY);
            while (ori.hasNext()){
View Full Code Here

    private void CustomParametersConstructorTest() throws Exception {
        //BasicJeriExporter(ServerEndpoint se,InvocationLayerFactory ilf,
        //boolean enableDGC, boolean keepAlive)
        int listenPort = config.getIntConfigVal("com.sun.jini.test.spec.jeri"
            + ".basicjeriexporter.ConstructorTest.listenPort", 9090);
        ServerEndpoint se = new BJETestServerEndpoint(
            TcpServerEndpoint.getInstance(listenPort));
        InvocationLayerFactory ilf = new BJETestILFactory();
        BasicJeriExporter exporter = new BasicJeriExporter(se,ilf,false,false);
        //Verify that the ServerEnpoint used by the exporter is a custom
        //ServerEnpoint
View Full Code Here

TOP

Related Classes of net.jini.jeri.ServerEndpoint

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.