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 xmlPath = System.getProperty("user.dir")+"/data/" +"PM-test.xml";
36 private String gzPath = System.getProperty("user.dir")+"/data/" +"PM-ENB-EUTRANCELLNB-testa.csv.gz";
37 private TaskThread taskThread;
38 private List<File> list = null;
40 public void setUp() throws IOException {
41 taskThread = new TaskThread();
42 taskThread.pmResultChannel = MessageChannelFactory.getMessageChannel(Constant.COLLECT_RESULT_PM_CHANNEL_KEY);
43 Gzip gzip = new Gzip();
44 gzip.compress(csvPath, gzPath);
48 public void decompressed(){
49 list = taskThread.decompressed(gzPath);
50 assertTrue(list.size() > 0);
51 new File(gzPath).delete();
55 public void processPMCsv(){
56 list = taskThread.decompressed(gzPath);
57 for(File file : list){
58 boolean re = taskThread.processPMCsv(file);
63 public void processPMXml(){
64 File file = new File(xmlPath);
65 boolean re = taskThread.processPMXml(file);
67 System.out.println(taskThread.pmResultChannel.size());
71 public void parseFtpAndSendMessage(){
72 CollectVo collectVo = new CollectVo();
73 collectVo.setType("ems-p");
74 taskThread.parseFtpAndSendMessage(gzPath,collectVo);
78 public void createMessage(){
79 CollectVo collectVo = new CollectVo();
80 collectVo.setType("ems-p");
81 taskThread.createMessage("zipName", "user", "pwd", "ip", "port", 122, "nename");
85 public void setDown() throws IOException {
86 new File(gzPath).delete();
87 new File(gzPath.replace(".gz", "")).delete();