Convert old tests to use xtest harness.
1.1 --- a/schema2beans/build.xml Mon Jun 17 16:18:33 2002 +0000
1.2 +++ b/schema2beans/build.xml Wed Jun 19 00:18:25 2002 +0000
1.3 @@ -116,4 +116,7 @@
1.4 </javadoc>
1.5 </target>
1.6
1.7 + <target name="test" depends="jars">
1.8 + <ant dir="test" antfile="build.xml" />
1.9 + </target>
1.10 </project>
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/schema2beans/test/build-unit.xml Wed Jun 19 00:18:25 2002 +0000
2.3 @@ -0,0 +1,218 @@
2.4 +<?xml version="1.0"?>
2.5 +<!--
2.6 + Sun Public License Notice
2.7 +
2.8 +The contents of this file are subject to the Sun Public License
2.9 +Version 1.0 (the "License"). You may not use this file except in
2.10 +compliance with the License. A copy of the License is available at
2.11 +http://www.sun.com/
2.12 +
2.13 +The Original Code is NetBeans. The Initial Developer of the Original
2.14 +Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
2.15 +Microsystems, Inc. All Rights Reserved.
2.16 +-->
2.17 +
2.18 +<project name="schema2beans logging tests compilers and executors" basedir="." default="all">
2.19 +
2.20 +<!-- =================== -->
2.21 + <!-- Setting classpathes -->
2.22 + <!-- =================== -->
2.23 +
2.24 + <target name="set_classpath" depends="prepare-compile-classpath,prepare-codetest-classpath">
2.25 +
2.26 + <!-- During filling classpathes remember that only <module>/test
2.27 + is checked out during automated test execution so <module>/src
2.28 + or <module>/netbeans isn't available. If you need to add something
2.29 + from <module>/src or <module>/netbeans to classpath,
2.30 + look below to "setting advanced claspathes" part of this target.
2.31 + -->
2.32 +
2.33 + <!-- List of directories where jars will be searched. -->
2.34 + <property name="xtest.extra.jars.path" location="../netbeans/modules"/>
2.35 +
2.36 + <!-- This jars is used for compilation, execution codetests and also for
2.37 + execution ide tests (it means this classpath will be mounted in repository).
2.38 + You can also write only name of jar or zip file, not in which directory it is and
2.39 + this file will be searched in directories specified by property xtest.extra.jars.path
2.40 + example: <property name="xtest.extra.jars" value="jemmy.jar;jelly.jar"/>
2.41 + -->
2.42 + <property name="xtest.extra.jars" value="schema2beans.jar"/>
2.43 +
2.44 + <!-- These jars will be copied to directory ${netebans.home}/lib/ext.
2.45 + Again you can write only name of jar or zip file, not in which directory it is and
2.46 + this file will be searched in directories specified by property xtest.extra.jars.path
2.47 + example: <property name="xtest.extra.jars.ide" value="jdbc_driver1.zip;jdbcd_river2.jar"/>
2.48 + -->
2.49 + <property name="xtest.extra.jars.ide" value=""/>
2.50 +
2.51 +
2.52 + <!-- Arguments which will be added into commandline of starting IDE.
2.53 + example: <property name="xtest.ide.commandline.suffix" value="-J-Dxtest.useclassloader=org.openidex.util"/>
2.54 + -->
2.55 + <property name="xtest.ide.commandline.suffix" value=""/>
2.56 +
2.57 + <!-- =========================== -->
2.58 + <!-- Setting avanced classpathes -->
2.59 + <!-- =========================== -->
2.60 +
2.61 + <!-- If you need to add something from <module>/src or <module>/netbeans
2.62 + to classpath use target prepare-compile-classpath or prepare-codetest-classpath
2.63 + which fills path according to property xtest.source.location. This property
2.64 + can have values "src" (compilation and execution against sources), "jar" (compil.
2.65 + and execut. against jars) or "ide" (compil. and execut. against installed IDE).
2.66 + "ide" mode is used during automated test execution so it has to be always supported.
2.67 + -->
2.68 +
2.69 + <!-- This classpath is beside jars in xtest.extra.jars also used for compilation,
2.70 + but it depends on property xtest.source.location which classpath will be used.
2.71 + Fill apropriate classpathes in targets "${xtest.source.location}compile-classath". -->
2.72 + <property name="compiletest.classpath" refid="compiletest.classpath"/>
2.73 +
2.74 + <!-- This classpath is beside jars in xtest.extra.jars also used for execution codetests,
2.75 + but it depends on property xtest.source.location which classpath will be used.
2.76 + Fill apropriate classpathes in targets "${xtest.source.location}test-classath". -->
2.77 + <property name="codetest.classpath" refid="codetest.classpath"/>
2.78 +
2.79 + </target>
2.80 +
2.81 + <!-- ========= -->
2.82 + <!-- Compilers -->
2.83 + <!-- ========= -->
2.84 +
2.85 + <target name="unit-compiler" depends="set_classpath">
2.86 + <ant dir="." antfile="${xtest.module_harness.antfile}"
2.87 + target="buildtests">
2.88 + <!-- This property contains directories to compile.
2.89 + These directories will be compiled separately.
2.90 + example: <property name="compile.srcdir" value="unit/src1;unit/src2"/>
2.91 + -->
2.92 + <property name="compile.srcdir" value="unit/src"/>
2.93 + <property name="compile.excludes" value="**/data/**"/>
2.94 + </ant>
2.95 + </target>
2.96 +
2.97 + <!-- ========= -->
2.98 + <!-- Executors -->
2.99 + <!-- ========= -->
2.100 +
2.101 + <!-- This target is executed from test-executor in newly created Project -->
2.102 + <!-- Name of this task is defined in cfg-xxx.xml -->
2.103 + <!-- This target executes standalone tests -->
2.104 + <target name="runcodetest" depends="set_classpath">
2.105 + <ant dir="." antfile="${xtest.module_harness.antfile}"
2.106 + target="test">
2.107 + <property name="xtest.exectype" value="code"/>
2.108 + </ant>
2.109 + </target>
2.110 +
2.111 +
2.112 + <!-- =============================================================
2.113 + Following targets are for "advanced" users who needs more
2.114 + compilacated classpathes, which depends on way of execution.
2.115 + ============================================================= -->
2.116 +
2.117 + <!-- this "switch" will decide how to create classpath -->
2.118 + <target name="which-classpath">
2.119 + <condition property="jarcode.classpath">
2.120 + <equals arg1="${xtest.source.location}" arg2="jar"/>
2.121 + </condition>
2.122 + <condition property="srccode.classpath">
2.123 + <equals arg1="${xtest.source.location}" arg2="src"/>
2.124 + </condition>
2.125 + <condition property="idecode.classpath">
2.126 + <equals arg1="${xtest.source.location}" arg2="ide"/>
2.127 + </condition>
2.128 + </target>
2.129 +
2.130 + <!-- ========================= -->
2.131 + <!-- Classpath for compilation -->
2.132 + <!-- ========================= -->
2.133 +
2.134 + <target name="prepare-compile-classpath"
2.135 + depends="jarcompile-classpath,srccompile-classpath,idecompile-classpath"/>
2.136 +
2.137 + <target name="jarcompile-classpath" depends="which-classpath" if="jarcode.classpath">
2.138 + <echo message="Using jars classpath for compilation."/>
2.139 + <!-- this classpath will be used for compiling tests against jars -->
2.140 + <path id="compiletest.classpath">
2.141 + <!-- If you need e.g. openide.jar, write this:
2.142 + <pathelement location="../netbeans/lib/openide.jar"/>
2.143 + -->
2.144 + <pathelement location="../schema2beans.jar"/>
2.145 + </path>
2.146 + </target>
2.147 +
2.148 + <target name="srccompile-classpath" depends="which-classpath" if="srccode.classpath">
2.149 + <echo message="Using srcs classpath for compilation."/>
2.150 + <!-- this classpath will be used for compiling tests against sources -->
2.151 + <path id="compiletest.classpath">
2.152 + <!-- If you need e.g. openide.jar, write this:
2.153 + <pathelement location="../netbeans/lib/openide.jar"/>
2.154 + If you need e.g. sources of your tested module, write this:
2.155 + <pathelement location="../src"/>
2.156 + -->
2.157 + <pathelement location="../src"/>
2.158 + </path>
2.159 + </target>
2.160 +
2.161 + <!-- we're not using this, because mymodule is not a part of IDE :-) -->
2.162 + <target name="idecompile-classpath" depends="which-classpath" if="idecode.classpath">
2.163 + <echo message="Using IDE classpath for compilation."/>
2.164 + <!-- this classpath will be used for compiling tests against installed IDE -->
2.165 + <path id="compiletest.classpath">
2.166 + <!-- If you need e.g. openide.jar, write this:
2.167 + <pathelement location="${netbeans.home}/lib/openide.jar"/>
2.168 + If you need e.g. your tested module, write this:
2.169 + <pathelement location="${netbeans.home}/modules/somemodule.jar"/>
2.170 + -->
2.171 + <pathelement location="../schema2beans.jar"/>
2.172 + </path>
2.173 + </target>
2.174 +
2.175 + <!-- ================================== -->
2.176 + <!-- Classpath for execution code tests -->
2.177 + <!-- ================================== -->
2.178 +
2.179 + <target name="prepare-codetest-classpath"
2.180 + depends="jartest-classpath,srctest-classpath,idetest-classpath"/>
2.181 +
2.182 + <target name="jartest-classpath" depends="which-classpath" if="jarcode.classpath">
2.183 + <echo message="Using jars classpath."/>
2.184 + <!-- this classpath will be used for executing tests against jars -->
2.185 + <path id="codetest.classpath">
2.186 + <!-- If you need e.g. openide.jar, write this:
2.187 + <pathelement location="../netbeans/lib/openide.jar"/>
2.188 + -->
2.189 + <pathelement location="../schema2beans.jar"/>
2.190 + </path>
2.191 + </target>
2.192 +
2.193 + <target name="srctest-classpath" depends="which-classpath" if="srccode.classpath">
2.194 + <echo message="Using srcs classpath."/>
2.195 + <!-- this classpath will be used for executing tests against sources -->
2.196 + <path id="codetest.classpath">
2.197 + <!-- If you need e.g. openide.jar, write this:
2.198 + <pathelement location="../netbeans/lib/openide.jar"/>
2.199 + If you need e.g. sources of your tested module, write this:
2.200 + <pathelement location="../src"/>
2.201 + -->
2.202 + <pathelement location="../src"/>
2.203 + </path>
2.204 + </target>
2.205 +
2.206 +
2.207 + <target name="idetest-classpath" depends="which-classpath" if="idecode.classpath">
2.208 + <echo message="Using IDE classpath."/>
2.209 + <!-- this classpath will be used for executing tests against installed IDE -->
2.210 + <path id="codetest.classpath">
2.211 + <!-- If you need e.g. openide.jar, write this:
2.212 + <pathelement location="${netbeans.home}/lib/openide.jar"/>
2.213 + If you need e.g. your tested module, write this:
2.214 + <pathelement location="${netbeans.home}/modules/somemodule.jar"/>
2.215 + -->
2.216 + <pathelement location="../schema2beans.jar"/>
2.217 + </path>
2.218 + </target>
2.219 +
2.220 +
2.221 +</project>
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/schema2beans/test/build.xml Wed Jun 19 00:18:25 2002 +0000
3.3 @@ -0,0 +1,95 @@
3.4 +<?xml version="1.0"?>
3.5 +<!--
3.6 + Sun Public License Notice
3.7 +
3.8 +The contents of this file are subject to the Sun Public License
3.9 +Version 1.0 (the "License"). You may not use this file except in
3.10 +compliance with the License. A copy of the License is available at
3.11 +http://www.sun.com/
3.12 +
3.13 +The Original Code is NetBeans. The Initial Developer of the Original
3.14 +Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
3.15 +Microsystems, Inc. All Rights Reserved.
3.16 +-->
3.17 +
3.18 +<project name="schema2beans tests build script" basedir="." default="all">
3.19 +
3.20 + <!-- Ant property. Value 'ignore' means that system classpath is ignored
3.21 + and only classpath specified in build file is used. -->
3.22 + <property name="build.sysclasspath" value="ignore"/>
3.23 +
3.24 + <!-- Points to directory with IDE to test-->
3.25 + <property name="netbeans.home" location="../../../../nbbuild/netbeans"/>
3.26 +
3.27 + <!-- Name of tested module -->
3.28 + <property name="xtest.module" value="schema2beans"/>
3.29 +
3.30 + <!-- Home of XTest -->
3.31 + <property name="xtest.home" location="../../xtest"/>
3.32 +
3.33 + <!-- default testtypes, attributes used when no value is supplied from command line -->
3.34 + <property name="xtest.testtype" value="unit"/>
3.35 + <property name="xtest.attribs" value="all,code,ide"/>
3.36 +
3.37 + <!-- Points to antfile with module's harness.
3.38 + Targets from that antfile is called from this build.xml -->
3.39 + <property name="xtest.module_harness.antfile" location="${xtest.home}/lib/module_harness.xml"/>
3.40 +
3.41 + <!-- Says how to create classpath for compilation and for execution code tests by default.
3.42 + Can have values src, jar, ide -->
3.43 + <property name="xtest.source.location" value="src"/>
3.44 +
3.45 +
3.46 +
3.47 + <!-- ============ -->
3.48 + <!-- Main targets -->
3.49 + <!-- ============ -->
3.50 +
3.51 + <target name="all" depends="runtests"/>
3.52 +
3.53 + <!-- This calls target which will call compilers according to cfg file.
3.54 + You should not change this target unless you realy know what you are doing -->
3.55 + <target name="buildtests">
3.56 + <ant dir="." antfile="${xtest.module_harness.antfile}"
3.57 + target="compiler-launcher"/>
3.58 + </target>
3.59 +
3.60 + <!-- This calls common clean process. -->
3.61 + <!-- You can write your own if you need something special -->
3.62 + <target name="cleantests">
3.63 + <ant dir="." antfile="${xtest.module_harness.antfile}"
3.64 + target="cleantests"/>
3.65 + </target>
3.66 +
3.67 + <!-- This target runs tests. You should not change this -->
3.68 + <!-- target unless you realy know what you are doing -->
3.69 + <target name="runtests" depends="buildtests">
3.70 + <echo message="Module: Running tests for ${xtest.module}, testtype ${xtest.testtype}, attribs=${xtest.attribs}"/>
3.71 + <ant dir="." antfile="${xtest.module_harness.antfile}"
3.72 + target="runtests"/>
3.73 + </target>
3.74 +
3.75 + <!-- This target is executed from test-executor in newly created Project -->
3.76 + <!-- Name of this task is defined in cfg-xxx.xml -->
3.77 + <target name="test_report">
3.78 + <ant dir="." antfile="${xtest.module_harness.antfile}"
3.79 + target="test_report"/>
3.80 + </target>
3.81 +
3.82 + <target name="cleanresults">
3.83 + <ant dir="." antfile="${xtest.module_harness.antfile}"
3.84 + target="cleanresults"/>
3.85 + </target>
3.86 +
3.87 + <target name="realclean" depends="cleantests,cleanresults">
3.88 + <ant dir="." antfile="${xtest.module_harness.antfile}"
3.89 + target="realclean"/>
3.90 + </target>
3.91 +
3.92 + <target name="printconfig">
3.93 + <echo message="Default config is testtype: ${xtest.testtype}, attributes: ${xtest.attribs}."/>
3.94 + </target>
3.95 +
3.96 +
3.97 +</project>
3.98 +
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/schema2beans/test/cfg-unit.xml Wed Jun 19 00:18:25 2002 +0000
4.3 @@ -0,0 +1,78 @@
4.4 +<?xml version="1.0" encoding="UTF-8"?>
4.5 +<!DOCTYPE mconfig PUBLIC "-//NetBeans//DTD XTest cfg 1.0//EN" "http://www.netbeans.org/dtds/xtest-cfg-1_0.dtd">
4.6 +<!--
4.7 + Sun Public License Notice
4.8 +
4.9 +The contents of this file are subject to the Sun Public License
4.10 +Version 1.0 (the "License"). You may not use this file except in
4.11 +compliance with the License. A copy of the License is available at
4.12 +http://www.sun.com/
4.13 +
4.14 +The Original Code is NetBeans. The Initial Developer of the Original
4.15 +Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
4.16 +Microsystems, Inc. All Rights Reserved.
4.17 +-->
4.18 +
4.19 +<!--
4.20 + These classes are excluded by default (defined in build.xml):
4.21 + "**/*Suite.class"
4.22 + "**/*$$*.class"
4.23 + "**/data/**"
4.24 + "**/hidden/**"
4.25 + "**/*Hidden.*"
4.26 + "**/*Hid.*"
4.27 +-->
4.28 +
4.29 +<mconfig name="schema2beans unit test config">
4.30 +
4.31 + <!-- testbag with all schema2beans tests running in code mode (i.e. in standard JVM)
4.32 + use ant runtests -Dxtest.attribs=stable,code to run this testbag -->
4.33 + <testbag testattribs="all and code" executor="code" name="all tests (no ide)" >
4.34 + <testset dir="unit/src">
4.35 + <patternset>
4.36 + <include name="TestMain.class"/>
4.37 + </patternset>
4.38 + </testset>
4.39 + </testbag>
4.40 +
4.41 + <!-- testbag with tests which does not fail, use ant runtests -Dxtest.attribs=stable,code -->
4.42 +<!--
4.43 + <testbag testattribs="stable and code" executor="code" name="stable tests (no ide)">
4.44 + <testset dir="unit/src">
4.45 + <patternset>
4.46 + <include name="myorg/*.class"/>
4.47 + <include name="HelloWorldTest.class"/>
4.48 + <exclude name="HelloWorldTest.class/testGreeting2"/>
4.49 + </patternset>
4.50 + </testset>
4.51 + </testbag> -->
4.52 +
4.53 + <!-- testbag with failing test (just one method) -->
4.54 + <testbag testattribs="failing" executor="code" name="failing tests (no ide)" resultsprocessor="unit">
4.55 + <testset dir="unit/src">
4.56 + <patternset>
4.57 + <include name="HelloWorldTest.class/testGreeting2"/>
4.58 + </patternset>
4.59 + </testset>
4.60 + </testbag>
4.61 +
4.62 +
4.63 + <testbag testattribs="empty" executor="code" name="empty">
4.64 + <testset dir="unit/src">
4.65 + <patternset/>
4.66 + </testset>
4.67 + </testbag>
4.68 + <!-- code excecutor - use this one if you plan to run your tests in standard
4.69 + JVM. You can also write your own executor, which will
4.70 + then call this one. It is handy when some servers (e.g. rmi registry)
4.71 + have to be started before tests are run and stopped after
4.72 + the run. -->
4.73 + <executor name="code" antfile="build-unit.xml" target="runcodetest"/>
4.74 +
4.75 + <compiler name="unit-compiler" antfile="build-unit.xml" target="unit-compiler" default="true"/>
4.76 +
4.77 + <!-- standard results processor - currently there is only one results processor
4.78 + in XTest -->
4.79 + <resultsprocessor name="unit" antfile="build.xml" target="test_report" default="true"/>
4.80 +
4.81 +</mconfig>
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/schema2beans/test/unit/src/TestMain.java Wed Jun 19 00:18:25 2002 +0000
5.3 @@ -0,0 +1,230 @@
5.4 +/*
5.5 + * Sun Public License Notice
5.6 + *
5.7 + * The contents of this file are subject to the Sun Public License
5.8 + * Version 1.0 (the "License"). You may not use this file except in
5.9 + * compliance with the License. A copy of the License is available at
5.10 + * http://www.sun.com/
5.11 + *
5.12 + * The Original Code is NetBeans. The Initial Developer of the Original
5.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
5.14 + * Microsystems, Inc. All Rights Reserved.
5.15 + */
5.16 +
5.17 +import java.io.*;
5.18 +import java.net.URL;
5.19 +import java.util.*;
5.20 +import junit.framework.*;
5.21 +import org.netbeans.junit.*;
5.22 +
5.23 +import org.netbeans.modules.schema2beans.*;
5.24 +
5.25 +public class TestMain extends NbTestCase {
5.26 +
5.27 + public TestMain(java.lang.String testName) {
5.28 + super(testName);
5.29 + }
5.30 +
5.31 + public static void main(java.lang.String[] args) {
5.32 + junit.textui.TestRunner.run(suite());
5.33 + }
5.34 +
5.35 + public static Test suite() {
5.36 + TestSuite suite = new NbTestSuite(TestMain.class);
5.37 +
5.38 + return suite;
5.39 + }
5.40 +
5.41 + public void testBook() throws IOException, Schema2BeansException, InterruptedException {
5.42 + generalTest("TestBook");
5.43 + }
5.44 +
5.45 + public void testEvents() throws IOException, Schema2BeansException, InterruptedException {
5.46 + generalTest("TestEvents");
5.47 + }
5.48 +
5.49 + public void testMerge() throws IOException, Schema2BeansException, InterruptedException {
5.50 + generalTest("TestMerge");
5.51 + }
5.52 +
5.53 + public void testAttr() throws IOException, Schema2BeansException, InterruptedException {
5.54 + generalTest("TestAttr");
5.55 + }
5.56 +
5.57 + public void testMdd() throws IOException, Schema2BeansException, InterruptedException {
5.58 + generalTest("TestMdd");
5.59 + }
5.60 +
5.61 + public void testValid() throws IOException, Schema2BeansException, InterruptedException {
5.62 + generalTest("TestValid");
5.63 + }
5.64 +
5.65 + public void testFind() throws IOException, Schema2BeansException, InterruptedException {
5.66 + generalTest("TestFind");
5.67 + }
5.68 +
5.69 + public void testVeto() throws IOException, Schema2BeansException, InterruptedException {
5.70 + generalTest("TestVeto");
5.71 + }
5.72 +
5.73 + public void testContrivedApp() throws IOException, Schema2BeansException, InterruptedException {
5.74 + generalTest("TestContrivedApp");
5.75 + }
5.76 +
5.77 + public void testEncoding() throws IOException, Schema2BeansException, InterruptedException {
5.78 + generalTest("TestEncoding");
5.79 + }
5.80 +
5.81 + public void testExceptions() throws IOException, Schema2BeansException, InterruptedException {
5.82 + generalTest("TestExceptions");
5.83 + }
5.84 +
5.85 + public void testEmpty() throws IOException, Schema2BeansException, InterruptedException {
5.86 + generalTest("TestEmpty");
5.87 + }
5.88 +
5.89 + public void generalTest(String testName) throws IOException, Schema2BeansException, InterruptedException {
5.90 + String testOnly = System.getProperty("TestMain.testOnly");
5.91 + if (testOnly != null && !testOnly.equals(testName))
5.92 + return;
5.93 + try {
5.94 + System.out.println("Starting "+testName);
5.95 + File workDir = getWorkDir();
5.96 + GenBeans.Config config = new GenBeans.Config();
5.97 + config.setAuto(true);
5.98 + config.setStandalone(false);
5.99 + //config.setTraceParse(true);
5.100 + //config.setTraceGen(true);
5.101 + //config.setThrowErrors(true);
5.102 + InputStream dtdIn = new FileInputStream(new File(dataDir, testName+".dtd"));
5.103 + System.out.println("workDir="+workDir.toString());
5.104 + config.setDTDIn(dtdIn);
5.105 + try {
5.106 + InputStream mddIn = new FileInputStream(new File(dataDir, testName+".mdd"));
5.107 + System.out.println("Found mdd file");
5.108 + config.setMDDIn(mddIn);
5.109 + } catch (FileNotFoundException e) {
5.110 + // It's okay if there is no mdd file present
5.111 + }
5.112 + config.setRootDir(workDir.toString());
5.113 + //config.setPackagePath();
5.114 + //config.setMessageOut(getRef());
5.115 + ref("Calling GenBeans.doIt");
5.116 + GenBeans.doIt(config);
5.117 +
5.118 + ref("Compiling");
5.119 + String cmd = "javac -classpath "+workDir.toString()+":"+dataDir.toString()+":"+theClassPath+" "+dataDir.toString()+"/"+testName+".java";
5.120 + int result = runCommand(cmd);
5.121 + ref("Finished compiling: "+result);
5.122 +
5.123 + cmd = "java -classpath "+workDir.toString()+":"+dataDir.toString()+":"+theClassPath+" "+testName+" "+dataDir.toString()+"/";
5.124 + result = runCommand(cmd);
5.125 + ref("Finished running "+testName+": "+result);
5.126 +
5.127 + System.out.println("Finished.\n");
5.128 + } catch (IOException e) {
5.129 + ref(e.getMessage());
5.130 + e.printStackTrace();
5.131 + } catch (Schema2BeansException e) {
5.132 + ref(e.getMessage());
5.133 + e.printStackTrace();
5.134 + }
5.135 + }
5.136 +
5.137 + private int runCommand(String cmd) throws java.io.IOException, java.lang.InterruptedException {
5.138 + System.out.println(cmd);
5.139 + Process proc = Runtime.getRuntime().exec(cmd);
5.140 + Writer out = new BufferedWriter(new OutputStreamWriter(getRef(), "UTF-8"));
5.141 + Thread outThread = new Thread(new InputMonitor("out: ", proc.getInputStream(), out));
5.142 + outThread.start();
5.143 + Thread errThread = new Thread(new InputMonitor("err: ", proc.getErrorStream(), out));
5.144 + errThread.start();
5.145 +
5.146 + int result = proc.waitFor();
5.147 + out.flush();
5.148 +
5.149 + // Wait upto 32s for that thread to finish before going on.
5.150 + outThread.join(32000);
5.151 + errThread.join(32000);
5.152 + return result;
5.153 + }
5.154 +
5.155 + static class InputMonitor implements Runnable {
5.156 + private String prefix;
5.157 + private InputStream is;
5.158 + private Writer out;
5.159 +
5.160 + public InputMonitor(String prefix, InputStream is, Writer out) {
5.161 + this.prefix = prefix;
5.162 + this.is = is;
5.163 + this.out = out;
5.164 + }
5.165 +
5.166 + public void run() {
5.167 + try {
5.168 + int c;
5.169 + boolean freshLine = true;
5.170 + while ((c = is.read()) != -1) {
5.171 + if (freshLine) {
5.172 + out.write(prefix);
5.173 + freshLine = false;
5.174 + }
5.175 + char ch = (char)c;
5.176 + if (ch == '\n')
5.177 + freshLine = true;
5.178 + out.write(ch);
5.179 + }
5.180 + out.flush();
5.181 + } catch (java.io.IOException e) {
5.182 + try {
5.183 + out.write(e.getMessage());
5.184 + } catch (java.io.IOException e2) {
5.185 + // try only once.
5.186 + }
5.187 + }
5.188 + }
5.189 + }
5.190 +
5.191 + protected File dataDir;
5.192 + protected String theClassPath = "";
5.193 +
5.194 + protected void setUp() {
5.195 + String packageName = "";
5.196 + if (null != getClass().getPackage())
5.197 + packageName = getClass().getPackage().getName();
5.198 +
5.199 + // when running this code inside IDE, getResource method returns URL in NBFS
5.200 + // formta, so we need to convert it to filename
5.201 + // when running this code inside code mode, nothing happens
5.202 + String dataDirName = NbTestCase.convertNBFSURL(TestMain.class.getResource("data"));
5.203 + dataDir = new File(dataDirName);
5.204 + System.out.println("dataDirName="+dataDirName);
5.205 +
5.206 + theClassPath += classPathEntryFromURL(org.netbeans.modules.schema2beans.GenBeans.class);
5.207 + theClassPath += ":" + classPathEntryFromURL(org.w3c.dom.Node.class);
5.208 + theClassPath += ":" + classPathEntryFromURL(javax.xml.parsers.DocumentBuilderFactory.newInstance().getClass());
5.209 + System.out.println("classpath="+theClassPath);
5.210 + }
5.211 +
5.212 + private String classPathEntryFromURL(Class cls) {
5.213 + String shortName = cls.getName().substring(1+cls.getName().lastIndexOf('.'));
5.214 + URL url = cls.getResource(shortName + ".class");
5.215 + String file = url.getFile();
5.216 + if (url.getProtocol().equals("jar")) {
5.217 + // example: file = 'file:/usr/local/j2sdkee1.3.1/lib/j2ee.jar!/org/w3c/dom/Node.class'
5.218 + String jarFile = file.substring(file.indexOf(':')+1);
5.219 + jarFile = jarFile.substring(0, jarFile.indexOf('!'));
5.220 + return jarFile;
5.221 + } else if (url.getProtocol().equals("file")) {
5.222 + // example: file='/home/cliffwd/cvs/dublin/nb_all/schema2beans/src/org/netbeans/modules/schema2beans/GenBeans.class'
5.223 + String result = file.substring(0, file.length() - cls.getName().length() - 6);
5.224 + return result;
5.225 + } else {
5.226 + return file;
5.227 + }
5.228 + }
5.229 +
5.230 + protected void tearDown() {
5.231 + compareReferenceFiles();
5.232 + }
5.233 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/schema2beans/test/unit/src/data/BaseTest.java Wed Jun 19 00:18:25 2002 +0000
6.3 @@ -0,0 +1,177 @@
6.4 +
6.5 +import java.io.*;
6.6 +import java.util.*;
6.7 +
6.8 +import org.w3c.dom.*;
6.9 +
6.10 +import javax.xml.parsers.DocumentBuilder;
6.11 +import javax.xml.parsers.DocumentBuilderFactory;
6.12 +
6.13 +import org.netbeans.modules.schema2beans.BaseBean;
6.14 +
6.15 +public class BaseTest
6.16 +{
6.17 + String testName;
6.18 + String testMsg;
6.19 + String documentDir = null;
6.20 +
6.21 + Document doc;
6.22 +
6.23 + OutputStream out;
6.24 +
6.25 + BaseTest()
6.26 + {
6.27 + this.testName = this.getClass().getName();
6.28 + this.out = System.out;
6.29 + this.doc = null;
6.30 + }
6.31 +
6.32 + String getDocumentName() {
6.33 + return getClass().getName()+".xml";
6.34 + }
6.35 +
6.36 + String getFullDocumentName() {
6.37 + if (documentDir == null)
6.38 + return getDocumentName();
6.39 + return documentDir + getDocumentName();
6.40 + }
6.41 +
6.42 + void setDocumentDir(String dir) {
6.43 + documentDir = dir;
6.44 + }
6.45 +
6.46 + void readDocument()
6.47 + {
6.48 + this.readDocument(getDocumentName());
6.49 + }
6.50 +
6.51 + void readDocument(String name)
6.52 + {
6.53 + /*
6.54 + * The other way to create the object graph:
6.55 + *
6.56 + * DDFactory.register("book", "book.Book");
6.57 + * book = DDFactory.create(in, "book");
6.58 + *
6.59 + */
6.60 + if (documentDir != null)
6.61 + name = documentDir + name;
6.62 + try
6.63 + {
6.64 + FileInputStream in = new FileInputStream(name);
6.65 +
6.66 + out("creating the DOM document");
6.67 + DocumentBuilderFactory dbf =
6.68 + DocumentBuilderFactory.newInstance();
6.69 + DocumentBuilder db = dbf.newDocumentBuilder();
6.70 + this.doc = db.parse(in);
6.71 + in.close();
6.72 + }
6.73 + catch (Throwable t)
6.74 + {
6.75 + t.printStackTrace();
6.76 + throw new RuntimeException("DD creation failed: " +
6.77 + t.getMessage());
6.78 + }
6.79 +
6.80 + if (doc == null)
6.81 + {
6.82 + err("doc is null");
6.83 + return;
6.84 + }
6.85 + }
6.86 +
6.87 + void setTest(String msg)
6.88 + {
6.89 + this.testMsg = msg;
6.90 + }
6.91 +
6.92 + void setOutputStream(OutputStream out)
6.93 + {
6.94 + this.out = out;
6.95 + }
6.96 +
6.97 + void println(String s)
6.98 + {
6.99 + try
6.100 + {
6.101 + this.out.write(s.getBytes());
6.102 + this.out.write((int)'\n');
6.103 + }
6.104 + catch(Exception e)
6.105 + {
6.106 + throw new RuntimeException("outputStream.write failed: " +
6.107 + e.getMessage());
6.108 + }
6.109 + }
6.110 +
6.111 + void err(String s)
6.112 + {
6.113 + println("### Error - " + s);
6.114 + }
6.115 +
6.116 + void out(String s, String s2)
6.117 + {
6.118 + println(this.testName + " - " + s + "\n" + s2);
6.119 + }
6.120 +
6.121 + void out(String s)
6.122 + {
6.123 + println(this.testName + " - " + s);
6.124 + }
6.125 +
6.126 + void out(int value)
6.127 + {
6.128 + println(this.testName + " - " + value);
6.129 + }
6.130 +
6.131 + void out(BaseBean bean) {
6.132 + bean.dumpXml();
6.133 + }
6.134 +
6.135 + void check(boolean success, String str)
6.136 + {
6.137 + if (success)
6.138 + println(this.testName + " " + this.testMsg +
6.139 + ((str != null)?" "+str:"") + " -> OK");
6.140 + else
6.141 + println(this.testName + " " + this.testMsg +
6.142 + ((str != null)?" "+str:"") + " -> FAILED");
6.143 + }
6.144 +
6.145 + void check(boolean success)
6.146 + {
6.147 + this.check(success, null);
6.148 + }
6.149 +
6.150 +
6.151 + int getKMemUsage() {
6.152 + Runtime rt = Runtime.getRuntime();
6.153 +
6.154 + try {
6.155 + rt.gc();
6.156 + Thread.sleep(2000L);
6.157 + rt.gc();
6.158 + Thread.sleep(2000L);
6.159 + rt.gc();
6.160 + Thread.sleep(2000L);
6.161 + rt.gc();
6.162 + } catch(Exception e) {
6.163 + }
6.164 +
6.165 + long used = rt.totalMemory()-rt.freeMemory();
6.166 + return (int)(used/1024L);
6.167 + }
6.168 +
6.169 + void printMemUsage() {
6.170 + out("Memory usage: " + getKMemUsage() + "k");
6.171 + }
6.172 +
6.173 +
6.174 + public void run()
6.175 + throws Exception
6.176 + {
6.177 + throw new RuntimeException("This run() method should be subclassed");
6.178 + }
6.179 +}
6.180 +
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/schema2beans/test/unit/src/data/TestAttr.dtd Wed Jun 19 00:18:25 2002 +0000
7.3 @@ -0,0 +1,53 @@
7.4 +<!-- The following DTD is a simple view of a book:
7.5 +book
7.6 + index
7.7 + +
7.8 + word
7.9 + #PCDATA
7.10 + page
7.11 + #PCDATA
7.12 + chapter+
7.13 + comment?
7.14 + #PCDATA
7.15 + paragraph*
7.16 + #PCDATA
7.17 + summary?
7.18 + #PCDATA
7.19 +
7.20 + good
7.21 + EMPTY
7.22 +-->
7.23 +
7.24 +<!ELEMENT summary (#PCDATA)>
7.25 +
7.26 +<!ELEMENT book (summary?, chapter+, index+, available)>
7.27 +
7.28 +<!ELEMENT available EMPTY>
7.29 +
7.30 +<!ELEMENT index (word, ref+)>
7.31 +
7.32 +<!ELEMENT ref (page, line)>
7.33 +
7.34 +<!ELEMENT word (#PCDATA)>
7.35 +
7.36 +<!ELEMENT line (#PCDATA)>
7.37 +
7.38 +<!ELEMENT page (#PCDATA)>
7.39 +
7.40 +<!ELEMENT chapter (comment?, paragraph*)>
7.41 +
7.42 +<!ELEMENT paragraph (#PCDATA)>
7.43 +
7.44 +<!ELEMENT comment (#PCDATA)>
7.45 +
7.46 +<!ATTLIST book good (yes, no) 'yes'>
7.47 +<!ATTLIST summary length CDATA #REQUIRED>
7.48 +<!ATTLIST summary lang CDATA #IMPLIED>
7.49 +<!ATTLIST summary size CDATA #FIXED '12'>
7.50 +<!ATTLIST chapter title CDATA #IMPLIED>
7.51 +<!ATTLIST index color CDATA #IMPLIED>
7.52 +<!ATTLIST index cross-ref (yes no) "no">
7.53 +<!ATTLIST index glossary CDATA #FIXED "nope">
7.54 +<!ATTLIST word freq CDATA #IMPLIED>
7.55 +
7.56 +
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/schema2beans/test/unit/src/data/TestAttr.java Wed Jun 19 00:18:25 2002 +0000
8.3 @@ -0,0 +1,463 @@
8.4 +/*
8.5 + * TestAttr - test the attribute features
8.6 + *
8.7 + * TestAttr.dtd and TestAttr.xml has to be kept in sync with this test.
8.8 + */
8.9 +
8.10 +import java.io.*;
8.11 +import java.util.*;
8.12 +import org.w3c.dom.*;
8.13 +
8.14 +import org.netbeans.modules.schema2beans.*;
8.15 +import java.beans.*;
8.16 +import book.*;
8.17 +
8.18 +
8.19 +public class TestAttr extends BaseTest
8.20 +{
8.21 + public static void main(String[] argv) {
8.22 + BaseTest o = new TestAttr();
8.23 + if (argv.length > 0)
8.24 + o.setDocumentDir(argv[0]);
8.25 + try {
8.26 + o.run();
8.27 + } catch (Exception e) {
8.28 + e.printStackTrace();
8.29 + System.exit(1);
8.30 + }
8.31 + System.exit(0);
8.32 + }
8.33 +
8.34 + public class MyListener implements PropertyChangeListener
8.35 + {
8.36 + GraphManager gm;
8.37 + String listenerName;
8.38 + Object oldValue;
8.39 + Object newValue;
8.40 + String propertyName;
8.41 + Object source;
8.42 + boolean mute;
8.43 + boolean remove;
8.44 +
8.45 + public MyListener(BaseBean bean)
8.46 + {
8.47 + this.listenerName = bean.name();
8.48 + gm = bean.graphManager();
8.49 + this.remove = false;
8.50 + this.mute = false;
8.51 + out("new listener for " + this.listenerName);
8.52 + }
8.53 +
8.54 + public void reset()
8.55 + {
8.56 + this.oldValue = null;
8.57 + this.newValue = null;
8.58 + this.propertyName = null;
8.59 + this.source = null;
8.60 + }
8.61 +
8.62 + public void propertyChange(PropertyChangeEvent e)
8.63 + {
8.64 + if (this.mute)
8.65 + return;
8.66 +
8.67 + String k;
8.68 + this.oldValue = e.getOldValue();
8.69 + this.newValue = e.getNewValue();
8.70 + this.propertyName = e.getPropertyName();
8.71 + this.source = e.getSource();
8.72 +
8.73 + String n = this.propertyName;
8.74 + int i = gm.getPropertyIndex(n);
8.75 + String pn;
8.76 +
8.77 + if (gm.isAttribute(n))
8.78 + {
8.79 + pn = "Attr:" + gm.getPropertyName(n);
8.80 + if (i != -1)
8.81 + pn += "[" + i + "]";
8.82 + pn += "." + gm.getAttributeName(n);
8.83 + }
8.84 + else
8.85 + {
8.86 + pn = "Prop:" + gm.getPropertyName(n);
8.87 + if (i != -1)
8.88 + pn += "[" + i + "]";
8.89 + }
8.90 +
8.91 + if (this.newValue == null)
8.92 + k = "Rmv";
8.93 + else
8.94 + if (this.oldValue == null)
8.95 + k = "Add";
8.96 + else
8.97 + k = "Chg";
8.98 +
8.99 + out("<" + k + " Lnr:" + this.listenerName + " Evt:" + n +
8.100 + " Src:" + this.source.getClass().getName() + ">");
8.101 +
8.102 + if (remove)
8.103 + {
8.104 + out("<" + pn + " - ParentName: " +
8.105 + gm.getPropertyParentName(n) + ">");
8.106 + }
8.107 + else
8.108 + {
8.109 + BaseBean bb = gm.getPropertyParent(n);
8.110 + String nm = "<no class>";
8.111 +
8.112 + if (bb != null)
8.113 + nm = bb.getClass().getName();
8.114 +
8.115 + out("<" + pn + " - ParentName: " +
8.116 + gm.getPropertyParentName(n) +
8.117 + " - ParentClass:" + nm + ">");
8.118 + }
8.119 +
8.120 + //out("received " + this.oldValue + "/" + this.newValue + "/" +
8.121 + // this.propertyName);
8.122 + }
8.123 +
8.124 + public void removeMode()
8.125 + {
8.126 + this.remove = true;
8.127 + }
8.128 +
8.129 + public Object oldValue()
8.130 + {
8.131 + return this.oldValue;
8.132 + }
8.133 +
8.134 + public String stringOldValue()
8.135 + {
8.136 + if (this.oldValue == null)
8.137 + return "<null>";
8.138 + else
8.139 + return this.oldValue.toString();
8.140 + }
8.141 +
8.142 + public Object newValue()
8.143 + {
8.144 + return this.newValue;
8.145 + }
8.146 +
8.147 + public String stringNewValue()
8.148 + {
8.149 + if (this.newValue == null)
8.150 + return "<null>";
8.151 + else
8.152 + return this.newValue.toString();
8.153 + }
8.154 +
8.155 + public String name()
8.156 + {
8.157 + return this.propertyName;
8.158 + }
8.159 +
8.160 + public void mute(boolean mute)
8.161 + {
8.162 + this.mute = mute;
8.163 + }
8.164 +
8.165 + public String toString()
8.166 + {
8.167 + return this.name() + " raised from source " +
8.168 + this.source.getClass().getName();
8.169 + }
8.170 + }
8.171 +
8.172 + private MyListener l1;
8.173 +
8.174 + public void run()
8.175 + throws Exception
8.176 + {
8.177 + Book book;
8.178 +
8.179 + this.readDocument();
8.180 + out("creating the bean graph");
8.181 + //out(DDFactory.XmlToString(doc));
8.182 + book = Book.createGraph(doc);
8.183 + out("bean graph created");
8.184 +
8.185 + l1 = new MyListener(book);
8.186 + book.addPropertyChangeListener(l1);
8.187 + l1.mute(true);
8.188 +
8.189 + //out(book.dumpBeanNode());
8.190 + //out(((BaseBean)book.clone()).dumpBeanNode());
8.191 + //((BaseBean)book.clone()).write(System.out);
8.192 +
8.193 + // Get/Change an enum attribute on the root
8.194 + {
8.195 + String s1, s2;
8.196 +
8.197 + setTest("get enum attribute from root");
8.198 + s1 = book.getAttributeValue("Good");
8.199 + check(s1.equals("no"));
8.200 + out("Changing to another value - should get an event");
8.201 + s2 = "yes";
8.202 + l1.mute(false);
8.203 + book.setAttributeValue("good", s2);
8.204 + l1.mute(false);
8.205 + s1 = book.getAttributeValue("good");
8.206 + check(s1.equals(s2));
8.207 + out("Book DOM content should be yes", book.dumpDomNode(0));
8.208 + out("Changing to a non-enum value (should get an exception)");
8.209 + boolean gotException = false;
8.210 + try
8.211 + {
8.212 + book.setAttributeValue("good", "maybe");
8.213 + }
8.214 + catch(IllegalArgumentException e)
8.215 + {
8.216 + check(true, "got the proper exception");
8.217 + gotException = true;
8.218 + }
8.219 + catch(Exception e)
8.220 + {
8.221 + check(false, "got the wrong exception type: " +
8.222 + e.getClass().getName() + ", it should be " +
8.223 + "IllegalArgumentException");
8.224 + gotException = true;
8.225 + }
8.226 + if (!gotException)
8.227 + check(false, "didnt' get any exception");
8.228 + }
8.229 +
8.230 + // Get/Change attributes on a non-root element
8.231 + {
8.232 + String s1, s2;
8.233 +
8.234 + setTest("get #REQUIRED attribute");
8.235 + s1 = book.getAttributeValue("Summary", "length");
8.236 + check(s1.equals("132"));
8.237 + out("Changing to another value");
8.238 + s2 = "133";
8.239 + book.setAttributeValue("Summary", "length", s2);
8.240 + s1 = book.getAttributeValue("Summary", "length");
8.241 + check(s1.equals(s2));
8.242 +
8.243 + setTest("get #IMPLIED attribute");
8.244 + s1 = book.getAttributeValue("Summary", "lang");
8.245 + check(s1.equals("en"));
8.246 + out("Setting a new value");
8.247 + s2 = "fr";
8.248 + book.setAttributeValue("Summary", "lang", s2);
8.249 + s1 = book.getAttributeValue("Summary", "lang");
8.250 + check(s1.equals(s2));
8.251 + s2 = "";
8.252 + book.setAttributeValue("Summary", "lang", s2);
8.253 + s1 = book.getAttributeValue("Summary", "lang");
8.254 + check(s1.equals(s2));
8.255 + book.setAttributeValue("Summary", "lang", null);
8.256 + s1 = book.getAttributeValue("Summary", "lang");
8.257 + check(s1 == null);
8.258 + s2 = "fr";
8.259 + book.setAttributeValue("Summary", "lang", s2);
8.260 +
8.261 +
8.262 + setTest("get #FIXED attribute");
8.263 + s1 = book.getAttributeValue("Summary", "size");
8.264 + check(s1.equals("12"));
8.265 + out("Summary DOM content should be 133/fr/12",
8.266 + book.dumpDomNode(1));
8.267 + out("Setting a new value (should get an exception)");
8.268 + s2 = "15";
8.269 + boolean gotException = false;
8.270 + try
8.271 + {
8.272 + book.setAttributeValue("Summary", "size", s2);
8.273 + }
8.274 + catch(IllegalStateException e)
8.275 + {
8.276 + check(true, "got the proper exception");
8.277 + gotException = true;
8.278 + }
8.279 + catch(Exception e)
8.280 + {
8.281 + check(false, "got the wrong exception type: " +
8.282 + e.getClass().getName() + ", it should be " +
8.283 + "IllegalStateException");
8.284 + gotException = true;
8.285 + }
8.286 + if (!gotException)
8.287 + check(false, "didnt' get any exception");
8.288 + }
8.289 +
8.290 + // Set from non defined
8.291 + {
8.292 + String s1, s2, s3, s4;
8.293 +
8.294 + setTest("get/set non set #IMPLIED attribute");
8.295 + Chapter c = book.getChapter(0);
8.296 + out("Chapter DOM should have no attribute",
8.297 + c.dumpDomNode(0));
8.298 + s1 = c.getAttributeValue("title");
8.299 + check(s1 == null);
8.300 + s2 = "My chapter";
8.301 + c.setAttributeValue("title", s2);
8.302 + s1 = c.getAttributeValue("title");
8.303 + check(s1.equals(s2));
8.304 + out("Chapter DOM should have one title attribute",
8.305 + c.dumpDomNode(0));
8.306 +
8.307 + // Check that we access the same from the bean itself
8.308 + // and from the parent that contains the attribute.
8.309 + setTest("access from parent & current bean");
8.310 + s1 = book.getAttributeValue("Chapter", 0, "title");
8.311 + s2 = c.getAttributeValue("title");
8.312 + check(s1.equals(s2));
8.313 +
8.314 + // Mix the elements, the attributes should follow
8.315 + setTest("attribute stick with elt when mixing");
8.316 + s1 = book.getAttributeValue("Chapter", 0, "title");
8.317 + s2 = book.getAttributeValue("Chapter", 1, "title");
8.318 + check(s1 != null);
8.319 + check(s2 == null);
8.320 + Chapter[] ac = book.getChapter();
8.321 + c = ac[1];
8.322 + ac[1] = ac[0];
8.323 + ac[0] = c;
8.324 + book.setChapter(ac);
8.325 + // Attribute of 0 should be what 1 was, and 1 what 0 was
8.326 + s3 = book.getAttributeValue("Chapter", 0, "title");
8.327 + s4 = book.getAttributeValue("Chapter", 1, "title");
8.328 + check(s3 == null);
8.329 + check(s4.equals(s1));
8.330 +
8.331 + setTest("get/set non set #IMPLIED attribute (idx != 0)");
8.332 + c = book.getChapter(2);
8.333 + out("Chapter DOM should have no attribute",
8.334 + c.dumpDomNode(0));
8.335 + s1 = c.getAttributeValue("title");
8.336 + check(s1 == null);
8.337 + s2 = "My chapter2";
8.338 + c.setAttributeValue("title", s2);
8.339 + s1 = c.getAttributeValue("title");
8.340 + check(s1.equals(s2));
8.341 + out("Chapter DOM should have one title attribute",
8.342 + c.dumpDomNode(0));
8.343 + }
8.344 +
8.345 + // Test unknown attribute
8.346 + {
8.347 + String s1;
8.348 +
8.349 + setTest("get unknown attribute");
8.350 + boolean gotException = false;
8.351 + try
8.352 + {
8.353 + s1 = book.getAttributeValue("Summary", "Splash");
8.354 + }
8.355 + catch(IllegalArgumentException e)
8.356 + {
8.357 + check(true, "got the proper exception");
8.358 + gotException = true;
8.359 + }
8.360 + catch(Exception e)
8.361 + {
8.362 + check(false, "got the wrong exception type: " +
8.363 + e.getClass().getName() + ", it should be " +
8.364 + "IllegalArgumentException");
8.365 + gotException = true;
8.366 + }
8.367 + if (!gotException)
8.368 + check(false, "didnt' get any exception");
8.369 + }
8.370 +
8.371 + // Add a brand new element with attributes
8.372 + {
8.373 + String s1, s2;
8.374 + setTest("add a brand new element with default attributes");
8.375 + Index idx = new Index();
8.376 + int i = book.addIndex(idx);
8.377 + s1 = idx.getAttributeValue("cross-ref");
8.378 + s2 = book.getAttributeValue("Index", i, "CrossRef");
8.379 + check(s1.equals(s2));
8.380 + out("should have created: cross-ref & glossary, and not color",
8.381 + book.dumpDomNode(1));
8.382 +
8.383 + // Add a brand new element, setting attributes
8.384 + setTest("add a brand new element, setting attributes");
8.385 + idx = new Index();
8.386 + idx.setAttributeValue("cross-ref", "yes");
8.387 + idx.setAttributeValue("color", "blue");
8.388 + idx.setWord("my word");
8.389 + idx.setAttributeValue("word", "freq", "123");
8.390 + book.setIndex(i, idx);
8.391 + out("should have created: cross-ref (yes), glossary (nope) " +
8.392 + "and color (blue)", book.dumpDomNode(3));
8.393 + }
8.394 +
8.395 + // Dynamic parsing of the graph of beans
8.396 + {
8.397 + BaseBean root = book.graphManager().getBeanRoot();
8.398 + this.parseGraph(root, "\t");
8.399 + }
8.400 +
8.401 + out("Make sure that default attributes get set.");
8.402 + Book anotherBook = Book.createGraph();
8.403 + anotherBook.setSummary("This is my summary.");
8.404 + out(anotherBook);
8.405 +
8.406 + /*setTest("get non set attribute");
8.407 + book.setAttributeValue("Summary", "lang", "");
8.408 + ByteArrayOutputStream bout = new ByteArrayOutputStream();
8.409 + book.write(bout);
8.410 + out("--------------------");
8.411 + out(bout.toString());
8.412 +
8.413 + book.setAttributeValue("Summary", "lang", null);
8.414 + String s1 = book.getAttributeValue("Summary", "lang");
8.415 + check(s1 == null);
8.416 + bout = new ByteArrayOutputStream();
8.417 + book.write(bout);
8.418 + out("---- 222 ----------------");
8.419 + out(bout.toString());
8.420 + */
8.421 + }
8.422 +
8.423 + void parseGraph(BaseBean bean, String indent)
8.424 + {
8.425 + if (bean == null)
8.426 + return;
8.427 +
8.428 + out(indent + "[" + bean.name() + "]");
8.429 +
8.430 + BaseProperty[] props = bean.listProperties();
8.431 + for (int i=0; i<props.length; i++)
8.432 + {
8.433 + BaseProperty p = props[i];
8.434 + String name = p.getName();
8.435 +
8.436 + // Prop name & size
8.437 + String str = "<" + name;
8.438 + if (p.isIndexed())
8.439 + str += "[" + p.size() + "]";
8.440 + str += "> - " + p.getPropertyClass();
8.441 + out(indent + str);
8.442 +
8.443 + // Prop attributes
8.444 + String[] attrs = p.getAttributeNames();
8.445 + for (int j=0; j<attrs.length; j++)
8.446 + out(indent + " a:" + attrs[j]);
8.447 +
8.448 + // recurse
8.449 + if (p.isBean() && p.isIndexed())
8.450 + {
8.451 + BaseBean[] ba = (BaseBean[])bean.getValues(name);
8.452 + for (int k=0; k<ba.length; k++)
8.453 + this.parseGraph(ba[k], indent + "\t");
8.454 + }
8.455 + else
8.456 + if (p.isBean())
8.457 + {
8.458 + BaseBean b = (BaseBean)bean.getValue(name);
8.459 + this.parseGraph(b, indent + "\t");
8.460 + }
8.461 + }
8.462 + }
8.463 +}
8.464 +
8.465 +
8.466 +
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/schema2beans/test/unit/src/data/TestAttr.xml Wed Jun 19 00:18:25 2002 +0000
9.3 @@ -0,0 +1,66 @@
9.4 +<?xml version="1.0" encoding="ISO-8859-1"?>
9.5 +
9.6 +<book good="no">
9.7 + <summary size="12" lang="en" length="132">
9.8 + This book is about the life of a book spent between books who dreamed
9.9 + to meet a fairy who could transform it into an XML book and travel
9.10 + in an electronic boundary-less world.
9.11 + </summary>
9.12 + <chapter>
9.13 + <comment>
9.14 + First chapter.
9.15 + </comment>
9.16 + <paragraph>
9.17 + Once upon a time...
9.18 + </paragraph>
9.19 + <paragraph>
9.20 + And this is how the book met the fairy, and how all this
9.21 + story began.
9.22 + </paragraph>
9.23 + </chapter>
9.24 + <chapter>
9.25 + <paragraph>
9.26 + And the book lived a never ending happy life, read, copied
9.27 + and enjoyed by so many readers.
9.28 + </paragraph>
9.29 + </chapter>
9.30 + <chapter>
9.31 + <comment>
9.32 + Empty chapter
9.33 + </comment>
9.34 + </chapter>
9.35 + <index>
9.36 + <word>
9.37 + Good book
9.38 + </word>
9.39 + <ref>
9.40 + <page>
9.41 + 22
9.42 + </page>
9.43 + <line>
9.44 + 12
9.45 + </line>
9.46 + </ref>
9.47 + </index>
9.48 + <index>
9.49 + <word>
9.50 + E-Tool
9.51 + </word>
9.52 + <ref>
9.53 + <page>
9.54 + 5
9.55 + </page>
9.56 + <line>
9.57 + 15
9.58 + </line>
9.59 + </ref>
9.60 + <ref>
9.61 + <page>
9.62 + 29
9.63 + </page>
9.64 + <line>
9.65 + 31
9.66 + </line>
9.67 + </ref>
9.68 + </index>
9.69 +</book>
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/schema2beans/test/unit/src/data/TestBook.dtd Wed Jun 19 00:18:25 2002 +0000
10.3 @@ -0,0 +1,58 @@
10.4 +<!-- The following DTD is a simple view of a book:
10.5 +book
10.6 + index
10.7 + +
10.8 + word
10.9 + #PCDATA
10.10 + page
10.11 + #PCDATA
10.12 + chapter+
10.13 + comment?
10.14 + #PCDATA
10.15 + paragraph*
10.16 + #PCDATA
10.17 + summary?
10.18 + #PCDATA
10.19 +
10.20 + good
10.21 + EMPTY
10.22 +-->
10.23 +
10.24 +<!ELEMENT summary (#PCDATA)>
10.25 +
10.26 +<!ELEMENT book (index+, chapter+, summary?, good, available, extra)>
10.27 +
10.28 +<!ELEMENT good EMPTY>
10.29 +
10.30 +<!ELEMENT available EMPTY>
10.31 +
10.32 +<!ELEMENT index (word, ref+)>
10.33 +
10.34 +<!ELEMENT ref (page, line)>
10.35 +
10.36 +<!ELEMENT word (#PCDATA)>
10.37 +
10.38 +<!ELEMENT line (#PCDATA)>
10.39 +
10.40 +<!ELEMENT page (#PCDATA)>
10.41 +
10.42 +<!ELEMENT chapter (comment?, paragraph*, comment?)>
10.43 +
10.44 +<!ELEMENT paragraph (#PCDATA)>
10.45 +
10.46 +<!ELEMENT comment (#PCDATA)>
10.47 +
10.48 +<!ELEMENT extra ((size-cm | size-inches | size), color?, (weight-lb | weight-kg))>
10.49 +
10.50 +<!ELEMENT size-cm (#PCDATA)>
10.51 +
10.52 +<!ELEMENT size-inches (#PCDATA)>
10.53 +
10.54 +<!ELEMENT size (#PCDATA)>
10.55 +
10.56 +<!ELEMENT color (#PCDATA)>
10.57 +
10.58 +<!ELEMENT weight-lb (#PCDATA)>
10.59 +
10.60 +<!ELEMENT weight-kg (#PCDATA)>
10.61 +
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/schema2beans/test/unit/src/data/TestBook.java Wed Jun 19 00:18:25 2002 +0000
11.3 @@ -0,0 +1,704 @@
11.4 +/*
11.5 + * TestBook - test the basic features.
11.6 + *
11.7 + * The following test assumes that we know the content of the
11.8 + * graph as we get elements, add and change them. Therefore, the TestBook.xml
11.9 + * file and this java test should be kept in sync.
11.10 + *
11.11 + * Test the following:
11.12 + *
11.13 + * single String: get/set/remove/set/get
11.14 + * boolean (from true): get/set true/get/set false/get/set true/get
11.15 + * boolean (from false): get/set false/get/set true/get/set false/get
11.16 + * String[]: get/set (null & !null)/add/remove
11.17 + * Bean: remove/set(null)/create bean and graph of beans/set/add
11.18 + *
11.19 + */
11.20 +
11.21 +import java.io.*;
11.22 +import java.util.*;
11.23 +import org.w3c.dom.*;
11.24 +
11.25 +import org.netbeans.modules.schema2beans.*;
11.26 +import book.*;
11.27 +
11.28 +
11.29 +public class TestBook extends BaseTest {
11.30 + public static void main(String[] argv) {
11.31 + TestBook o = new TestBook();
11.32 + if (argv.length > 0)
11.33 + o.setDocumentDir(argv[0]);
11.34 + try {
11.35 + o.run();
11.36 + } catch (Exception e) {
11.37 + e.printStackTrace();
11.38 + System.exit(1);
11.39 + }
11.40 + System.exit(0);
11.41 + }
11.42 +
11.43 + public void run()
11.44 + throws Exception {
11.45 + Book book;
11.46 +
11.47 + this.readDocument();
11.48 +
11.49 + out("creating the bean graph");
11.50 + book = Book.createGraph(doc);
11.51 +
11.52 + // Check that we can read the graph an it is complete
11.53 + out("bean graph created");
11.54 +
11.55 + //out(book.toString());
11.56 + //out(book.clone().toString());
11.57 + //((BaseBean)book.clone()).write(System.out);
11.58 +
11.59 + //
11.60 + // Single string test
11.61 + //
11.62 +
11.63 + String s1, s2;
11.64 +
11.65 + // Get a String element and change it
11.66 + {
11.67 + setTest("single String - get/set");
11.68 + s1 = book.getSummary();
11.69 + s1 += "Some more dynamic notes on the summary.";
11.70 + book.setSummary(s1);
11.71 + s2 = book.getSummary();
11.72 + check(s1.equals(s2));
11.73 + }
11.74 +
11.75 + // Remove a final string element
11.76 + {
11.77 + setTest("single String - remove");
11.78 + book.setSummary(null);
11.79 + s2 = book.getSummary();
11.80 + check(s2==null);
11.81 + out("should not have a 'summary' element:",
11.82 + book.dumpDomNode("summary", 1));
11.83 + }
11.84 +
11.85 + // Adding a final string
11.86 + {
11.87 + setTest("single String - set new");
11.88 + book.setSummary(s1);
11.89 + s2 = book.getSummary();
11.90 + check(s1.equals(s2));
11.91 + out("should have a 'summary' element:",
11.92 + book.dumpDomNode("summary", 1));
11.93 + }
11.94 +
11.95 + //
11.96 + // Boolean test - from initial value true
11.97 + //
11.98 +
11.99 + {
11.100 + boolean b1, b2;
11.101 + setTest("boolean - get value (from true)");
11.102 + b1 = book.isGood();
11.103 + check(b1==true);
11.104 + out("should have a 'good' element:",
11.105 + book.dumpDomNode("good", 1));
11.106 +
11.107 + setTest("boolean - change to same value (true)");
11.108 + book.setGood(b1);
11.109 + check(b1==book.isGood());
11.110 + out("should still have a 'good' element:",
11.111 + book.dumpDomNode("good", 1));
11.112 +
11.113 + setTest("boolean - change to false");
11.114 + book.setGood(!b1);
11.115 + check(b1!=book.isGood());
11.116 + out("should not have a 'good' element:",
11.117 + book.dumpDomNode("good", 1));
11.118 +
11.119 + setTest("boolean - change back to true");
11.120 + book.setGood(b1);
11.121 + check(b1==book.isGood());
11.122 + out("should have a 'good' element:",
11.123 + book.dumpDomNode("good", 1));
11.124 + }
11.125 +
11.126 + //
11.127 + // Boolean test - from initial value false
11.128 + //
11.129 + {
11.130 + boolean b1, b2;
11.131 + setTest("boolean - get value (from false)");
11.132 + b1 = book.isAvailable();
11.133 + check(b1==false);
11.134 + out("should not have an 'available' element:",
11.135 + book.dumpDomNode("available", 1));
11.136 +
11.137 + setTest("boolean - change to same value (false)");
11.138 + book.setAvailable(b1);
11.139 + check(b1==book.isAvailable());
11.140 + out("should not have an 'available' element:",
11.141 + book.dumpDomNode("available", 1));
11.142 +
11.143 + setTest("boolean - change to true");
11.144 + book.setAvailable(!b1);
11.145 + check(b1!=book.isAvailable());
11.146 + out("should have now an 'available' element:",
11.147 + book.dumpDomNode("available", 1));
11.148 +
11.149 + setTest("boolean - change back to false");
11.150 + book.setAvailable(b1);
11.151 + check(b1==book.isAvailable());
11.152 + out("should not have an 'available' element:",
11.153 + book.dumpDomNode("available", 1));
11.154 + }
11.155 +
11.156 +
11.157 + //
11.158 + // Array of string test
11.159 + //
11.160 + // The tests are performed on the Paragraph string array,
11.161 + // member of the Chapter bean.
11.162 + // The book contains three chapter. There is one chapter
11.163 + // with no paragraph, one with one paragraph and one with
11.164 + // two paragraph. This convers the three cases: empty array,
11.165 + // array with only one element, and array with more than one
11.166 + // element.
11.167 + //
11.168 +
11.169 + {
11.170 + out("String[] - search for the string arrays");
11.171 + out("found " + book.sizeChapter() + " chapter in book");
11.172 + for (int i=0; i<book.sizeChapter(); i++) {
11.173 + Chapter c = book.getChapter(i);
11.174 + out("chapter " + (i+1) + " has " + c.sizeParagraph() +
11.175 + " paragraphs:", c.dumpDomNode("paragraph", 1));
11.176 + }
11.177 + }
11.178 +
11.179 + // Test array size = 0
11.180 + {
11.181 + Chapter c = null;
11.182 +
11.183 + setTest("String[0] - search for empty array");
11.184 + for (int i=0; i<book.sizeChapter(); i++) {
11.185 + Chapter c2 = book.getChapter(i);
11.186 + if (c2.sizeParagraph() == 0) {
11.187 + c = c2;
11.188 + break;
11.189 + }
11.190 + }
11.191 + check(c != null);
11.192 +
11.193 + int tmp[] = {-1, 0, 1, 999};
11.194 +
11.195 + // Check for out of bound exception
11.196 + for (int i=0; i<tmp.length; i++) {
11.197 + setTest("String[0] - out of bounds access [" + tmp[i] +
11.198 + "]");
11.199 + s1 = "This is a new paragraph";
11.200 + try {
11.201 + c.setParagraph(tmp[i], s1);
11.202 + check(false, "didn't get an exception");
11.203 + }
11.204 + catch(IndexOutOfBoundsException e) {
11.205 + check(true, "(IndexOutOfBoundsException)");
11.206 + }
11.207 + catch(Exception ee) {
11.208 + check(false, ee.getMessage());
11.209 + }
11.210 + }
11.211 +
11.212 + // Adding an element
11.213 + setTest("String[0] - add a string to the array");
11.214 + c.addParagraph(s1);
11.215 + if (c.sizeParagraph() != 1)
11.216 + err("array size != 1");
11.217 + s2 = c.getParagraph(0);
11.218 + check(s1.equals(s2));
11.219 + out("should contain one paragraph:",
11.220 + c.dumpDomNode("paragraph", 1));
11.221 +
11.222 + setTest("String[0] - add another string to the array");
11.223 + c.addParagraph(s1);
11.224 + if (c.sizeParagraph() != 2)
11.225 + err("array size != 2");
11.226 + s2 = c.getParagraph(1);
11.227 + check(s1.equals(s2));
11.228 + out("should contain two paragraphs:",
11.229 + c.dumpDomNode("paragraph", 1));
11.230 +
11.231 + setTest("String[0] - compare paragraphs");
11.232 + s1 = c.getParagraph(0);
11.233 + s2 = c.getParagraph(1);
11.234 + check(s1.equals(s2), "(same content)");
11.235 + check(s1 != s2, "(different instances)");
11.236 +
11.237 + setTest("String[0] - remove element");
11.238 + c.setParagraph(0, null);
11.239 + check(c.sizeParagraph() == 2);
11.240 + out("should contain one paragraph:",
11.241 + c.dumpDomNode("paragraph", 1));
11.242 +
11.243 + setTest("String[0] - access elements");
11.244 + s2 = c.getParagraph(0);
11.245 + check(s2 == null, "(first, should be null)");
11.246 + s2 = c.getParagraph(1);
11.247 + check(s2 != null, "(second, should be !null)");
11.248 +
11.249 + s1 = "This is another new paragraph";
11.250 + setTest("String[0] - set again first element");
11.251 + c.setParagraph(0, s1);
11.252 + check(c.sizeParagraph() == 2);
11.253 + out("should contain two paragraphs:",
11.254 + c.dumpDomNode("paragraph", 1));
11.255 +
11.256 + setTest("String[0] - removing all elements");
11.257 + s1 = c.getParagraph(1);
11.258 + int i1 = c.removeParagraph(s1);
11.259 + check(i1 == 1, "(removed correct index)");
11.260 + check(c.sizeParagraph() == 1, "(size is now 1)");
11.261 + s1 = c.getParagraph(0);
11.262 + int i2 = c.removeParagraph(s1);
11.263 + check(i2 == 0, "(removed correct index)");
11.264 + check(c.sizeParagraph() == 0, "(size is now 0)");
11.265 + out("should contain no paragraph:",
11.266 + c.dumpDomNode("paragraph", 1));
11.267 +
11.268 + }
11.269 +
11.270 + // Test array size = 1
11.271 + {
11.272 + Chapter c = null;
11.273 + s1 = "This is again another new paragraph";
11.274 +
11.275 + setTest("String[0] - search for array of size 1");
11.276 + for (int i=0; i<book.sizeChapter(); i++) {
11.277 + Chapter c2 = book.getChapter(i);
11.278 + if (c2.sizeParagraph() == 1) {
11.279 + c = c2;
11.280 + break;
11.281 + }
11.282 + }
11.283 + check(c != null);
11.284 +
11.285 + int tmp[] = {-1, 1, 999};
11.286 +
11.287 + // Check for out of bound exception
11.288 + for (int i=0; i<tmp.length; i++) {
11.289 + setTest("String[0] - out of bounds access [" + tmp[i] +
11.290 + "]");
11.291 + try {
11.292 + c.setParagraph(tmp[i], s1);
11.293 + check(false, "didn't get an exception");
11.294 + }
11.295 + catch(IndexOutOfBoundsException e) {
11.296 + check(true, "(IndexOutOfBoundsException)");
11.297 + }
11.298 + catch(Exception ee) {
11.299 + check(false, ee.getMessage());
11.300 + }
11.301 + }
11.302 +
11.303 + // Adding an element
11.304 + setTest("String[0] - add a string to the array");
11.305 + c.addParagraph(s1);
11.306 + if (c.sizeParagraph() != 2)
11.307 + err("array size != 2");
11.308 + s2 = c.getParagraph(1);
11.309 + check(s1.equals(s2));
11.310 + out("should contain two paragraphs:",
11.311 + c.dumpDomNode("paragraph", 1));
11.312 +
11.313 + setTest("String[0] - compare paragraphs");
11.314 + s1 = c.getParagraph(0);
11.315 + s2 = c.getParagraph(1);
11.316 + check(!s1.equals(s2), "(different content)");
11.317 +
11.318 + setTest("String[0] - add more paragraphs");
11.319 + s1 = "I always wanted to be a kind of a big paragraph " +
11.320 + " as I always dreamed to fill an XML paragraph element " +
11.321 + " only to make sure it could be large enough stuffed with " +
11.322 + " useless characters.";
11.323 + int size = 100;
11.324 + for (int i=0; i<size; i++)
11.325 + c.addParagraph(s1);
11.326 + check(c.sizeParagraph() == size+2 ,
11.327 + "(" + size + " new paragraphs)");
11.328 +
11.329 + setTest("String[0] - removing paragraphs (leaving 10)");
11.330 + for (int i=0; i<size-8; i++)
11.331 + c.removeParagraph(s1);
11.332 + check(c.sizeParagraph() == 10);
11.333 + out("should contain 10 paragraphs:",
11.334 + c.dumpDomNode("paragraph", 1));
11.335 + }
11.336 +
11.337 +
11.338 + //
11.339 + // Bean elements test
11.340 + //
11.341 + // The following tests that we can create a brand new bean,
11.342 + // populate it with other beans an insert it into an existing
11.343 + // bean graph.
11.344 + //
11.345 + // The bean elements test are using the Index and Ref beans
11.346 + // of the Book bean graph:
11.347 + //
11.348 + // Book
11.349 + // Index[1,n]
11.350 + // Word - String
11.351 + // Ref[1,n]
11.352 + // Page - String
11.353 + // Line - String
11.354 + // ...
11.355 + //
11.356 + //
11.357 + {
11.358 + Index idx;
11.359 +
11.360 + int size = book.sizeIndex();
11.361 + out("book has " + size + " Index beans",
11.362 + book.dumpDomNode("index", 1));
11.363 +
11.364 + setTest("remove a bean w/ remove()");
11.365 + idx = book.getIndex(0);
11.366 + int i1 = book.removeIndex(idx);
11.367 + check(i1==0, "(correct element removed)");
11.368 + check(book.sizeIndex()==size-1, "(correct Index array size)");
11.369 + out("book should have " + (size - 1) + " Index beans",
11.370 + book.dumpDomNode("index", 1));
11.371 +
11.372 + setTest("remove another bean w/ set(null)");
11.373 + idx = book.getIndex(0);
11.374 + book.setIndex(0, null);
11.375 + check(book.sizeIndex()==size-1, "(correct Index array size)");
11.376 + out("book should have " + (size - 2) + " Index beans",
11.377 + book.dumpDomNode("index", 1));
11.378 +
11.379 + setTest("add an empty bean to the graph");
11.380 + idx = new Index();
11.381 + book.addIndex(idx);
11.382 + check(book.sizeIndex()==size, "(correct Index array size)");
11.383 + out("book should have " + (size - 1) + " Index beans",
11.384 + book.dumpDomNode("index", 1));
11.385 +
11.386 + setTest("add a subtree bean");
11.387 + Ref r = new Ref();
11.388 + r.setPage("122");
11.389 + r.setLine("32");
11.390 + idx = new Index();
11.391 + idx.addRef(r);
11.392 + r = new Ref();
11.393 + r.setPage("1");
11.394 + r.setLine("3");
11.395 + idx.addRef(r);
11.396 + idx.setWord("who");
11.397 + book.setIndex(0, idx);
11.398 + out("book should have " + size + " Index beans",
11.399 + book.dumpDomNode("index", 1));
11.400 + out("idx should have 2 refs",
11.401 + idx.dumpDomNode(3));
11.402 + check(book.sizeIndex() == size);
11.403 +
11.404 + setTest("add another subtree bean");
11.405 + r = new Ref();
11.406 + r.setPage("22");
11.407 + r.setLine("2");
11.408 + idx = new Index();
11.409 + idx.setWord("what");
11.410 + idx.addRef(r);
11.411 + book.addIndex(idx);
11.412 + out("book should have " + (size+1) + " Index beans",
11.413 + book.dumpDomNode("index", 1));
11.414 + out("idx should have 1 ref",
11.415 + idx.dumpDomNode(3));
11.416 + check(book.sizeIndex() == size+1);
11.417 +
11.418 + setTest("should failed adding the same instance subtree");
11.419 + try {
11.420 + book.addIndex(idx);
11.421 + check(false, "didn't get an exception");
11.422 + }
11.423 + catch(IllegalArgumentException e) {
11.424 + check(true, "\n >> caught: " + e);
11.425 + }
11.426 + catch(Exception ee) {
11.427 + ee.printStackTrace();
11.428 + check(false, "\n >> got wrong type of exception: " + ee);
11.429 + }
11.430 +
11.431 + setTest("add the same cloned tree");
11.432 + int i2 = book.addIndex((Index)book.getIndex(0).clone());
11.433 + out("book should have " + (i2+1) + " Index beans",
11.434 + book.dumpDomNode("index", 1));
11.435 +
11.436 + out("Initial Index is:",
11.437 + book.getIndex(0).dumpDomNode(3));
11.438 + out("New Index should be identical:",
11.439 + book.getIndex(i2).dumpDomNode(3));
11.440 +
11.441 + check(book.sizeIndex() == i2+1);
11.442 + }
11.443 +
11.444 + //
11.445 + // Bean elements test 2
11.446 + //
11.447 + // The following tests that we can create, add, remove beans
11.448 + // and values of a graph that is not attached to a DOM tree.
11.449 + //
11.450 + {
11.451 + Index idx = new Index();
11.452 + idx.setWord("oops");
11.453 + setTest("add beans");
11.454 + Ref r = new Ref();
11.455 + r.setPage("999");
11.456 + r.setLine("9");
11.457 + idx.addRef(r);
11.458 + r = new Ref();
11.459 + r.setPage("888");
11.460 + r.setLine("8");
11.461 + idx.addRef(r);
11.462 + check(idx.sizeRef()==2, "(correct size of array)");
11.463 + out("should have nothing to print: ", idx.dumpDomNode(1));
11.464 + setTest("remove an element");
11.465 + idx.removeRef(r);
11.466 + check(idx.sizeRef()==1, "(correct size of array)");
11.467 + setTest("remove last element");
11.468 + idx.setRef(0, null);
11.469 + check(idx.sizeRef()==1, "(correct size)");
11.470 + r = new Ref();
11.471 + r.setPage("77");
11.472 + r.setLine("7");
11.473 + idx.setRef(0, r);
11.474 + out("add an element and test getValues:", idx.dumpBeanNode());
11.475 + }
11.476 +
11.477 + //
11.478 + // The following test creates a brand new bean graph and therefore
11.479 + // a new DOM graph.
11.480 + //
11.481 + setTest("creating the root for a brand new graph");
11.482 + book = Book.createGraph();
11.483 + check(book != null);
11.484 +
11.485 + setTest("populating the graph");
11.486 + book.setGood(false);
11.487 + book.setAvailable(true);
11.488 + book.setSummary("This book is about avoiding summaries at the end of books");
11.489 + Chapter c = new Chapter();
11.490 + c.setComment("What's a good summary in chapter 1");
11.491 + c.setComment2("Additional comment");
11.492 + c.addParagraph("This is the first paragraph");
11.493 + c.addParagraph("This is a second paragraph");
11.494 + book.addChapter(c);
11.495 +
11.496 + c = new Chapter();
11.497 + book.addChapter(c);
11.498 + c.setComment("Yet another comment for chapter 2");
11.499 + c.addParagraph("only one paragraph in this second chapter");
11.500 +
11.501 + c = new Chapter();
11.502 + book.addChapter(c);
11.503 +
11.504 + Index i = new Index();
11.505 + i.setWord("summary");
11.506 +
11.507 + Ref r = new Ref();
11.508 + r.setPage("22");
11.509 + r.setLine("12");
11.510 + i.addRef(r);
11.511 +
11.512 + r = new Ref();
11.513 + i.addRef(r);
11.514 + r.setPage("4");
11.515 + r.setLine("5");
11.516 +
11.517 + book.addIndex(i);
11.518 +
11.519 + check(true);
11.520 +
11.521 + out("print the new graph DOM nodes:",
11.522 + book.dumpDomNode(9));
11.523 +
11.524 + out("Re-read the original XML file for array getter/setter testing");
11.525 + this.readDocument();
11.526 + book = Book.createGraph(doc);
11.527 + out("bean graph created");
11.528 +
11.529 + {
11.530 + setTest("check Index[] getter() method");
11.531 + Index []a1 = book.getIndex();
11.532 + check(a1.length == book.sizeIndex(), "(correct array size)");
11.533 + check(a1[0] == book.getIndex(0), "(same first element)");
11.534 + check(a1[1] == book.getIndex(1), "(same second element)");
11.535 + check(a1[0] != book.getIndex(1), "([0] != [1])");
11.536 + setTest("check Chapter[] getter() method");
11.537 + Chapter []a2 = book.getChapter();
11.538 + check(a2.length == book.sizeChapter(), "(correct array size)");
11.539 + check(a2[0] == book.getChapter(0), "(same first element)");
11.540 + check(a2[1] == book.getChapter(1), "(same second element)");
11.541 + check(a2[2] == book.getChapter(2), "(same third element)");
11.542 + check(a2[0] != book.getChapter(2), "([0] != [2])");
11.543 + setTest("check Chapter.Paragraph getter() method");
11.544 + String []p = a2[0].getParagraph();
11.545 + check(p.length == book.getChapter(0).sizeParagraph(),
11.546 + "(correct array size)");
11.547 + p = a2[1].getParagraph();
11.548 + check(p.length == book.getChapter(1).sizeParagraph(),
11.549 + "(correct array size)");
11.550 + p = a2[2].getParagraph();
11.551 + check(p.length == book.getChapter(2).sizeParagraph(),
11.552 + "(correct array size)");
11.553 + setTest("change the Chapter[] order");
11.554 + int []s = new int[3];
11.555 + s[0] = a2[0].sizeParagraph();
11.556 + s[1] = a2[1].sizeParagraph();
11.557 + s[2] = a2[2].sizeParagraph();
11.558 + Chapter []a3 = new Chapter[3];
11.559 + a3[2] = (Chapter)a2[0];
11.560 + a3[1] = (Chapter)a2[1];
11.561 + a3[0] = (Chapter)a2[2];
11.562 + book.setChapter(a3);
11.563 + check(book.getChapter(2).sizeParagraph()==s[0],
11.564 + "(reversed first element)");
11.565 + check(book.getChapter(1).sizeParagraph()==s[1],
11.566 + "(same second element)");
11.567 + check(book.getChapter(0).sizeParagraph()==s[2],
11.568 + "(reversed third element)");
11.569 +
11.570 + setTest("Chapter going in and out of Book");
11.571 + out("Make sure the contents of a Chapter object remain intact after removing that Chapter from the Book");
11.572 + Chapter undecidedChapter = new Chapter();
11.573 + undecidedChapter.setComment("This chapter may not make it into the book.");
11.574 + out(undecidedChapter.getComment());
11.575 + book.addChapter(undecidedChapter);
11.576 + out(book.sizeChapter());
11.577 + check(book.getChapter(book.sizeChapter()-1) == undecidedChapter, "undecided chapter is in there");
11.578 + book.removeChapter(undecidedChapter);
11.579 + out("make sure undecidedChapter is intact");
11.580 + out(undecidedChapter.getComment());
11.581 + out("make sure book is intact");
11.582 + out(book.sizeChapter());
11.583 + out("Put the chapter back in.");
11.584 + book.addChapter(undecidedChapter);
11.585 + out(book);
11.586 + }
11.587 +
11.588 + // Read again the document and play with the choice properties
11.589 + this.readDocument();
11.590 + out("creating the bean graph");
11.591 + book = Book.createGraph(doc);
11.592 +
11.593 + setTest("check if the root has any choice prop");
11.594 + Iterator it = book.listChoiceProperties();
11.595 + check(!it.hasNext(), "(none found)");
11.596 + check(book.listChoiceProperties("Chapter") == null, "(none found on Chapter prop)");
11.597 + check(book.listChoiceProperties("index") == null, "(none found on index prop)");
11.598 + setTest("test extra prop");
11.599 +
11.600 + BaseProperty[] bps;
11.601 + Extra e = book.getExtra();
11.602 + it = e.listChoiceProperties();
11.603 + check(it.hasNext(), "(at least one)");
11.604 + while (it.hasNext()) {
11.605 + out("Getting a set of choice properties:");
11.606 + bps = (BaseProperty[])it.next();
11.607 + this.printChoiceProperties(bps);
11.608 + }
11.609 +
11.610 + out("Getting the same list 3 times:");
11.611 + bps = e.listChoiceProperties("Size");
11.612 + this.printChoiceProperties(bps);
11.613 + bps = e.listChoiceProperties("size-cm");
11.614 + this.printChoiceProperties(bps);
11.615 + bps = e.listChoiceProperties("size-inches");
11.616 + this.printChoiceProperties(bps);
11.617 +
11.618 + out("Getting twice the same list:");
11.619 + bps = e.listChoiceProperties("WeightKg");
11.620 + this.printChoiceProperties(bps);
11.621 + bps = e.listChoiceProperties("weight-lb");
11.622 + this.printChoiceProperties(bps);
11.623 +
11.624 + check(!e.isChoiceProperty("color"), " color not choice prop");
11.625 +
11.626 + //
11.627 + // This tests the DDParser class
11.628 + //
11.629 + //this.out(book.dumpBeanNode());
11.630 +
11.631 + this.parse(book, "/Book/Good");
11.632 + this.parse(book, "/Good");
11.633 + this.parse(book, "Summary/");
11.634 + book.setSummary(null);
11.635 + this.parse(book, "Summary");
11.636 + this.parse(book, "Available");
11.637 + this.parse(book, "Extra");
11.638 + this.parse(book, "Chapter");
11.639 + this.parse(book, "Chapter/Comment");
11.640 + this.parse(book, "Chapter/Paragraph");
11.641 + this.parse(book, "index/ref/line");
11.642 +
11.643 + out(book.dumpBeanNode());
11.644 + this.parse(book, "/Book/Index.Word=E-Tools/Ref/Page");
11.645 + this.parse(book, "/Book/Index.Word=E-Tool/Ref/Page");
11.646 + this.parse(book, "/Book/Index.Word=E-Tool/Ref.Line=15/Page");
11.647 + this.parse(book, "/Book/Index.Word=E-Tool/Ref.Line=15/Page=22");
11.648 + this.parse(book, "/Book/Index.Word=E-Tool/Ref.Line=15/Page=5");
11.649 +
11.650 + book = new Book();
11.651 + out(book.dumpBeanNode());
11.652 + this.parse(book, "/Book/Index.Word=E-Tools/Ref.Line=15/Page!");
11.653 + out(book.dumpBeanNode());
11.654 + this.parse(book, "/Book/Chapter.Comment=My Comment");
11.655 + out(book.dumpBeanNode());
11.656 + this.parse(book, "/Book/Chapter.Comment=My Comment!");
11.657 + out(book.dumpBeanNode());
11.658 + this.parse(book, "/Book/Index.Word=the word/Ref.Line=10/Page=20!");
11.659 + out(book.dumpBeanNode());
11.660 +
11.661 + // Make sure that we can merge (this test the case of merge
11.662 + // without attribute which is covered by TestMerge)
11.663 + setTest("simple merge");
11.664 + this.readDocument();
11.665 + out("creating the bean graph");
11.666 + book = Book.createGraph(doc);
11.667 + Book b2 = (Book)book.clone();
11.668 + s1 = "Some more dynamic notes on the summary.";
11.669 + b2.setSummary(s1);
11.670 + b2.getChapter(0).setComment("New Comment");
11.671 + book.merge(b2);
11.672 + check(book.equals(b2), "identical graphs");
11.673 +
11.674 + // Merge two elements that are not part of the graph
11.675 + Chapter c1 = new Chapter();
11.676 + Chapter c2 = new Chapter();
11.677 + c1.merge(c2);
11.678 +
11.679 + }
11.680 +
11.681 +
11.682 + void parse(BaseBean bean, String parse) {
11.683 + out("Parsing " + parse);
11.684 + DDParser p = new DDParser(bean, parse);
11.685 + while (p.hasNext()) {
11.686 + Object o = p.next();
11.687 + if (o != null) {
11.688 + if (o instanceof BaseBean)
11.689 + this.out(((BaseBean)o).dumpBeanNode());
11.690 + else
11.691 + this.out(o.toString());
11.692 + }
11.693 + else
11.694 + this.out("null");
11.695 + }
11.696 + }
11.697 +
11.698 + void printChoiceProperties(BaseProperty[] bps) {
11.699 + if (bps == null)
11.700 + err("got null instead a BaseProperty[] instance");
11.701 + else {
11.702 + for (int l=0; l<bps.length; l++)
11.703 + check(bps[l].isChoiceProperty(), bps[l].getDtdName());
11.704 + }
11.705 + }
11.706 +}
11.707 +
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/schema2beans/test/unit/src/data/TestBook.xml Wed Jun 19 00:18:25 2002 +0000
12.3 @@ -0,0 +1,63 @@
12.4 +<?xml version="1.0" encoding="ISO-8859-1"?>
12.5 +
12.6 +<book>
12.7 + <summary>
12.8 + This book is about the life of a book spent between books who dreamed
12.9 + to meet a fairy who could transform it into an XML book and travel
12.10 + in an electronic boundary-less world.
12.11 + </summary>
12.12 + <chapter>
12.13 + <comment>
12.14 + First chapter.
12.15 + </comment>
12.16 + <paragraph>
12.17 + Once upon a time...
12.18 + </paragraph>
12.19 + <paragraph>
12.20 + And this is how the book met the fairy, and how all this
12.21 + story began.
12.22 + </paragraph>
12.23 + </chapter>
12.24 + <chapter>
12.25 + <paragraph>
12.26 + And the book lived a never ending happy life, read, copied
12.27 + and enjoyed by so many readers.
12.28 + </paragraph>
12.29 + </chapter>
12.30 + <chapter>
12.31 + <comment>
12.32 + Empty chapter
12.33 + </comment>
12.34 + </chapter>
12.35 + <index>
12.36 + <word>
12.37 + Good book
12.38 + </word>
12.39 + <ref>
12.40 + <page>22</page>
12.41 + <line>12</line>
12.42 + </ref>
12.43 + </index>
12.44 + <index>
12.45 + <word>
12.46 + E-Tool
12.47 + </word>
12.48 + <ref>
12.49 + <page>5</page>
12.50 + <line>15</line>
12.51 + </ref>
12.52 + <ref>
12.53 + <page>29</page>
12.54 + <line>31</line>
12.55 + </ref>
12.56 + </index>
12.57 + <good/>
12.58 + <extra>
12.59 + <size-cm>
12.60 + 10x20
12.61 + </size-cm>
12.62 + <weight-kg>
12.63 + 0.125
12.64 + </weight-kg>
12.65 + </extra>
12.66 +</book>
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2 +++ b/schema2beans/test/unit/src/data/TestContrivedApp.dtd Wed Jun 19 00:18:25 2002 +0000
13.3 @@ -0,0 +1,6 @@
13.4 +<!ELEMENT application (display-name, description, module)>
13.5 +<!ELEMENT module (ejb, alt-dd)>
13.6 +<!ELEMENT display-name #PCDATA>
13.7 +<!ELEMENT description #PCDATA>
13.8 +<!ELEMENT ejb #PCDATA>
13.9 +<!ELEMENT alt-dd #PCDATA>
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
14.2 +++ b/schema2beans/test/unit/src/data/TestContrivedApp.java Wed Jun 19 00:18:25 2002 +0000
14.3 @@ -0,0 +1,97 @@
14.4 +/*
14.5 + * TestBook - test the basic features.
14.6 + *
14.7 + * The following test assumes that we know the content of the
14.8 + * graph as we get elements, add and change them. Therefore, the TestBook.xml
14.9 + * file and this java test should be kept in sync.
14.10 + *
14.11 + * Test the following:
14.12 + *
14.13 + * single String: get/set/remove/set/get
14.14 + * boolean (from true): get/set true/get/set false/get/set true/get
14.15 + * boolean (from false): get/set false/get/set true/get/set false/get
14.16 + * String[]: get/set (null & !null)/add/remove
14.17 + * Bean: remove/set(null)/create bean and graph of beans/set/add
14.18 + *
14.19 + */
14.20 +
14.21 +import java.io.*;
14.22 +import java.util.*;
14.23 +import org.w3c.dom.*;
14.24 +
14.25 +import org.netbeans.modules.schema2beans.*;
14.26 +import application.*;
14.27 +
14.28 +
14.29 +public class TestContrivedApp extends BaseTest {
14.30 + public static void main(String[] argv) {
14.31 + BaseTest o = new TestContrivedApp();
14.32 + if (argv.length > 0)
14.33 + o.setDocumentDir(argv[0]);
14.34 + try {
14.35 + o.run();
14.36 + } catch (Exception e) {
14.37 + e.printStackTrace();
14.38 + System.exit(1);
14.39 + }
14.40 + System.exit(0);
14.41 + }
14.42 +
14.43 + public void run() throws Exception {
14.44 + Application app;
14.45 +
14.46 + out("creating the bean graph");
14.47 +
14.48 + app = Application.createGraph(new FileInputStream(getFullDocumentName()));
14.49 +
14.50 + // Check that we can read the graph and it is complete
14.51 + out("bean graph created");
14.52 +
14.53 + out(app);
14.54 + Module module = app.getModule();
14.55 + out("module.myaltDd = "+module.getMyAltDd());
14.56 + out("Make sure XML metacharacters get escapped");
14.57 + module.setMyAltDd("Foo & Co");
14.58 + out(app);
14.59 + out("Make sure alt-dd is still there with no whitespace");
14.60 + module.setMyAltDd("");
14.61 + out(app);
14.62 + out("alt-dd goes away now");
14.63 + module.setMyAltDd(null);
14.64 + out(app);
14.65 + module.setAlternateNameEjb("blue");
14.66 + out(app);
14.67 + //Module optionalModule = new Module();
14.68 + //optionalModule.setAlternateNameEjb("optional module");
14.69 + //app.setModule2(optionalModule);
14.70 + //out(app);
14.71 +
14.72 + return;
14.73 + }
14.74 +
14.75 + void parse(BaseBean bean, String parse) {
14.76 + out("Parsing " + parse);
14.77 + DDParser p = new DDParser(bean, parse);
14.78 + while (p.hasNext()) {
14.79 + Object o = p.next();
14.80 + if (o != null) {
14.81 + if (o instanceof BaseBean)
14.82 + this.out(((BaseBean)o).dumpBeanNode());
14.83 + else
14.84 + this.out(o.toString());
14.85 + }
14.86 + else
14.87 + this.out("null");
14.88 + }
14.89 + }
14.90 +
14.91 + void printChoiceProperties(BaseProperty[] bps) {
14.92 + if (bps == null)
14.93 + err("got null instead a BaseProperty[] instance");
14.94 + else {
14.95 + for (int l=0; l<bps.length; l++)
14.96 + check(bps[l].isChoiceProperty(), bps[l].getDtdName());
14.97 + }
14.98 + }
14.99 +}
14.100 +
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
15.2 +++ b/schema2beans/test/unit/src/data/TestContrivedApp.mdd Wed Jun 19 00:18:25 2002 +0000
15.3 @@ -0,0 +1,47 @@
15.4 +<?xml version="1.0" encoding="UTF-8"?>
15.5 +<metaDD>
15.6 + <throw-exceptions/>
15.7 + <meta-element>
15.8 + <dtd-name>display-name</dtd-name>
15.9 + <bean-name>DisplayName</bean-name>
15.10 + <wrapper-class>String</wrapper-class>
15.11 + </meta-element>
15.12 + <meta-element>
15.13 + <dtd-name>alt-dd</dtd-name>
15.14 + <bean-name>MyAltDd</bean-name>
15.15 + <wrapper-class>String</wrapper-class>
15.16 + </meta-element>
15.17 + <meta-element>
15.18 + <dtd-name>application</dtd-name>
15.19 + <bean-name>Application</bean-name>
15.20 + <meta-property>
15.21 + <bean-name>DisplayName</bean-name>
15.22 + </meta-property>
15.23 + <meta-property>
15.24 + <bean-name>Description</bean-name>
15.25 + </meta-property>
15.26 + <meta-property>
15.27 + <bean-name>Module</bean-name>
15.28 + </meta-property>
15.29 + </meta-element>
15.30 + <meta-element>
15.31 + <dtd-name>module</dtd-name>
15.32 + <bean-name>Module</bean-name>
15.33 + <meta-property>
15.34 + <bean-name>AlternateNameEjb</bean-name>
15.35 + </meta-property>
15.36 + <meta-property>
15.37 + <bean-name>MyAltDd</bean-name>
15.38 + </meta-property>
15.39 + </meta-element>
15.40 + <meta-element>
15.41 + <dtd-name>ejb</dtd-name>
15.42 + <bean-name>AlternateNameEjb</bean-name>
15.43 + <wrapper-class>String</wrapper-class>
15.44 + </meta-element>
15.45 + <meta-element>
15.46 + <dtd-name>description</dtd-name>
15.47 + <bean-name>Description</bean-name>
15.48 + <wrapper-class>String</wrapper-class>
15.49 + </meta-element>
15.50 +</metaDD>
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
16.2 +++ b/schema2beans/test/unit/src/data/TestContrivedApp.xml Wed Jun 19 00:18:25 2002 +0000
16.3 @@ -0,0 +1,10 @@
16.4 +<?xml version="1.0" encoding="UTF-8"?>
16.5 +<!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">
16.6 +<application>
16.7 +<display-name>Application_EJBModule_Entity2</display-name>
16.8 +<description>J2EE Application & < >Application_EJBModule_Entity2<![CDATA[<>&"']]></description>
16.9 +<module>
16.10 +<ejb>EJBModule_Entity2.jar</ejb>
16.11 +<alt-dd>EJBModule_Entity2.xml</alt-dd>
16.12 +</module>
16.13 +</application>
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
17.2 +++ b/schema2beans/test/unit/src/data/TestEmpty.dtd Wed Jun 19 00:18:25 2002 +0000
17.3 @@ -0,0 +1,1 @@
17.4 +<!ELEMENT EmptyElement EMPTY>
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
18.2 +++ b/schema2beans/test/unit/src/data/TestEmpty.java Wed Jun 19 00:18:25 2002 +0000
18.3 @@ -0,0 +1,53 @@
18.4 +/*
18.5 + * TestEmpty - test the basic features.
18.6 + *
18.7 + * The following test assumes that we know the content of the
18.8 + * graph as we get elements, add and change them. Therefore, the TestEmpty.xml
18.9 + * file and this java test should be kept in sync.
18.10 + *
18.11 + * Test the following:
18.12 + *
18.13 + * single String: get/set/remove/set/get
18.14 + * boolean (from true): get/set true/get/set false/get/set true/get
18.15 + * boolean (from false): get/set false/get/set true/get/set false/get
18.16 + * String[]: get/set (null & !null)/add/remove
18.17 + * Bean: remove/set(null)/create bean and graph of beans/set/add
18.18 + *
18.19 + */
18.20 +
18.21 +import java.io.*;
18.22 +import java.util.*;
18.23 +import org.w3c.dom.*;
18.24 +
18.25 +import org.netbeans.modules.schema2beans.*;
18.26 +import emptyelement.*;
18.27 +
18.28 +public class TestEmpty extends BaseTest {
18.29 + public static void main(String[] argv) {
18.30 + BaseTest o = new TestEmpty
18.31 + ();
18.32 + if (argv.length > 0)
18.33 + o.setDocumentDir(argv[0]);
18.34 + try {
18.35 + o.run();
18.36 + } catch (Exception e) {
18.37 + e.printStackTrace();
18.38 + System.exit(1);
18.39 + }
18.40 + System.exit(0);
18.41 + }
18.42 +
18.43 + public void run() throws Exception {
18.44 + EmptyElement ee;
18.45 +
18.46 + out("creating the bean graph");
18.47 + ee = new EmptyElement();
18.48 +
18.49 + // Check that we can read the graph an it is complete
18.50 + out("bean graph created");
18.51 +
18.52 + out(ee);
18.53 +
18.54 + return;
18.55 + }
18.56 +}
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
19.2 +++ b/schema2beans/test/unit/src/data/TestEncoding.dtd Wed Jun 19 00:18:25 2002 +0000
19.3 @@ -0,0 +1,30 @@
19.4 +<!ELEMENT FORTEDDL (PHASE+)>
19.5 +
19.6 +<!ELEMENT PHASE (ATTRIBUTE, ANNOTATION*)*>
19.7 +<!ATTLIST PHASE
19.8 + OBJECTTYPE CDATA #REQUIRED
19.9 + OBJECTNAME CDATA #REQUIRED
19.10 + NUMBER CDATA #REQUIRED>
19.11 +
19.12 +<!ELEMENT ATTRIBUTE ( #PCDATA | ARRAY | MYOBJECT | TRUE | FALSE | NIL )* >
19.13 +<!ATTLIST ATTRIBUTE NAME CDATA #REQUIRED>
19.14 +
19.15 +<!ELEMENT ANNOTATION (PROPERTYSHEET?, ATTRIBUTE+)>
19.16 +<!ATTLIST ANNOTATION
19.17 + OBJECTTYPE CDATA #REQUIRED
19.18 + NAME CDATA #REQUIRED
19.19 + VIEW CDATA #IMPLIED>
19.20 +
19.21 +<!ELEMENT PROPERTYSHEET EMPTY>
19.22 +<!ATTLIST PROPERTYSHEET
19.23 + CLASS CDATA #REQUIRED
19.24 + TAB CDATA #REQUIRED>
19.25 +
19.26 +<!ELEMENT MYOBJECT (ATTRIBUTE)+>
19.27 +<!ATTLIST MYOBJECT CLASS CDATA #REQUIRED>
19.28 +
19.29 +<!ELEMENT ARRAY (MYOBJECT)+>
19.30 +
19.31 +<!ELEMENT TRUE EMPTY>
19.32 +<!ELEMENT FALSE EMPTY>
19.33 +<!ELEMENT NIL EMPTY>
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
20.2 +++ b/schema2beans/test/unit/src/data/TestEncoding.java Wed Jun 19 00:18:25 2002 +0000
20.3 @@ -0,0 +1,67 @@
20.4 +/*
20.5 + * TestEncoding - Make sure we correctly deal with I18N encoding stuff.
20.6 + *
20.7 + */
20.8 +
20.9 +import java.io.*;
20.10 +import java.util.*;
20.11 +import org.w3c.dom.*;
20.12 +
20.13 +import org.netbeans.modules.schema2beans.*;
20.14 +import forteddl.*;
20.15 +
20.16 +
20.17 +public class TestEncoding extends BaseTest {
20.18 + public static void main(String[] argv) {
20.19 + BaseTest o = new TestEncoding();
20.20 + if (argv.length > 0)
20.21 + o.setDocumentDir(argv[0]);
20.22 + try {
20.23 + o.run();
20.24 + } catch (Exception e) {
20.25 + e.printStackTrace();
20.26 + System.exit(1);
20.27 + }
20.28 + System.exit(0);
20.29 + }
20.30 +
20.31 + public void run() throws Exception {
20.32 + Forteddl app;
20.33 +
20.34 + out("creating the bean graph");
20.35 + app = Forteddl.createGraph(new FileInputStream(getFullDocumentName()));
20.36 +
20.37 + // Check that we can read the graph an it is complete
20.38 + out("bean graph created");
20.39 +
20.40 + out(app);
20.41 +
20.42 + return;
20.43 + }
20.44 +
20.45 + void parse(BaseBean bean, String parse) {
20.46 + out("Parsing " + parse);
20.47 + DDParser p = new DDParser(bean, parse);
20.48 + while (p.hasNext()) {
20.49 + Object o = p.next();
20.50 + if (o != null) {
20.51 + if (o instanceof BaseBean)
20.52 + this.out(((BaseBean)o).dumpBeanNode());
20.53 + else
20.54 + this.out(o.toString());
20.55 + }
20.56 + else
20.57 + this.out("null");
20.58 + }
20.59 + }
20.60 +
20.61 + void printChoiceProperties(BaseProperty[] bps) {
20.62 + if (bps == null)
20.63 + err("got null instead a BaseProperty[] instance");
20.64 + else {
20.65 + for (int l=0; l<bps.length; l++)
20.66 + check(bps[l].isChoiceProperty(), bps[l].getDtdName());
20.67 + }
20.68 + }
20.69 +}
20.70 +
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
21.2 +++ b/schema2beans/test/unit/src/data/TestEncoding.xml Wed Jun 19 00:18:25 2002 +0000
21.3 @@ -0,0 +1,58 @@
21.4 +<?xml version="1.0" encoding="ISO-8859-1"?>
21.5 +
21.6 +<!-- ex1.xml -->
21.7 +<!-- This is a simple XML source file. Object class metamethod -->
21.8 +<!-- m3 includes 8-bit ASCII text, with a tilde-n and accent-e -->
21.9 +<!-- characters embedded, to test the UTF8->native codeset -->
21.10 +<!-- conversion feature of the SAX expat driver. As long as this -->
21.11 +<!-- test is run under ISO-8859-1 localization, test output should-->
21.12 +<!-- be identical to test input, with one odd byte representing -->
21.13 +<!-- each of these 8-bit characters. -->
21.14 +<!-- -->
21.15 +<!-- The vi editor on Sun Solaris displays the two odd characters -->
21.16 +<!-- as \161 and \151. -->
21.17 +<!-- -->
21.18 +
21.19 +<!-- <!DOCTYPE FORTEDDL SYSTEM "TestEncoding.dtd" []> -->
21.20 +<FORTEDDL>
21.21 + <PHASE OBJECTTYPE="MetaPlan.MetaClass" OBJECTNAME="c1" NUMBER="1">
21.22 + <ATTRIBUTE NAME="Name">c1</ATTRIBUTE>
21.23 + <ATTRIBUTE NAME="MethodArray">
21.24 + <ARRAY>
21.25 + <MYOBJECT CLASS="MetaMethod">
21.26 + <ATTRIBUTE NAME="Name">m1</ATTRIBUTE>
21.27 + <ATTRIBUTE NAME="Text">
21.28 + task.lgr.putline('this is m1');
21.29 + return;
21.30 + </ATTRIBUTE>
21.31 + </MYOBJECT>
21.32 + <MYOBJECT CLASS="MetaMethod">
21.33 + <ATTRIBUTE NAME="Name">m2</ATTRIBUTE>
21.34 + <ATTRIBUTE NAME="Text">
21.35 + <?FORTE ThisIsAProcessingInstruction ?>
21.36 + task.lgr.putline('this is m2');
21.37 + return;
21.38 + </ATTRIBUTE>
21.39 + </MYOBJECT>
21.40 + <MYOBJECT CLASS="MetaMethod">
21.41 + <ATTRIBUTE NAME="Name">m3</ATTRIBUTE>
21.42 + <ATTRIBUTE NAME="8-bit ASCII text">
21.43 + task.lgr.putline('Yo amo habañero chilés');
21.44 + return;
21.45 + </ATTRIBUTE>
21.46 + </MYOBJECT>
21.47 + </ARRAY>
21.48 + </ATTRIBUTE>
21.49 + <ANNOTATION OBJECTTYPE="CrossRefInfo" NAME="cr1">
21.50 + <ATTRIBUTE NAME="InfoArray">
21.51 + <ARRAY>
21.52 + <MYOBJECT CLASS="infoItem">
21.53 + <ATTRIBUTE NAME="Reference">putline</ATTRIBUTE>
21.54 + <ATTRIBUTE NAME="Class">c1</ATTRIBUTE>
21.55 + <ATTRIBUTE NAME="Method">m1</ATTRIBUTE>
21.56 + </MYOBJECT>
21.57 + </ARRAY>
21.58 + </ATTRIBUTE>
21.59 + </ANNOTATION>
21.60 + </PHASE>
21.61 +</FORTEDDL>
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
22.2 +++ b/schema2beans/test/unit/src/data/TestEvents.dtd Wed Jun 19 00:18:25 2002 +0000
22.3 @@ -0,0 +1,49 @@
22.4 +<!-- The following DTD is a simple view of a book:
22.5 +book
22.6 + index
22.7 + +
22.8 + word
22.9 + #PCDATA
22.10 + page
22.11 + #PCDATA
22.12 + chapter+
22.13 + comment?
22.14 + #PCDATA
22.15 + paragraph*
22.16 + #PCDATA
22.17 + summary?
22.18 + #PCDATA
22.19 +
22.20 + good
22.21 + EMPTY
22.22 +-->
22.23 +
22.24 +<!ELEMENT summary (#PCDATA)>
22.25 +
22.26 +<!ELEMENT book (index+, chapter+, summary?, author+, good, available)>
22.27 +
22.28 +<!ELEMENT good EMPTY>
22.29 +
22.30 +<!ELEMENT available EMPTY>
22.31 +
22.32 +<!ELEMENT index (word, ref+)>
22.33 +
22.34 +<!ELEMENT ref (page, line)>
22.35 +
22.36 +<!ELEMENT word (#PCDATA)>
22.37 +
22.38 +<!ELEMENT author (#PCDATA)>
22.39 +
22.40 +<!ELEMENT line (#PCDATA)>
22.41 +
22.42 +<!ELEMENT page (#PCDATA)>
22.43 +
22.44 +<!ELEMENT chapter (comment?, paragraph*)>
22.45 +
22.46 +<!ELEMENT paragraph (#PCDATA)>
22.47 +
22.48 +<!ELEMENT comment (#PCDATA)>
22.49 +
22.50 +
22.51 +
22.52 +
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
23.2 +++ b/schema2beans/test/unit/src/data/TestEvents.java Wed Jun 19 00:18:25 2002 +0000
23.3 @@ -0,0 +1,379 @@
23.4 +/*
23.5 + * TestEvents - test the events
23.6 + *
23.7 + * The following test assumes that we know the content of the
23.8 + * graph as we get elements, add and change them. Therefore, the TestBook.xml
23.9 + * file and this java test should be kept in sync.
23.10 + *
23.11 + * Test the following:
23.12 + *
23.13 + * listener on the root - change event for add/change/remove on the same root bean
23.14 + * listener on the root - change event for add/change/remove
23.15 + * on a sub node bean (propagation)
23.16 + * listener on the root and on a subnode: test no reception, both reception and
23.17 + * only one reception
23.18 + * listener on a specific property
23.19 + * remove listeners
23.20 + * indexed and non indexed property events
23.21 + * check utility methods to get the index, name and parent bean
23.22 + * from an event name (graphManager methods)
23.23 + * remove a subtree - get event within the subtree (no propagation)
23.24 + * and within the original tree (propagation)
23.25 + *
23.26 + */
23.27 +
23.28 +import java.io.*;
23.29 +import java.util.*;
23.30 +import org.w3c.dom.*;
23.31 +
23.32 +import java.beans.*;
23.33 +
23.34 +import org.netbeans.modules.schema2beans.*;
23.35 +import book.*;
23.36 +
23.37 +
23.38 +public class TestEvents extends BaseTest
23.39 +{
23.40 + public static void main(String[] argv) {
23.41 + BaseTest o = new TestEvents();
23.42 + if (argv.length > 0)
23.43 + o.setDocumentDir(argv[0]);
23.44 + try {
23.45 + o.run();
23.46 + } catch (Exception e) {
23.47 + e.printStackTrace();
23.48 + System.exit(1);
23.49 + }
23.50 + System.exit(0);
23.51 + }
23.52 +
23.53 + public class MyListener implements PropertyChangeListener
23.54 + {
23.55 + GraphManager gm;
23.56 + String listenerName;
23.57 + Object oldValue;
23.58 + Object newValue;
23.59 + String propertyName;
23.60 + Object source;
23.61 + int index;
23.62 +
23.63 + boolean remove;
23.64 +
23.65 + // Used to check that the event is triggered once the changed are done
23.66 + Chapter tracePara;
23.67 +
23.68 + public MyListener(BaseBean bean)
23.69 + {
23.70 + this.listenerName = bean.name();
23.71 + gm = bean.graphManager();
23.72 + this.remove = false;
23.73 + out("new listener for " + this.listenerName);
23.74 + }
23.75 +
23.76 + public void reset()
23.77 + {
23.78 + this.oldValue = null;
23.79 + this.newValue = null;
23.80 + this.propertyName = null;
23.81 + this.source = null;
23.82 + this.index = -1;
23.83 + }
23.84 +
23.85 + public void traceParagraphs(Chapter c)
23.86 + {
23.87 + this.tracePara = c;
23.88 + }
23.89 +
23.90 +
23.91 + public void propertyChange(PropertyChangeEvent e)
23.92 + {
23.93 + this.oldValue = e.getOldValue();
23.94 + this.newValue = e.getNewValue();
23.95 + this.propertyName = e.getPropertyName();
23.96 + this.source = e.getSource();
23.97 + String n = this.propertyName;
23.98 + this.index = gm.getPropertyIndex(n);
23.99 +
23.100 + out("<Lnr:" + this.listenerName + " Evt:" + n +
23.101 + " Src:" + this.source.getClass().getName() + ">");
23.102 + if (remove)
23.103 + {
23.104 + out("<" + gm.getPropertyName(n) + "[" + this.index +
23.105 + "]" + " - Parent: " + gm.getPropertyParentName(n) + ">");
23.106 + }
23.107 + else
23.108 + {
23.109 + out("<" + gm.getPropertyName(n) + "[" + this.index +
23.110 + "]" + " - Parent: " + gm.getPropertyParentName(n) +
23.111 + "/" + gm.getPropertyParent(n).getClass().getName() + ">");
23.112 + }
23.113 +
23.114 + if (this.tracePara != null)
23.115 + {
23.116 + String[] p = this.tracePara.getParagraph();
23.117 + for (int i=0; i<p.length; i++)
23.118 + out("From event listener: " + p[i]);
23.119 + }
23.120 + //out("received " + this.oldValue + "/" + this.newValue + "/" +
23.121 + // this.propertyName);
23.122 + }
23.123 +
23.124 + public void removeMode()
23.125 + {
23.126 + this.remove = true;
23.127 + }
23.128 +
23.129 + public Object oldValue()
23.130 + {
23.131 + return this.oldValue;
23.132 + }
23.133 +
23.134 + public String stringOldValue()
23.135 + {
23.136 + if (this.oldValue == null)
23.137 + return "<null>";
23.138 + else
23.139 + return this.oldValue.toString();
23.140 + }
23.141 +
23.142 + public Object newValue()
23.143 + {
23.144 + return this.newValue;
23.145 + }
23.146 +
23.147 + public String stringNewValue()
23.148 + {
23.149 + if (this.newValue == null)
23.150 + return "<null>";
23.151 + else
23.152 + return this.newValue.toString();
23.153 + }
23.154 +
23.155 + public String name()
23.156 + {
23.157 + return this.propertyName;
23.158 + }
23.159 +
23.160 + public String toString()
23.161 + {
23.162 + return this.name() + " raised from source " +
23.163 + this.source.getClass().getName();
23.164 + }
23.165 + }
23.166 +
23.167 + public void run()
23.168 + throws Exception
23.169 + {
23.170 + Book book;
23.171 +
23.172 + this.readDocument();
23.173 +
23.174 + out("creating the bean graph");
23.175 + book = Book.createGraph(this.doc);
23.176 + GraphManager gm = book.graphManager();
23.177 +
23.178 + // Check that we can read the graph an it is complete
23.179 + out("bean graph created");
23.180 + //out(book.toString());
23.181 +
23.182 + /*
23.183 + * Book
23.184 + * Index[1,n]
23.185 + * Word - String
23.186 + * Ref[1,n]
23.187 + * Page - String
23.188 + * Line - String
23.189 + * Chapter[1,n]
23.190 + * Comment? - String
23.191 + * Paragraph[0,n] - String
23.192 + * Summary? - String
23.193 + * Author[1,n] - String
23.194 + * Good - Boolean
23.195 + * Available - Boolean
23.196 + */
23.197 +
23.198 + //
23.199 + // Set a change event on the root
23.200 + //
23.201 + MyListener l = new MyListener(book);
23.202 +
23.203 + book.addPropertyChangeListener(l);
23.204 +
23.205 + setTest("simple change event on the root");
23.206 + l.reset();
23.207 + String s = "This book is about how to raise the event familly";
23.208 + // Change a property on the root - this should raises an event
23.209 + book.setSummary(s);
23.210 + // Check the received event
23.211 + check(l.oldValue() == null, "(old value)");
23.212 + check(l.newValue().equals(s), "(new value)");
23.213 +
23.214 + setTest("change the same property on the root");
23.215 + l.reset();
23.216 + String s2 = "This book is about nothing at all";
23.217 + // Change a property on the root - this should raises an event
23.218 + book.setSummary(s2);
23.219 + // Check the received event
23.220 + check(l.oldValue().equals(s), "(old value)");
23.221 + check(l.newValue().equals(s2), "(new value)");
23.222 +
23.223 + setTest("remove this same property");
23.224 + l.reset();
23.225 + // Change a property on the root - this should raises an event
23.226 + book.setSummary(null);
23.227 + // Check the received event
23.228 + check(l.oldValue().equals(s2), "(old value)");
23.229 + check(l.newValue() == null, "(new value)");
23.230 +
23.231 +
23.232 + //
23.233 + // Keep the same event on the root, but change a property of another
23.234 + // property (not a direct property of the root)
23.235 + //
23.236 + setTest("propagation of the event");
23.237 + Chapter c = book.getChapter(0);
23.238 + l.reset();
23.239 + s = c.getComment();
23.240 + s2 = "Comment on the first chapter";
23.241 + c.setComment(s2);
23.242 + check(l.oldValue.equals(s), "(oldvalue)");
23.243 + check(l.newValue.equals(s2), "(newvalue)");
23.244 +
23.245 + // Add three paragraphs
23.246 +
23.247 + setTest("event on indexed property - add new");
23.248 + l.reset();
23.249 + s = "This is a new paragraph";
23.250 + int i = c.addParagraph(s);
23.251 + check(l.oldValue == null, "(no old value - new element)");
23.252 + check(l.newValue.equals(s), "(new value)");
23.253 + check(l.index == i, "(correct index)");
23.254 +
23.255 + setTest("event on indexed property - add new");
23.256 + l.reset();
23.257 + s2 = "This is another paragraph";
23.258 + int j = c.addParagraph(s2);
23.259 + check(l.oldValue == null, "(no old value - new element)");
23.260 + check(l.newValue.equals(s2), "(new value)");
23.261 + check(l.index == j, "(correct index)");
23.262 +
23.263 + setTest("event on indexed property - add new");
23.264 + l.reset();
23.265 + s2 = "This is yet another paragraph";
23.266 + j = c.addParagraph(s2);
23.267 + check(l.oldValue == null, "(no old element - new element)");
23.268 + check(l.newValue.equals(s2), "(new value)");
23.269 + check(l.index == j, "(correct index)");
23.270 +
23.271 + // Remove the first added
23.272 + setTest("event on indexed property - remove index");
23.273 + l.reset();
23.274 + c.setParagraph(i, null);
23.275 + check(l.oldValue.equals(s), "(old value)");
23.276 + check(l.newValue == null, "(no new value)");
23.277 + check(l.index == i, "(correct index)");
23.278 +
23.279 + setTest("event on indexed property - reset new");
23.280 + l.reset();
23.281 + c.setParagraph(i, s);
23.282 + check(l.oldValue == null, "(old value)");
23.283 + check(l.newValue.equals(s), "(no new value)");
23.284 + check(l.index == i, "(correct index)");
23.285 +
23.286 + //
23.287 + // Add another listener on an intermediate node and on a leaf
23.288 + //
23.289 +
23.290 + Chapter c2 = book.getChapter(1);
23.291 +
23.292 + MyListener l2 = new MyListener(c2);
23.293 +
23.294 + // Get the events only for Paragraph changes
23.295 + c2.addPropertyChangeListener("Paragraph", l2);
23.296 +
23.297 + // Check that we receive the event twice
23.298 + setTest("two listeners - both receiving");
23.299 + l2.reset();
23.300 + l.reset();
23.301 + s = "This is a brand new one";
23.302 + c2.addParagraph(s);
23.303 + check(l.oldValue == null, "(no old value)");
23.304 + check(l.newValue.equals(s), "(new value)");
23.305 + check(l.oldValue == l2.oldValue, "(same old value - both listeners)");
23.306 + check(l.newValue.equals(l2.newValue), "(same new value - both listeners)");
23.307 + check(l.index == l2.index, "(same index - both listeners)");
23.308 + check(l.source == l2.source, "(same source - both listeners)");
23.309 +
23.310 + // Check that modifying the comment won't notify the Paragraph listener
23.311 + setTest("two listeners - one receiving");
23.312 + l2.reset();
23.313 + l.reset();
23.314 + s = "That's a new comment value";
23.315 + c2.setComment(s);
23.316 + check(l.newValue.equals(s), "(root listener: yep)");
23.317 + check(l2.newValue == null, "(chapter listener: noop)");
23.318 +
23.319 +
23.320 + // Remove the book listener
23.321 + book.removePropertyChangeListener(l);
23.322 + setTest("one listener - no receiving");
23.323 + l2.reset();
23.324 + l.reset();
23.325 + s = "That's another new comment value";
23.326 + c2.setComment(s);
23.327 + check(l.newValue == null, "(root listener: noop)");
23.328 + check(l2.newValue == null, "(chapter listener: noop)");
23.329 +
23.330 + setTest("one listener - one receiving");
23.331 + l2.reset();
23.332 + l.reset();
23.333 + s = "That's a brand new paragraph";
23.334 + c2.addParagraph(s);
23.335 + check(l.newValue == null, "(root listener: noop)");
23.336 + check(l2.newValue.equals(s), "(chapter listener: yep)");
23.337 +
23.338 + setTest("no listener - no receiving");
23.339 + c2.removePropertyChangeListener("Paragraph", l2);
23.340 + l2.reset();
23.341 + l.reset();
23.342 + s = "That's yet another brand new paragraph";
23.343 + c2.addParagraph(s);
23.344 + check(l.newValue == null, "(root listener: noop)");
23.345 + check(l2.newValue == null, "(chapter listener: noop)");
23.346 +
23.347 + // Register again the listeners
23.348 + book.addPropertyChangeListener(l);
23.349 + c2.addPropertyChangeListener("Paragraph", l2);
23.350 + l.removeMode();
23.351 + l2.removeMode();
23.352 + l2.reset();
23.353 + l.reset();
23.354 + book.removeChapter(c2);
23.355 + out("should have received paragraph events on Chapter and Chapter event on Book");
23.356 +
23.357 + //
23.358 + // Make sure that the event is triggered after the property
23.359 + // has changed.
23.360 + //
23.361 + c = new Chapter();
23.362 + c.addParagraph("1. this is a paragraph");
23.363 + c.addParagraph("2. this is a paragraph");
23.364 + c.addParagraph("3. this is a paragraph");
23.365 + c.addParagraph("4. this is a paragraph");
23.366 + out("should receive Chapter event and get 4 strings from the event");
23.367 + l.traceParagraphs(c);
23.368 + book.addChapter(c);
23.369 + String[] pp = c.getParagraph();
23.370 + String[] pp2 = new String[3];
23.371 + pp2[0] = pp[0];
23.372 + pp2[1] = pp[3];
23.373 + pp2[2] = pp[2];
23.374 + out("should receive Chapter event and get 3 strings from the event (1, 4, 3)");
23.375 + c.setParagraph(pp2);
23.376 + l.traceParagraphs(null);
23.377 + }
23.378 +
23.379 +}
23.380 +
23.381 +
23.382 +
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
24.2 +++ b/schema2beans/test/unit/src/data/TestEvents.xml Wed Jun 19 00:18:25 2002 +0000
24.3 @@ -0,0 +1,62 @@
24.4 +<?xml version="1.0" encoding="ISO-8859-1"?>
24.5 +
24.6 +<book>
24.7 + <chapter>
24.8 + <comment>
24.9 + First chapter.
24.10 + </comment>
24.11 + <paragraph>
24.12 + Once upon a time...
24.13 + </paragraph>
24.14 + <paragraph>
24.15 + And this is how the book met the fairy, and how all this
24.16 + story began.
24.17 + </paragraph>
24.18 + </chapter>
24.19 + <chapter>
24.20 + <paragraph>
24.21 + And the book lived a never ending happy life, read, copied
24.22 + and enjoyed by so many readers.
24.23 + </paragraph>
24.24 + </chapter>
24.25 + <chapter>
24.26 + <comment>
24.27 + Empty chapter
24.28 + </comment>
24.29 + </chapter>
24.30 + <index>
24.31 + <word>
24.32 + Good book
24.33 + </word>
24.34 + <ref>
24.35 + <page>
24.36 + 22
24.37 + </page>
24.38 + <line>
24.39 + 12
24.40 + </line>
24.41 + </ref>
24.42 + </index>
24.43 + <index>
24.44 + <word>
24.45 + E-Tool
24.46 + </word>
24.47 + <ref>
24.48 + <page>
24.49 + 5
24.50 + </page>
24.51 + <line>
24.52 + 15
24.53 + </line>
24.54 + </ref>
24.55 + <ref>
24.56 + <page>
24.57 + 29
24.58 + </page>
24.59 + <line>
24.60 + 31
24.61 + </line>
24.62 + </ref>
24.63 + </index>
24.64 + <good/>
24.65 +</book>
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
25.2 +++ b/schema2beans/test/unit/src/data/TestExceptions.dtd Wed Jun 19 00:18:25 2002 +0000
25.3 @@ -0,0 +1,4 @@
25.4 +<!ELEMENT EXCEPS BLUE?, GREEN?>
25.5 +
25.6 +<!ELEMENT BLUE #PCDATA>
25.7 +<!ELEMENT GREEN EMPTY>
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
26.2 +++ b/schema2beans/test/unit/src/data/TestExceptions.java Wed Jun 19 00:18:25 2002 +0000
26.3 @@ -0,0 +1,72 @@
26.4 +/*
26.5 + * TestExceptions - Make sure we correctly deal with exceptions.
26.6 + *
26.7 + */
26.8 +
26.9 +import java.io.*;
26.10 +import java.util.*;
26.11 +import org.w3c.dom.*;
26.12 +
26.13 +import org.netbeans.modules.schema2beans.*;
26.14 +import exceps.*;
26.15 +
26.16 +
26.17 +public class TestExceptions extends BaseTest {
26.18 + public static void main(String[] argv) {
26.19 + BaseTest o = new TestExceptions();
26.20 + if (argv.length > 0)
26.21 + o.setDocumentDir(argv[0]);
26.22 + try {
26.23 + o.run();
26.24 + } catch (Exception e) {
26.25 + e.printStackTrace();
26.26 + System.exit(1);
26.27 + }
26.28 + System.exit(0);
26.29 + }
26.30 +
26.31 + public void run() throws Exception {
26.32 + Exceps ex;
26.33 +
26.34 + try {
26.35 + out("creating the bean graph");
26.36 + ex = Exceps.createGraph(new FileInputStream(getFullDocumentName()));
26.37 +
26.38 + // Check that we can read the graph an it is complete
26.39 + out("bean graph created");
26.40 +
26.41 + out(ex);
26.42 + } catch (Schema2BeansException e) {
26.43 + out("Hit Exception: "+e.getClass());
26.44 + out(e.getMessage());
26.45 + }
26.46 +
26.47 + return;
26.48 + }
26.49 +
26.50 + void parse(BaseBean bean, String parse) {
26.51 + out("Parsing " + parse);
26.52 + DDParser p = new DDParser(bean, parse);
26.53 + while (p.hasNext()) {
26.54 + Object o = p.next();
26.55 + if (o != null) {
26.56 + if (o instanceof BaseBean)
26.57 + this.out(((BaseBean)o).dumpBeanNode());
26.58 + else
26.59 + this.out(o.toString());
26.60 + }
26.61 + else
26.62 + this.out("null");
26.63 + }
26.64 + }
26.65 +
26.66 + void printChoiceProperties(BaseProperty[] bps) {
26.67 + if (bps == null)
26.68 + err("got null instead a BaseProperty[] instance");
26.69 + else {
26.70 + for (int l=0; l<bps.length; l++)
26.71 + check(bps[l].isChoiceProperty(), bps[l].getDtdName());
26.72 + }
26.73 + }
26.74 +}
26.75 +
27.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
27.2 +++ b/schema2beans/test/unit/src/data/TestExceptions.mdd Wed Jun 19 00:18:25 2002 +0000
27.3 @@ -0,0 +1,24 @@
27.4 +<?xml version="1.0" encoding="UTF-8"?>
27.5 +<metaDD>
27.6 + <throw-exceptions/>
27.7 + <meta-element>
27.8 + <dtd-name>EXCEPS</dtd-name>
27.9 + <bean-name>Exceps</bean-name>
27.10 + <meta-property>
27.11 + <bean-name>Blue</bean-name>
27.12 + </meta-property>
27.13 + <meta-property>
27.14 + <bean-name>Green</bean-name>
27.15 + </meta-property>
27.16 + </meta-element>
27.17 + <meta-element>
27.18 + <dtd-name>BLUE</dtd-name>
27.19 + <bean-name>Blue</bean-name>
27.20 + <wrapper-class>String</wrapper-class>
27.21 + </meta-element>
27.22 + <meta-element>
27.23 + <dtd-name>GREEN</dtd-name>
27.24 + <bean-name>Green</bean-name>
27.25 + <wrapper-class>Boolean</wrapper-class>
27.26 + </meta-element>
27.27 +</metaDD>
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
28.2 +++ b/schema2beans/test/unit/src/data/TestExceptions.xml Wed Jun 19 00:18:25 2002 +0000
28.3 @@ -0,0 +1,3 @@
28.4 +<?xml version='1.0'?>
28.5 +
28.6 +<foo/>
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
29.2 +++ b/schema2beans/test/unit/src/data/TestFind.dtd Wed Jun 19 00:18:25 2002 +0000
29.3 @@ -0,0 +1,53 @@
29.4 +<!-- The following DTD is a simple view of a book:
29.5 +book
29.6 + index
29.7 + +
29.8 + word
29.9 + #PCDATA
29.10 + page
29.11 + #PCDATA
29.12 + chapter+
29.13 + comment?
29.14 + #PCDATA
29.15 + paragraph*
29.16 + #PCDATA
29.17 + summary?
29.18 + #PCDATA
29.19 +
29.20 + good
29.21 + EMPTY
29.22 +-->
29.23 +
29.24 +<!ELEMENT summary (#PCDATA)>
29.25 +
29.26 +<!ELEMENT book (index+, chapter+, summary?, available)>
29.27 +
29.28 +<!ELEMENT available EMPTY>
29.29 +
29.30 +<!ELEMENT index (word, ref+)>
29.31 +
29.32 +<!ELEMENT ref (page, line)>
29.33 +
29.34 +<!ELEMENT word (#PCDATA)>
29.35 +
29.36 +<!ELEMENT line (#PCDATA)>
29.37 +
29.38 +<!ELEMENT page (#PCDATA)>
29.39 +
29.40 +<!ELEMENT chapter (comment?, paragraph*)>
29.41 +
29.42 +<!ELEMENT paragraph (#PCDATA)>
29.43 +
29.44 +<!ELEMENT comment (#PCDATA)>
29.45 +
29.46 +<!ATTLIST book good (yes, no) "yes">
29.47 +<!ATTLIST summary length CDATA #REQUIRED>
29.48 +<!ATTLIST summary lang CDATA #IMPLIED>
29.49 +<!ATTLIST summary size CDATA #FIXED "12">
29.50 +<!ATTLIST chapter title CDATA #IMPLIED>
29.51 +<!ATTLIST index color CDATA #IMPLIED>
29.52 +<!ATTLIST index cross-ref (yes no) "no">
29.53 +<!ATTLIST index glossary CDATA #FIXED "nope">
29.54 +<!ATTLIST word freq CDATA #IMPLIED>
29.55 +
29.56 +
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
30.2 +++ b/schema2beans/test/unit/src/data/TestFind.java Wed Jun 19 00:18:25 2002 +0000
30.3 @@ -0,0 +1,149 @@
30.4 +/*
30.5 + * TestFind - test the find feature
30.6 + *
30.7 + * Search property value, attribute value and any value.
30.8 + *
30.9 + */
30.10 +
30.11 +import java.io.*;
30.12 +import java.util.*;
30.13 +import org.w3c.dom.*;
30.14 +
30.15 +import org.netbeans.modules.schema2beans.*;
30.16 +
30.17 +import java.beans.*;
30.18 +
30.19 +import book.*;
30.20 +
30.21 +
30.22 +public class TestFind extends BaseTest
30.23 +{
30.24 + public static void main(String[] argv) {
30.25 + BaseTest o = new TestFind();
30.26 + if (argv.length > 0)
30.27 + o.setDocumentDir(argv[0]);
30.28 + try {
30.29 + o.run();
30.30 + } catch (Exception e) {
30.31 + e.printStackTrace();
30.32 + System.exit(1);
30.33 + }
30.34 + System.exit(0);
30.35 + }
30.36 +
30.37 +
30.38 + public void run()
30.39 + throws Exception
30.40 + {
30.41 + Book b1, b2, b3;
30.42 +
30.43 + this.readDocument();
30.44 + out("creating the bean graph");
30.45 + Book book = Book.createGraph(doc);
30.46 +
30.47 + //GraphManager.debug(true);
30.48 + // Check that we can read the graph an it is complete
30.49 + out("bean graph created");
30.50 +
30.51 + //
30.52 + // Find property value
30.53 + //
30.54 + setTest("Test findProperty -");
30.55 + String []r = book.findPropertyValue("Word", "Good book");
30.56 + check(r.length == 1, "found element");
30.57 + if (r.length > 0)
30.58 + out(r[0]);
30.59 + r = book.findPropertyValue("Line", "31");
30.60 + check(r.length == 2, "found elements");
30.61 + if (r.length > 1)
30.62 + {
30.63 + out(r[0]);
30.64 + out(r[1]);
30.65 + }
30.66 +
30.67 + r = book.findPropertyValue("Page", "1234");
30.68 + check(r.length == 0, "not found element");
30.69 +
30.70 + //
30.71 + // Find property and/or attribute value
30.72 + //
30.73 + setTest("Test findValue -");
30.74 + r = book.findValue("31");
30.75 + check(r.length == 3, "found elements");
30.76 + if (r.length > 2)
30.77 + {
30.78 + out(r[0]);
30.79 + out(r[1]);
30.80 + out(r[2]);
30.81 + }
30.82 +
30.83 + r = book.findValue("E-Tool");
30.84 + check(r.length == 1, "found element");
30.85 + if (r.length > 0)
30.86 + {
30.87 + out(r[0]);
30.88 + }
30.89 +
30.90 + r = book.findValue("this is not in the XML document");
30.91 + check(r.length == 0, "not found element");
30.92 +
30.93 + r = book.findValue("yes");
30.94 + check(r.length == 2, "found elements");
30.95 + if (r.length > 1)
30.96 + {
30.97 + out(r[0]);
30.98 + out(r[1]);
30.99 + }
30.100 +
30.101 + r = book.findValue("no");
30.102 + check(r.length == 1, "found element");
30.103 + if (r.length > 0)
30.104 + {
30.105 + out(r[0]);
30.106 + }
30.107 +
30.108 + //
30.109 + // Find attribute value
30.110 + //
30.111 + setTest("Test findAttributeValue -");
30.112 + r = book.findAttributeValue("Color", "red");
30.113 + check(r.length == 1, "found element");
30.114 + if (r.length > 0)
30.115 + {
30.116 + out(r[0]);
30.117 + }
30.118 +
30.119 + // try with the dtd name (color instead of Color)
30.120 + r = book.findAttributeValue("color", "blue");
30.121 + check(r.length == 1, "found element");
30.122 + if (r.length > 0)
30.123 + {
30.124 + out(r[0]);
30.125 + }
30.126 +
30.127 + r = book.findAttributeValue("Color", "black");
30.128 + check(r.length == 0, "not found element");
30.129 +
30.130 + r = book.findAttributeValue("freq", "1");
30.131 + check(r.length == 2, "found elements");
30.132 + if (r.length > 1)
30.133 + {
30.134 + out(r[0]);
30.135 + out(r[1]);
30.136 + }
30.137 +
30.138 + r = book.findAttributeValue("Good", "no");
30.139 + check(r.length == 1, "found element");
30.140 + if (r.length > 0)
30.141 + {
30.142 + out(r[0]);
30.143 + }
30.144 +
30.145 + //
30.146 + // Try to remove an element by value the by reference
30.147 + //
30.148 +
30.149 + }
30.150 +}
30.151 +
30.152 +
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
31.2 +++ b/schema2beans/test/unit/src/data/TestFind.xml Wed Jun 19 00:18:25 2002 +0000
31.3 @@ -0,0 +1,69 @@
31.4 +<?xml version="1.0" encoding="ISO-8859-1"?>
31.5 +
31.6 +<book good="no">
31.7 + <summary size="12" lang="en" length="132">
31.8 + This book is about the life of a book spent between books who dreamed
31.9 + to meet a fairy who could transform it into an XML book and travel
31.10 + in an electronic boundary-less world.
31.11 + </summary>
31.12 + <chapter>
31.13 + <comment>
31.14 + First chapter.
31.15 + </comment>
31.16 + <paragraph>
31.17 + Once upon a time...
31.18 + </paragraph>
31.19 + <paragraph>
31.20 + And this is how the book met the fairy, and how all this
31.21 + story began.
31.22 + </paragraph>
31.23 + </chapter>
31.24 + <chapter>
31.25 + <comment>
31.26 + yes
31.27 + </comment>
31.28 + <paragraph>
31.29 + And the book lived a never ending happy life, read, copied
31.30 + and enjoyed by so many readers.
31.31 + </paragraph>
31.32 + </chapter>
31.33 + <chapter>
31.34 + <comment>
31.35 + Empty chapter
31.36 + </comment>
31.37 + </chapter>
31.38 + <index color="red" cross-ref="yes">
31.39 + <word freq="1">
31.40 + Good book
31.41 + </word>
31.42 + <ref>
31.43 + <page>
31.44 + 22
31.45 + </page>
31.46 + <line>
31.47 + 31
31.48 + </line>
31.49 + </ref>
31.50 + </index>
31.51 + <index color="blue">
31.52 + <word freq="1">
31.53 + E-Tool
31.54 + </word>
31.55 + <ref>
31.56 + <page>
31.57 + 5
31.58 + </page>
31.59 + <line>
31.60 + 15
31.61 + </line>
31.62 + </ref>
31.63 + <ref>
31.64 + <page>
31.65 + 31
31.66 + </page>
31.67 + <line>
31.68 + 31
31.69 + </line>
31.70 + </ref>
31.71 + </index>
31.72 +</book>
32.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
32.2 +++ b/schema2beans/test/unit/src/data/TestMdd.dtd Wed Jun 19 00:18:25 2002 +0000
32.3 @@ -0,0 +1,45 @@
32.4 +<!-- The following DTD is a simple view of a book:
32.5 + Index[1,n]
32.6 + Alpha - String
32.7 + Word - String
32.8 + Ref[1,n]
32.9 + Page - String
32.10 + Line[1,n] - String
32.11 + Chapter[1,n]
32.12 + Comment? - String
32.13 + Paragraph[0,n] - String
32.14 + Summary? - String
32.15 + Available - Boolean
32.16 + Price - String
32.17 + Date - String
32.18 +-->
32.19 +
32.20 +<!ELEMENT summary (#PCDATA)>
32.21 +
32.22 +<!ELEMENT book (index+, chapter+, summary?, available, price, date)>
32.23 +
32.24 +<!ELEMENT available EMPTY>
32.25 +
32.26 +<!ELEMENT index (alpha, word, ref+)>
32.27 +
32.28 +<!ELEMENT ref (page, line+)>
32.29 +
32.30 +<!ELEMENT alpha (#PCDATA)>
32.31 +
32.32 +<!ELEMENT price (#PCDATA)>
32.33 +
32.34 +<!ELEMENT date (#PCDATA)>
32.35 +
32.36 +<!ELEMENT word (#PCDATA)>
32.37 +
32.38 +<!ELEMENT line (#PCDATA)>
32.39 +
32.40 +<!ELEMENT page (#PCDATA)>
32.41 +
32.42 +<!ELEMENT chapter (comment?, paragraph*)>
32.43 +
32.44 +<!ELEMENT paragraph (#PCDATA)>
32.45 +
32.46 +<!ELEMENT comment (#PCDATA)>
32.47 +
32.48 +
33.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
33.2 +++ b/schema2beans/test/unit/src/data/TestMdd.java Wed Jun 19 00:18:25 2002 +0000
33.3 @@ -0,0 +1,93 @@
33.4 +/*
33.5 + * TestMdd - test the attribute features
33.6 + *
33.7 + * TestMdd.dtd and TestMdd.xml has to be kept in sync with this test.
33.8 + */
33.9 +
33.10 +import java.io.*;
33.11 +import java.util.*;
33.12 +import org.w3c.dom.*;
33.13 +
33.14 +import org.netbeans.modules.schema2beans.*;
33.15 +import java.beans.*;
33.16 +import book.*;
33.17 +
33.18 +
33.19 +public class TestMdd extends BaseTest
33.20 +{
33.21 + public static void main(String[] argv) {
33.22 + BaseTest o = new TestMdd();
33.23 + if (argv.length > 0)
33.24 + o.setDocumentDir(argv[0]);
33.25 + try {
33.26 + o.run();
33.27 + } catch (Exception e) {
33.28 + e.printStackTrace();
33.29 + System.exit(1);
33.30 + }
33.31 + System.exit(0);
33.32 + }
33.33 +
33.34 + public void run()
33.35 + throws Exception
33.36 + {
33.37 + Book book;
33.38 +
33.39 + this.readDocument();
33.40 + out("creating the bean graph");
33.41 + //out(DDFactory.XmlToString(doc));
33.42 + book = Book.createGraph(doc);
33.43 + out("bean graph created");
33.44 +
33.45 + // Check Wrapper class and float scalar
33.46 + {
33.47 + setTest("get non scalar wrapper object");
33.48 + Object obj = book.getDate();
33.49 + check(obj instanceof book.MyDate);
33.50 + out(obj.toString());
33.51 +
33.52 + setTest("get float scalar value");
33.53 + float f = book.getPrice();
33.54 + float ref = (float)10.95;
33.55 + float f2 = (float)9.99;
33.56 + check(f == ref);
33.57 + out("Setting new price to " + f2);
33.58 + book.setPrice(f2);
33.59 + f = book.getPrice();
33.60 + check(f == f2);
33.61 + out("Price and date should match", book.dumpDomNode(2));
33.62 + }
33.63 +
33.64 + // Check Character
33.65 + {
33.66 + setTest("get char scalar value");
33.67 + Index idx = book.getIndex(0);
33.68 + char c = idx.getAlpha();
33.69 + check(c == 'a');
33.70 + idx.setAlpha('x');
33.71 + check(idx.getAlpha() == 'x');
33.72 + out("Alpha should be 'x'", idx.dumpDomNode(2));
33.73 + }
33.74 +
33.75 + // Check Integer as an indexed property
33.76 + {
33.77 + setTest("get int/int[] scalar values");
33.78 + Ref ref = book.getIndex(0).getRef(0);
33.79 + int[] i = ref.getLine();
33.80 + check(i.length == 3);
33.81 + check(ref.getPage() == 22);
33.82 + check(i[0] == 12);
33.83 + check(i[1] == 22);
33.84 + check(i[2] == 32);
33.85 + i[2] = 323;
33.86 + ref.setLine(i);
33.87 + check(ref.getPage() == 22);
33.88 + check(ref.getLine(0) == 12);
33.89 + check(ref.getLine(1) == 22);
33.90 + check(ref.getLine(2) == 323);
33.91 + out("Lines should be 12/22/323", ref.dumpDomNode(2));
33.92 + }
33.93 + }
33.94 +}
33.95 +
33.96 +
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
34.2 +++ b/schema2beans/test/unit/src/data/TestMdd.mdd Wed Jun 19 00:18:25 2002 +0000
34.3 @@ -0,0 +1,114 @@
34.4 +<?xml version="1.0" encoding="UTF-8"?>
34.5 +
34.6 +<metaDD>
34.7 + <meta-element>
34.8 + <bean-name>Word</bean-name>
34.9 + <wrapper-class>String</wrapper-class>
34.10 + <dtd-name>word</dtd-name>
34.11 + <known-value>This is a known value</known-value>
34.12 + <known-value>This is another known value</known-value>
34.13 + </meta-element>
34.14 + <meta-element>
34.15 + <bean-name>Chapter</bean-name>
34.16 + <dtd-name>chapter</dtd-name>
34.17 + <meta-property>
34.18 + <bean-name>Comment</bean-name>
34.19 + </meta-property>
34.20 + <meta-property>
34.21 + <bean-name>Paragraph</bean-name>
34.22 + </meta-property>
34.23 + </meta-element>
34.24 + <meta-element>
34.25 + <bean-name>Ref</bean-name>
34.26 + <dtd-name>ref</dtd-name>
34.27 + <meta-property>
34.28 + <bean-name>Page</bean-name>
34.29 + </meta-property>
34.30 + <meta-property>
34.31 + <bean-name>Line</bean-name>
34.32 + </meta-property>
34.33 + </meta-element>
34.34 + <meta-element>
34.35 + <bean-name>Available</bean-name>
34.36 + <wrapper-class>Boolean</wrapper-class>
34.37 + <dtd-name>available</dtd-name>
34.38 + </meta-element>
34.39 + <meta-element>
34.40 + <bean-name>Date</bean-name>
34.41 + <wrapper-class>book.MyDate</wrapper-class>
34.42 + <dtd-name>date</dtd-name>
34.43 + </meta-element>
34.44 + <meta-element>
34.45 + <bean-name>Book</bean-name>
34.46 + <dtd-name>book</dtd-name>
34.47 + <meta-property>
34.48 + <bean-name>Index</bean-name>
34.49 + </meta-property>
34.50 + <meta-property>
34.51 + <bean-name>Chapter</bean-name>
34.52 + </meta-property>
34.53 + <meta-property>
34.54 + <bean-name>Summary</bean-name>
34.55 + </meta-property>
34.56 + <meta-property>
34.57 + <bean-name>Available</bean-name>
34.58 + </meta-property>
34.59 + <meta-property>
34.60 + <bean-name>Price</bean-name>
34.61 + </meta-property>
34.62 + <meta-property>
34.63 + <bean-name>Date</bean-name>
34.64 + </meta-property>
34.65 + </meta-element>
34.66 + <meta-element>
34.67 + <bean-name>Alpha</bean-name>
34.68 + <wrapper-class>char</wrapper-class>
34.69 + <dtd-name>alpha</dtd-name>
34.70 + </meta-element>
34.71 + <meta-element>
34.72 + <bean-name>Paragraph</bean-name>
34.73 + <wrapper-class>String</wrapper-class>
34.74 + <dtd-name>paragraph</dtd-name>
34.75 + </meta-element>
34.76 + <meta-element>
34.77 + <bean-name>Comment</bean-name>
34.78 + <wrapper-class>String</wrapper-class>
34.79 + <dtd-name>comment</dtd-name>
34.80 + </meta-element>
34.81 + <meta-element>
34.82 + <bean-name>Price</bean-name>
34.83 + <wrapper-class>float</wrapper-class>
34.84 + <dtd-name>price</dtd-name>
34.85 + </meta-element>
34.86 + <meta-element>
34.87 + <bean-name>Index</bean-name>
34.88 + <dtd-name>index</dtd-name>
34.89 + <meta-property>
34.90 + <bean-name>Alpha</bean-name>
34.91 + </meta-property>
34.92 + <meta-property>
34.93 + <bean-name>Word</bean-name>
34.94 + </meta-property>
34.95 + <meta-property>
34.96 + <bean-name>Ref</bean-name>
34.97 + </meta-property>
34.98 + </meta-element>
34.99 + <meta-element>
34.100 + <bean-name>Page</bean-name>
34.101 + <wrapper-class>int</wrapper-class>
34.102 + <dtd-name>page</dtd-name>
34.103 + <known-value>10</known-value>
34.104 + <known-value>20</known-value>
34.105 + </meta-element>
34.106 + <meta-element>
34.107 + <bean-name>Summary</bean-name>
34.108 + <wrapper-class>String</wrapper-class>
34.109 + <dtd-name>summary</dtd-name>
34.110 + </meta-element>
34.111 + <meta-element>
34.112 + <bean-name>Line</bean-name>
34.113 + <wrapper-class>int</wrapper-class>
34.114 + <dtd-name>line</dtd-name>
34.115 + </meta-element>
34.116 +</metaDD>
34.117 +
35.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
35.2 +++ b/schema2beans/test/unit/src/data/TestMdd.xml Wed Jun 19 00:18:25 2002 +0000
35.3 @@ -0,0 +1,75 @@
35.4 +<?xml version="1.0" encoding="ISO-8859-1"?>
35.5 +
35.6 +<book>
35.7 + <summary>
35.8 + This book is about the life of a book spent between books who dreamed
35.9 + to meet a fairy who could transform it into an XML book and travel
35.10 + in an electronic boundary-less world.
35.11 + </summary>
35.12 + <price>10.95</price>
35.13 + <date>14/07/2000</date>
35.14 + <chapter>
35.15 + <comment>
35.16 + First chapter.
35.17 + </comment>
35.18 + <paragraph>
35.19 + Once upon a time...
35.20 + </paragraph>
35.21 + <paragraph>
35.22 + And this is how the book met the fairy, and how all this
35.23 + story began.
35.24 + </paragraph>
35.25 + </chapter>
35.26 + <chapter>
35.27 + <paragraph>
35.28 + And the book lived a never ending happy life, read, copied
35.29 + and enjoyed by so many readers.
35.30 + </paragraph>
35.31 + </chapter>
35.32 + <chapter>
35.33 + <comment>
35.34 + Empty chapter
35.35 + </comment>
35.36 + </chapter>
35.37 + <index>
35.38 + <alpha>a</alpha>
35.39 + <word>
35.40 + Good book
35.41 + </word>
35.42 + <ref>
35.43 + <page>
35.44 + 22
35.45 + </page>
35.46 + <line>
35.47 + 12
35.48 + </line>
35.49 + <line>
35.50 + 22
35.51 + </line>
35.52 + <line>
35.53 + 32
35.54 + </line>
35.55 + </ref>
35.56 + </index>
35.57 + <index>
35.58 + <word>
35.59 + E-Tool
35.60 + </word>
35.61 + <ref>
35.62 + <page>
35.63 + 5
35.64 + </page>
35.65 + <line>
35.66 + 15
35.67 + </line>
35.68 + </ref>
35.69 + <ref>
35.70 + <page>
35.71 + 29
35.72 + </page>
35.73 + <line>
35.74 + 31
35.75 + </line>
35.76 + </ref>
35.77 + </index>
35.78 +</book>
36.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
36.2 +++ b/schema2beans/test/unit/src/data/TestMerge.dtd Wed Jun 19 00:18:25 2002 +0000
36.3 @@ -0,0 +1,68 @@
36.4 +<!-- The following DTD is a simple view of a book:
36.5 +Tree:
36.6 +book
36.7 + title
36.8 + #PCDATA
36.9 + index*
36.10 + word
36.11 + #PCDATA
36.12 + ref+
36.13 + page
36.14 + #PCDATA
36.15 + line
36.16 + #PCDATA
36.17 + chapter+
36.18 + number
36.19 + #PCDATA
36.20 + comment?
36.21 + #PCDATA
36.22 + paragraph*
36.23 + #PCDATA
36.24 + summary?
36.25 + #PCDATA
36.26 + instock
36.27 + EMPTY
36.28 +-->
36.29 +
36.30 +
36.31 +<!ELEMENT book (title, author+, index*, chapter+, summary?, instock, content)>
36.32 +
36.33 +<!ELEMENT content (title, comment)>
36.34 +
36.35 +<!ELEMENT title (#PCDATA)>
36.36 +
36.37 +<!ELEMENT author (#PCDATA)>
36.38 +
36.39 +<!ELEMENT summary (#PCDATA)>
36.40 +
36.41 +<!ELEMENT instock EMPTY>
36.42 +
36.43 +<!ELEMENT index (word, ref+)>
36.44 +
36.45 +<!ELEMENT ref (page, line)>
36.46 +
36.47 +<!ELEMENT word (#PCDATA)>
36.48 +
36.49 +<!ELEMENT line (#PCDATA)>
36.50 +
36.51 +<!ELEMENT page (#PCDATA)>
36.52 +
36.53 +<!ELEMENT chapter (number, comment?, paragraph*)>
36.54 +
36.55 +<!ELEMENT number (#PCDATA)>
36.56 +
36.57 +<!ELEMENT paragraph (#PCDATA)>
36.58 +
36.59 +<!ELEMENT comment (#PCDATA)>
36.60 +
36.61 +<!ATTLIST book good (yes, no) "yes">
36.62 +<!ATTLIST summary length CDATA #REQUIRED>
36.63 +<!ATTLIST summary lang CDATA #IMPLIED>
36.64 +<!ATTLIST paragraph opt CDATA #IMPLIED>
36.65 +<!ATTLIST summary size CDATA #FIXED "12">
36.66 +<!ATTLIST chapter title CDATA #IMPLIED>
36.67 +<!ATTLIST index color CDATA #IMPLIED>
36.68 +<!ATTLIST index cross-ref (yes no) "no">
36.69 +
36.70 +
36.71 +
37.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
37.2 +++ b/schema2beans/test/unit/src/data/TestMerge.java Wed Jun 19 00:18:25 2002 +0000
37.3 @@ -0,0 +1,535 @@
37.4 +/*
37.5 + * TestMerge - test the basic features.
37.6 + *
37.7 + */
37.8 +
37.9 +import java.io.*;
37.10 +import java.util.*;
37.11 +import org.w3c.dom.*;
37.12 +
37.13 +import org.netbeans.modules.schema2beans.*;
37.14 +
37.15 +import java.beans.*;
37.16 +
37.17 +import book.*;
37.18 +
37.19 +
37.20 +public class TestMerge extends BaseTest {
37.21 + public static void main(String[] argv) {
37.22 + BaseTest o = new TestMerge();
37.23 + if (argv.length > 0)
37.24 + o.setDocumentDir(argv[0]);
37.25 + try {
37.26 + o.run();
37.27 + } catch (Exception e) {
37.28 + e.printStackTrace();
37.29 + System.exit(1);
37.30 + }
37.31 + System.exit(0);
37.32 + }
37.33 +
37.34 +
37.35 +
37.36 + //
37.37 + // This is the reference number for memory consumption for 50 clones
37.38 + // (simply ran the test to get the number). We check against this number
37.39 + // to make sure that any change in schema2beans does not introduce a
37.40 + // significant increase of mem usage.
37.41 + //
37.42 + static float memUsageReference = 5314;
37.43 +
37.44 +
37.45 + public class MyListener implements PropertyChangeListener {
37.46 + GraphManager gm;
37.47 + String listenerName;
37.48 + Object oldValue;
37.49 + Object newValue;
37.50 + String propertyName;
37.51 + Object source;
37.52 + int index;
37.53 + boolean mute;
37.54 + boolean remove;
37.55 +
37.56 + public MyListener(BaseBean bean) {
37.57 + this.listenerName = bean.name();
37.58 + gm = bean.graphManager();
37.59 + this.remove = false;
37.60 + this.mute = false;
37.61 + out("new listener for " + this.listenerName);
37.62 + }
37.63 +
37.64 + public void reset() {
37.65 + this.oldValue = null;
37.66 + this.newValue = null;
37.67 + this.propertyName = null;
37.68 + this.source = null;
37.69 + this.index = -1;
37.70 + }
37.71 +
37.72 + public void propertyChange(PropertyChangeEvent e) {
37.73 + if (this.mute)
37.74 + return;
37.75 +
37.76 + String k;
37.77 + this.oldValue = e.getOldValue();
37.78 + this.newValue = e.getNewValue();
37.79 + this.propertyName = e.getPropertyName();
37.80 + this.source = e.getSource();
37.81 + String n = this.propertyName;
37.82 + this.index = gm.getPropertyIndex(n);
37.83 +
37.84 + if (this.newValue == null)
37.85 + k = "Rmv";
37.86 + else
37.87 + if (this.oldValue == null)
37.88 + k = "Add";
37.89 + else
37.90 + k = "Chg";
37.91 +
37.92 + out("<" + k + " Lnr:" + this.listenerName + " Evt:" + n +
37.93 + " Src:" + this.source.getClass().getName() + ">");
37.94 + if (remove) {
37.95 + out("<" + gm.getPropertyName(n) + "[" + this.index +
37.96 + "]" + " - Parent: " + gm.getPropertyParentName(n) + ">");
37.97 + }
37.98 + else {
37.99 + out("<" + gm.getPropertyName(n) + "[" + this.index +
37.100 + "]" + " - Parent: " + gm.getPropertyParentName(n) +
37.101 + "/" + gm.getPropertyParent(n).getClass().getName() + ">");
37.102 + }
37.103 +
37.104 + //out("received " + this.oldValue + "/" + this.newValue + "/" +
37.105 + // this.propertyName);
37.106 + }
37.107 +
37.108 + public void removeMode() {
37.109 + this.remove = true;
37.110 + }
37.111 +
37.112 + public Object oldValue() {
37.113 + return this.oldValue;
37.114 + }
37.115 +
37.116 + public String stringOldValue() {
37.117 + if (this.oldValue == null)
37.118 + return "<null>";
37.119 + else
37.120 + return this.oldValue.toString();
37.121 + }
37.122 +
37.123 + public Object newValue() {
37.124 + return this.newValue;
37.125 + }
37.126 +
37.127 + public String stringNewValue() {
37.128 + if (this.newValue == null)
37.129 + return "<null>";
37.130 + else
37.131 + return this.newValue.toString();
37.132 + }
37.133 +
37.134 + public String name() {
37.135 + return this.propertyName;
37.136 + }
37.137 +
37.138 + public void mute(boolean mute) {
37.139 + this.mute = mute;
37.140 + }
37.141 +
37.142 + public String toString() {
37.143 + return this.name() + " raised from source " +
37.144 + this.source.getClass().getName();
37.145 + }
37.146 + }
37.147 +
37.148 + private MyListener l1, l2, l3;
37.149 +
37.150 + void mute(boolean mute) {
37.151 + if (l1 != null)
37.152 + l1.mute(mute);
37.153 + if (l2 != null)
37.154 + l2.mute(mute);
37.155 + if (l3 != null)
37.156 + l3.mute(mute);
37.157 + }
37.158 +
37.159 + public void run()
37.160 + throws Exception {
37.161 + Book b1, b2, b3;
37.162 +
37.163 + this.readDocument("tm01_g1.xml");
37.164 + out("creating the bean graph1");
37.165 + b1 = Book.createGraph(doc);
37.166 +
37.167 + this.readDocument("tm01_g1.xml");
37.168 + out("creating the bean graph2");
37.169 + b2 = Book.createGraph(doc);
37.170 +
37.171 + l1 = new MyListener(b1);
37.172 + b1.addPropertyChangeListener(l1);
37.173 +
37.174 + // b2 should never change, so we should never receive anything
37.175 + // on this listener
37.176 + l2 = new MyListener(b2);
37.177 + b2.addPropertyChangeListener(l2);
37.178 +
37.179 + //
37.180 + // Merge two identical graphs
37.181 + //
37.182 + setTest("Merge(Update) - two identical xml files");
37.183 + out("should not get any event");
37.184 + b1.merge(b2);
37.185 + check(b1.toString().equals(b2.toString()), " - no diff");
37.186 + check(b1.equals(b2), " - equals");
37.187 +
37.188 + // One mixed up document, but should be the same
37.189 + setTest("Merge(Update) - two identical xml files (one mixed up)");
37.190 + this.readDocument("tm01_g2.xml");
37.191 + out("creating the bean graph3");
37.192 + b3 = Book.createGraph(doc);
37.193 +
37.194 + l3 = new MyListener(b3);
37.195 + b3.addPropertyChangeListener(l3);
37.196 +
37.197 + b3.merge(b1);
37.198 + check(b3.equals(b1), " - equals");
37.199 +
37.200 + //
37.201 + // Change only one element of the second graph
37.202 + //
37.203 + setTest("Merge(Update) - changing one property");
37.204 + String s1 = "This is the new summary";
37.205 + String s2 = b2.getSummary();
37.206 +
37.207 + // g1/g2
37.208 + this.mute(true);
37.209 + b2.setSummary(s1);
37.210 + out("should get one event for Summary");
37.211 + this.mute(false);
37.212 + b1.merge(b2);
37.213 +
37.214 + b1.write(System.out);
37.215 +
37.216 + check(b2.equals(b1), " - equals");
37.217 + // g1/g3
37.218 + this.mute(true);
37.219 + b1.setSummary(s2);
37.220 + this.mute(false);
37.221 + out("should not get any event");
37.222 + b1.merge(b3);
37.223 + check(b3.equals(b1), " - equals");
37.224 + this.mute(true);
37.225 + b2.setSummary(s2);
37.226 +
37.227 + //
37.228 + // Mixing array of strings
37.229 + //
37.230 + setTest("Merge(Update) - mixing array of strings");
37.231 + check(b1.getAuthor(0).equals(b2.getAuthor(0)), "initial match");
37.232 + check(b1.getAuthor(1).equals(b2.getAuthor(1)), "initial match");
37.233 + check(b1.getAuthor(2).equals(b2.getAuthor(2)), "initial match");
37.234 + this.mute(false);
37.235 + String [] ss1 = b2.getAuthor();
37.236 + String [] ss2 = new String[3];
37.237 + ss2[0] = ss1[2];
37.238 + ss2[1] = ss1[1];
37.239 + ss2[2] = ss1[0];
37.240 + b2.setAuthor(ss2);
37.241 + check(b1.getAuthor(0).equals(b2.getAuthor(2)), "mixed");
37.242 + check(b1.getAuthor(1).equals(b2.getAuthor(1)), "mixed");
37.243 + check(b1.getAuthor(2).equals(b2.getAuthor(0)), "mixed");
37.244 + out("should not get any event");
37.245 + b1.merge(b2);
37.246 + check(b2.equals(b1), " - equals");
37.247 + this.mute(true);
37.248 + b2.setAuthor(ss1);
37.249 + check(b1.getAuthor(0).equals(b2.getAuthor(0)), "reset match");
37.250 + check(b1.getAuthor(1).equals(b2.getAuthor(1)), "reset match");
37.251 + check(b1.getAuthor(2).equals(b2.getAuthor(2)), "reset match");
37.252 +
37.253 + //
37.254 + // Mixing array of beans
37.255 + //
37.256 + setTest("Merge(Update) - mixing array of beans");
37.257 + check(b1.getChapter(0).equals(b2.getChapter(0)), "initial match");
37.258 + check(b1.getChapter(1).equals(b2.getChapter(1)), "initial match");
37.259 + check(b1.getChapter(2).equals(b2.getChapter(2)), "initial match");
37.260 + this.mute(false);
37.261 + Chapter [] cc1 = b2.getChapter();
37.262 + Chapter [] cc2 = new Chapter[3];
37.263 + cc2[0] = cc1[2];
37.264 + cc2[1] = cc1[1];
37.265 + cc2[2] = cc1[0];
37.266 + b2.setChapter(cc2);
37.267 + check(b1.getChapter(0).equals(b2.getChapter(2)), "mixed");
37.268 + check(b1.getChapter(1).equals(b2.getChapter(1)), "mixed");
37.269 + check(b1.getChapter(2).equals(b2.getChapter(0)), "mixed");
37.270 + out("should not get any event");
37.271 + b1.merge(b2);
37.272 + check(b2.equals(b1), " - equals");
37.273 + this.mute(true);
37.274 + b2.setChapter(cc1);
37.275 + check(b1.getChapter(0).equals(b2.getChapter(0)), "reset match");
37.276 + check(b1.getChapter(1).equals(b2.getChapter(1)), "reset match");
37.277 + check(b1.getChapter(2).equals(b2.getChapter(2)), "reset match");
37.278 +
37.279 + //
37.280 + // Removing a String elt from an array
37.281 + //
37.282 + setTest("Merge(Update) - remove elt from array of strings");
37.283 + check(b1.getAuthor(0).equals(b2.getAuthor(0)), "initial match");
37.284 + check(b1.getAuthor(1).equals(b2.getAuthor(1)), "initial match");
37.285 + check(b1.getAuthor(2).equals(b2.getAuthor(2)), "initial match");
37.286 + this.mute(false);
37.287 + s1 = b2.getAuthor(1);
37.288 + out("should get one remove event from deletion");
37.289 + b2.removeAuthor(s1);
37.290 + check(b1.getAuthor(0).equals(b2.getAuthor(0)), "match after rem");
37.291 + check(b1.getAuthor(2).equals(b2.getAuthor(1)), "match after rem");
37.292 + out("should get one remove event from merge");
37.293 + b1.merge(b2);
37.294 + check(b1.getAuthor(0).equals(b2.getAuthor(0)), "match");
37.295 + check(b1.getAuthor(1).equals(b2.getAuthor(1)), "match");
37.296 + check(b1.sizeAuthor() == b2.sizeAuthor(), "correct size");
37.297 + check(b2.equals(b1), " - equals");
37.298 +
37.299 + //
37.300 + // Adding a String elt from an array
37.301 + //
37.302 + setTest("Merge(Update) - add elt from array of strings");
37.303 + this.mute(false);
37.304 + out("should get one event for elt added");
37.305 + b2.addAuthor(s1);
37.306 + check(b2.getAuthor(2).equals(s1), "added");
37.307 + out("should get one event for elt added from merge");
37.308 + b1.merge(b2);
37.309 + check(b1.getAuthor(0).equals(b2.getAuthor(0)), "match");
37.310 + check(b1.getAuthor(1).equals(b2.getAuthor(1)), "match");
37.311 + check(b1.getAuthor(2).equals(b2.getAuthor(2)), "match");
37.312 + check(b1.sizeAuthor() == b2.sizeAuthor(), "correct size");
37.313 + check(b2.equals(b1), " - equals");
37.314 +
37.315 + //
37.316 + // Removing a Bean elt from an array
37.317 + //
37.318 + setTest("Merge(Update) - remove elt from array of beans");
37.319 + check(b1.getChapter(0).equals(b2.getChapter(0)), "initial match");
37.320 + check(b1.getChapter(1).equals(b2.getChapter(1)), "initial match");
37.321 + check(b1.getChapter(2).equals(b2.getChapter(2)), "initial match");
37.322 + this.mute(false);
37.323 + Chapter c1 = b2.getChapter(1);
37.324 + Chapter c2 = (Chapter)c1.clone();
37.325 + out("should get one remove event from deletion");
37.326 + b2.removeChapter(c1);
37.327 + check(b1.getChapter(0).equals(b2.getChapter(0)), "match after rem");
37.328 + check(b1.getChapter(2).equals(b2.getChapter(1)), "match after rem");
37.329 + out("should get one remove event from merge");
37.330 + b1.merge(b2);
37.331 + check(b1.getChapter(0).equals(b2.getChapter(0)), "match");
37.332 + check(b1.getChapter(1).equals(b2.getChapter(1)), "match");
37.333 + check(b1.sizeChapter() == b2.sizeChapter(), "correct size");
37.334 + check(b2.equals(b1), " - equals");
37.335 +
37.336 + //
37.337 + // Adding a Bean elt from an array
37.338 + //
37.339 + setTest("Merge(Update) - add elt from array of strings");
37.340 + this.mute(false);
37.341 + out("should get one event for elt added");
37.342 + b2.addChapter(c2);
37.343 + check(b2.getChapter(2).equals(c2), "added");
37.344 + out("should get one event for elt added from merge");
37.345 + b1.merge(b2);
37.346 + check(b1.getChapter(0).equals(b2.getChapter(0)), "match");
37.347 + check(b1.getChapter(1).equals(b2.getChapter(1)), "match");
37.348 + check(b1.getChapter(2).equals(b2.getChapter(2)), "match");
37.349 + check(b1.sizeChapter() == b2.sizeChapter(), "correct size");
37.350 + check(b2.equals(b1), " - equals");
37.351 +
37.352 +
37.353 + //
37.354 + // Compare two graphs with missing nodes and elements
37.355 + //
37.356 + Book b4, b5, b6;
37.357 +
37.358 + this.readDocument("tm01_g1.xml");
37.359 + out("creating the bean graph1");
37.360 + b4 = Book.createGraph(doc);
37.361 +
37.362 + b5 = (Book)b4.clone();
37.363 + b6 = (Book)b4.clone();
37.364 +
37.365 + setTest("comparing graphs with 1 null elts");
37.366 + check(b4.sizeChapter() == 3);
37.367 + check(b5.sizeChapter() == 3);
37.368 +
37.369 + // bean[] full / bean null
37.370 + check(b4.equals(b5));
37.371 +
37.372 + setTest("comparing graphs with null indexed elts");
37.373 + // g1.bean[] has 1 null / g2.bean[] has 1 null / bean null
37.374 + b4.setChapter(1, null);
37.375 + b5.setChapter(2, null);
37.376 + check(!b4.equals(b5));
37.377 + b4.merge(b5);
37.378 + check(b4.sizeChapter() == 3, "correct new array sise");
37.379 + check(b4.getChapter(0).equals(b5.getChapter(0)), "elt ok");
37.380 + check(b4.getChapter(1) == null, "elt ok");
37.381 + check(b4.getChapter(2).equals(b5.getChapter(1)), "elt ok");
37.382 +
37.383 + setTest("comparing graphs with null single bean elt");
37.384 + // g1.bean non null / g2.bean is null
37.385 + b4 = (Book)b6.clone();
37.386 + b5 = (Book)b6.clone();
37.387 + Content ct = new Content();
37.388 + ct.setTitle("This is a title");
37.389 + ct.setComment("And this is a comment");
37.390 + check(b4.equals(b5));
37.391 + b5.setContent(ct);
37.392 + check(!b4.equals(b5));
37.393 + b4.merge(b5);
37.394 + check(b4.getContent().equals(b5.getContent()));
37.395 +
37.396 + // Clone an element which is not part of a graph
37.397 + Chapter c3 = new Chapter();
37.398 + c3.setComment("This is a comment");
37.399 + c3.setNumber("123");
37.400 + c3.addParagraph("This is a new paragraph");
37.401 + Chapter c4 = (Chapter)c3.clone();
37.402 +
37.403 + // Add both elements to two identical graphs - should get two
37.404 + // identical graphs
37.405 + setTest("cloning a new bean");
37.406 + Book b7 = (Book)b2.clone();
37.407 + Book b8 = (Book)b2.clone();
37.408 + b7.addChapter(c3);
37.409 + b8.addChapter(c4);
37.410 + check(c3.equals(c4), "objects equal");
37.411 + check(b7.equals(b8), "same graph once added");
37.412 +
37.413 + //
37.414 + // Test the attributes. When we merge graphs, we need to make
37.415 + // sure that the attributes are also merged.
37.416 + //
37.417 + this.readDocument("tm01_g2.xml");
37.418 + out("creating the bean graph1");
37.419 + b1 = Book.createGraph(doc);
37.420 +
37.421 + // g3 and g2 elements are identicals, g3 has attributes,
37.422 + // g2 has not.
37.423 + this.readDocument("tm01_g3.xml");
37.424 + out("creating the bean graph2");
37.425 + b2 = Book.createGraph(doc);
37.426 +
37.427 + // Make sure that we can clone a part of the graph without loosing
37.428 + // the attributes.
37.429 + BaseBean bb = b2.getChapter(0);
37.430 + // Should see the chapter attribute
37.431 + out(bb.dumpDomNode());
37.432 +
37.433 + b3 = (Book)b1.clone();
37.434 + int index = b3.addValue("Chapter", bb.clone());
37.435 + bb = b3.getChapter(index);
37.436 + // Should see the chapter attribute on this cloned element
37.437 + out(bb.dumpDomNode());
37.438 +
37.439 + l1 = new MyListener(b1);
37.440 + b1.addPropertyChangeListener(l1);
37.441 +
37.442 + // b2 should never change, so we should never receive anything
37.443 + // on this listener
37.444 + l2 = new MyListener(b2);
37.445 + b2.addPropertyChangeListener(l2);
37.446 +
37.447 + // The only events we should have when we merge are the
37.448 + // attributes events, because the graphs only differ by attr.
37.449 + setTest("Merging attributes");
37.450 + check(!b1.equals(b2), "shouldn't be equals (diff an attr)");
37.451 + //GraphManager.debug(true);
37.452 + b1.merge(b2);
37.453 + check(b1.equals(b2), "should be equals");
37.454 +
37.455 + // Make sure that b1 has the attributes
37.456 + s1 = b1.getAttributeValue("good");
37.457 + check(s1 != null, "attr on root != null");
37.458 + if (s1 != null) {
37.459 + check(s1.equals("no"), "attr on root");
37.460 + }
37.461 + s1 = b1.getAttributeValue("summary", "length");
37.462 + check(s1 != null, "attr on summary != null");
37.463 + if (s1 != null) {
37.464 + check(s1.equals("123"), "attr on summary");
37.465 + }
37.466 + s1 = b1.getAttributeValue("summary", "lang");
37.467 + check(s1 != null, "attr on summary != null");
37.468 + if (s1 != null) {
37.469 + check(s1.equals("us"), "attr on summary");
37.470 + }
37.471 +
37.472 + s1 = b1.getAttributeValue("chapter", 1, "title");
37.473 + out(s1);
37.474 + check(s1 != null, "attr on chapter != null");
37.475 + if (s1 != null) {
37.476 + check(s1.equals("First"), "attr on chapter");
37.477 + }
37.478 +
37.479 + s1 = b1.getAttributeValue("chapter", 2, "title");
37.480 + out(s1);
37.481 + check(s1 != null, "attr on chapter != null");
37.482 + if (s1 != null) {
37.483 + check(s1.equals("Second"), "attr on chapter");
37.484 + }
37.485 +
37.486 + //
37.487 + // Make sure that we do not consume too much memory
37.488 + //
37.489 +
37.490 + // Ignore the first one
37.491 + this.getKMemUsage();
37.492 +
37.493 + int k1 = this.getKMemUsage();
37.494 +
37.495 + Book newBook;
37.496 +
37.497 + this.readDocument("tm01_g3.xml");
37.498 + out("creating the bean graph for memory test");
37.499 + newBook = Book.createGraph(doc);
37.500 +
37.501 + int maxLoop = 50;
37.502 + BaseBean[] aBook = new BaseBean[maxLoop];
37.503 + for(int loop=0; loop<maxLoop; loop++) {
37.504 + aBook[loop] = (BaseBean)newBook.clone();
37.505 + }
37.506 +
37.507 + int k2 = this.getKMemUsage() - k1;
37.508 +
37.509 + float diff = (float)(k2 - memUsageReference);
37.510 +
37.511 + if (diff > 0) {
37.512 + // We consume more memory than excepted
37.513 + float p = diff/memUsageReference*100;
37.514 + if (p > 0.5) {
37.515 + out("It seems that the last schema2beans code changes have increased the memory consumption by " + p + "%");
37.516 + out("If this is expected and acceptable, change the memUsageReference value in TestMerge.java, to be " + k2);
37.517 + }
37.518 + } else {
37.519 + // We consume less memory than expected
37.520 + float p = Math.abs(diff)/memUsageReference*100;
37.521 + if (p > 0.1) {
37.522 + out("It seems that the last schema2beans code changes have decreased the memory consumption by " + p + "% !!!");
37.523 + out("Please, change the memUsageReference value in TestMerge.java, to be " + k2);
37.524 + }
37.525 + }
37.526 + out("memory test done");
37.527 +
37.528 + readDocument("tm01_g1.xml");
37.529 + b1 = Book.createGraph(doc);
37.530 + readDocument("tm01_g4.xml");
37.531 + out("creating the bean graph for the comment merge test");
37.532 + Book commentedGraph = Book.createGraph(doc);
37.533 + b1.merge(commentedGraph);
37.534 + out(b1);
37.535 + }
37.536 +}
37.537 +
37.538 +
38.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
38.2 +++ b/schema2beans/test/unit/src/data/TestValid.dtd Wed Jun 19 00:18:25 2002 +0000
38.3 @@ -0,0 +1,19 @@
38.4 +<!ELEMENT book (title?, chapter+, note?, paperback?, summary?, isbn?, price?)>
38.5 +<!ELEMENT title (#PCDATA)>
38.6 +<!ELEMENT chapter (title, summary?, paragraph*, conclusion?, ending?)>
38.7 +<!ELEMENT note ((year | date), copyright)>
38.8 +<!ELEMENT year (#PCDATA)>
38.9 +<!ELEMENT date (#PCDATA)>
38.10 +<!ELEMENT copyright (#PCDATA)>
38.11 +<!ELEMENT summary (#PCDATA)>
38.12 +<!ELEMENT price (#PCDATA)>
38.13 +<!ELEMENT isbn (#PCDATA)>
38.14 +<!ELEMENT conclusion (#PCDATA)>
38.15 +<!ELEMENT ending (#PCDATA)>
38.16 +<!ELEMENT paragraph (#PCDATA)>
38.17 +<!ELEMENT paperback EMPTY>
38.18 +<!ATTLIST book instock (yes | no) "yes">
38.19 +<!ATTLIST title lang CDATA #FIXED "en">
38.20 +<!ATTLIST chapter length CDATA #IMPLIED>
38.21 +
38.22 +
39.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
39.2 +++ b/schema2beans/test/unit/src/data/TestValid.java Wed Jun 19 00:18:25 2002 +0000
39.3 @@ -0,0 +1,106 @@
39.4 +import java.io.*;
39.5 +import book.*;
39.6 +
39.7 +import org.netbeans.modules.schema2beans.*;
39.8 +
39.9 +
39.10 +public class TestValid extends BaseTest
39.11 +{
39.12 + public static void main(String[] argv) {
39.13 + BaseTest o = new TestValid();
39.14 + if (argv.length > 0)
39.15 + o.setDocumentDir(argv[0]);
39.16 + try {
39.17 + o.run();
39.18 + } catch (Exception e) {
39.19 + e.printStackTrace();
39.20 + System.exit(1);
39.21 + }
39.22 + System.exit(0);
39.23 + }
39.24 +
39.25 + public void run()
39.26 + throws Exception
39.27 + {
39.28 + readDocument();
39.29 +
39.30 + // Create the graph from the input stream
39.31 + Book book = Book.createGraph(this.doc);
39.32 +
39.33 + out("Current XML document:");
39.34 + book.write(System.out);
39.35 +
39.36 + out("Should add paperback after chapter:");
39.37 + book.setPaperback(true);
39.38 + book.write(System.out);
39.39 +
39.40 + out("Should add summary after paperback:");
39.41 + book.setSummary("Summary of the book");
39.42 + book.write(System.out);
39.43 +
39.44 + out("Should add chapter before paperback");
39.45 + Chapter c = new Chapter();
39.46 + c.setTitle("title1");
39.47 + book.addChapter(c);
39.48 + c = new Chapter();
39.49 + c.setTitle("title2");
39.50 + book.addChapter(c);
39.51 + c = new Chapter();
39.52 + c.setTitle("title3");
39.53 + book.addChapter(c);
39.54 + c = new Chapter();
39.55 + c.setTitle("title4");
39.56 + book.addChapter(c);
39.57 + c = new Chapter();
39.58 + c.setTitle("title5");
39.59 + book.addChapter(c);
39.60 +
39.61 + // Mix to index/Dom Node to test the property indexed case
39.62 + Chapter[] c2 = book.getChapter();
39.63 + c = c2[2];
39.64 + c2[2] = c2[0];
39.65 + c2[0] = c;
39.66 + c = c2[3];
39.67 + c2[3] = c2[1];
39.68 + c2[1] = c;
39.69 + book.setChapter(c2);
39.70 +
39.71 + out(book);
39.72 +
39.73 + out("Should add title as the first property of book:");
39.74 + book.setTitle("Title of the book");
39.75 + out(book);
39.76 +
39.77 + out("Should add price as the last property of book:");
39.78 + book.setPrice("19.99");
39.79 + out(book);
39.80 +
39.81 + out("Should add isbn before the price:");
39.82 + book.setIsbn("120394857");
39.83 + out(book);
39.84 +
39.85 + out("Should add ending at the end of the chapter:");
39.86 + c = book.getChapter(0);
39.87 + c.setEnding("And this is how this chapter ends.");
39.88 + out(book);
39.89 +
39.90 + out("Should add conclusion before the ending");
39.91 + c.setConclusion("And this concludes this chapter.");
39.92 + out(book);
39.93 +
39.94 + out("Should add Note with year before copyright");
39.95 + Note n = new Note();
39.96 + n.setYear("2000");
39.97 + n.setCopyright("1997");
39.98 + book.setNote(n);
39.99 + out(book);
39.100 +
39.101 + out("Should set Note with date before copyright");
39.102 + n = new Note();
39.103 + n.setDate("2001");
39.104 + n.setCopyright("1996");
39.105 + book.setNote(n);
39.106 + out(book);
39.107 + }
39.108 +}
39.109 +
40.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
40.2 +++ b/schema2beans/test/unit/src/data/TestValid.xml Wed Jun 19 00:18:25 2002 +0000
40.3 @@ -0,0 +1,30 @@
40.4 +<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
40.5 +
40.6 +<!DOCTYPE book [
40.7 +<!ELEMENT book (title?, chapter+, note?, paperback?, summary?, isbn?, price?)>
40.8 +<!ELEMENT title (#PCDATA)>
40.9 +<!ELEMENT chapter (title, summary?, paragraph*, conclusion?, ending?)>
40.10 +<!ELEMENT note ((year | date), copyright)>
40.11 +<!ELEMENT year (#PCDATA)>
40.12 +<!ELEMENT date (#PCDATA)>
40.13 +<!ELEMENT summary (#PCDATA)>
40.14 +<!ELEMENT price (#PCDATA)>
40.15 +<!ELEMENT isbn (#PCDATA)>
40.16 +<!ELEMENT conclusion (#PCDATA)>
40.17 +<!ELEMENT ending (#PCDATA)>
40.18 +<!ELEMENT paragraph (#PCDATA)>
40.19 +<!ELEMENT paperback EMPTY>
40.20 +<!ATTLIST book instock (yes | no) "yes">
40.21 +<!ATTLIST title lang CDATA #FIXED "en">
40.22 +<!ATTLIST chapter length CDATA #IMPLIED>
40.23 +]>
40.24 +
40.25 +<book>
40.26 +<chapter>
40.27 +<title>The sand castle</title>
40.28 +<paragraph>
40.29 +Once upon a time, on a far sunny island, ...
40.30 +</paragraph>
40.31 +</chapter>
40.32 +</book>
40.33 +
41.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
41.2 +++ b/schema2beans/test/unit/src/data/TestVeto.dtd Wed Jun 19 00:18:25 2002 +0000
41.3 @@ -0,0 +1,49 @@
41.4 +<!-- The following DTD is a simple view of a book:
41.5 +book
41.6 + index
41.7 + +
41.8 + word
41.9 + #PCDATA
41.10 + page
41.11 + #PCDATA
41.12 + chapter+
41.13 + comment?
41.14 + #PCDATA
41.15 + paragraph*
41.16 + #PCDATA
41.17 + summary?
41.18 + #PCDATA
41.19 +
41.20 + good
41.21 + EMPTY
41.22 +-->
41.23 +
41.24 +<!ELEMENT summary (#PCDATA)>
41.25 +
41.26 +<!ELEMENT book (index+, chapter+, summary?, author+, reviews?, available)>
41.27 +
41.28 +<!ELEMENT reviews (#PCDATA)>
41.29 +
41.30 +<!ELEMENT available EMPTY>
41.31 +
41.32 +<!ELEMENT index (word, ref+)>
41.33 +
41.34 +<!ELEMENT ref (page, line)>
41.35 +
41.36 +<!ELEMENT word (#PCDATA)>
41.37 +
41.38 +<!ELEMENT author (#PCDATA)>
41.39 +
41.40 +<!ELEMENT line (#PCDATA)>
41.41 +
41.42 +<!ELEMENT page (#PCDATA)>
41.43 +
41.44 +<!ELEMENT chapter (comment?, paragraph*)>
41.45 +
41.46 +<!ELEMENT paragraph (#PCDATA)>
41.47 +
41.48 +<!ELEMENT comment (#PCDATA)>
41.49 +
41.50 +
41.51 +
41.52 +
42.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
42.2 +++ b/schema2beans/test/unit/src/data/TestVeto.java Wed Jun 19 00:18:25 2002 +0000
42.3 @@ -0,0 +1,327 @@
42.4 +/*
42.5 + * TestVeto - test the vetoable events
42.6 + *
42.7 + */
42.8 +
42.9 +import java.io.*;
42.10 +import java.util.*;
42.11 +import org.w3c.dom.*;
42.12 +
42.13 +import java.beans.*;
42.14 +
42.15 +import org.netbeans.modules.schema2beans.*;
42.16 +import book.*;
42.17 +
42.18 +
42.19 +public class TestVeto extends BaseTest
42.20 +{
42.21 + public static void main(String[] argv) {
42.22 + BaseTest o = new TestVeto();
42.23 + if (argv.length > 0)
42.24 + o.setDocumentDir(argv[0]);
42.25 + try {
42.26 + o.run();
42.27 + } catch (Exception e) {
42.28 + e.printStackTrace();
42.29 + System.exit(1);
42.30 + }
42.31 + System.exit(0);
42.32 + }
42.33 +
42.34 + public class MyListener implements VetoableChangeListener
42.35 + {
42.36 + GraphManager gm;
42.37 + String listenerName;
42.38 + String title;
42.39 + Object oldValue;
42.40 + Object newValue;
42.41 + String propertyName;
42.42 + Object source;
42.43 + int index;
42.44 +
42.45 + boolean remove;
42.46 +
42.47 + // Used to check that the event is triggered once the changed are done
42.48 + Chapter tracePara;
42.49 +
42.50 + boolean raise = false;;
42.51 + boolean raised = false;
42.52 + boolean printStringArray = false;
42.53 +
42.54 + public MyListener(String title, BaseBean bean)
42.55 + {
42.56 + this.listenerName = bean.name();
42.57 + gm = bean.graphManager();
42.58 + this.remove = false;
42.59 + this.title = title;
42.60 + out("new listener for " + this.title + " / " + this.listenerName);
42.61 + }
42.62 +
42.63 + public void printStringValues(String[] ss, String str)
42.64 + {
42.65 + if (ss == null)
42.66 + out(str + " is null");
42.67 + else
42.68 + {
42.69 + if (ss.length == 0)
42.70 + out(str + ".length = 0");
42.71 + else
42.72 + for(int i=0; i<ss.length; i++)
42.73 + out(str + "[" + i + "]=" + ss[i]);
42.74 + }
42.75 + }
42.76 +
42.77 + public void reset()
42.78 + {
42.79 + this.oldValue = null;
42.80 + this.newValue = null;
42.81 + this.propertyName = null;
42.82 + this.source = null;
42.83 + this.index = -1;
42.84 + this.raise = false;
42.85 + this.raised = false;
42.86 + this.printStringArray = false;
42.87 + }
42.88 +
42.89 + public void printStringArray()
42.90 + {
42.91 + this.printStringArray = true;
42.92 + }
42.93 +
42.94 + public void traceParagraphs(Chapter c)
42.95 + {
42.96 + this.tracePara = c;
42.97 + }
42.98 +
42.99 + public void veto()
42.100 + {
42.101 + this.raise = true;
42.102 + }
42.103 +
42.104 + public void vetoableChange(PropertyChangeEvent e)
42.105 + throws PropertyVetoException
42.106 + {
42.107 + if (this.raised)
42.108 + out(this.title+ " received an undo event:");
42.109 + else
42.110 + out(this.title + " received veto event:");
42.111 +
42.112 + this.oldValue = e.getOldValue();
42.113 + this.newValue = e.getNewValue();
42.114 + this.propertyName = e.getPropertyName();
42.115 + this.source = e.getSource();
42.116 + String n = this.propertyName;
42.117 + this.index = gm.getPropertyIndex(n);
42.118 +
42.119 + out("<Lnr:" + this.listenerName + " Evt:" + n +
42.120 + " Src:" + this.source.getClass().getName() + ">");
42.121 + if (remove)
42.122 + {
42.123 + out("<" + gm.getPropertyName(n) + "[" + this.index +
42.124 + "]" + " - Parent: " + gm.getPropertyParentName(n) + ">");
42.125 + }
42.126 + else
42.127 + {
42.128 + out("<" + gm.getPropertyName(n) + "[" + this.index +
42.129 + "]" + " - Parent: " + gm.getPropertyParentName(n) +
42.130 + "/" + gm.getPropertyParent(n).getClass().getName() + ">");
42.131 + }
42.132 +
42.133 + if (this.tracePara != null)
42.134 + {
42.135 + String[] p = this.tracePara.getParagraph();
42.136 + for (int i=0; i<p.length; i++)
42.137 + out("From event listener: " + p[i]);
42.138 + }
42.139 +
42.140 + if (this.printStringArray)
42.141 + {
42.142 + this.printStringValues((String[])this.oldValue, "oldValues");
42.143 + this.printStringValues((String[])this.newValue, "newValues");
42.144 + }
42.145 +
42.146 + if (this.raise && !this.raised)
42.147 + {
42.148 + out("Listener: raising PropertyVetoException");
42.149 + this.raised = true;
42.150 + throw new PropertyVetoException("value rejected", e);
42.151 + }
42.152 + //out("received " + this.oldValue + "/" + this.newValue + "/" +
42.153 + // this.propertyName);
42.154 + }
42.155 +
42.156 + public void removeMode()
42.157 + {
42.158 + this.remove = true;
42.159 + }
42.160 +
42.161 + public Object oldValue()
42.162 + {
42.163 + return this.oldValue;
42.164 + }
42.165 +
42.166 + public String stringOldValue()
42.167 + {
42.168 + if (this.oldValue == null)
42.169 + return "<null>";
42.170 + else
42.171 + return this.oldValue.toString();
42.172 + }
42.173 +
42.174 + public Object newValue()
42.175 + {
42.176 + return this.newValue;
42.177 + }
42.178 +
42.179 + public String stringNewValue()
42.180 + {
42.181 + if (this.newValue == null)
42.182 + return "<null>";
42.183 + else
42.184 + return this.newValue.toString();
42.185 + }
42.186 +
42.187 + public String name()
42.188 + {
42.189 + return this.propertyName;
42.190 + }
42.191 +
42.192 + public String toString()
42.193 + {
42.194 + return this.name() + " raised from source " +
42.195 + this.source.getClass().getName();
42.196 + }
42.197 + }
42.198 +
42.199 + public void run()
42.200 + throws Exception
42.201 + {
42.202 + Book book;
42.203 +
42.204 + this.readDocument();
42.205 +
42.206 + out("creating the bean graph");
42.207 + book = Book.createGraph(this.doc);
42.208 + GraphManager gm = book.graphManager();
42.209 +
42.210 + out("bean graph created");
42.211 + //out(book.toString());
42.212 +
42.213 + /*
42.214 + * Book
42.215 + * Index[1,n]
42.216 + * Word - String
42.217 + * Ref[1,n]
42.218 + * Page - String
42.219 + * Line - String
42.220 + * Chapter[1,n]
42.221 + * Comment? - String
42.222 + * Paragraph[0,n] - String
42.223 + * Summary? - String
42.224 + * Author[1,n] - String
42.225 + * Good - Boolean
42.226 + * Available - Boolean
42.227 + */
42.228 +
42.229 + //
42.230 + // Set a listener on the root
42.231 + //
42.232 + MyListener l = new MyListener("Book listener", book);
42.233 + book.addVetoableChangeListener(l);
42.234 + //GraphManager.debug(true);
42.235 + setTest("simple change event on the root - no veto");
42.236 + l.reset();
42.237 + String s = "This book is about how to veto changes";
42.238 + // Change a property on the root - this should raises an event
42.239 + book.setSummary(s);
42.240 + // Check the received event
42.241 + check(l.oldValue() == null, "(old value)");
42.242 + check(l.newValue().equals(s), "(new value)");
42.243 + check(book.getSummary().equals(s), "(new value)");
42.244 +
42.245 + boolean gotException = false;
42.246 + setTest("simple change event on the root - veto");
42.247 + l.reset();
42.248 + l.veto();
42.249 + String s2 = "this is the new value";
42.250 + s = book.getSummary();
42.251 + try {
42.252 + book.setSummary(s2);
42.253 + } catch(PropertyVetoException ve) {
42.254 + check(book.getSummary().equals(s), "(got exception & same value)");
42.255 + gotException = true;
42.256 + }
42.257 +
42.258 + if (!gotException)
42.259 + check(false, " didn't get the veto exception (1)!");
42.260 +
42.261 + setTest("Try to listen for a non vetoable property");
42.262 + gotException = false;
42.263 + try {
42.264 + book.addVetoableChangeListener("Reviews", l);
42.265 + } catch(Exception e) {
42.266 + check(true, "got exception:\n" + e.getMessage());
42.267 + gotException = true;
42.268 + }
42.269 +
42.270 + if (!gotException)
42.271 + check(false, " didn't get the runtime exception (2)!");
42.272 +
42.273 + setTest("Indexed final property");
42.274 + l.reset();
42.275 + String [] ss = {"Author1", "Author2", "Author3"};
42.276 + l.printStringArray();
42.277 + book.setAuthor(ss);
42.278 +
42.279 + l.reset();
42.280 + l.veto();
42.281 + l.printStringArray();
42.282 + String [] ss2 = {"Author1_new", "Author2_new"};
42.283 + try {
42.284 + book.setAuthor(ss2);
42.285 + } catch(PropertyVetoException ve) {
42.286 + check(true, "(got exception)");
42.287 + gotException = true;
42.288 + }
42.289 +
42.290 + if (!gotException)
42.291 + check(false, " didn't get the veto exception (3)!");
42.292 +
42.293 + l.printStringValues(book.getAuthor(), "getAuthor()");
42.294 +
42.295 + setTest("Set a second listener to get two events");
42.296 + MyListener l2 = new MyListener("Author listener", book);
42.297 + l.reset();
42.298 + l2.reset();
42.299 + gotException = false;
42.300 + try {
42.301 + book.addVetoableChangeListener("author", l2);
42.302 + } catch(Exception e) {
42.303 + check(false, "got exception:\n" + e.getMessage());
42.304 + gotException = true;
42.305 + }
42.306 +
42.307 + String [] ss3 = {"re-Author1_new", "re-Author2_new"};
42.308 + book.setAuthor(ss3);
42.309 + l.printStringValues(book.getAuthor(), "getAuthor()");
42.310 +
42.311 + l.reset();
42.312 + l2.reset();
42.313 + l.veto();
42.314 + String [] ss4 = {"only_one_author"};
42.315 + try {
42.316 + book.setAuthor(ss4);
42.317 + } catch(PropertyVetoException ve) {
42.318 + check(true, "(got exception)");
42.319 + gotException = true;
42.320 + }
42.321 +
42.322 + if (!gotException)
42.323 + check(false, " didn't get the veto exception (4)!");
42.324 +
42.325 + }
42.326 +
42.327 +}
42.328 +
42.329 +
42.330 +
43.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
43.2 +++ b/schema2beans/test/unit/src/data/TestVeto.mdd Wed Jun 19 00:18:25 2002 +0000
43.3 @@ -0,0 +1,104 @@
43.4 +<?xml version="1.0" encoding="UTF-8"?>
43.5 +
43.6 +<metaDD>
43.7 + <meta-element>
43.8 + <dtd-name>summary</dtd-name>
43.9 + <bean-name>Summary</bean-name>
43.10 + <wrapper-class>String</wrapper-class>
43.11 + <vetoable/>
43.12 + </meta-element>
43.13 + <meta-element>
43.14 + <dtd-name>comment</dtd-name>
43.15 + <bean-name>Comment</bean-name>
43.16 + <wrapper-class>String</wrapper-class>
43.17 + </meta-element>
43.18 + <meta-element>
43.19 + <dtd-name>ref</dtd-name>
43.20 + <bean-name>Ref</bean-name>
43.21 + <meta-property>
43.22 + <bean-name>Page</bean-name>
43.23 + </meta-property>
43.24 + <meta-property>
43.25 + <bean-name>Line</bean-name>
43.26 + </meta-property>
43.27 + </meta-element>
43.28 + <meta-element>
43.29 + <dtd-name>chapter</dtd-name>
43.30 + <bean-name>Chapter</bean-name>
43.31 + <meta-property>
43.32 + <bean-name>Comment</bean-name>
43.33 + </meta-property>
43.34 + <meta-property>
43.35 + <bean-name>Paragraph</bean-name>
43.36 + </meta-property>
43.37 + </meta-element>
43.38 + <meta-element>
43.39 + <dtd-name>available</dtd-name>
43.40 + <bean-name>Available</bean-name>
43.41 + <wrapper-class>Boolean</wrapper-class>
43.42 + </meta-element>
43.43 + <meta-element>
43.44 + <dtd-name>line</dtd-name>
43.45 + <bean-name>Line</bean-name>
43.46 + <wrapper-class>String</wrapper-class>
43.47 + </meta-element>
43.48 + <meta-element>
43.49 + <dtd-name>reviews</dtd-name>
43.50 + <bean-name>Reviews</bean-name>
43.51 + <wrapper-class>String</wrapper-class>
43.52 + </meta-element>
43.53 + <meta-element>
43.54 + <dtd-name>word</dtd-name>
43.55 + <bean-name>Word</bean-name>
43.56 + <wrapper-class>String</wrapper-class>
43.57 + </meta-element>
43.58 + <meta-element>
43.59 + <dtd-name>author</dtd-name>
43.60 + <bean-name>Author</bean-name>
43.61 + <wrapper-class>String</wrapper-class>
43.62 + </meta-element>
43.63 + <meta-element>
43.64 + <dtd-name>index</dtd-name>
43.65 + <bean-name>Index</bean-name>
43.66 + <meta-property>
43.67 + <bean-name>Word</bean-name>
43.68 + </meta-property>
43.69 + <meta-property>
43.70 + <bean-name>Ref</bean-name>
43.71 + </meta-property>
43.72 + </meta-element>
43.73 + <meta-element>
43.74 + <dtd-name>book</dtd-name>
43.75 + <bean-name>Book</bean-name>
43.76 + <meta-property>
43.77 + <bean-name>Index</bean-name>
43.78 + </meta-property>
43.79 + <meta-property>
43.80 + <bean-name>Chapter</bean-name>
43.81 + </meta-property>
43.82 + <meta-property>
43.83 + <bean-name>Summary</bean-name>
43.84 + </meta-property>
43.85 + <meta-property>
43.86 + <bean-name>Author</bean-name>
43.87 + <vetoable/>
43.88 + </meta-property>
43.89 + <meta-property>
43.90 + <bean-name>Reviews</bean-name>
43.91 + </meta-property>
43.92 + <meta-property>
43.93 + <bean-name>Available</bean-name>
43.94 + </meta-property>
43.95 + </meta-element>
43.96 + <meta-element>
43.97 + <dtd-name>paragraph</dtd-name>
43.98 + <bean-name>Paragraph</bean-name>
43.99 + <wrapper-class>String</wrapper-class>
43.100 + </meta-element>
43.101 + <meta-element>
43.102 + <dtd-name>page</dtd-name>
43.103 + <bean-name>Page</bean-name>
43.104 + <wrapper-class>String</wrapper-class>
43.105 + </meta-element>
43.106 +</metaDD>
43.107 +
44.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
44.2 +++ b/schema2beans/test/unit/src/data/TestVeto.xml Wed Jun 19 00:18:25 2002 +0000
44.3 @@ -0,0 +1,62 @@
44.4 +<?xml version="1.0" encoding="ISO-8859-1"?>
44.5 +
44.6 +<book>
44.7 + <chapter>
44.8 + <comment>
44.9 + First chapter.
44.10 + </comment>
44.11 + <paragraph>
44.12 + Once upon a time...
44.13 + </paragraph>
44.14 + <paragraph>
44.15 + And this is how the book met the fairy, and how all this
44.16 + story began.
44.17 + </paragraph>
44.18 + </chapter>
44.19 + <chapter>
44.20 + <paragraph>
44.21 + And the book lived a never ending happy life, read, copied
44.22 + and enjoyed by so many readers.
44.23 + </paragraph>
44.24 + </chapter>
44.25 + <chapter>
44.26 + <comment>
44.27 + Empty chapter
44.28 + </comment>
44.29 + </chapter>
44.30 + <index>
44.31 + <word>
44.32 + Good book
44.33 + </word>
44.34 + <ref>
44.35 + <page>
44.36 + 22
44.37 + </page>
44.38 + <line>
44.39 + 12
44.40 + </line>
44.41 + </ref>
44.42 + </index>
44.43 + <index>
44.44 + <word>
44.45 + E-Tool
44.46 + </word>
44.47 + <ref>
44.48 + <page>
44.49 + 5
44.50 + </page>
44.51 + <line>
44.52 + 15
44.53 + </line>
44.54 + </ref>
44.55 + <ref>
44.56 + <page>
44.57 + 29
44.58 + </page>
44.59 + <line>
44.60 + 31
44.61 + </line>
44.62 + </ref>
44.63 + </index>
44.64 + <good/>
44.65 +</book>
45.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
45.2 +++ b/schema2beans/test/unit/src/data/book/MyDate.java Wed Jun 19 00:18:25 2002 +0000
45.3 @@ -0,0 +1,33 @@
45.4 +/*
45.5 + */
45.6 +package book;
45.7 +
45.8 +import java.io.*;
45.9 +import java.util.*;
45.10 +
45.11 +import org.netbeans.modules.schema2beans.*;
45.12 +
45.13 +public class MyDate implements Wrapper
45.14 +{
45.15 + String value;
45.16 +
45.17 + public MyDate()
45.18 + {
45.19 + this.value = null;
45.20 + }
45.21 +
45.22 + public String getWrapperValue()
45.23 + {
45.24 + return value;
45.25 + }
45.26 +
45.27 + public void setWrapperValue(String value)
45.28 + {
45.29 + this.value = value;
45.30 + }
45.31 +
45.32 + public String toString()
45.33 + {
45.34 + return "MyDate value = " + this.value;
45.35 + }
45.36 +}
46.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
46.2 +++ b/schema2beans/test/unit/src/data/goldenfiles/TestMain/testAttr.pass Wed Jun 19 00:18:25 2002 +0000
46.3 @@ -0,0 +1,225 @@
46.4 +Calling GenBeans.doIt
46.5 +Compiling
46.6 +Finished compiling: 0
46.7 +out: TestAttr - creating the DOM document
46.8 +out: TestAttr - creating the bean graph
46.9 +out: TestAttr - bean graph created
46.10 +out: TestAttr - new listener for Book
46.11 +out: TestAttr get enum attribute from root -> OK
46.12 +out: TestAttr - Changing to another value - should get an event
46.13 +out: TestAttr - <Chg Lnr:Book Evt:/Book:good Src:book.Book>
46.14 +out: TestAttr - <Attr:Book.good - ParentName: - ParentClass:book.Book>
46.15 +out: TestAttr get enum attribute from root -> OK
46.16 +out: TestAttr - Book DOM content should be yes
46.17 +out: book - element
46.18 +out: attribute: good=yes
46.19 +out:
46.20 +out: TestAttr - Changing to a non-enum value (should get an exception)
46.21 +out: TestAttr get enum attribute from root got the proper exception -> OK
46.22 +out: TestAttr get #REQUIRED attribute -> OK
46.23 +out: TestAttr - Changing to another value
46.24 +out: TestAttr - <Chg Lnr:Book Evt:/Book/Summary:length Src:book.Book>
46.25 +out: TestAttr - <Attr:Summary.length - ParentName: Book - ParentClass:book.Book>
46.26 +out: TestAttr get #REQUIRED attribute -> OK
46.27 +out: TestAttr get #IMPLIED attribute -> OK
46.28 +out: TestAttr - Setting a new value
46.29 +out: TestAttr - <Chg Lnr:Book Evt:/Book/Summary:lang Src:book.Book>
46.30 +out: TestAttr - <Attr:Summary.lang - ParentName: Book - ParentClass:book.Book>
46.31 +out: TestAttr get #IMPLIED attribute -> OK
46.32 +out: TestAttr - <Chg Lnr:Book Evt:/Book/Summary:lang Src:book.Book>
46.33 +out: TestAttr - <Attr:Summary.lang - ParentName: Book - ParentClass:book.Book>
46.34 +out: TestAttr get #IMPLIED attribute -> OK
46.35 +out: TestAttr - <Rmv Lnr:Book Evt:/Book/Summary:lang Src:book.Book>
46.36 +out: TestAttr - <Attr:Summary.lang - ParentName: Book - ParentClass:book.Book>
46.37 +out: TestAttr get #IMPLIED attribute -> OK
46.38 +out: TestAttr - <Add Lnr:Book Evt:/Book/Summary:lang Src:book.Book>
46.39 +out: TestAttr - <Attr:Summary.lang - ParentName: Book - ParentClass:book.Book>
46.40 +out: TestAttr get #FIXED attribute -> OK
46.41 +out: TestAttr - Summary DOM content should be 133/fr/12
46.42 +out: book - element
46.43 +out: attribute: good=yes
46.44 +out: summary - element
46.45 +out: attribute: lang=fr
46.46 +out: attribute: length=133
46.47 +out: attribute: size=12
46.48 +out: chapter - element
46.49 +out: chapter - element
46.50 +out: chapter - element
46.51 +out: index - element
46.52 +out: index - element
46.53 +out:
46.54 +out: TestAttr - Setting a new value (should get an exception)
46.55 +out: TestAttr get #FIXED attribute got the proper exception -> OK
46.56 +out: TestAttr - Chapter DOM should have no attribute
46.57 +out: chapter - element
46.58 +out:
46.59 +out: TestAttr get/set non set #IMPLIED attribute -> OK
46.60 +out: TestAttr - <Add Lnr:Book Evt:/Book/Chapter.2:title Src:book.Book>
46.61 +out: TestAttr - <Attr:Chapter[0].title - ParentName: Book - ParentClass:book.Book>
46.62 +out: TestAttr get/set non set #IMPLIED attribute -> OK
46.63 +out: TestAttr - Chapter DOM should have one title attribute
46.64 +out: chapter - element
46.65 +out: attribute: title=My chapter
46.66 +out:
46.67 +out: TestAttr access from parent & current bean -> OK
46.68 +out: TestAttr attribute stick with elt when mixing -> OK
46.69 +out: TestAttr attribute stick with elt when mixing -> OK
46.70 +out: TestAttr - <Chg Lnr:Book Evt:/Book/Chapter.-1 Src:book.Book>
46.71 +out: TestAttr - <Prop:Chapter - ParentName: Book - ParentClass:book.Book>
46.72 +out: TestAttr attribute stick with elt when mixing -> OK
46.73 +out: TestAttr attribute stick with elt when mixing -> OK
46.74 +out: TestAttr - Chapter DOM should have no attribute
46.75 +out: chapter - element
46.76 +out:
46.77 +out: TestAttr get/set non set #IMPLIED attribute (idx != 0) -> OK
46.78 +out: TestAttr - <Add Lnr:Book Evt:/Book/Chapter.8:title Src:book.Book>
46.79 +out: TestAttr - <Attr:Chapter[2].title - ParentName: Book - ParentClass:book.Book>
46.80 +out: TestAttr get/set non set #IMPLIED attribute (idx != 0) -> OK
46.81 +out: TestAttr - Chapter DOM should have one title attribute
46.82 +out: chapter - element
46.83 +out: attribute: title=My chapter2
46.84 +out:
46.85 +out: TestAttr get unknown attribute got the proper exception -> OK
46.86 +out: TestAttr - <Add Lnr:Book Evt:/Book/Index.17 Src:book.Book>
46.87 +out: TestAttr - <Prop:Index[2] - ParentName: Book - ParentClass:book.Book>
46.88 +out: TestAttr add a brand new element with default attributes -> OK
46.89 +out: TestAttr - should have created: cross-ref & glossary, and not color
46.90 +out: book - element
46.91 +out: attribute: good=yes
46.92 +out: summary - element
46.93 +out: attribute: lang=fr
46.94 +out: attribute: length=133
46.95 +out: attribute: size=12
46.96 +out: chapter - element
46.97 +out: chapter - element
46.98 +out: attribute: title=My chapter
46.99 +out: chapter - element
46.100 +out: attribute: title=My chapter2
46.101 +out: index - element
46.102 +out: index - element
46.103 +out: index - element
46.104 +out: attribute: cross-ref=no
46.105 +out: attribute: glossary=nope
46.106 +out:
46.107 +out: TestAttr - <Rmv Lnr:Book Evt:/Book/Index.17i2 Src:book.Book>
46.108 +out: TestAttr - <Prop:Index[2] - ParentName: Book - ParentClass:book.Book>
46.109 +out: TestAttr - <Add Lnr:Book Evt:/Book/Index.19 Src:book.Book>
46.110 +out: TestAttr - <Prop:Index[2] - ParentName: Book - ParentClass:book.Book>
46.111 +out: TestAttr - <Add Lnr:Book Evt:/Book/Index.19:color Src:book.Book>
46.112 +out: TestAttr - <Attr:Index[2].color - ParentName: Book - ParentClass:book.Book>
46.113 +out: TestAttr - <Chg Lnr:Book Evt:/Book/Index.19:cross-ref Src:book.Book>
46.114 +out: TestAttr - <Attr:Index[2].cross-ref - ParentName: Book - ParentClass:book.Book>
46.115 +out: TestAttr - should have created: cross-ref (yes), glossary (nope) and color (blue)
46.116 +out: book - element
46.117 +out: attribute: good=yes
46.118 +out: summary - element
46.119 +out: attribute: lang=fr
46.120 +out: attribute: length=133
46.121 +out: attribute: size=12
46.122 +out: #text=
46.123 +out: This book is about the life of a book spent between books who dreamed
46.124 +out: to meet a fairy who could transform it into an XML book and travel
46.125 +out: in an electronic boundary-less world.
46.126 +out: - text
46.127 +out: chapter - element
46.128 +out: paragraph - element
46.129 +out: #text=
46.130 +out: And the book lived a never ending happy life, read, copied
46.131 +out: and enjoyed by so many readers.
46.132 +out: - text
46.133 +out: chapter - element
46.134 +out: attribute: title=My chapter
46.135 +out: comment - element
46.136 +out: #text=
46.137 +out: First chapter.
46.138 +out: - text
46.139 +out: paragraph - element
46.140 +out: #text=
46.141 +out: Once upon a time...
46.142 +out: - text
46.143 +out: paragraph - element
46.144 +out: #text=
46.145 +out: And this is how the book met the fairy, and how all this
46.146 +out: story began.
46.147 +out: - text
46.148 +out: chapter - element
46.149 +out: attribute: title=My chapter2
46.150 +out: comment - element
46.151 +out: #text=
46.152 +out: Empty chapter
46.153 +out: - text
46.154 +out: index - element
46.155 +out: word - element
46.156 +out: #text=
46.157 +out: Good book
46.158 +out: - text
46.159 +out: ref - element
46.160 +out: page - element
46.161 +out: line - element
46.162 +out: index - element
46.163 +out: word - element
46.164 +out: #text=
46.165 +out: E-Tool
46.166 +out: - text
46.167 +out: ref - element
46.168 +out: page - element
46.169 +out: line - element
46.170 +out: ref - element
46.171 +out: page - element
46.172 +out: line - element
46.173 +out: index - element
46.174 +out: attribute: color=blue
46.175 +out: attribute: cross-ref=yes
46.176 +out: attribute: glossary=nope
46.177 +out: word - element
46.178 +out: attribute: freq=123
46.179 +out: #text=my word - text
46.180 +out:
46.181 +out: TestAttr - [Book]
46.182 +out: TestAttr - <Summary> - class java.lang.String
46.183 +out: TestAttr - a:Length
46.184 +out: TestAttr - a:Lang
46.185 +out: TestAttr - a:Size
46.186 +out: TestAttr - <Chapter[3]> - class book.Chapter
46.187 +out: TestAttr - a:Title
46.188 +out: TestAttr - [Chapter]
46.189 +out: TestAttr - <Comment> - class java.lang.String
46.190 +out: TestAttr - <Paragraph[1]> - class java.lang.String
46.191 +out: TestAttr - [Chapter]
46.192 +out: TestAttr - <Comment> - class java.lang.String
46.193 +out: TestAttr - <Paragraph[2]> - class java.lang.String
46.194 +out: TestAttr - [Chapter]
46.195 +out: TestAttr - <Comment> - class java.lang.String
46.196 +out: TestAttr - <Paragraph[0]> - class java.lang.String
46.197 +out: TestAttr - <Index[3]> - class book.Index
46.198 +out: TestAttr - a:Color
46.199 +out: TestAttr - a:CrossRef
46.200 +out: TestAttr - a:Glossary
46.201 +out: TestAttr - [Index]
46.202 +out: TestAttr - <Word> - class java.lang.String
46.203 +out: TestAttr - a:Freq
46.204 +out: TestAttr - <Ref[1]> - class book.Ref
46.205 +out: TestAttr - [Ref]
46.206 +out: TestAttr - <Page> - class java.lang.String
46.207 +out: TestAttr - <Line> - class java.lang.String
46.208 +out: TestAttr - [Index]
46.209 +out: TestAttr - <Word> - class java.lang.String
46.210 +out: TestAttr - a:Freq
46.211 +out: TestAttr - <Ref[2]> - class book.Ref
46.212 +out: TestAttr - [Ref]
46.213 +out: TestAttr - <Page> - class java.lang.String
46.214 +out: TestAttr - <Line> - class java.lang.String
46.215 +out: TestAttr - [Ref]
46.216 +out: TestAttr - <Page> - class java.lang.String
46.217 +out: TestAttr - <Line> - class java.lang.String
46.218 +out: TestAttr - [Index]
46.219 +out: TestAttr - <Word> - class java.lang.String
46.220 +out: TestAttr - a:Freq
46.221 +out: TestAttr - <Ref[0]> - class book.Ref
46.222 +out: TestAttr - <Available> - class java.lang.Boolean
46.223 +out: TestAttr - Make sure that default attributes get set.
46.224 +out: <?xml version="1.0" encoding="UTF-8"?>
46.225 +out: <book>
46.226 +out: <summary size="12">This is my summary.</summary>
46.227 +out: </book>
46.228 +Finished running TestAttr: 0
47.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
47.2 +++ b/schema2beans/test/unit/src/data/goldenfiles/TestMain/testBook.pass Wed Jun 19 00:18:25 2002 +0000
47.3 @@ -0,0 +1,740 @@
47.4 +Calling GenBeans.doIt
47.5 +Compiling
47.6 +Finished compiling: 0
47.7 +out: TestBook - creating the DOM document
47.8 +out: TestBook - creating the bean graph
47.9 +out: TestBook - bean graph created
47.10 +out: TestBook single String - get/set -> OK
47.11 +out: TestBook single String - remove -> OK
47.12 +out: TestBook - should not have a 'summary' element:
47.13 +out:
47.14 +out: TestBook single String - set new -> OK
47.15 +out: TestBook - should have a 'summary' element:
47.16 +out: summary - element
47.17 +out:
47.18 +out: TestBook boolean - get value (from true) -> OK
47.19 +out: TestBook - should have a 'good' element:
47.20 +out: good - element
47.21 +out:
47.22 +out: TestBook boolean - change to same value (true) -> OK
47.23 +out: TestBook - should still have a 'good' element:
47.24 +out: good - element
47.25 +out:
47.26 +out: TestBook boolean - change to false -> OK
47.27 +out: TestBook - should not have a 'good' element:
47.28 +out:
47.29 +out: TestBook boolean - change back to true -> OK
47.30 +out: TestBook - should have a 'good' element:
47.31 +out: good - element
47.32 +out:
47.33 +out: TestBook boolean - get value (from false) -> OK
47.34 +out: TestBook - should not have an 'available' element:
47.35 +out:
47.36 +out: TestBook boolean - change to same value (false) -> OK
47.37 +out: TestBook - should not have an 'available' element:
47.38 +out:
47.39 +out: TestBook boolean - change to true -> OK
47.40 +out: TestBook - should have now an 'available' element:
47.41 +out: available - element
47.42 +out:
47.43 +out: TestBook boolean - change back to false -> OK
47.44 +out: TestBook - should not have an 'available' element:
47.45 +out:
47.46 +out: TestBook - String[] - search for the string arrays
47.47 +out: TestBook - found 3 chapter in book
47.48 +out: TestBook - chapter 1 has 2 paragraphs:
47.49 +out: paragraph - element
47.50 +out: paragraph - element
47.51 +out:
47.52 +out: TestBook - chapter 2 has 1 paragraphs:
47.53 +out: paragraph - element
47.54 +out:
47.55 +out: TestBook - chapter 3 has 0 paragraphs:
47.56 +out:
47.57 +out: TestBook String[0] - search for empty array -> OK
47.58 +out: TestBook String[0] - out of bounds access [-1] (IndexOutOfBoundsException) -> OK
47.59 +out: TestBook String[0] - out of bounds access [0] (IndexOutOfBoundsException) -> OK
47.60 +out: TestBook String[0] - out of bounds access [1] (IndexOutOfBoundsException) -> OK
47.61 +out: TestBook String[0] - out of bounds access [999] (IndexOutOfBoundsException) -> OK
47.62 +out: TestBook String[0] - add a string to the array -> OK
47.63 +out: TestBook - should contain one paragraph:
47.64 +out: paragraph - element
47.65 +out:
47.66 +out: TestBook String[0] - add another string to the array -> OK
47.67 +out: TestBook - should contain two paragraphs:
47.68 +out: paragraph - element
47.69 +out: paragraph - element
47.70 +out:
47.71 +out: TestBook String[0] - compare paragraphs (same content) -> OK
47.72 +out: TestBook String[0] - compare paragraphs (different instances) -> OK
47.73 +out: TestBook String[0] - remove element -> OK
47.74 +out: TestBook - should contain one paragraph:
47.75 +out: paragraph - element
47.76 +out:
47.77 +out: TestBook String[0] - access elements (first, should be null) -> OK
47.78 +out: TestBook String[0] - access elements (second, should be !null) -> OK
47.79 +out: TestBook String[0] - set again first element -> OK
47.80 +out: TestBook - should contain two paragraphs:
47.81 +out: paragraph - element
47.82 +out: paragraph - element
47.83 +out:
47.84 +out: TestBook String[0] - removing all elements (removed correct index) -> OK
47.85 +out: TestBook String[0] - removing all elements (size is now 1) -> OK
47.86 +out: TestBook String[0] - removing all elements (removed correct index) -> OK
47.87 +out: TestBook String[0] - removing all elements (size is now 0) -> OK
47.88 +out: TestBook - should contain no paragraph:
47.89 +out:
47.90 +out: TestBook String[0] - search for array of size 1 -> OK
47.91 +out: TestBook String[0] - out of bounds access [-1] (IndexOutOfBoundsException) -> OK
47.92 +out: TestBook String[0] - out of bounds access [1] (IndexOutOfBoundsException) -> OK
47.93 +out: TestBook String[0] - out of bounds access [999] (IndexOutOfBoundsException) -> OK
47.94 +out: TestBook String[0] - add a string to the array -> OK
47.95 +out: TestBook - should contain two paragraphs:
47.96 +out: paragraph - element
47.97 +out: paragraph - element
47.98 +out:
47.99 +out: TestBook String[0] - compare paragraphs (different content) -> OK
47.100 +out: TestBook String[0] - add more paragraphs (100 new paragraphs) -> OK
47.101 +out: TestBook String[0] - removing paragraphs (leaving 10) -> OK
47.102 +out: TestBook - should contain 10 paragraphs:
47.103 +out: paragraph - element
47.104 +out: paragraph - element
47.105 +out: paragraph - element
47.106 +out: paragraph - element
47.107 +out: paragraph - element
47.108 +out: paragraph - element
47.109 +out: paragraph - element
47.110 +out: paragraph - element
47.111 +out: paragraph - element
47.112 +out: paragraph - element
47.113 +out:
47.114 +out: TestBook - book has 2 Index beans
47.115 +out: index - element
47.116 +out: index - element
47.117 +out:
47.118 +out: TestBook remove a bean w/ remove() (correct element removed) -> OK
47.119 +out: TestBook remove a bean w/ remove() (correct Index array size) -> OK
47.120 +out: TestBook - book should have 1 Index beans
47.121 +out: index - element
47.122 +out:
47.123 +out: TestBook remove another bean w/ set(null) (correct Index array size) -> OK
47.124 +out: TestBook - book should have 0 Index beans
47.125 +out:
47.126 +out: TestBook add an empty bean to the graph (correct Index array size) -> OK
47.127 +out: TestBook - book should have 1 Index beans
47.128 +out: index - element
47.129 +out:
47.130 +out: TestBook - book should have 2 Index beans
47.131 +out: index - element
47.132 +out: index - element
47.133 +out:
47.134 +out: TestBook - idx should have 2 refs
47.135 +out: index - element
47.136 +out: word - element
47.137 +out: #text=who - text
47.138 +out: ref - element
47.139 +out: page - element
47.140 +out: #text=122 - text
47.141 +out: line - element
47.142 +out: #text=32 - text
47.143 +out: ref - element
47.144 +out: page - element
47.145 +out: #text=1 - text
47.146 +out: line - element
47.147 +out: #text=3 - text
47.148 +out:
47.149 +out: TestBook add a subtree bean -> OK
47.150 +out: TestBook - book should have 3 Index beans
47.151 +out: index - element
47.152 +out: index - element
47.153 +out: index - element
47.154 +out:
47.155 +out: TestBook - idx should have 1 ref
47.156 +out: index - element
47.157 +out: word - element
47.158 +out: #text=what - text
47.159 +out: ref - element
47.160 +out: page - element
47.161 +out: #text=22 - text
47.162 +out: line - element
47.163 +out: #text=2 - text
47.164 +out:
47.165 +out: TestBook add another subtree bean -> OK
47.166 +out: TestBook should failed adding the same instance subtree
47.167 +out: >> caught: java.lang.IllegalArgumentException: Cannot insert an element which is already part of a graph. The element should be cloned first. -> OK
47.168 +out: TestBook - book should have 4 Index beans
47.169 +out: index - element
47.170 +out: index - element
47.171 +out: index - element
47.172 +out: index - element
47.173 +out:
47.174 +out: TestBook - Initial Index is:
47.175 +out: index - element
47.176 +out: word - element
47.177 +out: #text=who - text
47.178 +out: ref - element
47.179 +out: page - element
47.180 +out: #text=122 - text
47.181 +out: line - element
47.182 +out: #text=32 - text
47.183 +out: ref - element
47.184 +out: page - element
47.185 +out: #text=1 - text
47.186 +out: line - element
47.187 +out: #text=3 - text
47.188 +out:
47.189 +out: TestBook - New Index should be identical:
47.190 +out: index - element
47.191 +out: word - element
47.192 +out: #text=who - text
47.193 +out: ref - element
47.194 +out: page - element
47.195 +out: #text=122 - text
47.196 +out: line - element
47.197 +out: #text=32 - text
47.198 +out: ref - element
47.199 +out: page - element
47.200 +out: #text=1 - text
47.201 +out: line - element
47.202 +out: #text=3 - text
47.203 +out:
47.204 +out: TestBook add the same cloned tree -> OK
47.205 +out: TestBook add beans (correct size of array) -> OK
47.206 +out: TestBook - should have nothing to print:
47.207 +out: <no binding>
47.208 +out: TestBook remove an element (correct size of array) -> OK
47.209 +out: TestBook remove last element (correct size) -> OK
47.210 +out: TestBook - add an element and test getValues:
47.211 +out: Index
47.212 +out:
47.213 +out: Word
47.214 +out: <oops>
47.215 +out:
47.216 +out: Ref[1]
47.217 +out: #0:
47.218 +out: Page
47.219 +out: <77>
47.220 +out:
47.221 +out: Line
47.222 +out: <7>
47.223 +out:
47.224 +out: TestBook creating the root for a brand new graph -> OK
47.225 +out: TestBook populating the graph -> OK
47.226 +out: TestBook - print the new graph DOM nodes:
47.227 +out: book - element
47.228 +out: index - element
47.229 +out: word - element
47.230 +out: #text=summary - text
47.231 +out: ref - element
47.232 +out: page - element
47.233 +out: #text=22 - text
47.234 +out: line - element
47.235 +out: #text=12 - text
47.236 +out: ref - element
47.237 +out: page - element
47.238 +out: #text=4 - text
47.239 +out: line - element
47.240 +out: #text=5 - text
47.241 +out: chapter - element
47.242 +out: comment - element
47.243 +out: #text=What's a good summary in chapter 1 - text
47.244 +out: paragraph - element
47.245 +out: #text=This is the first paragraph - text
47.246 +out: paragraph - element
47.247 +out: #text=This is a second paragraph - text
47.248 +out: comment - element
47.249 +out: #text=Additional comment - text
47.250 +out: chapter - element
47.251 +out: comment - element
47.252 +out: #text=Yet another comment for chapter 2 - text
47.253 +out: paragraph - element
47.254 +out: #text=only one paragraph in this second chapter - text
47.255 +out: chapter - element
47.256 +out: summary - element
47.257 +out: #text=This book is about avoiding summaries at the end of books - text
47.258 +out: available - element
47.259 +out:
47.260 +out: TestBook - Re-read the original XML file for array getter/setter testing
47.261 +out: TestBook - creating the DOM document
47.262 +out: TestBook - bean graph created
47.263 +out: TestBook check Index[] getter() method (correct array size) -> OK
47.264 +out: TestBook check Index[] getter() method (same first element) -> OK
47.265 +out: TestBook check Index[] getter() method (same second element) -> OK
47.266 +out: TestBook check Index[] getter() method ([0] != [1]) -> OK
47.267 +out: TestBook check Chapter[] getter() method (correct array size) -> OK
47.268 +out: TestBook check Chapter[] getter() method (same first element) -> OK
47.269 +out: TestBook check Chapter[] getter() method (same second element) -> OK
47.270 +out: TestBook check Chapter[] getter() method (same third element) -> OK
47.271 +out: TestBook check Chapter[] getter() method ([0] != [2]) -> OK
47.272 +out: TestBook check Chapter.Paragraph getter() method (correct array size) -> OK
47.273 +out: TestBook check Chapter.Paragraph getter() method (correct array size) -> OK
47.274 +out: TestBook check Chapter.Paragraph getter() method (correct array size) -> OK
47.275 +out: TestBook change the Chapter[] order (reversed first element) -> OK
47.276 +out: TestBook change the Chapter[] order (same second element) -> OK
47.277 +out: TestBook change the Chapter[] order (reversed third element) -> OK
47.278 +out: TestBook - Make sure the contents of a Chapter object remain intact after removing that Chapter from the Book
47.279 +out: TestBook - This chapter may not make it into the book.
47.280 +out: TestBook - 4
47.281 +out: TestBook Chapter going in and out of Book undecided chapter is in there -> OK
47.282 +out: TestBook - make sure undecidedChapter is intact
47.283 +out: TestBook - This chapter may not make it into the book.
47.284 +out: TestBook - make sure book is intact
47.285 +out: TestBook - 3
47.286 +out: TestBook - Put the chapter back in.
47.287 +out: <?xml version="1.0" encoding="UTF-8"?>
47.288 +out: <book>
47.289 +out: <chapter>
47.290 +out: <comment>This chapter may not make it into the book.</comment>
47.291 +out: </chapter>
47.292 +out: <summary>
47.293 +out: This book is about the life of a book spent between books who dreamed
47.294 +out: to meet a fairy who could transform it into an XML book and travel
47.295 +out: in an electronic boundary-less world.
47.296 +out: </summary>
47.297 +out: <chapter>
47.298 +out: <comment>
47.299 +out: First chapter.
47.300 +out: </comment>
47.301 +out: <paragraph>
47.302 +out: Once upon a time...
47.303 +out: </paragraph>
47.304 +out: <paragraph>
47.305 +out: And this is how the book met the fairy, and how all this
47.306 +out: story began.
47.307 +out: </paragraph>
47.308 +out: </chapter>
47.309 +out: <chapter>
47.310 +out: <paragraph>
47.311 +out: And the book lived a never ending happy life, read, copied
47.312 +out: and enjoyed by so many readers.
47.313 +out: </paragraph>
47.314 +out: </chapter>
47.315 +out: <chapter>
47.316 +out: <comment>
47.317 +out: Empty chapter
47.318 +out: </comment>
47.319 +out: </chapter>
47.320 +out: <index>
47.321 +out: <word>
47.322 +out: Good book
47.323 +out: </word>
47.324 +out: <ref>
47.325 +out: <page>22</page>
47.326 +out: <line>12</line>
47.327 +out: </ref>
47.328 +out: </index>
47.329 +out: <index>
47.330 +out: <word>
47.331 +out: E-Tool
47.332 +out: </word>
47.333 +out: <ref>
47.334 +out: <page>5</page>
47.335 +out: <line>15</line>
47.336 +out: </ref>
47.337 +out: <ref>
47.338 +out: <page>29</page>
47.339 +out: <line>31</line>
47.340 +out: </ref>
47.341 +out: </index>
47.342 +out: <good/>
47.343 +out: <extra>
47.344 +out: <size-cm>
47.345 +out: 10x20
47.346 +out: </size-cm>
47.347 +out: <weight-kg>
47.348 +out: 0.125
47.349 +out: </weight-kg>
47.350 +out: </extra>
47.351 +out: </book>
47.352 +out: TestBook - creating the DOM document
47.353 +out: TestBook - creating the bean graph
47.354 +out: TestBook check if the root has any choice prop (none found) -> OK
47.355 +out: TestBook check if the root has any choice prop (none found on Chapter prop) -> OK
47.356 +out: TestBook check if the root has any choice prop (none found on index prop) -> OK
47.357 +out: TestBook test extra prop (at least one) -> OK
47.358 +out: TestBook - Getting a set of choice properties:
47.359 +out: TestBook test extra prop weight-lb -> OK
47.360 +out: TestBook test extra prop weight-kg -> OK
47.361 +out: TestBook - Getting a set of choice properties:
47.362 +out: TestBook test extra prop size-cm -> OK
47.363 +out: TestBook test extra prop size-inches -> OK
47.364 +out: TestBook test extra prop size -> OK
47.365 +out: TestBook - Getting the same list 3 times:
47.366 +out: TestBook test extra prop size-cm -> OK
47.367 +out: TestBook test extra prop size-inches -> OK
47.368 +out: TestBook test extra prop size -> OK
47.369 +out: TestBook test extra prop size-cm -> OK
47.370 +out: TestBook test extra prop size-inches -> OK
47.371 +out: TestBook test extra prop size -> OK
47.372 +out: TestBook test extra prop size-cm -> OK
47.373 +out: TestBook test extra prop size-inches -> OK
47.374 +out: TestBook test extra prop size -> OK
47.375 +out: TestBook - Getting twice the same list:
47.376 +out: TestBook test extra prop weight-lb -> OK
47.377 +out: TestBook test extra prop weight-kg -> OK
47.378 +out: TestBook test extra prop weight-lb -> OK
47.379 +out: TestBook test extra prop weight-kg -> OK
47.380 +out: TestBook test extra prop color not choice prop -> OK
47.381 +out: TestBook - Parsing /Book/Good
47.382 +out: TestBook - true
47.383 +out: TestBook - Parsing /Good
47.384 +out: TestBook - true
47.385 +out: TestBook - Parsing Summary/
47.386 +out: TestBook -
47.387 +out: This book is about the life of a book spent between books who dreamed
47.388 +out: to meet a fairy who could transform it into an XML book and travel
47.389 +out: in an electronic boundary-less world.
47.390 +out:
47.391 +out: TestBook - Parsing Summary
47.392 +out: TestBook - null
47.393 +out: TestBook - Parsing Available
47.394 +out: TestBook - null
47.395 +out: TestBook - Parsing Extra
47.396 +out: TestBook - Extra
47.397 +out:
47.398 +out: SizeCm
47.399 +out: <10x20>
47.400 +out:
47.401 +out: SizeInches
47.402 +out: <null>
47.403 +out:
47.404 +out: Size
47.405 +out: <null>
47.406 +out:
47.407 +out: Color
47.408 +out: <null>
47.409 +out:
47.410 +out: WeightLb
47.411 +out: <null>
47.412 +out:
47.413 +out: WeightKg
47.414 +out: <0.125>
47.415 +out:
47.416 +out: TestBook - Parsing Chapter
47.417 +out: TestBook - Chapter
47.418 +out:
47.419 +out: Comment
47.420 +out: <First chapter.>
47.421 +out:
47.422 +out: Paragraph[2]
47.423 +out: #0:
47.424 +out: <Once upon a time...>
47.425 +out:
47.426 +out: #1:
47.427 +out: <And this is how the book met the fairy, and how all this
47.428 +out: story began.>
47.429 +out:
47.430 +out: Comment2
47.431 +out: <null>
47.432 +out:
47.433 +out: TestBook - Chapter
47.434 +out:
47.435 +out: Comment
47.436 +out: <null>
47.437 +out:
47.438 +out: Paragraph[1]
47.439 +out: #0:
47.440 +out: <And the book lived a never ending happy life, read, copied
47.441 +out: and enjoyed by so many readers.>
47.442 +out:
47.443 +out: Comment2
47.444 +out: <null>
47.445 +out:
47.446 +out: TestBook - Chapter
47.447 +out:
47.448 +out: Comment
47.449 +out: <Empty chapter>
47.450 +out:
47.451 +out: Paragraph[0]
47.452 +out: Comment2
47.453 +out: <null>
47.454 +out:
47.455 +out: TestBook - Parsing Chapter/Comment
47.456 +out: TestBook -
47.457 +out: First chapter.
47.458 +out:
47.459 +out: TestBook - null
47.460 +out: TestBook -
47.461 +out: Empty chapter
47.462 +out:
47.463 +out: TestBook - Parsing Chapter/Paragraph
47.464 +out: TestBook -
47.465 +out: Once upon a time...
47.466 +out:
47.467 +out: TestBook -
47.468 +out: And this is how the book met the fairy, and how all this
47.469 +out: story began.
47.470 +out:
47.471 +out: TestBook -
47.472 +out: And the book lived a never ending happy life, read, copied
47.473 +out: and enjoyed by so many readers.
47.474 +out:
47.475 +out: TestBook - Parsing index/ref/line
47.476 +out: TestBook - 12
47.477 +out: TestBook - 15
47.478 +out: TestBook - 31
47.479 +out: TestBook - Book
47.480 +out:
47.481 +out: Index[2]
47.482 +out: #0:
47.483 +out: Word
47.484 +out: <Good book>
47.485 +out:
47.486 +out: Ref[1]
47.487 +out: #0:
47.488 +out: Page
47.489 +out: <22>
47.490 +out:
47.491 +out: Line
47.492 +out: <12>
47.493 +out:
47.494 +out: #1:
47.495 +out: Word
47.496 +out: <E-Tool>
47.497 +out:
47.498 +out: Ref[2]
47.499 +out: #0:
47.500 +out: Page
47.501 +out: <5>
47.502 +out:
47.503 +out: Line
47.504 +out: <15>
47.505 +out:
47.506 +out: #1:
47.507 +out: Page
47.508 +out: <29>
47.509 +out:
47.510 +out: Line
47.511 +out: <31>
47.512 +out:
47.513 +out: Chapter[3]
47.514 +out: #0:
47.515 +out: Comment
47.516 +out: <First chapter.>
47.517 +out:
47.518 +out: Paragraph[2]
47.519 +out: #0:
47.520 +out: <Once upon a time...>
47.521 +out:
47.522 +out: #1:
47.523 +out: <And this is how the book met the fairy, and how all this
47.524 +out: story began.>
47.525 +out:
47.526 +out: Comment2
47.527 +out: <null>
47.528 +out:
47.529 +out: #1:
47.530 +out: Comment
47.531 +out: <null>
47.532 +out:
47.533 +out: Paragraph[1]
47.534 +out: #0:
47.535 +out: <And the book lived a never ending happy life, read, copied
47.536 +out: and enjoyed by so many readers.>
47.537 +out:
47.538 +out: Comment2
47.539 +out: <null>
47.540 +out:
47.541 +out: #2:
47.542 +out: Comment
47.543 +out: <Empty chapter>
47.544 +out:
47.545 +out: Paragraph[0]
47.546 +out: Comment2
47.547 +out: <null>
47.548 +out:
47.549 +out: Summary
47.550 +out: <null>
47.551 +out:
47.552 +out: Good
47.553 +out: true
47.554 +out: Available
47.555 +out: false
47.556 +out: Extra
47.557 +out: SizeCm
47.558 +out: <10x20>
47.559 +out:
47.560 +out: SizeInches
47.561 +out: <null>
47.562 +out:
47.563 +out: Size
47.564 +out: <null>
47.565 +out:
47.566 +out: Color
47.567 +out: <null>
47.568 +out:
47.569 +out: WeightLb
47.570 +out: <null>
47.571 +out:
47.572 +out: WeightKg
47.573 +out: <0.125>
47.574 +out:
47.575 +out: TestBook - Parsing /Book/Index.Word=E-Tools/Ref/Page
47.576 +out: TestBook - Parsing /Book/Index.Word=E-Tool/Ref/Page
47.577 +out: TestBook - 5
47.578 +out: TestBook - 29
47.579 +out: TestBook - Parsing /Book/Index.Word=E-Tool/Ref.Line=15/Page
47.580 +out: TestBook - 5
47.581 +out: TestBook - Parsing /Book/Index.Word=E-Tool/Ref.Line=15/Page=22
47.582 +out: TestBook - Parsing /Book/Index.Word=E-Tool/Ref.Line=15/Page=5
47.583 +out: TestBook - 5
47.584 +out: TestBook - Book
47.585 +out:
47.586 +out: Index[0]
47.587 +out: Chapter[0]
47.588 +out: Summary
47.589 +out: <null>
47.590 +out:
47.591 +out: Good
47.592 +out: false
47.593 +out: Available
47.594 +out: false
47.595 +out: Extra
47.596 +out: null
47.597 +out: TestBook - Parsing /Book/Index.Word=E-Tools/Ref.Line=15/Page!
47.598 +out: TestBook - null
47.599 +out: TestBook - Book
47.600 +out:
47.601 +out: Index[1]
47.602 +out: #0:
47.603 +out: Word
47.604 +out: <E-Tools>
47.605 +out:
47.606 +out: Ref[1]
47.607 +out: #0:
47.608 +out: Page
47.609 +out: <null>
47.610 +out:
47.611 +out: Line
47.612 +out: <15>
47.613 +out:
47.614 +out: Chapter[0]
47.615 +out: Summary
47.616 +out: <null>
47.617 +out:
47.618 +out: Good
47.619 +out: false
47.620 +out: Available
47.621 +out: false
47.622 +out: Extra
47.623 +out: null
47.624 +out: TestBook - Parsing /Book/Chapter.Comment=My Comment
47.625 +out: TestBook - Book
47.626 +out:
47.627 +out: Index[1]
47.628 +out: #0:
47.629 +out: Word
47.630 +out: <E-Tools>
47.631 +out:
47.632 +out: Ref[1]
47.633 +out: #0:
47.634 +out: Page
47.635 +out: <null>
47.636 +out:
47.637 +out: Line
47.638 +out: <15>
47.639 +out:
47.640 +out: Chapter[0]
47.641 +out: Summary
47.642 +out: <null>
47.643 +out:
47.644 +out: Good
47.645 +out: false
47.646 +out: Available
47.647 +out: false
47.648 +out: Extra
47.649 +out: null
47.650 +out: TestBook - Parsing /Book/Chapter.Comment=My Comment!
47.651 +out: TestBook - Chapter
47.652 +out:
47.653 +out: Comment
47.654 +out: <My Comment>
47.655 +out:
47.656 +out: Paragraph[0]
47.657 +out: Comment2
47.658 +out: <null>
47.659 +out:
47.660 +out: TestBook - Book
47.661 +out:
47.662 +out: Index[1]
47.663 +out: #0:
47.664 +out: Word
47.665 +out: <E-Tools>
47.666 +out:
47.667 +out: Ref[1]
47.668 +out: #0:
47.669 +out: Page
47.670 +out: <null>
47.671 +out:
47.672 +out: Line
47.673 +out: <15>
47.674 +out:
47.675 +out: Chapter[1]
47.676 +out: #0:
47.677 +out: Comment
47.678 +out: <My Comment>
47.679 +out:
47.680 +out: Paragraph[0]
47.681 +out: Comment2
47.682 +out: <null>
47.683 +out:
47.684 +out: Summary
47.685 +out: <null>
47.686 +out:
47.687 +out: Good
47.688 +out: false
47.689 +out: Available
47.690 +out: false
47.691 +out: Extra
47.692 +out: null
47.693 +out: TestBook - Parsing /Book/Index.Word=the word/Ref.Line=10/Page=20!
47.694 +out: TestBook - 20
47.695 +out: TestBook - Book
47.696 +out:
47.697 +out: Index[2]
47.698 +out: #0:
47.699 +out: Word
47.700 +out: <E-Tools>
47.701 +out:
47.702 +out: Ref[1]
47.703 +out: #0:
47.704 +out: Page
47.705 +out: <null>
47.706 +out:
47.707 +out: Line
47.708 +out: <15>
47.709 +out:
47.710 +out: #1:
47.711 +out: Word
47.712 +out: <the word>
47.713 +out:
47.714 +out: Ref[1]
47.715 +out: #0:
47.716 +out: Page
47.717 +out: <20>
47.718 +out:
47.719 +out: Line
47.720 +out: <10>
47.721 +out:
47.722 +out: Chapter[1]
47.723 +out: #0:
47.724 +out: Comment
47.725 +out: <My Comment>
47.726 +out:
47.727 +out: Paragraph[0]
47.728 +out: Comment2
47.729 +out: <null>
47.730 +out:
47.731 +out: Summary
47.732 +out: <null>
47.733 +out:
47.734 +out: Good
47.735 +out: false
47.736 +out: Available
47.737 +out: false
47.738 +out: Extra
47.739 +out: null
47.740 +out: TestBook - creating the DOM document
47.741 +out: TestBook - creating the bean graph
47.742 +out: TestBook simple merge identical graphs -> OK
47.743 +Finished running TestBook: 0
48.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
48.2 +++ b/schema2beans/test/unit/src/data/goldenfiles/TestMain/testContrivedApp.pass Wed Jun 19 00:18:25 2002 +0000
48.3 @@ -0,0 +1,58 @@
48.4 +Calling GenBeans.doIt
48.5 +Compiling
48.6 +Finished compiling: 0
48.7 +out: TestContrivedApp - creating the bean graph
48.8 +out: TestContrivedApp - bean graph created
48.9 +out: <?xml version="1.0" encoding="UTF-8"?>
48.10 +out: <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">
48.11 +out: <application>
48.12 +out: <display-name>Application_EJBModule_Entity2</display-name>
48.13 +out: <description>J2EE Application & < >Application_EJBModule_Entity2<>&"'</description>
48.14 +out: <module>
48.15 +out: <ejb>EJBModule_Entity2.jar</ejb>
48.16 +out: <alt-dd>EJBModule_Entity2.xml</alt-dd>
48.17 +out: </module>
48.18 +out: </application>
48.19 +out: TestContrivedApp - module.myaltDd = EJBModule_Entity2.xml
48.20 +out: TestContrivedApp - Make sure XML metacharacters get escapped
48.21 +out: <?xml version="1.0" encoding="UTF-8"?>
48.22 +out: <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">
48.23 +out: <application>
48.24 +out: <display-name>Application_EJBModule_Entity2</display-name>
48.25 +out: <description>J2EE Application & < >Application_EJBModule_Entity2<>&"'</description>
48.26 +out: <module>
48.27 +out: <ejb>EJBModule_Entity2.jar</ejb>
48.28 +out: <alt-dd>Foo & Co</alt-dd>
48.29 +out: </module>
48.30 +out: </application>
48.31 +out: TestContrivedApp - Make sure alt-dd is still there with no whitespace
48.32 +out: <?xml version="1.0" encoding="UTF-8"?>
48.33 +out: <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">
48.34 +out: <application>
48.35 +out: <display-name>Application_EJBModule_Entity2</display-name>
48.36 +out: <description>J2EE Application & < >Application_EJBModule_Entity2<>&"'</description>
48.37 +out: <module>
48.38 +out: <ejb>EJBModule_Entity2.jar</ejb>
48.39 +out: <alt-dd></alt-dd>
48.40 +out: </module>
48.41 +out: </application>
48.42 +out: TestContrivedApp - alt-dd goes away now
48.43 +out: <?xml version="1.0" encoding="UTF-8"?>
48.44 +out: <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">
48.45 +out: <application>
48.46 +out: <display-name>Application_EJBModule_Entity2</display-name>
48.47 +out: <description>J2EE Application & < >Application_EJBModule_Entity2<>&"'</description>
48.48 +out: <module>
48.49 +out: <ejb>EJBModule_Entity2.jar</ejb>
48.50 +out: </module>
48.51 +out: </application>
48.52 +out: <?xml version="1.0" encoding="UTF-8"?>
48.53 +out: <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">
48.54 +out: <application>
48.55 +out: <display-name>Application_EJBModule_Entity2</display-name>
48.56 +out: <description>J2EE Application & < >Application_EJBModule_Entity2<>&"'</description>
48.57 +out: <module>
48.58 +out: <ejb>blue</ejb>
48.59 +out: </module>
48.60 +out: </application>
48.61 +Finished running TestContrivedApp: 0
49.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
49.2 +++ b/schema2beans/test/unit/src/data/goldenfiles/TestMain/testEmpty.pass Wed Jun 19 00:18:25 2002 +0000
49.3 @@ -0,0 +1,8 @@
49.4 +Calling GenBeans.doIt
49.5 +Compiling
49.6 +Finished compiling: 0
49.7 +out: TestEmpty - creating the bean graph
49.8 +out: TestEmpty - bean graph created
49.9 +out: <?xml version="1.0" encoding="UTF-8"?>
49.10 +out: <EmptyElement/>
49.11 +Finished running TestEmpty: 0
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
50.2 +++ b/schema2beans/test/unit/src/data/goldenfiles/TestMain/testEncoding.pass Wed Jun 19 00:18:25 2002 +0000
50.3 @@ -0,0 +1,62 @@
50.4 +Calling GenBeans.doIt
50.5 +Compiling
50.6 +Finished compiling: 0
50.7 +out: TestEncoding - creating the bean graph
50.8 +out: TestEncoding - bean graph created
50.9 +out: <?xml version="1.0" encoding="UTF-8"?>
50.10 +out: <!-- ex1.xml -->
50.11 +out: <!-- This is a simple XML source file. Object class metamethod -->
50.12 +out: <!-- m3 includes 8-bit ASCII text, with a tilde-n and accent-e -->
50.13 +out: <!-- characters embedded, to test the UTF8->native codeset -->
50.14 +out: <!-- conversion feature of the SAX expat driver. As long as this -->
50.15 +out: <!-- test is run under ISO-8859-1 localization, test output should-->
50.16 +out: <!-- be identical to test input, with one odd byte representing -->
50.17 +out: <!-- each of these 8-bit characters. -->
50.18 +out: <!-- -->
50.19 +out: <!-- The vi editor on Sun Solaris displays the two odd characters -->
50.20 +out: <!-- as \161 and \151. -->
50.21 +out: <!-- -->
50.22 +out: <!-- <!DOCTYPE FORTEDDL SYSTEM "TestEncoding.dtd" []> -->
50.23 +out: <FORTEDDL>
50.24 +out: <PHASE NUMBER="1" OBJECTNAME="c1" OBJECTTYPE="MetaPlan.MetaClass">
50.25 +out: <ATTRIBUTE NAME="Name">c1</ATTRIBUTE>
50.26 +out: <ATTRIBUTE NAME="MethodArray">
50.27 +out: <ARRAY>
50.28 +out: <MYOBJECT CLASS="MetaMethod">
50.29 +out: <ATTRIBUTE NAME="Name">m1</ATTRIBUTE>
50.30 +out: <ATTRIBUTE NAME="Text">
50.31 +out: task.lgr.putline('this is m1');
50.32 +out: return;
50.33 +out: </ATTRIBUTE>
50.34 +out: </MYOBJECT>
50.35 +out: <MYOBJECT CLASS="MetaMethod">
50.36 +out: <ATTRIBUTE NAME="Name">m2</ATTRIBUTE>
50.37 +out: <ATTRIBUTE NAME="Text">
50.38 +out: <?FORTE ThisIsAProcessingInstruction ?>
50.39 +out: task.lgr.putline('this is m2');
50.40 +out: return;
50.41 +out: </ATTRIBUTE>
50.42 +out: </MYOBJECT>
50.43 +out: <MYOBJECT CLASS="MetaMethod">
50.44 +out: <ATTRIBUTE NAME="Name">m3</ATTRIBUTE>
50.45 +out: <ATTRIBUTE NAME="8-bit ASCII text">
50.46 +out: task.lgr.putline('Yo amo habañero chilés');
50.47 +out: return;
50.48 +out: </ATTRIBUTE>
50.49 +out: </MYOBJECT>
50.50 +out: </ARRAY>
50.51 +out: </ATTRIBUTE>
50.52 +out: <ANNOTATION NAME="cr1" OBJECTTYPE="CrossRefInfo">
50.53 +out: <ATTRIBUTE NAME="InfoArray">
50.54 +out: <ARRAY>
50.55 +out: <MYOBJECT CLASS="infoItem">
50.56 +out: <ATTRIBUTE NAME="Reference">putline</ATTRIBUTE>
50.57 +out: <ATTRIBUTE NAME="Class">c1</ATTRIBUTE>
50.58 +out: <ATTRIBUTE NAME="Method">m1</ATTRIBUTE>
50.59 +out: </MYOBJECT>
50.60 +out: </ARRAY>
50.61 +out: </ATTRIBUTE>
50.62 +out: </ANNOTATION>
50.63 +out: </PHASE>
50.64 +out: </FORTEDDL>
50.65 +Finished running TestEncoding: 0
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
51.2 +++ b/schema2beans/test/unit/src/data/goldenfiles/TestMain/testEvents.pass Wed Jun 19 00:18:25 2002 +0000
51.3 @@ -0,0 +1,101 @@
51.4 +Calling GenBeans.doIt
51.5 +Compiling
51.6 +Finished compiling: 0
51.7 +out: TestEvents - creating the DOM document
51.8 +out: TestEvents - creating the bean graph
51.9 +out: TestEvents - bean graph created
51.10 +out: TestEvents - new listener for Book
51.11 +out: TestEvents - <Lnr:Book Evt:/Book/Summary Src:book.Book>
51.12 +out: TestEvents - <Summary[-1] - Parent: Book/book.Book>
51.13 +out: TestEvents simple change event on the root (old value) -> OK
51.14 +out: TestEvents simple change event on the root (new value) -> OK
51.15 +out: TestEvents - <Lnr:Book Evt:/Book/Summary Src:book.Book>
51.16 +out: TestEvents - <Summary[-1] - Parent: Book/book.Book>
51.17 +out: TestEvents change the same property on the root (old value) -> OK
51.18 +out: TestEvents change the same property on the root (new value) -> OK
51.19 +out: TestEvents - <Lnr:Book Evt:/Book/Summary Src:book.Book>
51.20 +out: TestEvents - <Summary[-1] - Parent: Book/book.Book>
51.21 +out: TestEvents remove this same property (old value) -> OK
51.22 +out: TestEvents remove this same property (new value) -> OK
51.23 +out: TestEvents - <Lnr:Book Evt:/Book/Chapter.1/Comment Src:book.Chapter>
51.24 +out: TestEvents - <Comment[-1] - Parent: Chapter/book.Chapter>
51.25 +out: TestEvents propagation of the event (oldvalue) -> OK
51.26 +out: TestEvents propagation of the event (newvalue) -> OK
51.27 +out: TestEvents - <Lnr:Book Evt:/Book/Chapter.1/Paragraph.18 Src:book.Chapter>
51.28 +out: TestEvents - <Paragraph[2] - Parent: Chapter/book.Chapter>
51.29 +out: TestEvents event on indexed property - add new (no old value - new element) -> OK
51.30 +out: TestEvents event on indexed property - add new (new value) -> OK
51.31 +out: TestEvents event on indexed property - add new (correct index) -> OK
51.32 +out: TestEvents - <Lnr:Book Evt:/Book/Chapter.1/Paragraph.19 Src:book.Chapter>
51.33 +out: TestEvents - <Paragraph[3] - Parent: Chapter/book.Chapter>
51.34 +out: TestEvents event on indexed property - add new (no old value - new element) -> OK
51.35 +out: TestEvents event on indexed property - add new (new value) -> OK
51.36 +out: TestEvents event on indexed property - add new (correct index) -> OK
51.37 +out: TestEvents - <Lnr:Book Evt:/Book/Chapter.1/Paragraph.1a Src:book.Chapter>
51.38 +out: TestEvents - <Paragraph[4] - Parent: Chapter/book.Chapter>
51.39 +out: TestEvents event on indexed property - add new (no old element - new element) -> OK
51.40 +out: TestEvents event on indexed property - add new (new value) -> OK
51.41 +out: TestEvents event on indexed property - add new (correct index) -> OK
51.42 +out: TestEvents - <Lnr:Book Evt:/Book/Chapter.1/Paragraph.18i2 Src:book.Chapter>
51.43 +out: TestEvents - <Paragraph[2] - Parent: Chapter/book.Chapter>
51.44 +out: TestEvents event on indexed property - remove index (old value) -> OK
51.45 +out: TestEvents event on indexed property - remove index (no new value) -> OK
51.46 +out: TestEvents event on indexed property - remove index (correct index) -> OK
51.47 +out: TestEvents - <Lnr:Book Evt:/Book/Chapter.1/Paragraph.1b Src:book.Chapter>
51.48 +out: TestEvents - <Paragraph[2] - Parent: Chapter/book.Chapter>
51.49 +out: TestEvents event on indexed property - reset new (old value) -> OK
51.50 +out: TestEvents event on indexed property - reset new (no new value) -> OK
51.51 +out: TestEvents event on indexed property - reset new (correct index) -> OK
51.52 +out: TestEvents - new listener for Chapter
51.53 +out: TestEvents - <Lnr:Chapter Evt:/Book/Chapter.5/Paragraph.1c Src:book.Chapter>
51.54 +out: TestEvents - <Paragraph[1] - Parent: Chapter/book.Chapter>
51.55 +out: TestEvents - <Lnr:Book Evt:/Book/Chapter.5/Paragraph.1c Src:book.Chapter>
51.56 +out: TestEvents - <Paragraph[1] - Parent: Chapter/book.Chapter>
51.57 +out: TestEvents two listeners - both receiving (no old value) -> OK
51.58 +out: TestEvents two listeners - both receiving (new value) -> OK
51.59 +out: TestEvents two listeners - both receiving (same old value - both listeners) -> OK
51.60 +out: TestEvents two listeners - both receiving (same new value - both listeners) -> OK
51.61 +out: TestEvents two listeners - both receiving (same index - both listeners) -> OK
51.62 +out: TestEvents two listeners - both receiving (same source - both listeners) -> OK
51.63 +out: TestEvents - <Lnr:Book Evt:/Book/Chapter.5/Comment Src:book.Chapter>
51.64 +out: TestEvents - <Comment[-1] - Parent: Chapter/book.Chapter>
51.65 +out: TestEvents two listeners - one receiving (root listener: yep) -> OK
51.66 +out: TestEvents two listeners - one receiving (chapter listener: noop) -> OK
51.67 +out: TestEvents one listener - no receiving (root listener: noop) -> OK
51.68 +out: TestEvents one listener - no receiving (chapter listener: noop) -> OK
51.69 +out: TestEvents - <Lnr:Chapter Evt:/Book/Chapter.5/Paragraph.1e Src:book.Chapter>
51.70 +out: TestEvents - <Paragraph[2] - Parent: Chapter/book.Chapter>
51.71 +out: TestEvents one listener - one receiving (root listener: noop) -> OK
51.72 +out: TestEvents one listener - one receiving (chapter listener: yep) -> OK
51.73 +out: TestEvents no listener - no receiving (root listener: noop) -> OK
51.74 +out: TestEvents no listener - no receiving (chapter listener: noop) -> OK
51.75 +out: TestEvents - <Lnr:Chapter Evt:/Book/Chapter.-1i1/Paragraph.6i0 Src:book.Chapter>
51.76 +out: TestEvents - <Paragraph[0] - Parent: Chapter>
51.77 +out: TestEvents - <Lnr:Chapter Evt:/Book/Chapter.-1i1/Paragraph.1ci1 Src:book.Chapter>
51.78 +out: TestEvents - <Paragraph[1] - Parent: Chapter>
51.79 +out: TestEvents - <Lnr:Chapter Evt:/Book/Chapter.-1i1/Paragraph.1ei2 Src:book.Chapter>
51.80 +out: TestEvents - <Paragraph[2] - Parent: Chapter>
51.81 +out: TestEvents - <Lnr:Chapter Evt:/Book/Chapter.-1i1/Paragraph.1fi3 Src:book.Chapter>
51.82 +out: TestEvents - <Paragraph[3] - Parent: Chapter>
51.83 +out: TestEvents - <Lnr:Book Evt:/Book/Chapter.5i1 Src:book.Book>
51.84 +out: TestEvents - <Chapter[1] - Parent: Book>
51.85 +out: TestEvents - should have received paragraph events on Chapter and Chapter event on Book
51.86 +out: TestEvents - should receive Chapter event and get 4 strings from the event
51.87 +out: TestEvents - <Lnr:Book Evt:/Book/Chapter.24 Src:book.Book>
51.88 +out: TestEvents - <Chapter[2] - Parent: Book>
51.89 +out: TestEvents - From event listener: 1. this is a paragraph
51.90 +out: TestEvents - From event listener: 2. this is a paragraph
51.91 +out: TestEvents - From event listener: 3. this is a paragraph
51.92 +out: TestEvents - From event listener: 4. this is a paragraph
51.93 +out: TestEvents - should receive Chapter event and get 3 strings from the event (1, 4, 3)
51.94 +out: TestEvents - <Lnr:Book Evt:/Book/Chapter.24/Paragraph.21i1 Src:book.Chapter>
51.95 +out: TestEvents - <Paragraph[1] - Parent: Chapter>
51.96 +out: TestEvents - From event listener: 1. this is a paragraph
51.97 +out: TestEvents - From event listener: 4. this is a paragraph
51.98 +out: TestEvents - From event listener: 3. this is a paragraph
51.99 +out: TestEvents - <Lnr:Book Evt:/Book/Chapter.24/Paragraph.-1 Src:book.Chapter>
51.100 +out: TestEvents - <Paragraph[-1] - Parent: Chapter>
51.101 +out: TestEvents - From event listener: 1. this is a paragraph
51.102 +out: TestEvents - From event listener: 4. this is a paragraph
51.103 +out: TestEvents - From event listener: 3. this is a paragraph
51.104 +Finished running TestEvents: 0
52.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
52.2 +++ b/schema2beans/test/unit/src/data/goldenfiles/TestMain/testExceptions.pass Wed Jun 19 00:18:25 2002 +0000
52.3 @@ -0,0 +1,7 @@
52.4 +Calling GenBeans.doIt
52.5 +Compiling
52.6 +Finished compiling: 0
52.7 +out: TestExceptions - creating the bean graph
52.8 +out: TestExceptions - Hit Exception: class org.netbeans.modules.schema2beans.Schema2BeansException
52.9 +out: TestExceptions - Doc root 'EXCEPS' not found in the DOM graph! Found 'foo' instead.
52.10 +Finished running TestExceptions: 0
53.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
53.2 +++ b/schema2beans/test/unit/src/data/goldenfiles/TestMain/testFind.pass Wed Jun 19 00:18:25 2002 +0000
53.3 @@ -0,0 +1,35 @@
53.4 +Calling GenBeans.doIt
53.5 +Compiling
53.6 +Finished compiling: 0
53.7 +out: TestFind - creating the DOM document
53.8 +out: TestFind - creating the bean graph
53.9 +out: TestFind - bean graph created
53.10 +out: TestFind Test findProperty - found element -> OK
53.11 +out: TestFind - /Book/Index.b/Word
53.12 +out: TestFind Test findProperty - found elements -> OK
53.13 +out: TestFind - /Book/Index.b/Ref.d/Line
53.14 +out: TestFind - /Book/Index.10/Ref.15/Line
53.15 +out: TestFind Test findProperty - not found element -> OK
53.16 +out: TestFind Test findValue - found elements -> OK
53.17 +out: TestFind - /Book/Index.b/Ref.d/Line
53.18 +out: TestFind - /Book/Index.10/Ref.15/Page
53.19 +out: TestFind - /Book/Index.10/Ref.15/Line
53.20 +out: TestFind Test findValue - found element -> OK
53.21 +out: TestFind - /Book/Index.10/Word
53.22 +out: TestFind Test findValue - not found element -> OK
53.23 +out: TestFind Test findValue - found elements -> OK
53.24 +out: TestFind - /Book/Index.b:CrossRef
53.25 +out: TestFind - /Book/Chapter.6/Comment
53.26 +out: TestFind Test findValue - found element -> OK
53.27 +out: TestFind - /Book:Good
53.28 +out: TestFind Test findAttributeValue - found element -> OK
53.29 +out: TestFind - /Book/Index.b:Color
53.30 +out: TestFind Test findAttributeValue - found element -> OK
53.31 +out: TestFind - /Book/Index.10:Color
53.32 +out: TestFind Test findAttributeValue - not found element -> OK
53.33 +out: TestFind Test findAttributeValue - found elements -> OK
53.34 +out: TestFind - /Book/Index.b/Word:Freq
53.35 +out: TestFind - /Book/Index.10/Word:Freq
53.36 +out: TestFind Test findAttributeValue - found element -> OK
53.37 +out: TestFind - /Book:Good
53.38 +Finished running TestFind: 0
54.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
54.2 +++ b/schema2beans/test/unit/src/data/goldenfiles/TestMain/testMdd.pass Wed Jun 19 00:18:25 2002 +0000
54.3 @@ -0,0 +1,83 @@
54.4 +Calling GenBeans.doIt
54.5 +Compiling
54.6 +Finished compiling: 0
54.7 +out: TestMdd - creating the DOM document
54.8 +out: TestMdd - creating the bean graph
54.9 +out: TestMdd - bean graph created
54.10 +out: TestMdd get non scalar wrapper object -> OK
54.11 +out: TestMdd - MyDate value = 14/07/2000
54.12 +out: TestMdd get float scalar value -> OK
54.13 +out: TestMdd - Setting new price to 9.99
54.14 +out: TestMdd get float scalar value -> OK
54.15 +out: TestMdd - Price and date should match
54.16 +out: book - element
54.17 +out: summary - element
54.18 +out: #text=
54.19 +out: This book is about the life of a book spent between books who dreamed
54.20 +out: to meet a fairy who could transform it into an XML book and travel
54.21 +out: in an electronic boundary-less world.
54.22 +out: - text
54.23 +out: price - element
54.24 +out: #text=9.99 - text
54.25 +out: date - element
54.26 +out: #text=14/07/2000 - text
54.27 +out: chapter - element
54.28 +out: comment - element
54.29 +out: paragraph - element
54.30 +out: paragraph - element
54.31 +out: chapter - element
54.32 +out: paragraph - element
54.33 +out: chapter - element
54.34 +out: comment - element
54.35 +out: index - element
54.36 +out: alpha - element
54.37 +out: word - element
54.38 +out: ref - element
54.39 +out: index - element
54.40 +out: word - element
54.41 +out: ref - element
54.42 +out: ref - element
54.43 +out:
54.44 +out: TestMdd get char scalar value -> OK
54.45 +out: TestMdd get char scalar value -> OK
54.46 +out: TestMdd - Alpha should be 'x'
54.47 +out: index - element
54.48 +out: alpha - element
54.49 +out: #text=x - text
54.50 +out: word - element
54.51 +out: #text=
54.52 +out: Good book
54.53 +out: - text
54.54 +out: ref - element
54.55 +out: page - element
54.56 +out: line - element
54.57 +out: line - element
54.58 +out: line - element
54.59 +out:
54.60 +out: TestMdd get int/int[] scalar values -> OK
54.61 +out: TestMdd get int/int[] scalar values -> OK
54.62 +out: TestMdd get int/int[] scalar values -> OK
54.63 +out: TestMdd get int/int[] scalar values -> OK
54.64 +out: TestMdd get int/int[] scalar values -> OK
54.65 +out: TestMdd get int/int[] scalar values -> OK
54.66 +out: TestMdd get int/int[] scalar values -> OK
54.67 +out: TestMdd get int/int[] scalar values -> OK
54.68 +out: TestMdd get int/int[] scalar values -> OK
54.69 +out: TestMdd - Lines should be 12/22/323
54.70 +out: ref - element
54.71 +out: page - element
54.72 +out: #text=
54.73 +out: 22
54.74 +out: - text
54.75 +out: line - element
54.76 +out: #text=
54.77 +out: 12
54.78 +out: - text
54.79 +out: line - element
54.80 +out: #text=
54.81 +out: 22
54.82 +out: - text
54.83 +out: line - element
54.84 +out: #text=323 - text
54.85 +out:
54.86 +Finished running TestMdd: 0
55.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
55.2 +++ b/schema2beans/test/unit/src/data/goldenfiles/TestMain/testMerge.pass Wed Jun 19 00:18:25 2002 +0000
55.3 @@ -0,0 +1,333 @@
55.4 +Calling GenBeans.doIt
55.5 +Compiling
55.6 +Finished compiling: 0
55.7 +out: TestMerge - creating the DOM document
55.8 +out: TestMerge - creating the bean graph1
55.9 +out: TestMerge - creating the DOM document
55.10 +out: TestMerge - creating the bean graph2
55.11 +out: TestMerge - new listener for Book
55.12 +out: TestMerge - new listener for Book
55.13 +out: TestMerge - should not get any event
55.14 +out: TestMerge Merge(Update) - two identical xml files - no diff -> OK
55.15 +out: TestMerge Merge(Update) - two identical xml files - equals -> OK
55.16 +out: TestMerge - creating the DOM document
55.17 +out: TestMerge - creating the bean graph3
55.18 +out: TestMerge - new listener for Book
55.19 +out: TestMerge Merge(Update) - two identical xml files (one mixed up) - equals -> OK
55.20 +out: TestMerge - should get one event for Summary
55.21 +out: TestMerge - <Chg Lnr:Book Evt:/Book/Summary Src:book.Book>
55.22 +out: TestMerge - <Summary[-1] - Parent: Book/book.Book>
55.23 +out: <?xml version="1.0" encoding="UTF-8"?>
55.24 +out: <book>
55.25 +out: <author>
55.26 +out: John Smith
55.27 +out: </author>
55.28 +out: <author>
55.29 +out: Mikey Mouse
55.30 +out: </author>
55.31 +out: <chapter>
55.32 +out: <paragraph>
55.33 +out: Once upon a time...
55.34 +out: </paragraph>
55.35 +out: <paragraph>
55.36 +out: And this is how the book met the fairy, and how all this
55.37 +out: story began.
55.38 +out: </paragraph>
55.39 +out: <comment>
55.40 +out: First chapter.
55.41 +out: </comment>
55.42 +out: </chapter>
55.43 +out: <chapter>
55.44 +out: <paragraph>
55.45 +out: And the book lived a never ending happy life, read, copied
55.46 +out: and enjoyed by so many readers.
55.47 +out: </paragraph>
55.48 +out: </chapter>
55.49 +out: <index>
55.50 +out: <ref>
55.51 +out: <line>
55.52 +out: 12
55.53 +out: </line>
55.54 +out: <page>
55.55 +out: 22
55.56 +out: </page>
55.57 +out: </ref>
55.58 +out: <word>
55.59 +out: Good book
55.60 +out: </word>
55.61 +out: </index>
55.62 +out: <author>
55.63 +out: Donald Duck
55.64 +out: </author>
55.65 +out: <chapter>
55.66 +out: <comment>
55.67 +out: Empty chapter
55.68 +out: </comment>
55.69 +out: </chapter>
55.70 +out: <good/>
55.71 +out: <index>
55.72 +out: <ref>
55.73 +out: <page>
55.74 +out: 5
55.75 +out: </page>
55.76 +out: <line>
55.77 +out: 15
55.78 +out: </line>
55.79 +out: </ref>
55.80 +out: <word>
55.81 +out: E-Tool
55.82 +out: </word>
55.83 +out: <ref>
55.84 +out: <page>
55.85 +out: 29
55.86 +out: </page>
55.87 +out: <line>
55.88 +out: 31
55.89 +out: </line>
55.90 +out: </ref>
55.91 +out: </index>
55.92 +out: <summary size="12">This is the new summary</summary>
55.93 +out: </book>
55.94 +out: TestMerge Merge(Update) - changing one property - equals -> OK
55.95 +out: TestMerge - should not get any event
55.96 +out: TestMerge Merge(Update) - changing one property - equals -> OK
55.97 +out: TestMerge Merge(Update) - mixing array of strings initial match -> OK
55.98 +out: TestMerge Merge(Update) - mixing array of strings initial match -> OK
55.99 +out: TestMerge Merge(Update) - mixing array of strings initial match -> OK
55.100 +out: TestMerge - <Chg Lnr:Book Evt:/Book/Author.-1 Src:book.Book>
55.101 +out: TestMerge - <Author[-1] - Parent: Book/book.Book>
55.102 +out: TestMerge Merge(Update) - mixing array of strings mixed -> OK
55.103 +out: TestMerge Merge(Update) - mixing array of strings mixed -> OK
55.104 +out: TestMerge Merge(Update) - mixing array of strings mixed -> OK
55.105 +out: TestMerge - should not get any event
55.106 +out: TestMerge Merge(Update) - mixing array of strings - equals -> OK
55.107 +out: TestMerge Merge(Update) - mixing array of strings reset match -> OK
55.108 +out: TestMerge Merge(Update) - mixing array of strings reset match -> OK
55.109 +out: TestMerge Merge(Update) - mixing array of strings reset match -> OK
55.110 +out: TestMerge Merge(Update) - mixing array of beans initial match -> OK
55.111 +out: TestMerge Merge(Update) - mixing array of beans initial match -> OK
55.112 +out: TestMerge Merge(Update) - mixing array of beans initial match -> OK
55.113 +out: TestMerge - <Chg Lnr:Book Evt:/Book/Chapter.-1 Src:book.Book>
55.114 +out: TestMerge - <Chapter[-1] - Parent: Book/book.Book>
55.115 +out: TestMerge Merge(Update) - mixing array of beans mixed -> OK
55.116 +out: TestMerge Merge(Update) - mixing array of beans mixed -> OK
55.117 +out: TestMerge Merge(Update) - mixing array of beans mixed -> OK
55.118 +out: TestMerge - should not get any event
55.119 +out: TestMerge Merge(Update) - mixing array of beans - equals -> OK
55.120 +out: TestMerge Merge(Update) - mixing array of beans reset match -> OK
55.121 +out: TestMerge Merge(Update) - mixing array of beans reset match -> OK
55.122 +out: TestMerge Merge(Update) - mixing array of beans reset match -> OK
55.123 +out: TestMerge Merge(Update) - remove elt from array of strings initial match -> OK
55.124 +out: TestMerge Merge(Update) - remove elt from array of strings initial match -> OK
55.125 +out: TestMerge Merge(Update) - remove elt from array of strings initial match -> OK
55.126 +out: TestMerge - should get one remove event from deletion
55.127 +out: TestMerge - <Rmv Lnr:Book Evt:/Book/Author.1ci1 Src:book.Book>
55.128 +out: TestMerge - <Author[1] - Parent: Book/book.Book>
55.129 +out: TestMerge Merge(Update) - remove elt from array of strings match after rem -> OK
55.130 +out: TestMerge Merge(Update) - remove elt from array of strings match after rem -> OK
55.131 +out: TestMerge - should get one remove event from merge
55.132 +out: TestMerge - <Rmv Lnr:Book Evt:/Book/Author.2i1 Src:book.Book>
55.133 +out: TestMerge - <Author[1] - Parent: Book/book.Book>
55.134 +out: TestMerge Merge(Update) - remove elt from array of strings match -> OK
55.135 +out: TestMerge Merge(Update) - remove elt from array of strings match -> OK
55.136 +out: TestMerge Merge(Update) - remove elt from array of strings correct size -> OK
55.137 +out: TestMerge Merge(Update) - remove elt from array of strings - equals -> OK
55.138 +out: TestMerge - should get one event for elt added
55.139 +out: TestMerge - <Add Lnr:Book Evt:/Book/Author.4e Src:book.Book>
55.140 +out: TestMerge - <Author[2] - Parent: Book/book.Book>
55.141 +out: TestMerge Merge(Update) - add elt from array of strings added -> OK
55.142 +out: TestMerge - should get one event for elt added from merge
55.143 +out: TestMerge - <Add Lnr:Book Evt:/Book/Author.4f Src:book.Book>
55.144 +out: TestMerge - <Author[2] - Parent: Book/book.Book>
55.145 +out: TestMerge Merge(Update) - add elt from array of strings match -> OK
55.146 +out: TestMerge Merge(Update) - add elt from array of strings match -> OK
55.147 +out: TestMerge Merge(Update) - add elt from array of strings match -> OK
55.148 +out: TestMerge Merge(Update) - add elt from array of strings correct size -> OK
55.149 +out: TestMerge Merge(Update) - add elt from array of strings - equals -> OK
55.150 +out: TestMerge Merge(Update) - remove elt from array of beans initial match -> OK
55.151 +out: TestMerge Merge(Update) - remove elt from array of beans initial match -> OK
55.152 +out: TestMerge Merge(Update) - remove elt from array of beans initial match -> OK
55.153 +out: TestMerge - should get one remove event from deletion
55.154 +out: TestMerge - <Rmv Lnr:Book Evt:/Book/Chapter.21i1 Src:book.Book>
55.155 +out: TestMerge - <Chapter[1] - Parent: Book/book.Book>
55.156 +out: TestMerge Merge(Update) - remove elt from array of beans match after rem -> OK
55.157 +out: TestMerge Merge(Update) - remove elt from array of beans match after rem -> OK
55.158 +out: TestMerge - should get one remove event from merge
55.159 +out: TestMerge - <Rmv Lnr:Book Evt:/Book/Chapter.7i1 Src:book.Book>
55.160 +out: TestMerge - <Chapter[1] - Parent: Book/book.Book>
55.161 +out: TestMerge Merge(Update) - remove elt from array of beans match -> OK
55.162 +out: TestMerge Merge(Update) - remove elt from array of beans match -> OK
55.163 +out: TestMerge Merge(Update) - remove elt from array of beans correct size -> OK
55.164 +out: TestMerge Merge(Update) - remove elt from array of beans - equals -> OK
55.165 +out: TestMerge - should get one event for elt added
55.166 +out: TestMerge - <Add Lnr:Book Evt:/Book/Chapter.51 Src:book.Book>
55.167 +out: TestMerge - <Chapter[2] - Parent: Book/book.Book>
55.168 +out: TestMerge Merge(Update) - add elt from array of strings added -> OK
55.169 +out: TestMerge - should get one event for elt added from merge
55.170 +out: TestMerge - <Add Lnr:Book Evt:/Book/Chapter.53 Src:book.Book>
55.171 +out: TestMerge - <Chapter[2] - Parent: Book/book.Book>
55.172 +out: TestMerge Merge(Update) - add elt from array of strings match -> OK
55.173 +out: TestMerge Merge(Update) - add elt from array of strings match -> OK
55.174 +out: TestMerge Merge(Update) - add elt from array of strings match -> OK
55.175 +out: TestMerge Merge(Update) - add elt from array of strings correct size -> OK
55.176 +out: TestMerge Merge(Update) - add elt from array of strings - equals -> OK
55.177 +out: TestMerge - creating the DOM document
55.178 +out: TestMerge - creating the bean graph1
55.179 +out: TestMerge comparing graphs with 1 null elts -> OK
55.180 +out: TestMerge comparing graphs with 1 null elts -> OK
55.181 +out: TestMerge comparing graphs with 1 null elts -> OK
55.182 +out: TestMerge comparing graphs with null indexed elts -> OK
55.183 +out: TestMerge comparing graphs with null indexed elts correct new array sise -> OK
55.184 +out: TestMerge comparing graphs with null indexed elts elt ok -> OK
55.185 +out: TestMerge comparing graphs with null indexed elts elt ok -> OK
55.186 +out: TestMerge comparing graphs with null indexed elts elt ok -> OK
55.187 +out: TestMerge comparing graphs with null single bean elt -> OK
55.188 +out: TestMerge comparing graphs with null single bean elt -> OK
55.189 +out: TestMerge comparing graphs with null single bean elt -> OK
55.190 +out: TestMerge cloning a new bean objects equal -> OK
55.191 +out: TestMerge cloning a new bean same graph once added -> OK
55.192 +out: TestMerge - creating the DOM document
55.193 +out: TestMerge - creating the bean graph1
55.194 +out: TestMerge - creating the DOM document
55.195 +out: TestMerge - creating the bean graph2
55.196 +out: TestMerge - chapter - element
55.197 +out: attribute: title=First
55.198 +out: paragraph - element
55.199 +out: #text=
55.200 +out: And the book lived a never ending happy life, read, copied
55.201 +out: and enjoyed by so many readers.
55.202 +out: - text
55.203 +out:
55.204 +out: TestMerge - chapter - element
55.205 +out: attribute: title=First
55.206 +out: paragraph - element
55.207 +out: #text=
55.208 +out: And the book lived a never ending happy life, read, copied
55.209 +out: and enjoyed by so many readers.
55.210 +out: - text
55.211 +out:
55.212 +out: TestMerge - new listener for Book
55.213 +out: TestMerge - new listener for Book
55.214 +out: TestMerge Merging attributes shouldn't be equals (diff an attr) -> OK
55.215 +out: TestMerge - <Add Lnr:Book Evt:/Book:Good Src:book.Book>
55.216 +out: TestMerge - <Book[-1] - Parent: /book.Book>
55.217 +out: TestMerge - <Rmv Lnr:Book Evt:/Book/Chapter.11fi0 Src:book.Book>
55.218 +out: TestMerge - <Chapter[0] - Parent: Book/book.Book>
55.219 +out: TestMerge - <Rmv Lnr:Book Evt:/Book/Chapter.121i0 Src:book.Book>
55.220 +out: TestMerge - <Chapter[0] - Parent: Book/book.Book>
55.221 +out: TestMerge - <Add Lnr:Book Evt:/Book/Chapter.16b Src:book.Book>
55.222 +out: TestMerge - <Chapter[1] - Parent: Book/book.Book>
55.223 +out: TestMerge - <Add Lnr:Book Evt:/Book/Chapter.16b:Title Src:book.Book>
55.224 +out: TestMerge - <Chapter[1] - Parent: Book/book.Book>
55.225 +out: TestMerge - <Add Lnr:Book Evt:/Book/Chapter.16f Src:book.Book>
55.226 +out: TestMerge - <Chapter[2] - Parent: Book/book.Book>
55.227 +out: TestMerge - <Add Lnr:Book Evt:/Book/Chapter.16f:Title Src:book.Book>
55.228 +out: TestMerge - <Chapter[2] - Parent: Book/book.Book>
55.229 +out: TestMerge - <Rmv Lnr:Book Evt:/Book/Index.127i0 Src:book.Book>
55.230 +out: TestMerge - <Index[0] - Parent: Book/book.Book>
55.231 +out: TestMerge - <Add Lnr:Book Evt:/Book/Index.174 Src:book.Book>
55.232 +out: TestMerge - <Index[1] - Parent: Book/book.Book>
55.233 +out: TestMerge - <Add Lnr:Book Evt:/Book/Index.174:Color Src:book.Book>
55.234 +out: TestMerge - <Index[1] - Parent: Book/book.Book>
55.235 +out: TestMerge - <Add Lnr:Book Evt:/Book/Summary:Length Src:book.Book>
55.236 +out: TestMerge - <Summary[-1] - Parent: Book/book.Book>
55.237 +out: TestMerge - <Add Lnr:Book Evt:/Book/Summary:Lang Src:book.Book>
55.238 +out: TestMerge - <Summary[-1] - Parent: Book/book.Book>
55.239 +out: TestMerge Merging attributes should be equals -> OK
55.240 +out: TestMerge Merging attributes attr on root != null -> OK
55.241 +out: TestMerge Merging attributes attr on root -> OK
55.242 +out: TestMerge Merging attributes attr on summary != null -> OK
55.243 +out: TestMerge Merging attributes attr on summary -> OK
55.244 +out: TestMerge Merging attributes attr on summary != null -> OK
55.245 +out: TestMerge Merging attributes attr on summary -> OK
55.246 +out: TestMerge - First
55.247 +out: TestMerge Merging attributes attr on chapter != null -> OK
55.248 +out: TestMerge Merging attributes attr on chapter -> OK
55.249 +out: TestMerge - Second
55.250 +out: TestMerge Merging attributes attr on chapter != null -> OK
55.251 +out: TestMerge Merging attributes attr on chapter -> OK
55.252 +out: TestMerge - creating the DOM document
55.253 +out: TestMerge - creating the bean graph for memory test
55.254 +out: TestMerge - memory test done
55.255 +out: TestMerge - creating the DOM document
55.256 +out: TestMerge - creating the DOM document
55.257 +out: TestMerge - creating the bean graph for the comment merge test
55.258 +out: <?xml version="1.0" encoding="UTF-8"?>
55.259 +out: <book good="no">
55.260 +out: <!-- BLUE -->
55.261 +out: <author>
55.262 +out: John Smith
55.263 +out: </author>
55.264 +out: <author>
55.265 +out: Mikey Mouse
55.266 +out: </author>
55.267 +out: <author>
55.268 +out: Donald Duck
55.269 +out: </author>
55.270 +out: <index color="blue" cross-ref="no">
55.271 +out: <word>
55.272 +out: Good book
55.273 +out: </word>
55.274 +out: <ref>
55.275 +out: <page>
55.276 +out: 22
55.277 +out: </page>
55.278 +out: <line>
55.279 +out: 12
55.280 +out: </line>
55.281 +out: </ref>
55.282 +out: </index>
55.283 +out: <chapter>
55.284 +out: <comment>
55.285 +out: Empty chapter
55.286 +out: </comment>
55.287 +out: </chapter>
55.288 +out: <good/>
55.289 +out: <index>
55.290 +out: <!--RED-->
55.291 +out: <ref>
55.292 +out: <page>
55.293 +out: 5
55.294 +out: </page>
55.295 +out: <line>
55.296 +out: 15
55.297 +out: </line>
55.298 +out: </ref>
55.299 +out: <word>
55.300 +out: E-Tool
55.301 +out: </word>
55.302 +out: <ref>
55.303 +out: <page>
55.304 +out: 29
55.305 +out: </page>
55.306 +out: <line>
55.307 +out: 31
55.308 +out: </line>
55.309 +out: </ref>
55.310 +out: </index>
55.311 +out: <chapter title="First">
55.312 +out: <paragraph>
55.313 +out: And the book lived a never ending happy life, read, copied
55.314 +out: and enjoyed by so many readers.
55.315 +out: </paragraph>
55.316 +out: </chapter>
55.317 +out: <chapter title="Second">
55.318 +out: <comment>
55.319 +out: First chapter.
55.320 +out: </comment>
55.321 +out: <paragraph>
55.322 +out: Once upon a time...
55.323 +out: </paragraph>
55.324 +out: <paragraph>
55.325 +out: And this is how the book met the fairy, and how all this
55.326 +out: story began.
55.327 +out: </paragraph>
55.328 +out: </chapter>
55.329 +out: <summary lang="us" length="123" size="12">
55.330 +out: This book is about the life of a book spent between books who dreamed
55.331 +out: to meet a fairy who could transform it into an XML book and travel
55.332 +out: in an electronic boundary-less world.
55.333 +out: </summary>
55.334 +out: <!-- GREEN -->
55.335 +out: </book>
55.336 +Finished running TestMerge: 0
56.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
56.2 +++ b/schema2beans/test/unit/src/data/goldenfiles/TestMain/testValid.pass Wed Jun 19 00:18:25 2002 +0000
56.3 @@ -0,0 +1,298 @@
56.4 +Calling GenBeans.doIt
56.5 +Compiling
56.6 +Finished compiling: 0
56.7 +out: TestValid - creating the DOM document
56.8 +out: TestValid - Current XML document:
56.9 +out: <?xml version="1.0" encoding="UTF-8"?>
56.10 +out: <!DOCTYPE book>
56.11 +out: <book instock="yes">
56.12 +out: <chapter>
56.13 +out: <title lang="en">The sand castle</title>
56.14 +out: <paragraph>
56.15 +out: Once upon a time, on a far sunny island, ...
56.16 +out: </paragraph>
56.17 +out: </chapter>
56.18 +out: </book>
56.19 +out: TestValid - Should add paperback after chapter:
56.20 +out: <?xml version="1.0" encoding="UTF-8"?>
56.21 +out: <!DOCTYPE book>
56.22 +out: <book instock="yes">
56.23 +out: <chapter>
56.24 +out: <title lang="en">The sand castle</title>
56.25 +out: <paragraph>
56.26 +out: Once upon a time, on a far sunny island, ...
56.27 +out: </paragraph>
56.28 +out: </chapter>
56.29 +out: <paperback/>
56.30 +out: </book>
56.31 +out: TestValid - Should add summary after paperback:
56.32 +out: <?xml version="1.0" encoding="UTF-8"?>
56.33 +out: <!DOCTYPE book>
56.34 +out: <book instock="yes">
56.35 +out: <chapter>
56.36 +out: <title lang="en">The sand castle</title>
56.37 +out: <paragraph>
56.38 +out: Once upon a time, on a far sunny island, ...
56.39 +out: </paragraph>
56.40 +out: </chapter>
56.41 +out: <paperback/>
56.42 +out: <summary>Summary of the book</summary>
56.43 +out: </book>
56.44 +out: TestValid - Should add chapter before paperback
56.45 +out: <?xml version="1.0" encoding="UTF-8"?>
56.46 +out: <!DOCTYPE book>
56.47 +out: <book instock="yes">
56.48 +out: <chapter>
56.49 +out: <title lang="en">The sand castle</title>
56.50 +out: <paragraph>
56.51 +out: Once upon a time, on a far sunny island, ...
56.52 +out: </paragraph>
56.53 +out: </chapter>
56.54 +out: <chapter>
56.55 +out: <title lang="en">title1</title>
56.56 +out: </chapter>
56.57 +out: <chapter>
56.58 +out: <title lang="en">title2</title>
56.59 +out: </chapter>
56.60 +out: <chapter>
56.61 +out: <title lang="en">title3</title>
56.62 +out: </chapter>
56.63 +out: <chapter>
56.64 +out: <title lang="en">title4</title>
56.65 +out: </chapter>
56.66 +out: <chapter>
56.67 +out: <title lang="en">title5</title>
56.68 +out: </chapter>
56.69 +out: <paperback/>
56.70 +out: <summary>Summary of the book</summary>
56.71 +out: </book>
56.72 +out: TestValid - Should add title as the first property of book:
56.73 +out: <?xml version="1.0" encoding="UTF-8"?>
56.74 +out: <!DOCTYPE book>
56.75 +out: <book instock="yes">
56.76 +out: <title lang="en">Title of the book</title>
56.77 +out: <chapter>
56.78 +out: <title lang="en">The sand castle</title>
56.79 +out: <paragraph>
56.80 +out: Once upon a time, on a far sunny island, ...
56.81 +out: </paragraph>
56.82 +out: </chapter>
56.83 +out: <chapter>
56.84 +out: <title lang="en">title1</title>
56.85 +out: </chapter>
56.86 +out: <chapter>
56.87 +out: <title lang="en">title2</title>
56.88 +out: </chapter>
56.89 +out: <chapter>
56.90 +out: <title lang="en">title3</title>
56.91 +out: </chapter>
56.92 +out: <chapter>
56.93 +out: <title lang="en">title4</title>
56.94 +out: </chapter>
56.95 +out: <chapter>
56.96 +out: <title lang="en">title5</title>
56.97 +out: </chapter>
56.98 +out: <paperback/>
56.99 +out: <summary>Summary of the book</summary>
56.100 +out: </book>
56.101 +out: TestValid - Should add price as the last property of book:
56.102 +out: <?xml version="1.0" encoding="UTF-8"?>
56.103 +out: <!DOCTYPE book>
56.104 +out: <book instock="yes">
56.105 +out: <title lang="en">Title of the book</title>
56.106 +out: <chapter>
56.107 +out: <title lang="en">The sand castle</title>
56.108 +out: <paragraph>
56.109 +out: Once upon a time, on a far sunny island, ...
56.110 +out: </paragraph>
56.111 +out: </chapter>
56.112 +out: <chapter>
56.113 +out: <title lang="en">title1</title>
56.114 +out: </chapter>
56.115 +out: <chapter>
56.116 +out: <title lang="en">title2</title>
56.117 +out: </chapter>
56.118 +out: <chapter>
56.119 +out: <title lang="en">title3</title>
56.120 +out: </chapter>
56.121 +out: <chapter>
56.122 +out: <title lang="en">title4</title>
56.123 +out: </chapter>
56.124 +out: <chapter>
56.125 +out: <title lang="en">title5</title>
56.126 +out: </chapter>
56.127 +out: <paperback/>
56.128 +out: <summary>Summary of the book</summary>
56.129 +out: <price>19.99</price>
56.130 +out: </book>
56.131 +out: TestValid - Should add isbn before the price:
56.132 +out: <?xml version="1.0" encoding="UTF-8"?>
56.133 +out: <!DOCTYPE book>
56.134 +out: <book instock="yes">
56.135 +out: <title lang="en">Title of the book</title>
56.136 +out: <chapter>
56.137 +out: <title lang="en">The sand castle</title>
56.138 +out: <paragraph>
56.139 +out: Once upon a time, on a far sunny island, ...
56.140 +out: </paragraph>
56.141 +out: </chapter>
56.142 +out: <chapter>
56.143 +out: <title lang="en">title1</title>
56.144 +out: </chapter>
56.145 +out: <chapter>
56.146 +out: <title lang="en">title2</title>
56.147 +out: </chapter>
56.148 +out: <chapter>
56.149 +out: <title lang="en">title3</title>
56.150 +out: </chapter>
56.151 +out: <chapter>
56.152 +out: <title lang="en">title4</title>
56.153 +out: </chapter>
56.154 +out: <chapter>
56.155 +out: <title lang="en">title5</title>
56.156 +out: </chapter>
56.157 +out: <paperback/>
56.158 +out: <summary>Summary of the book</summary>
56.159 +out: <isbn>120394857</isbn>
56.160 +out: <price>19.99</price>
56.161 +out: </book>
56.162 +out: TestValid - Should add ending at the end of the chapter:
56.163 +out: <?xml version="1.0" encoding="UTF-8"?>
56.164 +out: <!DOCTYPE book>
56.165 +out: <book instock="yes">
56.166 +out: <title lang="en">Title of the book</title>
56.167 +out: <chapter>
56.168 +out: <title lang="en">The sand castle</title>
56.169 +out: <paragraph>
56.170 +out: Once upon a time, on a far sunny island, ...
56.171 +out: </paragraph>
56.172 +out: </chapter>
56.173 +out: <chapter>
56.174 +out: <title lang="en">title1</title>
56.175 +out: </chapter>
56.176 +out: <chapter>
56.177 +out: <title lang="en">title2</title>
56.178 +out: <ending>And this is how this chapter ends.</ending>
56.179 +out: </chapter>
56.180 +out: <chapter>
56.181 +out: <title lang="en">title3</title>
56.182 +out: </chapter>
56.183 +out: <chapter>
56.184 +out: <title lang="en">title4</title>
56.185 +out: </chapter>
56.186 +out: <chapter>
56.187 +out: <title lang="en">title5</title>
56.188 +out: </chapter>
56.189 +out: <paperback/>
56.190 +out: <summary>Summary of the book</summary>
56.191 +out: <isbn>120394857</isbn>
56.192 +out: <price>19.99</price>
56.193 +out: </book>
56.194 +out: TestValid - Should add conclusion before the ending
56.195 +out: <?xml version="1.0" encoding="UTF-8"?>
56.196 +out: <!DOCTYPE book>
56.197 +out: <book instock="yes">
56.198 +out: <title lang="en">Title of the book</title>
56.199 +out: <chapter>
56.200 +out: <title lang="en">The sand castle</title>
56.201 +out: <paragraph>
56.202 +out: Once upon a time, on a far sunny island, ...
56.203 +out: </paragraph>
56.204 +out: </chapter>
56.205 +out: <chapter>
56.206 +out: <title lang="en">title1</title>
56.207 +out: </chapter>
56.208 +out: <chapter>
56.209 +out: <title lang="en">title2</title>
56.210 +out: <conclusion>And this concludes this chapter.</conclusion>
56.211 +out: <ending>And this is how this chapter ends.</ending>
56.212 +out: </chapter>
56.213 +out: <chapter>
56.214 +out: <title lang="en">title3</title>
56.215 +out: </chapter>
56.216 +out: <chapter>
56.217 +out: <title lang="en">title4</title>
56.218 +out: </chapter>
56.219 +out: <chapter>
56.220 +out: <title lang="en">title5</title>
56.221 +out: </chapter>
56.222 +out: <paperback/>
56.223 +out: <summary>Summary of the book</summary>
56.224 +out: <isbn>120394857</isbn>
56.225 +out: <price>19.99</price>
56.226 +out: </book>
56.227 +out: TestValid - Should add Note with year before copyright
56.228 +out: <?xml version="1.0" encoding="UTF-8"?>
56.229 +out: <!DOCTYPE book>
56.230 +out: <book instock="yes">
56.231 +out: <title lang="en">Title of the book</title>
56.232 +out: <chapter>
56.233 +out: <title lang="en">The sand castle</title>
56.234 +out: <paragraph>
56.235 +out: Once upon a time, on a far sunny island, ...
56.236 +out: </paragraph>
56.237 +out: </chapter>
56.238 +out: <chapter>
56.239 +out: <title lang="en">title1</title>
56.240 +out: </chapter>
56.241 +out: <chapter>
56.242 +out: <title lang="en">title2</title>
56.243 +out: <conclusion>And this concludes this chapter.</conclusion>
56.244 +out: <ending>And this is how this chapter ends.</ending>
56.245 +out: </chapter>
56.246 +out: <chapter>
56.247 +out: <title lang="en">title3</title>
56.248 +out: </chapter>
56.249 +out: <chapter>
56.250 +out: <title lang="en">title4</title>
56.251 +out: </chapter>
56.252 +out: <chapter>
56.253 +out: <title lang="en">title5</title>
56.254 +out: </chapter>
56.255 +out: <note>
56.256 +out: <year>2000</year>
56.257 +out: <copyright>1997</copyright>
56.258 +out: </note>
56.259 +out: <paperback/>
56.260 +out: <summary>Summary of the book</summary>
56.261 +out: <isbn>120394857</isbn>
56.262 +out: <price>19.99</price>
56.263 +out: </book>
56.264 +out: TestValid - Should set Note with date before copyright
56.265 +out: <?xml version="1.0" encoding="UTF-8"?>
56.266 +out: <!DOCTYPE book>
56.267 +out: <book instock="yes">
56.268 +out: <title lang="en">Title of the book</title>
56.269 +out: <chapter>
56.270 +out: <title lang="en">The sand castle</title>
56.271 +out: <paragraph>
56.272 +out: Once upon a time, on a far sunny island, ...
56.273 +out: </paragraph>
56.274 +out: </chapter>
56.275 +out: <chapter>
56.276 +out: <title lang="en">title1</title>
56.277 +out: </chapter>
56.278 +out: <chapter>
56.279 +out: <title lang="en">title2</title>
56.280 +out: <conclusion>And this concludes this chapter.</conclusion>
56.281 +out: <ending>And this is how this chapter ends.</ending>
56.282 +out: </chapter>
56.283 +out: <chapter>
56.284 +out: <title lang="en">title3</title>
56.285 +out: </chapter>
56.286 +out: <chapter>
56.287 +out: <title lang="en">title4</title>
56.288 +out: </chapter>
56.289 +out: <chapter>
56.290 +out: <title lang="en">title5</title>
56.291 +out: </chapter>
56.292 +out: <note>
56.293 +out: <date>2001</date>
56.294 +out: <copyright>1996</copyright>
56.295 +out: </note>
56.296 +out: <paperback/>
56.297 +out: <summary>Summary of the book</summary>
56.298 +out: <isbn>120394857</isbn>
56.299 +out: <price>19.99</price>
56.300 +out: </book>
56.301 +Finished running TestValid: 0
57.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
57.2 +++ b/schema2beans/test/unit/src/data/goldenfiles/TestMain/testVeto.pass Wed Jun 19 00:18:25 2002 +0000
57.3 @@ -0,0 +1,72 @@
57.4 +Calling GenBeans.doIt
57.5 +Compiling
57.6 +Finished compiling: 0
57.7 +out: TestVeto - creating the DOM document
57.8 +out: TestVeto - creating the bean graph
57.9 +out: TestVeto - bean graph created
57.10 +out: TestVeto - new listener for Book listener / Book
57.11 +out: TestVeto - Book listener received veto event:
57.12 +out: TestVeto - <Lnr:Book Evt:/Book/Summary Src:book.Book>
57.13 +out: TestVeto - <Summary[-1] - Parent: Book/book.Book>
57.14 +out: TestVeto simple change event on the root - no veto (old value) -> OK
57.15 +out: TestVeto simple change event on the root - no veto (new value) -> OK
57.16 +out: TestVeto simple change event on the root - no veto (new value) -> OK
57.17 +out: TestVeto - Book listener received veto event:
57.18 +out: TestVeto - <Lnr:Book Evt:/Book/Summary Src:book.Book>
57.19 +out: TestVeto - <Summary[-1] - Parent: Book/book.Book>
57.20 +out: TestVeto - Listener: raising PropertyVetoException
57.21 +out: TestVeto - Book listener received an undo event:
57.22 +out: TestVeto - <Lnr:Book Evt:/Book/Summary Src:book.Book>
57.23 +out: TestVeto - <Summary[-1] - Parent: Book/book.Book>
57.24 +out: TestVeto simple change event on the root - veto (got exception & same value) -> OK
57.25 +out: TestVeto Try to listen for a non vetoable property got exception:
57.26 +out: The property "Reviews" has not been generated to support vetoable exceptions. -> OK
57.27 +out: TestVeto - Book listener received veto event:
57.28 +out: TestVeto - <Lnr:Book Evt:/Book/Author.-1 Src:book.Book>
57.29 +out: TestVeto - <Author[-1] - Parent: Book/book.Book>
57.30 +out: TestVeto - oldValues.length = 0
57.31 +out: TestVeto - newValues[0]=Author1
57.32 +out: TestVeto - newValues[1]=Author2
57.33 +out: TestVeto - newValues[2]=Author3
57.34 +out: TestVeto - Book listener received veto event:
57.35 +out: TestVeto - <Lnr:Book Evt:/Book/Author.-1 Src:book.Book>
57.36 +out: TestVeto - <Author[-1] - Parent: Book/book.Book>
57.37 +out: TestVeto - oldValues[0]=Author1
57.38 +out: TestVeto - oldValues[1]=Author2
57.39 +out: TestVeto - oldValues[2]=Author3
57.40 +out: TestVeto - newValues[0]=Author1_new
57.41 +out: TestVeto - newValues[1]=Author2_new
57.42 +out: TestVeto - Listener: raising PropertyVetoException
57.43 +out: TestVeto - Book listener received an undo event:
57.44 +out: TestVeto - <Lnr:Book Evt:/Book/Author.-1 Src:book.Book>
57.45 +out: TestVeto - <Author[-1] - Parent: Book/book.Book>
57.46 +out: TestVeto - oldValues[0]=Author1_new
57.47 +out: TestVeto - oldValues[1]=Author2_new
57.48 +out: TestVeto - newValues[0]=Author1
57.49 +out: TestVeto - newValues[1]=Author2
57.50 +out: TestVeto - newValues[2]=Author3
57.51 +out: TestVeto Indexed final property (got exception) -> OK
57.52 +out: TestVeto - getAuthor()[0]=Author1
57.53 +out: TestVeto - getAuthor()[1]=Author2
57.54 +out: TestVeto - getAuthor()[2]=Author3
57.55 +out: TestVeto - new listener for Author listener / Book
57.56 +out: TestVeto - Author listener received veto event:
57.57 +out: TestVeto - <Lnr:Book Evt:/Book/Author.-1 Src:book.Book>
57.58 +out: TestVeto - <Author[-1] - Parent: Book/book.Book>
57.59 +out: TestVeto - Book listener received veto event:
57.60 +out: TestVeto - <Lnr:Book Evt:/Book/Author.-1 Src:book.Book>
57.61 +out: TestVeto - <Author[-1] - Parent: Book/book.Book>
57.62 +out: TestVeto - getAuthor()[0]=re-Author1_new
57.63 +out: TestVeto - getAuthor()[1]=re-Author2_new
57.64 +out: TestVeto - Author listener received veto event:
57.65 +out: TestVeto - <Lnr:Book Evt:/Book/Author.-1 Src:book.Book>
57.66 +out: TestVeto - <Author[-1] - Parent: Book/book.Book>
57.67 +out: TestVeto - Book listener received veto event:
57.68 +out: TestVeto - <Lnr:Book Evt:/Book/Author.-1 Src:book.Book>
57.69 +out: TestVeto - <Author[-1] - Parent: Book/book.Book>
57.70 +out: TestVeto - Listener: raising PropertyVetoException
57.71 +out: TestVeto - Book listener received an undo event:
57.72 +out: TestVeto - <Lnr:Book Evt:/Book/Author.-1 Src:book.Book>
57.73 +out: TestVeto - <Author[-1] - Parent: Book/book.Book>
57.74 +out: TestVeto Set a second listener to get two events (got exception) -> OK
57.75 +Finished running TestVeto: 0
58.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
58.2 +++ b/schema2beans/test/unit/src/data/greeting.pass Wed Jun 19 00:18:25 2002 +0000
58.3 @@ -0,0 +1,1 @@
58.4 +a Hello world!
58.5 \ No newline at end of file
59.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
59.2 +++ b/schema2beans/test/unit/src/data/tm01_g1.xml Wed Jun 19 00:18:25 2002 +0000
59.3 @@ -0,0 +1,76 @@
59.4 +<?xml version="1.0" encoding="ISO-8859-1"?>
59.5 +
59.6 +<book>
59.7 + <author>
59.8 + John Smith
59.9 + </author>
59.10 + <author>
59.11 + Mikey Mouse
59.12 + </author>
59.13 + <chapter>
59.14 + <paragraph>
59.15 + Once upon a time...
59.16 + </paragraph>
59.17 + <paragraph>
59.18 + And this is how the book met the fairy, and how all this
59.19 + story began.
59.20 + </paragraph>
59.21 + <comment>
59.22 + First chapter.
59.23 + </comment>
59.24 + </chapter>
59.25 + <chapter>
59.26 + <paragraph>
59.27 + And the book lived a never ending happy life, read, copied
59.28 + and enjoyed by so many readers.
59.29 + </paragraph>
59.30 + </chapter>
59.31 + <index>
59.32 + <ref>
59.33 + <line>
59.34 + 12
59.35 + </line>
59.36 + <page>
59.37 + 22
59.38 + </page>
59.39 + </ref>
59.40 + <word>
59.41 + Good book
59.42 + </word>
59.43 + </index>
59.44 + <author>
59.45 + Donald Duck
59.46 + </author>
59.47 + <chapter>
59.48 + <comment>
59.49 + Empty chapter
59.50 + </comment>
59.51 + </chapter>
59.52 + <good/>
59.53 + <index>
59.54 + <ref>
59.55 + <page>
59.56 + 5
59.57 + </page>
59.58 + <line>
59.59 + 15
59.60 + </line>
59.61 + </ref>
59.62 + <word>
59.63 + E-Tool
59.64 + </word>
59.65 + <ref>
59.66 + <page>
59.67 + 29
59.68 + </page>
59.69 + <line>
59.70 + 31
59.71 + </line>
59.72 + </ref>
59.73 + </index>
59.74 + <summary size="12">
59.75 + This book is about the life of a book spent between books who dreamed
59.76 + to meet a fairy who could transform it into an XML book and travel
59.77 + in an electronic boundary-less world.
59.78 + </summary>
59.79 +</book>
60.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
60.2 +++ b/schema2beans/test/unit/src/data/tm01_g2.xml Wed Jun 19 00:18:25 2002 +0000
60.3 @@ -0,0 +1,76 @@
60.4 +<?xml version="1.0" encoding="ISO-8859-1"?>
60.5 +
60.6 +<book>
60.7 + <summary size="12">
60.8 + This book is about the life of a book spent between books who dreamed
60.9 + to meet a fairy who could transform it into an XML book and travel
60.10 + in an electronic boundary-less world.
60.11 + </summary>
60.12 + <author>
60.13 + John Smith
60.14 + </author>
60.15 + <author>
60.16 + Donald Duck
60.17 + </author>
60.18 + <author>
60.19 + Mikey Mouse
60.20 + </author>
60.21 + <chapter>
60.22 + <paragraph>
60.23 + And the book lived a never ending happy life, read, copied
60.24 + and enjoyed by so many readers.
60.25 + </paragraph>
60.26 + </chapter>
60.27 + <chapter>
60.28 + <comment>
60.29 + First chapter.
60.30 + </comment>
60.31 + <paragraph>
60.32 + Once upon a time...
60.33 + </paragraph>
60.34 + <paragraph>
60.35 + And this is how the book met the fairy, and how all this
60.36 + story began.
60.37 + </paragraph>
60.38 + </chapter>
60.39 + <chapter>
60.40 + <comment>
60.41 + Empty chapter
60.42 + </comment>
60.43 + </chapter>
60.44 + <index>
60.45 + <word>
60.46 + Good book
60.47 + </word>
60.48 + <ref>
60.49 + <page>
60.50 + 22
60.51 + </page>
60.52 + <line>
60.53 + 12
60.54 + </line>
60.55 + </ref>
60.56 + </index>
60.57 + <index>
60.58 + <word>
60.59 + E-Tool
60.60 + </word>
60.61 + <ref>
60.62 + <page>
60.63 + 5
60.64 + </page>
60.65 + <line>
60.66 + 15
60.67 + </line>
60.68 + </ref>
60.69 + <ref>
60.70 + <page>
60.71 + 29
60.72 + </page>
60.73 + <line>
60.74 + 31
60.75 + </line>
60.76 + </ref>
60.77 + </index>
60.78 + <good/>
60.79 +</book>
61.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
61.2 +++ b/schema2beans/test/unit/src/data/tm01_g3.xml Wed Jun 19 00:18:25 2002 +0000
61.3 @@ -0,0 +1,76 @@
61.4 +<?xml version="1.0" encoding="ISO-8859-1"?>
61.5 +
61.6 +<book good="no">
61.7 + <summary length="123" lang="us" size="12">
61.8 + This book is about the life of a book spent between books who dreamed
61.9 + to meet a fairy who could transform it into an XML book and travel
61.10 + in an electronic boundary-less world.
61.11 + </summary>
61.12 + <author>
61.13 + John Smith
61.14 + </author>
61.15 + <author>
61.16 + Donald Duck
61.17 + </author>
61.18 + <author>
61.19 + Mikey Mouse
61.20 + </author>
61.21 + <chapter title="First">
61.22 + <paragraph>
61.23 + And the book lived a never ending happy life, read, copied
61.24 + and enjoyed by so many readers.
61.25 + </paragraph>
61.26 + </chapter>
61.27 + <chapter title="Second">
61.28 + <comment>
61.29 + First chapter.
61.30 + </comment>
61.31 + <paragraph>
61.32 + Once upon a time...
61.33 + </paragraph>
61.34 + <paragraph>
61.35 + And this is how the book met the fairy, and how all this
61.36 + story began.
61.37 + </paragraph>
61.38 + </chapter>
61.39 + <chapter>
61.40 + <comment>
61.41 + Empty chapter
61.42 + </comment>
61.43 + </chapter>
61.44 + <index cross-ref="no" color="blue">
61.45 + <word>
61.46 + Good book
61.47 + </word>
61.48 + <ref>
61.49 + <page>
61.50 + 22
61.51 + </page>
61.52 + <line>
61.53 + 12
61.54 + </line>
61.55 + </ref>
61.56 + </index>
61.57 + <index>
61.58 + <word>
61.59 + E-Tool
61.60 + </word>
61.61 + <ref>
61.62 + <page>
61.63 + 5
61.64 + </page>
61.65 + <line>
61.66 + 15
61.67 + </line>
61.68 + </ref>
61.69 + <ref>
61.70 + <page>
61.71 + 29
61.72 + </page>
61.73 + <line>
61.74 + 31
61.75 + </line>
61.76 + </ref>
61.77 + </index>
61.78 + <good/>
61.79 +</book>
62.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
62.2 +++ b/schema2beans/test/unit/src/data/tm01_g4.xml Wed Jun 19 00:18:25 2002 +0000
62.3 @@ -0,0 +1,79 @@
62.4 +<?xml version="1.0" encoding="ISO-8859-1"?>
62.5 +
62.6 +<book good="no">
62.7 + <!-- BLUE -->
62.8 + <summary length="123" lang="us" size="12">
62.9 + This book is about the life of a book spent between books who dreamed
62.10 + to meet a fairy who could transform it into an XML book and travel
62.11 + in an electronic boundary-less world.
62.12 + </summary>
62.13 + <author>
62.14 + John Smith
62.15 + </author>
62.16 + <author>
62.17 + Donald Duck
62.18 + </author>
62.19 + <author>
62.20 + Mikey Mouse
62.21 + </author>
62.22 + <chapter title="First">
62.23 + <paragraph>
62.24 + And the book lived a never ending happy life, read, copied
62.25 + and enjoyed by so many readers.
62.26 + </paragraph>
62.27 + </chapter>
62.28 + <chapter title="Second">
62.29 + <comment>
62.30 + First chapter.
62.31 + </comment>
62.32 + <paragraph>
62.33 + Once upon a time...
62.34 + </paragraph>
62.35 + <paragraph>
62.36 + And this is how the book met the fairy, and how all this
62.37 + story began.
62.38 + </paragraph>
62.39 + </chapter>
62.40 + <chapter>
62.41 + <comment>
62.42 + Empty chapter
62.43 + </comment>
62.44 + </chapter>
62.45 + <index cross-ref="no" color="blue">
62.46 + <word>
62.47 + Good book
62.48 + </word>
62.49 + <ref>
62.50 + <page>
62.51 + 22
62.52 + </page>
62.53 + <line>
62.54 + 12
62.55 + </line>
62.56 + </ref>
62.57 + </index>
62.58 + <index>
62.59 + <!--RED-->
62.60 + <word>
62.61 + E-Tool
62.62 + </word>
62.63 + <ref>
62.64 + <page>
62.65 + 5
62.66 + </page>
62.67 + <line>
62.68 + 15
62.69 + </line>
62.70 + </ref>
62.71 + <ref>
62.72 + <page>
62.73 + 29
62.74 + </page>
62.75 + <line>
62.76 + 31
62.77 + </line>
62.78 + </ref>
62.79 + </index>
62.80 + <good/>
62.81 + <!-- GREEN -->
62.82 +</book>