001: /* JWebUnitTestStep.java
002: *
003: * DDSteps - Data Driven JUnit Test Steps
004: * Copyright (C) 2005 Jayway AB
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License version 2.1 as published by the Free Software Foundation.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, visit
017: * http://www.opensource.org/licenses/lgpl-license.php
018: */
019: package org.ddsteps.step.jwebunit;
020:
021: import org.apache.commons.lang.Validate;
022: import org.ddsteps.step.web.WebBrowserTestStep;
023: import org.ddsteps.web.WebBrowser;
024: import org.ddsteps.web.jwebunit.JWebUnitWebBrowser;
025: import org.springframework.beans.factory.InitializingBean;
026:
027: /**
028: * Subclass this step to build you own test steps based on JWebUnit.
029: * <p>
030: * If you do not need access to JWebUnit internal stuff, like the TestContext
031: * etc., the you are better off using the {@link WebBrowserTestStep}.
032: *
033: * @author Adam
034: * @version $Id: JWebUnitTestStep.java,v 1.3 2006/05/01 15:34:51 adamskogman Exp $
035: */
036: public abstract class JWebUnitTestStep extends WebBrowserTestStep
037: implements InitializingBean {
038:
039: /**
040: * Delegate
041: */
042: protected JWebUnitWebBrowser jWebUnitWebBrowser;
043:
044: /**
045: * Dependency injection constructor. Please expose this one in your
046: * subclass.
047: *
048: * @param webBrowser
049: * The webtester to use.
050: */
051: public JWebUnitTestStep(JWebUnitWebBrowser webBrowser) {
052: Validate.notNull(webBrowser,
053: "Argument webBrowser must not be null.");
054: this .jWebUnitWebBrowser = webBrowser;
055: this .webBrowser = webBrowser;
056: }
057:
058: /**
059: * Use {@link #setJWebUnitWebBrowser(JWebUnitWebBrowser)} to inject
060: * dependecy.
061: */
062: public JWebUnitTestStep() {
063: }
064:
065: /**
066: * @return Returns the webBrowser.
067: */
068: public JWebUnitWebBrowser getJWebUnitWebBrowser() {
069: return jWebUnitWebBrowser;
070: }
071:
072: /**
073: * @param webBrowser
074: * The webBrowser to set.
075: */
076: public void setJWebUnitWebBrowser(JWebUnitWebBrowser webBrowser) {
077: this .jWebUnitWebBrowser = webBrowser;
078: this .webBrowser = webBrowser;
079: }
080:
081: /**
082: * Checks that the webbrowser is set.
083: *
084: * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
085: */
086: public void afterPropertiesSet() throws Exception {
087: super .afterPropertiesSet();
088: Validate.notNull(jWebUnitWebBrowser,
089: "Dependency WebBrowser not set.");
090: }
091:
092: /**
093: *
094: * @see org.ddsteps.step.web.WebBrowserTestStep#setWebBrowser(org.ddsteps.web.WebBrowser)
095: * @deprecated Use {@link #setJWebUnitWebBrowser(JWebUnitWebBrowser)}
096: * instead.
097: */
098: public void setWebBrowser(WebBrowser webBrowser) {
099: if (webBrowser instanceof JWebUnitWebBrowser) {
100: setJWebUnitWebBrowser((JWebUnitWebBrowser) webBrowser);
101: }
102: super.setWebBrowser(webBrowser);
103: }
104:
105: }
|