/*
 * 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.jmeter.protocol.http.sampler;

import static org.junit.Assert.assertEquals;

import java.net.URLConnection;
import org.apache.jmeter.protocol.http.util.HTTPFileArg;
import org.junit.Test;
import org.apache.jmeter.protocol.http.util.HTTPConstants;

public class PutWriterTest {


    @Test
    public void testSetHeaders() throws Exception {
        URLConnection uc = new NullURLConnection();
        HTTPSampler sampler = new HTTPSampler();
        sampler.setHTTPFiles(new HTTPFileArg[]{new HTTPFileArg("file1", "", "mime1")});
        PutWriter pw = new PutWriter();
        pw.setHeaders(uc, sampler);
        assertEquals("mime1", uc.getRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE));
        uc = new NullURLConnection();
        sampler.setHTTPFiles(new HTTPFileArg[]{new HTTPFileArg("file2", "param2", "mime2")});
        pw.setHeaders(uc, sampler);
        assertEquals("mime2", uc.getRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE));
    }
}

@@ -923,16 +923,118 @@
 nection;
+%0A%0Aimport org.apache.jmeter.config.Arguments;%0Aimport org.apache.jmeter.protocol.http.util.HTTPArgument;
 %0Aimport 
@@ -1196,17 +1196,16 @@
 Test %7B%0A%0A
-%0A
     @Tes
@@ -1236,16 +1236,28 @@
 tHeaders
+WithNoParams
 () throw
@@ -1409,33 +1409,35 @@
 ew HTTPFileArg%5B%5D
-%7B
+ %7B 
 new HTTPFileArg(
@@ -1448,16 +1448,32 @@
 e1%22, %22%22,
+%0A               
  %22mime1%22
@@ -1473,16 +1473,17 @@
 %22mime1%22)
+ 
 %7D);%0A    
@@ -1583,16 +1583,32 @@
 %22mime1%22,
+%0A               
  uc.getR
@@ -1667,38 +1667,180 @@
     
+%7D%0A%0A
     
-uc = new NullURLConnection
+@Test%0A    public void testSetHeadersWithParams() throws Exception %7B%0A        URLConnection uc = new NullURLConnection();%0A        HTTPSampler sampler = new HTTPSampler
 ();%0A
@@ -1885,17 +1885,19 @@
 ileArg%5B%5D
-%7B
+ %7B 
 new HTTP
@@ -1912,16 +1912,32 @@
 %22file2%22,
+%0A               
  %22param2
@@ -1947,20 +1947,228 @@
 %22mime2%22)
+ 
 %7D);%0A
+        Arguments arguments = new Arguments();%0A        arguments.addArgument(new HTTPArgument(%22%22, %22parameter with no name%22));%0A        sampler.setArguments(arguments);%0A        PutWriter pw = new PutWriter();%0A
         
@@ -2224,16 +2224,32 @@
 %22mime2%22,
+%0A               
  uc.getR

Split up test case to test only one thing at a time. Correct the second test case at the same time. PutWriter would use all unnamed arguments for the body of the request, so set them. This is in preparation for Bug 60575.