incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svanteschub...@apache.org
Subject svn commit: r1434455 - in /incubator/odf/trunk/generator: ./ schema2template/ schema2template/src/main/java/schema2template/example/odf/ schema2template/src/main/resources/documentation/ schema2template/src/main/resources/examples/odf/odf-reference/ sc...
Date Wed, 16 Jan 2013 22:38:08 GMT
Author: svanteschubert
Date: Wed Jan 16 22:38:07 2013
New Revision: 1434455

URL: http://svn.apache.org/viewvc?rev=1434455&view=rev
Log:
Fixing the code generation examples (ODF reference & python) adding tests.

Added:
    incubator/odf/trunk/generator/schema2template/src/test/java/schema2template/example/ExampleGenerationTest.java
    incubator/odf/trunk/generator/schema2template/src/test/java/schema2template/example/odf/PuzzlePieceTest.java
      - copied, changed from r1433703, incubator/odf/trunk/generator/schema2template/src/test/java/schema2template/PuzzlePieceTest.java
Removed:
    incubator/odf/trunk/generator/schema2template/src/test/java/schema2template/PuzzlePieceTest.java
Modified:
    incubator/odf/trunk/generator/   (props changed)
    incubator/odf/trunk/generator/schema2template/   (props changed)
    incubator/odf/trunk/generator/schema2template/pom.xml
    incubator/odf/trunk/generator/schema2template/src/main/java/schema2template/example/odf/OdfHelper.java
    incubator/odf/trunk/generator/schema2template/src/main/resources/documentation/   (props
changed)
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odf-reference/dom-output-files.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-python/dom-output-files.vm

Propchange: incubator/odf/trunk/generator/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Jan 16 22:38:07 2013
@@ -0,0 +1 @@
+target

Propchange: incubator/odf/trunk/generator/schema2template/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Jan 16 22:38:07 2013
@@ -0,0 +1 @@
+target

Modified: incubator/odf/trunk/generator/schema2template/pom.xml
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/generator/schema2template/pom.xml?rev=1434455&r1=1434454&r2=1434455&view=diff
==============================================================================
--- incubator/odf/trunk/generator/schema2template/pom.xml (original)
+++ incubator/odf/trunk/generator/schema2template/pom.xml Wed Jan 16 22:38:07 2013
@@ -134,7 +134,7 @@
           				</goals>
           				<configuration>
             				<url>dav:http://docs.oasis-open.org/office/v1.2</url>
-            				<fromFile>cs01/OpenDocument-v1.2-cs01-schema.rng</fromFile>
+            				<fromFile>os/OpenDocument-v1.2-os-schema.rng</fromFile>
             				<toDir>${project.build.directory}/odf-schemas</toDir>
           				</configuration>
         			</execution>
@@ -146,7 +146,7 @@
           				</goals>
           				<configuration>
             				<url>dav:http://docs.oasis-open.org/office/v1.2</url>
-            				<fromFile>cs01/OpenDocument-v1.2-cs01-manifest-schema.rng</fromFile>
+            				<fromFile>os/OpenDocument-v1.2-os-manifest-schema.rng</fromFile>
             				<toDir>${project.build.directory}/odf-schemas</toDir>
           				</configuration>
         			</execution>
@@ -158,7 +158,7 @@
           				</goals>
           				<configuration>
             				<url>dav:http://docs.oasis-open.org/office/v1.2</url>
-            				<fromFile>cs01/OpenDocument-v1.2-cs01-dsig-schema.rng</fromFile>
+            				<fromFile>os/OpenDocument-v1.2-os-dsig-schema.rng</fromFile>
             				<toDir>${project.build.directory}/odf-schemas</toDir>
           				</configuration>
         			</execution>

