CPD Results
The following document contains the results of PMD's CPD 6.29.0.
Duplications
| File | Line |
|---|---|
| org\apache\fulcrum\testcontainer\BaseUnit4Test.java | 137 |
| org\apache\fulcrum\testcontainer\BaseUnit5Test.java | 144 |
public void tearDown()
{
if (container != null) {
container.dispose();
}
container = null;
}
/**
* Gets the configuration file name for the container should use for this test.
*
* @return The filename of the configuration file
*/
protected String getConfigurationFileName()
{
return configurationFileName;
}
/**
* Gets the role file name for the container should use for this test.
*
* @return The filename of the role configuration file
*/
protected String getRoleFileName()
{
return roleFileName;
}
/**
* Gets the parameter file name for the container should use for this test.
*
* @return The filename of the role configuration file
*/
protected String getParameterFileName()
{
return parameterFileName;
}
/**
* Returns an instance of the named component. This method will also start the
* container if it has not been started already
*
* @param roleName Name of the role the component fills.
* @return instance of the component
* @throws ComponentException generic exception
*/
protected Object lookup(String roleName) throws ComponentException
{
if (container == null)
{
if (containerType.equals(CONTAINER_ECM))
{
container = new ECMContainer();
}
else
{
container = new YAAFIContainer(logLevel);
}
container.startup(getConfigurationFileName(), getRoleFileName(), getParameterFileName());
}
return container.lookup(roleName);
}
/**
* Releases the component.
*
* @param component component to be released
*/
protected void release(Object component)
{
if (container != null)
{
container.release(component);
}
}
/**
* Get a mock requestion
*
* @return HttpServletRequest a mock servlet request
*/
protected HttpServletRequest getMockRequest()
{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpSession session = mock(HttpSession.class);
doAnswer(new Answer<Object>()
{
@Override
public Object answer(InvocationOnMock invocation) throws Throwable
{
String key = (String) invocation.getArguments()[0];
return attributes.get(key);
}
}).when(session).getAttribute(anyString());
doAnswer(new Answer<Object>()
{
@Override
public Object answer(InvocationOnMock invocation) throws Throwable
{
String key = (String) invocation.getArguments()[0];
Object value = invocation.getArguments()[1];
attributes.put(key, value);
return null;
}
}).when(session).setAttribute(anyString(), any());
when(session.getMaxInactiveInterval()).thenReturn(maxInactiveInterval);
doAnswer(new Answer<Integer>()
{
@Override
public Integer answer(InvocationOnMock invocation) throws Throwable {
return Integer.valueOf(maxInactiveInterval);
}
}).when(session).getMaxInactiveInterval();
doAnswer(new Answer<Object>()
{
@Override
public Object answer(InvocationOnMock invocation) throws Throwable
{
Integer value = (Integer) invocation.getArguments()[0];
maxInactiveInterval = value.intValue();
return null;
}
}).when(session).setMaxInactiveInterval(anyInt());
when(session.isNew()).thenReturn(true);
when(request.getSession()).thenReturn(session);
when(request.getServerName()).thenReturn("bob");
when(request.getProtocol()).thenReturn("http");
when(request.getScheme()).thenReturn("scheme");
when(request.getPathInfo()).thenReturn("damn");
when(request.getServletPath()).thenReturn("damn2");
when(request.getContextPath()).thenReturn("wow");
when(request.getContentType()).thenReturn("text/html");
when(request.getCharacterEncoding()).thenReturn("US-ASCII");
when(request.getServerPort()).thenReturn(8080);
when(request.getLocale()).thenReturn(Locale.US);
when(request.getHeader("Content-type")).thenReturn("text/html");
when(request.getHeader("Accept-Language")).thenReturn("en-US");
Vector<String> v = new Vector<String>();
when(request.getParameterNames()).thenReturn(v.elements());
return request;
}
public String getContainerType()
{
return containerType;
}
public void setContainerType(String containerType)
{
this.containerType = containerType;
}
} | |

