cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r408464 - in /incubator/cayenne/main/trunk/cayenne-regression-profiler: ./ src/main/java/org/apache/cayenne/profile/ src/main/java/org/apache/cayenne/profile/cases/ src/main/java/org/apache/cayenne/profile/servlet/ src/main/resources/
Date Sun, 21 May 2006 19:29:07 GMT
Author: aadamchik
Date: Sun May 21 12:29:07 2006
New Revision: 408464

URL: http://svn.apache.org/viewvc?rev=408464&view=rev
Log:
setting mavne profiles to support regression profiling on different dbs

Added:
    incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/AbstractCase.java
      - copied, changed from r408130, incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/servlet/AbstractCase.java
    incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/TestDataSourceFactory.java
Removed:
    incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/servlet/AbstractCase.java
    incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/resources/regression-profile.driver.xml
Modified:
    incubator/cayenne/main/trunk/cayenne-regression-profiler/pom.xml
    incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/cases/DeleteCase.java
    incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/cases/InsertCase.java
    incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/cases/SelectCase.java
    incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/servlet/ProfileFilter.java
    incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/servlet/ProfileServlet.java
    incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/resources/cayenne.xml

Modified: incubator/cayenne/main/trunk/cayenne-regression-profiler/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/cayenne-regression-profiler/pom.xml?rev=408464&r1=408463&r2=408464&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne-regression-profiler/pom.xml (original)
+++ incubator/cayenne/main/trunk/cayenne-regression-profiler/pom.xml Sun May 21 12:29:07 2006
@@ -6,15 +6,6 @@
   <name>Cayenne Regression Profiler Web Application</name>
   <version>1.2-SNAPSHOT</version>
   <url>http://incubator.apache.org/cayenne/</url>
-  
-  <repositories>
-		<repository>
-			<id>objectstyle</id>
-			<name>ObjectStyle Public Maven2 repo</name>
-			<url>http://objectstyle.org/maven2</url>
-		</repository>
-  </repositories>
-  
   <build>
     <finalName>cayenne-regression-profiler</finalName>
     <plugins>
@@ -41,9 +32,6 @@
           </execution>
         </executions>
       </plugin>
-      <!-- before running , do this:
-           export MAVEN_OPTS="-Xms128M -Xmx128M"
-      -->
       <plugin>
         <groupId>org.mortbay.jetty</groupId>
         <artifactId>maven-jetty6-plugin</artifactId>
@@ -57,37 +45,96 @@
         </dependencies>
         <configuration>
           <scanIntervalSeconds>20</scanIntervalSeconds>
-         <!-- <jettyConfig>etc/jetty.xml</jettyConfig> -->
         </configuration>
       </plugin>
     </plugins>
   </build>
   <profiles>
-   <profile>
-  		<id>1.2-SNAPSHOT</id>
-  		<activation>
-  			<activeByDefault>true</activeByDefault>
-  		</activation>
-  		 <dependencies>
-  		 	<dependency>
-				<groupId>org.objectstyle.cayenne</groupId>
-				<artifactId>cayenne</artifactId>
-				<version>1.2-SNAPSHOT</version>
-			</dependency>
-  		 </dependencies>
-	</profile>
-	<profile>
-  		<id>1.2M12</id>
-  		 <dependencies>
-  		 	<dependency>
-				<groupId>org.objectstyle.cayenne</groupId>
-				<artifactId>cayenne</artifactId>
-				<version>1.2M12</version>
-			</dependency>
-  		 </dependencies>
-	</profile>
+    <!-- Cayenne version profiles -->
+    <profile>
+      <id>1.2-SNAPSHOT</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>org.objectstyle.cayenne</groupId>
+          <artifactId>cayenne</artifactId>
+          <version>1.2-SNAPSHOT</version>
+        </dependency>
+      </dependencies>
+    </profile>
+    <profile>
+      <id>1.2M12</id>
+      <dependencies>
+        <dependency>
+          <groupId>org.objectstyle.cayenne</groupId>
+          <artifactId>cayenne</artifactId>
+          <version>1.2M12</version>
+        </dependency>
+      </dependencies>
+    </profile>
+    <!-- Database profiles -->
+    <profile>
+      <id>default-db</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+        <property>
+      		<name>cayenne.test.connection</name>
+      		<value>internal_embedded_datasource</value>
+      	</property>
+      </activation>
+      <dependencies>
+        <dependency>
+      		<groupId>hsqldb</groupId>
+      		<artifactId>hsqldb</artifactId>
+     		<version>1.8.0.1</version>
+      		<scope>runtime</scope>
+    	</dependency>
+      </dependencies>
+    </profile>
+    <profile>
+      <id>mysql</id>
+      <activation>
+      	<property>
+      		<name>cayenne.test.connection</name>
+      		<value>mysql</value>
+      	</property>
+      </activation>
+      <dependencies>
+        <dependency>
+      		<groupId>mysql</groupId>
+      		<artifactId>mysql-connector-java</artifactId>
+      		<version>3.1.11</version>
+      		<scope>runtime</scope>
+    	</dependency>
+      </dependencies>
+    </profile>
+    <profile>
+      <id>oracle</id>
+      <activation>
+      <property>
+      	<name>cayenne.test.connection</name>
+      	<value>oracle</value>
+      </property>
+      </activation>
+      <dependencies>
+        <dependency>
+			<groupId>com.oracle</groupId>
+			<artifactId>oracle-driver</artifactId>
+			<version>10</version>
+			<scope>runtime</scope>
+		</dependency>
+      </dependencies>
+    </profile>
   </profiles>