Modified: incubator/odf/trunk/generator/schema2template/src/main/java/schema2template/example/odf/OdfHelper.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/generator/schema2template/src/main/java/schema2template/example/odf/OdfHelper.java?rev=1434455&r1=1434454&r2=1434455&view=diff
==============================================================================
--- incubator/odf/trunk/generator/schema2template/src/main/java/schema2template/example/odf/OdfHelper.java
(original)
+++ incubator/odf/trunk/generator/schema2template/src/main/java/schema2template/example/odf/OdfHelper.java
Wed Jan 16 22:38:07 2013
@@ -84,23 +84,32 @@ public class OdfHelper {
 	NOTE: Ignoring the '*' there can be 1162 elements parsed, but with fixed schema it should
be 1169. */
 	public static final int ODF11_ATTRIBUTE_NUMBER = 1162; //ToDo: 1169 - by search/Replace
using RNGSchema and tools, prior exchange <name> to element or attribute declaration
 	public static final int ODF12_ATTRIBUTE_NUMBER = 1300; //in RNG 1301 as there is one deprecated
attribute on foreign elements not referenced (ie. @office:process-content)
-	public static String odfDomResourceDir;
-	public static String odfPkgResourceDir;
-	public static String outputRoot;
+	private static String odfDomResourceDir;
+	private static String odfPkgResourceDir;
+	private static String odfPythonResourceDir;
+	private static String odfReferenceResourceDir;
+	private static String outputRoot;
 	public static final String INPUT_ROOT = "target" + File.separator + "odf-schemas";
-	public static final String TEST_INPUT_ROOT = "target" + File.separator + "test-classes"
+ File.separator
+	public static final String TEST_REFERENCE_DIR = "target" + File.separator + "test-classes"
+ File.separator
+			+ "examples" + File.separator + "odf";
+	public static final String TEST_INPUT_ROOT = "target" + File.separator + "classes" + File.separator
 			+ "examples" + File.separator + "odf";
 	public static final String ODF10_RNG_FILE_NAME = "OpenDocument-strict-schema-v1.0-os.rng";
 	public static final String ODF11_RNG_FILE_NAME = "OpenDocument-strict-schema-v1.1.rng";
-	public static final String ODF12_RNG_FILE_NAME = "OpenDocument-v1.2-cs01-schema.rng";
-	public static final String ODF12_SIGNATURE_RNG_FILE_NAME = "OpenDocument-v1.2-cs01-dsig-schema.rng";
-	public static final String ODF12_MANIFEST_RNG_FILE_NAME = "OpenDocument-v1.2-cs01-manifest-schema.rng";
-	public static String odf12RngFile;
-	public static String odf12SignatureRngFile;
-	public static String odf12ManifestRngFile;
-	public static String odf11RngFile;
-	public static String odf10RngFile;
+	public static final String ODF12_RNG_FILE_NAME = "OpenDocument-v1.2-os-schema.rng";
+	public static final String ODF12_SIGNATURE_RNG_FILE_NAME = "OpenDocument-v1.2-os-dsig-schema.rng";
+	public static final String ODF12_MANIFEST_RNG_FILE_NAME = "OpenDocument-v1.2-os-manifest-schema.rng";
+	static String odf12RngFile;
+	static String odf12SignatureRngFile;
+	static String odf12ManifestRngFile;
+	static String odf11RngFile;
+	static String odf10RngFile;
 	private static String mConfigFile;
+	private static final String REFERENCE_OUTPUT_FILES_TEMPLATE = "dom-output-files.vm";
+	private static final String REFERENCE_OUTPUT_FILES = "target" + File.separator + "reference-output-files.xml";
+	private static final String PYTHON_OUTPUT_FILES_TEMPLATE = "dom-output-files.vm";
+	private static final String PYTHON_OUTPUT_FILES = "target" + File.separator + "python-output-files.xml";
+
 	private static final String DOM_OUTPUT_FILES_TEMPLATE = "dom-output-files.vm";
 	private static final String DOM_OUTPUT_FILES = "target" + File.separator + "dom-output-files.xml";
 	private static final String PKG_OUTPUT_FILES_TEMPLATE = "pkg-output-files.vm";
@@ -127,38 +136,48 @@ public class OdfHelper {
 		mConfigFile = configFile;
 	}
 	
-	static {
-		odfDomResourceDir = INPUT_ROOT + File.separator + "odfdom-java" + File.separator + "dom";
-		odfPkgResourceDir = INPUT_ROOT + File.separator + "odfdom-java" + File.separator + "pkg";
+	static {		
+		odfDomResourceDir = TEST_INPUT_ROOT + File.separator + "odfdom-java" + File.separator +
"dom";
+		odfPkgResourceDir = TEST_INPUT_ROOT + File.separator + "odfdom-java" + File.separator +
"pkg";
+		odfPythonResourceDir = TEST_INPUT_ROOT + File.separator + "odfdom-python";
+		odfReferenceResourceDir = TEST_INPUT_ROOT + File.separator + "odf-reference";
 		odf12SignatureRngFile = INPUT_ROOT + File.separator + ODF12_SIGNATURE_RNG_FILE_NAME;
 		odf12ManifestRngFile = INPUT_ROOT + File.separator + ODF12_MANIFEST_RNG_FILE_NAME;
 		odf12RngFile = INPUT_ROOT + File.separator + ODF12_RNG_FILE_NAME;
 		odf11RngFile = INPUT_ROOT + File.separator + ODF11_RNG_FILE_NAME;
 		odf10RngFile = INPUT_ROOT + File.separator + ODF10_RNG_FILE_NAME;
 		outputRoot = "target";
-		mConfigFile = INPUT_ROOT + File.separator + "config.xml";		
+		mConfigFile = TEST_INPUT_ROOT + File.separator + "config.xml";		
 	}
 
 	public void start() throws Exception{
 		LOG.info("Starting code generation:");
 		initialize();
+		
+		// ODF 1.2 Code Generation
 		fillTemplates(odfDomResourceDir, mOdf12Root, DOM_OUTPUT_FILES_TEMPLATE, DOM_OUTPUT_FILES);
 		fillTemplates(odfPkgResourceDir, mOdf12SignatureRoot, PKG_OUTPUT_FILES_TEMPLATE, PKG_OUTPUT_FILES);
 		fillTemplates(odfPkgResourceDir, mOdf12ManifestRoot, PKG_OUTPUT_FILES_TEMPLATE, PKG_OUTPUT_FILES);
 	}
 	
 	public static void main(String[] args) throws Exception {
-		initialize();
-		fillTemplates(INPUT_ROOT + File.separator + "odf-reference", mOdf12Root, DOM_OUTPUT_FILES_TEMPLATE,
DOM_OUTPUT_FILES);
-		fillTemplates(odfDomResourceDir, mOdf12Root, DOM_OUTPUT_FILES_TEMPLATE, DOM_OUTPUT_FILES);
-		fillTemplates(INPUT_ROOT + File.separator +"odfdom-python", mOdf12Root, DOM_OUTPUT_FILES_TEMPLATE,
DOM_OUTPUT_FILES);
-		fillTemplates(odfPkgResourceDir, mOdf12SignatureRoot, PKG_OUTPUT_FILES_TEMPLATE, PKG_OUTPUT_FILES);
+		LOG.info("Starting code generation:");		
+		initialize();		
+		
+		// ODF 1.2 HTML Reference (yet without BNF nor images)
+		fillTemplates(odfReferenceResourceDir, mOdf12Root, REFERENCE_OUTPUT_FILES_TEMPLATE, REFERENCE_OUTPUT_FILES);
+		// ODF 1.2 Python (The generated Python source is from a former colleague and might not
work any longer..)
+		fillTemplates(odfPythonResourceDir,	   mOdf12Root, PYTHON_OUTPUT_FILES_TEMPLATE, PYTHON_OUTPUT_FILES);
	
+
+		// ODF 1.2 Code Generation
+		fillTemplates(odfDomResourceDir, mOdf12Root, DOM_OUTPUT_FILES_TEMPLATE, DOM_OUTPUT_FILES);
			
 		fillTemplates(odfPkgResourceDir, mOdf12ManifestRoot, PKG_OUTPUT_FILES_TEMPLATE, PKG_OUTPUT_FILES);
+		fillTemplates(odfPkgResourceDir, mOdf12SignatureRoot, PKG_OUTPUT_FILES_TEMPLATE, PKG_OUTPUT_FILES);
 	}
 
 	private static void initialize() throws Exception{
+		LOG.info("Starting initilization..");
 		// calling MSV to parse the ODF 1.2 DSIG RelaxNG, returning a tree
-		System.out.println(new File(odf12SignatureRngFile).getAbsolutePath());
 		mOdf12SignatureRoot = loadSchema(new File(odf12SignatureRngFile));
 		// calling MSV to parse the ODF 1.2 Manifest RelaxNG, returning a tree
 		mOdf12ManifestRoot = loadSchema(new File(odf12ManifestRngFile));
@@ -184,6 +203,7 @@ public class OdfHelper {
 		mOdfModel = new OdfModel(elementStyleFamiliesMap, attributeDefaultMap);
 		// Needed for the base classes - common attributes are being moved into the base classes
 		mJavaModel = new SourceCodeModel(mOdf12SchemaModel, mOdf12SignatureSchemaModel, mOdf12ManifestSchemaModel,
mOdfModel, elementToBaseNameMap, datatypeValueAndConversionMap);
+		LOG.info("Finished initilization..");
 	}
 
 	private static void fillTemplates(String sourceDir, Expression root, String outputRuleTemplate,
String outputRuleFile) throws Exception {

Propchange: incubator/odf/trunk/generator/schema2template/src/main/resources/documentation/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Jan 16 22:38:07 2013
@@ -0,0 +1 @@
+.~lock.WorkInProgress-RelaxNGPatterns.odt#

Modified: incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odf-reference/dom-output-files.vm
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odf-reference/dom-output-files.vm?rev=1434455&r1=1434454&r2=1434455&view=diff
==============================================================================
--- incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odf-reference/dom-output-files.vm
(original)
+++ incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odf-reference/dom-output-files.vm
Wed Jan 16 22:38:07 2013
@@ -18,7 +18,6 @@
 ## under the License.
 ##
 ##################################################################
-
 <?xml version="1.0" encoding="UTF-8"?>
 ## Template to create the list of artefacts which are to be generated
 ##

Modified: incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-python/dom-output-files.vm
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-python/dom-output-files.vm?rev=1434455&r1=1434454&r2=1434455&view=diff
==============================================================================
--- incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-python/dom-output-files.vm
(original)
+++ incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-python/dom-output-files.vm
Wed Jan 16 22:38:07 2013
@@ -18,7 +18,6 @@
 ## under the License.
 ##
 ##################################################################
-
 <?xml version="1.0" encoding="UTF-8"?>
 ## Template to create the list of artefacts which are to be generated
 ##

Added: incubator/odf/trunk/generator/schema2template/src/test/java/schema2template/example/ExampleGenerationTest.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/generator/schema2template/src/test/java/schema2template/example/ExampleGenerationTest.java?rev=1434455&view=auto
==============================================================================
--- incubator/odf/trunk/generator/schema2template/src/test/java/schema2template/example/ExampleGenerationTest.java
(added)
+++ incubator/odf/trunk/generator/schema2template/src/test/java/schema2template/example/ExampleGenerationTest.java
Wed Jan 16 22:38:07 2013
@@ -0,0 +1,46 @@
+/**
+ * **********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
+ *
+ * Copyright 2009, 2010 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Use is subject to license terms.
+ *
+ * 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. You can also
+ * obtain a copy of the License at http://odftoolkit.org/docs/license.txt
+ *
+ * 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 schema2template.example;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.junit.Test;
+import org.junit.Assert;
+import schema2template.example.odf.OdfHelper;
+
+public class ExampleGenerationTest {
+
+	/**
+	 * Test: It should be able to generate all examples without a failure.
+	 */
+	@Test
+	public void testAllExampleGenerations() {
+		try {
+			OdfHelper.main(null);
+		} catch (Exception ex) {
+			Logger.getLogger(ExampleGenerationTest.class.getName()).log(Level.SEVERE, null, ex);
+			Assert.fail(ex.toString());
+		}
+	}
+}

Copied: incubator/odf/trunk/generator/schema2template/src/test/java/schema2template/example/odf/PuzzlePieceTest.java
(from r1433703, incubator/odf/trunk/generator/schema2template/src/test/java/schema2template/PuzzlePieceTest.java)
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/generator/schema2template/src/test/java/schema2template/example/odf/PuzzlePieceTest.java?p2=incubator/odf/trunk/generator/schema2template/src/test/java/schema2template/example/odf/PuzzlePieceTest.java&p1=incubator/odf/trunk/generator/schema2template/src/test/java/schema2template/PuzzlePieceTest.java&r1=1433703&r2=1434455&rev=1434455&view=diff
==============================================================================
--- incubator/odf/trunk/generator/schema2template/src/test/java/schema2template/PuzzlePieceTest.java
(original)
+++ incubator/odf/trunk/generator/schema2template/src/test/java/schema2template/example/odf/PuzzlePieceTest.java
Wed Jan 16 22:38:07 2013
@@ -19,7 +19,7 @@
  * limitations under the License.
  *
  ************************************************************************/
-package schema2template;
+package schema2template.example.odf;
 
 import com.sun.msv.grammar.Expression;
 import java.io.BufferedReader;
@@ -36,7 +36,6 @@ import schema2template.model.PuzzlePiece
 import schema2template.model.PuzzlePieceSet;
 import org.junit.Assert;
 import org.junit.Ignore;
-import schema2template.example.odf.OdfHelper;
 import schema2template.model.MSVExpressionIterator;
 
 public class PuzzlePieceTest {
@@ -45,9 +44,9 @@ public class PuzzlePieceTest {
 	private static final String OUTPUT_DUMP_ODF10 = "target" + File.separator + "odf10-msvtree.dump";
 	private static final String OUTPUT_DUMP_ODF11 = "target" + File.separator + "odf11-msvtree.dump";
 	private static final String OUTPUT_DUMP_ODF12 = "target" + File.separator + "odf12-msvtree.dump";
-	private static final String OUTPUT_REF_ODF10 = TEST_INPUT_ROOT + File.separator + "odf10-msvtree.ref";
-	private static final String OUTPUT_REF_ODF11 = TEST_INPUT_ROOT + File.separator + "odf11-msvtree.ref";
-	private static final String OUTPUT_REF_ODF12 = TEST_INPUT_ROOT + File.separator + "odf12-msvtree.ref";
+	private static final String OUTPUT_REF_ODF10 = TEST_REFERENCE_DIR + File.separator + "odf10-msvtree.ref";
+	private static final String OUTPUT_REF_ODF11 = TEST_REFERENCE_DIR + File.separator + "odf11-msvtree.ref";
+	private static final String OUTPUT_REF_ODF12 = TEST_REFERENCE_DIR + File.separator + "odf12-msvtree.ref";
 	private static final int ODF12_ELEMENT_DUPLICATES = 7;
 	private static final int ODF12_ATTRIBUTE_DUPLICATES = 134;
 
@@ -218,5 +217,5 @@ public class PuzzlePieceTest {
 			LOG.info("********************");
 			Assert.fail(errorMsg);
 		}
-	}
+	}	
 }



Mime
View raw message