geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xiam...@apache.org
Subject svn commit: r987097 - in /geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test: ./ src/main/java/org/apache/geronimo/sample/servlet/ src/main/webapp/
Date Thu, 19 Aug 2010 09:17:52 GMT
Author: xiaming
Date: Thu Aug 19 09:17:52 2010
New Revision: 987097

URL: http://svn.apache.org/viewvc?rev=987097&view=rev
Log:
GERONIMO-5523 patch to diff transactional datasource from non-transactional one, provided
by LiWenQin

Modified:
    geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/pom.xml
    geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/java/org/apache/geronimo/sample/servlet/BJAcc.java
    geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/java/org/apache/geronimo/sample/servlet/BaseServlet.java
    geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/java/org/apache/geronimo/sample/servlet/DoTransfer.java
    geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/java/org/apache/geronimo/sample/servlet/SHAcc.java
    geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/webapp/display.jsp

Modified: geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/pom.xml?rev=987097&r1=987096&r2=987097&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/pom.xml (original)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/pom.xml Thu Aug 19 09:17:52
2010
@@ -53,8 +53,20 @@
             <scope>provided</scope>
         </dependency>		
     </dependencies> 
-
-    <profiles>
+	
+	<build>
+		<plugins>
+			<plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-war-plugin</artifactId>
+                    <configuration>
+                        <archiveClasses>false</archiveClasses>
+                    </configuration>
+                </plugin>
+			</plugins>
+	</build>
+	
+	<profiles>
     <profile>
         <id>it</id>
         <activation>
@@ -63,11 +75,12 @@
             </property>
         </activation>
     <build>        
-        <plugins>
+        <plugins>   
             <plugin>
-                 <groupId>org.codehaus.mojo</groupId>
-                 <artifactId>selenium-maven-plugin</artifactId>
-            </plugin>            		
+				<groupId>org.codehaus.mojo</groupId>
+				<artifactId>selenium-maven-plugin</artifactId>
+		    </plugin>	
+		
 		    <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-failsafe-plugin</artifactId>

Modified: geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/java/org/apache/geronimo/sample/servlet/BJAcc.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/java/org/apache/geronimo/sample/servlet/BJAcc.java?rev=987097&r1=987096&r2=987097&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/java/org/apache/geronimo/sample/servlet/BJAcc.java
(original)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/java/org/apache/geronimo/sample/servlet/BJAcc.java
Thu Aug 19 09:17:52 2010
@@ -22,28 +22,57 @@ import javax.annotation.sql.DataSourceDe
 import javax.annotation.sql.DataSourceDefinitions;
 import javax.sql.DataSource;
 
