1.1 --- a/samples/exceptions/build.xml Sun Feb 01 16:27:41 2009 +0100
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,69 +0,0 @@
1.4 -<?xml version="1.0" encoding="UTF-8"?>
1.5 -<!-- You may freely edit this file. See commented blocks below for -->
1.6 -<!-- some examples of how to customize the build. -->
1.7 -<!-- (If you delete it and reopen the project it will be recreated.) -->
1.8 -<project name="exceptions" default="default" basedir=".">
1.9 - <description>Builds, tests, and runs the project exceptions.</description>
1.10 - <import file="nbproject/build-impl.xml"/>
1.11 - <!--
1.12 -
1.13 - There exist several targets which are by default empty and which can be
1.14 - used for execution of your tasks. These targets are usually executed
1.15 - before and after some main targets. They are:
1.16 -
1.17 - -pre-init: called before initialization of project properties
1.18 - -post-init: called after initialization of project properties
1.19 - -pre-compile: called before javac compilation
1.20 - -post-compile: called after javac compilation
1.21 - -pre-compile-single: called before javac compilation of single file
1.22 - -post-compile-single: called after javac compilation of single file
1.23 - -pre-compile-test: called before javac compilation of JUnit tests
1.24 - -post-compile-test: called after javac compilation of JUnit tests
1.25 - -pre-compile-test-single: called before javac compilation of single JUnit test
1.26 - -post-compile-test-single: called after javac compilation of single JUunit test
1.27 - -pre-jar: called before JAR building
1.28 - -post-jar: called after JAR building
1.29 - -post-clean: called after cleaning build products
1.30 -
1.31 - (Targets beginning with '-' are not intended to be called on their own.)
1.32 -
1.33 - Example of inserting an obfuscator after compilation could look like this:
1.34 -
1.35 - <target name="-post-compile">
1.36 - <obfuscate>
1.37 - <fileset dir="${build.classes.dir}"/>
1.38 - </obfuscate>
1.39 - </target>
1.40 -
1.41 - For list of available properties check the imported
1.42 - nbproject/build-impl.xml file.
1.43 -
1.44 -
1.45 - Another way to customize the build is by overriding existing main targets.
1.46 - The targets of interest are:
1.47 -
1.48 - -init-macrodef-javac: defines macro for javac compilation
1.49 - -init-macrodef-junit: defines macro for junit execution
1.50 - -init-macrodef-debug: defines macro for class debugging
1.51 - -init-macrodef-java: defines macro for class execution
1.52 - -do-jar-with-manifest: JAR building (if you are using a manifest)
1.53 - -do-jar-without-manifest: JAR building (if you are not using a manifest)
1.54 - run: execution of project
1.55 - -javadoc-build: Javadoc generation
1.56 - test-report: JUnit report generation
1.57 -
1.58 - An example of overriding the target for project execution could look like this:
1.59 -
1.60 - <target name="run" depends="exceptions-impl.jar">
1.61 - <exec dir="bin" executable="launcher.exe">
1.62 - <arg file="${dist.jar}"/>
1.63 - </exec>
1.64 - </target>
1.65 -
1.66 - Notice that the overridden target depends on the jar target and not only on
1.67 - the compile target as the regular run target does. Again, for a list of available
1.68 - properties which you can use, check the target you are overriding in the
1.69 - nbproject/build-impl.xml file.
1.70 -
1.71 - -->
1.72 -</project>
2.1 --- a/samples/exceptions/nbproject/build-impl.xml Sun Feb 01 16:27:41 2009 +0100
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,627 +0,0 @@
2.4 -<?xml version="1.0" encoding="UTF-8"?>
2.5 -<!--
2.6 -*** GENERATED FROM project.xml - DO NOT EDIT ***
2.7 -*** EDIT ../build.xml INSTEAD ***
2.8 -
2.9 -For the purpose of easier reading the script
2.10 -is divided into following sections:
2.11 -
2.12 - - initialization
2.13 - - compilation
2.14 - - jar
2.15 - - execution
2.16 - - debugging
2.17 - - javadoc
2.18 - - junit compilation
2.19 - - junit execution
2.20 - - junit debugging
2.21 - - applet
2.22 - - cleanup
2.23 -
2.24 - -->
2.25 -<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="exceptions-impl">
2.26 - <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
2.27 - <!--
2.28 - ======================
2.29 - INITIALIZATION SECTION
2.30 - ======================
2.31 - -->
2.32 - <target name="-pre-init">
2.33 - <!-- Empty placeholder for easier customization. -->
2.34 - <!-- You can override this target in the ../build.xml file. -->
2.35 - </target>
2.36 - <target depends="-pre-init" name="-init-private">
2.37 - <property file="nbproject/private/config.properties"/>
2.38 - <property file="nbproject/private/configs/${config}.properties"/>
2.39 - <property file="nbproject/private/private.properties"/>
2.40 - </target>
2.41 - <target depends="-pre-init,-init-private" name="-init-user">
2.42 - <property file="${user.properties.file}"/>
2.43 - <!-- The two properties below are usually overridden -->
2.44 - <!-- by the active platform. Just a fallback. -->
2.45 - <property name="default.javac.source" value="1.4"/>
2.46 - <property name="default.javac.target" value="1.4"/>
2.47 - </target>
2.48 - <target depends="-pre-init,-init-private,-init-user" name="-init-project">
2.49 - <property file="nbproject/configs/${config}.properties"/>
2.50 - <property file="nbproject/project.properties"/>
2.51 - </target>
2.52 - <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
2.53 - <available file="${manifest.file}" property="manifest.available"/>
2.54 - <condition property="manifest.available+main.class">
2.55 - <and>
2.56 - <isset property="manifest.available"/>
2.57 - <isset property="main.class"/>
2.58 - <not>
2.59 - <equals arg1="${main.class}" arg2="" trim="true"/>
2.60 - </not>
2.61 - </and>
2.62 - </condition>
2.63 - <condition property="manifest.available+main.class+mkdist.available">
2.64 - <and>
2.65 - <istrue value="${manifest.available+main.class}"/>
2.66 - <isset property="libs.CopyLibs.classpath"/>
2.67 - </and>
2.68 - </condition>
2.69 - <condition property="have.tests">
2.70 - <or>
2.71 - <available file="${test.src.dir}"/>
2.72 - </or>
2.73 - </condition>
2.74 - <condition property="have.sources">
2.75 - <or>
2.76 - <available file="${src.dir}"/>
2.77 - </or>
2.78 - </condition>
2.79 - <condition property="netbeans.home+have.tests">
2.80 - <and>
2.81 - <isset property="netbeans.home"/>
2.82 - <isset property="have.tests"/>
2.83 - </and>
2.84 - </condition>
2.85 - <condition property="no.javadoc.preview">
2.86 - <and>
2.87 - <isset property="javadoc.preview"/>
2.88 - <isfalse value="${javadoc.preview}"/>
2.89 - </and>
2.90 - </condition>
2.91 - <property name="run.jvmargs" value=""/>
2.92 - <property name="javac.compilerargs" value=""/>
2.93 - <property name="work.dir" value="${basedir}"/>
2.94 - <condition property="no.deps">
2.95 - <and>
2.96 - <istrue value="${no.dependencies}"/>
2.97 - </and>
2.98 - </condition>
2.99 - <property name="javac.debug" value="true"/>
2.100 - <property name="javadoc.preview" value="true"/>
2.101 - <property name="application.args" value=""/>
2.102 - <property name="source.encoding" value="${file.encoding}"/>
2.103 - <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
2.104 - <and>
2.105 - <isset property="javadoc.encoding"/>
2.106 - <not>
2.107 - <equals arg1="${javadoc.encoding}" arg2=""/>
2.108 - </not>
2.109 - </and>
2.110 - </condition>
2.111 - <property name="javadoc.encoding.used" value="${source.encoding}"/>
2.112 - <property name="includes" value="**"/>
2.113 - <property name="excludes" value=""/>
2.114 - <property name="do.depend" value="false"/>
2.115 - <condition property="do.depend.true">
2.116 - <istrue value="${do.depend}"/>
2.117 - </condition>
2.118 - <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
2.119 - <and>
2.120 - <isset property="jaxws.endorsed.dir"/>
2.121 - <available file="nbproject/jaxws-build.xml"/>
2.122 - </and>
2.123 - </condition>
2.124 - </target>
2.125 - <target name="-post-init">
2.126 - <!-- Empty placeholder for easier customization. -->
2.127 - <!-- You can override this target in the ../build.xml file. -->
2.128 - </target>
2.129 - <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
2.130 - <fail unless="src.dir">Must set src.dir</fail>
2.131 - <fail unless="test.src.dir">Must set test.src.dir</fail>
2.132 - <fail unless="build.dir">Must set build.dir</fail>
2.133 - <fail unless="dist.dir">Must set dist.dir</fail>
2.134 - <fail unless="build.classes.dir">Must set build.classes.dir</fail>
2.135 - <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
2.136 - <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
2.137 - <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
2.138 - <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
2.139 - <fail unless="dist.jar">Must set dist.jar</fail>
2.140 - </target>
2.141 - <target name="-init-macrodef-property">
2.142 - <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
2.143 - <attribute name="name"/>
2.144 - <attribute name="value"/>
2.145 - <sequential>
2.146 - <property name="@{name}" value="${@{value}}"/>
2.147 - </sequential>
2.148 - </macrodef>
2.149 - </target>
2.150 - <target name="-init-macrodef-javac">
2.151 - <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
2.152 - <attribute default="${src.dir}" name="srcdir"/>
2.153 - <attribute default="${build.classes.dir}" name="destdir"/>
2.154 - <attribute default="${javac.classpath}" name="classpath"/>
2.155 - <attribute default="${includes}" name="includes"/>
2.156 - <attribute default="${excludes}" name="excludes"/>
2.157 - <attribute default="${javac.debug}" name="debug"/>
2.158 - <attribute default="" name="sourcepath"/>
2.159 - <element name="customize" optional="true"/>
2.160 - <sequential>
2.161 - <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}">
2.162 - <classpath>
2.163 - <path path="@{classpath}"/>
2.164 - </classpath>
2.165 - <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
2.166 - <customize/>
2.167 - </javac>
2.168 - </sequential>
2.169 - </macrodef>
2.170 - <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
2.171 - <attribute default="${src.dir}" name="srcdir"/>
2.172 - <attribute default="${build.classes.dir}" name="destdir"/>
2.173 - <attribute default="${javac.classpath}" name="classpath"/>
2.174 - <sequential>
2.175 - <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
2.176 - <classpath>
2.177 - <path path="@{classpath}"/>
2.178 - </classpath>
2.179 - </depend>
2.180 - </sequential>
2.181 - </macrodef>
2.182 - <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
2.183 - <attribute default="${build.classes.dir}" name="destdir"/>
2.184 - <sequential>
2.185 - <fail unless="javac.includes">Must set javac.includes</fail>
2.186 - <pathconvert pathsep="," property="javac.includes.binary">
2.187 - <path>
2.188 - <filelist dir="@{destdir}" files="${javac.includes}"/>
2.189 - </path>
2.190 - <globmapper from="*.java" to="*.class"/>
2.191 - </pathconvert>
2.192 - <delete>
2.193 - <files includes="${javac.includes.binary}"/>
2.194 - </delete>
2.195 - </sequential>
2.196 - </macrodef>
2.197 - </target>
2.198 - <target name="-init-macrodef-junit">
2.199 - <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
2.200 - <attribute default="${includes}" name="includes"/>
2.201 - <attribute default="${excludes}" name="excludes"/>
2.202 - <attribute default="**" name="testincludes"/>
2.203 - <sequential>
2.204 - <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
2.205 - <batchtest todir="${build.test.results.dir}">
2.206 - <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
2.207 - <filename name="@{testincludes}"/>
2.208 - </fileset>
2.209 - </batchtest>
2.210 - <classpath>
2.211 - <path path="${run.test.classpath}"/>
2.212 - </classpath>
2.213 - <syspropertyset>
2.214 - <propertyref prefix="test-sys-prop."/>
2.215 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
2.216 - </syspropertyset>
2.217 - <formatter type="brief" usefile="false"/>
2.218 - <formatter type="xml"/>
2.219 - <jvmarg line="${run.jvmargs}"/>
2.220 - </junit>
2.221 - </sequential>
2.222 - </macrodef>
2.223 - </target>
2.224 - <target name="-init-macrodef-nbjpda">
2.225 - <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
2.226 - <attribute default="${main.class}" name="name"/>
2.227 - <attribute default="${debug.classpath}" name="classpath"/>
2.228 - <attribute default="" name="stopclassname"/>
2.229 - <sequential>
2.230 - <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="dt_socket">
2.231 - <classpath>
2.232 - <path path="@{classpath}"/>
2.233 - </classpath>
2.234 - </nbjpdastart>
2.235 - </sequential>
2.236 - </macrodef>
2.237 - <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
2.238 - <attribute default="${build.classes.dir}" name="dir"/>
2.239 - <sequential>
2.240 - <nbjpdareload>
2.241 - <fileset dir="@{dir}" includes="${fix.includes}*.class"/>
2.242 - </nbjpdareload>
2.243 - </sequential>
2.244 - </macrodef>
2.245 - </target>
2.246 - <target name="-init-debug-args">
2.247 - <property name="version-output" value="java version "${ant.java.version}"/>
2.248 - <condition property="have-jdk-older-than-1.4">
2.249 - <or>
2.250 - <contains string="${version-output}" substring="java version "1.0"/>
2.251 - <contains string="${version-output}" substring="java version "1.1"/>
2.252 - <contains string="${version-output}" substring="java version "1.2"/>
2.253 - <contains string="${version-output}" substring="java version "1.3"/>
2.254 - </or>
2.255 - </condition>
2.256 - <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
2.257 - <istrue value="${have-jdk-older-than-1.4}"/>
2.258 - </condition>
2.259 - </target>
2.260 - <target depends="-init-debug-args" name="-init-macrodef-debug">
2.261 - <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
2.262 - <attribute default="${main.class}" name="classname"/>
2.263 - <attribute default="${debug.classpath}" name="classpath"/>
2.264 - <element name="customize" optional="true"/>
2.265 - <sequential>
2.266 - <java classname="@{classname}" dir="${work.dir}" fork="true">
2.267 - <jvmarg line="${debug-args-line}"/>
2.268 - <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
2.269 - <jvmarg line="${run.jvmargs}"/>
2.270 - <classpath>
2.271 - <path path="@{classpath}"/>
2.272 - </classpath>
2.273 - <syspropertyset>
2.274 - <propertyref prefix="run-sys-prop."/>
2.275 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
2.276 - </syspropertyset>
2.277 - <customize/>
2.278 - </java>
2.279 - </sequential>
2.280 - </macrodef>
2.281 - </target>
2.282 - <target name="-init-macrodef-java">
2.283 - <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
2.284 - <attribute default="${main.class}" name="classname"/>
2.285 - <element name="customize" optional="true"/>
2.286 - <sequential>
2.287 - <java classname="@{classname}" dir="${work.dir}" fork="true">
2.288 - <jvmarg line="${run.jvmargs}"/>
2.289 - <classpath>
2.290 - <path path="${run.classpath}"/>
2.291 - </classpath>
2.292 - <syspropertyset>
2.293 - <propertyref prefix="run-sys-prop."/>
2.294 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
2.295 - </syspropertyset>
2.296 - <customize/>
2.297 - </java>
2.298 - </sequential>
2.299 - </macrodef>
2.300 - </target>
2.301 - <target name="-init-presetdef-jar">
2.302 - <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
2.303 - <jar compress="${jar.compress}" jarfile="${dist.jar}">
2.304 - <j2seproject1:fileset dir="${build.classes.dir}"/>
2.305 - </jar>
2.306 - </presetdef>
2.307 - </target>
2.308 - <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar" name="init"/>
2.309 - <!--
2.310 - ===================
2.311 - COMPILATION SECTION
2.312 - ===================
2.313 - -->
2.314 - <target depends="init" name="deps-jar" unless="no.deps"/>
2.315 - <target depends="init,deps-jar" name="-pre-pre-compile">
2.316 - <mkdir dir="${build.classes.dir}"/>
2.317 - </target>
2.318 - <target name="-pre-compile">
2.319 - <!-- Empty placeholder for easier customization. -->
2.320 - <!-- You can override this target in the ../build.xml file. -->
2.321 - </target>
2.322 - <target if="do.depend.true" name="-compile-depend">
2.323 - <j2seproject3:depend/>
2.324 - </target>
2.325 - <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
2.326 - <j2seproject3:javac/>
2.327 - <copy todir="${build.classes.dir}">
2.328 - <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
2.329 - </copy>
2.330 - </target>
2.331 - <target name="-post-compile">
2.332 - <!-- Empty placeholder for easier customization. -->
2.333 - <!-- You can override this target in the ../build.xml file. -->
2.334 - </target>
2.335 - <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
2.336 - <target name="-pre-compile-single">
2.337 - <!-- Empty placeholder for easier customization. -->
2.338 - <!-- You can override this target in the ../build.xml file. -->
2.339 - </target>
2.340 - <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
2.341 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
2.342 - <j2seproject3:force-recompile/>
2.343 - <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
2.344 - </target>
2.345 - <target name="-post-compile-single">
2.346 - <!-- Empty placeholder for easier customization. -->
2.347 - <!-- You can override this target in the ../build.xml file. -->
2.348 - </target>
2.349 - <target depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
2.350 - <!--
2.351 - ====================
2.352 - JAR BUILDING SECTION
2.353 - ====================
2.354 - -->
2.355 - <target depends="init" name="-pre-pre-jar">
2.356 - <dirname file="${dist.jar}" property="dist.jar.dir"/>
2.357 - <mkdir dir="${dist.jar.dir}"/>
2.358 - </target>
2.359 - <target name="-pre-jar">
2.360 - <!-- Empty placeholder for easier customization. -->
2.361 - <!-- You can override this target in the ../build.xml file. -->
2.362 - </target>
2.363 - <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
2.364 - <j2seproject1:jar/>
2.365 - </target>
2.366 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
2.367 - <j2seproject1:jar manifest="${manifest.file}"/>
2.368 - </target>
2.369 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
2.370 - <j2seproject1:jar manifest="${manifest.file}">
2.371 - <j2seproject1:manifest>
2.372 - <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
2.373 - </j2seproject1:manifest>
2.374 - </j2seproject1:jar>
2.375 - <echo>To run this application from the command line without Ant, try:</echo>
2.376 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
2.377 - <property location="${dist.jar}" name="dist.jar.resolved"/>
2.378 - <pathconvert property="run.classpath.with.dist.jar">
2.379 - <path path="${run.classpath}"/>
2.380 - <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
2.381 - </pathconvert>
2.382 - <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
2.383 - </target>
2.384 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
2.385 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
2.386 - <pathconvert property="run.classpath.without.build.classes.dir">
2.387 - <path path="${run.classpath}"/>
2.388 - <map from="${build.classes.dir.resolved}" to=""/>
2.389 - </pathconvert>
2.390 - <pathconvert pathsep=" " property="jar.classpath">
2.391 - <path path="${run.classpath.without.build.classes.dir}"/>
2.392 - <chainedmapper>
2.393 - <flattenmapper/>
2.394 - <globmapper from="*" to="lib/*"/>
2.395 - </chainedmapper>
2.396 - </pathconvert>
2.397 - <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
2.398 - <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
2.399 - <fileset dir="${build.classes.dir}"/>
2.400 - <manifest>
2.401 - <attribute name="Main-Class" value="${main.class}"/>
2.402 - <attribute name="Class-Path" value="${jar.classpath}"/>
2.403 - </manifest>
2.404 - </copylibs>
2.405 - <echo>To run this application from the command line without Ant, try:</echo>
2.406 - <property location="${dist.jar}" name="dist.jar.resolved"/>
2.407 - <echo>java -jar "${dist.jar.resolved}"</echo>
2.408 - </target>
2.409 - <target name="-post-jar">
2.410 - <!-- Empty placeholder for easier customization. -->
2.411 - <!-- You can override this target in the ../build.xml file. -->
2.412 - </target>
2.413 - <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
2.414 - <!--
2.415 - =================
2.416 - EXECUTION SECTION
2.417 - =================
2.418 - -->
2.419 - <target depends="init,compile" description="Run a main class." name="run">
2.420 - <j2seproject1:java>
2.421 - <customize>
2.422 - <arg line="${application.args}"/>
2.423 - </customize>
2.424 - </j2seproject1:java>
2.425 - </target>
2.426 - <target name="-do-not-recompile">
2.427 - <property name="javac.includes.binary" value=""/>
2.428 - </target>
2.429 - <target depends="init,-do-not-recompile,compile-single" name="run-single">
2.430 - <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
2.431 - <j2seproject1:java classname="${run.class}"/>
2.432 - </target>
2.433 - <!--
2.434 - =================
2.435 - DEBUGGING SECTION
2.436 - =================
2.437 - -->
2.438 - <target depends="init" if="netbeans.home" name="-debug-start-debugger">
2.439 - <j2seproject1:nbjpdastart name="${debug.class}"/>
2.440 - </target>
2.441 - <target depends="init,compile" name="-debug-start-debuggee">
2.442 - <j2seproject3:debug>
2.443 - <customize>
2.444 - <arg line="${application.args}"/>
2.445 - </customize>
2.446 - </j2seproject3:debug>
2.447 - </target>
2.448 - <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
2.449 - <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
2.450 - <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
2.451 - </target>
2.452 - <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
2.453 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
2.454 - <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
2.455 - <j2seproject3:debug classname="${debug.class}"/>
2.456 - </target>
2.457 - <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
2.458 - <target depends="init" name="-pre-debug-fix">
2.459 - <fail unless="fix.includes">Must set fix.includes</fail>
2.460 - <property name="javac.includes" value="${fix.includes}.java"/>
2.461 - </target>
2.462 - <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
2.463 - <j2seproject1:nbjpdareload/>
2.464 - </target>
2.465 - <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
2.466 - <!--
2.467 - ===============
2.468 - JAVADOC SECTION
2.469 - ===============
2.470 - -->
2.471 - <target depends="init" name="-javadoc-build">
2.472 - <mkdir dir="${dist.javadoc.dir}"/>
2.473 - <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
2.474 - <classpath>
2.475 - <path path="${javac.classpath}"/>
2.476 - </classpath>
2.477 - <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
2.478 - <filename name="**/*.java"/>
2.479 - </fileset>
2.480 - </javadoc>
2.481 - </target>
2.482 - <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
2.483 - <nbbrowse file="${dist.javadoc.dir}/index.html"/>
2.484 - </target>
2.485 - <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
2.486 - <!--
2.487 - =========================
2.488 - JUNIT COMPILATION SECTION
2.489 - =========================
2.490 - -->
2.491 - <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
2.492 - <mkdir dir="${build.test.classes.dir}"/>
2.493 - </target>
2.494 - <target name="-pre-compile-test">
2.495 - <!-- Empty placeholder for easier customization. -->
2.496 - <!-- You can override this target in the ../build.xml file. -->
2.497 - </target>
2.498 - <target if="do.depend.true" name="-compile-test-depend">
2.499 - <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
2.500 - </target>
2.501 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
2.502 - <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
2.503 - <copy todir="${build.test.classes.dir}">
2.504 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
2.505 - </copy>
2.506 - </target>
2.507 - <target name="-post-compile-test">
2.508 - <!-- Empty placeholder for easier customization. -->
2.509 - <!-- You can override this target in the ../build.xml file. -->
2.510 - </target>
2.511 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
2.512 - <target name="-pre-compile-test-single">
2.513 - <!-- Empty placeholder for easier customization. -->
2.514 - <!-- You can override this target in the ../build.xml file. -->
2.515 - </target>
2.516 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
2.517 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
2.518 - <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
2.519 - <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
2.520 - <copy todir="${build.test.classes.dir}">
2.521 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
2.522 - </copy>
2.523 - </target>
2.524 - <target name="-post-compile-test-single">
2.525 - <!-- Empty placeholder for easier customization. -->
2.526 - <!-- You can override this target in the ../build.xml file. -->
2.527 - </target>
2.528 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
2.529 - <!--
2.530 - =======================
2.531 - JUNIT EXECUTION SECTION
2.532 - =======================
2.533 - -->
2.534 - <target depends="init" if="have.tests" name="-pre-test-run">
2.535 - <mkdir dir="${build.test.results.dir}"/>
2.536 - </target>
2.537 - <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
2.538 - <j2seproject3:junit testincludes="**/*Test.java"/>
2.539 - </target>
2.540 - <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
2.541 - <fail if="tests.failed">Some tests failed; see details above.</fail>
2.542 - </target>
2.543 - <target depends="init" if="have.tests" name="test-report"/>
2.544 - <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
2.545 - <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
2.546 - <target depends="init" if="have.tests" name="-pre-test-run-single">
2.547 - <mkdir dir="${build.test.results.dir}"/>
2.548 - </target>
2.549 - <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
2.550 - <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
2.551 - <j2seproject3:junit excludes="" includes="${test.includes}"/>
2.552 - </target>
2.553 - <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
2.554 - <fail if="tests.failed">Some tests failed; see details above.</fail>
2.555 - </target>
2.556 - <target depends="init,-do-not-recompile,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
2.557 - <!--
2.558 - =======================
2.559 - JUNIT DEBUGGING SECTION
2.560 - =======================
2.561 - -->
2.562 - <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
2.563 - <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
2.564 - <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
2.565 - <delete file="${test.report.file}"/>
2.566 - <mkdir dir="${build.test.results.dir}"/>
2.567 - <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
2.568 - <customize>
2.569 - <syspropertyset>
2.570 - <propertyref prefix="test-sys-prop."/>
2.571 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
2.572 - </syspropertyset>
2.573 - <arg value="${test.class}"/>
2.574 - <arg value="showoutput=true"/>
2.575 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
2.576 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
2.577 - </customize>
2.578 - </j2seproject3:debug>
2.579 - </target>
2.580 - <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
2.581 - <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
2.582 - </target>
2.583 - <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
2.584 - <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
2.585 - <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
2.586 - </target>
2.587 - <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
2.588 - <!--
2.589 - =========================
2.590 - APPLET EXECUTION SECTION
2.591 - =========================
2.592 - -->
2.593 - <target depends="init,compile-single" name="run-applet">
2.594 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
2.595 - <j2seproject1:java classname="sun.applet.AppletViewer">
2.596 - <customize>
2.597 - <arg value="${applet.url}"/>
2.598 - </customize>
2.599 - </j2seproject1:java>
2.600 - </target>
2.601 - <!--
2.602 - =========================
2.603 - APPLET DEBUGGING SECTION
2.604 - =========================
2.605 - -->
2.606 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
2.607 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
2.608 - <j2seproject3:debug classname="sun.applet.AppletViewer">
2.609 - <customize>
2.610 - <arg value="${applet.url}"/>
2.611 - </customize>
2.612 - </j2seproject3:debug>
2.613 - </target>
2.614 - <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
2.615 - <!--
2.616 - ===============
2.617 - CLEANUP SECTION
2.618 - ===============
2.619 - -->
2.620 - <target depends="init" name="deps-clean" unless="no.deps"/>
2.621 - <target depends="init" name="-do-clean">
2.622 - <delete dir="${build.dir}"/>
2.623 - <delete dir="${dist.dir}"/>
2.624 - </target>
2.625 - <target name="-post-clean">
2.626 - <!-- Empty placeholder for easier customization. -->
2.627 - <!-- You can override this target in the ../build.xml file. -->
2.628 - </target>
2.629 - <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
2.630 -</project>
3.1 --- a/samples/exceptions/nbproject/genfiles.properties Sun Feb 01 16:27:41 2009 +0100
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,8 +0,0 @@
3.4 -build.xml.data.CRC32=fee87459
3.5 -build.xml.script.CRC32=02c97e29
3.6 -build.xml.stylesheet.CRC32=be360661
3.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
3.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
3.9 -nbproject/build-impl.xml.data.CRC32=fee87459
3.10 -nbproject/build-impl.xml.script.CRC32=ce1d9b31
3.11 -nbproject/build-impl.xml.stylesheet.CRC32=f1d9da08
4.1 --- a/samples/exceptions/nbproject/project.properties Sun Feb 01 16:27:41 2009 +0100
4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
4.3 @@ -1,57 +0,0 @@
4.4 -build.classes.dir=${build.dir}/classes
4.5 -build.classes.excludes=**/*.java,**/*.form
4.6 -# This directory is removed when the project is cleaned:
4.7 -build.dir=build
4.8 -build.generated.dir=${build.dir}/generated
4.9 -# Only compile against the classpath explicitly listed here:
4.10 -build.sysclasspath=ignore
4.11 -build.test.classes.dir=${build.dir}/test/classes
4.12 -build.test.results.dir=${build.dir}/test/results
4.13 -debug.classpath=\
4.14 - ${run.classpath}
4.15 -debug.test.classpath=\
4.16 - ${run.test.classpath}
4.17 -# This directory is removed when the project is cleaned:
4.18 -dist.dir=dist
4.19 -dist.jar=${dist.dir}/exceptions.jar
4.20 -dist.javadoc.dir=${dist.dir}/javadoc
4.21 -excludes=
4.22 -includes=**
4.23 -jar.compress=false
4.24 -javac.classpath=
4.25 -# Space-separated list of extra javac options
4.26 -javac.compilerargs=
4.27 -javac.deprecation=false
4.28 -javac.source=1.5
4.29 -javac.target=1.5
4.30 -javac.test.classpath=\
4.31 - ${javac.classpath}:\
4.32 - ${build.classes.dir}:\
4.33 - ${libs.junit.classpath}:\
4.34 - ${libs.junit_4.classpath}
4.35 -javadoc.additionalparam=
4.36 -javadoc.author=false
4.37 -javadoc.encoding=${source.encoding}
4.38 -javadoc.noindex=false
4.39 -javadoc.nonavbar=false
4.40 -javadoc.notree=false
4.41 -javadoc.private=false
4.42 -javadoc.splitindex=true
4.43 -javadoc.use=true
4.44 -javadoc.version=false
4.45 -javadoc.windowtitle=
4.46 -meta.inf.dir=${src.dir}/META-INF
4.47 -platform.active=default_platform
4.48 -run.classpath=\
4.49 - ${javac.classpath}:\
4.50 - ${build.classes.dir}
4.51 -# Space-separated list of JVM arguments used when running the project
4.52 -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
4.53 -# or test-sys-prop.name=value to set system properties for unit tests):
4.54 -run.jvmargs=
4.55 -run.test.classpath=\
4.56 - ${javac.test.classpath}:\
4.57 - ${build.test.classes.dir}
4.58 -source.encoding=UTF-8
4.59 -src.dir=src
4.60 -test.src.dir=test
5.1 --- a/samples/exceptions/nbproject/project.xml Sun Feb 01 16:27:41 2009 +0100
5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
5.3 @@ -1,16 +0,0 @@
5.4 -<?xml version="1.0" encoding="UTF-8"?>
5.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
5.6 - <type>org.netbeans.modules.java.j2seproject</type>
5.7 - <configuration>
5.8 - <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
5.9 - <name>exceptions</name>
5.10 - <minimum-ant-version>1.6.5</minimum-ant-version>
5.11 - <source-roots>
5.12 - <root id="src.dir"/>
5.13 - </source-roots>
5.14 - <test-roots>
5.15 - <root id="test.src.dir"/>
5.16 - </test-roots>
5.17 - </data>
5.18 - </configuration>
5.19 -</project>
6.1 --- a/samples/exceptions/src/org/apidesign/exceptions/trycatchredo/api/IOManager.java Sun Feb 01 16:27:41 2009 +0100
6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
6.3 @@ -1,44 +0,0 @@
6.4 -package org.apidesign.exceptions.trycatchredo.api;
6.5 -
6.6 -import java.net.URL;
6.7 -import javax.swing.Action;
6.8 -import javax.swing.JDialog;
6.9 -import javax.swing.JOptionPane;
6.10 -
6.11 -/**
6.12 - *
6.13 - * @author Jaroslav Tulach <jtulach@netbeans.org>
6.14 - */
6.15 -public final class IOManager {
6.16 - IOManager() {
6.17 - }
6.18 -
6.19 - /** Action that can store a text to given URL.
6.20 - *
6.21 - * @param where the url to upload the text to
6.22 - * @param what the text to upload
6.23 - * @return action that can be invoked anytime to save the content
6.24 - */
6.25 - public static Action createSaveAction(URL where, CharSequence what) {
6.26 - if (old) {
6.27 - return new SaveAction(where, what);
6.28 - } else {
6.29 - return new SaveActionWithQuery(where, what);
6.30 - }
6.31 - }
6.32 -
6.33 - //
6.34 - // Support for executing mock objects in tests
6.35 - //
6.36 -
6.37 - static boolean old;
6.38 - static Object setVisibleOption;
6.39 - static void setVisible(JDialog d, JOptionPane p) {
6.40 - if (setVisibleOption == null) {
6.41 - d.setVisible(true);
6.42 - } else {
6.43 - // only in test mode
6.44 - p.setValue(setVisibleOption);
6.45 - }
6.46 - }
6.47 -}
7.1 --- a/samples/exceptions/src/org/apidesign/exceptions/trycatchredo/api/SaveAction.java Sun Feb 01 16:27:41 2009 +0100
7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
7.3 @@ -1,35 +0,0 @@
7.4 -package org.apidesign.exceptions.trycatchredo.api;
7.5 -
7.6 -import java.awt.EventQueue;
7.7 -import java.awt.event.ActionEvent;
7.8 -import java.io.IOException;
7.9 -import java.io.OutputStream;
7.10 -import java.net.URL;
7.11 -import javax.swing.AbstractAction;
7.12 -import javax.swing.JOptionPane;
7.13 -
7.14 -/**
7.15 - *
7.16 - * @author Jaroslav Tulach
7.17 - */
7.18 -final class SaveAction extends AbstractAction {
7.19 - private final URL where;
7.20 - private final CharSequence what;
7.21 -
7.22 - SaveAction(URL where, CharSequence what) {
7.23 - this.where = where;
7.24 - this.what = what;
7.25 - }
7.26 -
7.27 -
7.28 - public void actionPerformed(ActionEvent ev) {
7.29 - assert EventQueue.isDispatchThread();
7.30 - try {
7.31 - OutputStream os = where.openConnection().getOutputStream();
7.32 - os.write(what.toString().getBytes());
7.33 - os.close();
7.34 - } catch (IOException ex) {
7.35 - JOptionPane.showMessageDialog(null, ex);
7.36 - }
7.37 - }
7.38 -}
8.1 --- a/samples/exceptions/src/org/apidesign/exceptions/trycatchredo/api/SaveActionWithQuery.java Sun Feb 01 16:27:41 2009 +0100
8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
8.3 @@ -1,54 +0,0 @@
8.4 -package org.apidesign.exceptions.trycatchredo.api;
8.5 -
8.6 -import java.awt.EventQueue;
8.7 -import java.awt.event.ActionEvent;
8.8 -import java.io.IOException;
8.9 -import java.io.OutputStream;
8.10 -import java.net.URL;
8.11 -import javax.swing.AbstractAction;
8.12 -import javax.swing.JDialog;
8.13 -import javax.swing.JOptionPane;
8.14 -
8.15 -/**
8.16 - *
8.17 - * @author Jaroslav Tulach
8.18 - */
8.19 -final class SaveActionWithQuery extends AbstractAction {
8.20 - private final URL where;
8.21 - private final CharSequence what;
8.22 -
8.23 - SaveActionWithQuery(URL where, CharSequence what) {
8.24 - this.where = where;
8.25 - this.what = what;
8.26 - }
8.27 -
8.28 -
8.29 - public void actionPerformed(ActionEvent ev) {
8.30 - assert EventQueue.isDispatchThread();
8.31 - for (;;) {
8.32 - try {
8.33 - OutputStream os = where.openConnection().getOutputStream();
8.34 - os.write(what.toString().getBytes());
8.35 - os.close();
8.36 - } catch (UserQuestionException ex) {
8.37 - JOptionPane p = ex.getQuestionPane();
8.38 - JDialog d = p.createDialog(ex.getLocalizedMessage());
8.39 - setVisible(d, p);
8.40 - ex.confirm(p.getValue());
8.41 - if (
8.42 - !p.getValue().equals(JOptionPane.CANCEL_OPTION) &&
8.43 - !p.getValue().equals(JOptionPane.CLOSED_OPTION)
8.44 - ) {
8.45 - continue;
8.46 - }
8.47 - } catch (IOException ex) {
8.48 - JOptionPane.showMessageDialog(null, ex);
8.49 - }
8.50 - break;
8.51 - }
8.52 - }
8.53 -
8.54 - private static void setVisible(JDialog d, JOptionPane p) {
8.55 - IOManager.setVisible(d, p);
8.56 - }
8.57 -}
9.1 --- a/samples/exceptions/src/org/apidesign/exceptions/trycatchredo/api/UserQuestionException.java Sun Feb 01 16:27:41 2009 +0100
9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
9.3 @@ -1,29 +0,0 @@
9.4 -package org.apidesign.exceptions.trycatchredo.api;
9.5 -
9.6 -import java.io.IOException;
9.7 -import javax.swing.JOptionPane;
9.8 -
9.9 -/** Specialized I/O exception to request some kind of user confirmation.
9.10 - * A code that needs to ask user shall not attempt to open a dialog itself,
9.11 - * rather it shall emit this exception and let its callers show the dialog
9.12 - * at appropriate time.
9.13 - *
9.14 - * @author Jaroslav Tulach
9.15 - * @since 2.0
9.16 - */
9.17 -public abstract class UserQuestionException extends IOException {
9.18 - /** Description of the dialog to show to the user. Whoever catches
9.19 - * this exception shall use {@link #getQuestionPane()}.{@link JOptionPane#createDialog(java.lang.String)}
9.20 - * to construct and display the dialog.
9.21 - *
9.22 - * @return the pane to display to user
9.23 - */
9.24 - public abstract JOptionPane getQuestionPane();
9.25 - /** When the user confirms (or rejects) message presented by the
9.26 - * {@link #getQuestionPane()} dialog, the exception shall be notified
9.27 - * by calling this method with {@link JOptionPane#getValue()} option.
9.28 - *
9.29 - * @param option the option selected by the user
9.30 - */
9.31 - public abstract void confirm(Object option);
9.32 -}
10.1 --- a/samples/exceptions/src/org/apidesign/exceptions/trycatchredo/usage/Main.java Sun Feb 01 16:27:41 2009 +0100
10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
10.3 @@ -1,35 +0,0 @@
10.4 -package org.apidesign.exceptions.trycatchredo.usage;
10.5 -
10.6 -import java.awt.EventQueue;
10.7 -import java.awt.event.ActionEvent;
10.8 -import java.net.URL;
10.9 -import javax.swing.Action;
10.10 -import org.apidesign.exceptions.trycatchredo.api.IOManager;
10.11 -import org.apidesign.exceptions.trycatchredo.api.UserQuestionException;
10.12 -
10.13 -/** Sample usage showing interactive storage capabilities of the
10.14 - * {@link UserQuestionException}
10.15 - *
10.16 - * @author Jaroslav Tulach <jtulach@netbeans.org>
10.17 - */
10.18 -public class Main {
10.19 - public static void main(String[] args) throws Exception {
10.20 - MemoryURL.initialize();
10.21 -
10.22 - for (int cnt = 0; cnt < 10; cnt++) {
10.23 - URL u = new URL("memory://" + cnt + "/queryEncoding.txt");
10.24 - MemoryURL.registerURL(u.toExternalForm(), "", new QueryStream());
10.25 - final Action a = IOManager.createSaveAction(u, "Ask a Question");
10.26 - EventQueue.invokeAndWait(new Runnable() {
10.27 - public void run() {
10.28 - a.actionPerformed(new ActionEvent(this, 0, ""));
10.29 - }
10.30 - });
10.31 - String out = MemoryURL.getOutputForURL(u.toExternalForm());
10.32 -
10.33 - System.err.println(cnt + " output: " + out);
10.34 - }
10.35 -
10.36 - System.exit(0);
10.37 - }
10.38 -}
11.1 --- a/samples/exceptions/src/org/apidesign/exceptions/trycatchredo/usage/MemoryURL.java Sun Feb 01 16:27:41 2009 +0100
11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
11.3 @@ -1,94 +0,0 @@
11.4 -
11.5 -package org.apidesign.exceptions.trycatchredo.usage;
11.6 -
11.7 -import java.io.ByteArrayInputStream;
11.8 -import java.io.ByteArrayOutputStream;
11.9 -import java.io.IOException;
11.10 -import java.io.InputStream;
11.11 -import java.io.OutputStream;
11.12 -import java.net.MalformedURLException;
11.13 -import java.net.URL;
11.14 -import java.net.URLConnection;
11.15 -import java.net.URLStreamHandler;
11.16 -import java.net.URLStreamHandlerFactory;
11.17 -import java.util.HashMap;
11.18 -import java.util.Map;
11.19 -
11.20 -/** Support for special "memory://" URLs. Useful when testing network communication.
11.21 - *
11.22 - * @author Jaroslav Tulach
11.23 - */
11.24 -public final class MemoryURL extends URLStreamHandler {
11.25 - private MemoryURL() {
11.26 - }
11.27 -
11.28 - public static void initialize() {
11.29 - }
11.30 - static {
11.31 - class F implements URLStreamHandlerFactory {
11.32 - public URLStreamHandler createURLStreamHandler(String protocol) {
11.33 - if (protocol.startsWith("memory")) {
11.34 - return new MemoryURL();
11.35 - }
11.36 - return null;
11.37 - }
11.38 - }
11.39 - F f = new F();
11.40 - URL.setURLStreamHandlerFactory(f);
11.41 - }
11.42 -
11.43 - private static Map<String,InputStream> contents = new HashMap<String,InputStream>();
11.44 - private static Map<String,OutputStream> outputs = new HashMap<String,OutputStream>();
11.45 -
11.46 - public static void registerURL(String u, String content, OutputStream out) throws MalformedURLException {
11.47 - contents.put(u, new ByteArrayInputStream(content.getBytes()));
11.48 - outputs.put(u, out);
11.49 - }
11.50 -
11.51 - public static String getOutputForURL(String u) {
11.52 - OutputStream out = outputs.get(u);
11.53 - return out.toString();
11.54 - }
11.55 -
11.56 - protected URLConnection openConnection(URL u) throws IOException {
11.57 - return new MC(u);
11.58 - }
11.59 -
11.60 - private static final class MC extends URLConnection {
11.61 - private InputStream values;
11.62 - private OutputStream out;
11.63 -
11.64 - public MC(URL u) {
11.65 - super(u);
11.66 - out = outputs.get(u.toExternalForm());
11.67 - if (out == null) {
11.68 - out = new ByteArrayOutputStream();
11.69 - outputs.put(u.toExternalForm(), out);
11.70 - }
11.71 - }
11.72 -
11.73 - public void connect() throws IOException {
11.74 - if (values != null) {
11.75 - return;
11.76 - }
11.77 - values = contents.remove(url.toExternalForm());
11.78 - if (values == null) {
11.79 - throw new IOException("No such content: " + url);
11.80 - }
11.81 - }
11.82 -
11.83 - @Override
11.84 - public InputStream getInputStream() throws IOException {
11.85 - connect();
11.86 - return values;
11.87 - }
11.88 -
11.89 - @Override
11.90 - public OutputStream getOutputStream() throws IOException {
11.91 - if (out == null) {
11.92 - out = new ByteArrayOutputStream();
11.93 - }
11.94 - return out;
11.95 - }
11.96 - }
11.97 -}
12.1 --- a/samples/exceptions/src/org/apidesign/exceptions/trycatchredo/usage/QueryStream.java Sun Feb 01 16:27:41 2009 +0100
12.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
12.3 @@ -1,65 +0,0 @@
12.4 -package org.apidesign.exceptions.trycatchredo.usage;
12.5 -
12.6 -import org.apidesign.exceptions.trycatchredo.api.UserQuestionException;
12.7 -import java.io.ByteArrayOutputStream;
12.8 -import java.io.IOException;
12.9 -import java.io.OutputStream;
12.10 -import javax.swing.JOptionPane;
12.11 -
12.12 -public final class QueryStream extends OutputStream {
12.13 - private ByteArrayOutputStream arr = new ByteArrayOutputStream();
12.14 - /** this field can be manipulated by the QueryException */
12.15 - Boolean reverse;
12.16 -
12.17 - @Override
12.18 - public synchronized void write(byte[] b, int off, int len) throws IOException {
12.19 - if (reverse == null) {
12.20 - throw new QueryException();
12.21 - }
12.22 - arr.write(b, off, len);
12.23 - }
12.24 -
12.25 - @Override
12.26 - public synchronized void write(int b) throws IOException {
12.27 - if (reverse == null) {
12.28 - throw new QueryException();
12.29 - }
12.30 - arr.write(b);
12.31 - }
12.32 -
12.33 - @Override
12.34 - public String toString() {
12.35 - if (reverse == null) {
12.36 - return "Reverse question was not answered yet!";
12.37 - }
12.38 - if (reverse) {
12.39 - StringBuilder sb = new StringBuilder();
12.40 - sb.append(arr.toString());
12.41 - sb.reverse();
12.42 - return sb.toString();
12.43 - }
12.44 - return arr.toString();
12.45 - }
12.46 -
12.47 - private class QueryException extends UserQuestionException {
12.48 -
12.49 - @Override
12.50 - public JOptionPane getQuestionPane() {
12.51 - JOptionPane p = new JOptionPane("Store in reverse way?");
12.52 - p.setOptionType(JOptionPane.YES_NO_CANCEL_OPTION);
12.53 - return p;
12.54 - }
12.55 -
12.56 - @Override
12.57 - public void confirm(Object option) {
12.58 - if (option.equals(JOptionPane.YES_OPTION)) {
12.59 - reverse = Boolean.TRUE;
12.60 - return;
12.61 - }
12.62 - if (option.equals(JOptionPane.NO_OPTION)) {
12.63 - reverse = Boolean.FALSE;
12.64 - return;
12.65 - }
12.66 - }
12.67 - }
12.68 -}
13.1 --- a/samples/exceptions/test/org/apidesign/exceptions/trycatchredo/api/IOManagerTest.java Sun Feb 01 16:27:41 2009 +0100
13.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
13.3 @@ -1,64 +0,0 @@
13.4 -package org.apidesign.exceptions.trycatchredo.api;
13.5 -
13.6 -
13.7 -import org.apidesign.exceptions.trycatchredo.usage.MemoryURL;
13.8 -import java.awt.EventQueue;
13.9 -import java.awt.event.ActionEvent;
13.10 -import java.net.URL;
13.11 -import javax.swing.Action;
13.12 -import javax.swing.JOptionPane;
13.13 -import org.apidesign.exceptions.trycatchredo.usage.QueryStream;
13.14 -import org.junit.After;
13.15 -import org.junit.Before;
13.16 -import org.junit.Test;
13.17 -import static org.junit.Assert.*;
13.18 -
13.19 -/**
13.20 - *
13.21 - * @author Jaroslav Tulach <jtulach@netbeans.org>
13.22 - */
13.23 -public class IOManagerTest {
13.24 -
13.25 - public IOManagerTest() {
13.26 - }
13.27 -
13.28 - @Before
13.29 - public void setUp() {
13.30 - MemoryURL.initialize();
13.31 - }
13.32 -
13.33 - @After
13.34 - public void tearDown() {
13.35 - }
13.36 -
13.37 - @Test
13.38 - public void simpleWrite() throws Exception {
13.39 - URL u = new URL("memory://simpleWrite.txt");
13.40 - MemoryURL.registerURL(u.toExternalForm(), "", null);
13.41 - final Action a = IOManager.createSaveAction(u, "Hello World!");
13.42 - EventQueue.invokeAndWait(new Runnable() {
13.43 - public void run() {
13.44 - a.actionPerformed(new ActionEvent(this, 0, ""));
13.45 - }
13.46 - });
13.47 - String out = MemoryURL.getOutputForURL(u.toExternalForm());
13.48 - assertEquals("Hello World!", out);
13.49 - }
13.50 -
13.51 - @Test
13.52 - public void writeWithAQuestion() throws Exception {
13.53 - URL u = new URL("memory://queryEncoding.txt");
13.54 -
13.55 - MemoryURL.registerURL(u.toExternalForm(), "", new QueryStream());
13.56 - final Action a = IOManager.createSaveAction(u, "Ask a Question");
13.57 - // simulate that the user clicks Yes to the reverse question in the dialog
13.58 - IOManager.setVisibleOption = JOptionPane.YES_OPTION;
13.59 - EventQueue.invokeAndWait(new Runnable() {
13.60 - public void run() {
13.61 - a.actionPerformed(new ActionEvent(this, 0, ""));
13.62 - }
13.63 - });
13.64 - String out = MemoryURL.getOutputForURL(u.toExternalForm());
13.65 - assertEquals("Text is reversed", "noitseuQ a ksA", out);
13.66 - }
13.67 -}
13.68 \ No newline at end of file
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
14.2 +++ b/samples/trycatchredo/build.xml Sun Feb 01 16:29:46 2009 +0100
14.3 @@ -0,0 +1,74 @@
14.4 +<?xml version="1.0" encoding="UTF-8"?>
14.5 +<!-- You may freely edit this file. See commented blocks below for -->
14.6 +<!-- some examples of how to customize the build. -->
14.7 +<!-- (If you delete it and reopen the project it will be recreated.) -->
14.8 +<!-- By default, only the Clean and Build commands use this build script. -->
14.9 +<!-- Commands such as Run, Debug, and Test only use this build script if -->
14.10 +<!-- the Compile on Save feature is turned off for the project. -->
14.11 +<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
14.12 +<!-- in the project's Project Properties dialog box.-->
14.13 +<project name="trycatchredo" default="default" basedir=".">
14.14 + <description>Builds, tests, and runs the project trycatchredo.</description>
14.15 + <import file="nbproject/build-impl.xml"/>
14.16 + <!--
14.17 +
14.18 + There exist several targets which are by default empty and which can be
14.19 + used for execution of your tasks. These targets are usually executed
14.20 + before and after some main targets. They are:
14.21 +
14.22 + -pre-init: called before initialization of project properties
14.23 + -post-init: called after initialization of project properties
14.24 + -pre-compile: called before javac compilation
14.25 + -post-compile: called after javac compilation
14.26 + -pre-compile-single: called before javac compilation of single file
14.27 + -post-compile-single: called after javac compilation of single file
14.28 + -pre-compile-test: called before javac compilation of JUnit tests
14.29 + -post-compile-test: called after javac compilation of JUnit tests
14.30 + -pre-compile-test-single: called before javac compilation of single JUnit test
14.31 + -post-compile-test-single: called after javac compilation of single JUunit test
14.32 + -pre-jar: called before JAR building
14.33 + -post-jar: called after JAR building
14.34 + -post-clean: called after cleaning build products
14.35 +
14.36 + (Targets beginning with '-' are not intended to be called on their own.)
14.37 +
14.38 + Example of inserting an obfuscator after compilation could look like this:
14.39 +
14.40 + <target name="-post-compile">
14.41 + <obfuscate>
14.42 + <fileset dir="${build.classes.dir}"/>
14.43 + </obfuscate>
14.44 + </target>
14.45 +
14.46 + For list of available properties check the imported
14.47 + nbproject/build-impl.xml file.
14.48 +
14.49 +
14.50 + Another way to customize the build is by overriding existing main targets.
14.51 + The targets of interest are:
14.52 +
14.53 + -init-macrodef-javac: defines macro for javac compilation
14.54 + -init-macrodef-junit: defines macro for junit execution
14.55 + -init-macrodef-debug: defines macro for class debugging
14.56 + -init-macrodef-java: defines macro for class execution
14.57 + -do-jar-with-manifest: JAR building (if you are using a manifest)
14.58 + -do-jar-without-manifest: JAR building (if you are not using a manifest)
14.59 + run: execution of project
14.60 + -javadoc-build: Javadoc generation
14.61 + test-report: JUnit report generation
14.62 +
14.63 + An example of overriding the target for project execution could look like this:
14.64 +
14.65 + <target name="run" depends="trycatchredo-impl.jar">
14.66 + <exec dir="bin" executable="launcher.exe">
14.67 + <arg file="${dist.jar}"/>
14.68 + </exec>
14.69 + </target>
14.70 +
14.71 + Notice that the overridden target depends on the jar target and not only on
14.72 + the compile target as the regular run target does. Again, for a list of available
14.73 + properties which you can use, check the target you are overriding in the
14.74 + nbproject/build-impl.xml file.
14.75 +
14.76 + -->
14.77 +</project>
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
15.2 +++ b/samples/trycatchredo/nbproject/build-impl.xml Sun Feb 01 16:29:46 2009 +0100
15.3 @@ -0,0 +1,642 @@
15.4 +<?xml version="1.0" encoding="UTF-8"?>
15.5 +<!--
15.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
15.7 +*** EDIT ../build.xml INSTEAD ***
15.8 +
15.9 +For the purpose of easier reading the script
15.10 +is divided into following sections:
15.11 +
15.12 + - initialization
15.13 + - compilation
15.14 + - jar
15.15 + - execution
15.16 + - debugging
15.17 + - javadoc
15.18 + - junit compilation
15.19 + - junit execution
15.20 + - junit debugging
15.21 + - applet
15.22 + - cleanup
15.23 +
15.24 + -->
15.25 +<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="trycatchredo-impl">
15.26 + <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
15.27 + <!--
15.28 + ======================
15.29 + INITIALIZATION SECTION
15.30 + ======================
15.31 + -->
15.32 + <target name="-pre-init">
15.33 + <!-- Empty placeholder for easier customization. -->
15.34 + <!-- You can override this target in the ../build.xml file. -->
15.35 + </target>
15.36 + <target depends="-pre-init" name="-init-private">
15.37 + <property file="nbproject/private/config.properties"/>
15.38 + <property file="nbproject/private/configs/${config}.properties"/>
15.39 + <property file="nbproject/private/private.properties"/>
15.40 + </target>
15.41 + <target depends="-pre-init,-init-private" name="-init-user">
15.42 + <property file="${user.properties.file}"/>
15.43 + <!-- The two properties below are usually overridden -->
15.44 + <!-- by the active platform. Just a fallback. -->
15.45 + <property name="default.javac.source" value="1.4"/>
15.46 + <property name="default.javac.target" value="1.4"/>
15.47 + </target>
15.48 + <target depends="-pre-init,-init-private,-init-user" name="-init-project">
15.49 + <property file="nbproject/configs/${config}.properties"/>
15.50 + <property file="nbproject/project.properties"/>
15.51 + </target>
15.52 + <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
15.53 + <available file="${manifest.file}" property="manifest.available"/>
15.54 + <condition property="manifest.available+main.class">
15.55 + <and>
15.56 + <isset property="manifest.available"/>
15.57 + <isset property="main.class"/>
15.58 + <not>
15.59 + <equals arg1="${main.class}" arg2="" trim="true"/>
15.60 + </not>
15.61 + </and>
15.62 + </condition>
15.63 + <condition property="manifest.available+main.class+mkdist.available">
15.64 + <and>
15.65 + <istrue value="${manifest.available+main.class}"/>
15.66 + <isset property="libs.CopyLibs.classpath"/>
15.67 + </and>
15.68 + </condition>
15.69 + <condition property="have.tests">
15.70 + <or>
15.71 + <available file="${test.src.dir}"/>
15.72 + </or>
15.73 + </condition>
15.74 + <condition property="have.sources">
15.75 + <or>
15.76 + <available file="${src.dir}"/>
15.77 + </or>
15.78 + </condition>
15.79 + <condition property="netbeans.home+have.tests">
15.80 + <and>
15.81 + <isset property="netbeans.home"/>
15.82 + <isset property="have.tests"/>
15.83 + </and>
15.84 + </condition>
15.85 + <condition property="no.javadoc.preview">
15.86 + <and>
15.87 + <isset property="javadoc.preview"/>
15.88 + <isfalse value="${javadoc.preview}"/>
15.89 + </and>
15.90 + </condition>
15.91 + <property name="run.jvmargs" value=""/>
15.92 + <property name="javac.compilerargs" value=""/>
15.93 + <property name="work.dir" value="${basedir}"/>
15.94 + <condition property="no.deps">
15.95 + <and>
15.96 + <istrue value="${no.dependencies}"/>
15.97 + </and>
15.98 + </condition>
15.99 + <property name="javac.debug" value="true"/>
15.100 + <property name="javadoc.preview" value="true"/>
15.101 + <property name="application.args" value=""/>
15.102 + <property name="source.encoding" value="${file.encoding}"/>
15.103 + <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
15.104 + <and>
15.105 + <isset property="javadoc.encoding"/>
15.106 + <not>
15.107 + <equals arg1="${javadoc.encoding}" arg2=""/>
15.108 + </not>
15.109 + </and>
15.110 + </condition>
15.111 + <property name="javadoc.encoding.used" value="${source.encoding}"/>
15.112 + <property name="includes" value="**"/>
15.113 + <property name="excludes" value=""/>
15.114 + <property name="do.depend" value="false"/>
15.115 + <condition property="do.depend.true">
15.116 + <istrue value="${do.depend}"/>
15.117 + </condition>
15.118 + <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
15.119 + <and>
15.120 + <isset property="jaxws.endorsed.dir"/>
15.121 + <available file="nbproject/jaxws-build.xml"/>
15.122 + </and>
15.123 + </condition>
15.124 + </target>
15.125 + <target name="-post-init">
15.126 + <!-- Empty placeholder for easier customization. -->
15.127 + <!-- You can override this target in the ../build.xml file. -->
15.128 + </target>
15.129 + <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
15.130 + <fail unless="src.dir">Must set src.dir</fail>
15.131 + <fail unless="test.src.dir">Must set test.src.dir</fail>
15.132 + <fail unless="build.dir">Must set build.dir</fail>
15.133 + <fail unless="dist.dir">Must set dist.dir</fail>
15.134 + <fail unless="build.classes.dir">Must set build.classes.dir</fail>
15.135 + <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
15.136 + <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
15.137 + <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
15.138 + <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
15.139 + <fail unless="dist.jar">Must set dist.jar</fail>
15.140 + </target>
15.141 + <target name="-init-macrodef-property">
15.142 + <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
15.143 + <attribute name="name"/>
15.144 + <attribute name="value"/>
15.145 + <sequential>
15.146 + <property name="@{name}" value="${@{value}}"/>
15.147 + </sequential>
15.148 + </macrodef>
15.149 + </target>
15.150 + <target name="-init-macrodef-javac">
15.151 + <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
15.152 + <attribute default="${src.dir}" name="srcdir"/>
15.153 + <attribute default="${build.classes.dir}" name="destdir"/>
15.154 + <attribute default="${javac.classpath}" name="classpath"/>
15.155 + <attribute default="${includes}" name="includes"/>
15.156 + <attribute default="${excludes}" name="excludes"/>
15.157 + <attribute default="${javac.debug}" name="debug"/>
15.158 + <attribute default="" name="sourcepath"/>
15.159 + <element name="customize" optional="true"/>
15.160 + <sequential>
15.161 + <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}">
15.162 + <classpath>
15.163 + <path path="@{classpath}"/>
15.164 + </classpath>
15.165 + <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
15.166 + <customize/>
15.167 + </javac>
15.168 + </sequential>
15.169 + </macrodef>
15.170 + <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
15.171 + <attribute default="${src.dir}" name="srcdir"/>
15.172 + <attribute default="${build.classes.dir}" name="destdir"/>
15.173 + <attribute default="${javac.classpath}" name="classpath"/>
15.174 + <sequential>
15.175 + <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
15.176 + <classpath>
15.177 + <path path="@{classpath}"/>
15.178 + </classpath>
15.179 + </depend>
15.180 + </sequential>
15.181 + </macrodef>
15.182 + <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
15.183 + <attribute default="${build.classes.dir}" name="destdir"/>
15.184 + <sequential>
15.185 + <fail unless="javac.includes">Must set javac.includes</fail>
15.186 + <pathconvert pathsep="," property="javac.includes.binary">
15.187 + <path>
15.188 + <filelist dir="@{destdir}" files="${javac.includes}"/>
15.189 + </path>
15.190 + <globmapper from="*.java" to="*.class"/>
15.191 + </pathconvert>
15.192 + <delete>
15.193 + <files includes="${javac.includes.binary}"/>
15.194 + </delete>
15.195 + </sequential>
15.196 + </macrodef>
15.197 + </target>
15.198 + <target name="-init-macrodef-junit">
15.199 + <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
15.200 + <attribute default="${includes}" name="includes"/>
15.201 + <attribute default="${excludes}" name="excludes"/>
15.202 + <attribute default="**" name="testincludes"/>
15.203 + <sequential>
15.204 + <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
15.205 + <batchtest todir="${build.test.results.dir}">
15.206 + <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
15.207 + <filename name="@{testincludes}"/>
15.208 + </fileset>
15.209 + </batchtest>
15.210 + <classpath>
15.211 + <path path="${run.test.classpath}"/>
15.212 + </classpath>
15.213 + <syspropertyset>
15.214 + <propertyref prefix="test-sys-prop."/>
15.215 + <mapper from="test-sys-prop.*" to="*" type="glob"/>
15.216 + </syspropertyset>
15.217 + <formatter type="brief" usefile="false"/>
15.218 + <formatter type="xml"/>
15.219 + <jvmarg line="${run.jvmargs}"/>
15.220 + </junit>
15.221 + </sequential>
15.222 + </macrodef>
15.223 + </target>
15.224 + <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
15.225 + <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
15.226 + <attribute default="${main.class}" name="name"/>
15.227 + <attribute default="${debug.classpath}" name="classpath"/>
15.228 + <attribute default="" name="stopclassname"/>
15.229 + <sequential>
15.230 + <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
15.231 + <classpath>
15.232 + <path path="@{classpath}"/>
15.233 + </classpath>
15.234 + </nbjpdastart>
15.235 + </sequential>
15.236 + </macrodef>
15.237 + <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
15.238 + <attribute default="${build.classes.dir}" name="dir"/>
15.239 + <sequential>
15.240 + <nbjpdareload>
15.241 + <fileset dir="@{dir}" includes="${fix.classes}">
15.242 + <include name="${fix.includes}*.class"/>
15.243 + </fileset>
15.244 + </nbjpdareload>
15.245 + </sequential>
15.246 + </macrodef>
15.247 + </target>
15.248 + <target name="-init-debug-args">
15.249 + <property name="version-output" value="java version "${ant.java.version}"/>
15.250 + <condition property="have-jdk-older-than-1.4">
15.251 + <or>
15.252 + <contains string="${version-output}" substring="java version "1.0"/>
15.253 + <contains string="${version-output}" substring="java version "1.1"/>
15.254 + <contains string="${version-output}" substring="java version "1.2"/>
15.255 + <contains string="${version-output}" substring="java version "1.3"/>
15.256 + </or>
15.257 + </condition>
15.258 + <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
15.259 + <istrue value="${have-jdk-older-than-1.4}"/>
15.260 + </condition>
15.261 + <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
15.262 + <os family="windows"/>
15.263 + </condition>
15.264 + <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
15.265 + <isset property="debug.transport"/>
15.266 + </condition>
15.267 + </target>
15.268 + <target depends="-init-debug-args" name="-init-macrodef-debug">
15.269 + <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
15.270 + <attribute default="${main.class}" name="classname"/>
15.271 + <attribute default="${debug.classpath}" name="classpath"/>
15.272 + <element name="customize" optional="true"/>
15.273 + <sequential>
15.274 + <java classname="@{classname}" dir="${work.dir}" fork="true">
15.275 + <jvmarg line="${debug-args-line}"/>
15.276 + <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
15.277 + <jvmarg line="${run.jvmargs}"/>
15.278 + <classpath>
15.279 + <path path="@{classpath}"/>
15.280 + </classpath>
15.281 + <syspropertyset>
15.282 + <propertyref prefix="run-sys-prop."/>
15.283 + <mapper from="run-sys-prop.*" to="*" type="glob"/>
15.284 + </syspropertyset>
15.285 + <customize/>
15.286 + </java>
15.287 + </sequential>
15.288 + </macrodef>
15.289 + </target>
15.290 + <target name="-init-macrodef-java">
15.291 + <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
15.292 + <attribute default="${main.class}" name="classname"/>
15.293 + <element name="customize" optional="true"/>
15.294 + <sequential>
15.295 + <java classname="@{classname}" dir="${work.dir}" fork="true">
15.296 + <jvmarg line="${run.jvmargs}"/>
15.297 + <classpath>
15.298 + <path path="${run.classpath}"/>
15.299 + </classpath>
15.300 + <syspropertyset>
15.301 + <propertyref prefix="run-sys-prop."/>
15.302 + <mapper from="run-sys-prop.*" to="*" type="glob"/>
15.303 + </syspropertyset>
15.304 + <customize/>
15.305 + </java>
15.306 + </sequential>
15.307 + </macrodef>
15.308 + </target>
15.309 + <target name="-init-presetdef-jar">
15.310 + <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
15.311 + <jar compress="${jar.compress}" jarfile="${dist.jar}">
15.312 + <j2seproject1:fileset dir="${build.classes.dir}"/>
15.313 + </jar>
15.314 + </presetdef>
15.315 + </target>
15.316 + <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar" name="init"/>
15.317 + <!--
15.318 + ===================
15.319 + COMPILATION SECTION
15.320 + ===================
15.321 + -->
15.322 + <target depends="init" name="deps-jar" unless="no.deps"/>
15.323 + <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
15.324 + <target depends="init" name="-check-automatic-build">
15.325 + <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
15.326 + </target>
15.327 + <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
15.328 + <antcall target="clean"/>
15.329 + </target>
15.330 + <target depends="init,deps-jar" name="-pre-pre-compile">
15.331 + <mkdir dir="${build.classes.dir}"/>
15.332 + </target>
15.333 + <target name="-pre-compile">
15.334 + <!-- Empty placeholder for easier customization. -->
15.335 + <!-- You can override this target in the ../build.xml file. -->
15.336 + </target>
15.337 + <target if="do.depend.true" name="-compile-depend">
15.338 + <j2seproject3:depend/>
15.339 + </target>
15.340 + <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
15.341 + <j2seproject3:javac/>
15.342 + <copy todir="${build.classes.dir}">
15.343 + <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
15.344 + </copy>
15.345 + </target>
15.346 + <target name="-post-compile">
15.347 + <!-- Empty placeholder for easier customization. -->
15.348 + <!-- You can override this target in the ../build.xml file. -->
15.349 + </target>
15.350 + <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
15.351 + <target name="-pre-compile-single">
15.352 + <!-- Empty placeholder for easier customization. -->
15.353 + <!-- You can override this target in the ../build.xml file. -->
15.354 + </target>
15.355 + <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
15.356 + <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
15.357 + <j2seproject3:force-recompile/>
15.358 + <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
15.359 + </target>
15.360 + <target name="-post-compile-single">
15.361 + <!-- Empty placeholder for easier customization. -->
15.362 + <!-- You can override this target in the ../build.xml file. -->
15.363 + </target>
15.364 + <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
15.365 + <!--
15.366 + ====================
15.367 + JAR BUILDING SECTION
15.368 + ====================
15.369 + -->
15.370 + <target depends="init" name="-pre-pre-jar">
15.371 + <dirname file="${dist.jar}" property="dist.jar.dir"/>
15.372 + <mkdir dir="${dist.jar.dir}"/>
15.373 + </target>
15.374 + <target name="-pre-jar">
15.375 + <!-- Empty placeholder for easier customization. -->
15.376 + <!-- You can override this target in the ../build.xml file. -->
15.377 + </target>
15.378 + <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
15.379 + <j2seproject1:jar/>
15.380 + </target>
15.381 + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
15.382 + <j2seproject1:jar manifest="${manifest.file}"/>
15.383 + </target>
15.384 + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
15.385 + <j2seproject1:jar manifest="${manifest.file}">
15.386 + <j2seproject1:manifest>
15.387 + <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
15.388 + </j2seproject1:manifest>
15.389 + </j2seproject1:jar>
15.390 + <echo>To run this application from the command line without Ant, try:</echo>
15.391 + <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
15.392 + <property location="${dist.jar}" name="dist.jar.resolved"/>
15.393 + <pathconvert property="run.classpath.with.dist.jar">
15.394 + <path path="${run.classpath}"/>
15.395 + <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
15.396 + </pathconvert>
15.397 + <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
15.398 + </target>
15.399 + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
15.400 + <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
15.401 + <pathconvert property="run.classpath.without.build.classes.dir">
15.402 + <path path="${run.classpath}"/>
15.403 + <map from="${build.classes.dir.resolved}" to=""/>
15.404 + </pathconvert>
15.405 + <pathconvert pathsep=" " property="jar.classpath">
15.406 + <path path="${run.classpath.without.build.classes.dir}"/>
15.407 + <chainedmapper>
15.408 + <flattenmapper/>
15.409 + <globmapper from="*" to="lib/*"/>
15.410 + </chainedmapper>
15.411 + </pathconvert>
15.412 + <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
15.413 + <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
15.414 + <fileset dir="${build.classes.dir}"/>
15.415 + <manifest>
15.416 + <attribute name="Main-Class" value="${main.class}"/>
15.417 + <attribute name="Class-Path" value="${jar.classpath}"/>
15.418 + </manifest>
15.419 + </copylibs>
15.420 + <echo>To run this application from the command line without Ant, try:</echo>
15.421 + <property location="${dist.jar}" name="dist.jar.resolved"/>
15.422 + <echo>java -jar "${dist.jar.resolved}"</echo>
15.423 + </target>
15.424 + <target name="-post-jar">
15.425 + <!-- Empty placeholder for easier customization. -->
15.426 + <!-- You can override this target in the ../build.xml file. -->
15.427 + </target>
15.428 + <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
15.429 + <!--
15.430 + =================
15.431 + EXECUTION SECTION
15.432 + =================
15.433 + -->
15.434 + <target depends="init,compile" description="Run a main class." name="run">
15.435 + <j2seproject1:java>
15.436 + <customize>
15.437 + <arg line="${application.args}"/>
15.438 + </customize>
15.439 + </j2seproject1:java>
15.440 + </target>
15.441 + <target name="-do-not-recompile">
15.442 + <property name="javac.includes.binary" value=""/>
15.443 + </target>
15.444 + <target depends="init,-do-not-recompile,compile-single" name="run-single">
15.445 + <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
15.446 + <j2seproject1:java classname="${run.class}"/>
15.447 + </target>
15.448 + <!--
15.449 + =================
15.450 + DEBUGGING SECTION
15.451 + =================
15.452 + -->
15.453 + <target depends="init" if="netbeans.home" name="-debug-start-debugger">
15.454 + <j2seproject1:nbjpdastart name="${debug.class}"/>
15.455 + </target>
15.456 + <target depends="init,compile" name="-debug-start-debuggee">
15.457 + <j2seproject3:debug>
15.458 + <customize>
15.459 + <arg line="${application.args}"/>
15.460 + </customize>
15.461 + </j2seproject3:debug>
15.462 + </target>
15.463 + <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
15.464 + <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
15.465 + <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
15.466 + </target>
15.467 + <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
15.468 + <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
15.469 + <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
15.470 + <j2seproject3:debug classname="${debug.class}"/>
15.471 + </target>
15.472 + <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
15.473 + <target depends="init" name="-pre-debug-fix">
15.474 + <fail unless="fix.includes">Must set fix.includes</fail>
15.475 + <property name="javac.includes" value="${fix.includes}.java"/>
15.476 + </target>
15.477 + <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
15.478 + <j2seproject1:nbjpdareload/>
15.479 + </target>
15.480 + <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
15.481 + <!--
15.482 + ===============
15.483 + JAVADOC SECTION
15.484 + ===============
15.485 + -->
15.486 + <target depends="init" name="-javadoc-build">
15.487 + <mkdir dir="${dist.javadoc.dir}"/>
15.488 + <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
15.489 + <classpath>
15.490 + <path path="${javac.classpath}"/>
15.491 + </classpath>
15.492 + <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
15.493 + <filename name="**/*.java"/>
15.494 + </fileset>
15.495 + </javadoc>
15.496 + </target>
15.497 + <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
15.498 + <nbbrowse file="${dist.javadoc.dir}/index.html"/>
15.499 + </target>
15.500 + <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
15.501 + <!--
15.502 + =========================
15.503 + JUNIT COMPILATION SECTION
15.504 + =========================
15.505 + -->
15.506 + <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
15.507 + <mkdir dir="${build.test.classes.dir}"/>
15.508 + </target>
15.509 + <target name="-pre-compile-test">
15.510 + <!-- Empty placeholder for easier customization. -->
15.511 + <!-- You can override this target in the ../build.xml file. -->
15.512 + </target>
15.513 + <target if="do.depend.true" name="-compile-test-depend">
15.514 + <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
15.515 + </target>
15.516 + <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
15.517 + <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
15.518 + <copy todir="${build.test.classes.dir}">
15.519 + <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
15.520 + </copy>
15.521 + </target>
15.522 + <target name="-post-compile-test">
15.523 + <!-- Empty placeholder for easier customization. -->
15.524 + <!-- You can override this target in the ../build.xml file. -->
15.525 + </target>
15.526 + <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
15.527 + <target name="-pre-compile-test-single">
15.528 + <!-- Empty placeholder for easier customization. -->
15.529 + <!-- You can override this target in the ../build.xml file. -->
15.530 + </target>
15.531 + <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
15.532 + <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
15.533 + <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
15.534 + <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
15.535 + <copy todir="${build.test.classes.dir}">
15.536 + <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
15.537 + </copy>
15.538 + </target>
15.539 + <target name="-post-compile-test-single">
15.540 + <!-- Empty placeholder for easier customization. -->
15.541 + <!-- You can override this target in the ../build.xml file. -->
15.542 + </target>
15.543 + <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
15.544 + <!--
15.545 + =======================
15.546 + JUNIT EXECUTION SECTION
15.547 + =======================
15.548 + -->
15.549 + <target depends="init" if="have.tests" name="-pre-test-run">
15.550 + <mkdir dir="${build.test.results.dir}"/>
15.551 + </target>
15.552 + <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
15.553 + <j2seproject3:junit testincludes="**/*Test.java"/>
15.554 + </target>
15.555 + <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
15.556 + <fail if="tests.failed">Some tests failed; see details above.</fail>
15.557 + </target>
15.558 + <target depends="init" if="have.tests" name="test-report"/>
15.559 + <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
15.560 + <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
15.561 + <target depends="init" if="have.tests" name="-pre-test-run-single">
15.562 + <mkdir dir="${build.test.results.dir}"/>
15.563 + </target>
15.564 + <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
15.565 + <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
15.566 + <j2seproject3:junit excludes="" includes="${test.includes}"/>
15.567 + </target>
15.568 + <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
15.569 + <fail if="tests.failed">Some tests failed; see details above.</fail>
15.570 + </target>
15.571 + <target depends="init,-do-not-recompile,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
15.572 + <!--
15.573 + =======================
15.574 + JUNIT DEBUGGING SECTION
15.575 + =======================
15.576 + -->
15.577 + <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
15.578 + <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
15.579 + <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
15.580 + <delete file="${test.report.file}"/>
15.581 + <mkdir dir="${build.test.results.dir}"/>
15.582 + <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
15.583 + <customize>
15.584 + <syspropertyset>
15.585 + <propertyref prefix="test-sys-prop."/>
15.586 + <mapper from="test-sys-prop.*" to="*" type="glob"/>
15.587 + </syspropertyset>
15.588 + <arg value="${test.class}"/>
15.589 + <arg value="showoutput=true"/>
15.590 + <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
15.591 + <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
15.592 + </customize>
15.593 + </j2seproject3:debug>
15.594 + </target>
15.595 + <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
15.596 + <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
15.597 + </target>
15.598 + <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
15.599 + <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
15.600 + <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
15.601 + </target>
15.602 + <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
15.603 + <!--
15.604 + =========================
15.605 + APPLET EXECUTION SECTION
15.606 + =========================
15.607 + -->
15.608 + <target depends="init,compile-single" name="run-applet">
15.609 + <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
15.610 + <j2seproject1:java classname="sun.applet.AppletViewer">
15.611 + <customize>
15.612 + <arg value="${applet.url}"/>
15.613 + </customize>
15.614 + </j2seproject1:java>
15.615 + </target>
15.616 + <!--
15.617 + =========================
15.618 + APPLET DEBUGGING SECTION
15.619 + =========================
15.620 + -->
15.621 + <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
15.622 + <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
15.623 + <j2seproject3:debug classname="sun.applet.AppletViewer">
15.624 + <customize>
15.625 + <arg value="${applet.url}"/>
15.626 + </customize>
15.627 + </j2seproject3:debug>
15.628 + </target>
15.629 + <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
15.630 + <!--
15.631 + ===============
15.632 + CLEANUP SECTION
15.633 + ===============
15.634 + -->
15.635 + <target depends="init" name="deps-clean" unless="no.deps"/>
15.636 + <target depends="init" name="-do-clean">
15.637 + <delete dir="${build.dir}"/>
15.638 + <delete dir="${dist.dir}"/>
15.639 + </target>
15.640 + <target name="-post-clean">
15.641 + <!-- Empty placeholder for easier customization. -->
15.642 + <!-- You can override this target in the ../build.xml file. -->
15.643 + </target>
15.644 + <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
15.645 +</project>
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
16.2 +++ b/samples/trycatchredo/nbproject/genfiles.properties Sun Feb 01 16:29:46 2009 +0100
16.3 @@ -0,0 +1,8 @@
16.4 +build.xml.data.CRC32=5d238722
16.5 +build.xml.script.CRC32=43ec1e0f
16.6 +build.xml.stylesheet.CRC32=958a1d3e
16.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
16.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
16.9 +nbproject/build-impl.xml.data.CRC32=5d238722
16.10 +nbproject/build-impl.xml.script.CRC32=10047cb8
16.11 +nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
17.2 +++ b/samples/trycatchredo/nbproject/project.properties Sun Feb 01 16:29:46 2009 +0100
17.3 @@ -0,0 +1,58 @@
17.4 +build.classes.dir=${build.dir}/classes
17.5 +build.classes.excludes=**/*.java,**/*.form
17.6 +# This directory is removed when the project is cleaned:
17.7 +build.dir=build
17.8 +build.generated.dir=${build.dir}/generated
17.9 +# Only compile against the classpath explicitly listed here:
17.10 +build.sysclasspath=ignore
17.11 +build.test.classes.dir=${build.dir}/test/classes
17.12 +build.test.results.dir=${build.dir}/test/results
17.13 +debug.classpath=\
17.14 + ${run.classpath}
17.15 +debug.test.classpath=\
17.16 + ${run.test.classpath}
17.17 +# This directory is removed when the project is cleaned:
17.18 +dist.dir=dist
17.19 +dist.jar=${dist.dir}/trycatchredo.jar
17.20 +dist.javadoc.dir=${dist.dir}/javadoc
17.21 +excludes=
17.22 +file.reference.junit-4.4.jar=../libs/dist/junit-4.4.jar
17.23 +includes=**
17.24 +jar.compress=false
17.25 +javac.classpath=
17.26 +# Space-separated list of extra javac options
17.27 +javac.compilerargs=
17.28 +javac.deprecation=false
17.29 +javac.source=1.5
17.30 +javac.target=1.5
17.31 +javac.test.classpath=\
17.32 + ${javac.classpath}:\
17.33 + ${build.classes.dir}:\
17.34 + ${file.reference.junit-4.4.jar}
17.35 +javadoc.additionalparam=
17.36 +javadoc.author=false
17.37 +javadoc.encoding=${source.encoding}
17.38 +javadoc.noindex=false
17.39 +javadoc.nonavbar=false
17.40 +javadoc.notree=false
17.41 +javadoc.private=false
17.42 +javadoc.splitindex=true
17.43 +javadoc.use=true
17.44 +javadoc.version=false
17.45 +javadoc.windowtitle=
17.46 +main.class=org.apidesign.exceptions.trycatchredo.usage.Main
17.47 +meta.inf.dir=${src.dir}/META-INF
17.48 +platform.active=default_platform
17.49 +run.classpath=\
17.50 + ${javac.classpath}:\
17.51 + ${build.classes.dir}
17.52 +# Space-separated list of JVM arguments used when running the project
17.53 +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
17.54 +# or test-sys-prop.name=value to set system properties for unit tests):
17.55 +run.jvmargs=
17.56 +run.test.classpath=\
17.57 + ${javac.test.classpath}:\
17.58 + ${build.test.classes.dir}
17.59 +source.encoding=UTF-8
17.60 +src.dir=src
17.61 +test.src.dir=test
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
18.2 +++ b/samples/trycatchredo/nbproject/project.xml Sun Feb 01 16:29:46 2009 +0100
18.3 @@ -0,0 +1,16 @@
18.4 +<?xml version="1.0" encoding="UTF-8"?>
18.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
18.6 + <type>org.netbeans.modules.java.j2seproject</type>
18.7 + <configuration>
18.8 + <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
18.9 + <name>trycatchredo</name>
18.10 + <minimum-ant-version>1.6.5</minimum-ant-version>
18.11 + <source-roots>
18.12 + <root id="src.dir"/>
18.13 + </source-roots>
18.14 + <test-roots>
18.15 + <root id="test.src.dir"/>
18.16 + </test-roots>
18.17 + </data>
18.18 + </configuration>
18.19 +</project>
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
19.2 +++ b/samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/api/IOManager.java Sun Feb 01 16:29:46 2009 +0100
19.3 @@ -0,0 +1,44 @@
19.4 +package org.apidesign.exceptions.trycatchredo.api;
19.5 +
19.6 +import java.net.URL;
19.7 +import javax.swing.Action;
19.8 +import javax.swing.JDialog;
19.9 +import javax.swing.JOptionPane;
19.10 +
19.11 +/**
19.12 + *
19.13 + * @author Jaroslav Tulach <jtulach@netbeans.org>
19.14 + */
19.15 +public final class IOManager {
19.16 + IOManager() {
19.17 + }
19.18 +
19.19 + /** Action that can store a text to given URL.
19.20 + *
19.21 + * @param where the url to upload the text to
19.22 + * @param what the text to upload
19.23 + * @return action that can be invoked anytime to save the content
19.24 + */
19.25 + public static Action createSaveAction(URL where, CharSequence what) {
19.26 + if (old) {
19.27 + return new SaveAction(where, what);
19.28 + } else {
19.29 + return new SaveActionWithQuery(where, what);
19.30 + }
19.31 + }
19.32 +
19.33 + //
19.34 + // Support for executing mock objects in tests
19.35 + //
19.36 +
19.37 + static boolean old;
19.38 + static Object setVisibleOption;
19.39 + static void setVisible(JDialog d, JOptionPane p) {
19.40 + if (setVisibleOption == null) {
19.41 + d.setVisible(true);
19.42 + } else {
19.43 + // only in test mode
19.44 + p.setValue(setVisibleOption);
19.45 + }
19.46 + }
19.47 +}
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
20.2 +++ b/samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/api/SaveAction.java Sun Feb 01 16:29:46 2009 +0100
20.3 @@ -0,0 +1,35 @@
20.4 +package org.apidesign.exceptions.trycatchredo.api;
20.5 +
20.6 +import java.awt.EventQueue;
20.7 +import java.awt.event.ActionEvent;
20.8 +import java.io.IOException;
20.9 +import java.io.OutputStream;
20.10 +import java.net.URL;
20.11 +import javax.swing.AbstractAction;
20.12 +import javax.swing.JOptionPane;
20.13 +
20.14 +/**
20.15 + *
20.16 + * @author Jaroslav Tulach
20.17 + */
20.18 +final class SaveAction extends AbstractAction {
20.19 + private final URL where;
20.20 + private final CharSequence what;
20.21 +
20.22 + SaveAction(URL where, CharSequence what) {
20.23 + this.where = where;
20.24 + this.what = what;
20.25 + }
20.26 +
20.27 +
20.28 + public void actionPerformed(ActionEvent ev) {
20.29 + assert EventQueue.isDispatchThread();
20.30 + try {
20.31 + OutputStream os = where.openConnection().getOutputStream();
20.32 + os.write(what.toString().getBytes());
20.33 + os.close();
20.34 + } catch (IOException ex) {
20.35 + JOptionPane.showMessageDialog(null, ex);
20.36 + }
20.37 + }
20.38 +}
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
21.2 +++ b/samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/api/SaveActionWithQuery.java Sun Feb 01 16:29:46 2009 +0100
21.3 @@ -0,0 +1,54 @@
21.4 +package org.apidesign.exceptions.trycatchredo.api;
21.5 +
21.6 +import java.awt.EventQueue;
21.7 +import java.awt.event.ActionEvent;
21.8 +import java.io.IOException;
21.9 +import java.io.OutputStream;
21.10 +import java.net.URL;
21.11 +import javax.swing.AbstractAction;
21.12 +import javax.swing.JDialog;
21.13 +import javax.swing.JOptionPane;
21.14 +
21.15 +/**
21.16 + *
21.17 + * @author Jaroslav Tulach
21.18 + */
21.19 +final class SaveActionWithQuery extends AbstractAction {
21.20 + private final URL where;
21.21 + private final CharSequence what;
21.22 +
21.23 + SaveActionWithQuery(URL where, CharSequence what) {
21.24 + this.where = where;
21.25 + this.what = what;
21.26 + }
21.27 +
21.28 +
21.29 + public void actionPerformed(ActionEvent ev) {
21.30 + assert EventQueue.isDispatchThread();
21.31 + for (;;) {
21.32 + try {
21.33 + OutputStream os = where.openConnection().getOutputStream();
21.34 + os.write(what.toString().getBytes());
21.35 + os.close();
21.36 + } catch (UserQuestionException ex) {
21.37 + JOptionPane p = ex.getQuestionPane();
21.38 + JDialog d = p.createDialog(ex.getLocalizedMessage());
21.39 + setVisible(d, p);
21.40 + ex.confirm(p.getValue());
21.41 + if (
21.42 + !p.getValue().equals(JOptionPane.CANCEL_OPTION) &&
21.43 + !p.getValue().equals(JOptionPane.CLOSED_OPTION)
21.44 + ) {
21.45 + continue;
21.46 + }
21.47 + } catch (IOException ex) {
21.48 + JOptionPane.showMessageDialog(null, ex);
21.49 + }
21.50 + break;
21.51 + }
21.52 + }
21.53 +
21.54 + private static void setVisible(JDialog d, JOptionPane p) {
21.55 + IOManager.setVisible(d, p);
21.56 + }
21.57 +}
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
22.2 +++ b/samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/api/UserQuestionException.java Sun Feb 01 16:29:46 2009 +0100
22.3 @@ -0,0 +1,29 @@
22.4 +package org.apidesign.exceptions.trycatchredo.api;
22.5 +
22.6 +import java.io.IOException;
22.7 +import javax.swing.JOptionPane;
22.8 +
22.9 +/** Specialized I/O exception to request some kind of user confirmation.
22.10 + * A code that needs to ask user shall not attempt to open a dialog itself,
22.11 + * rather it shall emit this exception and let its callers show the dialog
22.12 + * at appropriate time.
22.13 + *
22.14 + * @author Jaroslav Tulach
22.15 + * @since 2.0
22.16 + */
22.17 +public abstract class UserQuestionException extends IOException {
22.18 + /** Description of the dialog to show to the user. Whoever catches
22.19 + * this exception shall use {@link #getQuestionPane()}.{@link JOptionPane#createDialog(java.lang.String)}
22.20 + * to construct and display the dialog.
22.21 + *
22.22 + * @return the pane to display to user
22.23 + */
22.24 + public abstract JOptionPane getQuestionPane();
22.25 + /** When the user confirms (or rejects) message presented by the
22.26 + * {@link #getQuestionPane()} dialog, the exception shall be notified
22.27 + * by calling this method with {@link JOptionPane#getValue()} option.
22.28 + *
22.29 + * @param option the option selected by the user
22.30 + */
22.31 + public abstract void confirm(Object option);
22.32 +}
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
23.2 +++ b/samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/usage/Main.java Sun Feb 01 16:29:46 2009 +0100
23.3 @@ -0,0 +1,35 @@
23.4 +package org.apidesign.exceptions.trycatchredo.usage;
23.5 +
23.6 +import java.awt.EventQueue;
23.7 +import java.awt.event.ActionEvent;
23.8 +import java.net.URL;
23.9 +import javax.swing.Action;
23.10 +import org.apidesign.exceptions.trycatchredo.api.IOManager;
23.11 +import org.apidesign.exceptions.trycatchredo.api.UserQuestionException;
23.12 +
23.13 +/** Sample usage showing interactive storage capabilities of the
23.14 + * {@link UserQuestionException}
23.15 + *
23.16 + * @author Jaroslav Tulach <jtulach@netbeans.org>
23.17 + */
23.18 +public class Main {
23.19 + public static void main(String[] args) throws Exception {
23.20 + MemoryURL.initialize();
23.21 +
23.22 + for (int cnt = 0; cnt < 10; cnt++) {
23.23 + URL u = new URL("memory://" + cnt + "/queryEncoding.txt");
23.24 + MemoryURL.registerURL(u.toExternalForm(), "", new QueryStream());
23.25 + final Action a = IOManager.createSaveAction(u, "Ask a Question");
23.26 + EventQueue.invokeAndWait(new Runnable() {
23.27 + public void run() {
23.28 + a.actionPerformed(new ActionEvent(this, 0, ""));
23.29 + }
23.30 + });
23.31 + String out = MemoryURL.getOutputForURL(u.toExternalForm());
23.32 +
23.33 + System.err.println(cnt + " output: " + out);
23.34 + }
23.35 +
23.36 + System.exit(0);
23.37 + }
23.38 +}
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
24.2 +++ b/samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/usage/MemoryURL.java Sun Feb 01 16:29:46 2009 +0100
24.3 @@ -0,0 +1,94 @@
24.4 +
24.5 +package org.apidesign.exceptions.trycatchredo.usage;
24.6 +
24.7 +import java.io.ByteArrayInputStream;
24.8 +import java.io.ByteArrayOutputStream;
24.9 +import java.io.IOException;
24.10 +import java.io.InputStream;
24.11 +import java.io.OutputStream;
24.12 +import java.net.MalformedURLException;
24.13 +import java.net.URL;
24.14 +import java.net.URLConnection;
24.15 +import java.net.URLStreamHandler;
24.16 +import java.net.URLStreamHandlerFactory;
24.17 +import java.util.HashMap;
24.18 +import java.util.Map;
24.19 +
24.20 +/** Support for special "memory://" URLs. Useful when testing network communication.
24.21 + *
24.22 + * @author Jaroslav Tulach
24.23 + */
24.24 +public final class MemoryURL extends URLStreamHandler {
24.25 + private MemoryURL() {
24.26 + }
24.27 +
24.28 + public static void initialize() {
24.29 + }
24.30 + static {
24.31 + class F implements URLStreamHandlerFactory {
24.32 + public URLStreamHandler createURLStreamHandler(String protocol) {
24.33 + if (protocol.startsWith("memory")) {
24.34 + return new MemoryURL();
24.35 + }
24.36 + return null;
24.37 + }
24.38 + }
24.39 + F f = new F();
24.40 + URL.setURLStreamHandlerFactory(f);
24.41 + }
24.42 +
24.43 + private static Map<String,InputStream> contents = new HashMap<String,InputStream>();
24.44 + private static Map<String,OutputStream> outputs = new HashMap<String,OutputStream>();
24.45 +
24.46 + public static void registerURL(String u, String content, OutputStream out) throws MalformedURLException {
24.47 + contents.put(u, new ByteArrayInputStream(content.getBytes()));
24.48 + outputs.put(u, out);
24.49 + }
24.50 +
24.51 + public static String getOutputForURL(String u) {
24.52 + OutputStream out = outputs.get(u);
24.53 + return out.toString();
24.54 + }
24.55 +
24.56 + protected URLConnection openConnection(URL u) throws IOException {
24.57 + return new MC(u);
24.58 + }
24.59 +
24.60 + private static final class MC extends URLConnection {
24.61 + private InputStream values;
24.62 + private OutputStream out;
24.63 +
24.64 + public MC(URL u) {
24.65 + super(u);
24.66 + out = outputs.get(u.toExternalForm());
24.67 + if (out == null) {
24.68 + out = new ByteArrayOutputStream();
24.69 + outputs.put(u.toExternalForm(), out);
24.70 + }
24.71 + }
24.72 +
24.73 + public void connect() throws IOException {
24.74 + if (values != null) {
24.75 + return;
24.76 + }
24.77 + values = contents.remove(url.toExternalForm());
24.78 + if (values == null) {
24.79 + throw new IOException("No such content: " + url);
24.80 + }
24.81 + }
24.82 +
24.83 + @Override
24.84 + public InputStream getInputStream() throws IOException {
24.85 + connect();
24.86 + return values;
24.87 + }
24.88 +
24.89 + @Override
24.90 + public OutputStream getOutputStream() throws IOException {
24.91 + if (out == null) {
24.92 + out = new ByteArrayOutputStream();
24.93 + }
24.94 + return out;
24.95 + }
24.96 + }
24.97 +}
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
25.2 +++ b/samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/usage/QueryStream.java Sun Feb 01 16:29:46 2009 +0100
25.3 @@ -0,0 +1,65 @@
25.4 +package org.apidesign.exceptions.trycatchredo.usage;
25.5 +
25.6 +import org.apidesign.exceptions.trycatchredo.api.UserQuestionException;
25.7 +import java.io.ByteArrayOutputStream;
25.8 +import java.io.IOException;
25.9 +import java.io.OutputStream;
25.10 +import javax.swing.JOptionPane;
25.11 +
25.12 +public final class QueryStream extends OutputStream {
25.13 + private ByteArrayOutputStream arr = new ByteArrayOutputStream();
25.14 + /** this field can be manipulated by the QueryException */
25.15 + Boolean reverse;
25.16 +
25.17 + @Override
25.18 + public synchronized void write(byte[] b, int off, int len) throws IOException {
25.19 + if (reverse == null) {
25.20 + throw new QueryException();
25.21 + }
25.22 + arr.write(b, off, len);
25.23 + }
25.24 +
25.25 + @Override
25.26 + public synchronized void write(int b) throws IOException {
25.27 + if (reverse == null) {
25.28 + throw new QueryException();
25.29 + }
25.30 + arr.write(b);
25.31 + }
25.32 +
25.33 + @Override
25.34 + public String toString() {
25.35 + if (reverse == null) {
25.36 + return "Reverse question was not answered yet!";
25.37 + }
25.38 + if (reverse) {
25.39 + StringBuilder sb = new StringBuilder();
25.40 + sb.append(arr.toString());
25.41 + sb.reverse();
25.42 + return sb.toString();
25.43 + }
25.44 + return arr.toString();
25.45 + }
25.46 +
25.47 + private class QueryException extends UserQuestionException {
25.48 +
25.49 + @Override
25.50 + public JOptionPane getQuestionPane() {
25.51 + JOptionPane p = new JOptionPane("Store in reverse way?");
25.52 + p.setOptionType(JOptionPane.YES_NO_CANCEL_OPTION);
25.53 + return p;
25.54 + }
25.55 +
25.56 + @Override
25.57 + public void confirm(Object option) {
25.58 + if (option.equals(JOptionPane.YES_OPTION)) {
25.59 + reverse = Boolean.TRUE;
25.60 + return;
25.61 + }
25.62 + if (option.equals(JOptionPane.NO_OPTION)) {
25.63 + reverse = Boolean.FALSE;
25.64 + return;
25.65 + }
25.66 + }
25.67 + }
25.68 +}
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
26.2 +++ b/samples/trycatchredo/test/org/apidesign/exceptions/trycatchredo/api/IOManagerTest.java Sun Feb 01 16:29:46 2009 +0100
26.3 @@ -0,0 +1,64 @@
26.4 +package org.apidesign.exceptions.trycatchredo.api;
26.5 +
26.6 +
26.7 +import org.apidesign.exceptions.trycatchredo.usage.MemoryURL;
26.8 +import java.awt.EventQueue;
26.9 +import java.awt.event.ActionEvent;
26.10 +import java.net.URL;
26.11 +import javax.swing.Action;
26.12 +import javax.swing.JOptionPane;
26.13 +import org.apidesign.exceptions.trycatchredo.usage.QueryStream;
26.14 +import org.junit.After;
26.15 +import org.junit.Before;
26.16 +import org.junit.Test;
26.17 +import static org.junit.Assert.*;
26.18 +
26.19 +/**
26.20 + *
26.21 + * @author Jaroslav Tulach <jtulach@netbeans.org>
26.22 + */
26.23 +public class IOManagerTest {
26.24 +
26.25 + public IOManagerTest() {
26.26 + }
26.27 +
26.28 + @Before
26.29 + public void setUp() {
26.30 + MemoryURL.initialize();
26.31 + }
26.32 +
26.33 + @After
26.34 + public void tearDown() {
26.35 + }
26.36 +
26.37 + @Test
26.38 + public void simpleWrite() throws Exception {
26.39 + URL u = new URL("memory://simpleWrite.txt");
26.40 + MemoryURL.registerURL(u.toExternalForm(), "", null);
26.41 + final Action a = IOManager.createSaveAction(u, "Hello World!");
26.42 + EventQueue.invokeAndWait(new Runnable() {
26.43 + public void run() {
26.44 + a.actionPerformed(new ActionEvent(this, 0, ""));
26.45 + }
26.46 + });
26.47 + String out = MemoryURL.getOutputForURL(u.toExternalForm());
26.48 + assertEquals("Hello World!", out);
26.49 + }
26.50 +
26.51 + @Test
26.52 + public void writeWithAQuestion() throws Exception {
26.53 + URL u = new URL("memory://queryEncoding.txt");
26.54 +
26.55 + MemoryURL.registerURL(u.toExternalForm(), "", new QueryStream());
26.56 + final Action a = IOManager.createSaveAction(u, "Ask a Question");
26.57 + // simulate that the user clicks Yes to the reverse question in the dialog
26.58 + IOManager.setVisibleOption = JOptionPane.YES_OPTION;
26.59 + EventQueue.invokeAndWait(new Runnable() {
26.60 + public void run() {
26.61 + a.actionPerformed(new ActionEvent(this, 0, ""));
26.62 + }
26.63 + });
26.64 + String out = MemoryURL.getOutputForURL(u.toExternalForm());
26.65 + assertEquals("Text is reversed", "noitseuQ a ksA", out);
26.66 + }
26.67 +}
26.68 \ No newline at end of file