summaryrefslogtreecommitdiffstats
path: root/simple/simple-http/src/test/java/org/simpleframework/http/parse/ContentDispositionParserTest.java
blob: e5b0266554dc56c18d496f177e373af5a17171e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package org.simpleframework.http.parse;

import org.simpleframework.http.parse.ContentDispositionParser;

import junit.framework.TestCase;

public class ContentDispositionParserTest extends TestCase {
	
   private ContentDispositionParser parser;
	
   public void setUp() {
      parser = new ContentDispositionParser();
   }

   public void testDisposition() {
      parser.parse("form-data; name=\"input_check\"");

      assertFalse(parser.isFile());
      assertEquals(parser.getName(), "input_check");

      parser.parse("form-data; name=\"input_password\"");

      assertFalse(parser.isFile());
      assertEquals(parser.getName(), "input_password");

      parser.parse("form-data; name=\"FileItem\"; filename=\"C:\\Inetpub\\wwwroot\\Upload\\file1.txt\"");

      assertTrue(parser.isFile());
      assertEquals(parser.getName(), "FileItem");
      assertEquals(parser.getFileName(), "C:\\Inetpub\\wwwroot\\Upload\\file1.txt");

   }
}