    001    /*
    002     * Licensed to the Apache Software Foundation (ASF) under one or more
    003     * contributor license agreements.  See the NOTICE file distributed with
    004     * this work for additional information regarding copyright ownership.
    005     * The ASF licenses this file to You under the Apache License, Version 2.0
    006     * (the "License"); you may not use this file except in compliance with
    007     * the License.  You may obtain a copy of the License at
    008     *
    009     *      http://www.apache.org/licenses/LICENSE-2.0
    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    package org.apache.commons.fileupload;
    018
    019
    020    import junit.framework.TestCase;
    021    import java.io.*;
    022
    023
    024    /**
    025     * Unit tests {@link org.apache.commons.fileupload.MultipartStream}.
    026     *
    027     * @author Sean C. Sullivan
    028     *
    029     */
    030    public class MultipartStreamTest extends TestCase
    031    {
    032            static private final String BOUNDARY_TEXT = "myboundary";
    033
    034        public void testThreeParamConstructor() throws Exception {
    035                    final String strData = "foobar";
    036                    final byte[] contents = strData.getBytes();
    037                    InputStream input = new ByteArrayInputStream(contents);
    038            byte[] boundary = BOUNDARY_TEXT.getBytes();
    039            int iBufSize = boundary.length;
    040            MultipartStream ms = new MultipartStream(
    041                            input,
    042                            boundary,
    043                            iBufSize,
    044                            new MultipartStream.ProgressNotifier(null, contents.length));
    045        }
    046
    047            public void testTwoParamConstructor() throws Exception {
    048                    final String strData = "foobar";
    049                    final byte[] contents = strData.getBytes();
    050                    InputStream input = new ByteArrayInputStream(contents);
    051                    byte[] boundary = BOUNDARY_TEXT.getBytes();
    052                    MultipartStream ms = new MultipartStream(
    053                                    input,
    054                                    boundary,
    055                                    new MultipartStream.ProgressNotifier(null, contents.length));
    056            }
    057    }