You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by ce...@apache.org on 2005/02/09 19:08:25 UTC
svn commit: r153098 - in xmlbeans/trunk:
docs/guide/conGettingStartedwithXMLBeans.html
docs/guide/conSelectingXMLwithXQueryPathXPath.html
test/src/misc/checkin/SamplesRunner.java
Author: cezar
Date: Wed Feb 9 10:08:24 2005
New Revision: 153098
URL: http://svn.apache.org/viewcvs?view=rev&rev=153098
Log:
Contributed by:Yana Kadiyska. Fixing guide for new XQuery syntax. Adding an automated test for samples
Added:
xmlbeans/trunk/test/src/misc/checkin/SamplesRunner.java
Modified:
xmlbeans/trunk/docs/guide/conGettingStartedwithXMLBeans.html
xmlbeans/trunk/docs/guide/conSelectingXMLwithXQueryPathXPath.html
Modified: xmlbeans/trunk/docs/guide/conGettingStartedwithXMLBeans.html
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/docs/guide/conGettingStartedwithXMLBeans.html?view=diff&r1=153097&r2=153098
==============================================================================
--- xmlbeans/trunk/docs/guide/conGettingStartedwithXMLBeans.html (original)
+++ xmlbeans/trunk/docs/guide/conGettingStartedwithXMLBeans.html Wed Feb 9 10:08:24 2005
@@ -430,7 +430,7 @@
* the namespace prefix that's used in the query expression; the second
* declares the expression itself.
*/
-String nsText = "declare namespace po = 'http://openuri.org/easypo'";
+String nsText = "declare namespace po = 'http://openuri.org/easypo'; ";
String pathText = "$this/po:purchase-order/po:line-item[po:price <= 20.00]";
String queryText = nsText + pathText;
Modified: xmlbeans/trunk/docs/guide/conSelectingXMLwithXQueryPathXPath.html
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/docs/guide/conSelectingXMLwithXQueryPathXPath.html?view=diff&r1=153097&r2=153098
==============================================================================
--- xmlbeans/trunk/docs/guide/conSelectingXMLwithXQueryPathXPath.html (original)
+++ xmlbeans/trunk/docs/guide/conSelectingXMLwithXQueryPathXPath.html Wed Feb 9 10:08:24 2005
@@ -102,7 +102,7 @@
the XPath expression in this way:
<pre>
String queryExpression =
- "declare namespace xq='http://openuri.org/selectPath'" +
+ "declare namespace xq='http://openuri.org/selectPath'; " +
"$this/xq:employees/xq:employee/xq:phone[contains(., '(206)')]"
</pre>
<p>Notice in the query expression that the variable <span class="langinline">$this</span>
@@ -179,7 +179,7 @@
{
// Declare the namespace that will be used.
String xqNamespace =
- "declare namespace xq='http://openuri.org/selectPath'";
+ "declare namespace xq='http://openuri.org/selectPath'; ";
// Insert a cursor and move it to the first element.
XmlCursor cursor = xml.newCursor();
Added: xmlbeans/trunk/test/src/misc/checkin/SamplesRunner.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/misc/checkin/SamplesRunner.java?view=auto&rev=153098
==============================================================================
--- xmlbeans/trunk/test/src/misc/checkin/SamplesRunner.java (added)
+++ xmlbeans/trunk/test/src/misc/checkin/SamplesRunner.java Wed Feb 9 10:08:24 2005
@@ -0,0 +1,130 @@
+/* Copyright 2004 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 misc.checkin;
+
+import junit.framework.TestCase;
+
+import tools.ant.*;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Target;
+import org.apache.tools.ant.BuildException;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.util.ArrayList;
+
+/**
+ * Date: Feb 8, 2005
+ * Time: 11:30:24 AM
+ */
+public class SamplesRunner
+ extends TestCase
+{
+
+
+ protected void setUp()
+ throws Exception
+ {
+ proj = new Project();
+ proj.setName("Samples Task Tests");
+ XMLBEANS_HOME = proj.getBaseDir().getAbsolutePath();
+ samples = new ArrayList();
+ runSampleTest = new SamplesBuildFileTest("S2J Ant Task Wrapper");
+ }
+
+ public void testSamples()
+ throws Exception
+ {
+ loadSampleDirs(new File("./samples"));
+ ArrayList exceptions = new ArrayList();
+ for (int i = 0; i < samples.size(); i++)
+ {
+
+ runSampleTest.call_samples_task(
+ ((File) samples.get(i)).getAbsolutePath()
+ , "test");
+ BuildException e;
+ if ((e = runSampleTest.getAnyExceptions()) != null)
+ {
+ exceptions.add(((File) samples.get(i)).getAbsolutePath());
+ exceptions.add(e.getException());
+ }
+ }
+ if (exceptions.size() != 0)
+ throw new RuntimeException(getMessageFromExceptions(exceptions));
+
+ }
+
+ private String getMessageFromExceptions(ArrayList ex)
+ {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < ex.size(); i += 2)
+ {
+ sb.append("\n\nFILE:" + (String) ex.get(i));
+ sb.append(
+ "\n **Error: " + ((BuildException) ex.get(i + 1)).getMessage());
+ }
+ return sb.toString();
+ }
+
+ private void loadSampleDirs(File dir)
+ {
+ assert dir != null && dir.exists();
+ File[] files = dir.listFiles(new BuildFilter());
+ assert files.length == 1;
+ samples.add(files[0]);
+
+ }
+
+ private class BuildFilter
+ implements FilenameFilter
+ {
+ public boolean accept(File file, String name)
+ {
+ return name.equals("build.xml");
+ }
+ }
+
+ private class SamplesBuildFileTest
+ extends BuildFileTest
+ {
+ public SamplesBuildFileTest(String name)
+ {
+ super(name);
+ }
+
+ public void call_samples_task(String projectPath, String taskName)
+ {
+ configureProject(projectPath);
+ Project proj = getProject();
+ proj.setProperty("xmlbeans.home", XMLBEANS_HOME);
+ executeTarget(proj.getDefaultTarget());
+ return;
+ }
+
+ public BuildException getAnyExceptions()
+ throws Exception
+ {
+ return this.getBuildException();
+ }
+ }
+
+ ArrayList samples;
+ Project proj;
+ Target target;
+ String XMLBEANS_HOME;
+ SamplesBuildFileTest runSampleTest;
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org