cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ksen...@apache.org
Subject svn commit: r1022932 - in /cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin: ./ src/main/java/org/apache/cayenne/tools/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/cayenne/ src/test/java...
Date Fri, 15 Oct 2010 14:21:24 GMT
Author: kseniak
Date: Fri Oct 15 14:21:24 2010
New Revision: 1022932

URL: http://svn.apache.org/viewvc?rev=1022932&view=rev
Log:
CAY-1495. Synchronized maven-cayenne-plugin attributes with documented ones; Added unit test
for the plugin

Added:
    cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/
    cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/java/
    cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/java/org/
    cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/java/org/apache/
    cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/java/org/apache/cayenne/
    cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/
    cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/CayenneGeneratorMojoTest.java
    cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/resources/
    cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/resources/cgen/
    cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/resources/cgen/cayenne.xml
    cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/resources/cgen/project-to-test/
    cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/resources/cgen/project-to-test/pom.xml
    cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/resources/cgen/testDomainMap.map.xml
Modified:
    cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/.classpath
    cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/pom.xml
    cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java

Modified: cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/.classpath
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/.classpath?rev=1022932&r1=1022931&r2=1022932&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/.classpath (original)
+++ cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/.classpath Fri Oct 15
14:21:24 2010
@@ -1,7 +1,9 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="src" path="src/main/java"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
-	<classpathentry kind="output" path="target/classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="src" path="src/test/java"/>
+	<classpathentry kind="src" path="src/test/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Modified: cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/pom.xml
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/pom.xml?rev=1022932&r1=1022931&r2=1022932&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/pom.xml (original)
+++ cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/pom.xml Fri Oct 15 14:21:24
2010
@@ -93,7 +93,14 @@
 			<artifactId>vpp</artifactId>
 			<scope>compile</scope>
 		</dependency>
-
+		
+		<dependency>
+      		<groupId>org.apache.maven.shared</groupId>
+      		<artifactId>maven-plugin-testing-harness</artifactId>
+      		<version>1.0-beta-1</version>
+      		<scope>test</scope>
+    	</dependency>
+    
 	</dependencies>
 	<build>
 		<plugins>

Modified: cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java?rev=1022932&r1=1022931&r2=1022932&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
(original)
+++ cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
Fri Oct 15 14:21:24 2010
@@ -90,17 +90,17 @@ public class CayenneGeneratorMojo extend
 	 * Entities (expressed as a perl5 regex) to exclude from template
 	 * generation. (Default is to include all entities in the DataMap).
 	 * 
-	 * @parameter expression="${cgen.excludeEntitiesPattern}"
+	 * @parameter expression="${cgen.excludeEntities}"
 	 */
-	private String excludeEntitiesPattern;
+	private String excludeEntities;
 
 	/**
 	 * Entities (expressed as a perl5 regex) to include in template generation.
 	 * (Default is to include all entities in the DataMap).
 	 * 
-	 * @parameter expression="${cgen.includeEntitiesPattern}"
+	 * @parameter expression="${cgen.includeEntities}"
 	 */
-	private String includeEntitiesPattern;
+	private String includeEntities;
 
 	/**
 	 * If set to <code>true</code>, will generate subclass/superclass pairs,
@@ -230,7 +230,7 @@ public class CayenneGeneratorMojo extend
 		CayenneGeneratorEntityFilterAction filterAction = new CayenneGeneratorEntityFilterAction();
 		filterAction.setClient(client);
 		filterAction.setNameFilter(new NamePatternMatcher(logger,
-				includeEntitiesPattern, excludeEntitiesPattern));
+				includeEntities, excludeEntities));
 
 		try {
 			loaderAction.setAdditionalDataMapFiles(convertAdditionalDataMaps());
@@ -242,8 +242,10 @@ public class CayenneGeneratorMojo extend
 			generator.setTimestamp(map.lastModified());
 			generator.setDataMap(dataMap);
 			generator.addEntities(filterAction.getFilteredEntities(dataMap));
-			generator.addEmbeddables(filterAction
-					.getFilteredEmbeddables(dataMap));
+			//ksenia khailenko 15.10.2010
+			//TODO add the "includeEmbeddables" and "excludeEmbeddables" attributes
+			generator.addEmbeddables(dataMap.getEmbeddables());
+			//TODO add the "includeQueries" and "excludeQueries" attributes
 			generator.addQueries(dataMap.getQueries());
 			generator.execute();
 		} catch (Exception e) {

Added: cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/CayenneGeneratorMojoTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/CayenneGeneratorMojoTest.java?rev=1022932&view=auto
==============================================================================
--- cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/CayenneGeneratorMojoTest.java
(added)
+++ cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/CayenneGeneratorMojoTest.java
Fri Oct 15 14:21:24 2010
@@ -0,0 +1,89 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.tools;
+
+import java.io.File;
+
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+
+public class CayenneGeneratorMojoTest extends AbstractMojoTestCase {
+	/** {@inheritDoc} */
+	protected void setUp() throws Exception {
+		// required
+		super.setUp();
+
+	}
+
+	/** {@inheritDoc} */
+	protected void tearDown() throws Exception {
+		// required
+		super.tearDown();
+
+	}
+
+	/**
+	 * @throws Exception
+	 *             if any
+	 */
+	public void testCgenExecution() throws Exception {
+
+		File pom = getTestFile("src/test/resources/cgen/project-to-test/pom.xml");
+		assertNotNull(pom);
+		assertTrue(pom.exists());
+
+		CayenneGeneratorMojo myMojo = (CayenneGeneratorMojo) lookupMojo("cgen",
+				pom);
+		assertNotNull(myMojo);
+		myMojo.execute();
+
+		File superTestEntity = new File(
+				"target/cayenneGeneratedClasses/superPkg/_TestEntity.txt");
+		File testEntity = new File(
+				"target/cayenneGeneratedClasses/pack/TestEntity.txt");
+
+		File superEmbeddable = new File(
+				"target/cayenneGeneratedClasses/superPkg/_Embeddable.txt");
+		File embeddable = new File(
+				"target/cayenneGeneratedClasses/pack/Embeddable.txt");
+
+		File superNotIncludedEntity = new File(
+				"target/cayenneGeneratedClasses/pack/_NotIncludedEntity.txt");
+
+		File notIncludedEntity = new File(
+				"target/cayenneGeneratedClasses/pack/NotIncludedEntity.txt");
+
+		File superExcludedEntity = new File(
+				"target/cayenneGeneratedClasses/pack/_TestExcludedEntity.txt");
+		File excludedEntity = new File(
+				"target/cayenneGeneratedClasses/pack/TestExcludedEntity.txt");
+
+		assertTrue(superTestEntity.exists());
+		assertTrue(testEntity.exists());
+
+		assertTrue(superEmbeddable.exists());
+		assertTrue(embeddable.exists());
+
+		assertFalse(superNotIncludedEntity.exists());
+		assertFalse(notIncludedEntity.exists());
+
+		assertFalse(superExcludedEntity.exists());
+		assertFalse(excludedEntity.exists());
+
+	}
+}

