[jboss-svn-commits] JBL Code SVN: r31447 - in labs/jbossesb/branches/JBESB_4_7_CP/product: rosetta/src/org/jboss/soa/esb/http and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Feb 5 07:05:53 EST 2010
Author: kevin.conner at jboss.com
Date: 2010-02-05 07:05:53 -0500 (Fri, 05 Feb 2010)
New Revision: 31447
Added:
labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/tests/src/org/jboss/soa/esb/http/HttpContentTypeUtilUnitTest.java
Modified:
labs/jbossesb/branches/JBESB_4_7_CP/product/install/conf/jbossesb-properties.xml
labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/http/HttpContentTypeUtil.java
Log:
Fix http content type handling: JBESB-3173
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/install/conf/jbossesb-properties.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/install/conf/jbossesb-properties.xml 2010-02-05 12:01:29 UTC (rev 31446)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/install/conf/jbossesb-properties.xml 2010-02-05 12:05:53 UTC (rev 31447)
@@ -35,7 +35,7 @@
<property name="org.jboss.soa.esb.jndi.server.url" value="${jboss.esb.bind.address}:1099"/>
<property name="org.jboss.soa.esb.persistence.connection.factory" value="org.jboss.internal.soa.esb.persistence.format.MessageStoreFactoryImpl"/>
<property name="org.jboss.soa.esb.loadbalancer.policy" value="org.jboss.soa.esb.listeners.ha.RoundRobin"/>
- <property name="org.jboss.soa.esb.mime.text.types" value="text/*;application/xml;application/*-xml"/>
+ <property name="org.jboss.soa.esb.mime.text.types" value="text/*;application/xml;application/*+xml"/>
<property name="jboss.esb.invm.scope.default" value="NONE"/>
</properties>
<properties name="security">
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/http/HttpContentTypeUtil.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/http/HttpContentTypeUtil.java 2010-02-05 12:01:29 UTC (rev 31446)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/http/HttpContentTypeUtil.java 2010-02-05 12:05:53 UTC (rev 31447)
@@ -33,11 +33,13 @@
private static Pattern[] textMimePatterns;
static {
- String[] textTypes = ModulePropertyManager.getPropertyManager("core").getProperty("org.jboss.soa.esb.mime.text.types", "text/*;application/xml;application/*-xml").split(";");
+ String[] textTypes = ModulePropertyManager.getPropertyManager("core").getProperty("org.jboss.soa.esb.mime.text.types", "text/*;application/xml;application/*+xml").split(";");
textMimePatterns = new Pattern[textTypes.length];
for(int i = 0; i < textMimePatterns.length; i++) {
- textMimePatterns[i] = Pattern.compile(textTypes[i].trim().replace("*", ".*"));
+ String type = textTypes[i].trim().replace("*", ".*") ;
+ type = type.replace("+", "\\+") ;
+ textMimePatterns[i] = Pattern.compile(type);
}
}
@@ -46,6 +48,10 @@
return false;
}
+ final int separator = contentType.indexOf(';') ;
+ if (separator >= 0) {
+ contentType = contentType.substring(0, separator) ;
+ }
for(int i = 0; i < textMimePatterns.length; i++) {
if(textMimePatterns[i].matcher(contentType).matches()) {
return true;
Added: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/tests/src/org/jboss/soa/esb/http/HttpContentTypeUtilUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/tests/src/org/jboss/soa/esb/http/HttpContentTypeUtilUnitTest.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/tests/src/org/jboss/soa/esb/http/HttpContentTypeUtilUnitTest.java 2010-02-05 12:05:53 UTC (rev 31447)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.http;
+
+import static org.junit.Assert.*;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.junit.Test;
+
+/**
+ * Unit test for {@link HttpContentTypeUtil}.
+ * <p/>
+ *
+ * @author <a href="mailto:kevin.conner at jboss.com">Kevin Conner</a>
+ */
+public class HttpContentTypeUtilUnitTest
+{
+ @Test
+ public void testTextMatches()
+ throws Exception
+ {
+ // Should match text/*, application/xml and application/*+xml
+ testTextMatch("text/html") ;
+ testTextMatch("text/plain") ;
+ testTextMatch("text/xml") ;
+
+ testTextMatch("application/xml") ;
+
+ testTextMatch("application/soap+xml") ;
+ testTextMatch("application/atomcat+xml") ;
+ testTextMatch("application/wsdl+xml") ;
+ }
+
+ @Test
+ public void testBinaryMatches()
+ throws Exception
+ {
+ // Should not match audio/*, example/*, image/*, message/*, model/*, multipart/*, video/* and application/* not in text matches
+ testBinaryMatch("audio/3gpp") ;
+ testBinaryMatch("audio/basic") ;
+ testBinaryMatch("audio/mpeg") ;
+
+ testBinaryMatch("example/dummy") ;
+
+ testBinaryMatch("image/jpeg") ;
+ testBinaryMatch("image/png") ;
+ testBinaryMatch("image/tiff") ;
+
+ testBinaryMatch("message/example") ;
+ testBinaryMatch("message/global") ;
+ testBinaryMatch("message/partial") ;
+
+ testBinaryMatch("model/example") ;
+ testBinaryMatch("model/mesh") ;
+ testBinaryMatch("model/vrml") ;
+
+ testBinaryMatch("multipart/alternative") ;
+ testBinaryMatch("multipart/digest") ;
+ testBinaryMatch("multipart/encrypted") ;
+
+ testBinaryMatch("video/3gpp") ;
+ testBinaryMatch("video/ogg") ;
+ testBinaryMatch("video/raw") ;
+
+ testBinaryMatch("application/json") ;
+ testBinaryMatch("application/mp4") ;
+ testBinaryMatch("application/pdf") ;
+ }
+
+ private void testTextMatch(final String type)
+ {
+ expectTextMimetype(type) ;
+ expectTextMimetype(type + "; param1=1") ;
+ expectTextMimetype(type + "; param1=1; param2=2") ;
+ }
+
+ private void expectTextMimetype(final String type)
+ {
+ assertTrue(type, HttpContentTypeUtil.isTextMimetype(type)) ;
+ }
+
+ private void testBinaryMatch(final String type)
+ {
+ expectBinaryMimetype(type) ;
+ expectBinaryMimetype(type + "; param1=1") ;
+ expectBinaryMimetype(type + "; param1=1; param2=2") ;
+ }
+
+ private void expectBinaryMimetype(final String type)
+ {
+ assertFalse(type, HttpContentTypeUtil.isTextMimetype(type)) ;
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new JUnit4TestAdapter(HttpContentTypeUtilUnitTest.class);
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/tests/src/org/jboss/soa/esb/http/HttpContentTypeUtilUnitTest.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
More information about the jboss-svn-commits
mailing list