trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lium...@apache.org
Subject [37/38] incubator-trafodion git commit: store the jdbc connection info in the properties
Date Thu, 08 Dec 2016 00:46:04 GMT
store the jdbc connection info in the properties


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/9ee378b6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/9ee378b6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/9ee378b6

Branch: refs/heads/master
Commit: 9ee378b621de0bbb32bf2bc3987209a478d46b4d
Parents: 3cea666
Author: AlexPeng19 <alex_peng1986@hotmail.com>
Authored: Mon Dec 5 16:15:42 2016 +0800
Committer: AlexPeng19 <alex_peng1986@hotmail.com>
Committed: Mon Dec 5 16:15:42 2016 +0800

----------------------------------------------------------------------
 .../trafci/src/main/resources/trafci.properties |  5 ++
 .../org/trafodion/ci/UserInterfaceTest.java     | 90 +++++++++++++++++---
 2 files changed, 84 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9ee378b6/core/conn/trafci/src/main/resources/trafci.properties
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/main/resources/trafci.properties b/core/conn/trafci/src/main/resources/trafci.properties
new file mode 100644
index 0000000..870a149
--- /dev/null
+++ b/core/conn/trafci/src/main/resources/trafci.properties
@@ -0,0 +1,5 @@
+db.host=-h 10.10.10.8:23400 
+db.user= -u trafodion 
+db.pwd= -p traf123 
+db.query= -q values(1)
+output.file.name=output.txt
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9ee378b6/core/conn/trafci/test/main/java/org/trafodion/ci/UserInterfaceTest.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/test/main/java/org/trafodion/ci/UserInterfaceTest.java b/core/conn/trafci/test/main/java/org/trafodion/ci/UserInterfaceTest.java
index 4020e12..9b63313 100644
--- a/core/conn/trafci/test/main/java/org/trafodion/ci/UserInterfaceTest.java
+++ b/core/conn/trafci/test/main/java/org/trafodion/ci/UserInterfaceTest.java
@@ -20,29 +20,97 @@
 // @@@ END COPYRIGHT @@@
 package org.trafodion.ci;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
 
 import org.junit.Test;
 
 public class UserInterfaceTest {
 
 	@Test
-	public void test() {
-		MySecurityManager secManager = new MySecurityManager();
-		System.setSecurityManager(secManager);
+	public void testUserInterfaceMain() throws FileNotFoundException {
+		// MySecurityManager secManager = new MySecurityManager();
+		/*System.setSecurityManager(secManager);*/
 		try {
-			String[] params = "-h 10.10.12.99:23400 -u trafodion -p traf123 -q values(1);".split("\\s+");
-			UserInterface.main(params);
+			FileInputStream fs = new FileInputStream("src/main/resources/trafci.properties");
+			Properties prop = new Properties();
+			try {
+				prop.load(fs);
+				String host = prop.getProperty("db.host");
+				String user = prop.getProperty("db.user");
+				String pwd = prop.getProperty("db.pwd");
+				String query = prop.getProperty("db.query");
+				assertNotNull(prop);
+				assertNotNull(fs);
+				System.out.println(host + user + pwd);
+				String[] params = (host + user + pwd + query).split("\\s+");
+				System.out.println((host + user + pwd + query).split("\\s+"));
+				UserInterface.main(params);
+
+			} catch (IOException e1) {
+				// TODO Auto-generated catch block
+				e1.printStackTrace();
+			}
 		} catch (SecurityException e) {
 			assertTrue(true);
 		}
 	}
 
-}
+	@Test
+	public void testWithRuntime() {
+		try {
+			FileInputStream fs = new FileInputStream("src/main/resources/trafci.properties");
+			Properties prop = new Properties();
+			prop.load(fs);
+			String host = prop.getProperty("db.host");
+			String user = prop.getProperty("db.user");
+			String pwd = prop.getProperty("db.pwd");
+			String query = prop.getProperty("db.query");
+
+			Process p = Runtime.getRuntime().exec("trafci -h " + host + " -u " + user + " -p " + pwd
+ " -q " + query);
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
 
-class MySecurityManager extends SecurityManager {
-	@Override
-	public void checkExit(int status) {
-		throw new SecurityException();
 	}
+
+	@Test
+	public void testWithNewProcess() throws FileNotFoundException {
+		FileInputStream fs;
+		ProcessBuilder pb = null;
+		try {
+			fs = new FileInputStream("src/main/resources/trafci.properties");
+
+			Properties prop = new Properties();
+			prop.load(fs);
+			String host = prop.getProperty("db.host");
+			String user = prop.getProperty("db.user");
+			String pwd = prop.getProperty("db.pwd");
+			String query = prop.getProperty("db.query");
+			String output=prop.getProperty("output.file.name");
+
+			pb = new ProcessBuilder("trafci", "-h", host, "-u", user, "-p", pwd, "-q", query);
+			pb.redirectErrorStream(true);
+			File f = new File(output);
+			pb.redirectOutput(f);
+			Process p = pb.start();
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
 }
+/*
+ * class MySecurityManager extends SecurityManager {
+ * 
+ * @Override public void checkExit(int status) { throw new SecurityException();
+ * } }
+ */
\ No newline at end of file


Mime
View raw message