Package com.sun.jersey.test.framework.spi.container

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);
                }
                sa.setServletInstance(servletInstance);
            }

            for(Class<? extends EventListener> eventListener : eventListeners) {
                sa.addServletListener(eventListener.getName());
            }
        
            // Filter support
            if ( filters!=null ) {
                try {
                    for(WebAppDescriptor.FilterDescriptor d : this.filters) {
                        sa.addFilter(d.getFilterClass().newInstance(), d.getFilterName(), d.getInitParams());
                    }
                } catch (InstantiationException ex) {                   
                    throw new TestContainerException(ex);
                } catch (IllegalAccessException ex) {                   
                    throw new TestContainerException(ex);
                }
            }
           
            for(String contextParamName : contextParams.keySet()) {
                sa.addContextParameter(contextParamName, contextParams.get(contextParamName));
View Full Code Here


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

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

        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

                            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

        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

        if (gfr == null) {
            try {
                LOGGER.info("Create instantiated GlassFishRuntime");
                gfr = GlassFishRuntime.bootstrap();
            } catch (GlassFishException ex) {
                throw new TestContainerException(ex);
            }
        } else {
            LOGGER.info("Re-use Already instantiated GlassFishRuntime");
            // try doing gfr.shutdown() if you were to
            // bootstrap GlassFishRuntime again.
            // Shutdown GlassFish.
            try {
                gfr.shutdown();
                // can comment out to see if this fixes 'already bootstrapped' error
                // but never reaches here on 2nd test
                gfr = GlassFishRuntime.bootstrap();
            } catch (GlassFishException shutdownex) {
                throw new TestContainerException(shutdownex);
            }
        }

        if (glassfish == null) {
            try {
                GlassFishProperties gfProperties = new GlassFishProperties();
                gfProperties.setPort("http-listener", getBaseUri().getPort());

                glassfish = gfr.newGlassFish(gfProperties);
                // use glassfish
            } catch (GlassFishException ngfex) {
                throw new TestContainerException(ngfex);
            }
        } else {
            LOGGER.info("Dispose Already instantiated GlassFish");
            try {
                // dispose it.
                glassfish.dispose();
            } catch (GlassFishException disposeex) {
                throw new TestContainerException(disposeex);
            }
            LOGGER.info("Create another instantiated GlassFish");
            try {
                glassfish = gfr.newGlassFish();
            } catch (GlassFishException ngfex2) {
                throw new TestContainerException(ngfex2);
            }
        }

    }
View Full Code Here

                String deployedApp = deployer.deploy(warArchive.toURI());
                LOGGER.info("Deployed [" + deployedApp + "] to EmbeddedGlassFish instance [" + deployer.toString() + "] with context-root set to [" + this.appDescriptor.getContextPath() + "]");
            }
        } catch (org.glassfish.embeddable.GlassFishException ex) {
            LOGGER.info("Caught GlassFishException [" + ex.getMessage() + "] trying to start the embedded server instance");
            throw new TestContainerException(ex);
        } catch (java.io.IOException ioe) {
            LOGGER.info("Caught IOException [" + ioe.getMessage() + "] trying to start the embedded server instance");
            throw new TestContainerException(ioe);
        }
    }
View Full Code Here

            // this will avoid "already bootstrapped" errors seen when running multiple tests
            // in same VM
            gfr.shutdown();

        } catch (GlassFishException ex) {
            throw new TestContainerException(ex);
        }
    }
View Full Code Here

            deployer = glassfish.getDeployer();
            // Return names of all the deployed applications.
            deployedApps = deployer.getDeployedApplications();

        } catch (GlassFishException glassFishException) {
            throw new TestContainerException(glassFishException);
        }

        //  undeploy each app in for-each loop
        for (String deployedApp : deployedApps) {
            try {
                //see http://java.net/jira/browse/EMBEDDED_GLASSFISH-123
                deployer.undeploy(deployedApp, "--droptables", "true");
            } catch (GlassFishException glassFishException) {
                throw new TestContainerException(glassFishException);
            }
            LOGGER.info("Undeployed = " + deployedApp);
        }
    }
View Full Code Here

TOP

Related Classes of com.sun.jersey.test.framework.spi.container.TestContainerException

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.