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

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


                OutputStream outputStream = new FileOutputStream(webXml);
                WebXmlGenerator webXmlGenerator = new WebXmlGenerator(appDescriptor);
                try {
                    webXmlGenerator.marshalData(outputStream);
                } catch (JAXBException ex) {
                    throw new TestContainerException(ex);
                }
                outputStream.close();
            } catch (FileNotFoundException ex) {
                throw new TestContainerException(ex);
            } catch (IOException ex) {
                throw new TestContainerException(ex);
            }
            return true;
        }
        return false;
    }
View Full Code Here


                // required if exist already //The name for this metadata will be obtained by doing metadata.getName()
                try {
                    warArchive.addMetadata(new File(SRC_WEBAPP_PATH + "/" + WEB_INF_PATH + "/", WEB_XML));
                } catch (java.io.IOException ioe) {
                    LOGGER.info("Encountered IOException [" + ioe.getMessage() + "] trying to addMetadata [" + SRC_WEBAPP_PATH + "/" + WEB_INF_PATH + "/" + WEB_XML + "]");
                    throw new TestContainerException(ioe);
                }

                //The name for this metadata will be obtained by doing metadata.getName()
                //scatteredArchiveBuilder.addMetadata(new File(SRC_WEBAPP_PATH + "/"  + WEB_INF_PATH + "/" + SUN_WEB_XML));
                // resources/sun-web.xml is my WEB-INF/sun-web.xml
                //archive.addMetadata(new File("resources", "sun-web.xml"));
                try {
                    warArchive.addMetadata(new File(SRC_WEBAPP_PATH + "/" + WEB_INF_PATH + "/", SUN_WEB_XML));
                } catch (java.io.IOException ioe) {
                    LOGGER.info("Encountered IOException [" + ioe.getMessage() + "] trying to addMetadata [" + SUN_WEB_XML + "]");
                    throw new TestContainerException(ioe);
                }
                // target/classes directory contains my complied servlets
                //archive.addClassPath(new File("target", "classes"));
                try {
                    warArchive.addClassPath(new File(TARGET_PATH, CLASSES_PATH));
                } catch (java.io.IOException ioe) {
                    LOGGER.info("Encountered IOException [" + ioe.getMessage() + "] trying to addClassPath [" + TARGET_PATH + "/" + CLASSES_PATH + "]");
                    throw new TestContainerException(ioe);
                }
                // resources/MyLogFactory is my META-INF/services/org.apache.commons.logging.LogFactory
                //archive.addMetadata(new File("resources", "MyLogFactory"),
                //"META-INF/services/org.apache.commons.logging.LogFactory");
                LOGGER.info("#1 inside method createArchive ==> webXmlGeneratedOnTheFly ==> just created scatteredArchive [" + SRC_WEBAPP_PATH + "] using WEB-INF/web.xml from [" + warArchive.toString() + "]");
                System.out.println("jsb, #1 inside method createArchive ==> webXmlGeneratedOnTheFly ==> just created scatteredArchive [" + SRC_WEBAPP_PATH + "] using WEB-INF/web.xml from [" + warArchive.toString() + "]");
            } catch (Exception ex) {
                throw new TestContainerException(ex);
            }
        } else {
            try {
                LOGGER.info("#2 inside method createArchive ==> webXmlGeneratedOnTheFly ==> Creating scatteredArchive [" + TARGET_WEBAPP_PATH + "]");
                //use global variable
                //warArchive = new ScatteredArchive(baseUri.getRawPath()+File.separator+TARGET_WEBAPP_PATH+File.separator+"myWarArchive", ScatteredArchive.Type.WAR);
                warArchive = new ScatteredArchive(BASE_URI.getRawPath(), ScatteredArchive.Type.WAR);

                //The name for this metadata will be obtained by doing metadata.getName()
                try {
                    warArchive.addMetadata(new File(TARGET_WEBAPP_PATH + "/" + WEB_INF_PATH + "/", WEB_XML));
                } catch (java.io.IOException ioe) {
                    LOGGER.info("Encountered IOException [" + ioe.getMessage() + "] trying to addMetadata [" + TARGET_WEBAPP_PATH + "/" + WEB_INF_PATH + "/" + WEB_XML + "]");
                    throw new TestContainerException(ioe);
                }

                // do i need to add sun-web.xml to scatteredArchive via addMetaData to set context-root correctly
                //scatteredArchiveBuilder.addMetadata(new File(TARGET_WEBAPP_PATH + "/"  + WEB_INF_PATH + "/" + SUN_WEB_XML));
                try {
                    warArchive.addClassPath(new File(TARGET_PATH, CLASSES_PATH));
                } catch (java.io.IOException ioe) {
                    LOGGER.info("Encountered IOException [" + ioe.getMessage() + "] trying to addClassPath [" + TARGET_PATH + "/" + CLASSES_PATH + "]");
                    throw new TestContainerException(ioe);
                }

                LOGGER.info("#2 inside method createArchive ==> webXmlGeneratedOnTheFly ==> just created scatteredArchive [" + TARGET_WEBAPP_PATH + "] using WEB-INF/web.xml from [" + warArchive.toString() + "]");
            } catch (Exception ex) {
                throw new TestContainerException(ex);
            }
        }
    }
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.