001: /***************************************************************
002: * This file is part of the [fleXive](R) project.
003: *
004: * Copyright (c) 1999-2008
005: * UCS - unique computing solutions gmbh (http://www.ucs.at)
006: * All rights reserved
007: *
008: * The [fleXive](R) project is free software; you can redistribute
009: * it and/or modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation;
011: * either version 2 of the License, or (at your option) any
012: * later version.
013: *
014: * The GNU General Public License can be found at
015: * http://www.gnu.org/copyleft/gpl.html.
016: * A copy is found in the textfile GPL.txt and important notices to the
017: * license from the author are found in LICENSE.txt distributed with
018: * these libraries.
019: *
020: * This library is distributed in the hope that it will be useful,
021: * but WITHOUT ANY WARRANTY; without even the implied warranty of
022: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
023: * GNU General Public License for more details.
024: *
025: * For further information about UCS - unique computing solutions gmbh,
026: * please see the company website: http://www.ucs.at
027: *
028: * For further information about [fleXive](R), please see the
029: * project website: http://www.flexive.org
030: *
031: *
032: * This copyright notice MUST APPEAR in all copies of the file!
033: ***************************************************************/package com.flexive.tests.embedded;
034:
035: import com.flexive.shared.exceptions.FxApplicationException;
036: import org.apache.commons.logging.Log;
037: import org.apache.commons.logging.LogFactory;
038:
039: import java.io.File;
040: import java.io.FileInputStream;
041: import java.io.IOException;
042: import java.net.MalformedURLException;
043: import java.net.URL;
044: import java.util.Properties;
045:
046: /**
047: * Abstract base class for a container bootstrap to be used in a "dropped in"
048: * flexive application. To use this, you must subclass this class and at least
049: * override the {@link #startup()} and {@link #shutdown()} methods and annotate them
050: * with TestNG's BeforeSuite and AfterSuite annotations.
051: *
052: * @author Daniel Lichtenberger (daniel.lichtenberger@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
053: * @version $Rev: 181 $
054: */
055: public abstract class AbstractDropContainerBootstrap extends
056: ContainerBootstrap {
057: private static final transient Log LOG = LogFactory
058: .getLog(AbstractDropContainerBootstrap.class);
059:
060: @Override
061: public void startup() throws FxApplicationException {
062: try {
063: // deploy dropped ejbs
064: deployDirectories.add(new URL(
065: getFileUrl(getFlexiveBaseDir() + "/drop")));
066: // container bootstrap
067: super .startup();
068: } catch (MalformedURLException e) {
069: throw new IllegalArgumentException(e);
070: }
071: }
072:
073: @Override
074: public void shutdown() throws FxApplicationException {
075: super .shutdown();
076: }
077:
078: @Override
079: protected String getFlexiveBaseDir() {
080: FileInputStream fis = null;
081: try {
082: final Properties buildProperties = new Properties();
083: fis = new FileInputStream(new File("build.properties"));
084: buildProperties.load(fis);
085: return new File(buildProperties.getProperty("flexive.dir"))
086: .getCanonicalPath();
087: } catch (IOException e) {
088: if (fis != null) {
089: try {
090: fis.close();
091: } catch (IOException e1) {
092: // ignore
093: }
094: }
095: LOG.error(e.getMessage(), e);
096: throw new IllegalStateException(e);
097: }
098: }
099:
100: @Override
101: protected String getFlexiveDistDir() {
102: return "/dist";
103: }
104:
105: }
|