You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wink.apache.org by el...@apache.org on 2009/08/24 13:44:09 UTC

svn commit: r807159 [2/2] - in /incubator/wink/trunk: wink-common/src/main/java/org/apache/wink/common/internal/providers/multipart/ wink-common/src/main/java/org/apache/wink/common/internal/utils/ wink-common/src/main/java/org/apache/wink/common/model...

Added: incubator/wink/trunk/wink-common/src/test/resources/org/apache/wink/common/internal/providers/multipart/msg05.txt
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/test/resources/org/apache/wink/common/internal/providers/multipart/msg05.txt?rev=807159&view=auto
==============================================================================
--- incubator/wink/trunk/wink-common/src/test/resources/org/apache/wink/common/internal/providers/multipart/msg05.txt (added)
+++ incubator/wink/trunk/wink-common/src/test/resources/org/apache/wink/common/internal/providers/multipart/msg05.txt Mon Aug 24 11:44:07 2009
@@ -0,0 +1,531 @@
+------=_Part_1_807283631.1066069460327
+Content-Type: text/xml; charset=UTF-8
+Content-Transfer-Encoding: binary
+Content-Id: <10...@ibm-7pr28r4m35k>
+
+<?xml version="1.0" encoding="UTF-8"?>
+    <!--
+        Licensed to the Apache Software Foundation (ASF) under one or
+        more contributor license agreements. See the NOTICE file
+        distributed with this work for additional information regarding
+        copyright ownership. The ASF licenses this file to you under the
+        Apache License, Version 2.0 (the "License"); you may not use
+        this file except in compliance with the License. You may obtain
+        a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+        applicable law or agreed to in writing, software distributed
+        under the License is distributed on an "AS IS" BASIS, WITHOUT
+        WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+        See the License for the specific language governing permissions
+        and limitations under the License.
+    -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.wink</groupId>
+    <artifactId>wink</artifactId>
+    <version>0.2-incubating-SNAPSHOT</version>
+    <packaging>pom</packaging>
+    <name>Wink</name>
+    <parent>
+        <groupId>org.apache</groupId>
+        <artifactId>apache</artifactId>
+        <version>6</version>
+    </parent>
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <javadoc.aggregate>true</javadoc.aggregate>
+        <javadoc.exclude.patterns>*.internal:org.apache.wink.example.*</javadoc.exclude.patterns>
+        <maven.compile.source>1.5</maven.compile.source>
+        <maven.compile.target>1.5</maven.compile.target>
+    </properties>
+    <modules>
+        <module>wink-component-test-support</module>
+        <module>wink-common</module>
+        <module>wink-server</module>
+        <module>wink-client</module>
+        <module>wink-client-apache-httpclient</module>
+        <module>wink-spring-support</module>
+        <module>wink-webdav</module>
+        <module>wink-examples</module>
+        <module>wink-scripts</module>
+    </modules>
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/wink/trunk</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/wink/trunk</developerConnection>
+        <url>http://svn.apache.org/viewvc/incubator/wink/trunk</url>
+    </scm>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>com.google.code.maven-license-plugin</groupId>
+                <artifactId>maven-license-plugin</artifactId>
+                <inherited>false</inherited>
+                <configuration>
+                    <header>src/etc/header.txt</header>
+                    <quiet>false</quiet>
+                    <failIfMissing>true</failIfMissing>
+                    <aggregate>true</aggregate>
+                    <includes>
+                        <include>**/src/**</include>
+                    </includes>
+                    <excludes>
+                        <exclude>**/*.txt</exclude>
+                        <exclude>**/*.docx</exclude>
+                        <exclude>**/*.pdf</exclude>
+                        <exclude>javax.ws.rs.ext.RuntimeDelegate</exclude>
+                    </excludes>
+                    <useDefaultExcludes>true</useDefaultExcludes>
+                    <mapping>
+                        <app>SCRIPT_STYLE</app>
+                    </mapping>
+                    <useDefaultMapping>true</useDefaultMapping>
+                    <encoding>UTF-8</encoding>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>verify</phase>
+                        <goals>
+                            <goal>check</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>ianal-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>verify</phase>
+                        <goals>
+                            <goal>verify-legal-files</goal>
+                        </goals>
+                        <configuration>
+                            <strict>true</strict>
+                            <searchPaths>
+                                <searchPath>apache-wink-${project.version}</searchPath>
+                                <searchPath>apache-wink-${project.version}-src</searchPath>
+                                <searchPath>meta-inf</searchPath>
+                                <searchPath>META-INF</searchPath>
+                            </searchPaths>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>com.google.code.maven-license-plugin</groupId>
+                    <artifactId>maven-license-plugin</artifactId>
+                    <version>1.4.0</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.codehaus.mojo</groupId>
+                    <artifactId>ianal-maven-plugin</artifactId>
+                    <version>1.0-alpha-1</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-war-plugin</artifactId>
+                    <version>2.1-alpha-2</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-antrun-plugin</artifactId>
+                    <dependencies>
+                        <!--
+                            Override dependencies to use Ant 1.7.0 with
+                            regular expressions and maven support
+                        -->
+                        <dependency>
+                            <groupId>org.apache.ant</groupId>
+                            <artifactId>ant</artifactId>
+                            <version>1.7.0</version>
+                        </dependency>
+                        <dependency>
+                            <groupId>org.apache.ant</groupId>
+                            <artifactId>ant-apache-regexp</artifactId>
+                            <version>1.7.0</version>
+                        </dependency>
+                        <dependency>
+                            <groupId>org.apache.maven</groupId>
+                            <artifactId>maven-artifact-ant</artifactId>
+                            <version>2.0.4</version>
+                        </dependency>
+                    </dependencies>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <configuration>
+                        <source>${maven.compile.source}</source>
+                        <target>${maven.compile.target}</target>
+                        <encoding>UTF-8</encoding>
+                        <showDeprecation>true</showDeprecation>
+                        <showWarnings>true</showWarnings>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-surefire-plugin</artifactId>
+                    <configuration>
+                        <redirectTestOutputToFile>true</redirectTestOutputToFile>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-surefire-report-plugin</artifactId>
+                    <executions>
+                        <execution>
+                            <goals>
+                                <goal>report-only</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
+                <plugin>
+                    <artifactId>maven-eclipse-plugin</artifactId>
+                    <version>2.5.1</version>
+                    <configuration>
+                        <downloadSources>true</downloadSources>
+                        <downloadJavadocs>true</downloadJavadocs>
+                        <wtpversion>1.5</wtpversion>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <groupId>org.mortbay.jetty</groupId>
+                    <artifactId>maven-jetty-plugin</artifactId>
+                    <version>6.1.15</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-war-plugin</artifactId>
+                    <configuration>
+                        <!--
+                            HACK: Include legal files explicity,
+                            otherwise they will end up in the wrong path
+                            or in another jar file in the war. NOTE:
+                            targetPath is broken for webResources (as
+                            documented)
+                        -->
+                        <webResources>
+                            <resource>
+                                <directory>${project.build.outputDirectory}</directory>
+                                <includes>
+                                    <include>META-INF/LICENSE*</include>
+                                    <include>META-INF/NOTICE*</include>
+                                    <include>META-INF/DISCLAIMER*</include>
+                                    <include>META-INF/DEPENDENCIES*</include>
+                                </includes>
+                            </resource>
+                        </webResources>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <artifactId>maven-release-plugin</artifactId>
+                    <configuration>
+                        <tagBase>https://svn.apache.org/repos/asf/incubator/wink/tags</tagBase>
+                        <preparationGoals>clean install</preparationGoals>
+                        <autoVersionSubmodules>true</autoVersionSubmodules>
+                    </configuration>
+                </plugin>
+
+                <!-- Add manifest configuration since it is not defined in apache pom-->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-source-plugin</artifactId>
+                    <version>2.1</version>
+                    <configuration>
+                        <archive>
+                            <manifest>
+                                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
+                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+                            </manifest>
+                        </archive>
+                    </configuration>
+                    <executions>
+                        <execution>
+                            <id>attach-sources</id>
+                            <goals>
+                                <goal>jar</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
+
+                <!-- Add manifest configuration since it is not defined in apache pom-->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-javadoc-plugin</artifactId>
+                    <configuration>
+                        <archive>
+                            <manifest>
+                                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
+                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+                            </manifest>
+                        </archive>
+                    </configuration>
+                    <executions>
+                        <execution>
+                            <id>attach-javadocs</id>
+                            <goals>
+                                <goal>jar</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+    </build>
+
+    <!-- Repositories that we are working with -->
+    <!--
+        <repositories> <repository> <id>central</id> <url>TBD</url>
+        </repository> <repository> <id>snapshots</id> <url>TBD</url>
+        <releases> <enabled>false</enabled> </releases> <snapshots>
+        <enabled>true</enabled> </snapshots> </repository>
+        </repositories>
+    -->
+
+    <!-- plugins repositories that we will download from -->
+    <!--
+        <pluginRepositories> <pluginRepository> <id>central</id>
+        <url>TBD</url> </pluginRepository> <pluginRepository>
+        <id>snapshots</id> <url>TBD</url> <releases>
+        <enabled>false</enabled> </releases> <snapshots>
+        <enabled>true</enabled> </snapshots> </pluginRepository>
+        </pluginRepositories>
+    -->
+    <dependencyManagement>
+        <dependencies>
+            <!-- Internal dependencies -->
+            <dependency>
+                <groupId>org.apache.wink</groupId>
+                <artifactId>wink-common</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.wink</groupId>
+                <artifactId>wink-server</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.wink</groupId>
+                <artifactId>wink-component-test-support</artifactId>
+                <version>${project.version}</version>
+                <scope>test</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.wink</groupId>
+                <artifactId>wink-spring-support</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.wink</groupId>
+                <artifactId>wink-client</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+
+            <!-- 3rd party dependencies -->
+            <dependency>
+                <groupId>javax.ws.rs</groupId>
+                <artifactId>jsr311-api</artifactId>
+                <version>1.0</version>
+            </dependency>
+            <dependency>
+                <groupId>org.springframework</groupId>
+                <artifactId>spring</artifactId>
+                <version>2.5</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>commons-logging</groupId>
+                        <artifactId>commons-logging</artifactId>
+                    </exclusion>
+                </exclusions>
+            </dependency>
+            <dependency>
+                <groupId>org.springframework</groupId>
+                <artifactId>spring-test</artifactId>
+                <scope>test</scope>
+                <version>2.5</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>commons-logging</groupId>
+                        <artifactId>commons-logging</artifactId>
+                    </exclusion>
+                </exclusions>
+            </dependency>
+            <dependency>
+                <groupId>xmlunit</groupId>
+                <artifactId>xmlunit</artifactId>
+                <scope>test</scope>
+                <version>1.1</version>
+            </dependency>
+            <dependency>
+                <groupId>junit</groupId>
+                <artifactId>junit</artifactId>
+                <version>4.4</version>
+                <scope>test</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.slf4j</groupId>
+                <artifactId>slf4j-api</artifactId>
+                <version>1.5.8</version>
+            </dependency>
+            <dependency>
+                <groupId>org.slf4j</groupId>
+                <artifactId>slf4j-simple</artifactId>
+                <version>1.5.8</version>
+            </dependency>
+            <dependency>
+                <groupId>org.slf4j</groupId>
+                <artifactId>jcl-over-slf4j</artifactId>
+                <version>1.5.6</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.geronimo.specs</groupId>
+                <artifactId>geronimo-j2ee_1.4_spec</artifactId>
+                <version>1.1</version>
+                <scope>provided</scope>
+            </dependency>
+            <dependency>
+                <groupId>commons-lang</groupId>
+                <artifactId>commons-lang</artifactId>
+                <version>2.3</version>
+            </dependency>
+            <dependency>
+                <groupId>commons-collections</groupId>
+                <artifactId>commons-collections</artifactId>
+                <version>3.2</version>
+            </dependency>
+            <dependency>
+                <groupId>javax.xml.bind</groupId>
+                <artifactId>jaxb-api</artifactId>
+                <version>2.1</version>
+            </dependency>
+            <dependency>
+                <groupId>com.sun.xml.bind</groupId>
+                <artifactId>jaxb-impl</artifactId>
+                <version>2.1.4</version>
+            </dependency>
+            <dependency>
+                <groupId>javax.activation</groupId>
+                <artifactId>activation</artifactId>
+                <version>1.1</version>
+            </dependency>
+            <dependency>
+                <groupId>xerces</groupId>
+                <artifactId>xercesImpl</artifactId>
+                <version>2.6.2</version>
+            </dependency>
+            <dependency>
+                <groupId>org.json</groupId>
+                <artifactId>json</artifactId>
+                <version>20080701</version>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-report-plugin</artifactId>
+                <!--
+                    Fix for test's re-run
+                    http://jira.codehaus.org/browse/SUREFIRE-257
+                -->
+                <reportSets>
+                    <reportSet>
+                        <reports>
+                            <report>report-only</report>
+                        </reports>
+                    </reportSet>
+                </reportSets>
+                <!--
+                    End of :Fix for test's re-run
+                    http://jira.codehaus.org/browse/SUREFIRE-257
+                -->
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jxr-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </reporting>
+    <profiles>
+        <!--
+            This profile should be activated during CI build.
+        -->
+        <profile>
+            <id>CIBuild</id>
+            <activation>
+                <activeByDefault>false</activeByDefault>
+                <property>
+                    <name>build</name>
+                    <value>CI</value>
+                </property>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-source-plugin</artifactId>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-javadoc-plugin</artifactId>
+                        <configuration>
+                            <excludePackageNames>${javadoc.exclude.patterns}</excludePackageNames>
+                            <maxmemory>1024m</maxmemory>
+                            <minmemory>512m</minmemory>
+                            <groups>
+                                <group>
+                                    <title>Common Packages</title>
+                                    <packages>org.apache.wink.common*</packages>
+                                </group>
+                                <group>
+                                    <title>Server Packages</title>
+                                    <packages>org.apache.wink.server*</packages>
+                                </group>
+                                <group>
+                                    <title>Client Packages</title>
+                                    <packages>org.apache.wink.client*</packages>
+                                </group>
+                                <group>
+                                    <title>Spring Support Packages</title>
+                                    <packages>org.apache.wink.spring*</packages>
+                                </group>
+                                <group>
+                                    <title>WebDAV Packages</title>
+                                    <packages>org.apache.wink.webdav*</packages>
+                                </group>
+                            </groups>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <phase>package</phase>
+                                <goals>
+                                    <goal>aggregate</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+            <!--
+                properties>
+                <distribution.deploy.directory>ast</distribution.deploy.directory>
+                </properties -->
+        </profile>
+    </profiles>
+    <inceptionYear>2009</inceptionYear>
+</project>
+------=_Part_1_807283631.1066069460327
+Content-Type: image/jpeg
+Content-Transfer-Encoding: binary
+Content-Id: <xyz739993.09930.3089330.3>
+
+ÿØÿà JFIF      ÿÛ C 		
+------=_Part_1_807283631.1066069460327--
\ No newline at end of file

