summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwangguirong <wangguirong@boco.com.cn>2017-09-27 17:14:18 +0800
committerwangguirong <wangguirong@boco.com.cn>2017-09-27 17:14:34 +0800
commit9e646bf9645c0daf4cd7fd4e86a18c02fc2667cc (patch)
tree1de4cb74c712bb0668982987f0be93cd0ca679df
parent1047f2000394aa027967940e73fabf3586bb6fc1 (diff)
delete gz file and Modify test case
Change-Id: I76e013a35450d38cc9978aca9e799811c070176a Issue-Id:VFC-461 Signed-off-by: wangguirong <wangguirong@boco.com.cn>
-rw-r--r--ems/boco/data/PM-ENB-EUTRANCELLNB-test.csv4
-rw-r--r--ems/boco/data/PM-ENB-EUTRANCELLNB-test.csv.gzbin1058 -> 0 bytes
-rw-r--r--ems/boco/pom.xml9
-rw-r--r--ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/TaskThreadTest.java15
-rw-r--r--ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/commons/utils/GunzipTest.java8
-rw-r--r--ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/commons/utils/Gzip.java79
-rw-r--r--ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/commons/utils/UnZipTest.java21
-rw-r--r--ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/commons/utils/ZipTest.java1
8 files changed, 123 insertions, 14 deletions
diff --git a/ems/boco/data/PM-ENB-EUTRANCELLNB-test.csv b/ems/boco/data/PM-ENB-EUTRANCELLNB-test.csv
new file mode 100644
index 0000000..7b2a177
--- /dev/null
+++ b/ems/boco/data/PM-ENB-EUTRANCELLNB-test.csv
@@ -0,0 +1,4 @@
+TimeStamp=2017-07-17 09:00:54|TimeZone=UTC+8|Period=15|VendorName=ZTE|ElementType=ENB|PmVersion=V2.9.0|ObjectType=EutranCellNB
+rmUID|Dn|UserLabel|startTime|NBPHY.ULMaxNL.SubCarrier9|NBPHY.ULMaxNL.SubCarrier8|NBPHY.ULMaxNL.SubCarrier7|NBPHY.ULMaxNL.SubCarrier14|NBPHY.ULMaxNL.SubCarrier15|NBPHY.ULMaxNL.SubCarrier38|NBPHY.ULMaxNL.SubCarrier12|NBPHY.ULMaxNL.SubCarrier39|NBPHY.ULMaxNL.SubCarrier13|NBPHY.ULMaxNL.SubCarrier36|NBPHY.ULMaxNL.SubCarrier18|NBPHY.ULMaxNL.SubCarrier37|NBPHY.ULMaxNL.SubCarrier19|NBPHY.ULMaxNL.SubCarrier34|NBPHY.ULMaxNL.SubCarrier16|NBPHY.ULMaxNL.SubCarrier35|NBPHY.ULMaxNL.SubCarrier32|NBPHY.ULMaxNL.SubCarrier17|NBPHY.ULMaxNL.SubCarrier30|NBPHY.ULMaxNL.SubCarrier33|NBPHY.ULMaxNL.SubCarrier10|NBPHY.ULMaxNL.SubCarrier31|NBPHY.ULMaxNL.SubCarrier23|NBPHY.ULMaxNL.SubCarrier11|NBPHY.ULMaxNL.SubCarrier25|NBPHY.ULMaxNL.SubCarrier24|NBPHY.ULMaxNL.SubCarrier45|NBPHY.ULMaxNL.SubCarrier26|NBPHY.ULMaxNL.SubCarrier46|NBPHY.ULMaxNL.SubCarrier27|NBPHY.ULMaxNL.SubCarrier47|NBPHY.ULMaxNL.SubCarrier28|NBPHY.ULMaxNL.SubCarrier3|NBPHY.ULMaxNL.SubCarrier42|NBPHY.ULMaxNL.SubCarrier29|NBPHY.ULMaxNL.SubCarrier41|NBPHY.ULMaxNL.SubCarrier5|NBPHY.ULMaxNL.SubCarrier44|NBPHY.ULMaxNL.SubCarrier4|NBPHY.ULMaxNL.SubCarrier43|NBPHY.ULMaxNL.SubCarrier20|NBPHY.ULMaxNL.SubCarrier1|NBPHY.ULMaxNL.SubCarrier6|NBPHY.ULMaxNL.SubCarrier0|NBPHY.ULMaxNL.SubCarrier2|NBPHY.ULMaxNL.SubCarrier22|NBPHY.ULMaxNL.SubCarrier21|NBPHY.ULMaxNL.SubCarrier40|NBPHY.ULMeanNL.SubCarrier14|NBPHY.ULMeanNL.SubCarrier7|NBPHY.ULMeanNL.SubCarrier8|NBPHY.ULMeanNL.SubCarrier9|NBPHY.ULMeanNL.SubCarrier39|NBPHY.ULMeanNL.SubCarrier12|NBPHY.ULMeanNL.SubCarrier38|NBPHY.ULMeanNL.SubCarrier15|NBPHY.ULMeanNL.SubCarrier37|NBPHY.ULMeanNL.SubCarrier18|NBPHY.ULMeanNL.SubCarrier36|NBPHY.ULMeanNL.SubCarrier13|NBPHY.ULMeanNL.SubCarrier35|NBPHY.ULMeanNL.SubCarrier16|NBPHY.ULMeanNL.SubCarrier34|NBPHY.ULMeanNL.SubCarrier19|NBPHY.ULMeanNL.SubCarrier31|NBPHY.ULMeanNL.SubCarrier10|NBPHY.ULMeanNL.SubCarrier11|NBPHY.ULMeanNL.SubCarrier23|NBPHY.ULMeanNL.SubCarrier17|NBPHY.ULMeanNL.SubCarrier32|NBPHY.ULMeanNL.SubCarrier33|NBPHY.ULMeanNL.SubCarrier30|NBPHY.ULMeanNL.SubCarrier27|NBPHY.ULMeanNL.SubCarrier46|NBPHY.ULMeanNL.SubCarrier28|NBPHY.ULMeanNL.SubCarrier47|NBPHY.ULMeanNL.SubCarrier24|NBPHY.ULMeanNL.SubCarrier25|NBPHY.ULMeanNL.SubCarrier26|NBPHY.ULMeanNL.SubCarrier45|NBPHY.ULMeanNL.SubCarrier43|NBPHY.ULMeanNL.SubCarrier4|NBPHY.ULMeanNL.SubCarrier44|NBPHY.ULMeanNL.SubCarrier5|NBPHY.ULMeanNL.SubCarrier41|NBPHY.ULMeanNL.SubCarrier29|NBPHY.ULMeanNL.SubCarrier42|NBPHY.ULMeanNL.SubCarrier3|NBPHY.ULMeanNL.SubCarrier40|NBPHY.ULMeanNL.SubCarrier21|NBPHY.ULMeanNL.SubCarrier22|NBPHY.ULMeanNL.SubCarrier2|NBPHY.ULMeanNL.SubCarrier0|NBPHY.ULMeanNL.SubCarrier6|NBPHY.ULMeanNL.SubCarrier1|NBPHY.ULMeanNL.SubCarrier20|NBMAC.NbrSuccInitTbDl|NBMAC.NbrSuccInitTbUl|NBMAC.NbrResErrTbDl|NBMAC.NbrResErrTbUl|NBMAC.NbrInitTbUl.Bpsk|NBMAC.NbrInitTbUl.Qpsk|NBMAC.NbrInitTbDl|NBMAC.NbrInitTbUl|NBRRU.CellUnavailableTime|NBRRU.NpdcchCceUtil|NBRRU.NprachReserveResource|NBRRU.RachPreambleRcvd|NBMAC.NbrTbDl|NBMAC.NbrTbUl|NBMAC.NbrSuccInitTbUl.Bpsk|NBMAC.NbrSuccInitTbUl.Qpsk|NBSRB1bis.OctDl|NBRRU.NpuschUsageResource|NBRRU.NpdschUsageTime|NBRRU.NpdcchUsageTime.UL|NBRRU.NpdcchUsageTime.DL|NBRRU.NpdcchUsageTime|NBRRU.NpdcchCceUtil.1|NBRRU.NpdcchCceUtil.2|NBCONTEXT.AttRelEnb.CauseReset|NBCONTEXT.AttRelEnb.CauseOther|NBCONTEXT.AttRelEnb.Normal|NBCONTEXT.AttRelEnb.CauseUENotOnline|NBCONTEXT.AttRelEnb.CauseReestablish|NBCONTEXT.AttRelEnb.CauseS1LinkFail|NBCONTEXT.AttRelEnb|NBSRB1bis.OctUl|NBPAG.PagDiscarded|NBS1SIG.ConnEstabSucc|NBRRC.AttConnEstab|NBPAG.PagReceived|NBRRC.AttConnEstab.CauseMoData|NBRRC.AttConnEstab.CauseMoExceptionData|NBRRC.AttConnEstab.CauseMoSignalling|NBRRC.AttConnEstab.CauseMtAccess|NBCONTEXT.AttRelEnb.CauseUuFail|NBCONTEXT.AttRelEnb.CauseRedirection|NBCONTEXT.AttRelMme.CauseOther|NBCONTEXT.AttRelMme|NBCONTEXT.AttRelMme.CauseReestablishIntereNB|NBCONTEXT.AttRelMme.CauseRelSuccNbr|NBS1SIG.ConnEstabAtt|NBCONTEXT.NbrLeft|NBRRC.FailConnEstab.CauseMoData|NBRRC.FailConnEstab.CauseMtAccess|NBRRC.FailConnEstab.CauseMoSignalling|NBRRC.FailConnEstab.CauseDelayTolerantAccess|NBRRC.SetupTimeMax|NBRRC.SetupTimeMean|NBRRC.SuccConnEstab|NBRRC.SuccConnEstab.CauseMoExceptionData|NBRRC.AttConnEstab.CauseDelayTolerantAccess|NBRRC.AttConnReestab|NBRRC.AttConnReestab.CauseOther|NBRRC.AttConnReestab.CauseReconfig|NBRRC.ConnMax|NBRRC.ConnMean|NBRRC.FailConnEstab|NBRRC.FailConnEstab.CauseMoExceptionData|NBRRC.SuccConnEstab.CauseDelayTolerantAccess|NBRRC.SuccConnEstab.CauseMoSignalling|NBRRC.SuccConnEstab.CauseMtAccess|NBRRC.SuccConnEstab.CauseMoData|NBRRC.SuccConnReestab
+1101ZTWX3CEN0000000024100001|ZTE-CMBJ-BJ,SubNetwork=201,ManagedElement=241,EnbFunction=241,EutranCellNB=1|"EUtranCellNBIoT"|2017-07-17 08:45:00|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||0|0|0|0|0|0|0|0|0|0|33744|0|0|0|0|0|0.00|202464|11264|0|0|0|0|0|0|0|0|0|0|0|0|0.00|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.0000|0|0|0|0|0|0|0
+1101ZTWX3CEN0000000024000020|ZTE-CMBJ-BJ,SubNetwork=201,ManagedElement=240,EnbFunction=240,EutranCellNB=20|"EUtranCellNBIoT"|2017-07-17 08:45:00|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||0|0|0|0|0|0|0|0|0|0|33756|0|0|0|0|0|0.00|202536|11200|0|0|0|0|0|0|0|0|0|0|0|0|0.00|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.0000|0|0|0|0|0|0|0
diff --git a/ems/boco/data/PM-ENB-EUTRANCELLNB-test.csv.gz b/ems/boco/data/PM-ENB-EUTRANCELLNB-test.csv.gz
deleted file mode 100644
index 8c4a4d0..0000000
--- a/ems/boco/data/PM-ENB-EUTRANCELLNB-test.csv.gz
+++ /dev/null
Binary files differ
diff --git a/ems/boco/pom.xml b/ems/boco/pom.xml
index b194a11..2040f4f 100644
--- a/ems/boco/pom.xml
+++ b/ems/boco/pom.xml
@@ -16,13 +16,16 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <groupId>org.onap.vfc.nfvo.driver.ems.ems</groupId>
+ <parent>
+ <groupId>org.onap.vfc.nfvo.driver.ems.ems</groupId>
+ <artifactId>ems-driver-boco-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>boco-driver</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
- <name>vfc-nfvo-driver-ems-ems-boco</name>
+ <name>org/onap/vfc/nfvo/driver/ems/ems/boco</name>
<properties>
diff --git a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/TaskThreadTest.java b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/TaskThreadTest.java
index 4fd62b2..13d7052 100644
--- a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/TaskThreadTest.java
+++ b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/TaskThreadTest.java
@@ -21,24 +21,29 @@ import java.io.File;
import java.io.IOException;
import java.util.List;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.vfc.nfvo.emsdriver.collector.TaskThread;
+import org.onap.vfc.nfvo.emsdriver.commons.utils.Gzip;
public class TaskThreadTest {
-
- private String gzPath = System.getProperty("user.dir")+"/data/" +"PM-ENB-EUTRANCELLNB-test.csv.gz";
+ private String csvPath = System.getProperty("user.dir")+"/data/" +"PM-ENB-EUTRANCELLNB-test.csv";
+ private String gzPath = System.getProperty("user.dir")+"/data/" +"PM-ENB-EUTRANCELLNB-testa.csv.gz";
private TaskThread taskThread;
private List<File> list = null;
@Before
public void setUp() throws IOException {
taskThread = new TaskThread();
+ Gzip gzip = new Gzip();
+ gzip.compress(csvPath, gzPath);
}
@Test
public void decompressed(){
list = taskThread.decompressed(gzPath);
assertTrue(list.size() > 0);
+ new File(gzPath).delete();
}
@Test
@@ -49,4 +54,10 @@ public class TaskThreadTest {
assertTrue(re);
}
}
+
+ @After
+ public void setDown() throws IOException {
+ new File(gzPath).delete();
+ new File(gzPath.replace(".gz", "")).delete();
+ }
}
diff --git a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/commons/utils/GunzipTest.java b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/commons/utils/GunzipTest.java
index 6a31ab2..aebea0f 100644
--- a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/commons/utils/GunzipTest.java
+++ b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/commons/utils/GunzipTest.java
@@ -26,7 +26,7 @@ import org.junit.Test;
import org.onap.vfc.nfvo.emsdriver.commons.utils.Gunzip;
public class GunzipTest {
-
+ private String csvPath = System.getProperty("user.dir")+"/data/" +"PM-ENB-EUTRANCELLNB-test.csv";
private String gzPath = System.getProperty("user.dir")+"/data/" +"PM-ENB-EUTRANCELLNB-test.csv.gz";
private Gunzip gunzip = null;
private String gunzipfile;
@@ -35,12 +35,13 @@ public class GunzipTest {
@Before
public void setUp() throws IOException {
gunzip = new Gunzip();
-
+ Gzip gzip = new Gzip();
+ gzip.compress(csvPath, gzPath);
}
@Test
public void deCompress() throws IOException{
- gunzipfile = gzPath.replace(".gz", "");
+ gunzipfile = gzPath.replace(".gz", "file");
gunzip.unCompress(gzPath, gunzipfile);
assertTrue(new File(gunzipfile).length() > 0);
@@ -49,6 +50,7 @@ public class GunzipTest {
@After
public void setDown() throws IOException {
new File(gunzipfile).delete();
+ new File(gzPath).delete();
}
}
diff --git a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/commons/utils/Gzip.java b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/commons/utils/Gzip.java
new file mode 100644
index 0000000..9bee758
--- /dev/null
+++ b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/commons/utils/Gzip.java
@@ -0,0 +1,79 @@
+/**
+ * Copyright 2017 CMCC Technologies Co., Ltd
+ *
+ * Licensed 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.onap.vfc.nfvo.emsdriver.commons.utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.zip.GZIPOutputStream;
+
+public class Gzip {
+
+ public void compress(String srcFileName, String toGzFile)
+ throws IOException {
+ FileInputStream fileInput = new FileInputStream(srcFileName);
+ compress(fileInput, toGzFile);
+ fileInput.close();
+
+
+ }
+
+ public void compress(InputStream src, String toGzFile)
+ throws IOException {
+ File theFile = new File(toGzFile);
+ if (!theFile.exists()) {
+ String parentPath = theFile.getParent();
+ if (parentPath != null)
+ new File(parentPath).mkdirs();
+ theFile.createNewFile();
+ }
+ GZIPOutputStream gzOutput = new GZIPOutputStream(new FileOutputStream(theFile, false));
+
+ moveBytes(src, gzOutput, -1, -1, 1024);
+ gzOutput.close();
+ }
+
+ public long moveBytes(InputStream input, OutputStream output, long off, long len, int bufsize)
+ throws IOException {
+ if (off > 0)
+ input.skip(off);
+
+ long totalNum = 0;
+ byte[] buf = new byte[bufsize];
+
+ while (true) {
+ if (len>0 && (len-totalNum)<=0)
+ break;
+
+ else if (len>0 && bufsize>(len-totalNum))
+ bufsize = (int)(len-totalNum);
+
+ int readNum = input.read(buf, 0, bufsize);
+ if (readNum <= 0)
+ break;
+
+ output.write(buf, 0, readNum);
+ totalNum += readNum;
+ }
+ buf = null;
+ return totalNum;
+ }
+
+
+}
diff --git a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/commons/utils/UnZipTest.java b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/commons/utils/UnZipTest.java
index c89a756..74c8050 100644
--- a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/commons/utils/UnZipTest.java
+++ b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/commons/utils/UnZipTest.java
@@ -15,30 +15,41 @@
*/
package org.onap.vfc.nfvo.emsdriver.commons.utils;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.IOException;
+import org.junit.After;
import org.junit.Before;
-import org.onap.vfc.nfvo.emsdriver.commons.utils.UnZip;
+import org.junit.Test;
public class UnZipTest {
-
- private String zipPath = System.getProperty("user.dir")+"/data/" +"PM-ENB-EUTRANCELLNB-test.csv.gz";
+ private String file = "./test.txt";
+ private String zipPath = "./test.zip";
private String toPath = System.getProperty("user.dir")+"/data/";
private UnZip unZip = null;
@Before
public void setUp() throws IOException {
+ new File(file).createNewFile();
+ Zip zip = new Zip(file,zipPath);
+ zip.compress();
unZip = new UnZip(zipPath,toPath);
+
}
-
+ @Test
public void deCompress() throws IOException{
unZip.deCompress();
assertTrue(new File(toPath).listFiles().length > 0);
}
+ @After
+ public void setDown() throws IOException {
+ new File(zipPath).delete();
+ new File(file).delete();
+ new File(toPath+file).delete();
+ }
public static void main(String[] str){
System.out.println(System.getProperty("user.dir"));
diff --git a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/commons/utils/ZipTest.java b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/commons/utils/ZipTest.java
index 5274c7d..4ded482 100644
--- a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/commons/utils/ZipTest.java
+++ b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/commons/utils/ZipTest.java
@@ -41,7 +41,6 @@ public class ZipTest {
zip.compress();
assertTrue(tofile1.endsWith(".zip"));
-
}