cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r954041 - in /cayenne/main/trunk: ./ framework/cayenne-jdk1.5-unpublished/ framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/util/ framework/cayenne-jdk1.5-unpublished/src/test/resources/ framework/cayenne-jdk1.5-unpubli...
Date Sat, 12 Jun 2010 18:09:03 GMT
Author: aadamchik
Date: Sat Jun 12 18:09:02 2010
New Revision: 954041

URL: http://svn.apache.org/viewvc?rev=954041&view=rev
Log:
Unit tests refactoring

* moving tools-related test resources into tools project
* removing unused test resources
* removing dpendency on commons-oro
* organizing test resources by package

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/org/apache/cayenne/util/
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/org/apache/cayenne/util/jar-test.jar
      - copied, changed from r954029, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/jar-test.jar
    cayenne/main/trunk/framework/cayenne-tools/src/test/resources/
    cayenne/main/trunk/framework/cayenne-tools/src/test/resources/org/
    cayenne/main/trunk/framework/cayenne-tools/src/test/resources/org/apache/
    cayenne/main/trunk/framework/cayenne-tools/src/test/resources/org/apache/cayenne/
    cayenne/main/trunk/framework/cayenne-tools/src/test/resources/org/apache/cayenne/tools/
    cayenne/main/trunk/framework/cayenne-tools/src/test/resources/org/apache/cayenne/tools/cgen-dependent.map.xml
      - copied, changed from r954029, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testmap-dependent.map.xml
    cayenne/main/trunk/framework/cayenne-tools/src/test/resources/org/apache/cayenne/tools/cgen.map.xml
    cayenne/main/trunk/framework/cayenne-tools/src/test/resources/org/apache/cayenne/tools/velotemplate.vm
      - copied, changed from r954029, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testtemplate.vm