Propchange: incubator/wink/trunk/wink-common/src/test/resources/org/apache/wink/common/internal/providers/multipart/msg05.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-common/src/test/resources/org/apache/wink/common/internal/providers/multipart/msg07.txt
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/test/resources/org/apache/wink/common/internal/providers/multipart/msg07.txt?rev=807159&view=auto
==============================================================================
--- incubator/wink/trunk/wink-common/src/test/resources/org/apache/wink/common/internal/providers/multipart/msg07.txt (added)
+++ incubator/wink/trunk/wink-common/src/test/resources/org/apache/wink/common/internal/providers/multipart/msg07.txt Mon Aug 24 11:44:07 2009
@@ -0,0 +1,3 @@
+--Boundary1
+
+--Boundary1--

Propchange: incubator/wink/trunk/wink-common/src/test/resources/org/apache/wink/common/internal/providers/multipart/msg07.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-examples/ext/MultiPart/build.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/MultiPart/build.xml?rev=807159&view=auto
==============================================================================
--- incubator/wink/trunk/wink-examples/ext/MultiPart/build.xml (added)
+++ incubator/wink/trunk/wink-examples/ext/MultiPart/build.xml Mon Aug 24 11:44:07 2009
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+
+<project name="MultiPart" default="dist" basedir=".">
+	<description>
+        Ant build file for Wink example Simple Defects
+    </description>
+
+	<property name="final.war.name" value="MultiPart.war" />
+	<property name="sdk.jar.name" value="@SDK_JAR_NAME@" />
+
+
+	<!-- set global properties for this build -->
+	<property name="build" location="build" />
+	<property name="build.classes" location="${build}/classes" />
+	<property name="sdk.base" location="${basedir}/../../.." />
+	<property name="sdk.lib" location="${sdk.base}/lib" />
+	<property name="sdk.dist" location="${sdk.base}/dist" />
+	<property name="sdk.jar" location="${sdk.dist}/${sdk.jar.name}" />
+	<property name="final.war" location="${basedir}/${final.war.name}" />
+	<property name="main" location="${basedir}/src/main" />
+	<property name="webapp" location="${main}/webapp" />
+	<property name="resources" location="${main}/resources" />
+
+
+	<target name="init">
+		<!-- Create the time stamp -->
+		<tstamp />
+		<!-- Create the build directory structure used by compile -->
+		<mkdir dir="${build.classes}" />
+	</target>
+
+	<target name="compile" depends="init" description="compile the source ">
+		<!-- Set classpath for SDK lib -->
+		<path id="sdk.classpath">
+			<fileset dir="${sdk.lib}" includes="**/*.jar" />
+			<pathelement path="${sdk.jar}" />
+		</path>
+
+		<!-- Compile the java code -->
+		<javac srcdir="${main}/java" destdir="${build.classes}">
+			<classpath refid="sdk.classpath" />
+
+		</javac>
+	</target>
+
+
+	<target name="dist" depends="compile" description="generate the distribution">
+
+		<!-- Create the war file -->
+		<war destfile="${final.war}" webxml="${webapp}/WEB-INF/web.xml" basedir="${webapp}" excludes="WEB-INF/**">
+
+			<webinf dir="${webapp}/WEB-INF" includes="**/*" />
+			<classes dir="${build.classes}" includes="**/*" />
+			<lib dir="${sdk.lib}" includes="*.jar" excludes="spring*.jar"/>
+			<lib file="${sdk.jar}" />
+		</war>
+	</target>
+
+
+	<target name="clean" description="clean up">
+		<!-- Delete the ${build} and ${dist} directory trees -->
+		<delete dir="${build}" />
+		<delete file="${final.war}" />
+	</target>
+
+</project>

