From df033c0f54e9abe8031af63b942a9b295131aa58 Mon Sep 17 00:00:00 2001 From: Michael Zhou Date: Wed, 18 Sep 2013 20:49:54 -0600 Subject: [PATCH] =?UTF-8?q?*=20=E5=8D=87=E7=BA=A7=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E5=8C=85=E7=9A=84=E7=89=88=E6=9C=AC=EF=BC=9A=20=20=20=20=20=20?= =?UTF-8?q?=20spring=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=203.1.2?= =?UTF-8?q?=20=20=20->=203.2.4=20=20=20=20=20=20=20slf4j=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20=201.6.6=20=20=20->=201.7.5=20=20?= =?UTF-8?q?=20=20=20=20=20commons-fileupload=20=20=20=201.2.2=20=20=20->?= =?UTF-8?q?=201.3=20=20=20=20=20=20=20commons-io=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=202.3=20=20=20=20=20->=202.4=20=20=20=20=20=20=20comm?= =?UTF-8?q?ons-codec=20=20=20=20=20=20=20=20=201.6=20=20=20=20=20->=201.8?= =?UTF-8?q?=20=20=20=20=20=20=20fastjson=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=201.1.23=20=20->=201.1.36=20=20=20=20=20=20=20logback=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20=20=20=20=201.0.6=20=20=20->=201.?= =?UTF-8?q?0.13=20=20=20[provided]=20=20=20=20=20=20=20commons-logging=20?= =?UTF-8?q?=20=20=20=20=20=201.1.1=20=20=20->=201.1.3=20=20=20=20[provided?= =?UTF-8?q?]=20=20=20=20=20=20=20servlet=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=203.0.1=20=20=20->=203.1.0=20=20=20=20[provided]=20?= =?UTF-8?q?=20=20=20=20=20=20javamail=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=201.4.1=20=20=20->=201.4.7=20=20=20=20[provided]=20=20=20?= =?UTF-8?q?=20=20=20=20activation=20=20=20=20=20=20=20=20=20=20=20=201.1?= =?UTF-8?q?=20=20=20=20=20->=201.1.1=20=20=20=20[provided]=20=20=20=20=20?= =?UTF-8?q?=20=20freemarker=20=20=20=20=20=20=20=20=20=20=20=202.3.19=20?= =?UTF-8?q?=20->=202.3.20=20=20=20[provided]=20=20=20=20=20=20=20groovy=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20=20=20=20=20=201.8.6=20=20=20->?= =?UTF-8?q?=202.1.7=20=20=20=20[runtime]=20=20=20=20=20=20=20httpunit=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20=20=20=201.7=20=20=20=20=20->=201?= =?UTF-8?q?.7.2=20=20=20=20[test]=20=20=20=20=20=20=20xerces=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20=20=202.10.0=20=20->=202.11.0=20?= =?UTF-8?q?=20=20[test]=20=20=20=20=20=20=20easymock=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=203.1=20=20=20=20=20->=203.2=20=20=20=20=20?= =?UTF-8?q?=20[test]=20=20=20=20=20=20=20jasper=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=206.0.35=20=20->=206.0.37=20=20=20[test]=20?= =?UTF-8?q?=20=20=20=20=20=20mock-javamail=20=20=20=20=20=20=20=20=201.7?= =?UTF-8?q?=20=20=20=20=20->=201.9=20=20=20=20=20=20[test]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES_SINCE_3.2.0.txt | 19 ++++++ common/logconfig/pom.xml | 2 +- dist/test/pom.xml | 2 +- pom.xml | 52 ++++++++-------- .../freemarker/FreeMarkerEngineTests.java | 6 +- .../buffered/impl/BufferedResponseImpl.java | 19 ++++++ .../CommittingAwareServletOutputStream.java | 11 ++++ .../impl/RequestContextCommitTests.java | 11 ++++ .../upload/impl/cfu/ServletFileUpload.java | 5 +- .../uribroker/URIBrokerConfigTests.java | 2 +- test/util/pom.xml | 2 +- .../httpunit/cookies/PatchedCookieJar.java | 61 ++++++++++++++++--- test/webx/pom.xml | 2 +- .../citrus/webx/servlet/FilterBean.java | 10 +++ 14 files changed, 160 insertions(+), 44 deletions(-) diff --git a/CHANGES_SINCE_3.2.0.txt b/CHANGES_SINCE_3.2.0.txt index ea57eeef9..f1910fc45 100644 --- a/CHANGES_SINCE_3.2.0.txt +++ b/CHANGES_SINCE_3.2.0.txt @@ -56,3 +56,22 @@ * Bugfix: 修正当request.startAsync以后,每个请求都会生成cglib类,从而导致permgen溢出的问题。 +* 升级依赖包的版本: + spring 3.1.2 -> 3.2.4 + slf4j 1.6.6 -> 1.7.5 + commons-fileupload 1.2.2 -> 1.3 + commons-io 2.3 -> 2.4 + commons-codec 1.6 -> 1.8 + fastjson 1.1.23 -> 1.1.36 + logback 1.0.6 -> 1.0.13 [provided] + commons-logging 1.1.1 -> 1.1.3 [provided] + servlet 3.0.1 -> 3.1.0 [provided] + javamail 1.4.1 -> 1.4.7 [provided] + activation 1.1 -> 1.1.1 [provided] + freemarker 2.3.19 -> 2.3.20 [provided] + groovy 1.8.6 -> 2.1.7 [runtime] + httpunit 1.7 -> 1.7.2 [test] + xerces 2.10.0 -> 2.11.0 [test] + easymock 3.1 -> 3.2 [test] + jasper 6.0.35 -> 6.0.37 [test] + mock-javamail 1.7 -> 1.9 [test] diff --git a/common/logconfig/pom.xml b/common/logconfig/pom.xml index 89862be5c..5bef72a7c 100644 --- a/common/logconfig/pom.xml +++ b/common/logconfig/pom.xml @@ -39,7 +39,7 @@ hamcrest-library - httpunit + org.httpunit httpunit diff --git a/dist/test/pom.xml b/dist/test/pom.xml index 5c34fc913..24d74d7b8 100644 --- a/dist/test/pom.xml +++ b/dist/test/pom.xml @@ -141,7 +141,7 @@ compile - httpunit + org.httpunit httpunit compile diff --git a/pom.xml b/pom.xml index edaa156b1..1801a6a22 100644 --- a/pom.xml +++ b/pom.xml @@ -45,10 +45,10 @@ 1.6 UTF-8 3.2.1 - 3.1.2.RELEASE + 3.2.4.RELEASE 1.2 - 1.1 - 8.1.7.v20120910 + 1.2 + 8.1.13.v20130916 ${java.encoding} true @@ -282,33 +282,33 @@ org.slf4j slf4j-api - 1.6.6 + 1.7.5 org.slf4j jcl-over-slf4j - 1.6.6 + 1.7.5 commons-logging commons-logging - 1.1.1 + 1.1.3 provided ch.qos.logback logback-classic - 1.0.6 + 1.0.13 runtime org.slf4j slf4j-log4j12 - 1.6.6 + 1.7.5 runtime @@ -333,15 +333,19 @@ test - httpunit + org.httpunit httpunit - 1.7 + 1.7.2 test - jtidy + net.sf.jtidy jtidy + + xerces + xmlParserAPIs + javax.servlet servlet-api @@ -363,7 +367,7 @@ xerces xercesImpl - 2.10.0 + 2.11.0 test @@ -381,13 +385,13 @@ org.easymock easymockclassextension - 3.1 + 3.2 test org.apache.tomcat jasper - 6.0.35 + 6.0.37 test @@ -399,7 +403,7 @@ org.jvnet.mock-javamail mock-javamail - 1.7 + 1.9 test @@ -429,28 +433,28 @@ org.freemarker freemarker - 2.3.19 + 2.3.20 provided commons-fileupload commons-fileupload - 1.2.2 + 1.3 commons-io commons-io - 2.3 + 2.4 commons-codec commons-codec - 1.6 + 1.8 org.codehaus.groovy groovy-all - 1.8.6 + 2.1.7 runtime @@ -486,13 +490,13 @@ javax.mail mail - 1.4.1 + 1.4.7 provided javax.activation activation - 1.1 + 1.1.1 provided @@ -503,7 +507,7 @@ com.alibaba fastjson - 1.1.23 + 1.1.36 @@ -576,7 +580,7 @@ javax.servlet javax.servlet-api - 3.0.1 + 3.1.0 compile diff --git a/service/freemarker/src/test/java/com/alibaba/citrus/service/freemarker/FreeMarkerEngineTests.java b/service/freemarker/src/test/java/com/alibaba/citrus/service/freemarker/FreeMarkerEngineTests.java index b4dba1796..6d50945b2 100644 --- a/service/freemarker/src/test/java/com/alibaba/citrus/service/freemarker/FreeMarkerEngineTests.java +++ b/service/freemarker/src/test/java/com/alibaba/citrus/service/freemarker/FreeMarkerEngineTests.java @@ -204,8 +204,7 @@ public void render_error() throws Exception { } catch (TemplateException e) { assertThat( e, - exception(InvalidReferenceException.class, "Error rendering FreeMarker template: /test_render.ftl", - "Expression world is undefined on line 6, column 10 in test_render.ftl")); + exception(InvalidReferenceException.class, "Error rendering FreeMarker template: /test_render.ftl")); } // 语法错 @@ -213,8 +212,7 @@ public void render_error() throws Exception { templateService.getText("test_render_error.ftl", ctx); fail(); } catch (TemplateException e) { - assertThat(e, exception(ParseException.class, "Error rendering FreeMarker template: " - + "/test_render_error.ftl")); + assertThat(e, exception(ParseException.class, "Error rendering FreeMarker template: /test_render_error.ftl")); } } diff --git a/service/requestcontext/src/main/java/com/alibaba/citrus/service/requestcontext/buffered/impl/BufferedResponseImpl.java b/service/requestcontext/src/main/java/com/alibaba/citrus/service/requestcontext/buffered/impl/BufferedResponseImpl.java index c82012b21..1e8ea3b4a 100644 --- a/service/requestcontext/src/main/java/com/alibaba/citrus/service/requestcontext/buffered/impl/BufferedResponseImpl.java +++ b/service/requestcontext/src/main/java/com/alibaba/citrus/service/requestcontext/buffered/impl/BufferedResponseImpl.java @@ -31,6 +31,7 @@ import java.util.EmptyStackException; import java.util.LinkedList; import javax.servlet.ServletOutputStream; +import javax.servlet.WriteListener; import javax.servlet.http.HttpServletResponse; import com.alibaba.citrus.service.requestcontext.RequestContext; @@ -499,6 +500,15 @@ public void close() throws IOException { bytes.flush(); bytes.close(); } + + @Override + public boolean isReady() { + return true; + } + + @Override + public void setWriteListener(WriteListener writeListener) { + } } /** 代表一个将内容保存在内存中的PrintWriter。 */ @@ -558,5 +568,14 @@ public void flush() throws IOException { public void close() throws IOException { this.flush(); } + + @Override + public boolean isReady() { + return true; + } + + @Override + public void setWriteListener(WriteListener writeListener) { + } } } diff --git a/service/requestcontext/src/main/java/com/alibaba/citrus/service/requestcontext/impl/CommittingAwareServletOutputStream.java b/service/requestcontext/src/main/java/com/alibaba/citrus/service/requestcontext/impl/CommittingAwareServletOutputStream.java index 929f4c4fb..1b62af66f 100644 --- a/service/requestcontext/src/main/java/com/alibaba/citrus/service/requestcontext/impl/CommittingAwareServletOutputStream.java +++ b/service/requestcontext/src/main/java/com/alibaba/citrus/service/requestcontext/impl/CommittingAwareServletOutputStream.java @@ -19,6 +19,7 @@ import java.io.IOException; import javax.servlet.ServletOutputStream; +import javax.servlet.WriteListener; class CommittingAwareServletOutputStream extends ServletOutputStream { private final HeaderCommitter committer; @@ -148,6 +149,16 @@ public void close() throws IOException { originalStream.close(); } + @Override + public boolean isReady() { + return originalStream.isReady(); + } + + @Override + public void setWriteListener(WriteListener writeListener) { + originalStream.setWriteListener(writeListener); + } + @Override public String toString() { return originalStream.toString(); diff --git a/service/requestcontext/src/test/java/com/alibaba/citrus/service/requestcontext/impl/RequestContextCommitTests.java b/service/requestcontext/src/test/java/com/alibaba/citrus/service/requestcontext/impl/RequestContextCommitTests.java index 091fc23a4..e64d6e259 100644 --- a/service/requestcontext/src/test/java/com/alibaba/citrus/service/requestcontext/impl/RequestContextCommitTests.java +++ b/service/requestcontext/src/test/java/com/alibaba/citrus/service/requestcontext/impl/RequestContextCommitTests.java @@ -30,6 +30,7 @@ import java.util.concurrent.TimeUnit; import javax.servlet.ServletContext; import javax.servlet.ServletOutputStream; +import javax.servlet.WriteListener; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -67,8 +68,18 @@ public void init() throws Exception { expect(response.getWriter()).andReturn(new PrintWriter(System.out)).anyTimes(); expect(response.getOutputStream()).andReturn(new ServletOutputStream() { + @Override public void write(int b) throws IOException { } + + @Override + public boolean isReady() { + return true; + } + + @Override + public void setWriteListener(WriteListener writeListener) { + } }).anyTimes(); replay(servletContext, request, response); diff --git a/service/upload/src/main/java/com/alibaba/citrus/service/upload/impl/cfu/ServletFileUpload.java b/service/upload/src/main/java/com/alibaba/citrus/service/upload/impl/cfu/ServletFileUpload.java index 8525d00ce..91bd23b8e 100644 --- a/service/upload/src/main/java/com/alibaba/citrus/service/upload/impl/cfu/ServletFileUpload.java +++ b/service/upload/src/main/java/com/alibaba/citrus/service/upload/impl/cfu/ServletFileUpload.java @@ -66,13 +66,12 @@ public void setFileNameKey(String[] fileNameKey) { } @Override - public List parseRequest(HttpServletRequest request) throws FileUploadException { + public List parseRequest(HttpServletRequest request) throws FileUploadException { return parseRequest(new ServletRequestContext(request)); } @Override - public List parseRequest(RequestContext ctx) throws FileUploadException { - @SuppressWarnings("unchecked") + public List parseRequest(RequestContext ctx) throws FileUploadException { List items = super.parseRequest(ctx); String charset = ctx.getCharacterEncoding(); diff --git a/service/uribroker/src/test/java/com/alibaba/citrus/service/uribroker/URIBrokerConfigTests.java b/service/uribroker/src/test/java/com/alibaba/citrus/service/uribroker/URIBrokerConfigTests.java index 58df77641..1f11a52a5 100644 --- a/service/uribroker/src/test/java/com/alibaba/citrus/service/uribroker/URIBrokerConfigTests.java +++ b/service/uribroker/src/test/java/com/alibaba/citrus/service/uribroker/URIBrokerConfigTests.java @@ -81,7 +81,7 @@ public void link_URIBroker() { assertEquals("http://www.alibaba.com/", uri.setServerName("www.alibaba.com").render()); assertEquals("http://localhost:8080/", uri.setServerPort(8080).render()); assertEquals("http://localhost/", uri.setServerPort(80).render()); - assertEquals("https://localhost/", uri.setServerScheme("https").render()); + assertEquals("https://localhost:80/", uri.setServerScheme("https").render()); assertEquals("http://localhost/aa/bb", uri.addPath("aa").addPath("bb").render()); // fork diff --git a/test/util/pom.xml b/test/util/pom.xml index ec1d7db3f..5e35c66b4 100644 --- a/test/util/pom.xml +++ b/test/util/pom.xml @@ -31,7 +31,7 @@ compile - httpunit + org.httpunit httpunit compile diff --git a/test/util/src/main/java/com/meterware/httpunit/cookies/PatchedCookieJar.java b/test/util/src/main/java/com/meterware/httpunit/cookies/PatchedCookieJar.java index 75d9287a7..4075d9f15 100644 --- a/test/util/src/main/java/com/meterware/httpunit/cookies/PatchedCookieJar.java +++ b/test/util/src/main/java/com/meterware/httpunit/cookies/PatchedCookieJar.java @@ -19,26 +19,23 @@ import static com.alibaba.citrus.test.TestUtil.*; +import java.net.URL; +import java.util.HashMap; + public class PatchedCookieJar extends CookieJar { public PatchedCookieJar() { } public PatchedCookieJar(CookieSource source) { try { - getAccessibleField(getClass(), "_press").set(this, new CookiePress(source.getURL())); + getAccessibleField(getClass(), "_press").set(this, new PatchedCookiePress(source.getURL())); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } - findCookies(source.getHeaderFields("Set-Cookie"), new RFC2109CookieRecipe() { - @Override - protected boolean isCookieReservedWord(String token) { - return token.equalsIgnoreCase("httpOnly") || super.isCookieReservedWord(token); - } - }); - + findCookies(source.getHeaderFields("Set-Cookie"), new PatchedRFC2109CookieRecipe()); findCookies(source.getHeaderFields("Set-Cookie2"), new RFC2965CookieRecipe()); } @@ -47,4 +44,52 @@ private void findCookies(String cookieHeader[], CookieRecipe recipe) { recipe.findCookies(element); } } + + private class PatchedRFC2109CookieRecipe extends RFC2109CookieRecipe { + @Override + protected boolean isCookieReservedWord(String token) { + return token.equalsIgnoreCase("httpOnly") || super.isCookieReservedWord(token); + } + } + + private class PatchedCookiePress extends CookiePress { + public PatchedCookiePress(URL sourceURL) { + super(sourceURL); + } + + public void addTokenWithEqualsSign(CookieRecipe recipe, String token, int equalsIndex) { + final String name = token.substring(0, equalsIndex).trim(); + final String value = token.substring(equalsIndex + 1).trim(); + + StringBuffer _value = getFieldValue("_value", StringBuffer.class); + _value.insert(0, value); + + HashMap _attributes = getFieldValue("_attributes", HashMap.class); + + if (recipe.isCookieAttribute(name.toLowerCase())) { + _attributes.put(name.toLowerCase(), _value.toString()); + } else { + try { + getAccessibleMethod(CookiePress.class, "addCookieIfValid", new Class[] { Cookie.class }).invoke(this, new Cookie(name, _value.toString(), _attributes)); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new RuntimeException(e); + } + _attributes.clear(); + } + + _value.setLength(0); + } + + private T getFieldValue(String name, Class type) { + try { + return type.cast(getAccessibleField(getClass(), name).get(this)); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } } diff --git a/test/webx/pom.xml b/test/webx/pom.xml index 0bd71c795..4c2ee7768 100644 --- a/test/webx/pom.xml +++ b/test/webx/pom.xml @@ -26,7 +26,7 @@ compile - httpunit + org.httpunit httpunit compile diff --git a/webx/framework/src/main/java/com/alibaba/citrus/webx/servlet/FilterBean.java b/webx/framework/src/main/java/com/alibaba/citrus/webx/servlet/FilterBean.java index 3e0920704..38c4ed46e 100644 --- a/webx/framework/src/main/java/com/alibaba/citrus/webx/servlet/FilterBean.java +++ b/webx/framework/src/main/java/com/alibaba/citrus/webx/servlet/FilterBean.java @@ -34,6 +34,7 @@ import javax.servlet.ServletOutputStream; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; +import javax.servlet.WriteListener; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponseWrapper; @@ -243,5 +244,14 @@ public void write(byte[] buf, int offset, int len) throws IOException { throw new IOException("negative length"); } } + + @Override + public boolean isReady() { + return true; + } + + @Override + public void setWriteListener(WriteListener writeListener) { + } } }