-  
+  <repositories>
+    <repository>
+      <id>objectstyle</id>
+      <name>ObjectStyle Public Maven2 repo</name>
+      <url>http://objectstyle.org/maven2</url>
+    </repository>
+  </repositories>
   <dependencies>
     <dependency>
       <groupId>javax.servlet</groupId>
@@ -96,16 +143,9 @@
       <scope>provided</scope>
     </dependency>
     <dependency>
-		<groupId>junit</groupId>
-		<artifactId>junit</artifactId>
-		<version>3.8.1</version>
-	</dependency>
-    <dependency>
-      <groupId>hsqldb</groupId>
-      <artifactId>hsqldb</artifactId>
-      <version>1.8.0.1</version>
-      <scope>runtime</scope>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
     </dependency>
-    	
   </dependencies>
 </project>

Copied: incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/AbstractCase.java
(from r408130, incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/servlet/AbstractCase.java)
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/AbstractCase.java?p2=incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/AbstractCase.java&p1=incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/servlet/AbstractCase.java&r1=408130&r2=408464&rev=408464&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/servlet/AbstractCase.java
(original)
+++ incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/AbstractCase.java
Sun May 21 12:29:07 2006
@@ -13,7 +13,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package org.apache.cayenne.profile.servlet;
+package org.apache.cayenne.profile;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;

Added: incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/TestDataSourceFactory.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/TestDataSourceFactory.java?rev=408464&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/TestDataSourceFactory.java
(added)
+++ incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/TestDataSourceFactory.java
Sun May 21 12:29:07 2006
@@ -0,0 +1,74 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  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.apache.cayenne.profile;
+
+import javax.sql.DataSource;
+
+import org.apache.log4j.Level;
+import org.objectstyle.cayenne.CayenneRuntimeException;
+import org.objectstyle.cayenne.conf.Configuration;
+import org.objectstyle.cayenne.conf.ConnectionProperties;
+import org.objectstyle.cayenne.conf.DataSourceFactory;
+import org.objectstyle.cayenne.conn.DataSourceInfo;
+import org.objectstyle.cayenne.conn.PoolManager;
+
+/**
+ * A DataSourceFactory that loads connection info from connection properties, the same way
+ * unit tests do.
+ * 
+ * @author Andrus Adamchik
+ */
+public class TestDataSourceFactory implements DataSourceFactory {
+
+    // same as the one used in unit tests
+    public static final String CONNECTION_SET_PROPERTY = "cayenne.test.connection";
+
+    public static String getDataSourceName() {
+        String connectionSet = System.getProperty(CONNECTION_SET_PROPERTY);
+        if (connectionSet == null) {
+            connectionSet = ConnectionProperties.EMBEDDED_DATASOURCE;
+        }
+
+        return connectionSet;
+    }
+
+    public DataSource getDataSource(String location) throws Exception {
+
+        String connectionSet = getDataSourceName();
+        DataSourceInfo dsi = ConnectionProperties.getInstance().getConnectionInfo(
+                connectionSet);
+
+        if (dsi == null) {
+            throw new CayenneRuntimeException("Connection info for key '"
+                    + connectionSet
+                    + "' is not configured");
+        }
+
+        return new PoolManager(dsi.getJdbcDriver(), dsi.getDataSourceUrl(), dsi
+                .getMinConnections(), dsi.getMaxConnections(), dsi.getUserName(), dsi
+                .getPassword());
+    }
+
+    /**
+     * @deprecated since 1.2 super is deprecated
+     */
+    public DataSource getDataSource(String location, Level logLevel) throws Exception {
+        return getDataSource(location);
+    }
+
+    public void initializeWithParentConfiguration(Configuration conf) {
+    }
+}

Modified: incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/cases/DeleteCase.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/cases/DeleteCase.java?rev=408464&r1=408463&r2=408464&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/cases/DeleteCase.java
(original)
+++ incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/cases/DeleteCase.java
Sun May 21 12:29:07 2006
@@ -18,8 +18,8 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.cayenne.profile.AbstractCase;
 import org.apache.cayenne.profile.entity.Entity1;