Propchange: incubator/wink/trunk/wink-examples/ext/MultiPart/build.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-examples/ext/MultiPart/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/MultiPart/pom.xml?rev=807159&view=auto
==============================================================================
--- incubator/wink/trunk/wink-examples/ext/MultiPart/pom.xml (added)
+++ incubator/wink/trunk/wink-examples/ext/MultiPart/pom.xml Mon Aug 24 11:44:07 2009
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <!-- Project detailes -->
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>MultiPart</artifactId>
+    <packaging>war</packaging>
+    <name>Wink Examples Ext :: MultiPart</name>
+    <parent>
+        <groupId>org.apache.wink.example</groupId>
+        <artifactId>ext</artifactId>
+        <version>0.2-incubating-SNAPSHOT</version>
+    </parent>
+
+    <build>
+        <finalName>MultiPart</finalName>
+    </build>
+<!-- Dependency on Wink library -->
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.wink</groupId>
+            <artifactId>wink-common</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.wink</groupId>
+            <artifactId>wink-server</artifactId>
+        </dependency>
+        <dependency>
+			<groupId>org.apache.wink</groupId>
+			<artifactId>wink-component-test-support</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>jcl-over-slf4j</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-j2ee_1.4_spec</artifactId>
+        </dependency>
+    </dependencies>
+</project>