Removed:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/i18n/by/DataMap.map.xml
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/i18n/by/cayenne.xml
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/jar-test.jar
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testmap-dependent.map.xml
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testtemplate.vm
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/pom.xml
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/util/ZipUtilTest.java
    cayenne/main/trunk/framework/cayenne-tools/.classpath
    cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskCrossMapRelationshipsTest.java
    cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java
    cayenne/main/trunk/pom.xml

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/pom.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/pom.xml?rev=954041&r1=954040&r2=954041&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/pom.xml (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/pom.xml Sat Jun 12 18:09:02 2010
@@ -123,10 +123,6 @@
 			<groupId>mockrunner</groupId>
 			<artifactId>mockrunner</artifactId>
 		</dependency>
-        <dependency>
-			<groupId>oro</groupId>
-			<artifactId>oro</artifactId>
-		</dependency>
 	</dependencies>
 	<build>
 		<plugins>

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/util/ZipUtilTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/util/ZipUtilTest.java?rev=954041&r1=954040&r2=954041&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/util/ZipUtilTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/util/ZipUtilTest.java
Sat Jun 12 18:09:02 2010
@@ -35,7 +35,7 @@ public class ZipUtilTest extends TestCas
     public void testUnzip() throws Exception {
 
         URL jarResource = Thread.currentThread().getContextClassLoader().getResource(
-                "jar-test.jar");
+                "org/apache/cayenne/util/jar-test.jar");
         File jarCopy = new File(
                 CayenneResources.getResources().getTestDir(),
                 "jar-test.jar");
@@ -66,7 +66,7 @@ public class ZipUtilTest extends TestCas
 
     public void testZip() throws Exception {
         URL jarResource = Thread.currentThread().getContextClassLoader().getResource(
-                "jar-test.jar");
+                "org/apache/cayenne/util/jar-test.jar");
         File jarCopy = new File(
                 CayenneResources.getResources().getTestDir(),
                 "jar-test.jar");

Copied: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/org/apache/cayenne/util/jar-test.jar
(from r954029, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/jar-test.jar)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/org/apache/cayenne/util/jar-test.jar?p2=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/org/apache/cayenne/util/jar-test.jar&p1=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/jar-test.jar&r1=954029&r2=954041&rev=954041&view=diff
==============================================================================
Binary files - no diff available.

Modified: cayenne/main/trunk/framework/cayenne-tools/.classpath
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-tools/.classpath?rev=954041&r1=954040&r2=954041&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-tools/.classpath (original)
+++ cayenne/main/trunk/framework/cayenne-tools/.classpath Sat Jun 12 18:09:02 2010
@@ -3,6 +3,7 @@
 	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
 	<classpathentry kind="src" output="target/classes" path="src/main/resources"/>
 	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
 	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
 	<classpathentry kind="output" path="target/classes"/>

Modified: cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskCrossMapRelationshipsTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskCrossMapRelationshipsTest.java?rev=954041&r1=954040&r2=954041&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskCrossMapRelationshipsTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskCrossMapRelationshipsTest.java
Sat Jun 12 18:09:02 2010
@@ -23,11 +23,11 @@ import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStreamReader;
+import java.util.regex.Pattern;
 
 import junit.framework.TestCase;
 
 import org.apache.cayenne.unit.CayenneResources;
-import org.apache.oro.text.perl.Perl5Util;
 import org.apache.tools.ant.Location;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.FileList;
@@ -35,27 +35,16 @@ import org.apache.tools.ant.types.Path;
 
 public class CayenneGeneratorTaskCrossMapRelationshipsTest extends TestCase {
 
-    private static final Perl5Util regexUtil = new Perl5Util();
-    private static final Project project = new Project();
-
-    protected CayenneGeneratorTask task;
+    /**
+     * Tests pairs generation with a cross-DataMap relationship.
+     */
+    public void testCrossDataMapRelationships() throws Exception {
 
-    @Override
-    public void setUp() {
-        task = new CayenneGeneratorTask();
-        task.setProject(project);
+        CayenneGeneratorTask task = new CayenneGeneratorTask();
+        task.setProject(new Project());
         task.setTaskName("Test");
         task.setLocation(Location.UNKNOWN_LOCATION);
-    }
 
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-        task = null;
-    }
-
-    /** Test pairs generation with a cross-DataMap relationship. */
-    public void testCrossDataMapRelationships() throws Exception {
         // prepare destination directory
 
         File destDir = new File(CayenneResources.getResources().getTestDir(), "cgen12");
@@ -64,12 +53,16 @@ public class CayenneGeneratorTaskCrossMa
             assertTrue(destDir.mkdirs());
         }
 
-        File map = new File(destDir, "testmap-dependent.map.xml");
-        CayenneResources.copyResourceToFile("testmap-dependent.map.xml", map);
+        File map = new File(destDir, "cgen-dependent.map.xml");
+        CayenneResources.copyResourceToFile(
+                "org/apache/cayenne/tools/cgen-dependent.map.xml",
+                map);
 
         File additionalMaps[] = new File[1];
-        additionalMaps[0] = new File(destDir, "testmap.map.xml");
-        CayenneResources.copyResourceToFile("testmap.map.xml", additionalMaps[0]);
+        additionalMaps[0] = new File(destDir, "cgen.map.xml");
+        CayenneResources.copyResourceToFile(
+                "org/apache/cayenne/tools/cgen.map.xml",
+                additionalMaps[0]);
 
         FileList additionalMapsFilelist = new FileList();
         additionalMapsFilelist.setDir(additionalMaps[0].getParentFile());
@@ -152,7 +145,8 @@ public class CayenneGeneratorTaskCrossMa
 
         String s = null;
         while ((s = in.readLine()) != null) {
-            if (regexUtil.match("/^package\\s+([^\\s;]+);/", s + '\n')) {
+
+            if (Pattern.matches("^package\\s+([^\\s;]+);", s)) {
                 assertTrue(s.contains(packageName));
                 return;
             }
@@ -163,10 +157,12 @@ public class CayenneGeneratorTaskCrossMa
 
     private void assertClass(BufferedReader in, String className, String extendsName)
             throws Exception {
+        
+        Pattern classPattern = Pattern.compile("^public\\s+");
 
         String s = null;
         while ((s = in.readLine()) != null) {
-            if (regexUtil.match("/class\\s+([^\\s]+)\\s+extends\\s+([^\\s]+)/", s + '\n'))
{
+            if (classPattern.matcher(s).find()) {
                 assertTrue(s.contains(className));
                 assertTrue(s.contains(extendsName));
                 assertTrue(s.indexOf(className) < s.indexOf(extendsName));

Modified: cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java?rev=954041&r1=954040&r2=954041&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java
Sat Jun 12 18:09:02 2010
@@ -23,64 +23,52 @@ import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStreamReader;
-import java.net.URL;
+import java.util.regex.Pattern;
 
 import junit.framework.TestCase;
 
 import org.apache.cayenne.unit.CayenneResources;
-import org.apache.cayenne.util.ResourceLocator;
-import org.apache.cayenne.util.Util;
-import org.apache.oro.text.perl.Perl5Util;
 import org.apache.tools.ant.Location;
 import org.apache.tools.ant.Project;
 
 public class CayenneGeneratorTaskTest extends TestCase {
 
-    private static final Perl5Util regexUtil = new Perl5Util();
-    private static final Project project = new Project();
-    private static final File baseDir = CayenneResources.getResources().getTestDir();
-    private static final File map = new File(baseDir, "antmap.xml");
-    private static final File mapEmbeddables = new File(baseDir, "antmap-embeddables.xml");
-    private static final File template = new File(baseDir, "velotemplate.vm");
+    private static final File baseDir;
+    private static final File map;
+    private static final File mapEmbeddables;
+    private static final File template;
 
     static {
-        extractFiles();
-        project.setBaseDir(baseDir);
+
+        baseDir = CayenneResources.getResources().getTestDir();
+        map = new File(baseDir, "antmap.xml");
+        mapEmbeddables = new File(baseDir, "antmap-embeddables.xml");
+        template = new File(baseDir, "velotemplate.vm");
+
+        CayenneResources.copyResourceToFile("testmap.map.xml", map);
+        CayenneResources.copyResourceToFile("embeddable.map.xml", mapEmbeddables);
+        CayenneResources.copyResourceToFile(
+                "org/apache/cayenne/tools/velotemplate.vm",
+                template);
     }
 
     protected CayenneGeneratorTask task;
 
-    private static void extractFiles() {
-        ResourceLocator locator = new ResourceLocator();
-        locator.setSkipAbsolutePath(true);
-        locator.setSkipClasspath(false);
-        locator.setSkipCurrentDirectory(true);
-        locator.setSkipHomeDirectory(true);
-
-        URL url1 = locator.findResource("testmap.map.xml");
-        Util.copy(url1, map);
-        URL url2 = locator.findResource("testtemplate.vm");
-        Util.copy(url2, template);
-
-        URL url3 = locator.findResource("embeddable.map.xml");
-        Util.copy(url3, mapEmbeddables);
-    }
-
     @Override
     public void setUp() {
+
+        Project project = new Project();
+        project.setBaseDir(baseDir);
+
         task = new CayenneGeneratorTask();
         task.setProject(project);
         task.setTaskName("Test");
         task.setLocation(Location.UNKNOWN_LOCATION);
     }
 
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-        task = null;
-    }
-
-    /** Test single classes with a non-standard template. */
+    /**
+     * Test single classes with a non-standard template.
+     */
     public void testSingleClassesCustTemplate() throws Exception {
         // prepare destination directory
         File mapDir = new File(baseDir, "single-classes-custtempl");
@@ -323,7 +311,7 @@ public class CayenneGeneratorTaskTest ex
 
         String s = null;
         while ((s = in.readLine()) != null) {
-            if (regexUtil.match("/^package\\s+([^\\s;]+);/", s + '\n')) {
+            if (Pattern.matches("^package\\s+([^\\s;]+);", s)) {
                 assertTrue(s.indexOf(packageName) > 0);
                 return;
             }
@@ -335,9 +323,11 @@ public class CayenneGeneratorTaskTest ex
     private void assertClass(BufferedReader in, String className, String extendsName)
             throws Exception {
 
+        Pattern classPattern = Pattern.compile("^public\\s+");
+
         String s = null;
         while ((s = in.readLine()) != null) {
-            if (regexUtil.match("/class\\s+([^\\s]+)\\s+extends\\s+([^\\s]+)/", s + '\n'))
{
+            if (classPattern.matcher(s).find()) {
                 assertTrue(s.indexOf(className) > 0);
                 assertTrue(s.indexOf(extendsName) > 0);
                 assertTrue(s.indexOf(className) < s.indexOf(extendsName));

Copied: cayenne/main/trunk/framework/cayenne-tools/src/test/resources/org/apache/cayenne/tools/cgen-dependent.map.xml
(from r954029, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testmap-dependent.map.xml)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-tools/src/test/resources/org/apache/cayenne/tools/cgen-dependent.map.xml?p2=cayenne/main/trunk/framework/cayenne-tools/src/test/resources/org/apache/cayenne/tools/cgen-dependent.map.xml&p1=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testmap-dependent.map.xml&r1=954029&r2=954041&rev=954041&view=diff
==============================================================================
    (empty)

Added: cayenne/main/trunk/framework/cayenne-tools/src/test/resources/org/apache/cayenne/tools/cgen.map.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-tools/src/test/resources/org/apache/cayenne/tools/cgen.map.xml?rev=954041&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-tools/src/test/resources/org/apache/cayenne/tools/cgen.map.xml
(added)
+++ cayenne/main/trunk/framework/cayenne-tools/src/test/resources/org/apache/cayenne/tools/cgen.map.xml
Sat Jun 12 18:09:02 2010
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
+	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	 xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap http://cayenne.apache.org/schema/3.0/modelMap.xsd"
+	 project-version="6">
+
+	<db-entity name="ARTGROUP">
+		<db-attribute name="GROUP_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="NAME" type="VARCHAR" isMandatory="true" length="100"/>
+		<db-attribute name="PARENT_GROUP_ID" type="INTEGER"/>
+	</db-entity>
+	<obj-entity name="ArtGroup" className="org.apache.art.ArtGroup" dbEntityName="ARTGROUP">
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	</obj-entity>
+</data-map>

Copied: cayenne/main/trunk/framework/cayenne-tools/src/test/resources/org/apache/cayenne/tools/velotemplate.vm
(from r954029, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testtemplate.vm)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-tools/src/test/resources/org/apache/cayenne/tools/velotemplate.vm?p2=cayenne/main/trunk/framework/cayenne-tools/src/test/resources/org/apache/cayenne/tools/velotemplate.vm&p1=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testtemplate.vm&r1=954029&r2=954041&rev=954041&view=diff
==============================================================================
    (empty)

Modified: cayenne/main/trunk/pom.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/pom.xml?rev=954041&r1=954040&r2=954041&view=diff
==============================================================================
--- cayenne/main/trunk/pom.xml (original)
+++ cayenne/main/trunk/pom.xml Sat Jun 12 18:09:02 2010
@@ -374,12 +374,6 @@
 				<scope>test</scope>
 			</dependency>
 			<dependency>
-				<groupId>oro</groupId>
-				<artifactId>oro</artifactId>
-				<version>2.0.8</version>
-				<scope>test</scope>
-			</dependency>
-			<dependency>
 				<groupId>ognl</groupId>
 				<artifactId>ognl</artifactId>
 				<version>2.6.7</version>



Mime
View raw message