Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yxbdali committed Jun 24, 2015
1 parent 82dc049 commit 2b0fc80
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 36 deletions.
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@
<target>1.8</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<configuration>
<encoding>utf-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
15 changes: 15 additions & 0 deletions src/main/java/com/autonavi/data/test/DBDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,22 @@
*
*/
public class DBDriver implements AutoCloseable {
/**
* Default db connection string
*
*/
private String defaultDbConnString = "jdbc:oracle:thin:@10.17.129.217:1521:orcl";

/**
* Default db user
*
*/
private String defaultDbUser = "USER_PTMP_V108";

/**
* Default password
*
*/
private String defaultDbPassword = "testgdpoi";

private Connection dbConnection;
Expand Down Expand Up @@ -216,6 +230,7 @@ public void close() throws SQLException {
}
}

@SuppressWarnings("unused")
private void iniDbConnInfoFromConfig(){
String dbConfigFile = System.getProperty("user.dir") + File.separator + "DbConfig.xml";
File dbConfigFileObj = new File(dbConfigFile);
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/com/autonavi/data/test/DbDataQueryBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@
*
*/
public class DbDataQueryBase implements Serializable {
public DbDataQueryBase(){

/**
* Default Constructor
*
*/
public DbDataQueryBase(){
}

/**
* Constructor with table name and sql query clause
*
* @param tableName
* @param clause
*/
public DbDataQueryBase(String tableName, String clause) {
// TODO Auto-generated constructor stub
this.tableName = tableName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ public DbTableQueryConfigItem(){
super();
}

/**
* Constructor with table name and sql query clause
*
* @param tableName
* @param clause
*/
public DbTableQueryConfigItem(String tableName, String clause) {
// TODO Auto-generated constructor stub
super(tableName, clause);
Expand Down
49 changes: 49 additions & 0 deletions src/test/java/com/autonavi/data/test/unit/MyNGTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.autonavi.data.test.unit;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.logging.log4j.LogManager;
import org.testng.annotations.Test;
import com.autonavi.data.test.POIDataFlowPackage;
import com.autonavi.data.test.POIDataItem;
import com.autonavi.data.test.POIDataItemBase;
/**
*
* @author xiangbin.yang
*
*/
public class MyNGTest {
static org.apache.logging.log4j.Logger log = LogManager.getLogger();


@Test
public void testSpecialAchrieveData() throws ClassNotFoundException, IOException {
POIDataFlowPackage package1 = POIDataFlowPackage
.deserialize("E:/NetBeans_Projects/AutonaviDataFlowSnapshotUI/DataFlowPackages/ºóÆÚÉú³É20150623-03.dat");
ArrayList<POIDataItemBase> dbDataList = package1.getTaskPackageList().get(0).getDbDataList();
Map<String, Integer> tableDataCountMap = new HashMap<String, Integer>();
for (POIDataItemBase item : dbDataList) {
String dbTableName = item.getTableName();
if (!tableDataCountMap.containsKey(dbTableName)) {
tableDataCountMap.put(dbTableName, 1);
} else {
int _count = tableDataCountMap.get(dbTableName);
tableDataCountMap.put(dbTableName, ++_count);
}
}
log.info(String.format("Total data count: %d", dbDataList.size()));

Set<String> keySet = tableDataCountMap.keySet();
for (String key : keySet) {
log.info(String.format("Table: %s, DataCount: %d", key, tableDataCountMap.get(key)));
}
List<POIDataItem> poiDataList = package1.getTaskPackageList().get(0).getPOIDataList();
log.info(String.format("Table: %s, DataCount %d", "MDB_POI_Edit", poiDataList.size()));
}

}
88 changes: 55 additions & 33 deletions src/test/java/com/autonavi/data/test/unit/UnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

import static org.junit.Assert.*;

import java.awt.List;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -30,6 +30,7 @@
*/
public class UnitTest {
static Logger log = LogManager.getLogger(UnitTest.class);

/**
* @throws java.lang.Exception
*/
Expand Down Expand Up @@ -58,93 +59,102 @@ public void setUp() throws Exception {
public void tearDown() throws Exception {
}


@Test
public void testDataAchievementCatch() throws IOException, ClassNotFoundException {
POIDataFlowPackage package1 = POIDataFlowPackage.deserialize("E:/NetBeans_Projects/AutonaviDataFlowSnapshotUI/DataFlowPackages/成果表测试1.dat");
POIDataFlowPackage package2 = POIDataFlowPackage.deserialize("E:/NetBeans_Projects/AutonaviDataFlowSnapshotUI/DataFlowPackages/成果表测试2.dat");
POIDataFlowPackage package1 = POIDataFlowPackage
.deserialize("E:/NetBeans_Projects/AutonaviDataFlowSnapshotUI/DataFlowPackages/成果表测试1.dat");
POIDataFlowPackage package2 = POIDataFlowPackage
.deserialize("E:/NetBeans_Projects/AutonaviDataFlowSnapshotUI/DataFlowPackages/成果表测试2.dat");
ArrayList<POIDataItemBase> dbDataList1 = package1.getTaskPackageList().get(0).getDbDataList();
ArrayList<POIDataItemBase> achieveDataList1 = new ArrayList<>();
for (POIDataItemBase dataItem : dbDataList1) {
if (dataItem.getTableName().equalsIgnoreCase("mdb_poi") || dataItem.getTableName().equalsIgnoreCase("mdb_poi_chargepile")){
if (dataItem.getTableName().equalsIgnoreCase("mdb_poi")
|| dataItem.getTableName().equalsIgnoreCase("mdb_poi_chargepile")) {
achieveDataList1.add(dataItem);
}
}

ArrayList<POIDataItemBase> dbDataList2 = package2.getTaskPackageList().get(0).getDbDataList();
ArrayList<POIDataItemBase> achieveDataList2 = new ArrayList<>();
for(POIDataItemBase dataItem : dbDataList2){
if (dataItem.getTableName().equalsIgnoreCase("mdb_poi") || dataItem.getTableName().equalsIgnoreCase("mdb_poi_chargepile")){
for (POIDataItemBase dataItem : dbDataList2) {
if (dataItem.getTableName().equalsIgnoreCase("mdb_poi")
|| dataItem.getTableName().equalsIgnoreCase("mdb_poi_chargepile")) {
achieveDataList2.add(dataItem);
}
}

log.info(String.format("package1 contains %d items", achieveDataList1.size()));
log.info(String.format("package2 contains %d items", achieveDataList2.size()));
//assertEquals(achieveDataList1.size(), achieveDataList2.size());
// assertEquals(achieveDataList1.size(), achieveDataList2.size());
}

@Test
public void testDataAchieveCatch() throws FileNotFoundException, IOException, SQLException{
public void testDataAchieveCatch() throws FileNotFoundException, IOException, SQLException {
POIDataFlowPackage poiDataFlowPackage = new POIDataFlowPackage("Test1");
DbDataFlowQueryConfigItem dbDataFlowQueryConfigItem = DbDataFlowQueryConfigItem.xstreamDeserialize("E:/NetBeans_Projects/AutonaviDataFlowSnapshotUI/DataQueries/POI.xml");
DbDataFlowQueryConfigItem dbDataFlowQueryConfigItem = DbDataFlowQueryConfigItem
.xstreamDeserialize("E:/NetBeans_Projects/AutonaviDataFlowSnapshotUI/DataQueries/POI.xml");
DbTaskQueryConfigItem queryConfigItem = dbDataFlowQueryConfigItem.getTaskDataQueryConfigList().get(0);
DbQueryHelper dbQueryHelper = new DbQueryHelper(queryConfigItem, "CA96F0EBB6084AC8962DA21C084AA7BB");
POITaskPackage poiTaskPackage = dbQueryHelper.query();
poiDataFlowPackage.Add(poiTaskPackage);

ArrayList<POIDataItemBase> dbDataList = poiTaskPackage.getDbDataList();
ArrayList<POIDataItemBase> achieveDataList = new ArrayList<>();

for(POIDataItemBase dataItem : dbDataList){
if (dataItem.getTableName().equalsIgnoreCase("mdb_poi") || dataItem.getTableName().equalsIgnoreCase("mdb_poi_chargepile")){
for (POIDataItemBase dataItem : dbDataList) {
if (dataItem.getTableName().equalsIgnoreCase("mdb_poi")
|| dataItem.getTableName().equalsIgnoreCase("mdb_poi_chargepile")) {
achieveDataList.add(dataItem);
}
}
//assertEquals(0, achieveDataList.size());

// assertEquals(0, achieveDataList.size());
}

@Test
public void testCheckMarkDataSave() throws ClassNotFoundException, IOException {
POIDataFlowPackage package1 = POIDataFlowPackage.deserialize("D:/JavaTools/MyTools/DataFlowSnaphsot12.1/DataFlowPackages/本部.dat");
POIDataFlowPackage package1 = POIDataFlowPackage
.deserialize("D:/JavaTools/MyTools/DataFlowSnaphsot12.1/DataFlowPackages/本部.dat");
ArrayList<POIDataItemBase> dbDataList = package1.getTaskPackageList().get(10).getDbDataList();
for (POIDataItemBase item : dbDataList) {
String dbTableName = item.getTableName();
if (dbTableName.equalsIgnoreCase("mdb_poi_chargepile")){
//log.info(item.getDataMap().get("TAG_ATTR_ID").toString());
if (dbTableName.equalsIgnoreCase("mdb_poi_chargepile")) {
// log.info(item.getDataMap().get("TAG_ATTR_ID").toString());
log.info(item.getDataMap().get("CGUID"));
}
}
}

@Test
public void testSpecial() throws ClassNotFoundException, IOException {
POIDataFlowPackage package1 = POIDataFlowPackage.deserialize("E:/NetBeans_Projects/AutonaviDataFlowSnapshotUI/DataFlowPackages/专项测试包4.dat");
POIDataFlowPackage package1 = POIDataFlowPackage
.deserialize("E:/NetBeans_Projects/AutonaviDataFlowSnapshotUI/DataFlowPackages/专项测试包4.dat");
ArrayList<POIDataItemBase> dbDataList = package1.getTaskPackageList().get(0).getDbDataList();
ArrayList<POIDataItemBase> matArrayList = new ArrayList<>();
for (POIDataItemBase item : dbDataList) {
String dbTableName = item.getTableName();
if (dbTableName.equalsIgnoreCase("ref_post_third_mat")){
if (dbTableName.equalsIgnoreCase("ref_post_third_mat")) {
log.info(dbTableName + ":" + item.getDataMap().get("MATERIAL_ID").toString());
matArrayList.add(item);
}
}
//log.info("ref_post_third_mat: " + matArrayList.size());
// log.info("ref_post_third_mat: " + matArrayList.size());

ArrayList<POIDataItemBase> simiArrayList = new ArrayList<>();
for (POIDataItemBase item : dbDataList) {
String dbTableName = item.getTableName();
if (dbTableName.equalsIgnoreCase("ref_rel_post_third_simi")){
if (dbTableName.equalsIgnoreCase("ref_rel_post_third_simi")) {
log.info(dbTableName + ":" + item.getDataMap().get("MATERIAL_ID").toString());
simiArrayList.add(item);
}
}
log.info("ref_rel_post_third_simi: " + simiArrayList.size());

ArrayList<POIDataItemBase> invlArrayList = new ArrayList<>();
for (POIDataItemBase item : dbDataList) {
String dbTableName = item.getTableName();
if (dbTableName.equalsIgnoreCase("ref_rel_post_third_invl")){
if (dbTableName.equalsIgnoreCase("ref_rel_post_third_invl")) {
log.info(dbTableName + ":" + item.getDataMap().get("MATERIAL_ID").toString());
invlArrayList.add(item);
}
Expand All @@ -153,17 +163,29 @@ public void testSpecial() throws ClassNotFoundException, IOException {
}

@Test
public void testPostLine() throws ClassNotFoundException, IOException{
POIDataFlowPackage package1 = POIDataFlowPackage.deserialize("E:/NetBeans_Projects/AutonaviDataFlowSnapshotUI/DataFlowPackages/后期1.dat");
public void testPostLine() throws ClassNotFoundException, IOException {
System.out.println("*****************");
log.info("********************");
POIDataFlowPackage package1 = POIDataFlowPackage
.deserialize("E:/NetBeans_Projects/AutonaviDataFlowSnapshotUI/DataFlowPackages/专项成果表.dat");
ArrayList<POIDataItemBase> dbDataList = package1.getTaskPackageList().get(0).getDbDataList();
List<String> tableNameList = new ArrayList<>();
int count = 0;
for (POIDataItemBase item : dbDataList) {
String dbTableName = item.getTableName();
if (dbTableName.equalsIgnoreCase("REF_POST_TASKLIST_MAT")){
log.info(dbTableName + ":" + item.getDataMap().get("MATERIAL_ID").toString());
System.out.println(dbTableName);
if (!tableNameList.contains(dbTableName)) {
tableNameList.add(dbTableName);
}
if (dbTableName.equalsIgnoreCase("MDB_POI")) {
log.info(dbTableName + ":" + item.getDataMap().get("GUID").toString());
count++;
}
}
log.info(String.format("Total data count: %d", count));

for (String tableName : tableNameList) {
log.info(String.format("TableName: %s", tableName));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ com\autonavi\data\test\POITaskPackage.class
com\autonavi\data\test\InnerTaskDataItem.class
com\autonavi\data\test\DataFlowItem.class
com\autonavi\data\test\RollbackHelper.class
com\autonavi\data\test\unit\NGTest.class
com\autonavi\data\test\DbDataQueryBase.class
com\autonavi\data\test\DbQueryHelper.class
com\autonavi\data\test\POIDataFlowPackage.class
Expand Down

0 comments on commit 2b0fc80

Please sign in to comment.