Propchange: incubator/wink/trunk/wink-examples/ext/MultiPart/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-examples/ext/MultiPart/readme.txt
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/MultiPart/readme.txt?rev=807159&view=auto
==============================================================================
--- incubator/wink/trunk/wink-examples/ext/MultiPart/readme.txt (added)
+++ incubator/wink/trunk/wink-examples/ext/MultiPart/readme.txt Mon Aug 24 11:44:07 2009
@@ -0,0 +1,34 @@
+MultiPart Example
+===============================================================================
+
+Description 
+===============================================================================
+- This example demonstrate the usage of the Multipart module. 
+- It demonstrate two kind of Multipart usage:
+  The first is a simple user management, it uses buffered in and out multipart, 
+  while each part hold the xml representation of a user
+  usage: 
+  GET http://localhost:8080/MultiPart/rest/MP/users
+  to get the users list in a MultiPart format
+  
+  POST http://localhost:8080/MultiPart/rest/MP/users
+  with users information in multipart format to add users to the list. 
+  
+  
+  The second one is file uploader it upload, it uses the InMultiPart class which 
+  enable it to handle Messages of a huge size, it upload the files and save them to 
+  the temp directory
+      
+  usage:
+  using a browser open the page located in http://localhost:8080/MultiPart/UploadFiles.html
+  select 2 files and upload them   
+    
+-Wink features used in this example:
+   Multipart, ServiceDocument
+     
+Build
+===============================================================================
+- see build instructions in examples/readme.txt file
+
+--- readme.txt EOF ---
+  
\ No newline at end of file

