|
|||||||||||||||||||
| 30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| ServerTestCaseCaller.java | 50% | 91.7% | 100% | 87.5% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* ========================================================================
|
|
| 3 |
*
|
|
| 4 |
* Copyright 2001-2003 The Apache Software Foundation.
|
|
| 5 |
*
|
|
| 6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
| 7 |
* you may not use this file except in compliance with the License.
|
|
| 8 |
* You may obtain a copy of the License at
|
|
| 9 |
*
|
|
| 10 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
| 11 |
*
|
|
| 12 |
* Unless required by applicable law or agreed to in writing, software
|
|
| 13 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
| 14 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
| 15 |
* See the License for the specific language governing permissions and
|
|
| 16 |
* limitations under the License.
|
|
| 17 |
*
|
|
| 18 |
* ========================================================================
|
|
| 19 |
*/
|
|
| 20 |
package org.apache.cactus.internal.server;
|
|
| 21 |
|
|
| 22 |
import junit.framework.Assert;
|
|
| 23 |
import junit.framework.Test;
|
|
| 24 |
|
|
| 25 |
import org.apache.commons.logging.Log;
|
|
| 26 |
import org.apache.commons.logging.LogFactory;
|
|
| 27 |
|
|
| 28 |
/**
|
|
| 29 |
* Provide the ability to execute Cactus test case classes on the server side.
|
|
| 30 |
* It mimics the JUnit behavior by calling <code>setUp()</code>,
|
|
| 31 |
* <code>testXXX()</code> and <code>tearDown()</code> methods on the server
|
|
| 32 |
* side.
|
|
| 33 |
*
|
|
| 34 |
* @version $Id: ServerTestCaseCaller.java 238991 2004-05-22 11:34:50Z vmassol $
|
|
| 35 |
*/
|
|
| 36 |
public class ServerTestCaseCaller extends Assert |
|
| 37 |
{
|
|
| 38 |
/**
|
|
| 39 |
* The logger.
|
|
| 40 |
*/
|
|
| 41 |
private Log logger;
|
|
| 42 |
|
|
| 43 |
/**
|
|
| 44 |
* The test we are delegating for.
|
|
| 45 |
*/
|
|
| 46 |
private Test delegatedTest;
|
|
| 47 |
|
|
| 48 |
/**
|
|
| 49 |
* Pure JUnit Test Case that we are wrapping (if any)
|
|
| 50 |
*/
|
|
| 51 |
private Test wrappedTest;
|
|
| 52 |
|
|
| 53 |
/**
|
|
| 54 |
* @param theDelegatedTest the test we are delegating for
|
|
| 55 |
* @param theWrappedTest the test being wrapped by this delegate (or null
|
|
| 56 |
* if none)
|
|
| 57 |
*/
|
|
| 58 | 48 |
public ServerTestCaseCaller(Test theDelegatedTest, Test theWrappedTest)
|
| 59 |
{
|
|
| 60 | 48 |
if (theDelegatedTest == null) |
| 61 |
{
|
|
| 62 | 0 |
throw new IllegalStateException( |
| 63 |
"The test object passed must not be null");
|
|
| 64 |
} |
|
| 65 |
|
|
| 66 | 48 |
setDelegatedTest(theDelegatedTest); |
| 67 | 48 |
setWrappedTest(theWrappedTest); |
| 68 |
} |
|
| 69 |
|
|
| 70 |
/**
|
|
| 71 |
* @param theWrappedTest the pure JUnit test that we need to wrap
|
|
| 72 |
*/
|
|
| 73 | 48 |
public void setWrappedTest(Test theWrappedTest) |
| 74 |
{
|
|
| 75 | 48 |
this.wrappedTest = theWrappedTest;
|
| 76 |
} |
|
| 77 |
|
|
| 78 |
/**
|
|
| 79 |
* @return the wrapped JUnit test
|
|
| 80 |
*/
|
|
| 81 | 48 |
public Test getWrappedTest()
|
| 82 |
{
|
|
| 83 | 48 |
return this.wrappedTest; |
| 84 |
} |
|
| 85 |
|
|
| 86 |
/**
|
|
| 87 |
* @param theDelegatedTest the test we are delegating for
|
|
| 88 |
*/
|
|
| 89 | 48 |
public void setDelegatedTest(Test theDelegatedTest) |
| 90 |
{
|
|
| 91 | 48 |
this.delegatedTest = theDelegatedTest;
|
| 92 |
} |
|
| 93 |
|
|
| 94 |
/**
|
|
| 95 |
* @return the test we are delegating for
|
|
| 96 |
*/
|
|
| 97 | 24 |
public Test getDelegatedTest()
|
| 98 |
{
|
|
| 99 | 24 |
return this.delegatedTest; |
| 100 |
} |
|
| 101 |
|
|
| 102 |
/**
|
|
| 103 |
* Perform server side initializations before each test, such as
|
|
| 104 |
* initializating the logger.
|
|
| 105 |
*/
|
|
| 106 | 24 |
public void runBareInit() |
| 107 |
{
|
|
| 108 |
// Initialize the logging system. As this class is instanciated both
|
|
| 109 |
// on the server side and on the client side, we need to differentiate
|
|
| 110 |
// the logging initialisation. This method is only called on the server
|
|
| 111 |
// side, so we instanciate the log for server side here.
|
|
| 112 | 24 |
if (getLogger() == null) |
| 113 |
{
|
|
| 114 | 24 |
setLogger(LogFactory.getLog(getDelegatedTest().getClass())); |
| 115 |
} |
|
| 116 |
} |
|
| 117 |
|
|
| 118 |
/**
|
|
| 119 |
* @return the logger pointing to the wrapped test case that use to perform
|
|
| 120 |
* logging on behalf of the wrapped test.
|
|
| 121 |
*/
|
|
| 122 | 24 |
private Log getLogger()
|
| 123 |
{
|
|
| 124 | 24 |
return this.logger; |
| 125 |
} |
|
| 126 |
|
|
| 127 |
/**
|
|
| 128 |
* @param theLogger the logger to use
|
|
| 129 |
*/
|
|
| 130 | 24 |
private void setLogger(Log theLogger) |
| 131 |
{
|
|
| 132 | 24 |
this.logger = theLogger;
|
| 133 |
} |
|
| 134 |
} |
|
| 135 |
|
|
||||||||||