Seam SVN: r14146 - in branches/enterprise/JBPAPP_5_0/src: test/unit/org/jboss/seam/test/unit and 1 other directories.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2011-08-11 10:14:38 -0400 (Thu, 11 Aug 2011)
New Revision: 14146
Added:
branches/enterprise/JBPAPP_5_0/src/test/unit/org/jboss/seam/test/unit/web/MultipartRequestImplTest.java
Modified:
branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/web/MultipartRequestImpl.java
branches/enterprise/JBPAPP_5_0/src/test/unit/org/jboss/seam/test/unit/testng.xml
Log:
JBPAPP-6946 - fixing MultipartRequestImpl for missing data
Modified: branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/web/MultipartRequestImpl.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/web/MultipartRequestImpl.java 2011-08-11 13:21:46 UTC (rev 14145)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/web/MultipartRequestImpl.java 2011-08-11 14:14:38 UTC (rev 14146)
@@ -330,6 +330,14 @@
{
if (checkSequence(buffer, i, CR_LF))
{
+ // Check next CR_LF available in the buffer
+ if ( read <= i + CR_LF.length)
+ { /* if there is no space left for CRLF in the buffer,
+ force pushing of remaining (unread) bytes to the beginning of the buffer,
+ read more bytes and try again */
+ i = read;
+ break;
+ }
String param = (encoding == null) ?
new String(buffer, pos, i - pos - 1) :
new String(buffer, pos, i - pos - 1, encoding);
@@ -420,16 +428,40 @@
{
// move the bytes that weren't read to the start of the buffer
int bytesNotRead = read - pos;
- System.arraycopy(buffer, pos, buffer, 0, bytesNotRead);
- read = input.read(buffer, bytesNotRead, buffer.length - bytesNotRead);
- // Decrement loopCounter if no data was readable
- if (read == 0)
+ if (buffer.length == bytesNotRead )
{
- loopCounter--;
- }
+ //if no end of parameter value can be found in the buffer, we have to increase size of the buffer
+
+ byte[] buffer1 = new byte[buffer.length * 2];
+ System.arraycopy(buffer, 0, buffer1, 0, buffer.length);
+ buffer = buffer1;
+
+ read = input.read(buffer, bytesNotRead, buffer.length - bytesNotRead);
+ if (read == -1)
+ {
+ break;// too bad - nothing more to read (EOF) and last parameter value couldn't be parsed
+ }
+
+ read += bytesNotRead;
+ }
+ else
+ {
+ System.arraycopy(buffer, pos, buffer, 0, bytesNotRead);
+ read = input.read(buffer, bytesNotRead, buffer.length - bytesNotRead);
+
+ if (read == -1)
+ {
+ break;
+ // too bad - nothing more to read (EOF) and last parameter value couldn't be parsed
+ }
+
+ if(read == 0)
+ loopCounter--;
+
+ read += bytesNotRead;
+ }
- read += bytesNotRead;
}
else
{
Modified: branches/enterprise/JBPAPP_5_0/src/test/unit/org/jboss/seam/test/unit/testng.xml
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/test/unit/org/jboss/seam/test/unit/testng.xml 2011-08-11 13:21:46 UTC (rev 14145)
+++ branches/enterprise/JBPAPP_5_0/src/test/unit/org/jboss/seam/test/unit/testng.xml 2011-08-11 14:14:38 UTC (rev 14146)
@@ -64,6 +64,7 @@
<test name="Seam Unit Tests - Filters">
<classes>
<class name="org.jboss.seam.test.unit.web.MultipartRequestTest" />
+ <class name="org.jboss.seam.test.unit.web.MultipartRequestImplTest" />
<class name="org.jboss.seam.test.unit.web.IdentityRequestWrapperTest" />
</classes>
</test>
Added: branches/enterprise/JBPAPP_5_0/src/test/unit/org/jboss/seam/test/unit/web/MultipartRequestImplTest.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/test/unit/org/jboss/seam/test/unit/web/MultipartRequestImplTest.java (rev 0)
+++ branches/enterprise/JBPAPP_5_0/src/test/unit/org/jboss/seam/test/unit/web/MultipartRequestImplTest.java 2011-08-11 14:14:38 UTC (rev 14146)
@@ -0,0 +1,91 @@
+package org.jboss.seam.test.unit.web;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Map;
+import org.testng.annotations.Test;
+import org.jboss.seam.web.MultipartRequestImpl;
+import org.jboss.seam.mock.EnhancedMockHttpServletRequest;
+
+public class MultipartRequestImplTest
+{
+ private static final String CRLF = "\r\n";
+ private static final String HYPHENS = "--";
+
+ @Test
+ public void testParseRequestBasic() throws Throwable
+ {
+ String boundary = "boundary10"; //10 bytes
+
+ String data =
+ HYPHENS + boundary + CRLF +
+ "Content-Disposition: form-data; name=\"foo\"" + CRLF +
+ CRLF +
+ "bar" + CRLF +
+ HYPHENS + boundary + HYPHENS;
+
+ byte[] dataBytes = data.getBytes("UTF-8");
+
+ EnhancedMockHttpServletRequest req = new EnhancedMockHttpServletRequest();
+ req.setContent(dataBytes);
+ req.setContentType("multipart/form-data; boundary=" + boundary);
+ MultipartRequestImpl r = new MultipartRequestImpl(req, false, 0);
+ Map m = r.getParameterMap();
+ assertNotNull(m);
+ assertEquals(r.getParameterValues("foo")[0], "bar");
+ }
+
+ @Test
+ public void testParseRequestBufferBoundary() throws Throwable
+ {
+
+ int bufferSize = 2048; // See MultipartRequestImpl
+
+ String boundary = "boundary10";
+
+ String paddingParameter =
+ HYPHENS + boundary + CRLF +
+ "Content-Disposition: form-data; name=\"padding\"" + CRLF +
+ CRLF;
+
+ String testParameter =
+ HYPHENS + boundary + CRLF +
+ "Content-Disposition: form-data; name=\"foo\"" + CRLF +
+ CRLF +
+ "bar" + CRLF +
+ HYPHENS + boundary + HYPHENS;
+
+ // let's put test parameter near the buffer boundary, from (bufferSize - 100) to (bufferSize + 100)
+ for (int i = -100; i < 100; i++)
+ {
+ StringBuffer buffer = new StringBuffer(bufferSize + 256);
+ buffer.append(paddingParameter);
+ int paddingSize = bufferSize - i - paddingParameter.length() - CRLF.length();
+ appendPaddingValue(buffer, paddingSize);
+ buffer.append(CRLF);
+ buffer.append(testParameter);
+ String data = buffer.toString();
+
+ byte[] dataBytes = data.getBytes("UTF-8");
+ EnhancedMockHttpServletRequest req = new EnhancedMockHttpServletRequest();
+ req.setContent(dataBytes);
+ req.setContentType("multipart/form-data; boundary=" + boundary);
+ MultipartRequestImpl r = new MultipartRequestImpl(req, false, 0);
+ Map m = r.getParameterMap();
+ assertNotNull(m);
+ assertEquals(r.getParameterValues("foo")[0], "bar");
+ }
+ }
+
+ private static StringBuffer appendPaddingValue(StringBuffer buffer, int length)
+ {
+ for (int i = 0; i < length; i++)
+ {
+ buffer.append("x");
+ }
+ return buffer;
+ }
+}
13 years, 3 months
Seam SVN: r14145 - branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/util.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2011-08-11 09:21:46 -0400 (Thu, 11 Aug 2011)
New Revision: 14145
Modified:
branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/util/AnnotatedBeanProperty.java
Log:
JBPAPP-6924 - added Serializable to AnnotatedBeanProperty
Modified: branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/util/AnnotatedBeanProperty.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/util/AnnotatedBeanProperty.java 2011-08-08 11:19:20 UTC (rev 14144)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/util/AnnotatedBeanProperty.java 2011-08-11 13:21:46 UTC (rev 14145)
@@ -1,6 +1,7 @@
package org.jboss.seam.util;
import java.beans.Introspector;
+import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@@ -12,8 +13,9 @@
*
* @author Shane Bryzak
*/
-public class AnnotatedBeanProperty<T extends Annotation>
+public class AnnotatedBeanProperty<T extends Annotation> implements Serializable
{
+ private static final long serialVersionUID = 12345678456L;
private Field propertyField;
private Method propertyGetter;
private Method propertySetter;
13 years, 3 months
[seam/solder] c21fe2: move DefaultBean annotation to api, fix class name...
by noreply@github.com
Branch: refs/heads/develop
Home: https://github.com/seam/solder
Commit: c21fe2c4e3e6b8390f40b62e5d048c684c0555a6
https://github.com/seam/solder/commit/c21fe2c4e3e6b8390f40b62e5d048c684c0...
Author: Shane Bryzak <sbryzak(a)gmail.com>
Date: 2011-08-11 (Thu, 11 Aug 2011)
Changed paths:
A api/src/main/java/org/jboss/seam/solder/bean/defaultbean/DefaultBean.java
R impl/src/main/java/org/jboss/seam/solder/bean/defaultbean/AbstactDefaultBean.java
A impl/src/main/java/org/jboss/seam/solder/bean/defaultbean/AbstractDefaultBean.java
M impl/src/main/java/org/jboss/seam/solder/bean/defaultbean/AbstractDefaultProducerBean.java
R impl/src/main/java/org/jboss/seam/solder/bean/defaultbean/DefaultBean.java
M impl/src/main/java/org/jboss/seam/solder/bean/defaultbean/DefaultBeanExtension.java
M impl/src/main/java/org/jboss/seam/solder/bean/defaultbean/DefaultManagedBean.java
Log Message:
-----------
move DefaultBean annotation to api, fix class name typo
13 years, 3 months
[seam/solder] 1c8406: SOLDER-117
by noreply@github.com
Branch: refs/heads/develop
Home: https://github.com/seam/solder
Commit: 1c8406c4d03189126239a711772e4eebecc1e668
https://github.com/seam/solder/commit/1c8406c4d03189126239a711772e4eebecc...
Author: Shane Bryzak <sbryzak(a)gmail.com>
Date: 2011-08-11 (Thu, 11 Aug 2011)
Changed paths:
R impl/src/main/java/org/jboss/seam/solder/bean/generic/AbstactGenericBean.java
A impl/src/main/java/org/jboss/seam/solder/bean/generic/AbstractGenericBean.java
M impl/src/main/java/org/jboss/seam/solder/bean/generic/AbstractGenericProducerBean.java
M impl/src/main/java/org/jboss/seam/solder/bean/generic/GenericManagedBean.java
Log Message:
-----------
SOLDER-117
13 years, 3 months
[forge/core] bbd377: Fixed NPE in command completion, updated scaffold ...
by noreply@github.com
Branch: refs/heads/master
Home: https://github.com/forge/core
Commit: bbd377a758f8475197d4e86fe99ba2fc73a034ae
https://github.com/forge/core/commit/bbd377a758f8475197d4e86fe99ba2fc73a0...
Author: Lincoln Baxter, III <lincolnbaxter(a)gmail.com>
Date: 2011-08-10 (Wed, 10 Aug 2011)
Changed paths:
M javaee-impl/src/main/java/org/jboss/forge/spec/javaee/ServletFacetImpl.java
A javaee-impl/src/main/resources/org/jboss/forge/web/404.html
A javaee-impl/src/main/resources/org/jboss/forge/web/500.html
M javaee-impl/src/main/resources/org/jboss/forge/web/forge-style.css
M scaffold-metawidget/src/main/resources/org/metawidget/scaffold/create.xhtml
M scaffold-metawidget/src/main/resources/org/metawidget/scaffold/list.xhtml
M scaffold-metawidget/src/main/resources/org/metawidget/scaffold/view.xhtml
M scaffold-metawidget/src/main/resources/org/metawidget/templates/forge-style.css
M scaffold-metawidget/src/main/resources/org/metawidget/templates/forge-template.xhtml
M shell/src/main/java/org/jboss/forge/shell/completer/OptionAwareCompletionHandler.java
Log Message:
-----------
Fixed NPE in command completion, updated scaffold to include 404 and 500 error pages, updated scaffold styles
13 years, 3 months