001: /*
002: * Copyright 2005-2007 The Kuali Foundation.
003: *
004: *
005: * Licensed under the Educational Community License, Version 1.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.opensource.org/licenses/ecl1.php
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: // Created on May 19, 2006
018: package edu.iu.uis.eden.edl;
019:
020: /*import java.io.ByteArrayOutputStream;
021: import java.io.IOException;
022:
023: import org.apache.commons.httpclient.methods.PostMethod;
024: import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
025: import org.apache.commons.httpclient.methods.multipart.Part;
026: import org.apache.commons.httpclient.methods.multipart.StringPart;*/
027: import org.junit.Ignore;
028: import org.junit.Test;
029: import org.kuali.rice.test.LoggableTestCase;
030:
031: /**
032: * Tests the behavior of EDocLiteForm in the presence of various types of input
033: * @author Aaron Hamid (arh14 at cornell dot edu)
034: */
035: public class EDocLiteFormTest extends LoggableTestCase {
036: /**
037: * Tests how EDocLiteForm handles parameters with multiple values
038: */
039: @Ignore("This test needs to be implemented!")
040: @Test
041: public void testMultipleValuesPlainPOST() throws Exception {
042: // MockHttpServletRequest req = new MockHttpServletRequest();
043: // req.setMethod("post");
044: // req.addParameter("multiple_value", "value0");
045: // req.addParameter("multiple_value", "value1");
046: // req.addParameter("single_value", "value0");
047: // String[] values = req.getParameterValues("multiple_value");
048: // assertNotNull(values);
049: // assertEquals(2, values.length);
050: // values = req.getParameterValues("single_value");
051: // assertNotNull(values);
052: // assertEquals(1, values.length);
053: //
054: // values = (String[]) req.getParameterMap().get("multiple_value");
055: // assertNotNull(values);
056: // assertEquals(2, values.length);
057: // values = (String[]) req.getParameterMap().get("single_value");
058: // assertNotNull(values);
059: // assertEquals(1, values.length);
060: //
061: // EDocLiteForm form = new EDocLiteForm(req);
062: // values = (String[]) form.getParameterMap().get("multiple_value");
063: // assertNotNull(values);
064: // assertEquals(2, values.length);
065: // values = (String[]) form.getParameterMap().get("single_value");
066: // assertNotNull(values);
067: // assertEquals(1, values.length);
068: //
069: // req.addParameter("action", "testAction");
070: // form = new EDocLiteForm(req);
071: // assertEquals("testAction", form.getAction());
072: //
073: // req.addParameter("action", "testAction2");
074: // form = new EDocLiteForm(req);
075: // assertEquals("testAction", form.getAction());
076: }
077:
078: /* this requires Jakarta Commons HttpClient to compile and
079: Commons Codec, IO, and Collections as well to run */
080: /*
081: public void testMultipleValuesMultipart() throws IOException {
082: Part[] parts = {
083: new StringPart("multiple_value", "value0"),
084: new StringPart("multiple_value", "value1"),
085: new StringPart("single_value", "value0")
086: };
087: MultipartRequestEntity mp = new MultipartRequestEntity(parts, new PostMethod().getParams());
088: ByteArrayOutputStream baos = new ByteArrayOutputStream();
089: mp.writeRequest(baos);
090:
091: MockHttpServletRequest req = new MockHttpServletRequest();
092: req.setMethod("post");
093: req.setContentType(mp.getContentType());
094: req.setContent(baos.toByteArray());
095:
096: EDocLiteForm form = new EDocLiteForm(req);
097: Object o = form.getParameterMap().get("multiple_value");
098: assertNotNull(o);
099: log.info(o.toString());
100: assertTrue("multiple_value parameter value is not a String[]: " + o.getClass(), o instanceof String[]);
101:
102: String[] values = (String[]) o;
103: assertEquals(2, values.length);
104: o = form.getParameterMap().get("single_value");
105: assertNotNull(o);
106: assertTrue("single_value parameter value is not a String[]: " + o.getClass(), o instanceof String[]);
107: values = (String[]) o;
108: assertNotNull(values);
109: assertEquals(1, values.length);
110: assertEquals("testAction", form.getAction());
111: }*/
112: }
|