Propchange: incubator/wink/trunk/wink-examples/ext/MultiPart/readme.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/java/org/apache/wink/example/multipart/MultiPartResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/java/org/apache/wink/example/multipart/MultiPartResource.java?rev=807159&view=auto
==============================================================================
--- incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/java/org/apache/wink/example/multipart/MultiPartResource.java (added)
+++ incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/java/org/apache/wink/example/multipart/MultiPartResource.java Mon Aug 24 11:44:07 2009
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *  
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *  
+ *******************************************************************************/
+
+package org.apache.wink.example.multipart;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+
+import org.apache.wink.common.internal.utils.MediaTypeUtils;
+import org.apache.wink.common.model.multipart.BufferedInMultiPart;
+import org.apache.wink.common.model.multipart.BufferedOutMultiPart;
+import org.apache.wink.common.model.multipart.InMultiPart;
+import org.apache.wink.common.model.multipart.InPart;
+import org.apache.wink.common.model.multipart.OutPart;
+
+/**
+ * A resource that demonstrate the usage of MultiPart.
+ */
+
+@Path("/MP")
+public class MultiPartResource {
+
+    // user storage 
+    private static ArrayList<User> usersList = new ArrayList<User>();
+    static {
+        User u = new User("Moshe", "tornado", 1, "moshe@gmail.com");
+        usersList.add(u);
+        u = new User("Jhon", "Dow", 2, "Jhon@gmail.com");
+        usersList.add(u);
+    }
+    
+
+    /**
+     * This method return all the users in a multipart/mixed representation
+     * it demonstrat the usage of BufferedOutMultiPart and OutPart. 
+     * @return
+     */
+    @Path("users")
+    @GET
+    @Produces( {"multipart/mixed"})
+    public BufferedOutMultiPart getUsers() {
+        BufferedOutMultiPart mp = new BufferedOutMultiPart();
+
+        for (User user : usersList) {
+            OutPart op = new OutPart();
+            op.setContentType(MediaType.APPLICATION_XML);
+            op.setBody(user);
+            mp.addPart(op);
+        }
+        return mp;
+    }
+    
+    /**
+     *  This method add users and returns the updated user list in multipart/mixed representation
+     *  It demonstrate the usage of BufferedInMultiPart and InPart
+     */
+
+    @Path("users")
+    @POST
+    @Produces( {"multipart/mixed"})
+    @Consumes( {"multipart/mixed"})
+    public BufferedOutMultiPart addUsers(BufferedInMultiPart inMP) throws IOException {
+        List<InPart> parts = inMP.getParts();
+        for (InPart p : parts) {
+            User u = p.getBody(User.class, null);
+            usersList.add(u);
+
+        }
+        return getUsers();
+    }
+    
+    /**
+     * This method come to demonstrate the way to work with huge Multipart messages. 
+     * it uses the InMultiPart which does not buffer the content of the message.   
+     * @param inMP
+     * @return
+     * @throws IOException
+     */
+
+    @Path("files")
+    @POST
+    @Produces( MediaType.TEXT_PLAIN)
+    @Consumes( MediaTypeUtils.MULTIPART_FORM_DATA)
+    public String uploadFiles(InMultiPart inMP) throws IOException {
+        StringBuilder sb = new StringBuilder();
+        int fileID = 0;
+
+        while (inMP.hasNext()) {
+            File f = File.createTempFile("apache-wink-Multipart-example" + fileID, ".tmp");
+            FileOutputStream fos = new FileOutputStream(f);
+            InPart part = inMP.next();
+            MultivaluedMap<String, String> heades = part.getHeaders();
+            String CDHeader = heades.getFirst("Content-Disposition");
+            InputStream is = part.getInputStream();
+            int size = 0;
+            int i = 0;
+            byte[] ba = new byte[8196];
+            while ((i = is.read(ba)) != -1) {
+                fos.write(ba, 0, i);
+                size += i;
+            }
+            fos.close();
+            
+            String fileName ="";
+            Pattern p =  Pattern.compile("filename=\".*\""); 
+            Matcher m = p.matcher(CDHeader);            
+            if (m.find()){
+                fileName = m.group();
+            }
+            
+            //String filename = CDHeader. 
+            sb.append("uploaded a file, " + fileName + ", size = " + size + " bytes\n");
+        }
+        return sb.toString();
+    }
+
+}