Added: cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/resources/cgen/cayenne.xml
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/resources/cgen/cayenne.xml?rev=1022932&view=auto
==============================================================================
--- cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/resources/cgen/cayenne.xml
(added)
+++ cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/resources/cgen/cayenne.xml
Fri Oct 15 14:21:24 2010
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<domains project-version="3.0.0.1">
+<domain name="testDomain">
+	<map name="testDomainMap" location="testDomainMap.map.xml"/>
+</domain>
+</domains>

Added: cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/resources/cgen/project-to-test/pom.xml
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/resources/cgen/project-to-test/pom.xml?rev=1022932&view=auto
==============================================================================
--- cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/resources/cgen/project-to-test/pom.xml
(added)
+++ cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/resources/cgen/project-to-test/pom.xml
Fri Oct 15 14:21:24 2010
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	Licensed to the Apache Software Foundation (ASF) under one
+	or more contributor license agreements.  See the NOTICE file
+	distributed with this work for additional information
+	regarding copyright ownership.  The ASF licenses this file
+	to you 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.   
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+	http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+	<name>Test CayenneGeneratorMojo</name>
+
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<artifactId>maven-cayenne-plugin</artifactId>
+				<configuration>
+					<map>src/test/resources/cgen/testDomainMap.map.xml</map>
+					<destDir>target/cayenneGeneratedClasses</destDir>
+					<outputPattern>*.txt</outputPattern>
+					<makePairs>true</makePairs>
+					<usePkgPath>true</usePkgPath>
+					<superPkg>superPkg</superPkg>
+					<encoding>UTF-8</encoding>
+					<includeEntities>Test*</includeEntities>
+					<excludeEntities>TestExcludedEntity</excludeEntities>
+					<mode>all</mode>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+
+</project>

Added: cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/resources/cgen/testDomainMap.map.xml
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/resources/cgen/testDomainMap.map.xml?rev=1022932&view=auto
==============================================================================
--- cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/resources/cgen/testDomainMap.map.xml
(added)
+++ cayenne/main/branches/STABLE-3.0/framework/maven-cayenne-plugin/src/test/resources/cgen/testDomainMap.map.xml
Fri Oct 15 14:21:24 2010
@@ -0,0 +1,40 @@
+<?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="3.0.0.1">
+	<property name="defaultPackage" value="pack"/>
+	<embeddable className="pack.Embeddable">
+		<embeddable-attribute name="embAttr" type="java.lang.String" db-attribute-name="EMB_ATTR"/>
+	</embeddable>
+	<db-entity name="NotIncludedEntity">
+		<db-attribute name="id" type="BIGINT" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="name" type="VARCHAR" length="255"/>
+	</db-entity>
+	<db-entity name="TestEntity">
+		<db-attribute name="id" type="BIGINT" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="testAttr" type="VARCHAR" length="255"/>
+	</db-entity>
+	<db-entity name="TestExcludedEntity">
+		<db-attribute name="id" type="BIGINT" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="name" type="VARCHAR" length="255"/>
+	</db-entity>
+	<obj-entity name="NotIncludedEntity" className="pack.NotIncludedEntity" dbEntityName="NotIncludedEntity">
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="name"/>
+	</obj-entity>
+	<obj-entity name="TestEntity" className="pack.TestEntity" dbEntityName="TestEntity">
+		<embedded-attribute name="embeddedAtr" type="pack.Embeddable"/>
+		<obj-attribute name="testAttr" type="java.lang.String" db-attribute-path="testAttr"/>
+	</obj-entity>
+	<obj-entity name="TestExcludedEntity" className="pack.TestExcludedEntity" dbEntityName="TestExcludedEntity">
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="name"/>
+	</obj-entity>
+	<db-relationship name="childrenRel" source="TestEntity" target="TestEntity" toMany="true">
+		<db-attribute-pair source="id" target="id"/>
+	</db-relationship>
+	<db-relationship name="parentRel" source="TestEntity" target="TestEntity" toMany="false">
+		<db-attribute-pair source="id" target="id"/>
+	</db-relationship>
+	<obj-relationship name="childrenRel" source="TestEntity" target="TestEntity" deleteRule="Deny"
db-relationship-path="childrenRel"/>
+	<obj-relationship name="parentRel" source="TestEntity" target="TestEntity" deleteRule="Nullify"
db-relationship-path="parentRel"/>
+</data-map>



Mime
View raw message