-	@DataSourceDefinition(name="java:app/BJAcc",
+/*   @DataSourceDefinition(name="java:app/BJAcc",
    className="org.apache.derby.jdbc.ClientXADataSource",
    url="jdbc:derby://localhost:1527/BJAcc",
    user="system",
+   password="manager",
    databaseName="BJAcc",
    transactional=true,
    maxPoolSize=10,
    properties = {"createDatabase = create"})
+*/
+@DataSourceDefinitions({
+	  @DataSourceDefinition(name = "java:app/BJAccNonTx",
+	    className="org.apache.derby.jdbc.ClientDataSource",
+	    portNumber = 1527,
+	    serverName = "localhost",
+            url="jdbc:derby://localhost:1527/BJAcc",
+	    databaseName="BJAcc",
+	    user="system",
+            password="manager",
+            transactional=false,
+	    properties = {"createDatabase=create"}),
+
+
+	  @DataSourceDefinition(name = "java:app/BJAccTx",
+	    className="org.apache.derby.jdbc.ClientXADataSource",
+	    portNumber = 1527,
+	    serverName = "localhost",
+            url="jdbc:derby://localhost:1527/BJAcc",
+	    databaseName="BJAcc",
+	    user="system",
+            password="manager",
+            transactional= true,
+	    properties = {"createDatabase=create"})
+	})
 
 public class BJAcc extends BaseServlet {
 
-    @Resource(lookup="java:app/BJAcc")
-    DataSource dataSource;
+    @Resource(lookup="java:app/BJAccNonTx")
+    DataSource dataSourceNonTx;
+
+    @Resource(lookup="java:app/BJAccTx")
+    DataSource dataSourcenTx;
 
     @Override
-    DataSource getDataSourceA() {
-        return dataSource;
+    DataSource getNonTxDataSourceA() {
+        return dataSourceNonTx;
     }
 
     @Override
-    DataSource getDataSourceB() {
-        return dataSource;
+    DataSource getTxDataSourceB() {
+        return dataSourcenTx;
     }
-      
+
 }

Modified: geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/java/org/apache/geronimo/sample/servlet/BaseServlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/java/org/apache/geronimo/sample/servlet/BaseServlet.java?rev=987097&r1=987096&r2=987097&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/java/org/apache/geronimo/sample/servlet/BaseServlet.java
(original)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/java/org/apache/geronimo/sample/servlet/BaseServlet.java
Thu Aug 19 09:17:52 2010
@@ -37,14 +37,14 @@ import javax.sql.DataSource;
 
 public abstract class BaseServlet extends HttpServlet {
 
-    abstract DataSource getDataSourceA();
-    
-    abstract DataSource getDataSourceB();
-      
+    abstract DataSource getNonTxDataSourceA();
+
+    abstract DataSource getTxDataSourceB();
+
     String getTitle() {
         return getClass().getName();
     }
-    
+
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
         doPost(request,response);
     }
@@ -61,15 +61,15 @@ public abstract class BaseServlet extend
         } catch (SQLException e) {
             throw new ServletException("Error creating database", e);
         }
-        
+
         List<Account> Accounts;
-        
+
         try {
             Accounts = getAccounts();
         } catch (SQLException e) {
             throw new ServletException("Error accessing database", e);
         }
-        
+
         for (Account c : Accounts) {
             out.println(c.savings + "<br>");
         }
@@ -78,24 +78,23 @@ public abstract class BaseServlet extend
         out.println("</body></html>");
 
     }
-	
+
     public void init(ServletConfig config) {
         //System.out.println("Initializing servlet");
     }
-	    
+
     public void initDB() throws SQLException {
-        Connection con = getDataSourceA().getConnection();
+        Connection con = getNonTxDataSourceA().getConnection();
         Statement stmt = con.createStatement();
-		
+
         try {
             stmt.executeUpdate("DROP TABLE ACCOUNTS");
         } catch (SQLException e) {
             // ignore
         }
-        
+
         try {
         	stmt.executeUpdate("CREATE TABLE ACCOUNTS (ID INTEGER GENERATED ALWAYS AS IDENTITY
PRIMARY KEY, SAVINGS INTEGER)");
-			//System.out.println(this.getTitle()+"says:After create table!");
         } finally {
             stmt.close();
             con.close();
@@ -108,7 +107,7 @@ public abstract class BaseServlet extend
 
     public List<Account> getAccounts() throws SQLException {
         List<Account> Accounts = new ArrayList<Account>();
-        Connection con = getDataSourceB().getConnection();
+        Connection con = getTxDataSourceB().getConnection();
         Statement stmt = con.createStatement();
         try {
             ResultSet rs = stmt.executeQuery(
@@ -128,7 +127,7 @@ public abstract class BaseServlet extend
     }
 
     public void addAccount(long sav) throws SQLException {
-        Connection con = getDataSourceA().getConnection();
+        Connection con = getTxDataSourceB().getConnection();
         PreparedStatement pstmt = con.prepareStatement(
             "INSERT INTO ACCOUNTS (SAVINGS) VALUES (?)");
         try {
@@ -139,8 +138,8 @@ public abstract class BaseServlet extend
             con.close();
         }
     }
-    
-    
+
+
     private static class Account {
         long id;
         long savings;

Modified: geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/java/org/apache/geronimo/sample/servlet/DoTransfer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/java/org/apache/geronimo/sample/servlet/DoTransfer.java?rev=987097&r1=987096&r2=987097&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/java/org/apache/geronimo/sample/servlet/DoTransfer.java
(original)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/java/org/apache/geronimo/sample/servlet/DoTransfer.java
Thu Aug 19 09:17:52 2010
@@ -79,7 +79,7 @@ public class DoTransfer extends HttpServ
 			//System.out.println("tx begin!");
 
 			// First, add to SH
-			ds = (javax.sql.DataSource) initContext.lookup("java:app/SHAcc");
+			ds = (javax.sql.DataSource) initContext.lookup("java:app/SHAccTx");
             System.out.println("in DoTransfer, get java:app/SHAcc sucess!");
 			//conn_SH = ds_SH.getConnection();
 			conn_SH = ds.getConnection();
@@ -93,7 +93,7 @@ public class DoTransfer extends HttpServ
             {throw new Exception("fail shoud happen!");}
 
 			// Second, del in BJ
-			ds = (javax.sql.DataSource) initContext.lookup("java:app/BJAcc");
+			ds = (javax.sql.DataSource) initContext.lookup("java:app/BJAccTx");
             //System.out.println("in DoTransfer, get java:app/BJAcc sucess!");
 			//conn_BJ = ds_BJ.getConnection();
 			conn_BJ = ds.getConnection();

Modified: geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/java/org/apache/geronimo/sample/servlet/SHAcc.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/java/org/apache/geronimo/sample/servlet/SHAcc.java?rev=987097&r1=987096&r2=987097&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/java/org/apache/geronimo/sample/servlet/SHAcc.java
(original)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/java/org/apache/geronimo/sample/servlet/SHAcc.java
Thu Aug 19 09:17:52 2010
@@ -22,28 +22,47 @@ import javax.annotation.sql.DataSourceDe
 import javax.annotation.sql.DataSourceDefinitions;
 import javax.sql.DataSource;
 
-@DataSourceDefinition(name="java:app/SHAcc",
-   className="org.apache.derby.jdbc.ClientXADataSource",
-   url="jdbc:derby://localhost:1527/SHAcc",
-   user="system",
-   databaseName="SHAcc",
-   transactional=true,
-   maxPoolSize=10,
-   properties = {"createDatabase = create"})
+@DataSourceDefinitions({
+	  @DataSourceDefinition(name = "java:app/SHAccNonTx",
+	    className="org.apache.derby.jdbc.ClientDataSource",
+	    portNumber = 1527,
+	    serverName = "localhost",
+            url="jdbc:derby://localhost:1527/SHAcc",
+	    databaseName="SHAcc",
+	    user="system",
+            password="manager",
+            transactional=false,
+	    properties = {"createDatabase=create"}),
+
+
+	  @DataSourceDefinition(name = "java:app/SHAccTx",
+	    className="org.apache.derby.jdbc.ClientXADataSource",
+	    portNumber = 1527,
+	    serverName = "localhost",
+            url="jdbc:derby://localhost:1527/SHAcc",
+	    databaseName="SHAcc",
+	    user="system",
+            password="manager",
+            transactional= true,
+	    properties = {"createDatabase=create"})
+	})
 
 public class SHAcc extends BaseServlet {
 
-    @Resource(lookup="java:app/SHAcc")
-    DataSource dataSource;
+    @Resource(lookup="java:app/SHAccNonTx")
+    DataSource dataSourceNonTx;
+
+    @Resource(lookup="java:app/SHAccTx")
+    DataSource dataSourcenTx;
 
     @Override
-    DataSource getDataSourceA() {
-        return dataSource;
+    DataSource getNonTxDataSourceA() {
+        return dataSourceNonTx;
     }
 
     @Override
-    DataSource getDataSourceB() {
-        return dataSource;
+    DataSource getTxDataSourceB() {
+        return dataSourcenTx;
     }
-      
+
 }

Modified: geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/webapp/display.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/webapp/display.jsp?rev=987097&r1=987096&r2=987097&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/webapp/display.jsp
(original)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/jta1.1-test/src/main/webapp/display.jsp
Thu Aug 19 09:17:52 2010
@@ -55,7 +55,7 @@ String sav;
 			</tr>
 	
 <%
-	ds = (javax.sql.DataSource)initContext.lookup("java:app/BJAcc");
+	ds = (javax.sql.DataSource)initContext.lookup("java:app/BJAccTx");
 	//System.out.println("In desplay.jsp,sucess get java:app/BJAcc");	
 	conn = ds.getConnection();
 	stmt = conn.createStatement();
@@ -89,7 +89,7 @@ String sav;
 
 <%
 
-	ds = (javax.sql.DataSource)initContext.lookup("java:app/SHAcc");
+	ds = (javax.sql.DataSource)initContext.lookup("java:app/SHAccTx");
     //System.out.println("In desplay.jsp,sucess get java:app/SHAcc");	
 	conn = ds.getConnection();
 	stmt = conn.createStatement();



Mime
View raw message