2 * Copyright 2017 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.workflow.common;
20 import java.io.FileInputStream;
21 import java.io.InputStream;
23 import org.apache.http.HttpEntity;
24 import org.apache.http.entity.ContentType;
25 import org.junit.Assert;
26 import org.junit.Test;
31 public class RestClientUtilsTest {
34 public void testbuildMultipartRequest() {
35 String filePath = System.getProperty("java.io.tmpdir");
36 String fileName = "testfile";
37 File file = new File(filePath + File.separator + fileName);
38 InputStream is = null;
43 is = new FileInputStream(file);
44 HttpEntity httpentity = RestClientUtils.buildMultipartRequest(is, fileName);
45 Assert.assertTrue(httpentity.getContentType().getValue()
46 .indexOf(ContentType.MULTIPART_FORM_DATA.getMimeType()) > -1);
47 } catch (Exception e) {
50 ToolUtil.closeInputStream(is);