Propchange: incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/java/org/apache/wink/example/multipart/MultiPartResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/java/org/apache/wink/example/multipart/User.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/java/org/apache/wink/example/multipart/User.java?rev=807159&view=auto
==============================================================================
--- incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/java/org/apache/wink/example/multipart/User.java (added)
+++ incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/java/org/apache/wink/example/multipart/User.java Mon Aug 24 11:44:07 2009
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *  
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *  
+ *******************************************************************************/
+package org.apache.wink.example.multipart;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlRootElement(name = "user")
+public class User {
+
+    private String firstName;
+    private String lastName;
+    private int    id;
+    private String email;
+
+    public User() {
+    }
+
+    public User(String firstName, String lastName, int id, String email) {
+        this.firstName = firstName;
+        this.lastName = lastName;
+        this.id = id;
+        this.email = email;
+    }
+
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getEmail() {
+        return email;
+    }
+
+    public void setEmail(String email) {
+        this.email = email;
+    }
+
+}

Propchange: incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/java/org/apache/wink/example/multipart/User.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/webapp/UploadFiles.html
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/webapp/UploadFiles.html?rev=807159&view=auto
==============================================================================
--- incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/webapp/UploadFiles.html (added)
+++ incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/webapp/UploadFiles.html Mon Aug 24 11:44:07 2009
@@ -0,0 +1,42 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+    
+     http://www.apache.org/licenses/LICENSE-2.0
+    
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>File Uploader</title>
+</head>
+<body>
+<form action="rest/MP/files"
+enctype="multipart/form-data" method="post">
+<p>
+Please select a file to upload:<br>
+<input type="file" name="datafile1" size="40">
+</p>
+<p>
+Please select a file to upload:<br>
+<input type="file" name="datafile2" size="40">
+</p>
+<div>
+<input type="submit" value="Send">
+</div>
+</form>
+
+</body>
+</html>
\ No newline at end of file

Propchange: incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/webapp/UploadFiles.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/webapp/WEB-INF/application
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/webapp/WEB-INF/application?rev=807159&view=auto
==============================================================================
--- incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/webapp/WEB-INF/application (added)
+++ incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/webapp/WEB-INF/application Mon Aug 24 11:44:07 2009
@@ -0,0 +1,14 @@
+#	Licensed to the Apache Software Foundation (ASF) under one or more
+#	contributor license agreements. See the NOTICE file distributed with
+#	this work for additional information regarding copyright ownership.
+#	The ASF licenses this file to you under the Apache License, Version
+#	2.0 (the "License"); you may not use this file except in compliance
+#	with the License. You may obtain a copy of the License at
+#
+#	http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+#	applicable law or agreed to in writing, software distributed under the
+#	License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+#	CONDITIONS OF ANY KIND, either express or implied. See the License for
+#	the specific language governing permissions and limitations under the
+#	License.
+org.apache.wink.example.multipart.MultiPartResource

