WW-4515 Convert try blocks to try-with-resources

This commit is contained in:
Aaron Johnson
2015-06-17 09:24:08 -05:00
parent bf15ad20b1
commit 3fab155b4c
24 changed files with 99 additions and 270 deletions
@@ -465,12 +465,11 @@ public class Component {
* @return the exception as a string.
*/
protected String toString(Throwable t) {
FastByteArrayOutputStream bout = new FastByteArrayOutputStream();
PrintWriter wrt = new PrintWriter(bout);
t.printStackTrace(wrt);
wrt.close();
return bout.toString();
try (FastByteArrayOutputStream bout = new FastByteArrayOutputStream();
PrintWriter wrt = new PrintWriter(bout)) {
t.printStackTrace(wrt);
return bout.toString();
}
}
/**
@@ -64,20 +64,10 @@ class PropertiesSettings implements Settings {
settings = new LocatableProperties(new LocationImpl(null, settingsUrl.toString()));
// Load settings
InputStream in = null;
try {
in = settingsUrl.openStream();
try (InputStream in = settingsUrl.openStream()) {
settings.load(in);
} catch (IOException e) {
throw new StrutsException("Could not load " + name + ".properties: " + e, e);
} finally {
if(in != null) {
try {
in.close();
} catch(IOException io) {
LOG.warn("Unable to close input stream", io);
}
}
}
}
@@ -122,24 +122,11 @@ public class PlainTextResult extends StrutsResultSupport {
applyAdditionalHeaders(response);
String location = adjustLocation(finalLocation);
PrintWriter writer = response.getWriter();
InputStreamReader reader = null;
try {
InputStream resourceAsStream = readStream(invocation, location);
try (PrintWriter writer = response.getWriter();
InputStream resourceAsStream = readStream(invocation, location);
InputStreamReader reader = new InputStreamReader(resourceAsStream, charset == null ? Charset.defaultCharset() : charset)) {
logWrongStream(finalLocation, resourceAsStream);
if (charset != null) {
reader = new InputStreamReader(resourceAsStream, charset);
} else {
reader = new InputStreamReader(resourceAsStream);
}
sendStream(writer, reader);
} finally {
if (reader != null)
reader.close();
if (writer != null) {
writer.flush();
writer.close();
}
}
}
@@ -221,9 +221,9 @@ public class StreamResult extends StrutsResultSupport {
// Override any parameters using values on the stack
resolveParamsFromStack(invocation.getStack(), invocation);
OutputStream oOutput = null;
try {
// Find the Response in context
HttpServletResponse oResponse = (HttpServletResponse) invocation.getInvocationContext().get(HTTP_RESPONSE);
try (OutputStream oOutput = oResponse.getOutputStream()) {
if (inputStream == null) {
// Find the inputstream from the invocation variable stack
inputStream = (InputStream) invocation.getStack().findValue(conditionalParse(inputName, invocation));
@@ -236,9 +236,6 @@ public class StreamResult extends StrutsResultSupport {
throw new IllegalArgumentException(msg);
}
// Find the Response in context
HttpServletResponse oResponse = (HttpServletResponse) invocation.getInvocationContext().get(HTTP_RESPONSE);
// Set the content type
if (contentCharSet != null && ! contentCharSet.equals("")) {
oResponse.setContentType(conditionalParse(contentType, invocation)+";charset="+contentCharSet);
@@ -273,9 +270,6 @@ public class StreamResult extends StrutsResultSupport {
oResponse.addHeader("Cache-Control", "no-cache");
}
// Get the outputstream
oOutput = oResponse.getOutputStream();
LOG.debug("Streaming result [{}] type=[{}] length=[{}] content-disposition=[{}] charset=[{}]",
inputName, contentType, contentLength, contentDisposition, contentCharSet);
@@ -291,10 +285,6 @@ public class StreamResult extends StrutsResultSupport {
// Flush
oOutput.flush();
}
finally {
if (inputStream != null) inputStream.close();
if (oOutput != null) oOutput.close();
}
}
/**
@@ -449,31 +449,14 @@ public class JakartaStreamMultiPartRequest implements MultiPartRequest {
*/
private boolean streamFileToDisk(FileItemStream itemStream, File file) throws IOException {
boolean result = false;
InputStream input = itemStream.openStream();
OutputStream output = null;
try {
output = new BufferedOutputStream(new FileOutputStream(file), bufferSize);
try (InputStream input = itemStream.openStream();
OutputStream output = new BufferedOutputStream(new FileOutputStream(file), bufferSize)) {
byte[] buffer = new byte[bufferSize];
LOG.debug("Streaming file using buffer size {}.", bufferSize);
for (int length = 0; ((length = input.read(buffer)) > 0); ) {
output.write(buffer, 0, length);
}
result = true;
} finally {
if (output != null) {
try {
output.close();
} catch (IOException e) {
LOG.warn("Error occurred during closing of OutputStream.", e);
}
}
if (input != null) {
try {
input.close();
} catch (IOException e) {
LOG.warn("Error occurred during closing of InputStream.", e);
}
}
}
return result;
}
@@ -192,11 +192,9 @@ public class DebuggingInterceptor extends AbstractInterceptor {
HttpServletResponse res = ServletActionContext.getResponse();
res.setContentType("text/plain");
try {
PrintWriter writer =
ServletActionContext.getResponse().getWriter();
try (PrintWriter writer =
ServletActionContext.getResponse().getWriter()) {
writer.print(stack.findValue(cmd));
writer.close();
} catch (IOException ex) {
ex.printStackTrace();
}
@@ -213,8 +211,7 @@ public class DebuggingInterceptor extends AbstractInterceptor {
ValueStack stack = (ValueStack) ctx.get(ActionContext.VALUE_STACK);
Object rootObject = stack.findValue(rootObjectExpression);
try {
StringWriter writer = new StringWriter();
try (StringWriter writer = new StringWriter()) {
ObjectToHTMLWriter htmlWriter = new ObjectToHTMLWriter(writer);
htmlWriter.write(reflectionProvider, rootObject, rootObjectExpression);
String html = writer.toString();
@@ -133,20 +133,10 @@ public class FastByteArrayOutputStream extends OutputStream {
* This method is need only for debug. And needed for tests generated files.
*/
private void writeToFile() {
FileOutputStream fileOutputStream = null;
try {
fileOutputStream = new FileOutputStream(File.createTempFile(getClass().getName() + System.currentTimeMillis(), ".log"));
try (FileOutputStream fileOutputStream = new FileOutputStream(File.createTempFile(getClass().getName() + System.currentTimeMillis(), ".log"))){
writeTo(fileOutputStream);
} catch (IOException e) {
// Ignore
} finally {
if (fileOutputStream != null) {
try {
fileOutputStream.close();
} catch (IOException e) {
// Ignore
}
}
}
}
@@ -436,12 +436,7 @@ public class FreemarkerManager {
* @see freemarker.template.Configuration#setSettings for the definition of valid settings
*/
protected void loadSettings(ServletContext servletContext) {
InputStream in = null;
try {
in = fileManager.loadFile(ClassLoaderUtil.getResource("freemarker.properties", getClass()));
try (InputStream in = fileManager.loadFile(ClassLoaderUtil.getResource("freemarker.properties", getClass()))){
if (in != null) {
Properties p = new Properties();
p.load(in);
@@ -465,14 +460,6 @@ public class FreemarkerManager {
LOG.error("Error while loading freemarker settings from /freemarker.properties", e);
} catch (TemplateException e) {
LOG.error("Error while loading freemarker settings from /freemarker.properties", e);
} finally {
if (in != null) {
try {
in.close();
} catch(IOException io) {
LOG.warn("Unable to close input stream", io);
}
}
}
}
@@ -66,12 +66,12 @@ public class StrutsBodyTagSupport extends BodyTagSupport {
}
protected String toString(Throwable t) {
FastByteArrayOutputStream bout = new FastByteArrayOutputStream();
PrintWriter wrt = new PrintWriter(bout);
t.printStackTrace(wrt);
wrt.close();
try (FastByteArrayOutputStream bout = new FastByteArrayOutputStream();
PrintWriter wrt = new PrintWriter(bout)) {
t.printStackTrace(wrt);
return bout.toString();
return bout.toString();
}
}
protected String getBody() {
@@ -82,16 +82,15 @@ public class TestUtils {
}
StringBuilder buffer = new StringBuilder(128);
InputStream in = url.openStream();
byte[] buf = new byte[4096];
int nbytes;
try (InputStream in = url.openStream()) {
byte[] buf = new byte[4096];
int nbytes;
while((nbytes = in.read(buf)) > 0) {
buffer.append(new String(buf, 0, nbytes));
while ((nbytes = in.read(buf)) > 0) {
buffer.append(new String(buf, 0, nbytes));
}
}
in.close();
return buffer.toString();
}
}
@@ -56,13 +56,11 @@ public class PlainTextResultTest extends StrutsInternalTestCase {
response.setExpectedContentType("text/plain");
response.setExpectedHeader("Content-Disposition", "inline");
InputStream jspResourceInputStream =
try (InputStream jspResourceInputStream =
ClassLoaderUtil.getResourceAsStream(
"org/apache/struts2/dispatcher/someJspFile.jsp",
PlainTextResultTest.class);
try {
PlainTextResultTest.class)) {
servletContext.setResourceAsStream(jspResourceInputStream);
result.execute(invocation);
@@ -71,9 +69,6 @@ public class PlainTextResultTest extends StrutsInternalTestCase {
readAsString("org/apache/struts2/dispatcher/someJspFile.jsp"), true);
assertEquals(r, e);
}
finally {
jspResourceInputStream.close();
}
}
public void testPlainTextWithoutSlash() throws Exception {
@@ -82,11 +77,9 @@ public class PlainTextResultTest extends StrutsInternalTestCase {
response.setExpectedContentType("text/plain");
response.setExpectedHeader("Content-Disposition", "inline");
InputStream jspResourceInputStream =
ClassLoaderUtil.getResourceAsStream("org/apache/struts2/dispatcher/someJspFile.jsp", PlainTextResultTest.class);
try {
try (InputStream jspResourceInputStream =
ClassLoaderUtil.getResourceAsStream("org/apache/struts2/dispatcher/someJspFile.jsp", PlainTextResultTest.class)) {
servletContext.setResourceAsStream(jspResourceInputStream);
result.execute(invocation);
@@ -94,9 +87,6 @@ public class PlainTextResultTest extends StrutsInternalTestCase {
String e = AbstractUITagTest.normalize(readAsString("org/apache/struts2/dispatcher/someJspFile.jsp"), true);
assertEquals(r, e);
}
finally {
jspResourceInputStream.close();
}
}
public void testPlainTextWithEncoding() throws Exception {
@@ -106,13 +96,11 @@ public class PlainTextResultTest extends StrutsInternalTestCase {
response.setExpectedContentType("text/plain; charset=UTF-8");
response.setExpectedHeader("Content-Disposition", "inline");
InputStream jspResourceInputStream =
try (InputStream jspResourceInputStream =
ClassLoaderUtil.getResourceAsStream(
"org/apache/struts2/dispatcher/someJspFile.jsp",
PlainTextResultTest.class);
try {
PlainTextResultTest.class)) {
servletContext.setResourceAsStream(jspResourceInputStream);
result.execute(invocation);
@@ -121,15 +109,10 @@ public class PlainTextResultTest extends StrutsInternalTestCase {
readAsString("org/apache/struts2/dispatcher/someJspFile.jsp"), true);
assertEquals(r, e);
}
finally {
jspResourceInputStream.close();
}
}
protected String readAsString(String resource) throws Exception {
InputStream is = null;
try {
is = ClassLoaderUtil.getResourceAsStream(resource, PlainTextResultTest.class);
try (InputStream is = ClassLoaderUtil.getResourceAsStream(resource, PlainTextResultTest.class)) {
int sizeRead = 0;
byte[] buffer = new byte[1024];
StringBuilder stringBuilder = new StringBuilder();
@@ -138,11 +121,6 @@ public class PlainTextResultTest extends StrutsInternalTestCase {
}
return stringBuilder.toString();
}
finally {
if (is != null)
is.close();
}
}
@@ -251,16 +251,15 @@ public abstract class AbstractUITagTest extends AbstractTagTest {
}
StringBuilder buffer = new StringBuilder(128);
InputStream in = url.openStream();
byte[] buf = new byte[4096];
int nbytes;
while ((nbytes = in.read(buf)) > 0) {
buffer.append(new String(buf, 0, nbytes));
try (InputStream in = url.openStream()) {
byte[] buf = new byte[4096];
int nbytes;
while ((nbytes = in.read(buf)) > 0) {
buffer.append(new String(buf, 0, nbytes));
}
}
in.close();
/**
* compare the trimmed values of each buffer and make sure they're equivalent. however, let's make sure to
* normalize the strings first to account for line termination differences between platforms.
@@ -23,9 +23,11 @@ package org.apache.struts2.views.jasperreports;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.util.ValueStack;
import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.export.*;
import net.sf.jasperreports.engine.util.JRLoader;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -37,9 +39,11 @@ import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;
@@ -244,12 +248,9 @@ public class JasperReportsResult extends StrutsResultSupport implements JasperRe
// Handle IE special case: it sends a "contype" request first.
// TODO Set content type to config settings?
if ("contype".equals(request.getHeader("User-Agent"))) {
try {
try (OutputStream outputStream = response.getOutputStream()) {
response.setContentType("application/pdf");
response.setContentLength(0);
ServletOutputStream outputStream = response.getOutputStream();
outputStream.close();
} catch (IOException e) {
LOG.error("Error writing report output", e);
throw new ServletException(e.getMessage(), e);
@@ -300,7 +301,7 @@ public class JasperReportsResult extends StrutsResultSupport implements JasperRe
parameters.putAll(reportParams);
}
byte[] output;
ByteArrayOutputStream output;
JasperPrint jasperPrint;
// Fill the report and produce a print object
@@ -381,8 +382,7 @@ public class JasperReportsResult extends StrutsResultSupport implements JasperRe
throw new ServletException(e.getMessage(), e);
}
response.setContentLength(output.length);
response.setContentLength(output.size());
// Will throw ServletException on IOException.
writeReport(response, output);
}
@@ -394,24 +394,12 @@ public class JasperReportsResult extends StrutsResultSupport implements JasperRe
* @param output Report bytes to write.
* @throws ServletException on stream IOException.
*/
private void writeReport(HttpServletResponse response, byte[] output) throws ServletException {
ServletOutputStream outputStream = null;
try {
outputStream = response.getOutputStream();
outputStream.write(output);
private void writeReport(HttpServletResponse response, ByteArrayOutputStream output) throws ServletException {
try (OutputStream outputStream = response.getOutputStream()) {
outputStream.flush();
} catch (IOException e) {
LOG.error("Error writing report output", e);
throw new ServletException(e.getMessage(), e);
} finally {
try {
if (outputStream != null) {
outputStream.close();
}
} catch (IOException e) {
LOG.error("Error closing report output stream", e);
throw new ServletException(e.getMessage(), e);
}
}
}
@@ -456,8 +444,7 @@ public class JasperReportsResult extends StrutsResultSupport implements JasperRe
* @throws net.sf.jasperreports.engine.JRException
* If there is a problem running the report
*/
private byte[] exportReportToBytes(JasperPrint jasperPrint, JRExporter exporter) throws JRException {
byte[] output;
private ByteArrayOutputStream exportReportToBytes(JasperPrint jasperPrint, JRExporter exporter) throws JRException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
@@ -467,10 +454,7 @@ public class JasperReportsResult extends StrutsResultSupport implements JasperRe
}
exporter.exportReport();
output = baos.toByteArray();
return output;
return baos;
}
}
@@ -438,12 +438,9 @@ public class Java8ClassFinder implements ClassFinder {
try {
URL resource = classLoaderInterface.getResource(className);
if (resource != null) {
InputStream in = resource.openStream();
try {
try (InputStream in = resource.openStream()) {
ClassReader classReader = new ClassReader(in);
classReader.accept(new InfoBuildingClassVisitor(this), ClassReader.SKIP_DEBUG);
} finally {
in.close();
}
} else {
throw new XWorkException("Could not load " + className);
@@ -4,14 +4,19 @@ import com.opensymphony.xwork2.FileManager;
import com.opensymphony.xwork2.FileManagerFactory;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ClassLoaderUtil;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import net.sf.oval.configuration.Configurer;
import net.sf.oval.configuration.annotation.AnnotationsConfigurer;
import net.sf.oval.configuration.annotation.JPAAnnotationsConfigurer;
import net.sf.oval.configuration.xml.XMLConfigurer;
import org.apache.struts2.StrutsConstants;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
@@ -152,11 +157,8 @@ public class DefaultOValValidationManager implements OValValidationManager {
protected XMLConfigurer loadFile(String fileName, Class clazz, boolean checkFile) {
URL fileUrl = ClassLoaderUtil.getResource(fileName, clazz);
if ((checkFile && fileManager.fileNeedsReloading(fileUrl)) || !validatorFileCache.containsKey(fileName)) {
java.io.InputStream is = null;
try {
is = fileManager.loadFile(fileUrl);
try (InputStream is = fileManager.loadFile(fileUrl)) {
if (is != null) {
LOG.debug("Loading validation xml file [{}]", fileName);
XMLConfigurer configurer = new XMLConfigurer();
@@ -164,14 +166,8 @@ public class DefaultOValValidationManager implements OValValidationManager {
validatorFileCache.put(fileName, configurer);
return configurer;
}
} finally {
if (is != null) {
try {
is.close();
} catch (java.io.IOException e) {
LOG.error("Unable to close input stream for [{}] ", fileName, e);
}
}
} catch (IOException e) {
LOG.error("Unable to close input stream for [{}] ", fileName, e);
}
} else {
return (XMLConfigurer) validatorFileCache.get(fileName);
@@ -66,18 +66,17 @@ public class SiteGraph {
}
if (args.length != 8 && args.length != 6) {
InputStream is = SiteGraph.class.getResourceAsStream("sitegraph-usage.txt");
byte[] buffer = new byte[2048];
int length;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
while ((length = is.read(buffer)) != -1) {
baos.write(buffer, 0, length);
try (InputStream is = SiteGraph.class.getResourceAsStream("sitegraph-usage.txt");
ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
byte[] buffer = new byte[2048];
int length;
while ((length = is.read(buffer)) != -1) {
baos.write(buffer, 0, length);
}
String usage = baos.toString();
System.out.println(usage.replaceAll("//.*", ""));
}
is.close();
baos.close();
String usage = baos.toString();
System.out.println(usage.replaceAll("//.*", ""));
return;
}
@@ -85,9 +85,7 @@ public abstract class FileBasedView implements View {
protected abstract Pattern getFormPattern();
protected String readFile(File file) {
try {
BufferedReader in = new BufferedReader(new FileReader(file));
try (BufferedReader in = new BufferedReader(new FileReader(file))) {
String s;
StringBuilder buffer = new StringBuilder();
@@ -95,8 +93,6 @@ public abstract class FileBasedView implements View {
buffer.append(s).append('\n');
}
in.close();
return buffer.toString();
} catch (FileNotFoundException e) {
if (LOG.isWarnEnabled()) {
@@ -47,15 +47,14 @@ public class SiteGraphTest extends StrutsTestCase {
URL compare = SiteGraphTest.class.getResource("out.txt");
StringBuilder buffer = new StringBuilder(128);
InputStream in = compare.openStream();
byte[] buf = new byte[4096];
int nbytes;
while ((nbytes = in.read(buf)) > 0) {
buffer.append(new String(buf, 0, nbytes));
try (InputStream in = compare.openStream()){
byte[] buf = new byte[4096];
int nbytes;
while ((nbytes = in.read(buf)) > 0) {
buffer.append(new String(buf, 0, nbytes));
}
}
in.close();
assertEquals(buffer.toString().replaceAll("\r\n", "\n"), writer.toString().replaceAll("\r\n", "\n"));
}
}
@@ -32,6 +32,7 @@ import java.io.Serializable;
*/
public class ExceptionHolder implements Serializable {
private static final long serialVersionUID = 1L;
private Exception exception;
/**
@@ -44,37 +45,29 @@ public class ExceptionHolder implements Serializable {
}
/**
* Gets the holded exception
* Gets the held exception
*
* @return the holded exception
* @return the held exception
*/
public Exception getException() {
return this.exception;
}
/**
* Gets the holded exception stacktrace using {@link Exception#printStackTrace()}.
* Gets the held exception stack trace using {@link Exception#printStackTrace()}.
*
* @return stacktrace
* @return stack trace
*/
public String getExceptionStack() {
String exceptionStack = null;
if (getException() != null) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
try {
try (StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw)) {
getException().printStackTrace(pw);
exceptionStack = sw.toString();
}
finally {
try {
sw.close();
pw.close();
} catch (IOException e) {
// ignore
}
} catch (IOException e) {
// Ignore exception generating stack trace.
}
}
@@ -450,12 +450,9 @@ public class DefaultClassFinder implements ClassFinder {
try {
URL resource = classLoaderInterface.getResource(className);
if (resource != null) {
InputStream in = resource.openStream();
try {
try (InputStream in = resource.openStream()) {
ClassReader classReader = new ClassReader(in);
classReader.accept(new InfoBuildingVisitor(this), ClassReader.SKIP_DEBUG);
} finally {
in.close();
}
} else {
throw new XWorkException("Could not load " + className);
@@ -969,29 +969,18 @@ public class ResourceFinder {
}
private Properties loadProperties(URL resource) throws IOException {
InputStream in = resource.openStream();
BufferedInputStream reader = new BufferedInputStream(in);
try {
try (InputStream reader = new BufferedInputStream(resource.openStream())) {
Properties properties = new Properties();
properties.load(reader);
return properties;
} finally {
try {
in.close();
reader.close();
} catch (Exception e) {
}
}
}
private String readContents(URL resource) throws IOException {
InputStream in = resource.openStream();
StringBuilder sb = new StringBuilder();
BufferedInputStream reader = new BufferedInputStream(in);
try {
try (InputStream reader = new BufferedInputStream(resource.openStream())) {
int b = reader.read();
while (b != -1) {
sb.append((char) b);
@@ -999,12 +988,6 @@ public class ResourceFinder {
}
return sb.toString().trim();
} finally {
try {
in.close();
reader.close();
} catch (Exception e) {
}
}
}
@@ -138,8 +138,7 @@ public class DefaultValidatorFactory implements ValidatorFactory {
// Ex: struts-app.jar -> MyApp.jar -> Login-validators.xml should be
// parsed and loaded.
ZipInputStream zipInputStream = null;
try {
InputStream inputStream = u.openStream();
try (InputStream inputStream = u.openStream()) {
if (inputStream instanceof ZipInputStream) {
zipInputStream = (ZipInputStream) inputStream;
} else {
@@ -28,14 +28,8 @@ public class UrlUtilTest2 extends TestCase {
private void assertUrlCanBeOpened(URL url) throws IOException {
InputStream is = url.openStream();
JarInputStream jarStream = null;
try {
jarStream = new JarInputStream(is);
try (JarInputStream jarStream = new JarInputStream(is)) {
assertNotNull(jarStream);
} finally {
if (jarStream != null)
jarStream.close();
}
}
}
@@ -171,9 +171,7 @@ public class DefaultValidatorFileParserTest extends TestCase {
}
public void testValidatorWithI18nMessage() throws Exception {
InputStream is = null;
try {
is = ClassLoaderUtil.getResourceAsStream(testFileName6, this.getClass());
try (InputStream is = ClassLoaderUtil.getResourceAsStream(testFileName6, this.getClass())) {
mockValidatorFactory.expectAndReturn("lookupRegisteredValidatorType", C.args(C.eq("requiredstring")), RequiredStringValidator.class.getName());
mockValidatorFactory.expectAndReturn("lookupRegisteredValidatorType", C.args(C.eq("requiredstring")), RequiredStringValidator.class.getName());
@@ -203,11 +201,6 @@ public class DefaultValidatorFileParserTest extends TestCase {
assertEquals(((ValidatorConfig)validatorConfigs.get(1)).getParams().get("anotherParam"), "anotherValue");
assertEquals(((ValidatorConfig)validatorConfigs.get(1)).getType(), "requiredstring");
}
finally {
if (is != null) {
is.close();
}
}
}