package com.icitic.iccard.dp.test;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.sql.Connection;
import java.sql.PreparedStatement;
import javax.naming.InitialContext;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.log4j.Logger;
public class Test {
private static final Logger LOG = Logger.getLogger(PrepareTester.class);
private static final String NAME_DATASOURCE = "artery-datasource";
private InitialContext context;
public static void main(String[] args) {
Test test = new Test();
try {
try {
test.setUp();
// test.runTest();
} catch (Exception e) {
LOG.debug(e.getMessage(), e);
} finally {
BufferedReader reader = new BufferedReader(
new InputStreamReader(System.in));
for (String line; (line = reader.readLine()) != null;) {
if (line.equals("exit")) {
break;
}
}
test.tearDown();
}
} catch (Exception e) {
LOG.debug(e.getMessage(), e);
}
}
private void runTest() throws Exception {
// Map<String, Object> params = new HashMap<String, Object>();
// params.put(Constants.ATTRIB_BATCH_NO, "13");
// params.put(Constants.ATTRIB_FINAL_NAME, "test20110425");
// params.put("debug", false);
// //engine.execute("task1", null, 0, false, params);
// engine.execute("preparing", null, 0, true, params);
}
protected void setUp() throws Exception {
System.setProperty("ARTERY_HOME", "src/test/resources");
// 初始化JNDI
System.setProperty("java.naming.factory.initial",
"org.osjava.sj.memory.MemoryContextFactory");
System.setProperty("org.osjava.sj.jndi.shared", "true");
BasicDataSource datasource = new BasicDataSource();
/*
* datasource.setDriverClassName("com.mysql.jdbc.Driver");
* datasource.setUrl(
* "jdbc:mysql://localhost/artery?useUnicode=true&characterEncoding=utf8&characterResultSet=utf8"
* ); datasource.setUsername("root"); datasource.setPassword(""); /
*/
// datasource.setDriverClassName("oracle.jdbc.driver.OracleDriver");
// datasource.setUrl("jdbc:oracle:thin:@10.14.8.2:1521:ora10g");
// datasource.setUsername("ic_dp");
// datasource.setPassword("password");
datasource.setDriverClassName("oracle.jdbc.driver.OracleDriver");
datasource.setUrl("jdbc:oracle:thin:@10.200.68.13:1522:arterydb");
datasource.setUsername("artery");
datasource.setPassword("password");
// */
context = new InitialContext();
context.bind(NAME_DATASOURCE, datasource);
Connection con = datasource.getConnection();
// String sqlupdate="";
// 模板插入库
// String
// sql="INSERT INTO ARTERY.TEMPLATE(TEMPLATE_ID, APP_ID, TEMPLATE_NAME, TEMPLATE_DESC, TEMP_CONTENT, CREATE_DATE, CREATE_TIME, CREATOR) VALUES(?, ?, ?, ?, ?, ?, ?, ?)";
// PreparedStatement ps= con.prepareStatement(sql);
// ps.setInt(1, 0);
// ps.setString(2, "1");
// ps.setString(3, "中国银行模板");
// ps.setString(4, "模板描述");
// String
// orgData="<pboc>#macro(tlv $tag $value)$dp.tlv($tag, $value)#end#set ($appLabel = \"\")#set ($tag5A = $dp.tlv(\"5a\", $account))#set ($tag5F34 = $dp.tlv(\"5f34\", $pan-serial))#set ($tag5F28 = $dp.tlv(\"5f28\", $country-code))<tag57>#tlv(\"57\", $dp.decryptEncrypt($track2))</tag57><tag5F20>#tlv(\"5f20\", $name)</tag5F20><tag9F0B>#tlv(\"9f0b\", $name-ext)</tag9F0B><tag9F61>#tlv(\"9f61\", $cert-no)</tag9F61><tag9F62>#tlv(\"9f62\", $cert-type)</tag9F62><tag5A>$tag5A</tag5A><tag5F34>$tag5F34</tag5F34><tag5F28>$tag5F28</tag5F28><!-- start --><tag90>#tlv(\"90\", $issuer-pk)</tag90><tag92>#tlv(\"92\", $issuer-pk-rem)</tag92><tag9F32>#tlv(\"9f32\", $issuer-pk-exp)</tag9F32><tag8F>#tlv(\"8F\", $ca-pk-idx)</tag8F><tag9F46_pboc>#tlv(\"9f4601\", $dp.genCertificate($pboc_cert_data))</tag9F46_pboc><tag9F46_ecash>#tlv(\"9f4602\",$dp.genCertificate($ecash_cert_data))</tag9F46_ecash><!-- end --><tag9F47>#tlv(\"9f47\", $dp.getExponent($ic_exponent))</tag9F47><tag9F48>#tlv(\"9f48\",$dp.genCertificate($modulus))</tag9F48><!-- start --><tag93_pboc>#tlv(\"9301\", $dp.genSAD($pboc_static_data))</tag93_pboc><tag93_ecash>#tlv(\"9302\", $dp.genSAD($ecash_static_data))</tag93_ecash><!-- end --><tag9F49>#tlv(\"9f49\", \"9F3704\")</tag9F49><tag5F25>#tlv(\"5f25\", $effect-date)</tag5F25><tag5F24>#tlv(\"5f24\", $expiry-date)</tag5F24><ecash-8E>#tlv(\"8e\", \"00000000000000001F03\")</ecash-8E><ecash-9F0E>#tlv(\"9f0e\", \"0010800000\")</ecash-9F0E><ecash-9F0F>#tlv(\"9f0f\", \"D8683CF800\")</ecash-9F0F><ecash-9F0D>#tlv(\"9f0d\", \"D8603CA800\")</ecash-9F0D><ecash-9F68>#tlv(\"9f68\", \"81400000\")</ecash-9F68><tag8E>#tlv(\"8e\", \"000000000000000002031F00\")</tag8E><tag9F0E>#tlv(\"9f0e\", \"0010980000\")</tag9F0E><tag9F0F>#tlv(\"9f0f\", \"D86804F800\")</tag9F0F><tag9F0D>#tlv(\"9f0d\", \"D86004A800\")</tag9F0D><tag8C>#tlv(\"8c\", \"9F02069F03069F1A0295055F2A029A039C019F37049F21039F4E14\")</tag8C><tag8D>#tlv(\"8d\", \"8A029F02069F03069F1A0295055F2A029A039C019F37049F2103\")</tag8D><tag9F07>#tlv(\"9f07\", \"FF00\")</tag9F07><tag9F08>#tlv(\"9f08\", \"0020\")</tag9F08><tag5F30>#tlv(\"5f30\", \"0201\")</tag5F30><tag9F1F>#tlv(\"9f1f\", $track1)</tag9F1F><tag9F14>#tlv(\"9f14\", $lowerOfflineConsLim)</tag9F14><tag9F23>#tlv(\"9f23\", $upperOfflineConsLim)</tag9F23><tag9F74>#tlv(\"9f74\", $dp.hex(\"ECC001\"))</tag9F74><tag9F79>#tlv(\"9f79\", $ecashBalance)</tag9F79><tag9F51>#tlv(\"9f51\", \"0156\")</tag9F51><tag9F77>#tlv(\"9f77\", $balance-limit)</tag9F77><tag9F78>#tlv(\"9f78\", $amount-limit)</tag9F78><tag9F6B>#tlv(\"9f6b\", $CVM-limit)</tag9F6B><tag9F6D>#tlv(\"9f6d\", $reset-threshold)</tag9F6D><tag9F6C>#tlv(\"9f6c\", \"0000\")</tag9F6C><tag9F5D>#tlv(\"9f5d\", \"01\")</tag9F5D><tag9F56>#tlv(\"9f56\", \"80\")</tag9F56><tag9F4F>#tlv(\"9f4f\", \"9A039F21039F02069F03069F1A025F2A029F4E149C019F3602\")</tag9F4F><tag9F53>#tlv(\"9f53\", $offline-limit)</tag9F53><tag9F54>#tlv(\"9f54\", $offline-min-amt)</tag9F54><tag9F5C>#tlv(\"9f5c\", $offline-max-amt)</tag9F5C><tag9F58>#tlv(\"9f58\", $offline-min-count)</tag9F58><tag9F59>#tlv(\"9f59\", $offline-max-count)</tag9F59><tag9F52>#tlv(\"9f52\", \"C000\")</tag9F52><!-- 这是注释 --><udk>$dp.getDES($udk_ac)</udk><udk-enc>$dp.getDES($udk_enc)</udk-enc><udk-mac>$dp.getDES($udk_mac)</udk-mac><kcv>$dp.getKCV($udk_ac, $udk_enc, $udk_mac)</kcv><crt1>$dp.getCRT($rsa_p)</crt1><crt2>$dp.getCRT($rsa_q)</crt2><crt3>$dp.getCRT($rsa_dmp1)</crt3><crt4>$dp.getCRT($rsa_dmq1)</crt4><crt5>$dp.getCRT($rsa_iqmp)</crt5>#set ($contactA5 = [$dp.tlv(\"50\", $appLabel), $dp.tlv(\"87\", \"01\"), $dp.tlv(\"9f38\", \"9F7A019F02065F2A02\"), $dp.tlv(\"5f2d\", \"7A68\"), $dp.tlv(\"9f11\", \"01\"), $dp.tlv(\"9f12\", \"\"), $dp.tlv(\"bf0c\", $dp.concat([$dp.tlv(\"9f4d\", \"0B0A\")]))])<contact-based>#tlv(\"a5\", $dp.concat($contactA5))</contact-based>#set ($noncontA5 = [$dp.tlv(\"50\", $appLabel), $dp.tlv(\"87\", \"01\"), $dp.tlv(\"9f38\", \"9F66049F02069F37045F2A02\"), $dp.tlv(\"5f2d\", \"7A68\"), $dp.tlv(\"9f11\", \"01\"), $dp.tlv(\"9f12\", \"\")])<non-contact>#tlv(\"a5\", $dp.concat($noncontA5))</non-contact><aip1>#tlv(\"82\", \"7C00\")</aip1><afl1>#tlv(\"94\", \"080102001001040118010200\")</afl1><aip2>#tlv(\"82\", \"7C00\")</aip2><afl2>#tlv(\"94\", \"10010501\")</afl2><tag9F10>#tlv(\"9f10\", \"07800103000000010A01\")</tag9F10></pboc>";
// StringReader reader=new StringReader(orgData);
// ps.setCharacterStream(5, reader, orgData.length());
// ps.setString(6, "");
// ps.setString(7, "");
// ps.setString(8, "");
// ps.execute();
String updatesqll = " UPDATE ARTERY.TEMPLATE SET TEMP_CONTENT=? WHERE TEMPLATE_ID=? ";
PreparedStatement ps = con.prepareStatement(updatesqll);
String orgData = "<pboc>#macro(tlv $tag $value)$dp.tlv($tag, $value)#end#set ($appLabel = \"\")#set ($tag5A = $dp.tlv(\"5a\", $account))#set ($tag5F34 = $dp.tlv(\"5f34\", $pan-serial))#set ($tag5F28 = $dp.tlv(\"5f28\", $country-code))<tag57>#tlv(\"57\", $dp.decryptEncrypt($track2))</tag57><tag5F20>#tlv(\"5f20\", $name)</tag5F20><tag9F0B>#tlv(\"9f0b\", $name-ext)</tag9F0B><tag9F61>#tlv(\"9f61\", $cert-no)</tag9F61><tag9F62>#tlv(\"9f62\", $cert-type)</tag9F62><tag5A>$tag5A</tag5A><tag5F34>$tag5F34</tag5F34><tag5F28>$tag5F28</tag5F28><!-- start --><tag90>#tlv(\"90\", $issuer-pk)</tag90><tag92>#tlv(\"92\", $issuer-pk-rem)</tag92><tag9F32>#tlv(\"9f32\", $issuer-pk-exp)</tag9F32><tag8F>#tlv(\"8F\", $ca-pk-idx)</tag8F><tag9F46_pboc>#tlv(\"9f46\", $dp.genCertificate($pboc_cert_data))</tag9F46_pboc><!-- end --><tag9F47>#tlv(\"9f47\", $dp.getExponent($ic_exponent))</tag9F47><tag9F48>#tlv(\"9f48\",$dp.genCertificate($modulus))</tag9F48><!-- start --><tag93_pboc>#tlv(\"9301\", $dp.genSAD($pboc_static_data))</tag93_pboc><tag93_ecash>#tlv(\"9302\", $dp.genSAD($ecash_static_data))</tag93_ecash><!-- end --><tag9F49>#tlv(\"9f49\", \"9F3704\")</tag9F49><tag5F25>#tlv(\"5f25\", $effect-date)</tag5F25><tag5F24>#tlv(\"5f24\", $expiry-date)</tag5F24><ecash-8E>#tlv(\"8e\", \"00000000000000001F03\")</ecash-8E><ecash-9F0E>#tlv(\"9f0e\", \"0010800000\")</ecash-9F0E><ecash-9F0F>#tlv(\"9f0f\", \"D8683CF800\")</ecash-9F0F><ecash-9F0D>#tlv(\"9f0d\", \"D8603CA800\")</ecash-9F0D><ecash-9F68>#tlv(\"9f68\", \"81400000\")</ecash-9F68><tag8E>#tlv(\"8e\", \"000000000000000002031F00\")</tag8E><tag9F0E>#tlv(\"9f0e\", \"0010980000\")</tag9F0E><tag9F0F>#tlv(\"9f0f\", \"D86804F800\")</tag9F0F><tag9F0D>#tlv(\"9f0d\", \"D86004A800\")</tag9F0D><tag8C>#tlv(\"8c\", \"9F02069F03069F1A0295055F2A029A039C019F37049F21039F4E14\")</tag8C><tag8D>#tlv(\"8d\", \"8A029F02069F03069F1A0295055F2A029A039C019F37049F2103\")</tag8D><tag9F07>#tlv(\"9f07\", \"FF00\")</tag9F07><tag9F08>#tlv(\"9f08\", \"0020\")</tag9F08><tag5F30>#tlv(\"5f30\", \"0201\")</tag5F30><tag9F1F>#tlv(\"9f1f\", $track1)</tag9F1F><tag9F14>#tlv(\"9f14\", $lowerOfflineConsLim)</tag9F14><tag9F23>#tlv(\"9f23\", $upperOfflineConsLim)</tag9F23><tag9F74>#tlv(\"9f74\", $dp.hex(\"ECC001\"))</tag9F74><tag9F79>#tlv(\"9f79\", $ecashBalance)</tag9F79><tag9F51>#tlv(\"9f51\", \"0156\")</tag9F51><tag9F77>#tlv(\"9f77\", $balance-limit)</tag9F77><tag9F78>#tlv(\"9f78\", $amount-limit)</tag9F78><tag9F6B>#tlv(\"9f6b\", $CVM-limit)</tag9F6B><tag9F6D>#tlv(\"9f6d\", $reset-threshold)</tag9F6D><tag9F6C>#tlv(\"9f6c\", \"0000\")</tag9F6C><tag9F5D>#tlv(\"9f5d\", \"01\")</tag9F5D><tag9F56>#tlv(\"9f56\", \"80\")</tag9F56><tag9F4F>#tlv(\"9f4f\", \"9A039F21039F02069F03069F1A025F2A029F4E149C019F3602\")</tag9F4F><tag9F53>#tlv(\"9f53\", $offline-limit)</tag9F53><tag9F54>#tlv(\"9f54\", $offline-min-amt)</tag9F54><tag9F5C>#tlv(\"9f5c\", $offline-max-amt)</tag9F5C><tag9F58>#tlv(\"9f58\", $offline-min-count)</tag9F58><tag9F59>#tlv(\"9f59\", $offline-max-count)</tag9F59><tag9F52>#tlv(\"9f52\", \"C000\")</tag9F52><!-- 这是注释 --><udk>$dp.getDES($udk_ac)</udk><udk-enc>$dp.getDES($udk_enc)</udk-enc><udk-mac>$dp.getDES($udk_mac)</udk-mac><kcv>$dp.getKCV($udk_ac, $udk_enc, $udk_mac)</kcv><crt1>$dp.getCRT($rsa_p)</crt1><crt2>$dp.getCRT($rsa_q)</crt2><crt3>$dp.getCRT($rsa_dmp1)</crt3><crt4>$dp.getCRT($rsa_dmq1)</crt4><crt5>$dp.getCRT($rsa_iqmp)</crt5>#set ($contactA5 = [$dp.tlv(\"50\", $appLabel), $dp.tlv(\"87\", \"01\"), $dp.tlv(\"9f38\", \"9F7A019F02065F2A02\"), $dp.tlv(\"5f2d\", \"7A68\"), $dp.tlv(\"9f11\", \"01\"), $dp.tlv(\"9f12\", \"\"), $dp.tlv(\"bf0c\", $dp.concat([$dp.tlv(\"9f4d\", \"0B0A\")]))])<contact-based>#tlv(\"a5\", $dp.concat($contactA5))</contact-based>#set ($noncontA5 = [$dp.tlv(\"50\", $appLabel), $dp.tlv(\"87\", \"01\"), $dp.tlv(\"9f38\", \"9F66049F02069F37045F2A02\"), $dp.tlv(\"5f2d\", \"7A68\"), $dp.tlv(\"9f11\", \"01\"), $dp.tlv(\"9f12\", \"\")])<non-contact>#tlv(\"a5\", $dp.concat($noncontA5))</non-contact><aip1>#tlv(\"82\", \"7C00\")</aip1><afl1>#tlv(\"94\", \"080102001001040118010200\")</afl1><aip2>#tlv(\"82\", \"7C00\")</aip2><afl2>#tlv(\"94\", \"10010501\")</afl2><tag9F10>#tlv(\"9f10\", \"07800103000000010A01\")</tag9F10></pboc>";
StringReader reader = new StringReader(orgData);
ps.setCharacterStream(1, reader, orgData.length());
ps.setInt(2, 1);
ps.execute();
}
protected void tearDown() throws Exception {
context.unbind(NAME_DATASOURCE);
}
}