Propchange: incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/webapp/WEB-INF/application
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/webapp/WEB-INF/configuration.properties
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/webapp/WEB-INF/configuration.properties?rev=807159&view=auto
==============================================================================
--- incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/webapp/WEB-INF/configuration.properties (added)
+++ incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/webapp/WEB-INF/configuration.properties Mon Aug 24 11:44:07 2009
@@ -0,0 +1,20 @@
+##
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##  http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied.  See the License for the
+## specific language governing permissions and limitations
+## under the License.
+##
+
+wink.defaultUrisRelative=false

Propchange: incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/webapp/WEB-INF/configuration.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/webapp/WEB-INF/web.xml?rev=807159&view=auto
==============================================================================
--- incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/webapp/WEB-INF/web.xml (added)
+++ incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/webapp/WEB-INF/web.xml Mon Aug 24 11:44:07 2009
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+
+<!DOCTYPE web-app PUBLIC
+        "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+        "http://java.sun.com/dtd/web-app_2_3.dtd" >
+
+<web-app>
+	<display-name>Wink SDK demo</display-name>
+	<description>Demonstration of SDK features</description>
+
+	<servlet>
+		<servlet-name>restSdkService</servlet-name>
+		<servlet-class>org.apache.wink.server.internal.servlet.RestServlet</servlet-class>
+		<init-param>
+			<param-name>propertiesLocation</param-name>
+			<param-value>/WEB-INF/configuration.properties</param-value>
+		</init-param>
+		<init-param>
+			<param-name>applicationConfigLocation</param-name>
+			<param-value>/WEB-INF/application</param-value>
+		</init-param>
+		<load-on-startup>0</load-on-startup>
+	</servlet>
+
+	<servlet-mapping>
+		<servlet-name>restSdkService</servlet-name>
+		<url-pattern>/rest/*</url-pattern>
+	</servlet-mapping>
+
+</web-app>

Propchange: incubator/wink/trunk/wink-examples/ext/MultiPart/src/main/webapp/WEB-INF/web.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-examples/ext/MultiPart/src/test/java/org/apache/wink/example/multipart/MultiPartTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/MultiPart/src/test/java/org/apache/wink/example/multipart/MultiPartTest.java?rev=807159&view=auto
==============================================================================
--- incubator/wink/trunk/wink-examples/ext/MultiPart/src/test/java/org/apache/wink/example/multipart/MultiPartTest.java (added)
+++ incubator/wink/trunk/wink-examples/ext/MultiPart/src/test/java/org/apache/wink/example/multipart/MultiPartTest.java Mon Aug 24 11:44:07 2009
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *  
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *  
+ *******************************************************************************/
+
+package org.apache.wink.example.multipart;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.wink.common.internal.providers.multipart.MultiPartParser;
+import org.apache.wink.common.internal.utils.MediaTypeUtils;
+import org.apache.wink.common.model.atom.AtomEntry;
+import org.apache.wink.common.model.atom.AtomFeed;
+import org.apache.wink.server.internal.servlet.MockServletInvocationTest;
+import org.apache.wink.test.diff.DiffIgnoreUpdateWithAttributeQualifier;
+import org.apache.wink.test.mock.MockRequestConstructor;
+import org.apache.wink.test.mock.TestUtils;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.w3c.dom.Document;
+
+/**
+ *
+ */
+public class MultiPartTest extends MockServletInvocationTest {
+
+    @Override
+    protected Class<?>[] getClasses() {
+        return new Class[] {MultiPartResource.class};
+    }
+
+    private String buildUserXML(String first, String last, String id, String email) {
+        return "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><user><firstName>" + first
+            + "</firstName><lastName>"
+            + last
+            + "</lastName><id>"
+            + id
+            + "</id><email>"
+            + email
+            + "</email></user>";
+
+    }
+
+    public void verifyResponse(MockHttpServletResponse response, int expectedPartsNum)
+        throws Exception {
+        String contentType = response.getContentType();
+        String bound = contentType.substring(contentType.indexOf("=") + 1);
+        String content = response.getContentAsString();
+        ByteArrayInputStream in = new ByteArrayInputStream(content.getBytes());
+        MultiPartParser mpp = new MultiPartParser(in, bound);
+        int numOfParts = 0;
+        while (mpp.nextPart()) {
+            numOfParts++;
+        }
+        assertEquals(numOfParts, expectedPartsNum);
+
+    }
+
+    private byte[] obtainByteData(String filename) throws IOException {
+        InputStream inputStream = getClass().getResourceAsStream(filename);
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream(1024);
+        byte[] bytes = new byte[512];
+
+        // Read bytes from the input stream in bytes.length-sized chunks and
+        // write
+        // them into the output stream
+        int readBytes;
+        while ((readBytes = inputStream.read(bytes)) > 0) {
+            outputStream.write(bytes, 0, readBytes);
+        }
+
+        // Convert the contents of the output stream into a byte array
+        byte[] byteData = outputStream.toByteArray();
+
+        // Close the streams
+        inputStream.close();
+        outputStream.close();
+
+        return byteData;
+    }
+
+    public void testUsers() throws Exception {
+
+        // check the collection
+        MockHttpServletRequest request =
+            MockRequestConstructor.constructMockRequest("GET",
+                                                        "/users",
+                                                        MediaTypeUtils.MULTIPART_MIXED);
+        MockHttpServletResponse response = invoke(request);
+        assertEquals("status", 200, response.getStatus());
+        verifyResponse(response, 2);
+
+        String boundary = "I am a boundary";
+        String requestStr =
+            "--" + boundary
+                + "\n"
+                + "Content-Type: application/xml\n\n"
+                + buildUserXML("firstName", "lastName", "9", "myEmail@mail.com")
+                + "\n--"
+                + boundary
+                + "--";
+
+        request =
+            MockRequestConstructor
+                .constructMockRequest("POST",
+                                      "/users",
+                                      MediaTypeUtils.MULTIPART_MIXED,
+                                      MediaTypeUtils.MULTIPART_MIXED + ";boundary=" + boundary,
+                                      requestStr.getBytes());
+        response = invoke(request);
+        assertEquals("status", 200, response.getStatus());
+        verifyResponse(response, 3);
+
+    }
+
+    /**
+     * Upload files and test the the file size as returned by the resource is
+     * identical to the actual file length
+     * 
+     * @throws IOException
+     * @throws ServletException
+     * @throws UnsupportedEncodingException
+     */
+    public void testUploadFile() throws IOException, ServletException, UnsupportedEncodingException {
+        String boundary = "I am a boundary";
+        MockHttpServletRequest request;
+        MockHttpServletResponse response;
+
+        String msg1 =
+            "--" + boundary
+                + "\n"
+                + "Content-Disposition: form-data; name=\"datafile\"; filename=\"JDOMAbout\"\n"
+                + "Content-Type: application/octet-stream\n\n";
+        byte[] bms1 = msg1.getBytes();
+        byte[] bms2 = obtainByteData("file1");
+        String msg3 = "\n--" + boundary + "--";
+        byte[] bms3 = msg3.getBytes();
+        int bodyLength = bms2.length;
+        byte[] msg = new byte[bms1.length + bms2.length + bms3.length];
+        System.arraycopy(bms1, 0, msg, 0, bms1.length);
+        System.arraycopy(bms2, 0, msg, bms1.length, bms2.length);
+        System.arraycopy(bms3, 0, msg, bms1.length + bms2.length, bms3.length);
+
+        request =
+            MockRequestConstructor
+                .constructMockRequest("POST",
+                                      "/files",
+                                      MediaType.TEXT_PLAIN,
+                                      MediaTypeUtils.MULTIPART_FORM_DATA + ";boundary=" + boundary,
+                                      msg);
+        response = invoke(request);
+        String content = response.getContentAsString();
+        int i = content.indexOf(String.valueOf(bodyLength));
+        assertNotSame(i, -1);
+    }
+
+}

