2 * Copyright 2017 BOCO Corporation. CMCC Technologies Co., Ltd
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.
16 package org.onap.vfc.nfvo.emsdriver.collector;
18 import static org.junit.Assert.assertTrue;
21 import java.io.IOException;
22 import java.util.List;
24 import org.junit.After;
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.onap.vfc.nfvo.emsdriver.collector.TaskThread;
28 import org.onap.vfc.nfvo.emsdriver.commons.constant.Constant;
29 import org.onap.vfc.nfvo.emsdriver.commons.model.CollectVo;
30 import org.onap.vfc.nfvo.emsdriver.commons.utils.Gzip;
31 import org.onap.vfc.nfvo.emsdriver.messagemgr.MessageChannelFactory;
33 public class TaskThreadTest {
34 private String csvPath = System.getProperty("user.dir")+"/data/" +"PM-ENB-EUTRANCELLNB-test.csv";
35 private String gzPath = System.getProperty("user.dir")+"/data/" +"PM-ENB-EUTRANCELLNB-testa.csv.gz";
36 private TaskThread taskThread;
37 private List<File> list = null;
39 public void setUp() throws IOException {
40 taskThread = new TaskThread();
41 taskThread.pmResultChannel = MessageChannelFactory.getMessageChannel(Constant.COLLECT_CHANNEL_KEY);
42 Gzip gzip = new Gzip();
43 gzip.compress(csvPath, gzPath);
47 public void decompressed(){
48 list = taskThread.decompressed(gzPath);
49 assertTrue(list.size() > 0);
50 new File(gzPath).delete();
54 public void processPMCsv(){
55 list = taskThread.decompressed(gzPath);
56 for(File file : list){
57 boolean re = taskThread.processPMCsv(file);
63 public void parseFtpAndSendMessage(){
64 CollectVo collectVo = new CollectVo();
65 collectVo.setType("ems-p");
66 taskThread.parseFtpAndSendMessage(gzPath,collectVo);
70 public void createMessage(){
71 CollectVo collectVo = new CollectVo();
72 collectVo.setType("ems-p");
73 taskThread.createMessage("zipName", "user", "pwd", "ip", "port", 122, "nename");
81 public void setDown() throws IOException {
82 new File(gzPath).delete();
83 new File(gzPath.replace(".gz", "")).delete();