Examples of TestContainerException


Examples of com.sun.jersey.test.framework.spi.container.TestContainerException

            try {
                HttpHandler httpHandler = ContainerFactory.createContainer(HttpHandler.class,
                        ad.getResourceConfig());
                this.httpServer = create(this.baseUri, httpHandler);
            } catch (Exception ex) {
                throw new TestContainerException(ex);
            }
        }
View Full Code Here

Examples of com.sun.jersey.test.framework.spi.container.TestContainerException

        public void start() {
            try {
                LOGGER.info("Starting low level grizzly2 container");
                httpServer.start();
            } catch (IOException ex) {
                throw new TestContainerException(ex);
            }
        }
View Full Code Here

Examples of com.sun.jersey.test.framework.spi.container.TestContainerException

            LOGGER.info("Starting the Grizzly2 Web Container...");
           
            try {
                httpServer.start();
            } catch (IOException ex) {
                throw new TestContainerException(ex);
            }
            
        }
View Full Code Here

Examples of com.sun.jersey.test.framework.spi.container.TestContainerException

            Servlet servletInstance;
            if( servletClass != null) {
                try {
                    servletInstance = (Servlet) servletClass.newInstance();
                } catch (InstantiationException ex) {
                    throw new TestContainerException(ex);
                } catch (IllegalAccessException ex) {
                    throw new TestContainerException(ex);
                }
                handler.setServletInstance(servletInstance);
            }

            for(Class<? extends EventListener> eventListener : eventListeners) {
                handler.addServletListener(eventListener.getName());
            }

            for(String contextParamName : contextParams.keySet()) {
                handler.addContextParameter(contextParamName, contextParams.get(contextParamName));
            }

            for(String initParamName : initParams.keySet()) {
                handler.addInitParameter(initParamName, initParams.get(initParamName));
            }

            if(contextPath != null && contextPath.length() > 0) {
                if( !contextPath.startsWith("/") ) {
                    handler.setContextPath("/" + contextPath);
                } else {
                    handler.setContextPath(contextPath);
                }
            }

            if(servletPath != null && servletPath.length() > 0) {
                if( !servletPath.startsWith("/") ) {
                    handler.setServletPath("/" + servletPath);
                } else {
                    handler.setServletPath(servletPath);
                }
            }

            // Filter support
            if ( filters!=null ) {
                try {
                    for(WebAppDescriptor.FilterDescriptor d : this.filters) {
                        handler.addFilter(d.getFilterClass().newInstance(), d.getFilterName(), d.getInitParams());
                    }
                } catch (InstantiationException ex) {
                    throw new TestContainerException(ex);
                } catch (IllegalAccessException ex) {
                    throw new TestContainerException(ex);
                }
            }

            try {
                httpServer = GrizzlyServerFactory.createHttpServer(baseUri, handler);
            } catch(IOException ioe) {
                throw new TestContainerException(ioe);
            }
        }
View Full Code Here

Examples of com.sun.jersey.test.framework.spi.container.TestContainerException

        Class<? extends AppDescriptor> adType = tcf.supports();
        if (adType == LowLevelAppDescriptor.class &&
                ad.getClass() == WebAppDescriptor.class) {
            ad = LowLevelAppDescriptor.transform((WebAppDescriptor)ad);
        } else if (adType != ad.getClass()) {
            throw new TestContainerException("The application descriptor type, " +
                    ad.getClass() +
                    ", is not supported by the test container factory, " + tcf);
        }

        return tcf.create(getBaseURI(), ad);
View Full Code Here

Examples of com.sun.jersey.test.framework.spi.container.TestContainerException

                        DEFAULT_TEST_CONTAINER_FACTORY_CLASS_NAME);

                try {
                    defaultTestContainerFactoryClass = Class.forName(tcfClassName).asSubclass(TestContainerFactory.class);
                } catch (ClassNotFoundException ex) {
                    throw new TestContainerException(
                            "The default test container factory class name, " +
                                    tcfClassName +
                                    ", cannot be loaded", ex);
                } catch (ClassCastException ex) {
                    throw new TestContainerException(
                            "The default test container factory class, " +
                                    tcfClassName +
                                    ", is not an instance of TestContainerFactory", ex);
                }
            }
        }

        try {
            return defaultTestContainerFactoryClass.newInstance();
        } catch (Exception ex) {
            throw new TestContainerException(
                    "The default test container factory, " +
                    defaultTestContainerFactoryClass +
                    ", could not be instantiated", ex);
        }
    }
View Full Code Here

Examples of com.sun.jersey.test.framework.spi.container.TestContainerException

        String port = System.getProperty("jersey.test.port");
        if (null != port) {
            try {
                return Integer.parseInt(port);
            } catch (NumberFormatException e) {
                throw new TestContainerException("jersey.test.port with a " +
                        "value of \"" + port +"\" is not a valid integer.", e);
            }
        }

        port = System.getProperty("JERSEY_HTTP_PORT");
        if (null != port) {
            try {
                return Integer.parseInt(port);
            } catch (NumberFormatException e) {
                throw new TestContainerException("JERSEY_HTTP_PORT with a " +
                        "value of \"" + port +"\" is not a valid integer.", e);
            }
        }
        return defaultPort;
    }
View Full Code Here

Examples of com.sun.jersey.test.framework.spi.container.TestContainerException

            this.httpHandler = ContainerFactory.createContainer( HttpHandler.class,
                    resourceConfig );
            try {
                this.httpServer = HttpServerFactory.create(this.baseUri, httpHandler);
            } catch (Exception ex) {
                throw new TestContainerException(ex);
            }

        }
View Full Code Here

Examples of com.sun.jersey.test.framework.spi.container.TestContainerException

                }
              });

              server = createHttpServer(baseUri, rc, new GuiceComponentProviderFactory(rc, injector));
            } catch (IOException e) {
              throw new TestContainerException(e);
            }
          }

          public Client getClient() {
            return null;
View Full Code Here

Examples of com.sun.jersey.test.framework.spi.container.TestContainerException

        String port = System.getProperty("jersey.config.test.container.port");
        if (null != port) {
            try {
                return Integer.parseInt(port);
            } catch (NumberFormatException e) {
                throw new TestContainerException("jersey.config.test.container.port with a " +
                        "value of \"" + port +"\" is not a valid integer.", e);
            }
        }

        port = System.getProperty("JERSEY_TEST_PORT");
        if (null != port) {
            try {
                return Integer.parseInt(port);
            } catch (NumberFormatException e) {
                throw new TestContainerException("JERSEY_TEST_PORT with a " +
                        "value of \"" + port +"\" is not a valid integer.", e);
            }
        }
        return defaultPort;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.