Propchange: incubator/wink/trunk/wink-examples/ext/MultiPart/src/test/java/org/apache/wink/example/multipart/MultiPartTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-examples/ext/MultiPart/src/test/resources/org/apache/wink/example/multipart/file1
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/MultiPart/src/test/resources/org/apache/wink/example/multipart/file1?rev=807159&view=auto
==============================================================================
Files incubator/wink/trunk/wink-examples/ext/MultiPart/src/test/resources/org/apache/wink/example/multipart/file1 (added) and incubator/wink/trunk/wink-examples/ext/MultiPart/src/test/resources/org/apache/wink/example/multipart/file1 Mon Aug 24 11:44:07 2009 differ

Modified: incubator/wink/trunk/wink-examples/ext/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/pom.xml?rev=807159&r1=807158&r2=807159&view=diff
==============================================================================
--- incubator/wink/trunk/wink-examples/ext/pom.xml (original)
+++ incubator/wink/trunk/wink-examples/ext/pom.xml Mon Aug 24 11:44:07 2009
@@ -30,12 +30,13 @@
     </parent>
     <modules>
 		<module>Asset</module>
-		<module>Spring</module>
 		<module>DynamicResource</module>
 		<module>History</module>
-		<module>WebDAV</module>
-		<module>RuntimeRegistration</module>
 		<module>LinkBuilders</module>
+		<module>MultiPart</module>
+		<module>RuntimeRegistration</module>
 		<module>Scope</module>
+		<module>Spring</module>		
+		<module>WebDAV</module>
   </modules>
 </project>