Author: tv
Date: Tue Jul 31 22:23:27 2018
New Revision: 1837188

URL: http://svn.apache.org/viewvc?rev=1837188&view=rev
Log:
INCOMAPTIBLE: Update dependency servlet-api to 3.1
INCOMAPTIBLE: Remove dependency on fulcrum-upload. 
All FileItems are now Parts.
Require Java-8

Modified:
    
turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/ParameterParserTest.java

Modified: 
turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/ParameterParserTest.java
URL: 
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/ParameterParserTest.java?rev=1837188&r1=1837187&r2=1837188&view=diff
==============================================================================
--- 
turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/ParameterParserTest.java
 (original)
+++ 
turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/ParameterParserTest.java
 Tue Jul 31 22:23:27 2018
@@ -1,11 +1,5 @@
 package org.apache.fulcrum.parser;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -25,13 +19,20 @@ import static org.junit.Assert.fail;
  * under the License.
  */
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
 import java.util.Iterator;
 
+import javax.servlet.http.Part;
+
 import org.apache.avalon.framework.component.ComponentException;
-import org.apache.commons.fileupload.FileItem;
-import org.apache.commons.fileupload.FileItemFactory;
-import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 import org.apache.fulcrum.parser.ValueParser.URLCaseFolding;
 import org.apache.fulcrum.testcontainer.BaseUnit4Test;
 import org.junit.Before;
@@ -62,7 +63,7 @@ public class ParameterParserTest extends
             fail(e.getMessage());
         }
     }
-    
+
     @Test
     public void testConfiguredUrlCaseFolding() throws Exception
     {
@@ -76,7 +77,7 @@ public class ParameterParserTest extends
     public void testConfiguredParameterEncoding() throws Exception {
         assertEquals("utf-8", parserService.getParameterEncoding());
     }
-    
+
     /**
      * Simple test to verify that URL Case Folding works properly
      *
@@ -93,22 +94,81 @@ public class ParameterParserTest extends
     /**
      * This Test method checks the DefaultParameterParser which carries two 
Sets inside it.
      * The suggested problem was that pp.keySet() returns both Keys, but 
pp.getStrings("key")
-     * only checks for keys which are not FileItems.
+     * only checks for keys which are not Parts.
      *
      * @throws Exception
      */
     @Test
     public void testAddPathInfo() throws Exception
     {
-        FileItemFactory factory = new DiskFileItemFactory(10240, null);
-
         assertEquals("keySet() is not empty!", 0, 
parameterParser.keySet().size());
 
-        FileItem test = factory.createItem("upload-field", 
"application/octet-stream", false, null);
+        Part test = new Part()
+        {
+
+            @Override
+            public void write(String fileName) throws IOException
+            {
+            }
+
+            @Override
+            public String getSubmittedFileName()
+            {
+                return null;
+            }
+
+            @Override
+            public long getSize()
+            {
+                return 0;
+            }
+
+            @Override
+            public String getName()
+            {
+                return "upload-field";
+            }
+
+            @Override
+            public InputStream getInputStream() throws IOException
+            {
+                return null;
+            }
+
+            @Override
+            public Collection<String> getHeaders(String name)
+            {
+                return null;
+            }
+
+            @Override
+            public Collection<String> getHeaderNames()
+            {
+                return null;
+            }
+
+            @Override
+            public String getHeader(String name)
+            {
+                return null;
+            }
+
+            @Override
+            public String getContentType()
+            {
+                return "application/octet-stream";
+            }
+
+            @Override
+            public void delete() throws IOException
+            {
+            }
+        };
+
         // Push this into the parser using DefaultParameterParser's add() 
method.
         ((DefaultParameterParser) parameterParser).add("upload-field", test);
 
-        assertEquals("FileItem not found in keySet()!", 1, 
parameterParser.keySet().size());
+        assertEquals("Part not found in keySet()!", 1, 
parameterParser.keySet().size());
 
         Iterator<String> it = parameterParser.keySet().iterator();
         assertTrue(it.hasNext());
@@ -125,8 +185,8 @@ public class ParameterParserTest extends
         assertTrue(parameterParser.containsKey("upload-field"));
         assertTrue(parameterParser.containsKey("other-field"));
 
-        // The following will actually cause a ClassCastException because 
getStrings() (and others) are not catering for FileItems.
-        assertNull("The returned should be null because a FileItem is not a 
String", parameterParser.getStrings("upload-field"));
+        // The following will actually cause a ClassCastException because 
getStrings() (and others) are not catering for Parts.
+        assertNull("The returned should be null because a Part is not a 
String", parameterParser.getStrings("upload-field"));
         assertFalse(parameterParser.containsKey("missing-field"));
     }
 }


Reply via email to