-import org.apache.cayenne.profile.servlet.AbstractCase;
 import org.objectstyle.cayenne.access.DataContext;
 import org.objectstyle.cayenne.query.SQLTemplate;
 

Modified: incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/cases/InsertCase.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/cases/InsertCase.java?rev=408464&r1=408463&r2=408464&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/cases/InsertCase.java
(original)
+++ incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/cases/InsertCase.java
Sun May 21 12:29:07 2006
@@ -18,8 +18,8 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.cayenne.profile.AbstractCase;
 import org.apache.cayenne.profile.entity.Entity1;
-import org.apache.cayenne.profile.servlet.AbstractCase;
 import org.objectstyle.cayenne.access.DataContext;
 
 public class InsertCase extends AbstractCase {

Modified: incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/cases/SelectCase.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/cases/SelectCase.java?rev=408464&r1=408463&r2=408464&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/cases/SelectCase.java
(original)
+++ incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/cases/SelectCase.java
Sun May 21 12:29:07 2006
@@ -18,8 +18,8 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.cayenne.profile.AbstractCase;
 import org.apache.cayenne.profile.entity.Entity1;
-import org.apache.cayenne.profile.servlet.AbstractCase;
 import org.objectstyle.cayenne.access.DataContext;
 import org.objectstyle.cayenne.exp.Expression;
 import org.objectstyle.cayenne.query.SelectQuery;

Modified: incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/servlet/ProfileFilter.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/servlet/ProfileFilter.java?rev=408464&r1=408463&r2=408464&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/servlet/ProfileFilter.java
(original)
+++ incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/servlet/ProfileFilter.java
Sun May 21 12:29:07 2006
@@ -15,11 +15,10 @@
  */
 package org.apache.cayenne.profile.servlet;
 
-import java.io.File;
-
 import javax.servlet.FilterConfig;
 import javax.servlet.ServletException;
 
+import org.apache.cayenne.profile.TestDataSourceFactory;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.objectstyle.cayenne.access.DataDomain;
@@ -28,7 +27,6 @@
 import org.objectstyle.cayenne.conf.Configuration;
 import org.objectstyle.cayenne.conf.WebApplicationContextFilter;
 import org.objectstyle.cayenne.util.LocalizedStringsHandler;
-import org.objectstyle.cayenne.util.Util;
 
 /**
  * A filter that sets up DB schema.
@@ -39,21 +37,6 @@
 
     public synchronized void init(FilterConfig config) throws ServletException {
 
-        // remove old database
-        // store this value and log it after Cayenne logging is initialized.
-        boolean deletedOldDb = false;
-        File dbDir = new File("target/regression-db");
-        if (dbDir.isDirectory()) {
-            
-            if (Util.delete(dbDir.getAbsolutePath(), true)) {
-                deletedOldDb = true;
-            }
-
-            if (dbDir.isDirectory()) {
-                throw new ServletException("Can't delete the old database");
-            }
-        }
-
         // start Cayenne stack
         super.init(config);
 
@@ -61,10 +44,12 @@
         if (cayenneVersion == null) {
             cayenneVersion = "unknown";
         }
-        logger.info("Started Cayenne version - '" + cayenneVersion + "'");
-        if(deletedOldDb) {
-            logger.info("deleted old database");
-        }
+
+        logger.info("Started Cayenne... Version - '"
+                + cayenneVersion
+                + "'; connection: '"
+                + TestDataSourceFactory.getDataSourceName()
+                + "'");
 
         // create fresh database
         DataDomain domain = Configuration.getSharedConfiguration().getDomain();

Modified: incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/servlet/ProfileServlet.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/servlet/ProfileServlet.java?rev=408464&r1=408463&r2=408464&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/servlet/ProfileServlet.java
(original)
+++ incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/java/org/apache/cayenne/profile/servlet/ProfileServlet.java
Sun May 21 12:29:07 2006
@@ -22,6 +22,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.cayenne.profile.AbstractCase;
 import org.objectstyle.cayenne.access.DataContext;
 
 /**

Modified: incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/resources/cayenne.xml
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/resources/cayenne.xml?rev=408464&r1=408463&r2=408464&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/resources/cayenne.xml
(original)
+++ incubator/cayenne/main/trunk/cayenne-regression-profiler/src/main/resources/cayenne.xml
Sun May 21 12:29:07 2006
@@ -4,8 +4,8 @@
 	<map name="regression-profile" location="regression-profile.map.xml"/>
 
 	<node name="regression-profile"
-		 datasource="regression-profile.driver.xml"
-		 factory="org.objectstyle.cayenne.conf.DriverDataSourceFactory">
+		 datasource="regression-profile"
+		 factory="org.apache.cayenne.profile.TestDataSourceFactory">
 			<map-ref name="regression-profile"/>
 	 </node>
 </domain>



Mime
View raw message