|
|||||||||||||||||||
| 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 | |||||||||||||||
| ContainerSet.java | 62.5% | 68.4% | 88.9% | 72.2% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* ========================================================================
|
|
| 3 |
*
|
|
| 4 |
* Copyright 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.integration.ant;
|
|
| 21 |
|
|
| 22 |
import java.util.ArrayList;
|
|
| 23 |
import java.util.List;
|
|
| 24 |
|
|
| 25 |
import org.apache.cactus.integration.ant.container.Container;
|
|
| 26 |
import org.apache.cactus.integration.ant.container.ContainerFactory;
|
|
| 27 |
import org.apache.cactus.integration.ant.container.ContainerWrapper;
|
|
| 28 |
import org.apache.cactus.integration.ant.container.GenericContainer;
|
|
| 29 |
import org.apache.tools.ant.BuildException;
|
|
| 30 |
import org.apache.tools.ant.DynamicConfigurator;
|
|
| 31 |
import org.apache.tools.ant.types.DataType;
|
|
| 32 |
|
|
| 33 |
/**
|
|
| 34 |
* Ant data type that represents a set of J2EE containers.
|
|
| 35 |
*
|
|
| 36 |
* @version $Id: ContainerSet.java 238810 2004-02-29 10:05:26Z vmassol $
|
|
| 37 |
*/
|
|
| 38 |
public class ContainerSet extends DataType implements DynamicConfigurator |
|
| 39 |
{
|
|
| 40 |
|
|
| 41 |
// Instance Variables ------------------------------------------------------
|
|
| 42 |
|
|
| 43 |
/**
|
|
| 44 |
* The list of nested container elements.
|
|
| 45 |
*/
|
|
| 46 |
private ContainerFactory factory = new ContainerFactory(); |
|
| 47 |
|
|
| 48 |
/**
|
|
| 49 |
* The list of nested container and containerset elements.
|
|
| 50 |
*/
|
|
| 51 |
private List containers = new ArrayList(); |
|
| 52 |
|
|
| 53 |
/**
|
|
| 54 |
* The timeout in milliseconds.
|
|
| 55 |
*/
|
|
| 56 |
private long timeout = -1; |
|
| 57 |
|
|
| 58 |
/**
|
|
| 59 |
* The proxy port.
|
|
| 60 |
*/
|
|
| 61 |
private int proxyPort = -1; |
|
| 62 |
|
|
| 63 |
// DynamicConfigurator Implementation --------------------------------------
|
|
| 64 |
|
|
| 65 |
/**
|
|
| 66 |
* @see org.apache.tools.ant.DynamicConfigurator#createDynamicElement
|
|
| 67 |
*/
|
|
| 68 | 0 |
public final Object createDynamicElement(String theName)
|
| 69 |
throws BuildException
|
|
| 70 |
{
|
|
| 71 | 0 |
if (isReference())
|
| 72 |
{
|
|
| 73 | 0 |
throw noChildrenAllowed();
|
| 74 |
} |
|
| 75 | 0 |
Container container = this.factory.createContainer(theName);
|
| 76 | 0 |
this.containers.add(container);
|
| 77 | 0 |
return container;
|
| 78 |
} |
|
| 79 |
|
|
| 80 |
/**
|
|
| 81 |
* @see org.apache.tools.ant.DynamicConfigurator#setDynamicAttribute
|
|
| 82 |
*/
|
|
| 83 | 6 |
public final void setDynamicAttribute(String theName, String theValue) |
| 84 |
throws BuildException
|
|
| 85 |
{
|
|
| 86 | 6 |
if (isReference())
|
| 87 |
{
|
|
| 88 | 0 |
throw tooManyAttributes();
|
| 89 |
} |
|
| 90 | 6 |
throw new BuildException("Attribute [" + theName |
| 91 |
+ "] not supported");
|
|
| 92 |
} |
|
| 93 |
|
|
| 94 |
// Public Methods ----------------------------------------------------------
|
|
| 95 |
|
|
| 96 |
/**
|
|
| 97 |
* Adds a nested generic container to the set of containers.
|
|
| 98 |
*
|
|
| 99 |
* @param theContainer The generic container element to add
|
|
| 100 |
*/
|
|
| 101 | 3 |
public final void addGeneric(GenericContainer theContainer) |
| 102 |
{
|
|
| 103 | 3 |
this.containers.add(theContainer);
|
| 104 |
} |
|
| 105 |
|
|
| 106 |
/**
|
|
| 107 |
* Returns an iterator over the nested container elements, in the order
|
|
| 108 |
* they appear in the build file.
|
|
| 109 |
*
|
|
| 110 |
* @return An iterator over the nested container elements
|
|
| 111 |
*/
|
|
| 112 | 6 |
public final Container[] getContainers()
|
| 113 |
{
|
|
| 114 | 6 |
Container[] containers = (Container[]) |
| 115 |
this.containers.toArray(new Container[this.containers.size()]); |
|
| 116 | 6 |
if (this.proxyPort > 0) |
| 117 |
{
|
|
| 118 | 3 |
for (int i = 0; i < containers.length; i++) |
| 119 |
{
|
|
| 120 | 2 |
containers[i] = new ContainerWrapper(containers[i])
|
| 121 |
{
|
|
| 122 | 1 |
public int getPort() |
| 123 |
{
|
|
| 124 | 1 |
return proxyPort;
|
| 125 |
} |
|
| 126 |
}; |
|
| 127 |
} |
|
| 128 |
} |
|
| 129 | 6 |
return containers;
|
| 130 |
} |
|
| 131 |
|
|
| 132 |
/**
|
|
| 133 |
* Returns the timeout after which connecting to a container will be
|
|
| 134 |
* given up, or <code>-1</code> if no timeout has been set.
|
|
| 135 |
*
|
|
| 136 |
* @return The timeout in milliseconds
|
|
| 137 |
*/
|
|
| 138 | 3 |
public final long getTimeout() |
| 139 |
{
|
|
| 140 | 3 |
return this.timeout; |
| 141 |
} |
|
| 142 |
|
|
| 143 |
/**
|
|
| 144 |
* Sets the timeout after which connecting to a container will be given
|
|
| 145 |
* up.
|
|
| 146 |
*
|
|
| 147 |
* @param theTimeout The timeout in milliseconds
|
|
| 148 |
*/
|
|
| 149 | 1 |
public final void setTimeout(long theTimeout) |
| 150 |
{
|
|
| 151 | 1 |
this.timeout = theTimeout;
|
| 152 |
} |
|
| 153 |
|
|
| 154 |
/**
|
|
| 155 |
* Returns the proxy port, or <code>-1</code> if no proxy port has been set.
|
|
| 156 |
*
|
|
| 157 |
* @return The proxy port
|
|
| 158 |
*/
|
|
| 159 | 3 |
public final int getProxyPort() |
| 160 |
{
|
|
| 161 | 3 |
return this.proxyPort; |
| 162 |
} |
|
| 163 |
|
|
| 164 |
/**
|
|
| 165 |
* Sets the proxy port which will be used by the test caller instead
|
|
| 166 |
* of the real container port. This can be used to insert protocol
|
|
| 167 |
* tracers between the test caller and the container.
|
|
| 168 |
*
|
|
| 169 |
* @param theProxyPort The proxy port to set
|
|
| 170 |
*/
|
|
| 171 | 3 |
public final void setProxyPort(int theProxyPort) |
| 172 |
{
|
|
| 173 | 3 |
this.proxyPort = theProxyPort;
|
| 174 |
} |
|
| 175 |
|
|
| 176 |
} |
|
| 177 |
|
|
||||||||||