Codebase list jtharness / upstream/6.0-b02
New upstream version 6.0-b02 Emmanuel Bourg 4 years ago
346 changed file(s) with 3234 addition(s) and 10165 deletion(s). Raw diff Collapse all Expand all
44 dc134cf8fb40b026885020cb70d62b492bc55547 jt4.6
55 142b98326aafe755c2460af671bcf0ee834b97cc jt5.0
66 014e959a8f2dd58020517c715ce7a0aca60c9a2d jt5.0-b01
7 032f60f06c6b98f6f8bd60557ed2d3f4ccad6888 jt6.0-b01
00 <?xml version='1.0' encoding='ISO-8859-1' ?>
11 <!--
2 Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
2 Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
33 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
55 This code is free software; you can redistribute it and/or modify it
104104 <exclude name="com/sun/javatest/servlets/*.java" unless="servlet.present"/>
105105 </patternset>
106106
107 <patternset id="test.packages">
108 <include name="com/sun/jct/utils/copyrightcheck/**" />
109 </patternset>
107 <patternset id="test.packages">
108 <include name="com/sun/jct/utils/copyrightcheck/**" />
109 </patternset>
110110
111111 <patternset id="javatest.jdk11.files">
112112 <include name="com/sun/javatest/Command.java"/>
190190 </fileset>
191191 </copy>
192192
193 <replace file="${BUILD_DIR}/binaries/ReleaseNotes-jtharness.html">
194 <replacetoken><![CDATA[href="../../legal/copyright.txt"]]></replacetoken>
193 <replace file="${BUILD_DIR}/binaries/ReleaseNotes-jtharness.html">
194 <replacetoken><![CDATA[href="../../legal/copyright.txt"]]></replacetoken>
195195 <replacevalue><![CDATA[href="legal/copyright.txt"]]></replacevalue>
196 </replace>
197
198 <replace file="${BUILD_DIR}/binaries/ReleaseNotes-jtharness.html">
199 <replacetoken><![CDATA[href="../../document.css"]]></replacetoken>
196 </replace>
197
198 <replace file="${BUILD_DIR}/binaries/ReleaseNotes-jtharness.html">
199 <replacetoken><![CDATA[href="../../document.css"]]></replacetoken>
200200 <replacevalue><![CDATA[href="doc/document.css"]]></replacevalue>
201 </replace>
202
203 <replace file="${BUILD_DIR}/binaries/ReleaseNotes-jtharness.html"
201 </replace>
202
203 <replace file="${BUILD_DIR}/binaries/ReleaseNotes-jtharness.html"
204204 token="BUILD_VERSION"
205205 value="${build.version}"/>
206
207 <replace file="${BUILD_DIR}/binaries/ReleaseNotes-jtharness.html"
208 token="BUILD_DATE"
209 value="${build.date}"/>
206210
207211 <!-- clone release notes as index.html for convenience -->
208212 <copy tofile="${BUILD_DIR}/binaries/index.html"
286290 destdir="${build.classes}"
287291 classpath="${jdk14.classpath}:${jcommjar}">
288292 <patternset refid="javatest.packages"/>
293 <compilerarg value="-version"/>
294 <compilerarg value="-Xlint:rawtypes"/>
295 <compilerarg value="-Xlint:cast"/>
289296 </javac>
290297 <copy todir="${build.classes}">
291298 <fileset dir="${legal.dir}">
302309 destdir="${build.classes}"
303310 classpath="${jdk14.classpath}">
304311 <patternset refid="test.packages"/>
305 </javac>
306 </target>
312 <compilerarg value="-version"/>
313 <compilerarg value="-Xlint:rawtypes"/>
314 <compilerarg value="-Xlint:cast"/>
315 </javac>
316 </target>
307317
308318 <target name="compile.junit.classes" if="jar.junit.dependencies.present" depends="verify-dependencies, compile.classes,compile.junit.resources">
309319 <mkdir dir="${build.junit.classes}"/>
312322 destdir="${build.junit.classes}"
313323 classpath="${jdk14.classpath}:${build.classes}:${asmjar}:${asmcommonsjar}:${junitlib}">
314324 <patternset refid="javatest.junit.packages"/>
325 <compilerarg value="-version"/>
326 <compilerarg value="-Xlint:rawtypes"/>
327 <compilerarg value="-Xlint:cast"/>
315328 </javac>
316329
317330 <copy todir="${build.junit.classes}">
331344 <patternset refid="javatest.resources"/>
332345 </fileset>
333346 </copy>
334 <mkdir dir="${build.classes}/META-INF/"/>
347 <mkdir dir="${build.classes}/META-INF/"/>
335348 <buildinfo/>
336349 <copy file="${src.dir}/com/sun/javatest/tool/i18n.properties"
337350 tofile="${build.classes}/com/sun/javatest/tool/i18n_fr.properties"/>
338 <mkdir dir="${build.classes}/META-INF/services"/>
351 <mkdir dir="${build.classes}/META-INF/services"/>
339352 <copy file="${build.dir}/JavaTest.cmdMgrs.lst" tofile="${build.classes}/META-INF/services/com.sun.javatest.tool.CommandManager.lst"/>
340353 <copy file="${build.dir}/JavaTest.toolMgrs.lst" tofile="${build.classes}/META-INF/services/com.sun.javatest.tool.ToolManager.lst"/>
341354 <copy file="${build.dir}/com.sun.javatest.report.ReportFormat" tofile="${build.classes}/META-INF/services/com.sun.javatest.report.ReportFormat"/>
347360 <patternset refid="javatest.junit.resources"/>
348361 </fileset>
349362 </copy>
350 <mkdir dir="${build.classes}/META-INF/"/>
363 <mkdir dir="${build.classes}/META-INF/"/>
351364 <buildinfo/>
352365 </target>
353366
407420 </java>
408421 </target>
409422
410 <target name="test-sanity" depends="test-sanity-version,test-sanity-simpletck" />
411
412 <target name="test-sanity-version" depends="jar">
413 <java fork="true" failonerror="false" classname="${run.class}"
414 outputproperty="test.sanity.version.output"
415 resultproperty="test.sanity.version.result">
416 <classpath>
417 <path path="${BUILD_DIR}/binaries/lib/javatest.jar"/>
418 </classpath>
419 <arg value="-version"/>
420 </java>
421
422 <property name="test-sanity-version-pattern" value="JT Harness, version ${build.version}.*\nCopyright \(C\) 1996-[0-9][0-9][0-9][0-9] Sun Microsystems, Inc\. All rights reserved" />
423
424 <condition property="test.sanity.version.success">
425 <and>
426 <equals arg1="${test.sanity.version.result}" arg2="0" />
427 <!--<matches singleline="true" string="${test.sanity.version.output}" pattern="${test-sanity-version-pattern}" />-->
428 </and>
429 </condition>
430 <fail unless="test.sanity.version.success">
431 "java ${run.class} -version" exited with code "${test.sanity.version.result}"
432
433 The output:
434 ${test.sanity.version.output}
435
436 Pattern: ${test-sanity-version-pattern}</fail>
437 </target>
438
439 <target name="test-sanity-simpletck" depends="jar,build-examples">
440 <property name="libs" value="${BUILD_DIR}/binaries/examples/tutorial/demots/lib" />
441 <delete dir="${build.tmp}/sanity-demo-wd" />
442 <java fork="true" failonerror="false" jar="${BUILD_DIR}/binaries/lib/javatest.jar"
443 outputproperty="test.sanity.simpletck.output"
444 resultproperty="test.sanity.simpletck.result">
445 <classpath>
446 <path path="${libs}/demots.jar" />
447 <path path="${libs}/demoapi.jar" />
448 </classpath>
449 <arg line="-verbose:max -ts ${BUILD_DIR}/binaries/examples/tutorial/demots/ -wd -create ${build.tmp}/sanity-demo-wd -config ${libs}/demots.jti -set demoTS.jvm ${java.home}/bin/java -excludelist lib/demo.jtx -runtests -writeReport report" />
450 </java>
451
452 <property name="test-sanity-simpletck-pattern" value="Test results: passed: 16" />
453
454 <condition property="test.sanity.simpletck.success">
455 <and>
456 <equals arg1="${test.sanity.simpletck.result}" arg2="0" />
457 <!--<matches singleline="true" string="${test.sanity.simpletck.output}" pattern="${test-sanity-simpletck-pattern}" />-->
458 </and>
459 </condition>
460 <fail unless="test.sanity.simpletck.success">
461 Simple tck run exited with code "${test.sanity.simpletck.result}"
462
463 The output:
464 ${test.sanity.simpletck.output}
465
466 Pattern: ${test-sanity-simpletck-pattern}</fail>
467 </target>
423 <target name="test-sanity" depends="test-sanity-version,test-sanity-simpletck" />
424
425 <target name="test-sanity-version" depends="jar">
426 <java fork="true" failonerror="false" classname="${run.class}"
427 outputproperty="test.sanity.version.output"
428 resultproperty="test.sanity.version.result">
429 <classpath>
430 <path path="${BUILD_DIR}/binaries/lib/javatest.jar"/>
431 </classpath>
432 <arg value="-version"/>
433 </java>
434
435 <property name="test-sanity-version-pattern" value="JT Harness, version ${build.version}.*\nCopyright \(C\) 1996-[0-9][0-9][0-9][0-9] Sun Microsystems, Inc\. All rights reserved" />
436
437 <condition property="test.sanity.version.success">
438 <and>
439 <equals arg1="${test.sanity.version.result}" arg2="0" />
440 <!--<matches singleline="true" string="${test.sanity.version.output}" pattern="${test-sanity-version-pattern}" />-->
441 </and>
442 </condition>
443 <fail unless="test.sanity.version.success">
444 "java ${run.class} -version" exited with code "${test.sanity.version.result}"
445
446 The output:
447 ${test.sanity.version.output}
448
449 Pattern: ${test-sanity-version-pattern}</fail>
450 </target>
451
452 <target name="test-sanity-simpletck" depends="jar,build-examples">
453 <property name="libs" value="${BUILD_DIR}/binaries/examples/tutorial/demots/lib" />
454 <delete dir="${build.tmp}/sanity-demo-wd" />
455 <java fork="true" failonerror="false" jar="${BUILD_DIR}/binaries/lib/javatest.jar"
456 outputproperty="test.sanity.simpletck.output"
457 resultproperty="test.sanity.simpletck.result">
458 <classpath>
459 <path path="${libs}/demots.jar" />
460 <path path="${libs}/demoapi.jar" />
461 </classpath>
462 <arg line="-verbose:max -ts ${BUILD_DIR}/binaries/examples/tutorial/demots/ -wd -create ${build.tmp}/sanity-demo-wd -config ${libs}/demots.jti -set demoTS.jvm ${java.home}/bin/java -excludelist lib/demo.jtx -runtests -writeReport report" />
463 </java>
464
465 <property name="test-sanity-simpletck-pattern" value="Test results: passed: 16" />
466
467 <condition property="test.sanity.simpletck.success">
468 <and>
469 <equals arg1="${test.sanity.simpletck.result}" arg2="0" />
470 <!--<matches singleline="true" string="${test.sanity.simpletck.output}" pattern="${test-sanity-simpletck-pattern}" />-->
471 </and>
472 </condition>
473 <fail unless="test.sanity.simpletck.success">
474 Simple tck run exited with code "${test.sanity.simpletck.result}"
475
476 The output:
477 ${test.sanity.simpletck.output}
478
479 Pattern: ${test-sanity-simpletck-pattern}</fail>
480 </target>
468481
469482 <target name="test-nohead" depends="dist" description="Runs all tests, which do not need display">
470483 <antcall target="test-statusmsg"/>
530543 <include name="com/sun/jct/utils/glossarygen/**"/>
531544 <include name="com/sun/jct/utils/indexgen/**"/>
532545 <include name="com/sun/jct/utils/mapmerge/**"/>
546 <compilerarg value="-version"/>
547 <compilerarg value="-Xlint:rawtypes"/>
548 <compilerarg value="-Xlint:cast"/>
533549 </javac>
534550 </target>
535551
545561 <javac encoding="iso-8859-1" debug="true" source="1.6"
546562 srcdir="${exam.dir}/tutorial/demoapi"
547563 destdir="${build.tmp}/${exam.dir}/demoapi">
564 <compilerarg value="-version"/>
565 <compilerarg value="-Xlint:rawtypes"/>
566 <compilerarg value="-Xlint:cast"/>
548567 </javac>
549568 <jar destfile="${build.examples}/demots/lib/demoapi.jar"
550569 basedir="${build.tmp}/${exam.dir}/demoapi" index="false">
562581 srcdir="${exam.dir}/tutorial/simpleTags"
563582 destdir="${build.tmp}/${exam.dir}/simpleTags"
564583 classpath="${BUILD_DIR}/binaries/lib/javatest.jar:${build.examples}/demots/lib/demoapi.jar">
584 <compilerarg value="-version"/>
585 <compilerarg value="-Xlint:rawtypes"/>
586 <compilerarg value="-Xlint:cast"/>
565587 </javac>
566588 <copy todir="${build.tmp}/${exam.dir}/simpleTags">
567589 <fileset dir="${exam.dir}/tutorial/simpleTags/src">
588610 </copy>
589611
590612
591 </target>
613 </target>
592614
593615
594616 <target name="build-services-ts" depends="build-tutorial">
595 <property name="services.ts" location="${BUILD_DIR}/binaries/examples/services_ts"/>
596 <mkdir dir="${build.tmp}/${exam.dir}/services_demo/classes"/>
617 <property name="services.ts" location="${BUILD_DIR}/binaries/examples/services_ts"/>
618 <mkdir dir="${build.tmp}/${exam.dir}/services_demo/classes"/>
597619 <mkdir dir="${services.ts}/lib"/>
598620
599 <copy todir="${services.ts}/lib">
600 <fileset file="${BUILD_DIR}/binaries/lib/javatest.jar"/>
621 <copy todir="${services.ts}/lib">
622 <fileset file="${BUILD_DIR}/binaries/lib/javatest.jar"/>
601623 <fileset file="${build.examples}/demots/lib/demoapi.jar"/>
602 </copy>
624 </copy>
603625
604626
605627 <javac encoding="iso-8859-1" debug="true"
606 srcdir="${exam.dir}/services_demo/src"
607 destdir="${build.tmp}/${exam.dir}/services_demo/classes"
608 classpath="${BUILD_DIR}/binaries/lib/javatest.jar">
628 srcdir="${exam.dir}/services_demo/src"
629 destdir="${build.tmp}/${exam.dir}/services_demo/classes"
630 classpath="${BUILD_DIR}/binaries/lib/javatest.jar">
631 <compilerarg value="-version"/>
632 <compilerarg value="-Xlint:rawtypes"/>
633 <compilerarg value="-Xlint:cast"/>
609634 </javac>
610 <copy todir="${build.tmp}/${exam.dir}/services_demo/classes">
611 <fileset dir="${exam.dir}/services_demo/src">
612 <include name="**/moreinfo/**"/>
635 <copy todir="${build.tmp}/${exam.dir}/services_demo/classes">
636 <fileset dir="${exam.dir}/services_demo/src">
637 <include name="**/moreinfo/**"/>
613638 <include name="**/*.properties"/>
614 </fileset>
639 </fileset>
615640 </copy>
616641
617 <jar destfile="${services.ts}/lib/jtservices.jar"
618 basedir="${build.tmp}/${exam.dir}/services_demo/classes" index="false">
619 <manifest>
642 <jar destfile="${services.ts}/lib/jtservices.jar"
643 basedir="${build.tmp}/${exam.dir}/services_demo/classes" index="false">
644 <manifest>
620645 <attribute name="Built-By" value="${user.name}"/>
621 <attribute name="Main-Class" value="${run.class}"/>
622 </manifest>
646 <attribute name="Main-Class" value="${run.class}"/>
647 </manifest>
623648 </jar>
624649
625 <copy todir="${services.ts}">
626 <fileset dir="${exam.dir}/services_demo/services_ts"/>
650 <copy todir="${services.ts}">
651 <fileset dir="${exam.dir}/services_demo/services_ts"/>
627652 </copy>
628653
629 </target>
630
631
632 <!--
633 ********** copyright checker **********************************************
634 -->
635 <property file="build/copyright.properties"/>
636 <target name="test-copyrights" depends="compile.test.copyright.classes">
637 <taskdef name="checkCopyrights" classpath="${build.classes}" classname="com.sun.jct.utils.copyrightcheck.CheckCopyrights"/>
638 <checkCopyrights pattern="${copyright.pattern}" dir="${src.dir}" includes="${copyright.includes}" excludes="${copyright.excludes}" failOnError="yes"/>
639 </target>
654 </target>
655
656
657 <!--
658 ********** copyright checker **********************************************
659 -->
660 <property file="build/copyright.properties"/>
661 <target name="test-copyrights" depends="compile.test.copyright.classes">
662 <taskdef name="checkCopyrights" classpath="${build.classes}" classname="com.sun.jct.utils.copyrightcheck.CheckCopyrights"/>
663 <checkCopyrights pattern="${copyright.pattern}" dir="${src.dir}" includes="${copyright.includes}" excludes="${copyright.excludes}" failOnError="yes"/>
664 </target>
640665 </project>
00 com.sun.javatest.report.HTMLReport
11 com.sun.javatest.report.PlainTextReport
22 com.sun.javatest.report.XMLReport
3 com.sun.javatest.report.COFReport
43 com.sun.javatest.report.CustomReportFormat
54
4141
4242 <h4 class="h4.title">
4343 Version BUILD_VERSION<br>
44 June 2013
44 BUILD_DATE
4545 <hr class="hr.light">
4646 <p class="navtop" ><a href="#_maincontent">Skip TOC&nbsp;<img src="shared/downicon.gif" alt="skip TOC"></a></p>
4747 <h2>Table of Contents</h2>
135135 <th scope="col"> Notes </th>
136136 </tr>
137137 <tr valign="top">
138 <td> JDK&#8482; version 1.6 or later </td>
138 <td> JDK&#8482; version 7 or later </td>
139139 <td> <a href="http://www.oracle.com/technetwork/java/javase/overview/index.html">http://www.oracle.com/technetwork/java/javase/overview/index.html</a>
140140 </td>
141141 <td>See <a href="#secjava7">Security Exceptions With Java 7 on Windows</a> for known issues with Java 7.
203203 <h2>Security Exceptions With Java 7 on Windows</h2>
204204 <p>When using Java 7 on Windows, the harness might experience problems executing particular parts of the Java 7 APIs because, by default, the harness security manager denies access to certain properties. The problem might manifest as one of the <a href="#knownexcept">Known Exceptions</a> reproduced below (see <a href="#knownexceptio">java.io.IOException</a> and <a href="#knownexceptsocket">Socket Exception Error</a>). </p>
205205
206 <p>There are three ways to workaround the security exceptions:</p>
206 <p>There are ways to workaround the security exceptions:</p>
207207 <ol>
208 <li><p><b>Use the Java 6 runtime instead.</b> Java 6 is the target execution platform for the harness and is also the minimum Java version supported by the harness.</p></li>
209208 <li><p><b>Set the <code>javatest.security.allowPropertiesAccess</code> system property to <code>"true"</code> at startup.</b> The harness security manager (JavaTestSecurityManager) is automatically installed at startup, and its default settings deny access to the System Properties object. You can manually allow access to harness properties as follows:<p>
210209 <p><code>java -Djavatest.security.allowPropertiesAccess=true ...</code></p></li>
211210 <li><p><b>Enable and disable property access programatically.</b> The following code temporarily allows properties access until after the code in the <code>try</code> block is executed. Beware of race conditions when using this code.</p>
6464 * Create an empty checklist.
6565 */
6666 public Checklist() {
67 sections = new TreeMap();
67 sections = new TreeMap<>();
6868 }
6969
7070 /**
9090 * added for the given section
9191 */
9292 public String[] getSectionMessages(String sectionName) {
93 Vector v = (Vector) (sections.get(sectionName));
93 Vector<String> v = sections.get(sectionName);
9494 if (v == null)
9595 return null;
9696 String[] msgs = new String[v.size()];
103103 * @param item The Item to be added
104104 */
105105 public void add(Item item) {
106 Vector msgs = (Vector) (sections.get(item.sectionName));
106 Vector<String> msgs = sections.get(item.sectionName);
107107 if (msgs == null) {
108 msgs = new Vector();
108 msgs = new Vector<>();
109109 sections.put(item.sectionName, msgs);
110110 }
111111 msgs.add(item.text);
119119 return sections.isEmpty();
120120 }
121121
122 private Map sections; // section name to vector of messages
122 private Map<String, Vector<String>> sections; // section name to vector of messages
123123 }
104104 if (choices == null)
105105 throw new NullPointerException();
106106
107 for (int i = 0; i < choices.length; i++) {
108 if (choices[i] == null)
107 for (String choice : choices) {
108 if (choice == null)
109109 throw new NullPointerException();
110110 }
111111
346346 * the tag as the key.
347347 * @param data The map from which to load the value for this question.
348348 */
349 protected void load(Map data) {
350 Object o = data.get(tag);
351 if (o != null && o instanceof String)
352 setValue((String)o);
349 protected void load(Map<String, String> data) {
350 String o = data.get(tag);
351 if (o != null)
352 setValue(o);
353353 }
354354
355355 /**
357357 * the tag as the key.
358358 * @param data The map in which to save the value for this question.
359359 */
360 protected void save(Map data) {
360 protected void save(Map<String, String> data) {
361361 data.put(tag, getStringValue());
362362 }
363363
137137 interview.updatePath(this);
138138 interview.setEdited(true);
139139 } else {
140 for (int i = 0; i < choices.length; i++) {
141 if (value.equals(choices[i])) {
142 value = choices[i];
140 for (String choice : choices) {
141 if (value.equals(choice)) {
142 value = choice;
143143 return;
144144 }
145145 }
303303 }
304304 else {
305305 // try and canonicalize newValue to one of the specified choices
306 for (int i = 0; i < choices.length; i++) {
307 if (newValue.equals(choices[i])) {
308 newValue = choices[i];
306 for (String choice : choices) {
307 if (newValue.equals(choice)) {
308 newValue = choice;
309309 break;
310310 }
311311 }
320320
321321 public boolean isValueValid() {
322322 // value is valid if it matches one of the specified choices
323 for (int i = 0; i < choices.length; i++) {
324 if (value == null ? choices[i] == null : value.equals(choices[i]))
323 for (String choice : choices) {
324 if (value == null ? choice == null : value.equals(choice))
325325 return true;
326326 }
327327 return false;
344344 * the tag as the key.
345345 * @param data The map from which to load the value for this question.
346346 */
347 protected void load(Map data) {
348 Object o = data.get(tag);
349 if (o instanceof String)
350 setValue((String)o);
347 protected void load(Map<String, String> data) {
348 String o = data.get(tag);
349 setValue(o);
351350 }
352351
353352 /**
355354 * the tag as the key.
356355 * @param data The map in which to save the value for this question.
357356 */
358 protected void save(Map data) {
357 protected void save(Map<String, String> data) {
359358 if (value != null)
360359 data.put(tag, value);
361360 }
125125 */
126126 @Override
127127 public void setValue(String paths) {
128 setValue(paths == null ? (File[])null : split(paths));
128 setValue(paths == null ? null : split(paths));
129129 }
130130
131131 /**
314314 * the tag as the key.
315315 * @param data The map from which to load the value for this question.
316316 */
317 protected void load(Map data) {
317 protected void load(Map<String, String> data) {
318318 Object o = data.get(tag);
319319 if (o instanceof File[])
320320 setValue((File[])o);
339339
340340 char sep = (s.indexOf('\n') == -1 ? ' ' : '\n');
341341
342 ArrayList v = new ArrayList();
342 ArrayList<File> v = new ArrayList<>();
343343 int start = -1;
344344 for (int i = 0; i < s.length(); i++) {
345345 if (s.charAt(i) == sep) {
366366 * the tag as the key.
367367 * @param data The map in which to save the value for this question.
368368 */
369 protected void save(Map data) {
369 protected void save(Map<String, String> data) {
370370 if (value != null)
371371 data.put(tag, join(value));
372372 }
6666 */
6767 public void setSuggestions(File[] newSuggestions) {
6868 if (newSuggestions != null) {
69 for (int i = 0; i < newSuggestions.length; i++) {
70 if (newSuggestions[i] == null)
69 for (File newSuggestion : newSuggestions) {
70 if (newSuggestion == null)
7171 throw new IllegalArgumentException();
7272 }
7373 }
130130 * @see #getValue
131131 */
132132 public void setValue(String path) {
133 setValue(path == null ? (File)null : new File(path));
133 setValue(path == null ? null : new File(path));
134134 }
135135
136136 /**
260260 * the tag as the key.
261261 * @param data The map from which to load the value for this question.
262262 */
263 protected void load(Map data) {
263 protected void load(Map<String, String> data) {
264264 Object o = data.get(tag);
265265 if (o instanceof File)
266266 setValue((File)o);
273273 * the tag as the key.
274274 * @param data The map in which to save the value for this question.
275275 */
276 protected void save(Map data) {
276 protected void save(Map<String, String> data) {
277277 if (value != null)
278278 data.put(tag, value.toString());
279279 }
351351 * the tag as the key.
352352 * @param data The map from which to load the value for this question.
353353 */
354 protected void load(Map data) {
355 Object o = data.get(tag);
354 protected void load(Map<String, String> data) {
355 String o = data.get(tag);
356356 if (o == null)
357357 clear();
358 else if (o instanceof Float)
359 setValue(((Float)o).floatValue());
360 else if (o instanceof String) {
358 else {
361359 //get locate to parse string with
362360 Locale l = Interview.readLocale(data);
363361 try {
364 setValue((String) o, l);
362 setValue(o, l);
365363 }
366364 catch (Interview.Fault e) {
367365 throw new Error(e);
374372 * the tag as the key.
375373 * @param data The map in which to save the value for this question.
376374 */
377 protected void save(Map data) {
375 protected void save(Map<String, String> data) {
378376 data.put(tag, getStringValue());
379377 }
380378
3232 import java.net.URL;
3333 import java.text.MessageFormat;
3434 import java.util.HashMap;
35 import java.util.Map;
3536 import java.util.ResourceBundle;
3637
3738 /**
9697
9798 HelpSet hs = getHelpSet(i);
9899 if (hs != null) {
99 HashMap m = hs.getLocalMap();
100 Map<String, URL> m = hs.getLocalMap();
100101 if (m != null) {
101102 helpId = HelpID.create(key, hs);
102103 //System.err.println("Q: FOUND int:" + i.getTag() + " key:" + key + " helpId:" + helpId);
4646 *
4747 * @throws com.sun.interview.Interview.Fault if something went wrong
4848 */
49 public Object createHelpSetObject(String name, Class c) throws Interview.Fault;
49 public Object createHelpSetObject(String name, Class<?> c) throws Interview.Fault;
5050
5151 /**
5252 * Creates an instance of HelpSet.
7777 static class Default implements HelpSetFactory {
7878 private static final Object EMPTY = new Object();
7979
80 public Object createHelpSetObject(String name, Class c) throws Fault {
80 public Object createHelpSetObject(String name, Class<?> c) throws Fault {
8181 return EMPTY;
8282 }
8383
336336 * the tag as the key.
337337 * @param data The map from which to load the value for this question.
338338 */
339 protected void load(Map data) {
340 Object o = data.get(tag);
341 if (o instanceof InetAddress) {
342 setValue((InetAddress) o);
343 }
344 else if (o instanceof String) {
345 try {
346 setValue((String) o);
347 }
348 catch (Interview.Fault e) {
349 // never thrown. but just in case...
350 throw new Error(e);
351 }
339 protected void load(Map<String, String> data) {
340 String o = data.get(tag);
341 try {
342 setValue(o);
343 }
344 catch (Interview.Fault e) {
345 // never thrown. but just in case...
346 throw new Error(e);
352347 }
353348 }
354349
357352 * the tag as the key.
358353 * @param data The map in which to save the value for this question.
359354 */
360 protected void save(Map data) {
355 protected void save(Map<String, String> data) {
361356 String s = getStringValue();
362357 if (s != null)
363358 data.put(tag, s);
326326 * the tag as the key.
327327 * @param data The map from which to load the value for this question.
328328 */
329 protected void load(Map data) {
330 Object o = data.get(tag);
329 protected void load(Map<String, String> data) {
330 String o = data.get(tag);
331331 if (o == null)
332332 clear();
333 else if (o instanceof Integer)
334 setValue(((Integer)o).intValue());
335 else if (o instanceof String) {
333 else {
336334 //get locate to parse string with
337335 Locale l = Interview.readLocale(data);
338336 try {
339 setValue((String) o, l);
337 setValue(o, l);
340338 }
341339 catch (Interview.Fault e) {
342340 throw new Error(e); // should not happen
349347 * the tag as the key.
350348 * @param data The map in which to save the value for this question.
351349 */
352 protected void save(Map data) {
350 protected void save(Map<String, String> data) {
353351 data.put(tag, getStringValue());
354352 }
355353
279279 {
280280 // name is not null
281281 if (!name.equals(bundleName)) {
282 Class c = getClass();
282 Class<?> c = getClass();
283283 final ClassLoader cl = c.getClassLoader();
284284 final String rn;
285285 if (name.startsWith("/"))
428428 */
429429 private static HelpSetFactory createHelpFactory() {
430430 try {
431 Class factoryClass = Class.forName("com.sun.interview.JavaHelpFactory");
431 Class<?> factoryClass = Class.forName("com.sun.interview.JavaHelpFactory");
432432 return (HelpSetFactory) factoryClass.newInstance();
433433 } catch (ClassNotFoundException e) {
434434 return HelpSetFactory.DEFAULT;
525525 return this;
526526
527527 for (int i = 0; i < children.size(); i++) {
528 Interview c = (Interview) (children.elementAt(i));
528 Interview c = children.elementAt(i);
529529 Interview iv = c.getInterview0(t);
530530 if (iv != null)
531531 return iv;
534534 return null;
535535 }
536536
537 Set getInterviews() {
538 Set s = new HashSet();
537 Set<Interview> getInterviews() {
538 Set<Interview> s = new HashSet<>();
539539 getInterviews0(s);
540540 return s;
541541 }
542542
543 private void getInterviews0(Set s) {
543 private void getInterviews0(Set<Interview> s) {
544544 s.add(this);
545545 for (int i = 0; i < children.size(); i++) {
546 Interview child = (Interview) (children.elementAt(i));
546 Interview child = children.elementAt(i);
547547 child.getInterviews0(s);
548548 }
549549 }
943943 * @see #getPathToCurrent
944944 */
945945 public Question[] getPath() {
946 Vector v = new Vector();
946 Vector<Question> v = new Vector<>();
947947 iteratePath0(v, true, true, true);
948948 Question[] p = new Question[v.size()];
949949 v.copyInto(p);
958958 * @see #getPath
959959 */
960960 public Question[] getPathToCurrent() {
961 Vector v = new Vector();
961 Vector<Question> v = new Vector<>();
962962 iteratePath0(v, true, false, true);
963963 Question[] p = new Question[v.size()];
964964 v.copyInto(p);
999999 * @return an Iterator for the questions on the current path
10001000 * @see #iteratePathToCurrent
10011001 */
1002 public Iterator iteratePath(boolean flattenNestedInterviews) {
1003 Vector v = new Vector();
1002 public Iterator<Question> iteratePath(boolean flattenNestedInterviews) {
1003 Vector<Question> v = new Vector<>();
10041004 iteratePath0(v, flattenNestedInterviews, true, true);
10051005 return v.iterator();
10061006 }
10161016 * up to and including the current question
10171017 * @see #iteratePath
10181018 */
1019 public Iterator iteratePathToCurrent(boolean flattenNestedInterviews) {
1020 Vector v = new Vector();
1019 public Iterator<Question> iteratePathToCurrent(boolean flattenNestedInterviews) {
1020 Vector<Question> v = new Vector<>();
10211021 iteratePath0(v, flattenNestedInterviews, false, true);
10221022 return v.iterator();
10231023 }
10241024
10251025
1026 private void iteratePath0(List l, boolean flattenNestedInterviews, boolean all, boolean addFinal) {
1026 private void iteratePath0(List<Question> l, boolean flattenNestedInterviews, boolean all, boolean addFinal) {
10271027 ensurePathInitialized();
10281028
10291029 int n = (all ? path.size() : currIndex + 1);
11021102 * recursively, in all child interviews.
11031103 * @return a set of all questions in this and every child interview.
11041104 */
1105 public Set getQuestions() {
1106 Set s = new HashSet();
1105 public Set<Question> getQuestions() {
1106 Set<Question> s = new HashSet<>();
11071107 getQuestions0(s);
11081108 return s;
11091109 }
11101110
1111 private void getQuestions0(Set s) {
1111 private void getQuestions0(Set<Question> s) {
11121112 s.addAll(allQuestions.values());
11131113
11141114 for (int i = 0; i < children.size(); i++) {
1115 Interview child = (Interview) (children.elementAt(i));
1115 Interview child = children.elementAt(i);
11161116 child.getQuestions0(s);
11171117 }
11181118 }
11221122 * recursively, in all child interviews.
11231123 * @return a map containing all questions in this and every child interview.
11241124 */
1125 public Map getAllQuestions() {
1126 Map m = new LinkedHashMap();
1125 public Map<String, Question> getAllQuestions() {
1126 Map<String, Question> m = new LinkedHashMap<>();
11271127 getAllQuestions0(m);
11281128 return m;
11291129 }
11301130
1131 private void getAllQuestions0(Map m) {
1131 private void getAllQuestions0(Map<String, Question> m) {
11321132 m.putAll(allQuestions);
11331133
11341134 for (int i = 0; i < children.size(); i++) {
1135 Interview child = (Interview) (children.elementAt(i));
1135 Interview child = children.elementAt(i);
11361136 child.getAllQuestions0(m);
11371137 }
11381138 }
11441144 * items, and false otherwise.
11451145 */
11461146 public boolean isChecklistEmpty() {
1147 for (Iterator iter = iteratePath(true); iter.hasNext(); ) {
1148 Question q = (Question) (iter.next());
1147 for (Iterator<Question> iter = iteratePath(true); iter.hasNext(); ) {
1148 Question q = iter.next();
11491149 Checklist.Item[] items = q.getChecklistItems();
11501150 if (items != null && items.length > 0)
11511151 return false;
11631163 */
11641164 public Checklist createChecklist() {
11651165 Checklist c = new Checklist();
1166 for (Iterator iter = iteratePath(true); iter.hasNext(); ) {
1167 Question q = (Question) (iter.next());
1166 for (Iterator<Question> iter = iteratePath(true); iter.hasNext(); ) {
1167 Question q = iter.next();
11681168 Checklist.Item[] items = q.getChecklistItems();
11691169 if (items != null) {
1170 for (int i = 0; i < items.length; i++)
1171 c.add(items[i]);
1170 for (Checklist.Item item : items) c.add(item);
11721171 }
11731172 }
11741173 return c;
12321231 throw new NullPointerException();
12331232
12341233 if (allMarkers == null)
1235 allMarkers = new HashMap();
1236
1237 Set markersForName = (Set) (allMarkers.get(name));
1234 allMarkers = new HashMap<>();
1235
1236 Set<Question> markersForName = allMarkers.get(name);
12381237 if (markersForName == null) {
1239 markersForName = new HashSet();
1238 markersForName = new HashSet<>();
12401239 allMarkers.put(name, markersForName);
12411240 }
12421241
12611260 if (allMarkers == null)
12621261 return;
12631262
1264 Set markersForName = (Set) (allMarkers.get(name));
1263 Set<Question> markersForName = allMarkers.get(name);
12651264 if (markersForName == null)
12661265 return;
12671266
12871286 if (allMarkers == null)
12881287 return false;
12891288
1290 Set markersForName = (Set) (allMarkers.get(name));
1289 Set<Question> markersForName = allMarkers.get(name);
12911290 if (markersForName == null)
12921291 return false;
12931292
13341333 if (allMarkers == null) // no markers at all
13351334 return;
13361335
1337 Set markersForName = (Set) (allMarkers.get(name));
1336 Set<Question> markersForName = allMarkers.get(name);
13381337 if (markersForName == null) // no markers for this name
13391338 return;
13401339
13411340 updateEnabled = false;
13421341 Question oldCurrentQuestion = getCurrentQuestion();
13431342
1344 for (Iterator iter = markersForName.iterator(); iter.hasNext(); ) {
1345 Question q = (Question) (iter.next());
1343 for (Question q : markersForName) {
13461344 q.clear();
13471345 }
13481346
13541352 notifyCurrentQuestionChanged(newCurrentQuestion);
13551353 }
13561354
1357 private void loadMarkers(Map data) {
1358 String s = (String) (data.get(MARKERS));
1355 private void loadMarkers(Map<String, String> data) {
1356 String s = data.get(MARKERS);
13591357 int count = 0;
13601358 if (s != null) {
13611359 try {
13691367 allMarkers = null;
13701368
13711369 for (int i = 0; i < count; i++) {
1372 String name = (String) (data.get(MARKERS_PREF + i + ".name"));
1373 String tags = (String) (data.get(MARKERS_PREF + i));
1370 String name = data.get(MARKERS_PREF + i + ".name");
1371 String tags = data.get(MARKERS_PREF + i);
13741372 if (tags != null)
13751373 loadMarkers(name, tags);
13761374 }
14041402 }
14051403 }
14061404
1407 private void saveMarkers(Map data) {
1405 private void saveMarkers(Map<String, String> data) {
14081406 if (allMarkers == null)
14091407 return;
14101408
14111409 int i = 0;
1412 for (Iterator iter = allMarkers.entrySet().iterator(); iter.hasNext(); ) {
1413 Map.Entry e = (Map.Entry) (iter.next());
1414 String name = (String) (e.getKey());
1415 Set markersForName = (Set) (e.getValue());
1410 for (Map.Entry<String, Set<Question>> e : allMarkers.entrySet()) {
1411 String name = e.getKey();
1412 Set<Question> markersForName = e.getValue();
14161413 if (name != null)
14171414 data.put(MARKERS_PREF + i + ".name", name);
14181415 StringBuffer sb = new StringBuffer();
1419 for (Iterator qIter = markersForName.iterator(); qIter.hasNext(); ) {
1420 Question q = (Question) (qIter.next());
1416 for (Question q : markersForName) {
14211417 if (sb.length() > 0)
14221418 sb.append('\n');
14231419 sb.append(q.getTag());
14551451 */
14561452 public void clear() {
14571453 updateEnabled = false;
1458 for (Iterator iter = allQuestions.values().iterator(); iter.hasNext(); ) {
1459 Question q = (Question) (iter.next());
1454 for (Question q : allQuestions.values()) {
14601455 q.clear();
14611456 }
14621457
14631458 for (int i = 0; i < children.size(); i++) {
1464 Interview child = (Interview)children.elementAt(i);
1459 Interview child = children.elementAt(i);
14651460 child.clear();
14661461 }
14671462 if (parent == null) {
14801475 * @param data The archive map from which the state should be loaded.
14811476 * @throws Interview.Fault if the checksum is found to be incorrect.
14821477 */
1483 public void load(Map data) throws Fault {
1478 public void load(Map<String, String> data) throws Fault {
14841479 load(data, true);
14851480 }
14861481
14941489 * @param checkChecksum If true, the checksum in the data will be checked.
14951490 * @throws Interview.Fault if the checksum is found to be incorrect.
14961491 */
1497 public void load(Map data, boolean checkChecksum) throws Fault {
1492 public void load(Map<String, String> data, boolean checkChecksum) throws Fault {
14981493 if (checkChecksum && !isChecksumValid(data, true))
14991494 throw new Fault(i18n, "interview.checksumError");
15001495
15011496 if (parent == null) {
1502 String iTag = (String)(data.get(INTERVIEW));
1497 String iTag = data.get(INTERVIEW);
15031498 if (iTag != null && !iTag.equals(getClass().getName()))
15041499 throw new Fault(i18n, "interview.classMismatch");
15051500
15111506
15121507 // clear all the answers in this interview before loading an
15131508 // responses from the archive
1514 for (Iterator iter = allQuestions.values().iterator(); iter.hasNext(); ) {
1515 Question q = (Question) (iter.next());
1509 for (Question q : allQuestions.values()) {
15161510 q.clear();
15171511 }
15181512
1519 for (Iterator iter = allQuestions.values().iterator(); iter.hasNext(); ) {
1520 Question q = (Question) (iter.next());
1513 for (Question q : allQuestions.values()) {
15211514 q.load(data);
15221515 }
15231516
15241517 for (int i = 0; i < children.size(); i++) {
1525 Interview child = (Interview)children.elementAt(i);
1518 Interview child = children.elementAt(i);
15261519 child.load(data, false);
15271520 }
15281521
15291522 if (parent == null) {
1530 String qTag = (String)(data.get(QUESTION));
1523 String qTag = data.get(QUESTION);
15311524 Question q = (qTag == null ? null : lookup(qTag));
15321525 reset(q == null ? firstQuestion : q);
15331526 }
15481541 * @deprecated As of version 4.4.1, checksums are no longer
15491542 * calculated or checked. True is always returned.
15501543 */
1551 public static boolean isChecksumValid(Map data, boolean okIfOmitted) {
1544 public static boolean isChecksumValid(Map<String, String> data, boolean okIfOmitted) {
15521545 return true;
15531546 }
15541547
15591552 * its state, according to its tag.
15601553 * @param data The archive in which the values should be saved.
15611554 */
1562 public void save(Map data) {
1555 public void save(Map<String, String> data) {
15631556 // only in the root interview
15641557 if (parent == null) {
15651558 data.put(INTERVIEW, getClass().getName());
15671560 writeLocale(data);
15681561
15691562 if (extraValues != null && extraValues.size() > 0) {
1570 Set keys = getPropertyKeys();
1571 Iterator it = keys.iterator();
1572 while (it.hasNext()) {
1573 Object key = it.next();
1563 Set<String> keys = getPropertyKeys();
1564 for (String key : keys) {
15741565 data.put(EXTERNAL_PREF + key, extraValues.get(key));
15751566 } // while
15761567 }
15771568
15781569 if (templateValues != null && templateValues.size() > 0) {
1579 Set keys = templateValues.keySet();
1580 Iterator it = keys.iterator();
1581 while (it.hasNext()) {
1582 String key = (String)it.next();
1570 Set<String> keys = templateValues.keySet();
1571 for (String key : keys) {
15831572 data.put(TEMPLATE_PREF + key, retrieveTemplateProperty(key));
15841573 } // while
15851574 }
15861575
15871576 }
1588
1589 for (Iterator iter = allQuestions.values().iterator(); iter.hasNext(); ) {
1590 Question q = (Question) (iter.next());
1577 for (Question q : allQuestions.values()) {
15911578 try {
15921579 q.save(data);
15931580 }
15971584 }
15981585 }
15991586
1600 for (int i = 0; i < children.size(); i++) {
1601 Interview child = (Interview)children.elementAt(i);
1587 for (Interview child : children) {
16021588 child.save(data);
16031589 }
16041590
16161602 * @see #LOCALE
16171603 * @see #readLocale(Map)
16181604 */
1619 protected static void writeLocale(Map data) {
1605 protected static void writeLocale(Map<String, String> data) {
16201606 data.put(LOCALE, Locale.getDefault().toString());
16211607 }
16221608
16291615 * @see #LOCALE
16301616 * @see #writeLocale(Map)
16311617 */
1632 protected static Locale readLocale(Map data) {
1618 protected static Locale readLocale(Map<?, ?> data) {
16331619 Locale result = null;
16341620 Object o = data.get(LOCALE);
16351621 if (o != null) {
17461732 * @see #EXPORT_IGNORE_RUNTIME_EXCEPTIONS
17471733 * @see #EXPORT_IGNORE_NO_EXCEPTIONS
17481734 */
1749 public void export(Map data) {
1750 ArrayList<Question> path = new ArrayList();
1735 public void export(Map<String, String> data) {
1736 ArrayList<Question> path = new ArrayList<>();
17511737
17521738 // new 4.3 semantics allow the path to contain InterviewQuestions, which
17531739 // in turn allows sub-interviews to export data.
17641750 export0(data, hiddenPath, true);
17651751 }
17661752
1767 private void export0(Map data, ArrayList<Question> path, boolean processHidden) {
1768 for (int i = 0; i < path.size(); i++) {
1753 private void export0(Map<String, String> data, ArrayList<Question> paths, boolean processHidden) {
1754 for (Question path : paths) {
17691755 try {
1770 if (path.get(i) instanceof InterviewQuestion) {
1756 if (path instanceof InterviewQuestion) {
17711757 if (!processHidden)
1772 ((InterviewQuestion)path.get(i)).getTargetInterview().export(data);
1758 ((InterviewQuestion) path).getTargetInterview().export(data);
17731759 else
17741760 continue;
1761 } else {
1762 path.export(data);
17751763 }
1776 else {
1777 path.get(i).export(data);
1764 } catch (RuntimeException e) {
1765 switch (exportIgnoreExceptionPolicy) {
1766 case EXPORT_IGNORE_ALL_EXCEPTIONS:
1767 case EXPORT_IGNORE_RUNTIME_EXCEPTIONS:
1768 break;
1769 case EXPORT_IGNORE_NO_EXCEPTIONS:
1770 throw e;
17781771 }
1779 }
1780 catch (RuntimeException e) {
1772 } catch (Error e) {
17811773 switch (exportIgnoreExceptionPolicy) {
1782 case EXPORT_IGNORE_ALL_EXCEPTIONS:
1783 case EXPORT_IGNORE_RUNTIME_EXCEPTIONS:
1784 break;
1785 case EXPORT_IGNORE_NO_EXCEPTIONS:
1786 throw e;
1787 }
1788 }
1789 catch (Error e) {
1790 switch (exportIgnoreExceptionPolicy) {
1791 case EXPORT_IGNORE_ALL_EXCEPTIONS:
1792 break;
1793 case EXPORT_IGNORE_RUNTIME_EXCEPTIONS:
1794 case EXPORT_IGNORE_NO_EXCEPTIONS:
1795 throw e;
1774 case EXPORT_IGNORE_ALL_EXCEPTIONS:
1775 break;
1776 case EXPORT_IGNORE_RUNTIME_EXCEPTIONS:
1777 case EXPORT_IGNORE_NO_EXCEPTIONS:
1778 throw e;
17961779 }
17971780 }
17981781 }
19011884 if (o == null)
19021885 throw new NullPointerException();
19031886
1904 for (int i = 0; i < observers.length; i++) {
1905 if (observers[i] == o) {
1887 for (Observer observer : observers) {
1888 if (observer == o) {
19061889 return true;
19071890 }
19081891 }
19161899 }
19171900
19181901 private void notifyPathUpdated() {
1919 for (int i = 0; i < observers.length; i++)
1920 observers[i].pathUpdated();
1902 for (Observer observer : observers) observer.pathUpdated();
19211903 }
19221904
19231905 private Observer[] observers = new Observer[0];
19511933
19521934 // update the tags for the questions in the interview
19531935 // and rebuild the tag map
1954 Map newAllQuestions = new LinkedHashMap();
1955 for (Iterator iter = allQuestions.values().iterator(); iter.hasNext(); ) {
1956 Question q = (Question) (iter.next());
1936 Map<String, Question> newAllQuestions = new LinkedHashMap<>();
1937 for (Question q : allQuestions.values()) {
19571938 q.updateTag();
19581939 newAllQuestions.put(q.getTag(), q);
19591940 }
19601941 allQuestions = newAllQuestions;
19611942
19621943 // recursively update children
1963 for (Iterator iter = children.iterator(); iter.hasNext(); ) {
1964 Interview i = (Interview) (iter.next());
1944 for (Interview i : children) {
19651945 i.updateTags();
19661946 }
19671947 }
19741954
19751955 void add(Question question) {
19761956 String qTag = question.getTag();
1977 Question prev = (Question) allQuestions.put(qTag, question);
1957 Question prev = allQuestions.put(qTag, question);
19781958 if (prev != null)
19791959 throw new IllegalArgumentException("duplicate questions for tag: " + qTag);
19801960 }
20882068 if (extraValues == null)
20892069 return null;
20902070 else
2091 return (String)(extraValues.remove(key));
2071 return extraValues.remove(key);
20922072 }
20932073
20942074 if (extraValues == null)
2095 extraValues = new HashMap();
2096
2097 return (String)(extraValues.put(key, value));
2075 extraValues = new HashMap<>();
2076
2077 return extraValues.put(key, value);
20982078 }
20992079 }
21002080
21092089 return getParent().storeTemplateProperty(key, value);
21102090 else {
21112091 ensureTemValuesInitialized();
2112 return (String)(templateValues.put(key, value));
2092 return templateValues.put(key, value);
21132093 }
21142094 }
21152095
21172097 * Clear a previous template properties and store the new into the configuration.
21182098 * @param props The properties to store.
21192099 */
2120 public void storeTemplateProperties(Properties props) {
2100 public void storeTemplateProperties(Map<String, String> props) {
21212101 if (getParent() != null)
21222102 getParent().storeTemplateProperties(props);
21232103 else {
21242104 ensureTemValuesInitialized();
21252105 templateValues.clear();
2126 templateValues.putAll((Map) props);
2106 templateValues.putAll(props);
21272107 }
21282108 }
21292109
21432123 if (extraValues == null)
21442124 return null;
21452125
2146 return (String)(extraValues.get(key));
2126 return extraValues.get(key);
21472127 }
21482128 }
21492129
21582138 return getParent().retrieveTemplateProperty(key);
21592139 else {
21602140 ensureTemValuesInitialized();
2161 return (String)(templateValues.get(key));
2162 }
2163 }
2164
2165 public Set retrieveTemplateKeys() {
2141 return templateValues.get(key);
2142 }
2143 }
2144
2145 public Set<String> retrieveTemplateKeys() {
21662146 if (getParent() != null)
21672147 return getParent().retrieveTemplateKeys();
21682148 else {
21812161 * @see #storeProperty
21822162 * @see #retrieveProperty
21832163 */
2184 public Set getPropertyKeys() {
2164 public Set<String> getPropertyKeys() {
21852165 if (getParent() != null)
21862166 return parent.getPropertyKeys();
21872167 else {
22002180 */
22012181 public Map<String,String> getExternalProperties() {
22022182 if (extraValues != null)
2203 return (Map)extraValues.clone();
2183 return new HashMap<>(extraValues);
22042184 else
22052185 return null;
22062186 }
22092189 /**
22102190 * @see #load(Map)
22112191 */
2212 private void loadExternalValues(Map data) {
2192 private void loadExternalValues(Map<String, String> data) {
22132193
22142194 if (extraValues != null) {
22152195 extraValues.clear();
22162196 }
22172197
2218 Set keys = data.keySet();
2219 Iterator it = keys.iterator();
2220
2221 while (it.hasNext()) {
2198 Set<String> keys = data.keySet();
2199
2200 for (String key : keys) {
22222201 // look for special external value keys
22232202 // should consider removing it from data, is it safe to alter
22242203 // that object?
2225 String key = (String)(it.next());
22262204 if (key.startsWith(EXTERNAL_PREF)) {
22272205 if (extraValues == null)
2228 extraValues = new HashMap();
2229
2230 String val = (String)(data.get(key));
2206 extraValues = new HashMap<>();
2207
2208 String val = data.get(key);
22312209
22322210 // store it, minus the special prefix
22332211 extraValues.put(key.substring(EXTERNAL_PREF.length()), val);
22352213 } // while
22362214 }
22372215
2238 private void loadTemplateValues(Map data) {
2216 private void loadTemplateValues(Map<String, String> data) {
22392217
22402218 if (templateValues != null) {
22412219 templateValues.clear();
22422220 }
22432221
2244 Set keys = data.keySet();
2245 Iterator it = keys.iterator();
2246
2247 while (it.hasNext()) {
2248 String key = (String)(it.next());
2222 Set<String> keys = data.keySet();
2223 for (String key : keys) {
22492224 if (key.startsWith(TEMPLATE_PREF)) {
22502225 ensureTemValuesInitialized();
2251 String val = (String)(data.get(key));
2226 String val = data.get(key);
22522227 // store it, minus the special prefix
22532228 templateValues.put(key.substring(TEMPLATE_PREF.length()), val);
22542229 }
22572232
22582233 public void propagateTemplateForAll() {
22592234 ensureTemValuesInitialized();
2260 for (Iterator iter = getAllQuestions().values().iterator(); iter.hasNext(); ) {
2261 Question q = (Question) (iter.next());
2235 for (Question q : getAllQuestions().values()) {
22622236 q.load(templateValues);
22632237 }
22642238 }
22672241
22682242 private void ensureTemValuesInitialized() {
22692243 if (templateValues == null) {
2270 templateValues = new HashMap();
2244 templateValues = new HashMap<>();
22712245 }
22722246 }
22732247
22742248 private void ensurePathInitialized() {
22752249 if (path == null) {
22762250 path = new Path();
2277 hiddenPath = new ArrayList();
2251 hiddenPath = new ArrayList<>();
22782252
22792253 if (parent == null)
22802254 rawPath = new Path();
22882262
22892263
22902264 private Question lookup(String tag) {
2291 Question q = (Question)(allQuestions.get(tag));
2265 Question q = allQuestions.get(tag);
22922266 // if q is null, search children till we find it
22932267 for (int i = 0; i < children.size() && q == null; i++) {
2294 Interview child = (Interview)children.elementAt(i);
2268 Interview child = children.elementAt(i);
22952269 q = child.lookup(tag);
22962270 }
22972271
23752349 }
23762350
23772351 private void verifyPredictPath(){
2378 for (Object o : getInterviews()){
2379 if (o instanceof Interview){
2380 Interview i = (Interview) o;
2381 if (i.path != null && i.currIndex >= i.path.size()){
2382 i.currIndex = i.path.size()-1;
2383 }
2352 for (Interview i : getInterviews()) {
2353 if (i.path != null && i.currIndex >= i.path.size()) {
2354 i.currIndex = i.path.size() - 1;
23842355 }
23852356 }
23862357 }
24722443 i2.caller = iq;
24732444 if (i2.path == null) {
24742445 i2.path = new Path();
2475 i2.hiddenPath = new ArrayList();
2446 i2.hiddenPath = new ArrayList<>();
24762447 }
24772448 else {
24782449 i2.path.clear();
26732644 /**
26742645 * Any child interviews.
26752646 */
2676 private Vector children = new Vector();
2647 private Vector<Interview> children = new Vector<>();
26772648
26782649 /**
26792650 * An index of the questions in this interview.
26802651 */
2681 private Map allQuestions = new LinkedHashMap();
2652 private Map<String, Question> allQuestions = new LinkedHashMap<>();
26822653
26832654 /**
26842655 * The default image for questions in the interview.
27012672 private boolean updateEnabled;
27022673 private boolean edited;
27032674
2704 private Map allMarkers;
2705 private HashMap<String,String> extraValues; // used in top-level interview only
2706 private HashMap<String,String> templateValues;
2675 private Map<String, Set<Question>> allMarkers;
2676 private Map<String, String> extraValues; // used in top-level interview only
2677 private Map<String, String> templateValues;
27072678
27082679 private int semantics = SEMANTIC_PRE_32;
27092680
107107 * there is no value, and so no action is performed.
108108 * @param data The map from which to load the state for this question.
109109 */
110 protected void load(Map data) {
110 protected void load(Map<String, String> data) {
111111 // no need to super.load(data)
112112 }
113113
117117 * there is no value, and so no action is performed.
118118 * @param data The map from which to load the state for this question.
119119 */
120 protected void save(Map data) {
120 protected void save(Map<String, String> data) {
121121 // no need to super.save(data)
122122 }
123123
107107 if (dependency == null)
108108 throw new NullPointerException();
109109
110 Set allDeps = getAllDependencies(dependency);
110 Set<Interview> allDeps = getAllDependencies(dependency);
111111 if (allDeps != null && allDeps.contains(child))
112112 throw new CycleFault(child, dependency);
113113
114 Set deps = getDependencies(child, true);
114 Set<Interview> deps = getDependencies(child, true);
115115 deps.add(dependency);
116116
117117 sortedCalls = null;
130130 if (dependency == null)
131131 throw new NullPointerException();
132132
133 Set deps = getDependencies(child, false);
133 Set<Interview> deps = getDependencies(child, false);
134134
135135 if (deps != null)
136136 deps.remove(dependency);
141141 sortedCalls = null;
142142 }
143143
144 private Set getDependencies(Interview child, boolean create) {
145 Set deps = (Set) (dependencies.get(child));
144 private Set<Interview> getDependencies(Interview child, boolean create) {
145 Set<Interview> deps = dependencies.get(child);
146146
147147 if (deps == null && create) {
148 deps = new TreeSet(new ChildComparator());
148 deps = new TreeSet<Interview>(new ChildComparator());
149149 dependencies.put(child, deps);
150150 }
151151
152152 return deps;
153153 }
154154
155 private Set getAllDependencies(Interview child) {
156 Set s = new HashSet();
155 private Set<Interview> getAllDependencies(Interview child) {
156 Set<Interview> s = new HashSet<>();
157157 getAllDependencies(child, s);
158158 return s;
159159 }
160160
161 private void getAllDependencies(Interview child, Set s) {
161 private void getAllDependencies(Interview child, Set<Interview> s) {
162162 if (s.contains(child))
163163 return;
164164
165 Set deps = getDependencies(child, false);
165 Set<Interview> deps = getDependencies(child, false);
166166 if (deps != null) {
167 for (Iterator iter = deps.iterator(); iter.hasNext(); ) {
168 Interview i = (Interview) (iter.next());
167 for (Iterator<Interview> iter = deps.iterator(); iter.hasNext(); ) {
168 Interview i = iter.next();
169169 getAllDependencies(i, s);
170170 s.add(i);
171171 }
173173 }
174174
175175 private Interview[] sortChildren() {
176 List list = new ArrayList();
177 Set cycleSet = new HashSet();
178
179 for (Iterator iter = children.iterator(); iter.hasNext(); ) {
180 Interview child = (Interview) (iter.next());
176 List<Interview> list = new ArrayList<>();
177 Set<Interview> cycleSet = new HashSet<>();
178
179 for (Interview child : children) {
181180 if (!list.contains(child))
182181 addToList(list, child, cycleSet);
183182 }
184183
185 for (Iterator iter = list.iterator(); iter.hasNext(); ) {
186 Interview i = (Interview) (iter.next());
184 for (Interview i : list) {
187185 System.err.println(i.getTag() + " " + i);
188186 }
189187
190 return (Interview[]) (list.toArray(new Interview[list.size()]));
191 }
192
193 private void addToList(List list, Interview child, Set cycleSet) {
188 return list.toArray(new Interview[list.size()]);
189 }
190
191 private void addToList(List<Interview> list, Interview child, Set<Interview> cycleSet) {
194192 // assert !cycleSet.contains(child);
195193 if (cycleSet.contains(child))
196194 throw new IllegalArgumentException();
197195
198196 cycleSet.add(child);
199197
200 Set deps = (Set) (dependencies.get(child));
198 Set<Interview> deps = dependencies.get(child);
201199 if (deps != null) {
202 for (Iterator iter = deps.iterator(); iter.hasNext(); ) {
203 Interview dep = (Interview) (iter.next());
200 for (Iterator<Interview> iter = deps.iterator(); iter.hasNext(); ) {
201 Interview dep = iter.next();
204202 addToList(list, dep, cycleSet);
205203 }
206204 }
234232
235233 private FinalQuestion qEnd = new FinalQuestion(this);
236234
237 private List children = new ArrayList();
238 private Map dependencies = new HashMap();
235 private List<Interview> children = new ArrayList<>();
236 private Map<Interview, Set<Interview>> dependencies = new HashMap<>();
239237 private Question sortedCalls;
240238
241 private class ChildComparator implements Comparator
239 private class ChildComparator implements Comparator<Interview>
242240 {
243 public int compare(Object o1, Object o2) {
241 public int compare(Interview o1, Interview o2) {
244242 if (!children.contains(o1) || !children.contains(o2))
245243 throw new IllegalArgumentException();
246244
247245 if (o1 == o2)
248246 return 0;
249247
250 for (Iterator iter = children.iterator(); iter.hasNext(); ) {
251 Object o = iter.next();
248 for (Iterator<Interview> iter = children.iterator(); iter.hasNext(); ) {
249 Interview o = iter.next();
252250 if (o == o1)
253251 return -1;
254252 if (o == o2)
4747 public JavaHelpFactory() {
4848 }
4949
50 public Object createHelpSetObject(String name, Class c) throws Interview.Fault {
50 public Object createHelpSetObject(String name, Class<?> c) throws Interview.Fault {
5151 ClassLoader cl = c.getClassLoader();
5252 String hsn;
5353 String pref = "";
8686 public Object createHelpID(Object hsObject, String target) {
8787 if (hsObject != null) {
8888 HelpSet hs = (HelpSet) hsObject;
89 HashMap m = hs.getCombinedMap();
89 HashMap<String, URL> m = hs.getCombinedMap();
9090 if (m != null && !m.isEmpty()) {
9191 return HelpID.create(target, hs);
9292 }
102102 if (oldHelpSet == null) {
103103 // no previously registered helpset
104104 // so add in any helpsets for child interviews
105 for (Iterator iter = interview.getInterviews().iterator(); iter.hasNext(); ) {
106 Interview i = (Interview) (iter.next());
105 for (Iterator<Interview> iter = interview.getInterviews().iterator(); iter.hasNext(); ) {
106 Interview i = iter.next();
107107 HelpSet ihs = (HelpSet)i.getHelpSet();
108108 if (ihs != null)
109109 newHelpSet.add(ihs);
124124 public String getDefaultSummary() {
125125 if (defaultSummary == null) {
126126 // recycle any default summaries that are no longer required
127 Vector bodies = question.bodies;
127 Vector<Body> bodies = question.bodies;
128128 for (int i = 0; i < bodies.size(); i++) {
129 Body b = (Body) (bodies.elementAt(i));
129 Body b = (bodies.elementAt(i));
130130 if (b.defaultSummary != null
131131 && b.getSummary() != null
132132 && !b.defaultSummary.equals(b.getSummary())) {
141141 // check s is not the same as any current default summary;
142142 // if it is, reset it to null
143143 for (int i = 0; i < bodies.size(); i++) {
144 Body b = (Body) (bodies.elementAt(i));
144 Body b = (bodies.elementAt(i));
145145 if (s.equals(b.defaultSummary)) {
146146 s = null;
147147 break;
188188 }
189189 else {
190190 end = new EndQuestion(interview, tag, this);
191 bodies = new Vector();
191 bodies = new Vector<>();
192192 }
193193 }
194194
234234 */
235235 public Body getSelectedBody() {
236236 if (value >= 0 && value < bodies.size())
237 return (Body) (bodies.elementAt(value));
237 return bodies.elementAt(value);
238238 else
239239 return null;
240240 }
393393 return end.getDefaultTextArgs();
394394 }
395395
396 protected void load(Map data) {
396 protected void load(Map<String, String> data) {
397397 bodies.setSize(0);
398 String c = (String) (data.get(tag + ".count"));
398 String c = data.get(tag + ".count");
399399 if (c != null && c.length() > 0) {
400400 try {
401401 int n = Integer.parseInt(c);
408408 }
409409 }
410410
411 String v = (String) (data.get(tag + ".curr"));
411 String v = data.get(tag + ".curr");
412412 if (v == null || v.length() == 0)
413413 value = 0;
414414 else {
421421 }
422422 }
423423
424 protected void save(Map data) {
424 protected void save(Map<String, String> data) {
425425 data.put(tag + ".count", String.valueOf(bodies.size()));
426426 data.put(tag + ".curr", String.valueOf(value));
427427 }
454454 * valid body
455455 */
456456 public Body getBody(int index) {
457 return (Body) (bodies.elementAt(index));
457 return bodies.elementAt(index);
458458 }
459459
460460 /**
509509 public int getIncompleteBodyCount() {
510510 int count = 0;
511511 for (int i = 0; i < bodies.size(); i++) {
512 Body b = (Body) (bodies.elementAt(i));
512 Body b = bodies.elementAt(i);
513513 if (!b.isInterviewFinishable())
514514 count++;
515515 }
518518
519519
520520 private final EndQuestion end;
521 private final Vector bodies;
521 private final Vector<Body> bodies;
522522 private int value;
523523
524524 private static final ResourceBundle i18n = Interview.i18n;
532532 public Question getNext() {
533533 boolean allBodiesFinishable = true;
534534 for (int i = 0; i < head.getBodyCount(); i++) {
535 Body b = (Body) (head.getBody(i));
535 Body b = head.getBody(i);
536536 if (!b.isInterviewFinishable()) {
537537 allBodiesFinishable = false;
538538 break;
604604 head.clear();
605605 }
606606
607 protected void load(Map data) {
608 }
609
610 protected void save(Map data) {
607 protected void load(Map<String, String> data) {
608 }
609
610 protected void save(Map<String, String> data) {
611611 }
612612
613613 public Body[] getBodies() {
149149 * the tag as the key.
150150 * @param data ignored
151151 */
152 protected void load(Map data) {
152 protected void load(Map<String, String> data) {
153153 }
154154
155155 /**
157157 * the tag as the key. Since there is no value, this method is a no-op.
158158 * @param data ignored
159159 */
160 protected void save(Map data) {
160 protected void save(Map<String, String> data) {
161161 }
162162
163163 public static final int LEVEL_NONE = -1;
4747 * capabilities.
4848 */
4949
50 public class Properties2 extends Hashtable {
50 public class Properties2 extends Hashtable<String, Object> {
5151 /**
5252 * A property list that contains default values for any keys not
5353 * found in this property list.
7070 }
7171
7272 public void load(java.util.Properties source) {
73 Enumeration e = source.propertyNames();
73 Enumeration<?> e = source.propertyNames();
7474 while(e.hasMoreElements()) {
7575 Object next = e.nextElement();
7676 put( ((String)next), source.get(next) );
202202 prnt.write('#');
203203 prnt.println(new Date());
204204
205 for (Enumeration e = keys() ; e.hasMoreElements() ;) {
206 String key = (String)e.nextElement();
205 for (Enumeration<String> e = keys() ; e.hasMoreElements() ;) {
206 String key = e.nextElement();
207207 prnt.print(key);
208208 prnt.write('=');
209209
284284 * @see java.util.Enumeration
285285 * @see com.sun.interview.Properties2#defaults
286286 */
287 public Enumeration propertyNames() {
288 Hashtable h = new Hashtable();
287 public Enumeration<String> propertyNames() {
288 Hashtable<String, Object> h = new Hashtable<>();
289289 enumerate(h);
290290 return h.keys();
291291 }
304304 */
305305 public void list(PrintWriter out) {
306306 out.println("-- listing properties --");
307 Hashtable h = new Hashtable();
307 Hashtable<String, Object> h = new Hashtable<>();
308308 enumerate(h);
309 for (Enumeration e = h.keys() ; e.hasMoreElements() ;) {
310 String key = (String)e.nextElement();
309 for (Enumeration<String> e = h.keys() ; e.hasMoreElements() ;) {
310 String key = e.nextElement();
311311 String val = (String)h.get(key);
312312 if (val.length() > 40) {
313313 val = val.substring(0, 37) + "...";
320320 * Enumerates all key/value pairs in the specified hastable.
321321 * @param h the hashtable
322322 */
323 private synchronized void enumerate(Hashtable h) {
323 private synchronized void enumerate(Hashtable<String, Object> h) {
324324 if (defaults != null) {
325325 defaults.enumerate(h);
326326 }
327 for (Enumeration e = keys() ; e.hasMoreElements() ;) {
328 String key = (String)e.nextElement();
327 for (Enumeration<String> e = keys() ; e.hasMoreElements() ;) {
328 String key = e.nextElement();
329329 h.put(key, get(key));
330330 }
331331 }
2929 import java.io.IOException;
3030 import java.io.StringReader;
3131 import java.io.StringWriter;
32 import java.util.ArrayList;
33 import java.util.Enumeration;
34 import java.util.HashMap;
35 import java.util.Iterator;
36 import java.util.Map;
37 import java.util.MissingResourceException;
38 import java.util.Properties;
39 import java.util.ResourceBundle;
40 import java.util.Set;
32 import java.util.*;
4133
4234 import com.sun.interview.Interview.Fault;
4335
4436 // todo:
45 import java.util.Collections;
37
4638 // how to sort values
4739 // how to sort groups for display
4840 // table headers - default, with set methods
142134 if (!localize || b == null) // will use literal keys
143135 presentationKeys = null;
144136 else {
145 presentationKeys = new HashMap();
137 presentationKeys = new HashMap<>();
146138 for (int i = 0; i < keys.length; i++) {
147139 String c = keys[i];
148140 String rn = tag + "." + c;
163155 * @return The set of keys (internal non-i18n value)
164156 * @see #setKeys
165157 */
166 public Enumeration getKeys() {
158 public Enumeration<?> getKeys() {
167159 if (value != null)
168160 return value.keys();
169161 else
223215 if (value != null) {
224216 String sep = System.getProperty("line.separator");
225217
226 Enumeration names = value.propertyNames();
227 ArrayList list = Collections.list(names);
228 Collections.sort(list);
229 for (Object o : list) {
230 String key = (String)o;
218 SortedSet<String> names = new TreeSet<>(value.stringPropertyNames());
219 for (String key : names) {
231220 result.append(key);
232221 result.append("=");
233222 result.append(value.getProperty(key));
306295 * the tag as the key.
307296 * @param data The map from which to load the value for this question.
308297 */
309 protected void load(Map data) {
310 Object o = data.get(tag);
311 if (o != null && o instanceof String) {
312 setValue(load((String)o));
298 protected void load(Map<String, String> data) {
299 String o = data.get(tag);
300 if (o != null) {
301 setValue(load(o));
313302 }
314303 }
315304
327316 // repopulate a J2SE properties object
328317 Properties p = new Properties();
329318
330 Enumeration e = p2.propertyNames();
319 Enumeration<?> e = p2.propertyNames();
331320 while(e.hasMoreElements()) {
332321 Object next = e.nextElement();
333 p.put( ((String)next), p2.get(next) );
322 p.put( next, p2.get(next) );
334323 } // while
335324
336325 return p;
341330 * the tag as the key.
342331 * @param data The map in which to save the value for this question.
343332 */
344 protected void save(Map data) {
333 protected void save(Map<String, String> data) {
345334 if (value == null)
346335 return;
347336
418407 * in index one. Null means there are no invalid keys.
419408 */
420409 public String[][] getInvalidKeys() {
421 Enumeration names = value.propertyNames();
422 ArrayList badKeys = new ArrayList();
423 ArrayList reasons = new ArrayList();
410 Enumeration<?> names = value.propertyNames();
411 List<String> badKeys = new ArrayList<>();
412 List<String> reasons = new ArrayList<>();
424413
425414 while (names.hasMoreElements()) {
426415 String curr = (String)(names.nextElement());
442431 if (badKeys.size() > 0) {
443432 String[][] ret = new String[badKeys.size()][2];
444433 for (int i = 0; i < badKeys.size(); i++) {
445 ret[i][0] = (String)(badKeys.get(i));
446 ret[i][1] = (String)(reasons.get(i));
434 ret[i][0] = badKeys.get(i);
435 ret[i][1] = reasons.get(i);
447436 } // for
448437
449438 return ret;
558547 */
559548 public void createGroup(String name) {
560549 if (keyGroups == null)
561 keyGroups = new HashMap();
550 keyGroups = new HashMap<>();
562551
563552 Object o = keyGroups.get(name);
564553 if (o != null)
565554 throw new IllegalStateException("Group " + name + " already exists.");
566555
567 ArrayList al = new ArrayList();
556 ArrayList<String> al = new ArrayList<>();
568557 keyGroups.put(name, al);
569558 }
570559
591580 throw new IllegalArgumentException("No such group: " + group);
592581
593582 // find existing group or create
594 ArrayList l = ((ArrayList)(keyGroups.get(group)));
583 ArrayList<String> l = keyGroups.get(group);
595584 if (l == null)
596585 throw new IllegalArgumentException("No such group: " + group);
597586
598587 // remove key from all groups
599 Iterator vals = keyGroups.values().iterator();
588 Iterator<ArrayList<String>> vals = keyGroups.values().iterator();
600589 while (vals.hasNext()) {
601 ArrayList al = ((ArrayList)(vals.next()));
590 ArrayList<String> al = vals.next();
602591 for (int i = 0; i < al.size(); i++)
603592 if (al.get(i).equals(key))
604593 al.remove(i);
632621 if (keyGroups == null)
633622 return null;
634623
635 ArrayList result = new ArrayList();
636 Set keys = keyGroups.keySet();
624 ArrayList<String> result = new ArrayList<>();
625 Set<String> keys = keyGroups.keySet();
637626 if (keys != null) {
638 Iterator it = keys.iterator();
627 Iterator<String> it = keys.iterator();
639628 while(it.hasNext()) {
640 Object key = it.next();
641 ArrayList al = ((ArrayList)keyGroups.get(key));
629 String key = it.next();
630 ArrayList<String> al = keyGroups.get(key);
642631 if (al == null || al.size() == 0)
643632 continue; // empty group
644633
650639 return null;
651640 else {
652641 String[] ret = new String[result.size()];
653 ret = (String[])(result.toArray(ret));
642 ret = result.toArray(ret);
654643 return ret;
655644 }
656645 }
670659 if (group == null)
671660 return getUngrouped();
672661
673 ArrayList al = ((ArrayList)keyGroups.get(group));
662 ArrayList<String> al = keyGroups.get(group);
674663
675664 if (al == null || al.size() == 0)
676665 return null;
677666 else {
678 Iterator it = al.iterator();
667 Iterator<String> it = al.iterator();
679668 String[][] data = new String[al.size()][2];
680669 for(int i = 0; it.hasNext(); i++) {
681 data[i][0] = (String)(it.next());
670 data[i][0] = it.next();
682671 data[i][1] = (String)(value.get(data[i][0]));
683672 } // for
684673
697686 return null;
698687
699688 if (keyGroups != null) {
700 Set keys = keyGroups.keySet();
689 Set<String> keys = keyGroups.keySet();
701690 if (keys != null) {
702691 String[] gps = getGroups();
703692 Properties copy = (Properties)(value.clone());
712701 }
713702
714703 if (copy.size() > 0) {
715 Enumeration en = copy.propertyNames();
704 Set<String> en = copy.stringPropertyNames();
716705 String[][] ret = new String[copy.size()][2];
717706 int i = 0;
718
719 while (en.hasMoreElements()) {
720 String key = (String)(en.nextElement());
707 for (String key : en) {
721708 ret[i][0] = key;
722709 ret[i][1] = copy.getProperty(key);
723710 i++;
731718 }
732719 // no groups, return the entire value set
733720 String[][] ret = new String[value.size()][2];
734 Enumeration en = value.propertyNames();
721 Enumeration<?> en = value.propertyNames();
735722 int i = 0;
736723
737724 while (en.hasMoreElements()) {
802789 */
803790 public void setConstraints(String key, ValueConstraints c) {
804791 if (constraints == null)
805 constraints = new HashMap();
792 constraints = new HashMap<>();
806793
807794 if (value == null || value.getProperty(key) == null)
808795 throw new IllegalArgumentException("No such key: " + key);
858845 /**
859846 * Returns the localized key values to display
860847 */
861 public HashMap getPresentationKeys(){
848 public Map<String, String> getPresentationKeys(){
862849 return presentationKeys;
863850 }
864851
871858 if (constraints == null)
872859 return null;
873860 else
874 return ((ValueConstraints)(constraints.get(key)));
861 return constraints.get(key);
875862 }
876863
877864 /**
879866 * set of property keys. Null indicates that no i18n presentation values
880867 * are provided.
881868 */
882 private HashMap presentationKeys;
869 private Map<String, String> presentationKeys;
883870
884871 /**
885872 * Indexed like everything else, by property key, the value is a
886873 * ValueConstraint.
887874 */
888 private HashMap constraints;
875 private Map<String, ValueConstraints> constraints;
889876
890877 /**
891878 * The current (default or latest) response to this question.
901888 * Record of key groupings. Key is the group name string, the value is
902889 * a ArrayList.
903890 */
904 private HashMap keyGroups;
891 private Map<String, ArrayList<String>> keyGroups;
905892
906893 // these are now represented in ValueConstraints
907894 //private HashSet readOnlyKeys;
2727
2828 import java.net.URL;
2929 import java.text.MessageFormat;
30 import java.util.HashMap;
3031 import java.util.Map;
3132
3233 /**
400401 * using the tag as the key.
401402 * @param data The map from which to load the value for this question.
402403 */
403 protected abstract void load(Map data);
404 protected abstract void load(Map<String, String> data);
404405
405406 /**
406407 * Save any state for this question in a dictionary,
407408 * using the tag as the key.
408409 * @param data The map in which to save the value for this question.
409410 */
410 protected abstract void save(Map data);
411 protected abstract void save(Map<String, String> data);
411412
412413 /**
413414 * Export any appropriate values to the dictionary, as part
420421 * @see Interview#getPath
421422 * @see #isEnabled
422423 */
423 protected void export(Map data) {
424 protected void export(Map<String, String> data) {
424425 }
425426
426427 /**
429430 * the question value.
430431 */
431432 public void reload() {
432 Map map = new java.util.HashMap();
433 Map<String, String> map = new HashMap<>();
433434 save(map);
434435 clear();
435436 load(map);
140140 }
141141
142142 public void setValue(String s) {
143 setValue(s == null ? ((String[]) null) : split(s));
143 setValue(s == null ? null : split(s));
144144 }
145145
146146 /**
182182 * the tag as the key.
183183 * @param data The map from which to load the value for this question.
184184 */
185 protected void load(Map data) {
186 Object o = data.get(tag);
187 if (o instanceof String[])
188 setValue((String[]) o);
189 else if (o instanceof String)
190 setValue((String) o);
185 protected void load(Map<String, String> data) {
186 String o = data.get(tag);
187 setValue(o);
191188 }
192189
193190 /**
195192 * the tag as the key.
196193 * @param data The map in which to save the value for this question.
197194 */
198 protected void save(Map data) {
195 protected void save(Map<String, String> data) {
199196 if (value != null)
200197 data.put(tag, getStringValue());
201198 }
247244
248245 final char sep = '\n';
249246
250 Vector v = new Vector();
247 Vector<String> v = new Vector<>();
251248 int start = -1;
252249 for (int i = 0; i < s.length(); i++) {
253250 if (s.charAt(i) == sep) {
180180 * the tag as the key.
181181 * @param data The map from which to load the value for this question.
182182 */
183 protected void load(Map data) {
184 Object o = data.get(tag);
185 if (o instanceof String)
186 setValue((String)o);
183 protected void load(Map<String, String> data) {
184 setValue(data.get(tag));
187185 }
188186
189187 /**
191189 * the tag as the key.
192190 * @param data The map in which to save the value for this question.
193191 */
194 protected void save(Map data) {
192 protected void save(Map<String, String> data) {
195193 if (value != null)
196194 data.put(tag, value);
197195 }
310310 * the tag as the key.
311311 * @param data The map from which to load the value for this question.
312312 */
313 protected void load(Map data) {
314 String paths = (String) (data.get(tag));
313 protected void load(Map<String, String> data) {
314 String paths = data.get(tag);
315315 setValue(paths);
316316 }
317317
320320 * the tag as the key.
321321 * @param data The map in which to save the value for this question.
322322 */
323 protected void save(Map data) {
323 protected void save(Map<String, String> data) {
324324 data.put(tag, join(value));
325325 }
326326
328328 if (s == null)
329329 return empty;
330330
331 Vector v = new Vector();
331 Vector<String> v = new Vector<>();
332332 int start = -1;
333333 for (int i = 0; i < s.length(); i++) {
334334 if (white(s.charAt(i))) {
3636 import java.io.IOException;
3737 import java.io.PrintStream;
3838 import java.text.MessageFormat;
39 import java.util.Hashtable;
40 import java.util.Properties;
41 import java.util.ResourceBundle;
42 import java.util.Vector;
39 import java.util.*;
4340
4441 /**
4542 * An API (with a basic front-end application) for batch editing an
130127 */
131128 public static void main(String[] args) {
132129 try {
133 Vector v = new Vector();
130 Vector<String> v = new Vector<>();
134131 File interviewFile = null;
135132 File outFileName = null;
136133
154151
155152 try {
156153 InputStream in = new BufferedInputStream(new FileInputStream(interviewFile));
157 Properties p = new Properties();
158 p.load(in);
159 String interviewClassName = (String)p.get("INTERVIEW");
154 Map<String, String> stringProps = com.sun.javatest.util.Properties.load(in);
155 String interviewClassName = stringProps.get("INTERVIEW");
160156 if (interviewClassName == null)
161157 throw new Fault(i18n, "edit.noInterview");
162 Class ic = Class.forName(interviewClassName);
158 Class<?> ic = Class.forName(interviewClassName);
163159 interview = (Interview)(ic.newInstance());
164 interview.load(p, false);
160 interview.load(stringProps, false);
165161 }
166162 catch (FileNotFoundException e) {
167163 throw new Fault(i18n, "edit.cantFindFile", interviewFile);
179175 try {
180176 OutputStream out = new BufferedOutputStream(new FileOutputStream(outFileName));
181177 Properties p = new Properties();
182 interview.save(p);
178 interview.save(com.sun.javatest.util.Properties.convertToStringProps(p));
183179 p.store(out, "Interview: " + interview.getTitle());
184180 }
185181 catch (IOException e) {
279275 if (searchText.length() == 0)
280276 throw new Fault(i18n, "edit.badCmd", cmd);
281277
282 Hashtable answers = new Hashtable();
278 Map<String, String> answers = new Hashtable<>();
283279 interview.save(answers);
284280
285281 Question[] path = interview.getPath();
286282 for (int i = 0; i < path.length; i++) {
287283 Question q = path[i];
288284 try {
289 String answer = (String)(answers.get(q.getTag()));
285 String answer = answers.get(q.getTag());
290286 if (answer == null)
291287 continue;
292288 // // currently hardwired: considerCase: false; word match: false
300296 q.setValue(newAnswer);
301297
302298 if (verbose) {
303 Hashtable h = new Hashtable();
299 Map<String, String> h = new Hashtable<>();
304300 q.save(h);
305301 out.println("Question: " + q.getSummary());
306302 out.println("changed from: " + answer);
2525 */
2626 package com.sun.interview;
2727
28 import com.sun.javatest.util.Properties;
29
2830 import java.io.*;
2931 import java.nio.charset.StandardCharsets;
3032 import java.text.MessageFormat;
31 import java.util.Map;
32 import java.util.Iterator;
33 import java.util.Properties;
34 import java.util.ResourceBundle;
35 import java.util.Vector;
33 import java.util.*;
3634
3735 /**
3836 * An API (with a basic front-end application) for generating HTML printouts
170168 throw new BadArgs(i18n, "wp.badArg", args[i]);
171169 }
172170
173 Map interviewData = null;
171 Map<String, String> interviewData = null;
174172
175173 if (interviewFile != null) {
176174 try {
177175 InputStream in = new BufferedInputStream(new FileInputStream(interviewFile));
178 Properties p = new Properties();
179 p.load(in);
180 interviewClassName = (String)p.get("INTERVIEW");
181 interviewData = p;
176 interviewData = Properties.load(in);
177 interviewClassName = interviewData.get("INTERVIEW");
182178 }
183179 catch (FileNotFoundException e) {
184180 throw new Fault(i18n, "wp.cantFindFile", interviewFile);
203199 throw new BadArgs(i18n, "wp.noOutput");
204200 }
205201
206 Class ic = Class.forName(interviewClassName, true, ClassLoader.getSystemClassLoader());
202 Class<?> ic = Class.forName(interviewClassName, true, ClassLoader.getSystemClassLoader());
207203 Interview interview = (Interview)(ic.newInstance());
208204 Question[] questions;
209205
216212 else {
217213 // enumerate questions, sort on tag
218214 SortedVector v = new SortedVector();
219 for (Iterator iter = interview.getQuestions().iterator(); iter.hasNext(); ) {
220 Question q = (Question) (iter.next());
215 for (Iterator<Question> iter = interview.getQuestions().iterator(); iter.hasNext(); ) {
216 Question q = iter.next();
221217 v.insert(q);
222218 }
223219 questions = new Question[v.size()];
996992 private static class SortedVector
997993 {
998994 public SortedVector() {
999 v = new Vector();
995 v = new Vector<Question>();
1000996 }
1001997
1002998 public SortedVector(int initialSize) {
1003 v = new Vector(initialSize);
999 v = new Vector<>(initialSize);
10041000 }
10051001
10061002
10081004 return v.size();
10091005 }
10101006
1011 public Object elementAt(int index) {
1007 public Question elementAt(int index) {
10121008 return v.elementAt(index);
10131009 }
10141010
1015 public void insert(Object o) {
1011 public void insert(Question o) {
10161012 v.insertElementAt(o, findSortIndex(o));
10171013 }
10181014
1019 public void insert(Object o, boolean ignoreDuplicates) {
1015 public void insert(Question o, boolean ignoreDuplicates) {
10201016 int i = findSortIndex(o);
10211017 if (ignoreDuplicates && (i < v.size()) && (compare(o, v.elementAt(i)) == 0))
10221018 return;
10241020 v.insertElementAt(o, i);
10251021 }
10261022
1027 public void copyInto(Object[] target) {
1023 public void copyInto(Question[] target) {
10281024 v.copyInto(target);
10291025 }
10301026
1031 protected int compare(Object o1, Object o2) {
1032 String p1 = ((Question)o1).getTag();
1033 String p2 = ((Question)o2).getTag();
1027 protected int compare(Question o1, Question o2) {
1028 String p1 = o1.getTag();
1029 String p2 = o2.getTag();
10341030
10351031 if (p1 == null && p2 == null)
10361032 return 0;
10441040 return p1.compareTo(p2);
10451041 }
10461042
1047 private int findSortIndex(Object o) {
1043 private int findSortIndex(Question o) {
10481044 int lower = 0;
10491045 int upper = v.size() - 1;
10501046 int mid = 0;
10541050 }
10551051
10561052 int cmp = 0;
1057 Object last = v.elementAt(upper);
1053 Question last = v.elementAt(upper);
10581054 cmp = compare(o, last);
10591055 if (cmp > 0)
10601056 return upper + 1;
10611057
10621058 while (lower <= upper) {
10631059 mid = lower + ((upper - lower) / 2);
1064 Object entry = v.elementAt(mid);
1060 Question entry = v.elementAt(mid);
10651061 cmp = compare(o, entry);
10661062
10671063 if (cmp == 0) {
10781074 return (cmp < 0) ? mid : mid + 1;
10791075 }
10801076
1081 private Vector v;
1077 private Vector<Question> v;
10821078 }
10831079
10841080 }
2525 */
2626 package com.sun.interview;
2727
28 import java.util.Objects;
2829 import java.util.ResourceBundle;
2930
3031 /**
7374
7475 setChoices(choices, displayChoices);
7576
76 if (defaultValue != getDefaultValue()) {
77 if ( !Objects.equals(defaultValue, getDefaultValue()) ) {
7778 setDefaultValue(defaultValue);
7879 setValue(defaultValue);
7980 }
133133 }
134134
135135 protected class TestTableModel extends AbstractTableModel {
136 public Class getColumnClass(int c) {
136 public Class<?> getColumnClass(int c) {
137137 return (c == 0 ? Boolean.class : String.class);
138138 }
139139
146146 }
147147
148148 public Object getValueAt(int r, int c) {
149 return (c == 0 ? (Object) (new Boolean(values[r])) : displayChoices[r]);
149 return c == 0 ? new Boolean(values[r]) : displayChoices[r];
150150 }
151151
152152 public void setValueAt(Object o, int r, int c) {
184184
185185 protected class TestTableModel extends AbstractTableModel {
186186
187 public Class getColumnClass(int c) {
187 public Class<?> getColumnClass(int c) {
188188 return String.class;
189189 }
190190
6464 setName(uiKey);
6565 setFocusable(false);
6666
67 listModel = new DefaultListModel(); // need to force the type of model
67 listModel = new DefaultListModel<>(); // need to force the type of model
6868 if (items != null) {
6969 for (int i = 0; i < items.length; i++)
7070 listModel.addElement(items[i]);
7171 }
72 list = new JList(listModel);
72 list = new JList<>(listModel);
7373 list.setName(uiKey);
7474 list.setToolTipText(i18n.getString(uiKey + ".tip"));
7575 list.getAccessibleContext().setAccessibleName(list.getName());
119119 * @param c the component type of the array to be returned
120120 * @return an array containing the items currently in the list
121121 */
122 public Object[] getItems(Class c) {
122 public Object[] getItems(Class<?> c) {
123123 Object[] items = (Object[]) (Array.newInstance(c, listModel.size()));
124124 listModel.copyInto(items);
125125 return items;
280280
281281 protected class Renderer
282282 extends DefaultListCellRenderer {
283 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
283 public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
284284 return super.getListCellRendererComponent(list,
285285 getDisplayValue(value),
286286 index,
364364 protected boolean duplicatesAllowed;
365365 protected Listener listener = createListener();
366366 protected Renderer renderer = createRenderer();
367 protected DefaultListModel listModel;
368 protected JList list;
367 protected DefaultListModel<Object> listModel;
368 protected JList<Object> list;
369369 protected JButton addBtn;
370370 protected JButton removeBtn;
371371 protected JButton upBtn;
5454 * @param c the class for which to obtain the resource bundle
5555 * @return the appropriate resource bundle for the class
5656 */
57 public static I18NResourceBundle getBundleForClass(Class c) {
57 public static I18NResourceBundle getBundleForClass(Class<?> c) {
5858 String cn = c.getName();
5959 int dot = cn.lastIndexOf('.');
6060 String rn = (dot == -1 ? "i18n" : cn.substring(0, dot) + ".i18n");
165165 * Load the actual resource bundle, if it has not yet been loaded,
166166 * then hand the request off to that bundle.
167167 */
168 public Enumeration getKeys() {
168 public Enumeration<String> getKeys() {
169169 if (delegate == null)
170170 delegate = ResourceBundle.getBundle(name, Locale.getDefault(), classLoader);
171171 return delegate.getKeys();
303303 c.weightx = 1;
304304 msgPanel.add(errorField, c);
305305
306 listModel = new DefaultListModel();
307 list = new JList(listModel);
306 listModel = new DefaultListModel<>();
307 list = new JList<>(listModel);
308308 list.setVisibleRowCount(3);
309309 list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
310310 list.addListSelectionListener(this);
386386 protected int type;
387387 protected JTextField nameField;
388388 protected JTextField errorField;
389 protected DefaultListModel listModel;
390 protected JList list;
389 protected DefaultListModel<String> listModel;
390 protected JList<String> list;
391391 protected JButton okBtn;
392392
393393 protected static final String LOOKUP = "lookup";
113113
114114 public boolean getScrollableTracksViewportHeight() {
115115 if (getParent() instanceof JViewport) {
116 return (((JViewport)getParent()).getHeight() > getPreferredSize().height);
116 return getParent().getHeight() > getPreferredSize().height;
117117 }
118118 return false;
119119 }
167167 setFocusable(false);
168168 setLayout(new BorderLayout());
169169 pathList = new PathList();
170 list = new JList(pathList);
170 list = new JList<>(pathList);
171171 setInfo(list, "path.list", true);
172172 list.setCellRenderer(pathList);
173173 KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
230230 private QuestionPanel questionPanel;
231231 private Interview interview;
232232 private PathList pathList;
233 private JList list;
233 private JList<Object> list;
234234 private String moreText;
235235
236236 // client parameters
243243 private static final int DOTS_PER_INCH = Toolkit.getDefaultToolkit().getScreenResolution();
244244
245245 private class PathList
246 extends AbstractListModel
246 extends AbstractListModel<Object>
247247 implements ActionListener, AncestorListener,
248 ListCellRenderer, ListSelectionListener,
248 ListCellRenderer<Object>, ListSelectionListener,
249249 MouseListener,
250250 Interview.Observer
251251 {
281281 //----- state support for menus -----------------------------
282282
283283 boolean isQuestionVisible(Question q) {
284 for (int i = 0; i < currEntries.length; i++) {
285 Object e = currEntries[i];
286 if (e instanceof Question && ((Question) e) == q)
284 for (Object e : currEntries) {
285 if (e instanceof Question && e == q)
287286 return true;
288 else if (e instanceof List && ((List) e).contains(q))
287 else if (e instanceof List && ((List<?>) e).contains(q))
289288 return false;
290289 }
291290 return false;
306305 else if (qe == q)
307306 return autoOpened;
308307 }
309 else if (e instanceof List && ((List) e).contains(q))
308 else if (e instanceof List && ((List<?>) e).contains(q))
310309 return false;
311310 }
312311 return false;
349348 if (currEntries[i] == o) {
350349 Object m = currEntries[i - 1];
351350 if (m instanceof Question)
352 autoOpenSet.add(m);
351 autoOpenSet.add((Question) m);
353352 update();
354353 }
355354 }
408407 }
409408 };
410409
411 public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) {
410 public Component getListCellRendererComponent(JList<?> list, Object o, int index, boolean isSelected, boolean cellHasFocus) {
412411 if (o instanceof Question) {
413412 Question q = (Question)o;
414413 Font f;
479478 }
480479 else if (o instanceof String) {
481480 // prototype value or more...
482 sample.setText(" " + (String)o);
481 sample.setText(" " + o);
483482 sample.setFont(list.getFont().deriveFont(Font.ITALIC));
484483 sample.setForeground(list.getForeground());
485484 sample.setIcon(markersEnabled ? noMarkerIcon : null);
508507 // invoked by keyboard "enter"
509508 public void actionPerformed(ActionEvent e) {
510509 //System.err.println("PP.actionPerformed");
511 JList list = (JList)(e.getSource());
510 JList<?> list = (JList<?>)(e.getSource());
512511 Object o = list.getSelectedValue();
513512 if (o != null && o instanceof Question) {
514513 Question q = (Question)o;
532531
533532 // invoked by mouse selection (or by list.setSelectedXXX ??)
534533 public void valueChanged(ListSelectionEvent e) {
535 JList list = (JList) (e.getSource());
534 JList<?> list = (JList<?>) (e.getSource());
536535 Object o = list.getSelectedValue();
537536 if (o == null)
538537 return;
554553 }
555554 }
556555 else if (o instanceof List) {
557 List l = (List) o;
556 List<?> l = (List<?>) o;
558557 if (l.contains(interview.getCurrentQuestion()))
559558 return;
560559
606605 }
607606
608607 private boolean isOverSelection(MouseEvent e) {
609 JList l = (JList) (e.getComponent());
608 JList<?> l = (JList<?>) (e.getComponent());
610609 Rectangle r = l.getCellBounds(currIndex, currIndex);
611610 return (r.contains(e.getX(), e.getY()));
612611 }
659658 currQuestion = q;
660659 for (int i = 0; i < currEntries.length; i++) {
661660 Object o = currEntries[i];
662 if (o == q || (o instanceof List && ((List) o).contains(q))) {
661 if (o == q || (o instanceof List && ((List<?>) o).contains(q))) {
663662 currIndex = i;
664663 break;
665664 }
754753 for (int i = 0; i < currEntries.length; i++) {
755754 Object o = currEntries[i];
756755 if (o == currQuestion
757 || (o instanceof List && ((List) o).contains(currQuestion))) {
756 || (o instanceof List && ((List<?>) o).contains(currQuestion))) {
758757 currIndex = i;
759758 break;
760759 }
775774 if ( (!markersEnabled || !markersFilterEnabled) && !needMore)
776775 return path;
777776
778 Vector v = new Vector();
777 Vector<Object> v = new Vector<>();
779778 Question lastMarker = null;
780779 for (int i = 0; i < path.length; i++) {
781780 Question q = path[i];
792791 v.add(q);
793792 }
794793 else {
795 List l;
794 List<Question> l;
796795 Object o = v.lastElement();
797796 if (o == null || o instanceof Question) {
798 l = new Vector();
797 l = new Vector<>();
799798 v.add(l);
800799 }
801800 else
802 l = (List) o;
801 l = (List<Question>) o;
803802 l.add(q);
804803 }
805804 }
806805
807806 // auto-expand the final section if it doesn't end in FinalQuestion
808807 if (!(last instanceof FinalQuestion) && v.lastElement() instanceof List) {
809 List l = (List) (v.lastElement());
808 List<?> l = (List<?>) (v.lastElement());
810809 v.setSize(v.size() - 1);
811810 v.addAll(l);
812811 }
837836 private boolean[] currMarks;
838837
839838 // autoOpenSet gives which non-markered questions should be displayed
840 private Set autoOpenSet = new HashSet();
839 private Set<Question> autoOpenSet = new HashSet<>();
841840
842841 private Icon markerIcon = new MarkerIcon(true);
843842 private Icon noMarkerIcon = new MarkerIcon(false);
3131 import java.awt.KeyboardFocusManager;
3232 import java.awt.event.ActionEvent;
3333 import java.awt.event.ActionListener;
34 import java.util.ArrayList;
35 import java.util.HashMap;
34 import java.util.*;
3635
3736 import javax.accessibility.AccessibleContext;
3837
5352 import com.sun.interview.Question;
5453 import com.sun.javatest.tool.UIFactory;
5554
56 import java.util.Iterator;
57 import java.util.Set;
5855 import javax.swing.CellEditor;
5956 import javax.swing.event.AncestorEvent;
6057 import javax.swing.event.AncestorListener;
6562 public JComponent getQuestionRendererComponent(Question qq, ActionListener listener) {
6663 question = (PropertiesQuestion)qq;
6764
68 tables = new HashMap();
65 tables = new HashMap<>();
6966
7067 panel = new JPanel();
7168 panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
9390
9491 valueSaver = new Runnable() {
9592 public void run() {
96 Set keys = tables.keySet();
97 Iterator iter = keys.iterator();
93 Set<String> keys = tables.keySet();
94 Iterator<String> iter = keys.iterator();
9895 while(iter.hasNext()) {
99 JTable table = (JTable)tables.get((String)iter.next());
96 JTable table = tables.get(iter.next());
10097 CellEditor editor = table.getCellEditor();
10198 if(editor != null) {
10299 editor.stopCellEditing();
290287 String[][] d = q.getGroup(group);
291288
292289 if (d != null) {
293 ArrayList rm = null;
290 ArrayList<String> rm = null;
294291 for (int i = 0; i < d.length; i++) {
295292 if (!q.isEntryVisible(d[i][0])) {
296293 if (rm == null)
297 rm = new ArrayList();
294 rm = new ArrayList<>();
298295 else { }
299296 rm.add(d[i][0]);
300297 }
323320
324321 for (int i = 0; i < d.length; i++){
325322 if (q.getPresentationKeys() != null && q.getPresentationKeys().get(d[i][0]) != null){
326 d[i][0] = (String) q.getPresentationKeys().get(d[i][0]);
323 d[i][0] = q.getPresentationKeys().get(d[i][0]);
327324 }
328325 }
329326
366363 }
367364
368365 protected Runnable valueSaver;
369 protected HashMap tables;
366 protected Map<String, JTable> tables;
370367 protected RenderingUtilities.PropCellRenderer renderer;
371368 protected PropertiesQuestion question;
372369 protected JPanel panel;
155155 // viewport height becomes less than getPreferredSize().height, but may be enough for components
156156 // without any scrolling
157157 if(getParent() instanceof JViewport)
158 return (((JViewport)getParent()).getHeight() > getPreferredSize().height);
158 return getParent().getHeight() > getPreferredSize().height;
159159 else
160160 return false;
161161 }
212212 }
213213
214214 private void initRenderers() {
215 renderers = new HashMap();
215 renderers = new HashMap<>();
216216 renderers.put(ChoiceQuestion.class, new ChoiceQuestionRenderer());
217217 renderers.put(ChoiceArrayQuestion.class, new ChoiceArrayQuestionRenderer());
218218 renderers.put(FileQuestion.class, new FileQuestionRenderer());
227227 renderers.put(StringListQuestion.class, new StringListQuestionRenderer());
228228 renderers.put(TreeQuestion.class, new TreeQuestionRenderer());
229229 renderers.put(YesNoQuestion.class, new YesNoQuestionRenderer());
230 setCustomRenderers(new HashMap());
230 setCustomRenderers(new HashMap<Class<? extends Question>, QuestionRenderer>());
231231 }
232232
233233 /**
551551 return result;
552552 }
553553
554 private QuestionRenderer getRenderer(Question q, Map rendMap) {
555 for (Class c = q.getClass(); c != null; c = c.getSuperclass()) {
556 QuestionRenderer r = (QuestionRenderer) (rendMap.get(c));
554 private QuestionRenderer getRenderer(Question q, Map<Class<? extends Question>, QuestionRenderer> rendMap) {
555 for (Class<?> c = q.getClass(); c != null; c = c.getSuperclass()) {
556 QuestionRenderer r = rendMap.get(c);
557557 if (r != null)
558558 return r;
559559 }
567567
568568 for (int i = 0; i < p.getComponentCount(); i++) {
569569 Component c = (p.getComponent(i));
570 if ((c instanceof JComponent) && ((JComponent)c).hasFocus()
570 if ((c instanceof JComponent && c.hasFocus())
571571 || (c instanceof JPanel && anyChildHasFocus((JPanel)c)))
572572 return true;
573573 }
585585 private JTextField valueMessageField;
586586 private JPanel propsPanel;
587587 private JTextField tagField;
588 private Map renderers;
589 private Map customRenderers;
588 private Map<Class<? extends Question>, QuestionRenderer> renderers;
589 private Map<Class<? extends Question>, QuestionRenderer> customRenderers;
590590 private Listener listener = new Listener();
591591
592592 private static final I18NResourceBundle i18n = I18NResourceBundle.getDefaultBundle();
642642 private static final int PROPS_PANEL_INSETS_TOP = 0;
643643 private static final int PROPS_PANEL_INSETS_BOTTOM = 10;
644644
645 public void setCustomRenderers(Map customRenderers) {
645 public void setCustomRenderers(Map<Class<? extends Question>, QuestionRenderer> customRenderers) {
646646 this.customRenderers = customRenderers;
647647 }
648648
7474 private PropertiesQuestion q;
7575
7676 public PCE(PropertiesQuestion q) {
77 cbCE = new PropCellEditor(new JComboBox(), q);
77 cbCE = new PropCellEditor(new JComboBox<Object>(), q);
7878 tfCE = new RestrainedCellEditor(new JTextField(), q);
7979 this.q = q;
8080 }
217217 * for editing.
218218 */
219219 public static class PropCellEditor extends DefaultCellEditor {
220 protected PropCellEditor(JComboBox box) {
220 protected PropCellEditor(JComboBox<Object> box) {
221221 super(box);
222222 }
223223
224 PropCellEditor(JComboBox box, PropertiesQuestion q) {
224 PropCellEditor(JComboBox<Object> box, PropertiesQuestion q) {
225225 this(box);
226226 question = q;
227227 }
230230 * For use when this renderer is being used outside the context of
231231 * an interview and question.
232232 */
233 PropCellEditor(JComboBox box, ValueConstraints rules) {
233 PropCellEditor(JComboBox<Object> box, ValueConstraints rules) {
234234 this(box);
235235 this.rules = rules;
236236 }
281281
282282 }
283283
284 final JComboBox cb = ((JComboBox)getComponent());
284 final JComboBox<Object> cb = (JComboBox<Object>)getComponent();
285285 cb.setEditable(true);
286286 cb.removeAllItems();
287287 cb.addItem(value);
375375 }
376376 }
377377
378 private void setConstraints(JComboBox cb, ValueConstraints rules) {
378 private void setConstraints(JComboBox<Object> cb, ValueConstraints rules) {
379379 if (rules instanceof IntConstraints) {
380380 // attach input filter
381381 // add suggestions
437437 else {}
438438 }
439439 else { // generic constraints
440 ValueConstraints vRules = (ValueConstraints)rules;
440 ValueConstraints vRules = rules;
441441 }
442442 }
443443
447447 * adds a blank choice (unset). Assume the current value in the
448448 * combo box is the one at index zero.
449449 */
450 private void configureSet(JComboBox cb, String[] possible,
450 private void configureSet(JComboBox<Object> cb, String[] possible,
451451 boolean ignoreCase, boolean isUnsetAllowed) {
452452 // wishlist: i18n
453453 // values which are independent of locale
516516 }
517517 }
518518 else{
519 jComboBox = new JComboBox();
519 jComboBox = new JComboBox<>();
520520 jComboBox.addItem(value);
521521 jComboBox.setEditable(true);
522 if ( q.isValueValid((String)(q.getKeyPropertyName((String)table.getValueAt(row, 0)))) != null ) {
522 if ( q.isValueValid(q.getKeyPropertyName((String)table.getValueAt(row, 0))) != null ) {
523523 jComboBox.setBorder(new LineBorder(Color.RED, 2));
524524 }
525525 return jComboBox;
542542 PropertiesQuestion q;
543543 JCheckBox jCheckBox;
544544 YesNoBox yesNoBox;
545 JComboBox jComboBox;
545 JComboBox<Object> jComboBox;
546546 } // non-editing cell
547547
548548 static class YesNoBox extends JPanel{
3535 import java.awt.event.ActionEvent;
3636 import java.awt.event.ActionListener;
3737 import java.util.Hashtable;
38 import java.util.Map;
3839 import javax.accessibility.AccessibleContext;
3940 import javax.swing.BorderFactory;
4041 import javax.swing.DefaultListCellRenderer;
182183 setVisible(true);
183184 else {
184185 // just get this once for the query
185 Hashtable answers = new Hashtable();
186 Map<String, String> answers = new Hashtable<>();
186187 interview.save(answers);
187188 Question[] path = interview.getPath();
188189 Question curr = interview.getCurrentQuestion();
190191 if (path[i] == curr) {
191192 for (int j = 0; j < path.length; j++) {
192193 Question q = path[(i + 1 + j)%path.length];
193 String answer = (String)(answers.get(q.getTag()));
194 String answer = answers.get(q.getTag());
194195 if (matches(q, answer, caseChk.isSelected(), wordChk.isSelected())) {
195196 try {
196197 interview.setCurrentQuestion(q);
261262 return b;
262263 }
263264
264 private JComboBox createChoice(final String uiKey, final String[] choiceKeys) {
265 private JComboBox<String> createChoice(final String uiKey, final String[] choiceKeys) {
265266 // create a cache of the presentation string, for use when
266267 // rendering, but otherwise, let the JComboBox work in terms of the
267268 // choiceKeys
269270 for (int i = 0; i < choices.length; i++)
270271 choices[i] = i18n.getString(uiKey + "." + choiceKeys[i] + ".chc");
271272
272 JComboBox choice = new JComboBox(choiceKeys);
273 JComboBox<String> choice = new JComboBox<>(choiceKeys);
273274 choice.setName(uiKey);
274275 AccessibleContext ac = choice.getAccessibleContext();
275276 ac.setAccessibleName(i18n.getString(uiKey + ".tip"));
276277
277278 choice.setRenderer(new DefaultListCellRenderer() {
278 public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) {
279 public Component getListCellRendererComponent(JList<?> list, Object o, int index, boolean isSelected, boolean cellHasFocus) {
279280 Object c = o;
280281 for (int i = 0; i < choiceKeys.length; i++) {
281282 if (choiceKeys[i] == o) {
327328 private HelpBroker helpBroker;
328329 private String helpPrefix;
329330 private JTextField textField;
330 private JComboBox whereChoice;
331 private JComboBox<String> whereChoice;
331332 private JCheckBox caseChk;
332333 private JCheckBox wordChk;
333334
8080 add(field, c);
8181 }
8282 else {
83 choice = new JComboBox();
83 choice = new JComboBox<>();
8484 choice.setName(uiKey + ".chc");
8585 choice.setEditable(true);
8686 choice.setSelectedItem(q.getStringValue());
152152 }
153153
154154 protected JTextField field;
155 protected JComboBox choice;
155 protected JComboBox<String> choice;
156156
157157 private static final I18NResourceBundle i18n = I18NResourceBundle.getDefaultBundle();
158158 }
495495 ac.setAccessibleDescription(i18n.getString(uiKey + ".desc"));
496496 }
497497
498 public void setCustomRenderers(Map customRenderers) {
498 public void setCustomRenderers(Map<Class<? extends Question>, QuestionRenderer> customRenderers) {
499499 questionPanel.setCustomRenderers(customRenderers);
500500 }
501501
4141 import java.lang.reflect.Method;
4242 import java.net.URL;
4343 import java.nio.charset.StandardCharsets;
44 import java.util.Map;
4445 import java.util.Properties;
4546 import javax.swing.BorderFactory;
4647 import javax.swing.Box;
112113 try {
113114 UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
114115
115 Class ic = (Class.forName(args[0], true, ClassLoader.getSystemClassLoader()));
116 Class<?> ic = Class.forName(args[0], true, ClassLoader.getSystemClassLoader());
116117 Interview i = (Interview)(ic.newInstance());
117118 Wizard w = new Wizard(i);
118119 w.showInFrame(true);
151152 * @see #setFile
152153 */
153154 public void open(File f) throws Interview.Fault, IOException {
154 InputStream in = new BufferedInputStream(new FileInputStream(f));
155 try {
156 Properties p = new Properties();
157 p.load(in);
158 interview.load(p);
155 try (InputStream in = new BufferedInputStream(new FileInputStream(f))) {
156
157 Map<String, String> stringProps = com.sun.javatest.util.Properties.load(in);
158 interview.load(stringProps);
159159 interview.setEdited(false);
160 initialInfoVisible = p.getProperty("INFO", "true").equals("true");
161 }
162 finally {
163 in.close();
160 String info = stringProps.get("INFO");
161 if (info == null) {
162 info = "true";
163 }
164 initialInfoVisible = info.equals("true");
164165 }
165166 }
166167
171172 * @see Interview#save
172173 */
173174 public void save(File f) throws IOException {
174 OutputStream out = new BufferedOutputStream(new FileOutputStream(f));
175 try {
175 try (OutputStream out = new BufferedOutputStream(new FileOutputStream(f))) {
176176 Properties p = new Properties();
177177 if (infoPanel != null)
178178 p.put("INFO", String.valueOf(infoPanel.isShowing()));
179 interview.save(p);
179 interview.save(com.sun.javatest.util.Properties.convertToStringProps(p));
180180 interview.setEdited(false);
181181 p.save(out, "Wizard data file: " + interview.getTitle());
182 }
183 finally {
184 out.close();
185182 }
186183 }
187184
469466 if (exporters != null) {
470467 // replace the default "export log" item with a full export submenu
471468 for (int i = 0; i < fileMenu.getItemCount(); i++) {
472 JMenuItem mi = (JMenuItem)(fileMenu.getItem(i));
469 JMenuItem mi = fileMenu.getItem(i);
473470 if (mi != null && mi.getActionCommand().equals("performExportLog")) {
474471 fileMenu.remove(i);
475472 JMenu exportMenu = new ExportMenu(exporters);
548545 */
549546 private void perform(String s) {
550547 try {
551 Method m = Wizard.class.getDeclaredMethod(s, new Class[] { });
548 Method m = Wizard.class.getDeclaredMethod(s, new Class<?>[] { });
552549 m.invoke(Wizard.this, new Object[] { });
553550 }
554551 catch (IllegalAccessException ex) {
580580 SelectionTreeNode lastNode = firstNode;
581581
582582 while (lastNode.getChildCount() > 0) {
583 lastNode = (SelectionTreeNode) lastNode.getChildAt(lastNode.getChildCount() - 1);
583 lastNode = lastNode.getChildAt(lastNode.getChildCount() - 1);
584584 }
585585
586586 if (!isRootVisible()) {
711711 }
712712
713713 public String[] getSelection() {
714 Vector v = new Vector();
714 Vector<String> v = new Vector<>();
715715 getSelection((SelectionTreeNode) getModel().getRoot(), v);
716716
717717 String[] paths = new String[v.size()];
719719 return paths;
720720 }
721721
722 private void getSelection(SelectionTreeNode node, Vector v) {
722 private void getSelection(SelectionTreeNode node, Vector<String> v) {
723723 switch (node.getSelectionType()) {
724724 case UNSELECTED:
725725 break;
9999 prevNode = node;
100100 int childCount;
101101 while ((childCount = prevNode.getChildCount()) > 0) {
102 prevNode = (SelectionTreeNode) prevNode.getChildAt(childCount - 1);
102 prevNode = prevNode.getChildAt(childCount - 1);
103103 }
104104 children.add(node);
105105 }
292292 }
293293 } else {
294294 depth++;
295 result = getPathToRoot((SelectionTreeNode) aNode.getParent(), depth);
295 result = getPathToRoot(aNode.getParent(), depth);
296296 result[result.length - depth] = aNode;
297297 }
298298
667667 private TestEnvironment cachedRelevantTestFilterEnv;
668668
669669 public synchronized TestFilter[] getFilters() {
670 Vector v = new Vector();
670 Vector<TestFilter> v = new Vector<>();
671671
672672 TestFilter excludeFilter = getExcludeListFilter();
673673 if (excludeFilter != null)
799799 return true;
800800 }
801801
802 private static boolean equal(Vector v, TestFilter[] f) {
802 private static boolean equal(Vector<TestFilter> v, TestFilter[] f) {
803803 if (f == null || v.size() != f.length)
804804 return false;
805805 for (int i = 0; i < v.size(); i++) {
195195 public int hashCode() {
196196 int hash = 3;
197197 hash = 61 * hash + (this.filters != null ?
198 new HashSet(Arrays.asList(this.filters)).hashCode() : 0);
198 new HashSet<>(Arrays.asList(this.filters)).hashCode() : 0);
199199 return hash;
200200 }
201201
224224 * @return true of the two arrays of filters are equivalent.
225225 */
226226 public static boolean equals(TestFilter[] array1, TestFilter[] array2) {
227 List list1 = Arrays.asList(array1);
228 List list2 = Arrays.asList(array2);
229
230 HashSet set1 = new HashSet(list1);
231 HashSet set2 = new HashSet(list2);
227 List<TestFilter> list1 = Arrays.asList(array1);
228 List<TestFilter> list2 = Arrays.asList(array2);
229
230 HashSet<TestFilter> set1 = new HashSet<>(list1);
231 HashSet<TestFilter> set2 = new HashSet<>(list2);
232232
233233 return set1.equals(set2);
234234 }
4141 */
4242 public class DefaultTestRunner extends TestRunner
4343 {
44 public synchronized boolean runTests(Iterator testIter)
44 public synchronized boolean runTests(Iterator<TestDescription> testIter)
4545 throws InterruptedException
4646 {
4747 this.testIter = testIter;
4848
4949 Thread[] threads = new Thread[getConcurrency()];
50 activeThreads = new HashSet();
50 activeThreads = new HashSet<>();
5151 allPassed = true;
5252
5353 try {
100100 stopping = true; // stop workers from starting any new tests
101101
102102 // interrupt the worker threads
103 for (Iterator iter = activeThreads.iterator() ; iter.hasNext(); ) {
104 Thread t = (Thread) (iter.next());
103 for (Thread t : activeThreads) {
105104 t.interrupt();
106105 }
107106
140139 return null;
141140
142141 if (testIter.hasNext())
143 return (TestDescription) (testIter.next());
142 return (testIter.next());
144143 else {
145144 stopping = true;
146145 return null;
253252 private static final Integer THROWABLE = new Integer(2);
254253
255254
256 private Iterator testIter;
257 private Set activeThreads;
255 private Iterator<TestDescription> testIter;
256 private Set<Thread> activeThreads;
258257 private boolean allPassed;
259258 private boolean stopping;
260259
453453
454454 String interviewClassName = (String) (p.get("INTERVIEW"));
455455 try {
456 Class interviewClass = loader.loadClass(interviewClassName);
457
458 interview = (InterviewParameters)(interviewClass.newInstance());
456 Class<InterviewParameters> interviewClass = (Class<InterviewParameters>) loader.loadClass(interviewClassName);
457
458 interview = interviewClass.newInstance();
459459 }
460460 catch (ClassCastException e) {
461461 throw new Fault(i18n, "editJTI.invalidInterview", inFile);
592592 in = new BufferedInputStream(new FileInputStream(file));
593593 }
594594 catch (FileNotFoundException e) {
595 throw new Fault(i18n, "editJTI.cantFindImport", file);
596 }
597 catch (IOException e) {
598 throw new Fault(i18n, "editJTI.cantOpenImport",
599 new Object[] { file, e });
595 throw new Fault(i18n, "editJTI.cantFindImport", new Object[] { file, e });
600596 }
601597
602598 Properties p;
177177 * @param file The name of a file to be ignored when editing.
178178 */
179179 public void ignore(String file) {
180 ignores.add(file);
180 ignores.add(new File(file));
181181 }
182182
183183 /**
286286 int size = (int)(from.length());
287287 byte data[] = new byte[size];
288288
289 InputStream in = new BufferedInputStream(new FileInputStream(from));
290 try {
289 try (InputStream in = new BufferedInputStream(new FileInputStream(from))) {
291290 for (int total = 0; total < data.length; ) {
292291 total += in.read(data, total, data.length - total);
293292 }
294293 }
295 finally {
296 in.close();
297 }
298
299 OutputStream out = new BufferedOutputStream(new FileOutputStream(to));
300 try {
294
295 try (OutputStream out = new BufferedOutputStream(new FileOutputStream(to))) {
301296 out.write(data, 0, data.length);
302 }
303 finally {
304 out.close();
305297 }
306298 }
307299
535527 private File[] inFiles = new File[0];
536528 private File outFile;
537529 private String[][] edits = new String[0][];
538 private Set ignores = new HashSet();
530 private Set<File> ignores = new HashSet<>();
539531
540532 private int c;
541533 private int line;
2727
2828 import java.io.*;
2929 import java.nio.charset.StandardCharsets;
30 import java.util.Arrays;
31 import java.util.HashMap;
32 import java.util.Iterator;
33 import java.util.Map;
34 import java.util.SortedSet;
35 import java.util.TreeSet;
36 import java.util.Vector;
30 import java.util.*;
3731
3832 import com.sun.javatest.util.DynamicArray;
3933 import com.sun.javatest.util.I18NResourceBundle;
9892 {
9993 setStrictModeEnabled(strict);
10094 if (f != null) {
101 BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8));
102 try {
95 try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8))) {
10396 Parser p = new Parser(in);
10497 Entry e;
10598 while ((e = p.readEntry()) != null)
10699 addEntry(e);
107100
108101 title = p.getTitle();
109 }
110 finally {
111 in.close();
112102 }
113103 }
114104 }
142132 throws FileNotFoundException, IOException, Fault
143133 {
144134 setStrictModeEnabled(strict);
145 for (int i = 0; i < files.length; i++) {
146 ExcludeList et = new ExcludeList(files[i], strict);
135 for (File file : files) {
136 ExcludeList et = new ExcludeList(file, strict);
147137 merge(et);
148138 }
149139 }
375365 }
376366 else {
377367 Entry[] entries = (Entry[])o;
378 for (int i = 0; i < entries.length; i++) {
379 Entry e = entries[i];
368 for (Entry e : entries) {
380369 if (isInList(e.testCase, testCase))
381370 return e;
382371 }
393382 */
394383 public void merge(ExcludeList other) {
395384 synchronized (table) {
396 for (Iterator iter = other.getIterator(false); iter.hasNext(); ) {
385 for (Iterator<?> iter = other.getIterator(false); iter.hasNext(); ) {
397386 Entry otherEntry = (Entry) (iter.next());
398387 Key key = new Key(otherEntry.relativeURL);
399388 Object o = table.get(key);
421410 String[] bugIdStrings = otherEntry.bugIdStrings;
422411 String[] platforms = otherEntry.platforms;
423412 String synopsis = otherEntry.synopsis;
424 Entry[] curr = (Entry[])o;
425 for (int i = 0; i < curr.length; i++) {
426 bugIdStrings = mergeBugIds(bugIdStrings, curr[i].bugIdStrings);
427 platforms = mergePlatforms(platforms, curr[i].platforms);
428 synopsis = mergeSynopsis(synopsis, curr[i].synopsis);
413 for (Entry entry : (Entry[])o) {
414 bugIdStrings = mergeBugIds(bugIdStrings, entry.bugIdStrings);
415 platforms = mergePlatforms(platforms, entry.platforms);
416 synopsis = mergeSynopsis(synopsis, entry.synopsis);
429417 }
430418 table.put(key, new Entry(otherEntry.relativeURL, null,
431419 bugIdStrings, platforms, synopsis));
435423 // an entry with another set of test cases.
436424 // For now, concatenate the arrays.
437425 // RFE: Replace Entry[] with Set and merge the sets.
438 table.put(key, (Entry[]) DynamicArray.append((Entry[]) o, otherEntry));
426 table.put(key, DynamicArray.append((Entry[]) o, otherEntry));
439427 }
440428 }
441429 }
450438 }
451439
452440 static String[] merge(String[] a, String[] b) {
453 SortedSet s = new TreeSet();
441 SortedSet<String> s = new TreeSet<>();
454442 s.addAll(Arrays.asList(a));
455443 s.addAll(Arrays.asList(b));
456 return (String[]) (s.toArray(new String[s.size()]));
444 return s.toArray(new String[s.size()]);
457445 }
458446
459447 static String mergeSynopsis(String a, String b) {
486474 table.remove(key);
487475 }
488476 else {
489 Entry[] o2 = (Entry[])DynamicArray.remove((Entry[])o, e);
477 Entry[] o2 = DynamicArray.remove((Entry[])o, e);
490478 if (o2 == o)
491479 // not found
492480 return;
517505 public int size() {
518506 // ouch, this is now expensive to compute
519507 int n = 0;
520 for (Iterator i = table.values().iterator(); i.hasNext(); ) {
521 Object o = i.next();
508 for (Object o : table.values()) {
522509 if (o instanceof Entry[])
523 n += ((Entry[])o).length;
510 n += ((Entry[]) o).length;
524511 else
525512 n++;
526513 }
539526 * and @link(Entry)[], depending on the <code>group</code>
540527 * parameter.
541528 */
542 public Iterator getIterator(boolean group) {
529 public Iterator<?> getIterator(boolean group) {
543530 if (group)
544531 return table.values().iterator();
545532 else {
546533 // flatten the enumeration into a vector, then
547534 // enumerate that
548 Vector v = new Vector(table.size());
549 for (Iterator iter = table.values().iterator(); iter.hasNext(); ) {
550 Object o = iter.next();
535 Vector<Object> v = new Vector<>(table.size());
536 for (Object o : table.values()) {
551537 if (o instanceof Entry)
552538 v.addElement(o);
553539 else {
554 Entry[] entries = (Entry[])o;
555 for (int i = 0; i < entries.length; i++)
556 v.addElement(entries[i]);
540 for (Entry entry : (Entry[]) o) v.addElement(entry);
557541 }
558542 }
559543 return v.iterator();
590574 int maxURLWidth = 0;
591575 int maxBugIdWidth = 0;
592576 int maxPlatformWidth = 0;
593 SortedSet entries = new TreeSet();
594 for (Iterator iter = getIterator(false); iter.hasNext(); ) {
577 SortedSet<Entry> entries = new TreeSet<>();
578 for (Iterator<?> iter = getIterator(false); iter.hasNext(); ) {
595579 Entry entry = (Entry) (iter.next());
596580 entries.add(entry);
597581 if (entry.testCase == null)
611595 out.write("### title " + title);
612596 out.newLine();
613597 }
614 for (Iterator iter = entries.iterator(); iter.hasNext(); ) {
615 Entry e = (Entry) (iter.next());
598 for (Entry e : entries) {
616599 if (e.testCase == null)
617600 write(out, e.relativeURL, maxURLWidth + 2);
618601 else
712695 return hash;
713696 }
714697
715 private Map table = new HashMap();
698 private Map<Key, Object> table = new HashMap<>();
716699 private String title;
717700 private boolean strict;
718701
780763 // skip white space, then read and sort a list of comma-separated
781764 // numbers with no embedded white-space
782765 skipWhite();
783 TreeSet s = new TreeSet();
766 TreeSet<String> s = new TreeSet<>();
784767 StringBuffer sb = new StringBuffer();
785768 for ( ; !isEndOfLine(ch) && !isWhitespace(ch); ch = in.read()) {
786769 if (ch == ',') {
799782 if (s.size() == 0)
800783 s.add("0"); // backwards compatibility
801784
802 return (String[]) (s.toArray(new String[s.size()]));
785 return s.toArray(new String[s.size()]);
803786 }
804787
805788 private String[] readPlatforms() throws IOException {
809792 // share the result amongst all equivalent entries.
810793 skipWhite();
811794 String s = readWord();
812 String[] platforms = (String[])platformCache.get(s);
795 String[] platforms = platformCache.get(s);
813796 if (platforms == null) {
814797 // split string into sorted comma separated pieces
815798 int n = 0;
817800 if (s.charAt(i) == ',')
818801 n++;
819802 }
820 TreeSet ts = new TreeSet();
803 Set<String> ts = new TreeSet<>();
821804 int start = 0;
822805 int end = s.indexOf(',');
823806 while (end != -1) {
826809 end = s.indexOf(',', start);
827810 }
828811 ts.add(s.substring(start));
829 platforms = (String[]) (ts.toArray(new String[ts.size()]));
812 platforms = ts.toArray(new String[ts.size()]);
830813 platformCache.put(s, platforms);
831814 }
832815 return platforms;
880863
881864 private Reader in; // source stream being read
882865 private int ch; // current character
883 private Map platformCache = new HashMap();
866 private Map<String, String[]> platformCache = new HashMap<>();
884867 // cache of results for readPlatforms
885868 private String title;
886869 };
952935 /**
953936 * An entry in the exclude list.
954937 */
955 public static final class Entry implements Comparable {
938 public static final class Entry implements Comparable<Entry> {
956939 /**
957940 * Create an ExcludeList entry.
958941 * @param u The URL for the test, specified relative to the test suite root.
1010993 synopsis = s;
1011994 }
1012995
1013 public int compareTo(Object o) {
1014 Entry e = (Entry) o;
996 public int compareTo(Entry e) {
1015997 int n = relativeURL.compareTo(e.relativeURL);
1016998 if (n == 0) {
1017999 if (testCase == null && e.testCase == null)
10571039 if (testCase == null)
10581040 return null;
10591041
1060 Vector v = new Vector();
1042 Vector<String> v = new Vector<String>();
10611043 int start = -1;
10621044 for (int i = 0; i < testCase.length(); i++) {
10631045 if (testCase.charAt(i) == ',') {
308308 envError = i18n.getString("fp.envNotFound", envName);
309309 return;
310310 }
311 for (Iterator i = env.elements().iterator(); i.hasNext(); ) {
312 TestEnvironment.Element entry = (TestEnvironment.Element) (i.next());
311 for (Iterator<TestEnvironment.Element> i = env.elements().iterator(); i.hasNext(); ) {
312 TestEnvironment.Element entry = i.next();
313313 if (entry.value.indexOf("VALUE_NOT_DEFINED") >= 0) {
314314 String eText =
315315 ( (entry.definedInEnv == null ? "" : "env." + entry.definedInEnv + ".") +
2727
2828 import java.io.File;
2929 import java.io.IOException;
30 import java.util.Iterator;
31 import java.util.ArrayList;
30 import java.util.*;
3231
3332 import com.sun.javatest.TestResultTable.TreeIterator;
3433 import com.sun.javatest.httpd.HttpdServer;
3736 import com.sun.javatest.util.DynamicArray;
3837 import com.sun.javatest.util.I18NResourceBundle;
3938 import com.sun.javatest.util.ReadAheadIterator;
40 import java.util.HashMap;
41 import java.util.Set;
4239
4340 /**
4441 * The object responsible for coordinating the execution of a test run.
722719 notifier.addObserver(testURLCollector);
723720 testsStartTime = System.currentTimeMillis();
724721 try {
725 ok = r.runTests(new Iterator() {
722 ok = r.runTests(new Iterator<TestDescription>() {
726723 public boolean hasNext() {
727724 return (stopping ? false : raTestIter.hasNext());
728725 }
729 public Object next() {
730 TestResult tr = (TestResult) (raTestIter.next());
726 public TestDescription next() {
727 TestResult tr = raTestIter.next();
731728 try {
732729 return tr.getDescription();
733730 }
797794 return ok;
798795 }
799796
800 public ReadAheadIterator getTestsIterator(TreeIterator iter) throws Fault {
797 public ReadAheadIterator<TestResult> getTestsIterator(TreeIterator iter) throws Fault {
801798 if (iter == null) {
802799 iter = createTreeIterator();
803800 }
804 return new ReadAheadIterator(iter, readAheadMode, DEFAULT_READ_AHEAD);
801 return new ReadAheadIterator<TestResult>(iter, readAheadMode, DEFAULT_READ_AHEAD);
805802 }
806803
807804 private TreeIterator createTreeIterator() throws Fault {
835832 }
836833
837834 private static ArrayList<String> listFilterNames(final TestFilter[] filters) {
838 ArrayList<String> result = new ArrayList();
835 ArrayList<String> result = new ArrayList<>();
839836
840837 if (filters == null || filters.length == 0)
841838 return result; // i.e. empty
947944 private ExcludeList excludeList;
948945 private TestResultTable.TreeIterator testIter;
949946 private int readAheadMode = ReadAheadIterator.FULL;
950 private ReadAheadIterator raTestIter;
947 private ReadAheadIterator<TestResult> raTestIter;
951948 private int numTestsDone;
952949 private TestEnvironment env;
953950 private TestResultTable resultTable;
971968 void addObserver(Observer o) {
972969 if (o == null)
973970 throw new NullPointerException();
974 observers = (Observer[])DynamicArray.append(observers, o);
971 observers = DynamicArray.append(observers, o);
975972 }
976973
977974 void removeObserver(Observer o) {
978 observers = (Observer[])DynamicArray.remove(observers, o);
975 observers = DynamicArray.remove(observers, o);
979976 }
980977
981978 public void startingTestRun(Parameters params) {
11061103 TestURLCollector() {
11071104 }
11081105
1109 final ArrayList testURLs = new ArrayList();
1106 final List<String> testURLs = new ArrayList<>();
11101107
11111108 public void startingTestRun(Parameters p) { }
11121109
220220
221221 String[] pa = new String[0];
222222
223 for (Iterator i = env.elements().iterator(); i.hasNext(); ) {
224 TestEnvironment.Element elem = (TestEnvironment.Element) (i.next());
223 for (Iterator<TestEnvironment.Element> i = env.elements().iterator(); i.hasNext(); ) {
224 TestEnvironment.Element elem = i.next();
225225 // this is stunningly inefficient and should be fixed
226226 pa = PropertyArray.put(pa, elem.getKey(), elem.getValue());
227227 }
309309 TestFilter[] filters = params.getFilters();
310310 String[] tests = params.getTests();
311311
312 Iterator it = null;
312 Iterator<TestResult> it = null;
313313 if (tests == null || tests.length == 0)
314314 it = trt.getIterator(filters);
315315 else
316316 it = trt.getIterator(params.getTests(), filters);
317317
318318 while (it.hasNext()) {
319 TestResult tr = (TestResult)(it.next());
319 TestResult tr = it.next();
320320 out.println(tr.getTestName());
321321 out.println(tr.getStatus().toString());
322322 } // while
543543 buf.append("</tr>");
544544 out.println(buf.toString());
545545
546 for (Iterator keys = env.keys().iterator(); keys.hasNext(); ) {
547 String key = (String) (keys.next());
546 for (Iterator<String> keys = env.keys().iterator(); keys.hasNext(); ) {
547 String key = keys.next();
548548 out.println("<tr>");
549549 buf.setLength(0);
550550 buf.append("<td>");
3434 import java.io.IOException;
3535 import java.io.InputStream;
3636 import java.io.OutputStream;
37 import java.util.Map;
38 import java.util.Properties;
39 import java.util.ResourceBundle;
40 import java.util.Vector;
37 import java.util.*;
4138
4239 import com.sun.interview.ErrorQuestion;
4340 import com.sun.interview.FinalQuestion;
4744 import com.sun.javatest.tool.FileHistory;
4845 import com.sun.javatest.util.BackupPolicy;
4946 import com.sun.javatest.util.I18NResourceBundle;
50 import com.sun.javatest.util.SortedProperties;
47 import com.sun.javatest.util.Properties;
5148
5249 /**
5350 * Configuration parameters provided via an interview.
744741 private TestEnvironment cachedRelevantTestFilterEnv;
745742
746743 public synchronized TestFilter[] getFilters() {
747 Vector v = new Vector();
744 Vector<TestFilter> v = new Vector<>();
748745
749746 TestFilter excludeFilter = getExcludeListFilter();
750747 if (excludeFilter != null) {
801798 return true;
802799 }
803800
804 private static boolean equal(Vector v, TestFilter[] f) {
801 private static boolean equal(Vector<TestFilter> v, TestFilter[] f) {
805802 if (f == null || v.size() != f.length)
806803 return false;
807804 for (int i = 0; i < v.size(); i++) {
987984 // note: the additional Fault types were introduced in JT 3.2.1
988985
989986 // read the .jti data
990 Properties data = new Properties();
991
992 InputStream in = new BufferedInputStream(new FileInputStream(file));
993 try {
994 data.load(in);
987 Map<String, String> data;
988
989 try (InputStream in = new BufferedInputStream(new FileInputStream(file))) {
990 data = Properties.load(in);
995991 }
996992 catch (RuntimeException e) {
997993 // can get IllegalArgumentException if the file is corrupt
998994 throw new JTIFault(i18n, "ip.errorReadingFile", new Object[] { file, e });
999995 }
1000 finally {
1001 in.close();
1002 }
1003996
1004997 // if the test suite has not been given, set it from the .jti data
1005998 if (testSuite == null) {
1006 String s = (String) (data.get(TESTSUITE));
999 String s = data.get(TESTSUITE);
10071000 if (s == null)
10081001 throw new Fault(i18n, "ip.noTestSuiteInFile", file);
10091002
10231016 // if the work directory has not been given,
10241017 // set it from the .jti data if given
10251018 if (workDir == null) {
1026 String s = (String) (data.get(WORKDIR));
1019 String s = data.get(WORKDIR);
10271020 if (s != null) {
10281021 try {
10291022 workDir = WorkDirectory.open(new File(s), testSuite);
11451138 testSuite = TestSuite.open(testSuitePath);
11461139 }
11471140 catch (FileNotFoundException e) {
1148 throw new Fault(i18n, "ip.cantFindTestSuite", testSuitePath);
1149 }
1150 catch (IOException e) {
1151 throw new Fault(i18n, "ip.cantOpenTestSuite", new Object[] { testSuitePath, e });
1141 throw new Fault(i18n, "ip.cantFindTestSuite", new Object[] { testSuitePath, e });
11521142 }
11531143 catch (TestSuite.Fault e) {
11541144 throw new Fault(i18n, "ip.cantOpenTestSuite", new Object[] { testSuitePath, e.getMessage() });
11711161 workDir = WorkDirectory.open(workDirPath, testSuite);
11721162 }
11731163 catch (FileNotFoundException e) {
1174 throw new Fault(i18n, "ip.cantFindWorkDir", workDirPath);
1175 }
1176 catch (IOException e) {
1177 throw new Fault(i18n, "ip.cantOpenWorkDir", new Object[] { workDirPath, e });
1164 throw new Fault(i18n, "ip.cantFindWorkDir", new Object[] { workDirPath, e });
11781165 }
11791166 catch (WorkDirectory.Fault e) {
11801167 throw new Fault(i18n, "ip.cantOpenWorkDir", new Object[] { workDirPath, e.getMessage() });
12751262 * @return true if there was an update from template
12761263 */
12771264 public boolean load(File file) throws FileNotFoundException, IOException, Fault {
1278 InputStream in = new BufferedInputStream(new FileInputStream(file));
1279 try {
1280 Properties data = new Properties();
1281 data.load(in);
1265 try (InputStream in = new BufferedInputStream(new FileInputStream(file))) {
1266 Map<String, String> data = Properties.load(in);
12821267 return load(data, file);
1283 }
1284 finally {
1285 in.close();
12861268 }
12871269 }
12881270
12941276 * @throws Interview.Fault if there is a problem loading the interview
12951277 * @return true if there was an update from template
12961278 */
1297 public boolean load(Map data, File file) throws Fault {
1279 public boolean load(Map<String, String> data, File file) throws Fault {
12981280 load(data);
12991281
13001282 // restore template state
1301 String tm = (String) data.get(IS_TEMPLATE);
1283 String tm = data.get(IS_TEMPLATE);
13021284 setTemplate(tm != null && tm.equalsIgnoreCase(TRUE));
13031285
13041286 setEdited(false);
13161298 return prop.checkForUpdate();
13171299 }
13181300
1319 public void load(Map data, boolean checkChecksum) throws Fault {
1301 public void load(Map<String, String> data, boolean checkChecksum) throws Fault {
13201302 super.load(data, checkChecksum);
13211303
1322 String me = (String) data.get(MARKERS_ENABLED);
1304 String me = data.get(MARKERS_ENABLED);
13231305 setMarkersEnabled(me != null && me.equalsIgnoreCase(TRUE));
13241306
1325 String mf = (String) data.get(MARKERS_FILTER);
1307 String mf = data.get(MARKERS_FILTER);
13261308 setMarkersFilterEnabled(mf != null && mf.equalsIgnoreCase(TRUE));
13271309
1328 String tm = (String) data.get(IS_TEMPLATE);
1310 String tm = data.get(IS_TEMPLATE);
13291311 setTemplate(tm != null && tm.equalsIgnoreCase(TRUE));
13301312
13311313 String tu = null;
13321314 //if (isTemplate()) {
1333 tu = (String) data.get(TEMPLATE_PATH);
1315 tu = data.get(TEMPLATE_PATH);
13341316 //} else {
13351317 //tu = (String) data.get(TEMPLATE_PREF + TEMPLATE_PATH);
13361318 //}
15681550 public void saveAs(File file, boolean saveTestSuite, boolean saveWorkDir, boolean isTemplate)
15691551 throws IOException, Fault
15701552 {
1571 Properties data = new SortedProperties();
1553 SortedMap<String, String> data = new TreeMap<>();
15721554 setTemplate(isTemplate); // dubious, why do we need to do this?
15731555
15741556 if (saveTestSuite) {
15991581 out = backupPolicy.backupAndOpenStream(file);
16001582
16011583 try {
1602 data.store(out, "JT Harness Configuration Interview");
1584 Properties.store(data, out, "JT Harness Configuration Interview");
16031585 }
16041586 finally {
16051587 out.close();
16271609 saveAs(file, saveTestSuite, saveWorkDir, false);
16281610 }
16291611
1630 public void save(Map data) {
1612 public void save(Map<String, String> data) {
16311613 if (markersEnabled)
16321614 data.put(MARKERS_ENABLED, TRUE);
16331615
16371619 if (isTemplate()) {
16381620 data.put(IS_TEMPLATE, TRUE);
16391621
1640 storeTemplateProperties(new Properties());
1622 storeTemplateProperties(new HashMap<String, String>());
16411623 }
16421624 else {
16431625 WorkDirectory wd = getWorkDirectory();
3232 import com.sun.javatest.report.HTMLWriterEx;
3333 import com.sun.javatest.util.I18NResourceBundle;
3434 import com.sun.javatest.tool.CustomPropagationController.EventType;
35 import com.sun.javatest.util.Properties;
3536
3637 import java.io.BufferedInputStream;
3738 import java.io.BufferedReader;
5253 import java.util.Iterator;
5354 import java.util.LinkedHashMap;
5455 import java.util.Map;
55 import java.util.Properties;
5656 import java.util.Set;
5757
5858 public class InterviewPropagator {
7979 InputStream in = null;
8080 PrintStream psConflicts = null;
8181 PrintStream psUpdates = null;
82 boolean needToSave1=false, needToSave2=false;
83
84 Properties templateData = new Properties();
82 boolean needToSave1 = false, needToSave2 = false;
83
84 Map<String, String> templateData = new HashMap<>();
8585
8686 try {
8787 File template = new File(interview.getTemplatePath());
8888 in = new BufferedInputStream(new FileInputStream(template));
89 templateData.load(in);
89 templateData = Properties.load(in);
9090
9191 fireEvent(EventType.TemplateLoaded, templateData);
9292 } catch (FileNotFoundException ex) {
93 notifyError(i18n.getString("tmpltProp.tmpFileError", new String[] {interview.getTemplatePath()}));
93 notifyError(i18n.getString("tmpltProp.tmpFileError", new String[]{interview.getTemplatePath()}));
9494 logException(ex);
9595 } catch (IOException ex) {
96 notifyError(i18n.getString("tmpltProp.tmpFileError", new String[] {interview.getTemplatePath()}));
96 notifyError(i18n.getString("tmpltProp.tmpFileError", new String[]{interview.getTemplatePath()}));
9797 logException(ex);
9898 }
9999
101101
102102 pm = new PropogateMap();
103103
104 HashMap actual = new HashMap();
104 Map<String, String> actual = new HashMap<>();
105105 interview.save(actual);
106106
107107 // process custom changes such as property rename
112112 needToSave2 = processNotUpdatableKeys(templateData, interview);
113113
114114 // don't optimize this expression! both of methods must be invoked
115 if(needToSave1 || needToSave2) {
115 if (needToSave1 || needToSave2) {
116116 // save to file!
117117 saveInterview();
118118 }
119119
120 Map allQuestionMap = interview.getAllQuestions();
120 Map<String, Question> allQuestionMap = interview.getAllQuestions();
121121 // autoupdate partial questions
122122 if (processPartialQuestions(templateData, allQuestionMap, actual)) {
123123 // update it
156156 logException(ex);
157157 }
158158 }
159 if(needToSave1 || needToSave2 || pm.hasConflicts() || pm.hasUpdates())
159 if (needToSave1 || needToSave2 || pm.hasConflicts() || pm.hasUpdates())
160160 fireEvent(EventType.Finish, null);
161161 }
162162 cleanup();
163163 return wasUpdated;
164164 }
165165
166 private void fireEvent(EventType eventType, Properties templateData) {
166 private void fireEvent(EventType eventType, Map<String, String> templateData) {
167167 interview.getPropagationController().notify(eventType, interview, templateData);
168168 }
169169
170 private boolean processNotUpdatableKeys(Properties templateData, InterviewParameters interview) {
170 private boolean processNotUpdatableKeys(Map<String, String> templateData, InterviewParameters interview) {
171171 boolean wasUpdate = false;
172 for (Object key : templateData.keySet()) {
173 String templateKey = (String) key;
174 if(!isSystemIgnorableTemplateProperty(templateKey) && !this.interview.isUpdatableKey(templateKey)) {
175 String newTV = templateData.getProperty(templateKey);
172 for (String templateKey : templateData.keySet()) {
173 if (!isSystemIgnorableTemplateProperty(templateKey) && !this.interview.isUpdatableKey(templateKey)) {
174 String newTV = templateData.get(templateKey);
176175 String oldTV = interview.retrieveTemplateProperty(templateKey);
177176 if (oldTV != null &&
178177 !oldTV.equals(newTV)) {
179178 wasUpdate = true;
180 interview.storeTemplateProperty(templateKey, newTV);
179 interview.storeTemplateProperty(templateKey, newTV);
181180 }
182181 }
183182 }
184183 return wasUpdate;
185184 }
186185
187 private boolean processPartialQuestions(Properties templateData, Map allQuestionMap, Map actual) throws IOException {
188 Iterator keys = templateData.keySet().iterator();
186 private boolean processPartialQuestions(Map<String, String> templateData, Map<String, Question> allQuestionMap, Map<String, String> actual) throws IOException {
187 Iterator<String> keys = templateData.keySet().iterator();
189188 boolean updated = false;
190189 while (keys.hasNext()) {
191 String questionKey = (String)keys.next();
190 String questionKey = keys.next();
192191 if (!interview.isUpdatableKey(questionKey)) {
193192 continue;
194193 }
195194 if (isPropertyQuestion(questionKey, allQuestionMap)) {
196195 // create template map
197 String templateValue = templateData.getProperty(questionKey);
196 String templateValue = templateData.get(questionKey);
198197 Properties2 templateProps = InterviewPropagator.stringToProperties2(templateValue);
199198 // create actual map
200 String actualValue = (String) actual.get(questionKey);
199 String actualValue = actual.get(questionKey);
201200 Properties2 actualProps = InterviewPropagator.stringToProperties2(actualValue);
202201 String oldTVal = interview.retrieveTemplateProperty(questionKey);
203202 Properties2 oldTemplateProps = null;
206205 }
207206
208207
209 Iterator itt = templateProps.keySet().iterator();
208 Iterator<String> itt = templateProps.keySet().iterator();
210209 boolean currentQuestionUpdated = false;
211210 Properties2 oldValuesMap = new Properties2();
212211 while (itt.hasNext()) {
213 String subKey = (String)itt.next();
212 String subKey = itt.next();
214213 if (interview.isAutoUpdatableKey(questionKey, subKey) ||
215214 !actualProps.containsKey(subKey)) {
216215 String templateSubValue = templateProps.getProperty(subKey);
245244 pq.setValue(sw.toString());
246245 interview.setEdited(true);
247246 updated = true;
248 Object [] data = new Object[] {sw.toString(), swOld.toString(), swOld.toString(),
249 getQuestionText(questionKey, allQuestionMap)};
247 String[] data = new String[]{sw.toString(), swOld.toString(), swOld.toString(),
248 getQuestionText(questionKey, allQuestionMap)};
250249 pm.partialUpdateMap.put(questionKey, data);
251250 }
252251 }
254253 return updated;
255254 }
256255
257 private void processQuestionFromSet(Properties templateData, Map allQ, Set keySet, Map actual) {
258 Iterator keys = keySet.iterator();
259 while (keys.hasNext()) {
260 String questionKey = (String)keys.next();
261 if (! isIgnorableTemplateProperty(questionKey)) {
262 Object templateV = templateData.getProperty(questionKey);
263 Object oldTemplateV = interview.retrieveTemplateProperty(questionKey);
264 Object configurationV = actual.get(questionKey);
256 private void processQuestionFromSet(Map<String, String> templateData, Map<String, Question> allQ, Set<String> keySet, Map<String, String> actual) {
257 for (String questionKey : keySet) {
258 if (!isIgnorableTemplateProperty(questionKey)) {
259 String templateV = templateData.get(questionKey);
260 String oldTemplateV = interview.retrieveTemplateProperty(questionKey);
261 String configurationV = actual.get(questionKey);
265262 pm.add(questionKey, templateV, oldTemplateV, configurationV,
266263 getQuestionText(questionKey, allQ),
267264 isPropertyQuestion(questionKey, allQ));
295292
296293
297294 private boolean isFromTemplate() {
298 return ! interview.isTemplate() && interview.getTemplatePath() != null;
295 return !interview.isTemplate() && interview.getTemplatePath() != null;
299296 }
300297
301298 private String getQuestionText(String key, Map<String, Question> allQ) {
311308
312309 /**
313310 * Gets current PropogateMap
311 *
314312 * @return InterviewPropagator.PropogateMap with actual data
315313 */
316314 public InterviewPropagator.PropogateMap getPropagateMap() {
324322 public void acceptAll() {
325323 InterviewPropagator.PropogateMap pm = getPropagateMap();
326324 if (pm.hasConflicts()) {
327 Map map = pm.conflictMap;
325 Map<String, String[]> map = pm.conflictMap;
328326 acceptTemplateDatafromMap(map);
329327 try {
330328 interview.save();
342340 public void rejectAll() {
343341 InterviewPropagator.PropogateMap pm = getPropagateMap();
344342 if (pm.hasConflicts()) {
345 Map map = pm.conflictMap;
343 Map<String, String[]> map = pm.conflictMap;
346344 acceptTemplateDatafromMap(map, true);
347345 try {
348346 interview.save();
355353 }
356354
357355 // autoupdatable values
358 private void updateAll() {
356 private void updateAll() {
359357 InterviewPropagator.PropogateMap pm = getPropagateMap();
360358 if (pm.hasUpdates()) {
361 Map map = pm.updateMap;
359 Map<String, String[]> map = pm.updateMap;
362360 acceptTemplateDatafromMap(map);
363361 saveInterview();
364362 }
375373 }
376374 }
377375
378 private void acceptTemplateDatafromMap(final Map map) {
376 private void acceptTemplateDatafromMap(final Map<String, String[]> map) {
379377 acceptTemplateDatafromMap(map, false);
380378 }
381379
382380
383 private void acceptTemplateDatafromMap(final Map map, boolean templateOnly) {
384 Iterator it = map.keySet().iterator();
385 while (it.hasNext()) {
386 String key = (String) it.next();
387 Object[] vals = (Object[]) map.get(key);
381 private void acceptTemplateDatafromMap(final Map<String, String[]> map, boolean templateOnly) {
382 for (String key : map.keySet()) {
383 String[] vals = map.get(key);
388384 interview.storeTemplateProperty(key, vals[NEW_TEMPLATE].toString());
389385 }
390386 if (!templateOnly) {
391 Map actual = new HashMap();
387 Map<String, String> actual = new HashMap<>();
392388 interview.save(actual);
393 it = map.keySet().iterator();
394 while (it.hasNext()) {
395 String key = (String) it.next();
396 Object[] vals = (Object[]) map.get(key);
389 for (String key : map.keySet()) {
390 String[] vals = map.get(key);
397391 actual.put(key, vals[NEW_TEMPLATE]);
398392 }
399393 try {
435429
436430 /**
437431 * Converts string representation of property question to Properties2 object
432 *
438433 * @param str - string representation of property question
439434 * @return corresponding Properties2 object
440435 * @throws IOException
450445 /**
451446 * Properties2 object to its string representation.
452447 * Used for property question processing
448 *
453449 * @param pr - Properties2 object
454450 * @return corresponding string representation
455451 */
456 public static String properties2ToString(Properties2 pr) {
452 public static String properties2ToString(Properties2 pr) {
457453 StringWriter sw = new StringWriter();
458454 pr.save(sw, null);
459455 return sw.toString();
461457
462458 /**
463459 * Returns is the specified question is properties question
464 * @param key - question key
460 *
461 * @param key - question key
465462 * @param interview - InterviewParameters object
466463 * @return true if the specified question is properties question, otherwise false
467464 */
471468
472469 /**
473470 * Returns is the specified question is properties question
474 * @param key - question key
471 *
472 * @param key - question key
475473 * @param allQ - question map
476474 * @return true if the specified question is properties question, otherwise false
477475 */
484482 }
485483
486484
487
488485 /**
489486 * Propagation data model.
490487 */
491488 public class PropogateMap {
492489
493 void add(String key, Object templV, Object oldTemplV, Object confV, String questionText, boolean isPropQ) {
490 void add(String key, String templV, String oldTemplV, String confV, String questionText, boolean isPropQ) {
494491
495492 if (isPropQ) {
496493 propQs.add(key);
504501 }
505502
506503
507 private void add(Map aMap, String key, Object templV, Object oldTemplV, Object confV, String questionText, boolean isPropQ, Map updateMap) {
508
509
510 if (templV != null ) {
511 Object [] data = new Object[] {templV, oldTemplV, confV, questionText};
512 Object [] comp_data = data;
504 private void add(Map<String, String[]> aMap, String key, String templV, String oldTemplV, String confV, String questionText, boolean isPropQ, Map<String, String[]> updateMap) {
505
506
507 if (templV != null) {
508 String[] data = {templV, oldTemplV, confV, questionText};
509 String[] comp_data = data;
513510 boolean added = false;
514511 boolean isUpdate = false;
515512 if (isPropQ) {
520517
521518 // is it "new template value" ?
522519 if (comp_data[OLD_TEMPLATE] == null && !comp_data[NEW_TEMPLATE].equals(comp_data[CONFIGURATION])) {
523 comp_data[OLD_TEMPLATE] = notAvailable ;
520 comp_data[OLD_TEMPLATE] = notAvailable;
524521 if (comp_data[CONFIGURATION] == null) comp_data[CONFIGURATION] = notAvailable;
525 updateMap.put(key, data );
522 updateMap.put(key, data);
526523 isUpdate = added = true;
527524
528 // is it "simple template update with no conflicts" ?
525 // is it "simple template update with no conflicts" ?
529526 } else if (comp_data[OLD_TEMPLATE] != null && comp_data[CONFIGURATION] != null) {
530527 if (!comp_data[NEW_TEMPLATE].equals(comp_data[CONFIGURATION]) &&
531528 comp_data[OLD_TEMPLATE].equals(comp_data[CONFIGURATION])) {
532 updateMap.put(key, data );
529 updateMap.put(key, data);
533530 isUpdate = added = true;
534531 } else if (!comp_data[NEW_TEMPLATE].equals(comp_data[CONFIGURATION]) &&
535532 !comp_data[NEW_TEMPLATE].equals(comp_data[OLD_TEMPLATE])) {
536533 // cases 1 and 3, notify and ask user
537 aMap.put(key, data);
534 aMap.put(key, data);
538535 added = true;
539536 } else if (!comp_data[NEW_TEMPLATE].equals(comp_data[CONFIGURATION]) &&
540537 comp_data[NEW_TEMPLATE].equals(comp_data[OLD_TEMPLATE])) {
542539 //
543540 } else if (!comp_data[NEW_TEMPLATE].equals(comp_data[OLD_TEMPLATE])) {
544541 // case 2 notify and show user
545 aMap.put(key, data );
542 aMap.put(key, data);
546543 added = true;
547544 }
548545 }
579576 }
580577
581578 void makeUpdatesReport(PrintStream sw) {
582 LinkedHashMap allUpdate = new LinkedHashMap(updateMap);
579 LinkedHashMap<String, String[]> allUpdate = new LinkedHashMap<>(updateMap);
583580 allUpdate.putAll(partialUpdateMap);
584581 makeReport(sw, allUpdate, true);
585582 }
586583
587 private void makeReport(PrintStream sw, Map m, boolean hideOldTemplate) {
588 Iterator it = m.keySet().iterator();
589 if (! it.hasNext()) {
584 private void makeReport(PrintStream sw, Map<String, String[]> m, boolean hideOldTemplate) {
585 Iterator<String> it = m.keySet().iterator();
586 if (!it.hasNext()) {
590587 return;
591588 }
592589 try {
633630 writer.endTag(HTMLWriterEx.TR);
634631
635632 while (it.hasNext()) {
636 String key = (String) it.next();
637 Object [] data = (Object []) m.get(key);
633 String key = it.next();
634 String[] data = m.get(key);
638635 writer.startTag(HTMLWriterEx.TR);
639636 writer.startTag(HTMLWriterEx.TD);
640637 writer.writeAttr("class", "pname");
641 writer.writeAttr("colspan", hideOldTemplate? 2:3);
638 writer.writeAttr("colspan", hideOldTemplate ? 2 : 3);
642639 writer.startTag(HTMLWriterEx.HR);
643 writer.write((String)data[QUESTION_TEXT]);
640 writer.write(data[QUESTION_TEXT]);
644641 writer.endTag(HTMLWriterEx.TD);
645642 writer.endTag(HTMLWriterEx.TR);
646643
647644 String[] s;
648 if(!propQs.contains(key)) {
645 if (!propQs.contains(key)) {
649646 s = new String[data.length];
650 for(int i = 0; i < data.length; i++)
651 s[i] = (String)data[i];
647 for (int i = 0; i < data.length; i++)
648 s[i] = data[i];
652649 } else
653650 s = convertPQ(data);
654651
655652 writer.startTag(HTMLWriterEx.TR);
656653
657 for(int i = CONFIGURATION; i >= NEW_TEMPLATE; i--) {
658
659 if (i != OLD_TEMPLATE || ! hideOldTemplate) {
654 for (int i = CONFIGURATION; i >= NEW_TEMPLATE; i--) {
655
656 if (i != OLD_TEMPLATE || !hideOldTemplate) {
660657 writer.startTag(HTMLWriterEx.TD);
661658 writer.writeAttr("class", "val");
662659 writer.writeAttr("valign", "top");
672669 writer.endTag(HTMLWriterEx.BODY);
673670 writer.endTag(HTMLWriterEx.HTML);
674671 writer.close();
675 } catch (IOException ex){
672 } catch (IOException ex) {
676673 ex.printStackTrace();
677674 }
678675 // no finally block to close stream because it wasn't created here
679676 return;
680677 }
681678
682 private String [] convertPQ(Object[] data) {
683
684 try{
679 private String[] convertPQ(Object[] data) {
680
681 try {
685682
686683 Properties2 oldT = InterviewPropagator.stringToProperties2((String) data[OLD_TEMPLATE]);
687684 Properties2 newT = InterviewPropagator.stringToProperties2((String) data[NEW_TEMPLATE]);
689686
690687 HTMLWriterEx[] writers = new HTMLWriterEx[3];
691688 StringWriter[] stringWriters = new StringWriter[writers.length];
692 for(int i = 0; i < writers.length; i++) {
689 for (int i = 0; i < writers.length; i++) {
693690 stringWriters[i] = new StringWriter();
694691 writers[i] = new HTMLWriterEx(stringWriters[i], i18n);
695692 writers[i].startTag(HTMLWriterEx.TABLE);
719716 }
720717
721718 String[] result = new String[writers.length];
722 for(int i = 0; i < writers.length; i++) {
719 for (int i = 0; i < writers.length; i++) {
723720 writers[i].endTag(HTMLWriterEx.TABLE);
724721 writers[i].flush();
725722 result[i] = stringWriters[i].toString();
729726 } catch (IOException ex) {
730727 logException(ex);
731728 }
732 return new String[] {"", "", ""};
729 return new String[]{"", "", ""};
733730 }
734731
735732 private String getCSS() {
744741 r = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
745742
746743 String line;
747 while( (line = r.readLine()) != null )
744 while ((line = r.readLine()) != null)
748745 sb.append(line);
749746 return sb.toString();
750747 } catch (IOException ex) {
792789 }
793790
794791
795 private HashSet propQs = new HashSet();
796 private LinkedHashMap conflictMap = new LinkedHashMap();
797 private LinkedHashMap updateMap = new LinkedHashMap();
798 private LinkedHashMap partialUpdateMap = new LinkedHashMap();
792 private Set<String> propQs = new HashSet<>();
793 private Map<String, String[]> conflictMap = new LinkedHashMap<>();
794 private Map<String, String[]> updateMap = new LinkedHashMap<>();
795 private Map<String, String[]> partialUpdateMap = new LinkedHashMap<>();
799796 private File conflictReport;
800797 private File updateReport;
801798
805802
806803 public interface ViewManager {
807804 void showView(InterviewPropagator prop, InterviewParameters interview);
805
808806 void logException(Throwable th, InterviewParameters interview);
807
809808 void notifyError(String message, InterviewParameters interview);
810809 }
811810
834833 private static TestRefresher refresher;
835834 private InterviewParameters interview;
836835 private PropogateMap pm;
837 private String [] ignorableProps ;
838 private String [] ignorablePrefs ;
836 private String[] ignorableProps;
837 private String[] ignorablePrefs;
839838 }
840839
841840
153153
154154 // These methods are added for forward-compatibility with JDK1.1
155155 public void checkAwtEventQueueAccess() { }
156 public void checkMemberAccess(Class clazz, int which) { }
156 public void checkMemberAccess(Class<?> clazz, int which) { }
157157 public void checkMulticast(InetAddress maddr) { }
158158 public void checkMulticast(InetAddress maddr, byte ttl) { }
159159 public void checkPrintJobAccess() { }
202202 }
203203 }
204204 else if (perm instanceof PropertyPermission) {
205 if (((PropertyPermission)(perm)).getActions().equals("read,write"))
205 if (perm.getActions().equals("read,write"))
206206 checkPropertiesAccess();
207207 }
208208 }
104104 * @return A Keywords object for the specified type and text.
105105 * @throws Keywords.Fault if there are errors in the arguments.
106106 */
107 public static Keywords create(String type, String text, Set validKeywords) throws Fault {
108 Set lowerCaseValidKeywords = toLowerCase(validKeywords);
107 public static Keywords create(String type, String text, Set<String> validKeywords) throws Fault {
108 Set<String> lowerCaseValidKeywords = toLowerCase(validKeywords);
109109 if (text == null) {
110110 text = "";
111111 }
188188 * @return true if the the specified set of words are compatible
189189 * with this keywords object.
190190 */
191 public abstract boolean accepts(Set s);
192
193 private static Set toLowerCase(Set words) {
191 public abstract boolean accepts(Set<String> s);
192
193 private static Set<String> toLowerCase(Set<String> words) {
194194 if (words == null)
195195 return null;
196196
197197 boolean allLowerCase = true;
198 for (Iterator iter = words.iterator(); iter.hasNext() && allLowerCase; ) {
199 String word = (String) (iter.next());
198 for (Iterator<String> iter = words.iterator(); iter.hasNext() && allLowerCase; ) {
199 String word = iter.next();
200200 allLowerCase &= word.equals(word.toLowerCase());
201201 }
202202
203203 if (allLowerCase)
204204 return words;
205205
206 Set s = new HashSet();
207 for (Iterator iter = words.iterator(); iter.hasNext(); ) {
208 String word = (String) (iter.next());
206 Set<String> s = new HashSet<>();
207 for (Iterator<String> iter = words.iterator(); iter.hasNext(); ) {
208 String word = iter.next();
209209 s.add(word.toLowerCase());
210210 }
211211
230230 //------------------------------------------------------------------------------
231231
232232 abstract class SetKeywords extends Keywords {
233 HashSet<String> keys;
233 Set<String> keys;
234234 String allKwds = ""; // string to be used by toString()
235235
236 SetKeywords(String[] kwds, Set validKeywords) throws Keywords.Fault {
236 SetKeywords(String[] kwds, Set<String> validKeywords) throws Keywords.Fault {
237237 if (kwds.length == 0) {
238238 throw new Keywords.Fault(i18n, "kw.noKeywords");
239239 }
277277
278278 }
279279 class AllKeywords extends SetKeywords {
280 AllKeywords(String[] keys, Set validKeywords) throws Keywords.Fault {
280 AllKeywords(String[] keys, Set<String> validKeywords) throws Keywords.Fault {
281281 super(keys, validKeywords);
282282 }
283283
288288 * @return
289289 */
290290 @Override
291 public boolean accepts(Set s) {
291 public boolean accepts(Set<String> s) {
292292 return s.containsAll(keys);
293293 }
294294
300300
301301
302302 class AnyKeywords extends SetKeywords {
303 AnyKeywords(String[] keys, Set validKeywords) throws Keywords.Fault {
303 AnyKeywords(String[] keys, Set<String> validKeywords) throws Keywords.Fault {
304304 super(keys, validKeywords);
305305 }
306306
309309 * @return false, if none of the keywords is in the set
310310 */
311311 @Override
312 public boolean accepts(Set s) {
312 public boolean accepts(Set<String> s) {
313313 for (String kwd :keys) {
314314 if (s.contains(kwd)) {
315315 return true;
327327 //------------------------------------------------------------------------------
328328
329329 class ExprParser {
330 ExprParser(String text, Set validKeywords) {
330 ExprParser(String text, Set<String> validKeywords) {
331331 this.text = text;
332332 this.validKeywords = validKeywords;
333333 nextToken();
436436 protected static boolean allowNumericKeywords =
437437 Boolean.getBoolean("javatest.allowNumericKeywords");
438438 private String text;
439 private Set validKeywords;
439 private Set<String> validKeywords;
440440 private int index;
441441 private int token;
442442 private String idValue;
515515 super(left, right);
516516 }
517517
518 public boolean accepts(Set s) {
518 public boolean accepts(Set<String> s) {
519519 return (left.accepts(s) && right.accepts(s));
520520 }
521521
539539 this.expr = expr;
540540 }
541541
542 public boolean accepts(Set s) {
542 public boolean accepts(Set<String> s) {
543543 return !expr.accepts(s);
544544 }
545545
582582 super(left, right);
583583 }
584584
585 public boolean accepts(Set s) {
585 public boolean accepts(Set<String> s) {
586586 return (left.accepts(s) || right.accepts(s));
587587 }
588588
606606 this.expr = expr;
607607 }
608608
609 public boolean accepts(Set s) {
609 public boolean accepts(Set<String> s) {
610610 return expr.accepts(s);
611611 }
612612
649649 this.key = key;
650650 }
651651
652 public boolean accepts(Set s) {
652 public boolean accepts(Set<String> s) {
653653 return (s.contains(key));
654654 }
655655
2929
3030 import java.io.*;
3131 import java.nio.charset.StandardCharsets;
32 import java.util.HashMap;
33 import java.util.Map;
32 import java.util.*;
3433
3534 import com.sun.javatest.util.I18NResourceBundle;
36
37 import java.util.ArrayList;
38 import java.util.Iterator;
39 import java.util.TreeSet;
4035
4136 /**
4237 * Support class to read and process a list of tests and test cases which are
280275 else {
281276 // flatten the enumeration into a vector, then
282277 // enumerate that
283 ArrayList<Entry> v = new ArrayList(table.size());
284 for (Iterator<Entry> iter = table.values().iterator(); iter.hasNext(); ) {
278 List<Entry> v = new ArrayList<>(table.size());
279 for (Iterator<Object> iter = table.values().iterator(); iter.hasNext(); ) {
285280 Object o = iter.next();
286281 if (o instanceof Entry)
287282 v.add((Entry)o);
306301 */
307302 public void merge(KnownFailuresList other) {
308303 synchronized (table) {
309 for (Iterator iter = other.getIterator(false); iter.hasNext(); ) {
310 Entry otherEntry = (Entry) (iter.next());
304 for (Iterator<Entry> iter = other.getIterator(false); iter.hasNext(); ) {
305 Entry otherEntry = iter.next();
311306 Key key = new Key(otherEntry.relativeURL);
312307 Object o = table.get(key);
313308 if (o == null) {
345340 // an entry with another set of test cases.
346341 // For now, concatenate the arrays.
347342 // RFE: Replace Entry[] with Set and merge the sets.
348 table.put(key, (Entry[]) DynamicArray.append((Entry[]) o, otherEntry));
343 table.put(key, DynamicArray.append((Entry[]) o, otherEntry));
349344 }
350345 }
351346 }
582577 // skip white space, then read and sort a list of comma-separated
583578 // numbers with no embedded white-space
584579 skipWhite();
585 TreeSet s = new TreeSet();
580 Set<String> s = new TreeSet<>();
586581 StringBuilder sb = new StringBuilder();
587582 for ( ; !isEndOfLine(ch) && !isWhitespace(ch); ch = in.read()) {
588583 if (ch == ',') {
601596 if (s.isEmpty())
602597 s.add("0"); // backwards compatibility
603598
604 return (String[]) (s.toArray(new String[s.size()]));
599 return s.toArray(new String[s.size()]);
605600 }
606601
607602 private String readRest() throws IOException {
711706 /**
712707 * An entry in the exclude list.
713708 */
714 public static final class Entry implements Comparable {
709 public static final class Entry implements Comparable<Entry> {
715710 /**
716711 * Create an ExcludeList entry.
717712 * @param u The URL for the test, specified relative to the test suite root.
736731 notes = s;
737732 }
738733
739 public int compareTo(Object o) {
740 Entry e = (Entry) o;
734 public int compareTo(Entry e) {
741735 int n = relativeURL.compareTo(e.relativeURL);
742736 if (n == 0) {
743737 if (testCase == null && e.testCase == null)
797791 if (testCase == null)
798792 return null;
799793
800 ArrayList v = new ArrayList();
794 List<String> v = new ArrayList<>();
801795 int start = -1;
802796 for (int i = 0; i < testCase.length(); i++) {
803797 if (testCase.charAt(i) == ',') {
2828 import java.io.IOException;
2929 import java.io.File;
3030 import java.util.ArrayList;
31 import java.util.List;
3132
3233 import com.sun.javatest.util.I18NResourceBundle;
3334
111112 if (fileTestURLs == null) {
112113 fileTestURLs = new File[testURLs.size()];
113114 for (int i = 0; i < fileTestURLs.length; i++) {
114 fileTestURLs[i] = new File((String)testURLs.get(i));
115 fileTestURLs[i] = new File(testURLs.get(i));
115116 }
116117 }
117118 return fileTestURLs;
170171
171172 private WorkDirectory workdir;
172173 private long lastStart;
173 private ArrayList testURLs = new ArrayList();
174 private List<String> testURLs = new ArrayList<>();
174175 private File[] fileTestURLs = null; // testURLs as file array
175176 private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(LastRunFilter.class);
176177 }
2828 import java.io.FileInputStream;
2929 import java.io.FileOutputStream;
3030 import java.io.IOException;
31 import java.util.Date;
32 import java.util.ArrayList;
33 import java.util.Iterator;
34 import java.util.Properties;
31 import java.util.*;
3532
3633 /**
3734 * Information about the last or current test run. This is an interface onto
4441 private LastRunInfo(WorkDirectory wd) throws IOException {
4542 this();
4643
47 FileInputStream in = null;
4844 Properties p;
49 try {
50 in = new FileInputStream(wd.getSystemFile(FILENAME));
45 try (FileInputStream in = new FileInputStream(wd.getSystemFile(FILENAME))) {
5146 p = new Properties();
5247 p.load(in);
53 } finally {
54 try { if (in != null) in.close(); } catch (IOException e) {}
5548 }
5649
5750 String val = p.getProperty(START);
133126 * Get the URLs of the tests that were executed in the last test run.
134127 * @return String array of testURLs executed.
135128 */
136 public ArrayList getTestURLs() {
129 public List<String> getTestURLs() {
137130 return testURLs;
138131 }
139132
142135 * @param list
143136 * @return A single string with all the items in the list joined.
144137 */
145 private static String join(ArrayList list) {
138 private static String join(List<String> list) {
146139 if (list == null) {
147140 return "";
148141 }
149142 StringBuffer sb = new StringBuffer();
150 for (Iterator it = list.iterator(); it.hasNext();) {
151 sb.append((String)it.next());
143 for (Iterator<String> it = list.iterator(); it.hasNext();) {
144 sb.append(it.next());
152145 sb.append(SEP);
153146 }
154147
163156 * @param joined - string to split
164157 * @return array list, never null.
165158 */
166 private static ArrayList split(String joined) {
167 ArrayList list = new ArrayList();
159 private static List<String> split(String joined) {
160 List<String> list = new ArrayList<>();
168161 if (joined == null || joined.trim().length() == 0) {
169162 return list;
170163 }
207200 * created, opened, written into or deleted.
208201 */
209202 public static void writeInfo(WorkDirectory workdir, long start, long stop,
210 String config, ArrayList testURLs)
203 String config, List<String> testURLs)
211204 throws IOException {
212205 Properties p = new Properties();
213206 p.setProperty(CONFIG, config);
215208 p.setProperty(FINISH, Long.toString(stop));
216209 p.setProperty(TEST_URLS, join(testURLs));
217210
218 FileOutputStream out = null;
219 try {
220 out = new FileOutputStream(workdir.getSystemFile(FILENAME));
211 try (FileOutputStream out = new FileOutputStream(workdir.getSystemFile(FILENAME))) {
221212
222213 // this is a date file, does not need i18n
223214 p.store(out, "Last test run info");
224 }
225 finally {
226 try { if (out != null) out.close(); } catch (IOException e) {}
227215 }
228216 }
229217
230218 private String configName;
231219 private long startTime;
232220 private long finishTime;
233 private ArrayList testURLs;
221 private List<String> testURLs;
234222
235223 // file in the work dir
236224 private static final String FILENAME = "lastRun.txt";
5151 * @param o The observer to be registered. Should never be null.
5252 */
5353 public void addObserver(Observer o) {
54 observers = (Observer[])DynamicArray.append(observers, o);
54 observers = DynamicArray.append(observers, o);
5555 }
5656
5757 /**
6060 * @param o The filter to be un-registered.
6161 */
6262 public void removeObserver(Observer o) {
63 observers = (Observer[])DynamicArray.remove(observers, o);
63 observers = DynamicArray.remove(observers, o);
6464 }
6565
6666 /**
3636 import java.net.URLDecoder;
3737 import java.text.DateFormat;
3838 import java.text.ParseException;
39 import java.util.ArrayList;
40 import java.util.Date;
41 import java.util.Locale;
42 import java.util.Properties;
43 import java.util.StringTokenizer;
39 import java.util.*;
4440
4541
4642 /**
9288 */
9389 private static int[] parseVersion(String v) {
9490 int[] arr = {0,0,0,0,0,0,0,0,0,0};
95 ArrayList list = new ArrayList();
91 List<String> list = new ArrayList<>();
9692 StringTokenizer st = new StringTokenizer(v, ".");
9793 while (st.hasMoreTokens()) {
9894 list.add(st.nextToken());
4444
4545 public class ResourceLoader {
4646
47 public static Enumeration getResources(String name, Class ownClass) throws IOException {
47 public static Enumeration<URL> getResources(String name, Class<?> ownClass) throws IOException {
4848 URL extResource = getExtResource(name, null);
4949 if (extResource != null) {
50 Vector r = new Vector();
50 Vector<URL> r = new Vector<>();
5151 r.add(extResource);
5252 return r.elements();
5353 }
5454 return ownClass.getClassLoader().getResources(name);
5555 }
5656
57 public static InputStream getResourceAsStream(final String name, final Class ownClass) {
57 public static InputStream getResourceAsStream(final String name, final Class<?> ownClass) {
5858 URL url = getExtResource(name, ownClass);
5959 try {
6060 if (url != null) {
7474 }
7575 }
7676
77 public static File getResourceFile(String name, Class ownClass) {
77 public static File getResourceFile(String name, Class<?> ownClass) {
7878 File f = getExtResourceFile(name, ownClass);
7979 if (f != null) {
8080 return f;
100100 return url;
101101 }
102102
103 private static URL getExtResource(String name, Class ownClass) {
103 private static URL getExtResource(String name, Class<?> ownClass) {
104104 URL ret = null;
105105 File rf = getExtResourceFile(name, ownClass);
106106 if (rf != null) {
113113 return ret;
114114 }
115115
116 private static File getExtResourceFile(String name, Class ownClass) {
116 private static File getExtResourceFile(String name, Class<?> ownClass) {
117117 if (ext != null) {
118118 String relName;
119119 if (ownClass == null) {
132132
133133
134134 // get from java.lang.Class with minimal changes
135 private static String resolveName(String name, Class baseClass) {
135 private static String resolveName(String name, Class<?> baseClass) {
136136 if (name == null || baseClass == null) {
137137 return name;
138138 }
2525 */
2626 package com.sun.javatest;
2727
28 import java.util.Arrays;
29 import java.util.HashMap;
30 import java.util.TreeSet;
28 import java.util.*;
3129
3230 /**
3331 * A table providing simple named locks for arbitrary resources.
3836 * Create a resource table.
3937 */
4038 public ResourceTable() {
41 table = new HashMap();
39 table = new HashMap<>();
4240 }
4341
4442 /**
4644 * @param initialSize a hint as to the initial capacity to make the table
4745 */
4846 public ResourceTable(int initialSize) {
49 table = new HashMap(initialSize);
47 table = new HashMap<>(initialSize);
5048 }
5149
5250 /**
6563 if (resourceNames.length > 1) {
6664 // sort and remove duplicates
6765 // canonicalize acquisition order to prevent deadlocks
68 TreeSet ts = new TreeSet();
66 Set<String> ts = new TreeSet<>();
6967 ts.addAll(Arrays.asList(resourceNames));
7068 String[] s = new String[ts.size()];
7169 ts.toArray(s);
116114 notifyAll();
117115 }
118116
119 private HashMap table;
117 private Map<String, Thread> table;
120118 }
718718 if (!cdf.exists())
719719 cdf.mkdirs();
720720
721 Vector v = new Vector(0, srcs.length);
721 Vector<String> v = new Vector<>(0, srcs.length);
722722
723723 for (int i = 0; i < srcs.length; i++) {
724724 String src = srcs[i];
732732 // if none found, set setPrefix to empty string
733733 // if error, report the error, ignore pkgPrefix, and set file to
734734 // be unconditionally compiled.
735 BufferedReader r = null;
736 try {
737 r = new BufferedReader(new FileReader(src));
735 try (BufferedReader r = new BufferedReader(new FileReader(src))) {
738736 StreamTokenizer tr = new StreamTokenizer(r);
739737 tr.ordinaryChar('/');
740738 tr.slashStarComments(true);
763761 v.addElement(src);
764762 continue;
765763 }
766 finally {
767 if (r != null) {
768 try {
769 r.close();
770 }
771 catch (IOException ignore) {
772 }
773 }
774 }
775764
776765
777766 File srcFile = new File(src);
1006995 section.getMessageWriter().println(i18n.getString("script.command",
1007996 new Object[] {className, StringArray.join(args) }));
1008997
1009 PrintWriter out1 = null;
1010 PrintWriter out2 = null;
1011 try {
1012 out1 = section.createOutput(cmdOut1Name);
1013 out2 = section.createOutput(cmdOut2Name);
998 try (PrintWriter out1 = section.createOutput(cmdOut1Name);
999 PrintWriter out2 = section.createOutput(cmdOut2Name)) {
10141000
10151001 s = invokeClass(className, args, out1, out2);
1016
1017 out1.close();
1018 out2.close();
1019 }
1020 finally {
1021 if (out2 != null) out2.close();
1022 if (out1 != null) out1.close();
10231002 }
10241003
10251004 section.setStatus(s);
10601039 // says in the environment file:
10611040 Command testCommand;
10621041 try {
1063 Class c = (loader == null ? Class.forName(className) : loader.loadClass(className));
1042 Class<?> c = (loader == null ? Class.forName(className) : loader.loadClass(className));
10641043 testCommand = (Command)(c.newInstance());
10651044 }
10661045 catch (ClassCastException e) {
140140 }
141141 else {
142142 */
143 Iterator it = trt.getIterator();
143 Iterator<TestResult> it = trt.getIterator();
144144 while (it.hasNext()) {
145 TestResult tr = (TestResult)(it.next());
145 TestResult tr = it.next();
146146 String url;
147147 try {
148148 url = tr.getDescription().getRootRelativeURL();
2525 */
2626 package com.sun.javatest;
2727
28 import java.util.ArrayList;
29 import java.util.Enumeration;
30 import java.util.HashMap;
31 import java.util.Iterator;
32 import java.util.LinkedList;
33 import java.util.NoSuchElementException;
34 import java.util.Stack;
28 import java.util.*;
3529
3630 import com.sun.javatest.tool.Preferences;
3731 import com.sun.javatest.util.Debug;
3832 import com.sun.javatest.util.I18NResourceBundle;
39 import java.util.Set;
4033
4134
4235 /**
6154 * construction code and does not create a usable object.
6255 */
6356 protected TRT_Iterator() {
64 outQueue = new LinkedList();
57 outQueue = new LinkedList<>();
6558 resultStats = new int[Status.NUM_STATES];
6659 nodeIndex = -1;
6760 currFrame = null;
133126 this.filters = filters;
134127
135128 if (trs != null && trs.length != 0) {
136 ArrayList names = new ArrayList();
129 ArrayList<String> names = new ArrayList<>();
137130
138131 // prime the outqueue with the given tests
139132 for (int i = 0; i < trs.length; i++) {
176169 }
177170
178171 @Override
179 public Object nextElement() {
172 public TestResult nextElement() {
180173 TestResult val = null;
181174 synchronized (outQueueLock) {
182175 if (hasMoreElements()) {
203196 }
204197
205198 @Override
206 public Object next() {
199 public TestResult next() {
207200 return nextElement();
208201 }
209202
246239 // only create new objects if they don't exist
247240 // users can turn on and off this feature if they want
248241 if (filteredTRs == null) {
249 filteredTRs = new HashMap(10); // not likely to have > 10 filters
242 filteredTRs = new HashMap<>(10); // not likely to have > 10 filters
250243 }
251244
252245 if (fo == null) {
289282 else {
290283 // create shallow copy
291284 // keys are TRs, values are TestFilters.
292 HashMap<TestFilter, ArrayList<TestDescription>> out = new HashMap(filteredTRs.size());
285 HashMap<TestFilter, ArrayList<TestDescription>> out = new HashMap<>(filteredTRs.size());
293286
294287 synchronized (rejLock) {
295 Set keys = filteredTRs.keySet();
288 Set<TestFilter> keys = filteredTRs.keySet();
296289 // each key is a TestFilter
297290 Iterator<TestFilter> it = keys.iterator();
298291 while (it.hasNext()) {
299292 // could cast this to TestFilter, but why?
300293 TestFilter thisKey = it.next();
301 ArrayList<TestDescription> al = (ArrayList<TestDescription>) filteredTRs.get(thisKey).clone();
294 ArrayList<TestDescription> al = new ArrayList<>(filteredTRs.get(thisKey));
302295 out.put(thisKey, al);
303296 } // outer while
304297 } // sync
341334 @Override
342335 public String[] getInitialURLs() {
343336 String[] list = null;
344 ArrayList urls = new ArrayList();
337 List<String> urls = new ArrayList<>();
345338
346339 // can we correctly show the effective urls from here? what about TCs?
347340 if (nodes != null) {
428421 // XXX special cases here...
429422
430423 // it would be nicer if we could just cast to TRT.TreeNode
431 PseudoFrame frame = (PseudoFrame)(stack.elementAt(j));
424 PseudoFrame frame = stack.elementAt(j);
432425 TRT_TreeNode tn = (TRT_TreeNode)(frame.getNode());
433426 int pos = tn.getNodeIndex(dir, false);
434427 int currIndex = frame.getCurrentIndex();
712705 private boolean nextNode() {
713706 // stacks only valid in the context of a single node
714707 // we create a new one when we move to a new initial node
715 stack = new Stack();
708 stack = new Stack<>();
716709
717710 // invalidate the current frame
718711 // NOTE: a null currFrame will terminate the iteration in findNext()
759752 */
760753 private PseudoFrame pop() {
761754 if (!stack.empty())
762 return (PseudoFrame)(stack.pop());
755 return stack.pop();
763756 else
764757 return null;
765758 }
958951 boolean recordRejectTR = p.getPreference("exec.recordNotrunReasons", "false").equals("true");
959952
960953 // ------ state information ------
961 private Stack stack;
954 private Stack<PseudoFrame> stack;
962955 private PseudoFrame currFrame;
963956
964957 private boolean finished = false;
10151008 @Override
10161009 public void rejected(TestDescription d, TestFilter rejector) {
10171010 synchronized (rejLock) {
1018 ArrayList vec = filteredTRs.get(rejector);
1011 ArrayList<TestDescription> vec = filteredTRs.get(rejector);
10191012 if (vec == null) {
1020 vec = new ArrayList();
1013 vec = new ArrayList<>();
10211014 filteredTRs.put(rejector, vec);
10221015 }
10231016
2727 package com.sun.javatest;
2828
2929 import java.io.File;
30 import java.util.ArrayList;
31 import java.util.Hashtable;
32 import java.util.HashMap;
30 import java.util.*;
3331
3432 import com.sun.javatest.util.Debug;
3533 import com.sun.javatest.util.DynamicArray;
3634 import com.sun.javatest.util.I18NResourceBundle;
3735
3836 import com.sun.javatest.TestResultTable.TreeNode;
39 import java.util.Iterator;
4037
4138 /**
4239 * This is the implementation of a tree node structure for TestResultTable.
5047 * Add an observer to watch this node for changes.
5148 */
5249 public synchronized void addObserver(TestResultTable.TreeNodeObserver obs) {
53 TestResultTable.TreeNodeObserver[] observers =
54 (TestResultTable.TreeNodeObserver[])observerTable.get(this);
50 TestResultTable.TreeNodeObserver[] observers = observerTable.get(this);
5551
5652 if (observers == null) observers = new TestResultTable.TreeNodeObserver[0];
57 observers = (TestResultTable.TreeNodeObserver[])(DynamicArray.append(observers, obs));
53 observers = DynamicArray.append(observers, obs);
5854 observerTable.put(this, observers);
5955 }
6056
6258 * Remove an observer that was previously added.
6359 */
6460 public synchronized void removeObserver(TestResultTable.TreeNodeObserver obs) {
65 TestResultTable.TreeNodeObserver[] observers =
66 (TestResultTable.TreeNodeObserver[])observerTable.get(this);
61 TestResultTable.TreeNodeObserver[] observers = observerTable.get(this);
6762 if (observers == null)
6863 return;
6964
70 observers = (TestResultTable.TreeNodeObserver[])(DynamicArray.remove(observers, obs));
65 observers = DynamicArray.remove(observers, obs);
7166 if (observers == null)
7267 observerTable.remove(this);
7368 else
711706 // anymore
712707 if (newTd == null) // create an "emergency" one
713708 newTd = new TestDescription(table.getTestFinder().getRoot(),
714 new File(filename), new HashMap());
709 new File(filename), new HashMap<String, String>());
715710
716711 newTr = TestResult.notRun(newTd);
717712
14201415
14211416 // if no conflicts were found, append it
14221417 if (node.filesToScan == null || i >= node.filesToScan.length)
1423 node.filesToScan = (String[])DynamicArray.append(node.filesToScan, file);
1418 node.filesToScan = DynamicArray.append(node.filesToScan, file);
14241419 else {
14251420 // name collision, ignore
14261421 // actually, with scan suppression, this may be normal
17581753 // these methods assume that the parent of the action is "this"
17591754
17601755 private void notifyInsBranch(TRT_TreeNode newNode, int index) {
1761 TestResultTable.TreeNodeObserver[] observers = (TestResultTable.TreeNodeObserver[])(observerTable.get(this));
1756 TestResultTable.TreeNodeObserver[] observers = observerTable.get(this);
17621757
17631758 if (observers != null)
17641759 for (int i = 0; i < observers.length; i ++)
17661761 }
17671762
17681763 private void notifyInsResult(TestResult test, int index) {
1769 TestResultTable.TreeNodeObserver[] observers = (TestResultTable.TreeNodeObserver[])(observerTable.get(this));
1764 TestResultTable.TreeNodeObserver[] observers = observerTable.get(this);
17701765
17711766 if (observers != null)
17721767 for (int i = 0; i < observers.length; i ++)
17741769 }
17751770
17761771 private void notifyReplacedResult(TestResult oldTest, TestResult newTest, int index) {
1777 TestResultTable.TreeNodeObserver[] observers = (TestResultTable.TreeNodeObserver[])(observerTable.get(this));
1772 TestResultTable.TreeNodeObserver[] observers = observerTable.get(this);
17781773
17791774 if (observers != null)
17801775 for (int i = 0; i < observers.length; i ++)
17821777 }
17831778
17841779 private void notifyRemovedBranch(int index) {
1785 TestResultTable.TreeNodeObserver[] observers = (TestResultTable.TreeNodeObserver[])(observerTable.get(this));
1780 TestResultTable.TreeNodeObserver[] observers = observerTable.get(this);
17861781
17871782 if (observers != null)
17881783 for (int i = 0; i < observers.length; i ++)
17901785 }
17911786
17921787 private void notifyRemovedResult(TestResult test, int index) {
1793 TestResultTable.TreeNodeObserver[] observers = (TestResultTable.TreeNodeObserver[])(observerTable.get(this));
1788 TestResultTable.TreeNodeObserver[] observers = observerTable.get(this);
17941789
17951790 if (observers != null)
17961791 for (int i = 0; i < observers.length; i ++)
17981793 }
17991794
18001795 private void notifyCounterChange() {
1801 TestResultTable.TreeNodeObserver[] observers = (TestResultTable.TreeNodeObserver[])(observerTable.get(this));
1796 TestResultTable.TreeNodeObserver[] observers = observerTable.get(this);
18021797 if (observers != null)
18031798 for (int i = 0; i < observers.length; i ++) {
18041799 observers[i].countersInvalidated(this);
18231818 private long lastScanDate;
18241819
18251820 // no per-instance array of observers, use a static Hashtable of arrays
1826 private static Hashtable observerTable = new Hashtable(16);
1821 private static Map<TRT_TreeNode, TestResultTable.TreeNodeObserver[]> observerTable = new Hashtable<>(16);
18271822
18281823 /**
18291824 * List of files that makeup the on-disk contents of this node.
7070 File dataFile = wd.getSystemFile(TEMPLATE_FILE);
7171 Properties p = new Properties();
7272
73 FileInputStream in = null;
74 try {
75 in = new FileInputStream(dataFile);
73 try (FileInputStream in = new FileInputStream(dataFile)) {
7674 p.load(in);
7775 }
7876 catch (FileNotFoundException e) {
8280 }
8381 catch (IOException e) {
8482 // should log the error
85 }
86 finally {
87 try {
88 if (in != null)
89 in.close();
90 }
91 catch (IOException e) {
92 }
9383 }
9484
9585 if (p != null)
5959 * filename and does not begin with the root filename.
6060 *
6161 */
62 public TestDescription(File root, File file, Map params)
62 public TestDescription(File root, File file, Map<?, ?> params)
6363 throws IllegalArgumentException {
6464
6565 synchronized (this.getClass()) {
8989 rootRelativeFile = fp;
9090 rootRelativePath = rootRelativeFile.replace(File.separatorChar, '/');
9191
92 Vector v = new Vector(0, params.size() * 2);
93 for (Iterator i = params.keySet().iterator(); i.hasNext(); ) {
94 String key = (String) (i.next());
95 String value = (String)(params.get(key));
96 insert(v, key, value);
92 Vector<String> v = new Vector<>(0, params.size() * 2);
93 for (Map.Entry<?, ?> entry : params.entrySet()) {
94 insert(v, (String) entry.getKey(), (String) entry.getValue());
9795 }
9896 fields = new String[v.size()];
9997 v.copyInto(fields);
108106 char sep = file.charAt(root.length());
109107 rootRelativePath = file.substring(root.length() + 1).replace(sep, '/');
110108
111 Vector v = new Vector(0, params.length);
109 Vector<String> v = new Vector<>(0, params.length);
112110 for (int i = 0; i < params.length; i += 2) {
113111 String key = params[i];
114112 if (!(key.startsWith("$") || key.equals("testsuite") || key.equals("file"))) {
238236 * They are returned in canonical form (lower-case).
239237 * @return the set of keywords
240238 */
241 public Set getKeywordTable() {
239 public Set<String> getKeywordTable() {
242240 String[] keys = StringArray.split(getParameter("keywords"));
243 Set s = new TreeSet();
241 Set<String> s = new TreeSet<>();
244242 for (int i = 0; i < keys.length; i++) {
245243 String k = keys[i].toLowerCase();
246244 s.add(k);
454452 * this test description.
455453 * @return an iterator for the names of the parameters
456454 */
457 public Iterator getParameterKeys() {
458 return new Iterator() {
455 public Iterator<String> getParameterKeys() {
456 return new Iterator<String>() {
459457 int pos = 0;
460458
461459 public boolean hasNext() {
467465 }
468466 }
469467
470 public Object next() {
468 public String next() {
471469 if(fields == null || fields.length == 0 ||
472470 pos == fields.length) {
473471 return null;
533531 * WARNING: If this description has been read in from a .jtr file, the rootDir
534532 * may be inappropriate for this system.
535533 */
536 void save(Map p) {
534 void save(Map<String, String> p) {
537535 saveField(p, "$root", rootDir);
538536 saveField(p, "$file", getFile().getPath());
539537 for (int i = 0; i < fields.length; i+=2) {
541539 }
542540 }
543541
544 private void saveField(Map p, String key, String value) {
542 private void saveField(Map<String, String> p, String key, String value) {
545543 if (value != null)
546544 p.put(key, value);
547545 }
563561 return new TestDescription(r, f, params);
564562 }
565563
566 private static void insert(Vector v, String key, String value) {
564 private static void insert(Vector<String> v, String key, String value) {
567565 int lower = 0;
568566 int upper = v.size() - 2;
569567 int mid = 0;
574572 return;
575573 }
576574
577 String last = (String)v.elementAt(upper);
575 String last = v.elementAt(upper);
578576 int cmp = key.compareTo(last);
579577 if (cmp > 0) {
580578 v.addElement(key);
585583 while (lower <= upper) {
586584 // in next line, take care to ensure that mid is always even
587585 mid = lower + ((upper - lower) / 4) * 2;
588 String e = (String)(v.elementAt(mid));
586 String e = v.elementAt(mid);
589587 cmp = key.compareTo(e);
590588 if (cmp < 0) {
591589 upper = mid - 2;
6666 * @throws TestEnvContext.Fault if an error is found while reading the files
6767 */
6868 public TestEnvContext(File[] files) throws Fault {
69 Vector n = new Vector();
70 Vector p = new Vector();
69 Vector<String> n = new Vector<>();
70 Vector<Map<String, String>> p = new Vector<>();
7171 try {
7272 if (files != null) {
7373 for (int i = 0; i < files.length; i++) {
9292 * that will be used to identify the source of the properties in any
9393 * environments that are created
9494 */
95 public TestEnvContext(Map[] tables, String[] tableNames) {
96 Vector n = new Vector();
97 Vector p = new Vector();
95 public TestEnvContext(Map<String, String>[] tables, String[] tableNames) {
96 Vector<String> n = new Vector<>();
97 Vector<Map<String, String>> p = new Vector<>();
9898 for (int i = 0; i < tables.length; i++) {
9999 add(p, n, tables[i], tableNames[i]);
100100 }
111111 * @param tableName The name that will be used to identify the source
112112 * of the properties in any environments that are created.
113113 */
114 public TestEnvContext(Map table, String tableName) {
115 Vector n = new Vector();
116 Vector p = new Vector();
114 public TestEnvContext(Map<String, String> table, String tableName) {
115 Vector<String> n = new Vector<>();
116 Vector<Map<String, String>> p = new Vector<>();
117117 add(p, n, table, tableName);
118118 propTables = new Map[p.size()];
119119 p.copyInto(propTables);
176176 return envMenuNames;
177177 }
178178
179 private Map load(File f) throws Fault {
179 private Map<String, String> load(File f) throws Fault {
180180 if (f == null)
181181 return null;
182182
183183 try {
184 Properties p = new Properties();
185 Reader in = new BufferedReader(new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8));
186 p.load(in);
184 InputStream in = new BufferedInputStream(new FileInputStream(f));
185 Map<String, String> p = Properties.load(in);
187186 in.close();
188187
189188 /*
226225 */
227226 }
228227
229 private void add(Vector pv, Vector nv, Map p, String n) {
228 private void add(Vector<Map<String, String>> pv, Vector<String> nv, Map<String, String> p, String n) {
230229 if (p != null) {
231230 pv.addElement(p);
232231 nv.addElement(n);
235234
236235 private void updateEnvTable() {
237236 // the tables given to the constructor ...
238 Map[] tables = propTables;
237 Map<String, String>[] tables = propTables;
239238 String[] tableNames = propTableNames;
240239
241240 // defaults given to TestEnvironment
242 Map[] defaultTables = TestEnvironment.defaultPropTables;
241 Map<String, String>[] defaultTables = TestEnvironment.defaultPropTables;
243242 String[] defaultTableNames = TestEnvironment.defaultPropTableNames;
244243
245244 // if there are defaults, merge them with the TestEnvContext tables
246245 // for the purposes of determining the EnvTable
247246 if (defaultTables != null && defaultTables.length > 0) {
248 tables = (Map[]) (DynamicArray.join(defaultTables, tables));
249 tableNames = (String[]) (DynamicArray.join(defaultTableNames, tableNames));
250 }
251
252 Vector allVec = new Vector();
253 Vector menuExcludeVec = new Vector();
247 tables = DynamicArray.join(defaultTables, tables);
248 tableNames = DynamicArray.join(defaultTableNames, tableNames);
249 }
250
251 Vector<String> allVec = new Vector<>();
252 Vector<String> menuExcludeVec = new Vector<>();
254253
255254 // scan all the property tables, looking for entries
256255 final String ENV_DOT = "env.";
269268 if (debug)
270269 System.err.println("Checking " + tableNames[i] + " for environments...");
271270
272 Map table = tables[i];
273 for (Iterator ii = table.keySet().iterator(); ii.hasNext(); ) {
274 String prop = (String) (ii.next());
271 Map<String, String> table = tables[i];
272 for (Iterator<String> ii = table.keySet().iterator(); ii.hasNext(); ) {
273 String prop = (ii.next());
275274 String name = null;
276275
277276 if (debug)
285284 }
286285 else if (prop.endsWith(DOT_MENU)) {
287286 name = prop.substring(ENV_DOT.length(), prop.length() - DOT_MENU.length());
288 String value = (String) (table.get(prop));
287 String value = (table.get(prop));
289288 if ("false".equals(value))
290289 sortedInsert(menuExcludeVec, name);
291290 }
321320
322321 envNames = new String[allVec.size()];
323322 allVec.copyInto(envNames);
324 Vector menuVec = (Vector)allVec.clone();
323 Vector<String> menuVec = new Vector<String>(allVec);
325324 for (int i = 0; i < menuExcludeVec.size(); i++)
326325 menuVec.removeElement(menuExcludeVec.elementAt(i));
327326 envMenuNames = new String[menuVec.size()];
328327 menuVec.copyInto(envMenuNames);
329328 }
330329
331 private void sortedInsert(Vector v, String s) {
330 private void sortedInsert(Vector<String> v, String s) {
332331 for (int i = 0; i < v.size(); i++) {
333 int c = s.compareTo((String)(v.elementAt(i)));
332 int c = s.compareTo(v.elementAt(i));
334333 if (c > 0) {
335334 v.insertElementAt(s, i);
336335 return;
341340 v.addElement(s);
342341 }
343342
344 private Map[] propTables;
343 private Map<String, String>[] propTables;
345344 private String[] propTableNames;
346345 private String[] envNames;
347346 private String[] envMenuNames;
3535
3636 import com.sun.javatest.util.DynamicArray;
3737 import com.sun.javatest.util.I18NResourceBundle;
38 import com.sun.javatest.util.Properties;
3839 import com.sun.javatest.util.StringArray;
3940
4041 /**
7475
7576 /**
7677 * Add a default set of properties to be included when environments are
77 * created.
78 * created. Properties are passed in as a {@code Map<String, String>} instance.
7879 * @param name a name for this collection or properties, so that the
7980 * source of the properties can be identified when browing an environment
8081 * @param propTable a table of properties to be included when environments
8283 * @see #clearDefaultPropTables
8384 * @throws NullPointerException if either name or propTable is null.
8485 */
85 public static synchronized void addDefaultPropTable(String name, Map propTable) {
86 public static synchronized void addDefaultPropTable(String name, Map<String, String> propTable) {
8687 if (name == null || propTable == null)
8788 throw new NullPointerException();
8889
8990 //System.err.println("TEC: add default propTable " + name);
90 defaultPropTableNames = (String[]) (DynamicArray.append(defaultPropTableNames, name));
91 defaultPropTables = (Map[]) (DynamicArray.append(defaultPropTables, propTable));
91 defaultPropTableNames = DynamicArray.append(defaultPropTableNames, name);
92 defaultPropTables = DynamicArray.append(defaultPropTables, propTable);
93 }
94
95 /**
96 * Add a default set of properties to be included when environments are
97 * created. Properties are passed in as a {@code java.util.Properties} instance.
98 * @param name a name for this collection or properties, so that the
99 * source of the properties can be identified when browing an environment
100 * @param propTable a table of properties to be included when environments
101 * are created
102 * @see #clearDefaultPropTables
103 * @throws NullPointerException if either name or propTable is null.
104 */
105 public static synchronized void addDefaultPropTable(String name, java.util.Properties propTable) {
106 addDefaultPropTable(name, Properties.convertToStringProps(propTable));
92107 }
93108
94109 /**
101116 }
102117
103118 static String[] defaultPropTableNames = { };
104 static Map[] defaultPropTables = { };
119 static Map<String, String>[] defaultPropTables = new Map[0];
105120
106121 /**
107122 * Construct an environment for a named group of properties.
114129 * @throws TestEnvironment.Fault if there is an error in the table
115130 *
116131 */
117 public TestEnvironment(String name, Map propTable, String propTableName)
132 public TestEnvironment(String name, Map<String, String> propTable, String propTableName)
118133 throws Fault {
119134 this(name, (new Map[] {propTable}), (new String[] {propTableName}));
120135 }
137152 {
138153 this.name = name;
139154 if (defaultPropTables != null && defaultPropTables.length > 0) {
140 propTables = (Map[]) (DynamicArray.join(defaultPropTables, propTables));
141 propTableNames = (String[]) (DynamicArray.join(defaultPropTableNames, propTableNames));
155 propTables = DynamicArray.join(defaultPropTables, propTables);
156 propTableNames = DynamicArray.join(defaultPropTableNames, propTableNames);
142157 }
143158
144159 // First, figure out the inheritance chain
145 Vector v = new Vector();
160 Vector<String> v = new Vector<>();
146161 for (String n = name, inherit = null; n != null && n.length() > 0; n = inherit, inherit = null) {
147162 if (v.contains(n))
148163 throw new Fault(i18n, "env.loop", name);
162177 for (int inheritIndex = 0; inheritIndex < inherits.length; inheritIndex++) {
163178 String prefix = "env." + inherits[inheritIndex] + ".";
164179 for (int propIndex = propTables.length - 1; propIndex >= 0; propIndex--) {
165 Map propTable = propTables[propIndex];
166 for (Iterator i = propTable.keySet().iterator(); i.hasNext(); ) {
167 String prop = (String) (i.next());
180 Map<String, String> propTable = propTables[propIndex];
181 for (Iterator<String> i = propTable.keySet().iterator(); i.hasNext(); ) {
182 String prop = (i.next());
168183 if (prop.startsWith(prefix)) {
169184 String key = prop.substring(prefix.length());
170185 if (!table.containsKey(key)) {
171186 Element elem = new Element(key,
172 (String)(propTable.get(prop)),
187 (propTable.get(prop)),
173188 inherits[inheritIndex],
174189 propTableNames[propIndex]);
175190 table.put(key, elem);
181196
182197 // finally, add in any top-level names (not beginning with env.)
183198 for (int propIndex = propTables.length - 1; propIndex >= 0; propIndex--) {
184 Map propTable = propTables[propIndex];
185 for (Iterator i = propTable.keySet().iterator(); i.hasNext(); ) {
186 String key = (String) (i.next());
199 Map<String, String> propTable = propTables[propIndex];
200 for (Iterator<String> i = propTable.keySet().iterator(); i.hasNext(); ) {
201 String key = (i.next());
187202 if (!key.startsWith("env.")) {
188203 if (!table.containsKey(key)) {
189204 Element elem = new Element(key,
190 (String)(propTable.get(key)),
205 (propTable.get(key)),
191206 null,
192207 propTableNames[propIndex]);
193208 table.put(key, elem);
223238 return null;
224239 }
225240
226 return ((Element)table.get("description")).getValue();
241 return table.get("description").getValue();
227242 }
228243
229244 /**
290305 *
291306 * @return all external global properties.
292307 */
293 public HashMap getExtraValues() {
308 public Map<String, String[]> getExtraValues() {
294309 return extras;
295310 }
296311
306321 return lookup(key, null);
307322 }
308323
309 private String[] lookup(String key, Vector activeKeys) throws Fault {
310 String[] v = (String[])extras.get(key);
324 private String[] lookup(String key, Vector<String> activeKeys) throws Fault {
325 String[] v = extras.get(key);
311326 if (v != null)
312327 return v;
313328
314329
315 Element elem = (Element)table.get(key);
330 Element elem = table.get(key);
316331 if (elem != null) {
317332 cache.put(key, elem);
318333 if (activeKeys == null)
319 activeKeys = new Vector();
334 activeKeys = new Vector<>();
320335 else if (activeKeys.contains(key))
321336 throw new Fault(i18n, "env.recursive",
322337 new Object[] {key, elem.getDefinedInFile()});
360375 return resolve(s, null);
361376 }
362377
363 private String[] resolve(String s, Vector activeKeys) throws Fault {
364 Vector v = new Vector();
378 private String[] resolve(String s, Vector<String> activeKeys) throws Fault {
379 Vector<String> v = new Vector<>();
365380 StringBuffer current = new StringBuffer(64);
366381 char term = 0;
367382
542557 * VALUE_NOT_DEFINED.
543558 */
544559 public boolean hasUndefinedValues() {
545 for (Iterator i = elements().iterator(); i.hasNext(); ) {
546 TestEnvironment.Element entry = (TestEnvironment.Element) (i.next());
560 for (Iterator<Element> i = elements().iterator(); i.hasNext(); ) {
561 Element entry = i.next();
547562 if (entry.value.indexOf("VALUE_NOT_DEFINED") >= 0)
548563 return true;
549564 }
609624 * include the `env.<em>environment-name</em>.' prefix of the corresponding
610625 * property names.
611626 */
612 public Set keys() {
627 public Set<String> keys() {
613628 return table.keySet();
614629 }
615630
621636 * referenced.
622637 * @see #resetElementsUsed
623638 */
624 public Collection elementsUsed() {
639 public Collection<Element> elementsUsed() {
625640 return cache.values();
626641 }
627642
639654 * @return An enumeration that yields the various elements, explicit or inherited,
640655 * that are available in this environment.
641656 */
642 public Collection elements() {
657 public Collection<Element> elements() {
643658 return table.values();
644659 }
645660
648663 name = o.name;
649664 inherits = o.inherits;
650665 table = o.table;
651 extras = (HashMap)(o.extras.clone());
666 extras = new HashMap<>(o.extras);
652667 }
653668
654669 /**
701716
702717 private String name;
703718 private String[] inherits;
704 private HashMap table = new HashMap();
705 private HashMap extras = new HashMap();
706 private HashMap cache = new HashMap();
719 private Map<String, Element> table = new HashMap<>();
720 private Map<String, String[]> extras = new HashMap<>();
721 private Map<String, Element> cache = new HashMap<>();
707722
708723 private static final String[] EMPTY_STRING_ARRAY = {};
709724 private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(TestEnvironment.class);
245245 * @see #foundFile(File)
246246 * @since 3.2
247247 */
248 public void setComparator(Comparator c) {
248 public void setComparator(Comparator<String> c) {
249249 comp = c;
250250
251251 }
257257 * @see #setComparator
258258 * @since 3.2
259259 */
260 public Comparator getComparator() {
260 public Comparator<String> getComparator() {
261261 return comp;
262262 }
263263
266266 * their own. The default is a US Locale Collator.
267267 * @return The comparator which would be used if a custom one was not provided.
268268 */
269 protected Comparator getDefaultComparator() {
269 protected static Comparator<String> getDefaultComparator() {
270270 // this is the default
271 Collator c = Collator.getInstance(Locale.US);
271 final Collator c = Collator.getInstance(Locale.US);
272272 c.setStrength(Collator.PRIMARY);
273 return c;
273 return new Comparator<String>() {
274 @Override
275 public int compare(String s1, String s2) {
276 return c.compare(s1, s2);
277 }
278 };
274279 }
275280
276281 //--------------------------------------------------------------------------
457462 * @param name The name of the entry that has been read
458463 * @param value The value of the entry that has been read
459464 */
460 protected void processEntry(Map entries, String name, String value) {
465 protected void processEntry(Map<String, String> entries, String name, String value) {
461466 // uniquefy the keys as they go into the entries table
462467 name = name.intern();
463468
464469 if (name.equalsIgnoreCase("keywords")) {
465470 // canonicalize keywords in their own special table
466 String keywordCacheValue = (String)keywordCache.get(value);
471 String keywordCacheValue = keywordCache.get(value);
467472 if (keywordCacheValue == null) {
468473 String lv = value.toLowerCase();
469474 String[] lvs = StringArray.split(lv);
480485 }
481486
482487 // cache for canonicalized lists of keywords
483 private Map keywordCache = new HashMap();
488 private Map<String, String> keywordCache = new HashMap<>();
484489
485490 /**
486491 * "normalize" the test description entries read from a file.
489494 * @param entries A set of tag values read from a test description in a file
490495 * @return A normalized set of entries
491496 */
492 protected Map normalize(Map entries) {
497 protected Map<String, String> normalize(Map<String, String> entries) {
493498 return entries;
494499 }
495500
502507 * @param file The file being read
503508 * @param line The line number within the file (used for error messages)
504509 */
505 protected void foundTestDescription(Map entries, File file, int line) {
510 protected void foundTestDescription(Map<String, String> entries, File file, int line) {
506511 entries = normalize(entries);
507512
508513 if (debug) {
509514 System.err.println("Found TestDescription");
510515
511516 System.err.println("--------values----------------------------");
512 for (Iterator i = entries.keySet().iterator() ; i.hasNext() ;) {
517 for (Iterator<String> i = entries.keySet().iterator() ; i.hasNext() ;) {
513518 Object key = i.next();
514519 System.err.println(">> " + key + ": " + entries.get(key) );
515520 }
516521 System.err.println("------------------------------------------");
517522 }
518523
519 String id = (String)(entries.get("id"));
524 String id = entries.get("id");
520525 if (id == null)
521526 id = "";
522527
523528 // make sure test has unique id within file
524 Integer prevLine = (Integer)testsInFile.get(id);
529 Integer prevLine = testsInFile.get(id);
525530 if (prevLine != null) {
526531 int i = 1;
527532 String newId;
568573 }
569574
570575 if (tests == null)
571 tests = new Vector();
576 tests = new Vector<>();
572577
573578 int target = 0;
574579
585590
586591 while (left < right) {
587592 center = ((right+left)/2);
588 int cmp = comp.compare(name, ((TestDescription)(tests.get(center))).getName());
593 int cmp = comp.compare(name, tests.get(center).getName());
589594 if (cmp < 0)
590595 right = center;
591596 else if (cmp >= 0)
592597 left = center+1;
593598 } // while
594599
595 if (comp.compare(name, ((TestDescription)(tests.get(left))).getName()) > 0)
600 if (comp.compare(name, tests.get(left).getName()) > 0)
596601 target = left+1;
597602 else
598603 target = left;
640645 */
641646 protected void foundFile(File newFile) {
642647 if (files == null)
643 files = new Vector();
648 files = new Vector<>();
644649
645650 int target = 0;
646651
657662
658663 while (left < right) {
659664 center = ((right+left)/2);
660 int cmp = comp.compare(path, ((File)(files.get(center))).getPath());
665 int cmp = comp.compare(path, files.get(center).getPath());
661666 if (cmp < 0)
662667 right = center;
663668 else if (cmp >= 0)
664669 left = center+1;
665670 } // while
666671
667 if (comp.compare(path, ((File)(files.get(left))).getPath()) > 0)
672 if (comp.compare(path, files.get(left).getPath()) > 0)
668673 target = left+1;
669674 else
670675 target = left;
726731 */
727732 protected TestEnvironment env;
728733 private ErrorHandler errHandler;
729 private Comparator comp = getDefaultComparator();
730
731 private Vector files;
732 private Vector tests;
733
734 private Map testsInFile = new HashMap();
735
736 private Vector errorMessages = new Vector();
734 private Comparator<String> comp = getDefaultComparator();
735
736 private Vector<File> files;
737 private Vector<TestDescription> tests;
738
739 private Map<String, Integer> testsInFile = new HashMap<>();
740
741 private Vector<String> errorMessages = new Vector<>();
737742
738743 /**
739744 * A boolean to enable trace output while debugging test finders.
2727
2828 import java.io.File;
2929 import java.util.Hashtable;
30 import java.util.Map;
3031 import java.util.Vector;
3132
3233 import com.sun.javatest.util.DynamicArray;
184185
185186 // build up the fifo of tests to be used by readNextFile
186187
187 tests = new Fifo();
188 tests = new Fifo<>();
188189 currInitialFile = null;
189190
190191 for (int pass = 0; pass < 2; pass++) {
231232 */
232233 public void repeat(TestDescription[] tds) {
233234 if (tests == null)
234 tests = new Fifo(); // for now
235 tests = new Fifo<>(); // for now
235236 for (int i = 0; i < tds.length; i++) {
236237 TestDescription td = tds[i];
237238 testDescsFound.insert(td);
256257
257258 // read files until there is a test description available or there
258259 // are no more files.
259 while ((td = (TestDescription)(testDescsFound.remove())) == null) {
260 while ((td = testDescsFound.remove()) == null) {
260261 boolean ok = readNextFile();
261262 if (!ok)
262263 return null;
505506 // are there any more tests that have not been read?
506507 // check until we find one (just one).
507508 while (filesToRead.isEmpty() && !tests.isEmpty()) {
508 currInitialFile = (File)tests.remove();
509 currInitialFile = tests.remove();
509510 foundFile(currInitialFile);
510511 }
511512
519520 }
520521
521522
522 File f = (File)(filesToRead.lastElement());
523 File f = filesToRead.lastElement();
523524 filesToRead.setSize(filesToRead.size() - 1);
524525 filesRemainingCount = filesToRead.size() + tests.size();
525526
626627
627628 private static class Notifier implements Observer {
628629 public synchronized void addObserver(Observer o) {
629 observers = (Observer[])DynamicArray.append(observers, o);
630 observers = DynamicArray.append(observers, o);
630631 }
631632
632633 public synchronized void removeObserver(Observer o) {
633 observers = (Observer[])DynamicArray.remove(observers, o);
634 observers = DynamicArray.remove(observers, o);
634635 }
635636
636637 public synchronized void found(File file) {
685686
686687
687688 private TestFinder testFinder;
688 private Fifo tests;
689 private Fifo<File> tests;
689690 private TestFilter[] filters;
690691 private String selectedId;
691692 private File rootDir;
693694 private int testsFoundCountBeforeCurrInitialFile;
694695 private boolean zeroTestsOK;
695696
696 private Vector filesToRead = new Vector(32, 8);
697 private Vector<File> filesToRead = new Vector<>(32, 8);
697698 private int fileInsertPosn;
698 private Fifo testDescsFound = new Fifo();
699 private Fifo<TestDescription> testDescsFound = new Fifo<>();
699700 private int filesRemainingCount;
700701 private int filesDoneCount;
701702 private int testsDoneCount;
702703 private int testsFoundCount;
703704 private int errorCount;
704705
705 private Hashtable filesFound = new Hashtable();
706 private Map<String, File> filesFound = new Hashtable<>();
706707
707708 private byte readAheadMode;
708709 private Thread readAheadWorker;
3131 import java.text.DateFormat;
3232 import java.text.ParseException;
3333 import java.text.SimpleDateFormat;
34 import java.util.Date;
35 import java.util.Enumeration;
36 import java.util.Hashtable;
37 import java.util.Iterator;
38 import java.util.LinkedList;
39 import java.util.Locale;
40 import java.util.Map;
41 import java.util.Vector;
42
43 import com.sun.javatest.util.BackupPolicy;
44 import com.sun.javatest.util.I18NResourceBundle;
34 import java.util.*;
35
36 import com.sun.javatest.util.*;
4537 import com.sun.javatest.util.Properties;
46 import com.sun.javatest.util.PropertyArray;
47 import com.sun.javatest.util.StringArray;
48 import com.sun.javatest.util.DynamicArray;
4938
5039 /**
5140 * The TestResult object encapsulates the results from a test.
298287 checkMutable();
299288
300289 OutputBuffer b = new WritableOutputBuffer(name);
301 buffers = (OutputBuffer[])(DynamicArray.append(buffers, b));
290 buffers = DynamicArray.append(buffers, b);
302291
303292 notifyCreatedOutput(this, name);
304293
367356
368357 // ---------- PACKAGE PRIVATE ----------
369358
370 Section(String title) {
359 public Section(String title) {
371360 if (title == null)
372361 throw new NullPointerException();
373362 if (title.indexOf(' ') != -1)
408397
409398 while ((line = in.readLine()).startsWith(JTR_V2_SECTSTREAM)) {
410399 OutputBuffer b = new FixedOutputBuffer(line, in);
411 buffers = (OutputBuffer[])(DynamicArray.append(buffers, b));
400 buffers = DynamicArray.append(buffers, b);
412401 }
413402
414403 // if not in the message section, line should have the section result
532521 if (name.equals(MESSAGE_OUTPUT_NAME))
533522 name = MESSAGE_OUTPUT_NAME;
534523 OutputBuffer b = new FixedOutputBuffer(name, data);
535 buffers = (OutputBuffer[])(DynamicArray.append(buffers, b));
524 buffers = DynamicArray.append(buffers, b);
536525 }
537526
538527 /**
938927 }
939928
940929 Section section = new Section(name);
941 sections = (Section[])(DynamicArray.append(sections, section));
930 sections = DynamicArray.append(sections, section);
942931 notifyCreatedSection(section);
943932 // avoid creating output (which will cause observer messages)
944933 // before the createdSection has been notified
960949 throw new IllegalStateException(
961950 "This TestResult is no longer mutable!");
962951 }
963 for (Iterator i = environment.elementsUsed().iterator(); i.hasNext(); ) {
964 TestEnvironment.Element elem = (TestEnvironment.Element) (i.next());
952 for (Iterator<TestEnvironment.Element> i = environment.elementsUsed().iterator(); i.hasNext(); ) {
953 TestEnvironment.Element elem = i.next();
965954 // this is stunningly inefficient and should be fixed
966955 env = PropertyArray.put(env, elem.getKey(), elem.getValue());
967956 }
13111300 * Get the keys of the properties that this object has stored.
13121301 * @return the keys of the properties that this object has stored
13131302 */
1314 public synchronized Enumeration getPropertyNames() {
1303 public synchronized Enumeration<String> getPropertyNames() {
13151304 return PropertyArray.enumerate(props);
13161305 }
13171306
13421331 * recreating data from the results file.
13431332 * @see #setEnvironment
13441333 */
1345 public synchronized Map getEnvironment() throws Fault {
1334 public synchronized Map<String, String> getEnvironment() throws Fault {
13461335 if (env == null) {
13471336 // reconstitute environment
13481337 // this may result in a Fault, which is okay
16481637 out.write(JTR_V2_TESTDESC);
16491638 out.write(lineSeparator);
16501639
1651 Properties tdProps = new Properties();
1640 Map<String, String> tdProps = new HashMap<>();
16521641 desc.save(tdProps);
16531642 PropertyArray.save(PropertyArray.getArray(tdProps), out);
16541643 out.write(lineSeparator);
17161705 */
17171706 public synchronized void addObserver(Observer obs) {
17181707 if (isMutable()) {
1719 Observer[] observers = (Observer[])observersTable.get(this);
1708 Observer[] observers = observersTable.get(this);
17201709
17211710 if (observers == null) observers = new Observer[0];
17221711
1723 observers = (Observer[])(DynamicArray.append(observers, obs));
1712 observers = DynamicArray.append(observers, obs);
17241713 observersTable.put(this, observers);
17251714 }
17261715 }
17301719 * @param obs the observer to be removed
17311720 */
17321721 public synchronized void removeObserver(Observer obs) {
1733 Observer[] observers = (Observer[])observersTable.get(this);
1722 Observer[] observers = observersTable.get(this);
17341723 if (observers == null)
17351724 return;
17361725
1737 observers = (Observer[])(DynamicArray.remove(observers, obs));
1726 observers = DynamicArray.remove(observers, obs);
17381727 if (observers == null)
17391728 observersTable.remove(this);
17401729 else
18791868 this.endTime = endTime;
18801869 }
18811870
1882 void shareStatus(Hashtable[] tables) {
1871 void shareStatus(Map<String, Status>[] tables) {
18831872 execStatus = shareStatus(tables, execStatus);
18841873 }
18851874
19001889 return null;
19011890 }
19021891
1903 Vector tagV = new Vector(sections.length * 2);
1892 Vector<String> tagV = new Vector<>(sections.length * 2);
19041893
19051894 for (int i = 0; i < sections.length; i++) {
19061895 String[] names = sections[i].getOutputNames();
19921981
19931982 private static long computeChecksum(TestDescription td) {
19941983 long cs = 0;
1995 for (Iterator i = td.getParameterKeys(); i.hasNext(); ) {
1984 for (Iterator<String> i = td.getParameterKeys(); i.hasNext(); ) {
19961985 // don't rely on enumeration in a particular order
19971986 // so simply add the checksum products together
1998 String key = (String) (i.next());
1987 String key = (i.next());
19991988 cs += computeChecksum(key) * computeChecksum(td.getParameter(key));
20001989 }
20011990 return cs;
21312120 pairs = null;
21322121
21332122 if (desc == null) {
2134 File path = new File((String)(PropertyArray.get(props, "testsuite")));
2123 File path = new File(PropertyArray.get(props, "testsuite"));
21352124 if (!path.isDirectory())
21362125 path = new File(path.getParent());
21372126 File file = new File(PropertyArray.get(props, "file"));
21502139 Section blk = processOldSection(line, in);
21512140
21522141 if (blk != null) {
2153 sections = (Section[])(DynamicArray.append(sections, blk));
2142 sections = DynamicArray.append(sections, blk);
21542143 }
21552144 }
21562145 else if (line.startsWith(JTR_V1_TSTRESULT)) {
24122401 }
24132402 }
24142403
2415 private static Status shareStatus(Hashtable[] tables, Status s) {
2404 private static Status shareStatus(Map<String, Status>[] tables, Status s) {
24162405 int type = s.getType();
24172406 String reason = s.getReason();
2418 Status result = (Status)tables[type].get(reason);
2407 Status result = tables[type].get(reason);
24192408 if (result == null) {
24202409 tables[type].put(reason, s);
24212410 result = s;
24322421 * @param section The section that was created.
24332422 */
24342423 private synchronized void notifyCreatedSection(Section section) {
2435 Observer[] observers = (Observer[])(observersTable.get(this));
2424 Observer[] observers = observersTable.get(this);
24362425 if (observers != null)
24372426 for (int i = 0; i < observers.length; i++)
24382427 observers[i].createdSection(this, section);
24442433 * @param section The section that was completed.
24452434 */
24462435 private synchronized void notifyCompletedSection(Section section) {
2447 Observer[] observers = (Observer[])(observersTable.get(this));
2436 Observer[] observers = observersTable.get(this);
24482437 if (observers != null)
24492438 for (int i = 0; i < observers.length; i++)
24502439 observers[i].completedSection(this, section);
24572446 * @param outputName The name of the output.
24582447 */
24592448 private synchronized void notifyCreatedOutput(Section section, String outputName) {
2460 Observer[] observers = (Observer[])(observersTable.get(this));
2449 Observer[] observers = observersTable.get(this);
24612450 if (observers != null)
24622451 for (int i = 0; i < observers.length; i++)
24632452 observers[i].createdOutput(this, section, outputName);
24702459 * @param outputName The name of the output.
24712460 */
24722461 private synchronized void notifyCompletedOutput(Section section, String outputName) {
2473 Observer[] observers = (Observer[])(observersTable.get(this));
2462 Observer[] observers = observersTable.get(this);
24742463 if (observers != null)
24752464 for (int i = 0; i < observers.length; i++)
24762465 observers[i].completedOutput(this, section, outputName);
24842473 * @param text The text that was added (appended).
24852474 */
24862475 private synchronized void notifyUpdatedOutput(Section section, String outputName, int start, int end, String text) {
2487 Observer[] observers = (Observer[])(observersTable.get(this));
2476 Observer[] observers = observersTable.get(this);
24882477 if (observers != null)
24892478 for (int i = 0; i < observers.length; i++)
24902479 observers[i].updatedOutput(this, section, outputName, start, end, text);
24982487 */
24992488 private synchronized void notifyUpdatedOutput(Section section, String outputName, int start, int end,
25002489 char[] buf, int offset, int len) {
2501 Observer[] observers = (Observer[])(observersTable.get(this));
2490 Observer[] observers = observersTable.get(this);
25022491 if (observers != null) {
25032492 // only create string if there are really observers who want to see it
25042493 String text = new String(buf, offset, len);
25142503 * @param value The new value for the property.
25152504 */
25162505 private synchronized void notifyUpdatedProperty(String key, String value) {
2517 Observer[] observers = (Observer[])(observersTable.get(this));
2506 Observer[] observers = observersTable.get(this);
25182507 if (observers != null)
25192508 for (int i = 0; i < observers.length; i++)
25202509 observers[i].updatedProperty(this, key, value);
25282517 // is no need to keep any observers registered after we finish here
25292518 // so get the observers one last time, and at the same time
25302519 // remove them from the table
2531 Observer[] observers = (Observer[])(observersTable.remove(this));
2520 Observer[] observers = observersTable.remove(this);
25322521 if (observers != null) {
25332522 for (int i = 0; i < observers.length; i++)
25342523 observers[i].completed(this);
25662555 synchronized (shrinkList) {
25672556 // if this object is in the list; remove it;
25682557 // if there are dead weak refs, remove them
2569 for (Iterator iter = shrinkList.iterator(); iter.hasNext(); ) {
2570 WeakReference wref = (WeakReference) (iter.next());
2558 for (Iterator<WeakReference<TestResult>> iter = shrinkList.iterator(); iter.hasNext(); ) {
2559 WeakReference<TestResult> wref = iter.next();
25712560 Object o = wref.get();
25722561 if (o == null || o == this)
25732562 iter.remove();
25742563 }
25752564 while (shrinkList.size() >= maxShrinkListSize) {
2576 WeakReference wref = (WeakReference) (shrinkList.removeFirst());
2577 TestResult tr = (TestResult) (wref.get());
2565 WeakReference<TestResult> wref = shrinkList.removeFirst();
2566 TestResult tr = wref.get();
25782567 if (tr != null)
25792568 tr.shrink();
25802569 }
2581 shrinkList.addLast(new WeakReference(this));
2570 shrinkList.addLast(new WeakReference<>(this));
25822571 }
25832572 }
25842573
26222611 // because so few test results will typically be observed (e.g. at most one)
26232612 // we don't use a per-instance array of observers, but instead associate any
26242613 // such arrays here.
2625 private static Hashtable observersTable = new Hashtable(16);
2614 private static Map<TestResult, Observer[]> observersTable = new Hashtable<>(16);
26262615
26272616 /**
26282617 * The name of the default output that all Sections are equipped with.
27512740 private static final int DEFAULT_MAX_SHRINK_LIST_SIZE = 128;
27522741 private static final int maxShrinkListSize =
27532742 Integer.getInteger("javatest.numCachedResults", DEFAULT_MAX_SHRINK_LIST_SIZE).intValue();
2754 private static LinkedList shrinkList = new LinkedList();
2743 private static LinkedList<WeakReference<TestResult>> shrinkList = new LinkedList<>();
27552744
27562745 private static final int DEFAULT_MAX_OUTPUT_SIZE = 100000;
27572746 private static final int commonOutputSize =
5858 * Called when tests have been read from the cache file.
5959 * @param tests the tests that have been read
6060 */
61 void update(Map tests);
61 void update(Map<String, TestResult> tests);
6262
6363 /**
6464 * Called periodically while waiting to access the cache.
117117 this.workDir = workDir;
118118 this.observer = observer;
119119
120 weakWorkDir = new WeakReference(workDir);
121 weakObserver = new WeakReference(observer);
120 weakWorkDir = new WeakReference<>(workDir);
121 weakObserver = new WeakReference<>(observer);
122122
123123 cacheFile = workDir.getSystemFile(V2_FILENAME);
124124 lockFile = workDir.getSystemFile(V2_LOCKNAME);
308308 }
309309
310310 private void doWork() throws IOException {
311 Map tests = null;
311 Map<String, TestResult> tests = null;
312312 boolean rebuildCache = false;
313313
314314 getLock();
481481 //
482482 // Read a set of tests from the *.jtr files in the work directory
483483
484 private Map readJTRFiles() {
484 private Map<String, TestResult> readJTRFiles() {
485485 final long start = System.currentTimeMillis();
486 Map tests = new TreeMap();
486 Map<String, TestResult> tests = new TreeMap<>();
487487 readJTRFiles(workDir.getRoot(), tests);
488488
489489 // these lines are all for logging benchmark info
511511 return tests;
512512 }
513513
514 private void readJTRFiles(File dir, Map tests) {
514 private void readJTRFiles(File dir, Map<String, TestResult> tests) {
515515 File[] entries = dir.listFiles();
516516 if (entries != null) {
517517 // monitor shutdownRequested and give up if set true;
543543 }
544544 }
545545
546 private TestResult reload(Map tests, TestResult tr) {
546 private TestResult reload(Map<String, TestResult> tests, TestResult tr) {
547547 File jtr = workDir.getFile(tr.getWorkRelativePath());
548548 try {
549549 return new TestResult(jtr);
572572 //
573573 // Read the cache
574574
575 private Map readCache()
575 private Map<String, TestResult> readCache()
576576 throws IOException, IllegalArgumentException
577577 {
578578 final long start = System.currentTimeMillis();
594594 // read full cache
595595 lastSerial = fileSerial;
596596 totalEntryCount = 0;
597 Map tests = readCacheEntries();
597 Map<String, TestResult> tests = readCacheEntries();
598598 uniqueInitialEntryCount = tests.size();
599599
600600 if (DEBUG_WORK)
626626 else if (raf.length() > lastFileSize) {
627627 // just read updates from file
628628 raf.seek(lastFileSize);
629 Map tests = readCacheEntries();
629 Map<String, TestResult> tests = readCacheEntries();
630630
631631 if (DEBUG_WORK)
632632 Debug.println("TRC.readCache read update (" + tests.size() + " tests)");
641641 }
642642 }
643643
644 private Map readCacheEntries()
644 private Map<String, TestResult> readCacheEntries()
645645 throws IOException, IllegalArgumentException
646646 {
647 Map tests = new TreeMap();
647 Map<String, TestResult> tests = new TreeMap<>();
648648 while (raf.getFilePointer() < raf.length()) {
649649 String name = raf.readUTF();
650650 int status = raf.readInt();
666666 //
667667 // Write the cache
668668
669 private void writeCache(Map tests) throws IOException {
669 private void writeCache(Map<String, TestResult> tests) throws IOException {
670670 if (tests == null)
671671 throw new IllegalStateException();
672672
675675 // it till its empty, even though some tests may even have been added
676676 // after the worker woke up
677677 TestResult tr;
678 while ((tr = (TestResult) (testsToWrite.remove())) != null) {
678 while ((tr = testsToWrite.remove()) != null) {
679679 // check if test is in the set we've just read
680680 String name = tr.getTestName();
681 TestResult tr2 = (TestResult) (tests.get(name));
681 TestResult tr2 = tests.get(name);
682682 // if the cache file contains a conflicting entry,
683683 // reload the test from the .jtr file; otherwise, add it to the cache
684684 if (tr2 != null && !tr2.getStatus().equals(tr.getStatus()))
693693 lastSerial = (int) ((now >> 16) + (now & 0xffff));
694694 raf.writeInt(lastSerial);
695695
696 for (Iterator iter = tests.values().iterator(); iter.hasNext(); ) {
697 tr = (TestResult) (iter.next());
696 for (Iterator<TestResult> iter = tests.values().iterator(); iter.hasNext(); ) {
697 tr = iter.next();
698698 writeCacheEntry(tr);
699699 }
700700
706706 uniqueInitialEntryCount = totalEntryCount = tests.size();
707707 }
708708
709 private void updateCache(Map tests) throws IOException {
709 private void updateCache(Map<String, TestResult> tests) throws IOException {
710710 // testsToWrite is a thread-safe fifo, so it is safe to keep reading
711711 // it till its empty, even though some tests may even have been added
712712 // after the worker woke up
713713 int debugCount = 0;
714714 raf.seek(lastFileSize);
715715 TestResult tr;
716 while ((tr = (TestResult) (testsToWrite.remove())) != null) {
716 while ((tr = testsToWrite.remove()) != null) {
717717 if (tests != null) {
718718 // check if test is in the set we've just read
719719 String name = tr.getTestName();
720 TestResult tr2 = (TestResult) (tests.get(name));
720 TestResult tr2 = tests.get(name);
721721 if (tr2 != null) {
722722 // cache also contains an entry for this test:
723723 // reload from .jtr file in case of conflict
850850 // These weak references get revived when the worker thread has work to do.
851851 private void reviveWeakReferences() {
852852 if (workDir == null)
853 workDir = (WorkDirectory) weakWorkDir.get();
853 workDir = weakWorkDir.get();
854854
855855 if (observer == null)
856 observer = (Observer) weakObserver.get();
856 observer = weakObserver.get();
857857 }
858858
859859 //-------------------------------------------------------------------------------------
860860
861861 // general instance data
862862 private Observer observer;
863 private WeakReference weakObserver;
863 private WeakReference<Observer> weakObserver;
864864 private WorkDirectory workDir;
865 private WeakReference weakWorkDir;
865 private WeakReference<WorkDirectory> weakWorkDir;
866866 private File cacheFile;
867867 private File lockFile;
868868 private Thread worker;
882882 private boolean compressRequested;
883883 private boolean flushRequested;
884884 private boolean shutdownRequested;
885 private Fifo testsToWrite = new Fifo();
885 private Fifo<TestResult> testsToWrite = new Fifo<>();
886886
887887 private static final String V1_FILENAME = "ResultCache.jtw";
888888 private static final String V1_LOCKNAME = V1_FILENAME + ".lck";
2828 import java.io.File;
2929 import java.io.IOException;
3030 import java.text.Collator;
31 import java.util.ArrayList;
32 import java.util.Arrays;
33 import java.util.Comparator;
34 import java.util.Enumeration;
35 import java.util.HashMap;
36 import java.util.HashSet;
37 import java.util.Hashtable;
38 import java.util.Iterator;
39 import java.util.LinkedList;
40 import java.util.Locale;
41 import java.util.Map;
42 import java.util.NoSuchElementException;
43 import java.util.Vector;
31 import java.util.*;
4432 import java.util.concurrent.locks.ReentrantLock;
4533
4634 import com.sun.javatest.finder.TestFinderDecorator;
265253 * Create a table ready to be occupied.
266254 */
267255 public TestResultTable() {
268 statusTables = new Hashtable[Status.NUM_STATES];
256 statusTables = new Map[Status.NUM_STATES];
269257 for (int i = 0; i < statusTables.length; i++)
270 statusTables[i] = new Hashtable();
258 statusTables[i] = new Hashtable<>();
271259
272260 root = new TRT_TreeNode(this, null);
273261
585573 // no tree yet
586574 if (root == null) return null;
587575
588 return findTest((TRT_TreeNode)root, jtrPath, jtrPath);
576 return findTest(root, jtrPath, jtrPath);
589577 }
590578
591579 /**
639627 if (target == null)
640628 return null;
641629
642 ArrayList path = new ArrayList();
630 ArrayList<TreeNode> path = new ArrayList<>();
643631 TreeNode loc = target.getParent();
644632 while (loc != null) {
645633 path.add(0, loc);
675663 if (target == null)
676664 return null;
677665
678 ArrayList path = new ArrayList();
666 ArrayList<TreeNode> path = new ArrayList<>();
679667 TreeNode loc = target;
680668 while (loc != null) {
681669 path.add(0, loc);
714702 * @see #getIterator()
715703 * @since 3.0
716704 */
717 public Enumeration elements() {
705 public Enumeration<TestResult> elements() {
718706 return getIterator();
719707 }
720708
744732 * @since 3.0
745733 * @see #getIterator()
746734 */
747 public Enumeration elements(TestFilter[] filters) {
735 public Enumeration<TestResult> elements(TestFilter[] filters) {
748736 return getIterator(filters);
749737 }
750738
770758 * @see #getIterator()
771759 * @since 3.0
772760 */
773 public static Enumeration elements(TreeNode node) {
761 public static Enumeration<TestResult> elements(TreeNode node) {
774762 return getIterator(node);
775763 }
776764
807795 * @see #getIterator()
808796 * @since 3.0
809797 */
810 public static Enumeration elements(TreeNode node, TestFilter filter) {
798 public static Enumeration<TestResult> elements(TreeNode node, TestFilter filter) {
811799 return getIterator(node, filter);
812800 }
813801
840828 * @see #getIterator()
841829 * @since 3.0
842830 */
843 public static Enumeration elements(TreeNode node, TestFilter[] filters) {
831 public static Enumeration<TestResult> elements(TreeNode node, TestFilter[] filters) {
844832 return getIterator(node, filters);
845833 }
846834
861849 * @see #getIterator()
862850 * @since 3.0
863851 */
864 public Enumeration elements(String url, TestFilter[] filters) {
852 public Enumeration<TestResult> elements(String url, TestFilter[] filters) {
865853 if (url == null)
866854 return NullEnum.getInstance();
867855 else {
909897 * @see #getIterator()
910898 * @since 3.0
911899 */
912 public Enumeration elements(File[] tests, TestFilter[] filters) throws Fault {
900 public Enumeration<TestResult> elements(File[] tests, TestFilter[] filters) throws Fault {
913901 return getIterator(tests, filters);
914902 }
915903
953941 }
954942 else if (objs instanceof TreeNode[]) {
955943 // don't add duplicates
956 if (!initNodes.contains((TreeNode) objs[0]))
944 if (!initNodes.contains(objs[0]))
957945 initNodes.add((TreeNode) objs[0]);
958946 }
959947 else if (objs instanceof TestResult[]) {
996984 * @see #getIterator()
997985 * @since 3.0
998986 */
999 public Enumeration elements(String[] urls, TestFilter[] filters) {
987 public Enumeration<TestResult> elements(String[] urls, TestFilter[] filters) {
1000988 return getIterator(urls, filters);
1001989 }
1002990
11691157 public synchronized void addObserver(Observer o) {
11701158 if (o == null)
11711159 throw new NullPointerException();
1172 observers = (Observer[])DynamicArray.append(observers, o);
1160 observers = DynamicArray.append(observers, o);
11731161 }
11741162
11751163 /**
11791167 * @param o The observer to remove.
11801168 */
11811169 public synchronized void removeObserver(Observer o) {
1182 observers = (Observer[])DynamicArray.remove(observers, o);
1170 observers = DynamicArray.remove(observers, o);
11831171 }
11841172
11851173 /**
11881176 * @param obs The observer to attach. Must never be null.
11891177 */
11901178 public void addObserver(TreeObserver obs) {
1191 treeObservers = (TreeObserver[])DynamicArray.append(treeObservers, obs);
1179 treeObservers = DynamicArray.append(treeObservers, obs);
11921180 }
11931181
11941182 /**
11991187 */
12001188 public void removeObserver(TreeObserver obs) {
12011189 if (treeObservers != null)
1202 treeObservers = (TreeObserver[])(DynamicArray.remove(treeObservers, obs));
1190 treeObservers = DynamicArray.remove(treeObservers, obs);
12031191 }
12041192
12051193 /**
14711459 }
14721460
14731461 private static class SortingComparator implements Comparator<DisassembledUrl> {
1474 Comparator<Object> c;
1475
1476 public SortingComparator(Comparator c) {
1462 Comparator<String> c;
1463
1464 public SortingComparator(Comparator<String> c) {
14771465 this.c = c;
14781466 }
14791467
15071495 if (in == null || in.length <= 1)
15081496 return in;
15091497
1510 Comparator c = finder.getComparator();
1498 Comparator<String> c = finder.getComparator();
15111499
15121500 if (c == null) {
15131501 // show warning message?
1514 c = Collator.getInstance(Locale.US);
1515 ((Collator)c).setStrength(Collator.PRIMARY);
1502 c = TestFinder.getDefaultComparator();
15161503 }
15171504
15181505 DisassembledUrl[] elements = new DisassembledUrl[in.length];
15301517 return result;
15311518 }
15321519
1533 private int compareStringArrays(Comparator c, String[] s1, String[] s2) {
1520 private int compareStringArrays(Comparator<String> c, String[] s1, String[] s2) {
15341521 // loop until names become unequal
15351522 for (int i = 0; i < s1.length; i++) {
15361523 if (i >= s2.length)
16261613 return result;
16271614 }
16281615
1629 private synchronized void updateFromCache(Map m) {
1616 private synchronized void updateFromCache(Map<String, TestResult> m) {
16301617 updateInProgress = true;
16311618
16321619 // this method could use further optimization to take advantage
16361623 if (rtc.getRequests() != null) {
16371624 for (TestDescription td : rtc.getRequests()) {
16381625 String testRes = TestResult.getWorkRelativePath(td.getRootRelativeURL());
1639 TestResult tr = (TestResult)m.get(testRes);
1626 TestResult tr = m.get(testRes);
16401627 if (tr != null) {
16411628 tr.setTestDescription(td);
16421629 update(tr, suppressFinderScan);
16931680 // in the test suite.
16941681 TestResult oldTR = node.addChild(tr, suppressScan, !cacheInitialized);
16951682 //tr.setParent(node); // now done in TRT_TreeNode.addChild()
1696 rec = (TRT_TreeNode[])DynamicArray.append(rec, node);
1683 rec = DynamicArray.append(rec, node);
16971684
16981685 // index will be -1 if the node insertion was rejected
16991686 // perhaps upgrade the code so that addChild() throws and
17741761 tn.setName(getDirName(nextDir));
17751762 node.addChild(tn, suppressScan);
17761763
1777 rec = (TRT_TreeNode[])DynamicArray.append(rec, tn);
1764 rec = DynamicArray.append(rec, tn);
17781765 notifyNewBranch(rec, tn, node.getIndex(tn, suppressScan));
17791766
17801767 return insert(tn, newPath, tr, rec, suppressScan);
17811768 }
17821769 else { // no work, just recurse
1783 rec = (TRT_TreeNode[])DynamicArray.append(rec, node);
1770 rec = DynamicArray.append(rec, node);
17841771 return insert(next, newPath, tr, rec, suppressScan);
17851772 }
17861773
20292016 // if url is exec/index.html#ExecSucc
20302017 // that should match a test with exactly that name
20312018 String jtrPath = TestResult.getWorkRelativePath(url);
2032 TestResult tr = findTest((TRT_TreeNode)where, jtrPath, jtrPath);
2019 TestResult tr = findTest(where, jtrPath, jtrPath);
20332020 return tr; // may be null
20342021 }
20352022
20942081 return null;
20952082
20962083 // try to partial match a test
2097 Vector v = new Vector();
2084 Vector<TestResult> v = new Vector<>();
20982085 try {
20992086 for (int i = 0; i < trs.length; i++) {
21002087 if (trs[i].getDescription().getRootRelativeURL().startsWith(url))
21872174 public TestResult getCachedResult(TestDescription td) {
21882175 if (cachedResults != null) {
21892176 String url = TestResult.getWorkRelativePath(td.getRootRelativeURL());
2190 TestResult res = (TestResult)cachedResults.get(url);
2177 TestResult res = cachedResults.get(url);
21912178 if (res != null) {
21922179 res.setTestDescription(td);
21932180 }
22082195
22092196 public synchronized void addToUpdateFromCache(TestDescription td) {
22102197 if (needUpdateFromCache == null) {
2211 needUpdateFromCache = new HashSet();
2198 needUpdateFromCache = new HashSet<>();
22122199 }
22132200 needUpdateFromCache.add(td);
22142201 }
22392226 /*OLD
22402227 private static final String formatVersion = "JavaTest/Results/2.0";
22412228 */
2242 private Hashtable[] statusTables;
2229 private Map<String, Status>[] statusTables;
22432230 // tables indexed by status.type mapping status.reason
22442231 // to a unique status object
22452232 private WorkDirectory workDir;
22612248 private volatile boolean updateInProgress;
22622249 private volatile boolean cacheInitialized = false;
22632250
2264 private Vector testsInUpdate = new Vector();
2251 private List<TestResult> testsInUpdate = new Vector<>();
22652252
22662253 /*
22672254 * Effectively a count of the number of instances of TRTs that have been created.
24462433 return hasMoreElements();
24472434 }
24482435
2449 public Object next() {
2436 public TestResult next() {
24502437 return nextElement();
24512438 }
24522439
24642451 return false;
24652452 }
24662453
2467 public Object nextElement() {
2454 public TestResult nextElement() {
24682455 throw new NoSuchElementException(i18n.getString("trt.noElements"));
24692456 }
24702457
24822469 * tree. This is a read-only interface, so <code>remove()</code> is not
24832470 * supported.
24842471 */
2485 public interface TreeIterator extends Enumeration, Iterator {
2472 public interface TreeIterator extends Enumeration<TestResult>, Iterator<TestResult> {
24862473 // --- Enumerator interface ---
24872474 public abstract boolean hasMoreElements();
2488 public abstract Object nextElement();
2475 public abstract TestResult nextElement();
24892476
24902477 // --- Iterator interface ---
24912478 public abstract boolean hasNext();
2492 public abstract Object next();
2479 public abstract TestResult next();
24932480
24942481 /**
24952482 * Do not call this method.
25922579 class Updater implements TestResultCache.Observer
25932580 {
25942581 //-----methods from TestResultCache.Observer-----
2595 public void update(Map tests) {
2582 public void update(Map<String, TestResult> tests) {
25962583 updateFromCache(tests);
25972584 }
25982585
28212808 void addNode(TreeNode tn) {
28222809 if (tr != null) throw new JavaTestError(i18n, "trt.invalidPath");
28232810
2824 nodes = (TreeNode[])DynamicArray.append(nodes, tn);
2811 nodes = DynamicArray.append(nodes, tn);
28252812 }
28262813
28272814 /*
28782865 TreeNode node = tr.getParent();
28792866
28802867 while (node != null) {
2881 nodes = (TreeNode[])DynamicArray.insert(nodes, node, 0);
2868 nodes = DynamicArray.insert(nodes, node, 0);
28822869 node = node.getParent();
28832870 }
28842871
199199 * @return true if and only if all the tests executed successfully and passed
200200 * @throws InterruptedException if the test run was interrupted
201201 */
202 protected abstract boolean runTests(Iterator testIter) throws InterruptedException;
202 protected abstract boolean runTests(Iterator<TestDescription> testIter) throws InterruptedException;
203203
204204 /**
205205 * This method must be called as each test is started, to notify any
5858 import com.sun.javatest.util.BackupPolicy;
5959 import com.sun.javatest.util.I18NResourceBundle;
6060 import com.sun.javatest.util.StringArray;
61
6162 import java.lang.reflect.Method;
6263 import java.lang.reflect.Modifier;
6364
214215
215216 File f = new File(canonRootDir, TESTSUITE_JTT);
216217 if (isReadableFile(f)) {
217 try {
218 Properties p = new Properties();
219 InputStream in = new BufferedInputStream(new FileInputStream(f));
220 p.load(in);
221 in.close();
218 try (InputStream in = new BufferedInputStream(new FileInputStream(f))) {
219 Map<String, String> p = com.sun.javatest.util.Properties.load(in);
222220 return open(canonRoot, p);
223221 }
224222 catch (IOException e) {
231229 File parentDir = canonRootDir.getParentFile();
232230 File parent_jtt = (parentDir == null ? null : new File(parentDir, TESTSUITE_JTT));
233231 if (isReadableFile(ts_html) && (parent_jtt == null || !parent_jtt.exists()))
234 return open(canonRoot, new HashMap());
232 return open(canonRoot, new HashMap<String, String>());
235233 else
236234 throw new NotTestSuiteFault(i18n, "ts.notTestSuiteFile", canonRoot);
237235 }
244242 * @return A TestSuite object for the test suite in question.
245243 * @throws TestSuite.Fault if any problems occur while opening the test suite
246244 */
247 private static TestSuite open(File root, Map tsInfo) throws Fault {
245 private static TestSuite open(File root, Map<String, String> tsInfo) throws Fault {
248246 synchronized (dirMap) {
249247 TestSuite ts;
250248
251249 // if this test suite has already been opened, return that
252 WeakReference ref = (WeakReference)(dirMap.get(root));
250 WeakReference<TestSuite> ref = dirMap.get(root);
253251 if (ref != null) {
254 ts = (TestSuite)(ref.get());
252 ts = ref.get();
255253 if (ts != null) {
256254 return ts;
257255 }
261259 ts = open0(root, tsInfo);
262260
263261 // save reference in case opened again
264 dirMap.put(root, new WeakReference(ts));
262 dirMap.put(root, new WeakReference<>(ts));
265263 return ts;
266264 }
267265 }
268266
269 private static TestSuite open0(File root, Map tsInfo) throws Fault {
270 String[] classPath = StringArray.split((String) (tsInfo.get("classpath")));
267 private static TestSuite open0(File root, Map<String, String> tsInfo) throws Fault {
268 String[] classPath = StringArray.split(tsInfo.get("classpath"));
271269
272270 ClassLoader cl;
273271 if (classPath.length == 0)
295293 }
296294 }
297295
298 String[] tsClassAndArgs = StringArray.split((String) (tsInfo.get("testsuite")));
296 String[] tsClassAndArgs = StringArray.split(tsInfo.get("testsuite"));
299297
300298 TestSuite testSuite;
301299 if (tsClassAndArgs.length == 0)
304302 String className = tsClassAndArgs[0];
305303
306304 try {
307 Class c = loadClass(className, cl);
308 Class[] tsArgTypes = {File.class, Map.class, ClassLoader.class};
305 Class<?> c = loadClass(className, cl);
306 Class<?>[] tsArgTypes = {File.class, Map.class, ClassLoader.class};
309307 Object[] tsArgs = {root, tsInfo, cl};
310308 testSuite = (TestSuite)(newInstance(c, tsArgTypes, tsArgs));
311309 }
363361 * typically using a class path defined in the test suite properties file.
364362 * @throws TestSuite.Fault if a problem occurs while creating this test suite.
365363 */
366 public TestSuite(File root, Map tsInfo, ClassLoader cl) throws Fault {
364 public TestSuite(File root, Map<String, String> tsInfo, ClassLoader cl) throws Fault {
367365 this.root = root;
368366 this.tsInfo = tsInfo;
369367 this.loader = cl;
370368
371 String kw = (tsInfo == null ? null : (String) (tsInfo.get("keywords")));
369 String kw = (tsInfo == null ? null : tsInfo.get("keywords"));
372370 keywords = (kw == null ? null : StringArray.split(kw));
373371 }
374372
438436 * @return the directory that contains the tests
439437 */
440438 public File getTestsDir() {
441 String t = (String) (tsInfo == null ? null : tsInfo.get("tests"));
439 String t = (tsInfo == null ? null : tsInfo.get("tests"));
442440 if (t == null || t.length() == 0) {
443441 File rootDir = getRootDir();
444442 File testsDir = new File(rootDir, "tests");
549547 File testsDir = getTestsDir();
550548
551549 // no BTF file; look for a finder=class args... entry
552 String[] finderCmd = StringArray.split((String) (tsInfo.get("finder")));
550 String[] finderCmd = StringArray.split((tsInfo.get("finder")));
553551 String finderClassName;
554552 String[] finderArgs = new String[0];
555553
571569 }
572570
573571 // first, try looking for testsuite.jtd
574 String jtd = (String) (tsInfo.get("testsuite.jtd"));
572 String jtd = tsInfo.get("testsuite.jtd");
575573 File jtdFile = (jtd == null ? new File(testsDir, "testsuite.jtd") : new File(root, jtd));
576574 if (jtdFile.exists()) {
577575 try {
589587 }
590588
591589 try {
592 Class c = loadClass(finderClassName);
590 Class<?> c = loadClass(finderClassName);
593591 TestFinder tf = (TestFinder) (newInstance(c));
594592 // called old deprecated entry till we know no-one cares
595593 //tf.init(finderArgs, testsRoot, null, null, tsInfo/*pass in env?*/);
629627 TestFinder tf = null;
630628
631629 if (finderClassName != null) {
632 Class c = loadClass(finderClassName);
630 Class<?> c = loadClass(finderClassName);
633631 tf = (TestFinder) (newInstance(c));
634632 }
635633
695693 if (scriptClass == null) {
696694 String[] script = envLookup(scriptEnv, "script");
697695 if (script.length == 0)
698 script = StringArray.split((String) tsInfo.get("script"));
696 script = StringArray.split(tsInfo.get("script"));
699697 if (script.length > 0) {
700698 scriptClass = loadClass(script[0]);
701699 if (!Script.class.isAssignableFrom(scriptClass)) {
709707 // for backwards compatibility,
710708 // see if KeywordScript is a reasonable default
711709 boolean keywordScriptOK = false;
712 for (Iterator i = scriptEnv.keys().iterator(); i.hasNext() && !keywordScriptOK; ) {
713 String key = (String)(i.next());
710 for (Iterator<String> i = scriptEnv.keys().iterator(); i.hasNext() && !keywordScriptOK; ) {
711 String key = i.next();
714712 keywordScriptOK = key.startsWith("script.");
715713 }
716714 if (keywordScriptOK) {
756754 public InterviewParameters createInterview()
757755 throws Fault
758756 {
759 String[] classNameAndArgs = StringArray.split((String) (tsInfo.get("interview")));
757 String[] classNameAndArgs = StringArray.split((tsInfo.get("interview")));
760758 if (classNameAndArgs == null || classNameAndArgs.length == 0) {
761759 try {
762760 return new LegacyParameters(this);
773771 System.arraycopy(classNameAndArgs, 1, args, 0, args.length);
774772
775773 try {
776 Class c = loadClass(className);
774 Class<?> c = loadClass(className);
777775 InterviewParameters p = (InterviewParameters) (newInstance(c));
778776 p.init(args);
779777 p.setTestSuite(this);
796794 * @return A configuration interview to collect the configuration data for a test run.
797795 * @throws TestSuite.Fault if a problem occurs while creating the interview
798796 */
799 public InterviewParameters loadInterviewFromTemplate(Properties templateInfo, InterviewParameters newInterview)
797 public InterviewParameters loadInterviewFromTemplate(Map<String, String> templateInfo, InterviewParameters newInterview)
800798 throws Fault
801799 {
802800 newInterview.storeTemplateProperties(templateInfo);
815813 InterviewParameters ip)
816814 throws Fault, IOException
817815 {
818 InputStream in = null;
819 try {
820 in = new BufferedInputStream(new FileInputStream(template));
821 Properties data = new Properties();
822 data.load(in);
823 String tm = (String) data.get(InterviewParameters.IS_TEMPLATE);
816 try (InputStream in = new BufferedInputStream(new FileInputStream(template))) {
817 Map<String, String> stringProps = com.sun.javatest.util.Properties.load(in);
818 String tm = stringProps.get(InterviewParameters.IS_TEMPLATE);
824819 if (InterviewParameters.TRUE.equals(tm)) {
825 data.put(InterviewParameters.TEMPLATE_PATH,
820 stringProps.put(InterviewParameters.TEMPLATE_PATH,
826821 template.getAbsolutePath());
827822 ip.setTemplatePath(template.getAbsolutePath());
828 return loadInterviewFromTemplate(data, ip);
823 return loadInterviewFromTemplate(stringProps, ip);
829824 } else {
830825 // XXX should probably return ip
831826 // or throw Fault
832827 return null;
833828 }
834 } finally {
835 if (in != null) in.close();
836829 }
837830 }
838831
845838 * @see #getName
846839 */
847840 public String getID() {
848 return (tsInfo == null ? null : (String) (tsInfo.get("id")));
841 return (tsInfo == null ? null : tsInfo.get("id"));
849842 }
850843
851844 /**
857850 * @see #getID
858851 */
859852 public String getName() {
860 return (tsInfo == null ? null : (String) (tsInfo.get("name")));
853 return (tsInfo == null ? null : tsInfo.get("name"));
861854 }
862855
863856 /**
870863 public int getEstimatedTestCount() {
871864 try {
872865 if (tsInfo != null) {
873 String s = (String) (tsInfo.get("testCount"));
866 String s = tsInfo.get("testCount");
874867 if (s != null)
875868 return Integer.parseInt(s);
876869 }
889882 * @return the name of the default exclude list, or null if none specified.
890883 */
891884 public File getInitialExcludeList() {
892 String s = (tsInfo == null ? null : (String) (tsInfo.get("initial.jtx")));
885 String s = (tsInfo == null ? null : tsInfo.get("initial.jtx"));
893886 if (s == null)
894887 return null;
895888
920913 */
921914 public URL getLatestExcludeList() {
922915 try {
923 String s = (tsInfo == null ? null : (String) (tsInfo.get("latest.jtx")));
916 String s = (tsInfo == null ? null : tsInfo.get("latest.jtx"));
924917 return (s == null ? null : new URL(s));
925918 }
926919 catch (MalformedURLException e) {
958951 public String[] getAdditionalDocNames() {
959952 return (tsInfo == null
960953 ? null
961 : StringArray.split((String) (tsInfo.get("additionalDocs"))));
954 : StringArray.split((tsInfo.get("additionalDocs"))));
962955 }
963956
964957 /**
10131006 */
10141007 public URL getLogo() {
10151008 try {
1016 String s = (tsInfo == null ? null : (String) (tsInfo.get("logo")));
1009 String s = (tsInfo == null ? null : tsInfo.get("logo"));
10171010 return (s == null ? null : new URL(getRootDir().toURL(), s));
10181011 }
10191012 catch (MalformedURLException e) {
10401033 * @throws TestSuite.Fault if any errors arise while trying to instantiate
10411034 * the class.
10421035 */
1043 protected static Object newInstance(Class c) throws Fault {
1036 protected static Object newInstance(Class<?> c) throws Fault {
10441037 try {
10451038 return c.newInstance();
10461039 }
10661059 * @throws TestSuite.Fault if any errors arise while trying to instantiate
10671060 * the class.
10681061 */
1069 protected static Object newInstance(Class c, Class[] argTypes, Object[] args)
1062 protected static Object newInstance(Class<?> c, Class<?>[] argTypes, Object[] args)
10701063 throws Fault
10711064 {
10721065 try {
10901083 catch (NoSuchMethodException e) {
10911084 // don't recurse past the use of a single arg constructor
10921085 if (argTypes.length > 1 && Boolean.getBoolean(FIND_LEGACY_CONSTRUCTOR)) {
1093 return newInstance(c, new Class[] {File.class}, new Object[] {args[0]});
1086 return newInstance(c, new Class<?>[] {File.class}, new Object[] {args[0]});
10941087 }
10951088
10961089 throw new Fault(i18n, "ts.cantFindConstructor",
11041097 * @return the class that was loaded
11051098 * @throws TestSuite.Fault if there was a problem loading the specified class
11061099 */
1107 public Class loadClass(String className) throws Fault {
1100 public Class<?> loadClass(String className) throws Fault {
11081101 return loadClass(className, loader);
11091102 }
11101103
11161109 * @return the class that was loaded
11171110 * @throws TestSuite.Fault if there was a problem loading the specified class
11181111 */
1119 protected static Class loadClass(String className, ClassLoader cl) throws Fault {
1112 protected static Class<?> loadClass(String className, ClassLoader cl) throws Fault {
11201113 try {
11211114 if (cl == null)
11221115 return Class.forName(className);
11721165 */
11731166 boolean isLegacy = false;
11741167 try {
1175 Method m = sr.getClass().getMethod("getServiceDescriptorFileName", new Class[0]);
1168 Method m = sr.getClass().getMethod("getServiceDescriptorFileName", new Class<?>[0]);
11761169 if (Modifier.isAbstract(m.getModifiers())) {
11771170 isLegacy = true;
11781171 }
11961189 return serviceReader;
11971190 }
11981191
1199 String servInfo = (String)tsInfo.get("serviceReader");
1192 String servInfo = tsInfo.get("serviceReader");
12001193 if (servInfo != null) {
12011194 String[] args = servInfo.split(" ");
12021195 try {
1203 Class c = loadClass(args[0]);
1196 Class<?> c = loadClass(args[0]);
12041197 serviceReader = (ServiceReader) (newInstance(c));
12051198 if (args.length > 1) {
12061199 // problem with java1.5, which has no Arrays.copyOfRange();
12301223 * Get a map containing the test suite data in the .jtt file.
12311224 * @return a map containing the test suite data in the .jtt file
12321225 */
1233 protected Map getTestSuiteInfo() {
1226 protected Map<String, String> getTestSuiteInfo() {
12341227 return tsInfo;
12351228 }
12361229
12431236 if (tsInfo == null)
12441237 return null;
12451238 else
1246 return (String) (tsInfo.get(name));
1239 return (tsInfo.get(name));
12471240 }
12481241
12491242 /**
12981291 f = new ObservedFile(wd.getLogFileName());
12991292
13001293 if(observedFiles == null) {
1301 observedFiles = new HashMap();
1294 observedFiles = new HashMap<>();
13021295 }
13031296 if (!observedFiles.containsKey(f.getAbsolutePath())) {
13041297 observedFiles.put(f.getAbsolutePath(), f);
14551448 handlersMap.put(wd.getLogFileName(), wdlh);
14561449 }
14571450
1458 addHandler((WorkDirLogHandler)handlersMap.get(wd.getLogFileName()));
1451 addHandler(handlersMap.get(wd.getLogFileName()));
14591452 }
14601453 setLevel(Level.ALL);
14611454 }
14861479 private static final String FIND_LEGACY_CONSTRUCTOR = "com.sun.javatest.ts.findLegacyCtor";
14871480
14881481 private File root;
1489 private Map tsInfo;
1482 private Map<String, String> tsInfo;
14901483 private ClassLoader loader;
14911484 private TestFinder finder;
14921485
14931486 // the following are used by the default impl of createScript
1494 private Class scriptClass;
1487 private Class<?> scriptClass;
14951488 private String[] scriptArgs;
14961489
14971490 private String[] keywords;
14991492 private ServiceReader serviceReader;
15001493 private ServiceManager serviceManager;
15011494
1502 private static HashMap dirMap = new HashMap(2);
1495 private static Map<File, WeakReference<TestSuite>> dirMap = new HashMap<>(2);
15031496
15041497 private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(TestSuite.class);
15051498 private static String notificationLogName = i18n.getString("notification.logname");
15061499
1507 static HashMap handlersMap = new HashMap();
1500 static Map<String, WorkDirLogHandler> handlersMap = new HashMap<>();
15081501 private static Vector<GeneralPurposeLogger> gpls;
1509 private static HashMap observedFiles;
1502 private static Map<String, File> observedFiles;
15101503
15111504 private final NotificationLogger notifLogger = new NotificationLogger(null);
15121505
286286 throws BadDirectoryFault, WorkDirectoryExistsFault, InitializationFault {
287287 File canonDir;
288288 File jtData;
289 ArrayList undoList = new ArrayList();
289 ArrayList<File> undoList = new ArrayList<>();
290290
291291 try {
292292 if (dir.exists()) {
347347 return logFileName;
348348 }
349349
350 private static boolean mkdirs(File dir, ArrayList undoList) {
350 private static boolean mkdirs(File dir, ArrayList<File> undoList) {
351351 File parent = dir.getParentFile();
352352 if (parent != null && !parent.exists()) {
353353 if (!mkdirs(parent, undoList))
363363 return false;
364364 }
365365
366 private static void undo(ArrayList undoList) {
366 private static void undo(ArrayList<File> undoList) {
367367 for (int i = undoList.size() - 1; i >= 0; i--) {
368 File f = (File) (undoList.get(i));
368 File f = undoList.get(i);
369369 delete(f);
370370 }
371371 }
433433 File templateData = new File(canonDir, JTDATA + File.separator + "template.data");
434434 if (templateData.exists()) {
435435 Properties p = new Properties();
436 FileInputStream fis = null;
437 try {
438 fis = new FileInputStream(templateData.getAbsolutePath());
436 try (FileInputStream fis = new FileInputStream(templateData.getAbsolutePath())) {
439437 p.load(fis);
440438 } catch (IOException e) {
441439 e.printStackTrace();
442440 }
443 finally {
444 try { if (fis != null) fis.close(); } catch (IOException e) {}
445 }
446441
447442 String templateFile = p.getProperty("file");
448443 if (!new File(templateFile).exists()) {
449444
450445 try {
451446 // try to calculate relocation
452 String oldWDpath = loadWdInfo(jtData).getProperty(PREV_WD_PATH);
447 String oldWDpath = loadWdInfo(jtData).get(PREV_WD_PATH);
453448 String[] begins = getDiffInPaths(dir.getPath(), oldWDpath);
454449 if (begins != null) {
455450 if (templateFile.startsWith(begins[1])) {
555550
556551 synchronized (dirMap) {
557552 // sync-ed to make dirMap data consistent
558 WeakReference ref = (WeakReference)(dirMap.get(canonDir));
559 wd = (ref == null ? null : (WorkDirectory) (ref.get()));
553 WeakReference<WorkDirectory> ref = dirMap.get(canonDir);
554 wd = (ref == null ? null : ref.get());
560555
561556 if (wd != null)
562557 return wd;
563558
564 Properties tsInfo;
559 Map<String, String> tsInfo;
565560 TestSuite ts;
566561
567562 try {
568563 tsInfo = loadTestSuiteInfo(jtData);
569 String root = tsInfo.getProperty(TESTSUITE_ROOT);
564 String root = tsInfo.get(TESTSUITE_ROOT);
570565 if (root == null)
571566 throw new BadDirectoryFault(i18n, "wd.noTestSuiteRoot", canonDir);
572567
576571
577572 ts = TestSuite.open(tsr);
578573
579 String wdID = (tsInfo == null ? null : (String) (tsInfo.get(TESTSUITE_ID)));
574 String wdID = (tsInfo == null ? null : tsInfo.get(TESTSUITE_ID));
580575 String tsID = ts.getID();
581576 if (!(wdID == null ? "" : wdID).equals(tsID == null ? "" : tsID))
582577 throw new MismatchFault(i18n, "wd.mismatchID", canonDir);
637632
638633 WorkDirectory wd = null;
639634 synchronized (dirMap) {
640 WeakReference ref = (WeakReference)(dirMap.get(canonDir));
635 WeakReference<WorkDirectory> ref = dirMap.get(canonDir);
641636 if (ref != null)
642 wd = (WorkDirectory)(ref.get());
637 wd = ref.get();
643638
644639 if (wd == null) {
645 Properties tsInfo;
640 Map<String, String> tsInfo;
646641 try {
647642 tsInfo = loadTestSuiteInfo(jtData);
648643 } catch (IOException e) {
649644 tsInfo = null;
650645 }
651646
652 String wdID = (tsInfo == null ? null : (String) (tsInfo.get(TESTSUITE_ID)));
647 String wdID = (tsInfo == null ? null : tsInfo.get(TESTSUITE_ID));
653648 String tsID = testSuite.getID();
654649 if (!(wdID == null ? "" : wdID).equals(tsID == null ? "" : tsID))
655650 throw new MismatchFault(i18n, "wd.mismatchID", canonDir);
672667 * Create a WorkDirectory object for a given directory and testsuite.
673668 * The directory is assumed to be valid (exists(), isDirectory(), canRead() etc)
674669 */
675 private WorkDirectory(File root, TestSuite testSuite, Map tsInfo) {
670 private WorkDirectory(File root, TestSuite testSuite, Map<String, String> tsInfo) {
676671 if (root == null || testSuite == null)
677672 throw new NullPointerException();
678673 this.root = root;
695690 // -- possibly conditionally (don't need to write it in case of normal open)
696691
697692 if (tsInfo != null) {
698 String testC = (String) (tsInfo.get(TESTSUITE_TESTCOUNT));
693 String testC = (tsInfo.get(TESTSUITE_TESTCOUNT));
699694 int tc;
700695 if (testC == null)
701696 tc = -1;
721716
722717 private void doWDinfo(File jtData, TestSuite testSuite) {
723718 try {
724 oldWDpath = loadWdInfo(jtData).getProperty(PREV_WD_PATH);
719 oldWDpath = loadWdInfo(jtData).get(PREV_WD_PATH);
725720 } catch (IOException ex) {
726721 oldWDpath = null;
727722 }
948943 public synchronized void putTestAnnotation(String testName, String key, String value) {
949944 loadAnnotations();
950945
951 HashMap<String,String> map = null;
946 Map<String,String> map = null;
952947 if (annotationMap == null)
953 annotationMap = new TreeMap<String,HashMap<String,String>>();
948 annotationMap = new TreeMap<String, Map<String,String>>();
954949 else
955950 map = annotationMap.get(testName);
956951
10711066
10721067 DataInputStream reader = new DataInputStream(new BufferedInputStream(fis));
10731068
1074 annotationMap = new TreeMap<String,HashMap<String,String>>();
1069 annotationMap = new TreeMap<String, Map<String,String>>();
10751070
10761071 try {
10771072 while(reader.available() > 0) {
10801075 String s2 = reader.readUTF();
10811076 String s3 = reader.readUTF();
10821077
1083 HashMap map = annotationMap.get(s1);
1078 Map<String,String> map = annotationMap.get(s1);
10841079 if (map == null) {
10851080 map = new HashMap<String,String>();
10861081 annotationMap.put(s1, map);
11271122 DataOutputStream writer = new DataOutputStream(new BufferedOutputStream(fos));
11281123 // writes a triplet
11291124 for (String s: annotationMap.keySet()) {
1130 HashMap<String,String> map = annotationMap.get(s);
1125 Map<String,String> map = annotationMap.get(s);
11311126 try {
11321127 for (String key: map.keySet()) {
11331128 writer.writeUTF(s); // 1
11881183 return result;
11891184 }
11901185
1191 private static Properties loadTestSuiteInfo(File jtData) throws FileNotFoundException, IOException {
1186 private static Map<String, String> loadTestSuiteInfo(File jtData) throws FileNotFoundException, IOException {
11921187 return loadInfo(jtData, TESTSUITE);
11931188 }
11941189
1195 private static Properties loadWdInfo(File jtData) throws FileNotFoundException, IOException {
1190 private static Map<String, String> loadWdInfo(File jtData) throws FileNotFoundException, IOException {
11961191 return loadInfo(jtData, WD_INFO);
11971192 }
11981193
1199 private static Properties loadInfo(File jtData, String name) throws FileNotFoundException, IOException {
1200 File f = new File(jtData, name);
1201 InputStream in = new BufferedInputStream(new FileInputStream(f));
1202 Properties p = new Properties();
1203 p.load(in);
1204 in.close();
1205 return p;
1194 private static Map<String, String> loadInfo(File jtData, String name) throws FileNotFoundException, IOException {
1195 try (InputStream in = new BufferedInputStream(new FileInputStream(new File(jtData, name)))) {
1196 return com.sun.javatest.util.Properties.load(in);
1197 }
12061198 }
12071199
12081200
12541246 private String oldWDpath;
12551247 private int testCount = -1;
12561248 private TestResultTable testResultTable;
1257 private TreeMap<String,HashMap<String,String>> annotationMap;
1249 private Map<String, Map<String,String>> annotationMap;
12581250 private File jtData;
12591251 private String logFileName;
12601252 private LogFile logFile;
1261 private static HashMap dirMap = new HashMap(2); // must be manually synchronized
1253 private static HashMap<File, WeakReference<WorkDirectory>> dirMap = new HashMap<>(2); // must be manually synchronized
12621254 public static final String JTDATA = "jtData";
12631255 private static final String TESTSUITE = "testsuite";
12641256 private static final String WD_INFO = "wdinfo";
00 /*
11 * $Id$
22 *
3 * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
44 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55 *
66 * This code is free software; you can redistribute it and/or modify it
323323 return v.contains(e);
324324 }
325325
326 synchronized Enumeration elements() {
327 return ((Vector)(v.clone())).elements();
326 synchronized Enumeration<Connection> elements() {
327 return ((Vector<Connection>)(v.clone())).elements();
328328 }
329329
330330 synchronized void add(final Entry e) {
353353 synchronized Entry next() {
354354 Entry e = null;
355355 if (v.size() > 0) {
356 e = (Entry)(v.elementAt(0));
356 e = v.elementAt(0);
357357 v.removeElementAt(0);
358358 notifyRemovedFromPool(e);
359359 }
374374 }
375375
376376 synchronized void addObserver(Observer o) {
377 observers = (Observer[])(DynamicArray.append(observers, o));
377 observers = DynamicArray.append(observers, o);
378378 }
379379
380380
381381 synchronized void deleteObserver(Observer o) {
382 observers = (Observer[])(DynamicArray.remove(observers, o));
382 observers = DynamicArray.remove(observers, o);
383383 }
384384
385385 private synchronized void notifyAddedToPool(Entry e) {
394394 }
395395 }
396396
397 private Vector v = new Vector();
397 private Vector<Entry> v = new Vector<>();
398398 private Observer[] observers = new Observer[0];
399399 }
400400
589589 /**
590590 * Get an enumeration of the entries currently in the active agent pool.
591591 */
592 Enumeration elements() {
592 Enumeration<Connection> elements() {
593593 return entries.elements();
594594 }
595595
00 /*
11 * $Id$
22 *
3 * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
44 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55 *
66 * This code is free software; you can redistribute it and/or modify it
202202 else {
203203 traceOut.println("set map:");
204204 map.setTracing(tracing, traceOut);
205 for (Enumeration e = map.enumerate(); e.hasMoreElements(); ) {
206 String[] entry = (String[])(e.nextElement());
205 for (Enumeration<String[]> e = map.enumerate(); e.hasMoreElements(); ) {
206 String[] entry = e.nextElement();
207207 traceOut.println("map-from: " + entry[0]);
208208 traceOut.println("map-to: " + entry[1]);
209209 }
334334
335335 // interrupt any threads that are running
336336 for (int i = 0; i < threads.size(); i++) {
337 Thread t = (Thread)(threads.elementAt(i));
337 Thread t = threads.elementAt(i);
338338 if (tracing)
339339 traceOut.println("INTERRUPTING THREAD " + t.getName());
340340 t.interrupt();
346346
347347 // close any tasks that are running
348348 for (int i = 0; i < tasks.size(); i++) {
349 Task t = (Task)(tasks.elementAt(i));
349 Task t = tasks.elementAt(i);
350350 if (tracing) {
351351 Connection c = t.connection; // maybe null; if it is, task is already closing
352352 traceOut.println("CLOSING TASK " + (c == null ? "[unknown]" : c.getName()));
450450
451451 private class Notifier {
452452 public synchronized void addObserver(Observer o) {
453 observers = (Observer[])(DynamicArray.append(observers, o));
453 observers = DynamicArray.append(observers, o);
454454 }
455455
456456 public synchronized void removeObserver(Agent.Observer o) {
457 observers = (Observer[])(DynamicArray.remove(observers, o));
457 observers = DynamicArray.remove(observers, o);
458458 }
459459
460460 public synchronized void started() {
541541 private boolean closing;
542542 private Thread mainThread;
543543 private int maxThreads;
544 private Vector threads = new Vector();
545 private Vector tasks = new Vector();
544 private Vector<Thread> threads = new Vector<>();
545 private Vector<Task> tasks = new Vector<>();
546546 private Notifier notifier = new Notifier();
547547 private Object currSystemStreamOwner = null;
548548 private PrintStream saveOut;
596596
597597 static final String productName = "JT Harness Agent";
598598 static final String productVersion = "JTA_5.0";
599 static final String productCopyright = "Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.";
599 static final String productCopyright = "Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.";
600600
601601
602602 /**
780780 PrintWriter testRef = new PrintWriter(new AgentWriter(REF, this));
781781
782782 try {
783 Class c;
783 Class<?> c;
784784 ClassLoader cl = null;
785785 if (remoteClasses) {
786786 cl = getAgentClassLoader(sharedClassLoader);
833833 }
834834 }
835835
836 private Status executeTest(Class c, String[] args,
836 private Status executeTest(Class<?> c, String[] args,
837837 PrintWriter testLog, PrintWriter testRef)
838838 throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException {
839839 notifier.execTest(connection, tag, c.getName(), args);
841841 return t.run(args, testLog, testRef);
842842 }
843843
844 private Status executeCommand(Class c, String[] args,
844 private Status executeCommand(Class<?> c, String[] args,
845845 PrintWriter testLog, PrintWriter testRef,
846846 ClassLoader cl)
847847 throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException {
935935
936936 }
937937
938 private Status executeMain(Class c, String[] args,
938 private Status executeMain(Class<?> c, String[] args,
939939 PrintWriter testLog, PrintWriter testRef)
940940 throws IOException, ClassNotFoundException, IllegalAccessException {
941941 notifier.execMain(connection, tag, c.getName(), args);
944944 PrintStream err = Deprecated.createPrintStream(new WriterStream(testLog));
945945 try {
946946 setSystemStreams(this, out, err);
947 Method main = c.getDeclaredMethod("main", new Class[] {String[].class});
947 Method main = c.getDeclaredMethod("main", new Class<?>[] {String[].class});
948948 main.invoke(null, new Object[] {args});
949949 return Status.passed("OK");
950950 } catch (NoSuchMethodException e) {
11061106
11071107 private ClassLoader getAgentClassLoader(boolean useSharedClassLoader)
11081108 throws InstantiationException, IllegalAccessException {
1109 Class classLoaderClass;
1109 Class<? extends ClassLoader> classLoaderClass;
11101110 try {
11111111 String s = getClass().getName();
11121112 String pkg = s.substring(0, s.lastIndexOf('.'));
1113 classLoaderClass = Class.forName(pkg + ".AgentClassLoader2");
1113 classLoaderClass = (Class<? extends ClassLoader>) Class.forName(pkg + ".AgentClassLoader2");
11141114 } catch (Throwable t) {
11151115 classLoaderClass = AgentClassLoader.class;
11161116 }
11171117
1118 Class[] argTypes = {Task.class};
1118 Class<?>[] argTypes = {Task.class};
11191119 if (useSharedClassLoader && factoryMethod == null) {
11201120 try {
11211121 factoryMethod = classLoaderClass.getDeclaredMethod("getInstance", argTypes);
11381138 if (useSharedClassLoader && factoryMethod != null) {
11391139 return (ClassLoader) factoryMethod.invoke(null, args);
11401140 } else {
1141 return (ClassLoader) (classLoaderConstructor.newInstance(args));
1141 return classLoaderConstructor.newInstance(args);
11421142 }
11431143 } catch (InvocationTargetException e) {
11441144 Throwable t = e.getTargetException();
11611161 private Integer timeoutValue;
11621162 }
11631163
1164 private static Constructor classLoaderConstructor;
1164 private static Constructor<? extends ClassLoader> classLoaderConstructor;
11651165 private static Method factoryMethod = null;
11661166 }
11671167
127127
128128 ModeOptions smo = null;
129129 try {
130 Class serial = Class.forName("com.sun.javatest.agent.SerialPortModeOptions");
130 Class<?> serial = Class.forName("com.sun.javatest.agent.SerialPortModeOptions");
131131 smo = (ModeOptions)serial.newInstance();
132132 } catch (Exception e) {
133133 System.err.println("There is no support for serial port");
162162
163163 if (observerClassName != null) {
164164 try {
165 Class observerClass = Class.forName(observerClassName);
165 Class<?> observerClass = Class.forName(observerClassName);
166166 Agent.Observer observer = (Agent.Observer)(observerClass.newInstance());
167167 ap.addObserver(observer);
168168 }
3333 this.parent = parent;
3434 }
3535
36 public synchronized Class loadClass(String className, boolean resolve) throws ClassNotFoundException {
36 public synchronized Class<?> loadClass(String className, boolean resolve) throws ClassNotFoundException {
3737
3838 // check the cache first
39 Class c = findLoadedClass(className);
39 Class<?> c = findLoadedClass(className);
4040
4141 // not found in the cache?
4242 if (c == null) {
9797 return instance;
9898 }
9999
100 public Class loadClassLocal(String name) throws ClassNotFoundException {
101 Class target = null;
100 public Class<?> loadClassLocal(String name) throws ClassNotFoundException {
101 Class<?> target = null;
102102 System.out.println("FORCE REMOTE " + name);
103103 try {
104104 target = findClass(name);
117117
118118
119119 @Override
120 public Class findClass(String className) throws ClassNotFoundException {
120 public Class<?> findClass(String className) throws ClassNotFoundException {
121121 if (className != null) {
122122 int i = className.lastIndexOf('.');
123123 if (i > 0) {
9393 ModeOptions smo = null;
9494
9595 try {
96 Class serial = Class.forName("com.sun.javatest.agent.SerialPortModeOptions");
96 Class<?> serial = Class.forName("com.sun.javatest.agent.SerialPortModeOptions");
9797 smo = (ModeOptions)serial.newInstance();
9898 } catch (Exception e) {
9999 System.err.println("There is no support for serial port");
207207
208208 if (observerClassName != null) {
209209 try {
210 Class observerClass = Class.forName(observerClassName);
210 Class<?> observerClass = Class.forName(observerClassName);
211211 Agent.Observer observer = (Agent.Observer)(observerClass.newInstance());
212212 sf.panel.addObserver(observer);
213213 }
260260 sp.start();
261261
262262 try {
263 Method invokeLater = EventQueue.class.getMethod("invokeLater", new Class[] { Runnable.class });
263 Method invokeLater = EventQueue.class.getMethod("invokeLater", new Class<?>[] { Runnable.class });
264264 invokeLater.invoke(null, new Object[] { new Runnable() {
265265 public void run() {
266266 sf.showCentered();
00 /*
11 * $Id$
22 *
3 * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
44 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55 *
66 * This code is free software; you can redistribute it and/or modify it
373373 switch (mode) {
374374 case ACTIVE:
375375 try {
376 Class c = Class.forName(pkg + ".ActiveConnectionFactory");
377 Constructor m = c.getConstructor(new Class[] {String.class, int.class});
376 Class<?> c = Class.forName(pkg + ".ActiveConnectionFactory");
377 Constructor<?> m = c.getConstructor(new Class<?>[] {String.class, int.class});
378378 Object[] args = { activeHost, new Integer(activePort) };
379379 return (ConnectionFactory)(m.newInstance(args));
380380 }
390390
391391 case PASSIVE:
392392 try {
393 Class c = Class.forName(pkg + ".PassiveConnectionFactory");
394 Constructor m = c.getConstructor(new Class[] {int.class, int.class});
393 Class<?> c = Class.forName(pkg + ".PassiveConnectionFactory");
394 Constructor<?> m = c.getConstructor(new Class<?>[] {int.class, int.class});
395395 Object[] args = { new Integer(passivePort), new Integer(concurrency + 1) };
396396 return (ConnectionFactory)(m.newInstance(args));
397397 }
411411
412412 case SERIAL:
413413 try {
414 Class c = Class.forName(pkg + ".SerialPortConnectionFactory");
415 Constructor m = c.getConstructor(new Class[] {String.class, String.class, int.class});
414 Class<?> c = Class.forName(pkg + ".SerialPortConnectionFactory");
415 Constructor<?> m = c.getConstructor(new Class<?>[] {String.class, String.class, int.class});
416416 Object[] args = {serialPort, Agent.productName, new Integer(10*1000)};
417417 return (ConnectionFactory)(m.newInstance(args));
418418 }
459459
460460 if (observerClassName != null) {
461461 try {
462 Class observerClass = Class.forName(observerClassName);
462 Class<?> observerClass = Class.forName(observerClassName);
463463 Agent.Observer observer = (Agent.Observer)(observerClass.newInstance());
464464 agent.addObserver(observer);
465465 }
620620 public void completed(Agent agent, Connection c) {
621621 }
622622
623 private Class connectExceptionClass;
624 private Class unknownHostExceptionClass;
623 private Class<?> connectExceptionClass;
624 private Class<?> unknownHostExceptionClass;
625625 }
626626 }
00 /*
11 * $Id$
22 *
3 * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
44 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55 *
66 * This code is free software; you can redistribute it and/or modify it
106106 * @see #removeObserver
107107 */
108108 public synchronized void addObserver(Observer o) {
109 observers = (Observer[])(DynamicArray.append(observers, o));
109 observers = DynamicArray.append(observers, o);
110110 }
111111
112112 /**
114114 * @param o The observer to be removed.
115115 */
116116 public synchronized void removeObserver(Observer o) {
117 observers = (Observer[])(DynamicArray.remove(observers, o));
117 observers = DynamicArray.remove(observers, o);
118118 }
119119
120120 private synchronized void notifyStarted(Connection connection,
535535 ref.flush();
536536
537537 // might be better not to flush these ...
538 for (Enumeration e = zips.keys(); e.hasMoreElements(); ) {
539 File f = (File)(e.nextElement());
540 ZipFile z = (ZipFile)(zips.get(f));
538 for (Enumeration<File> e = zips.keys(); e.hasMoreElements(); ) {
539 File f = (e.nextElement());
540 ZipFile z = zips.get(f);
541541 zips.remove(f);
542542 z.close();
543543 }
603603 private byte[] readFromJar(String name, File jarFile) {
604604 //System.err.println("readFromJar: " + name + " " + jarFile);
605605 try {
606 ZipFile z = (ZipFile)zips.get(jarFile);
606 ZipFile z = zips.get(jarFile);
607607 if (z == null) {
608608 z = new ZipFile(jarFile);
609609 zips.put(jarFile, z);
640640
641641 private File[] split(String s) {
642642 char pathCh = File.pathSeparatorChar;
643 Vector v = new Vector();
643 Vector<File> v = new Vector<>();
644644 int start = 0;
645645 for (int i = s.indexOf(pathCh); i != -1; i = s.indexOf(pathCh, start)) {
646646 add(s.substring(start, i), v);
653653 return path;
654654 }
655655
656 private void add(String s, Vector v) {
656 private void add(String s, Vector<File> v) {
657657 if (s.length() != 0)
658658 v.addElement(new File(s));
659659 }
665665 private File[] classPath;
666666 private boolean sharedCl;
667667 private int timeout = 0;
668 private Hashtable zips = new Hashtable();
668 private Hashtable<File, ZipFile> zips = new Hashtable<>();
669669 }
670670
671671 }
5555
5656 //----------------------------------------------------------------------------
5757
58 public boolean parseCommand(String cmd, ListIterator argIter, CommandContext ctx)
58 public boolean parseCommand(String cmd, ListIterator<String> argIter, CommandContext ctx)
5959 throws Command.Fault
6060 {
6161 if (cmd.equalsIgnoreCase(AgentPoolPortCommand.getName())) {
8585 return "agentPoolPort";
8686 }
8787
88 AgentPoolPortCommand(ListIterator argIter) throws Fault {
88 AgentPoolPortCommand(ListIterator<String> argIter) throws Fault {
8989 super(getName());
9090
9191 if (!argIter.hasNext())
115115 return "agentPoolTimeout";
116116 }
117117
118 AgentPoolTimeoutCommand(ListIterator argIter) throws Fault {
118 AgentPoolTimeoutCommand(ListIterator<String> argIter) throws Fault {
119119 super(getName());
120120
121121 if (!argIter.hasNext())
145145 return "startAgentPool";
146146 }
147147
148 StartAgentPoolCommand(ListIterator argIter) throws Fault {
148 StartAgentPoolCommand(ListIterator<String> argIter) throws Fault {
149149 super(getName());
150150
151151 while (argIter.hasNext()) {
4141
4242
4343 @Override
44 public boolean parseCommand(String cmd, ListIterator argIter, CommandContext ctx)
44 public boolean parseCommand(String cmd, ListIterator<String> argIter, CommandContext ctx)
4545 throws Command.Fault
4646 {
4747
00 /*
11 * $Id$
22 *
3 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
44 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55 *
66 * This code is free software; you can redistribute it and/or modify it
9898 return menuBar;
9999 }
100100
101 public void save(Map m) {
101 public void save(Map<String, String> m) {
102102 int port = agentPoolSubpanel.getPort();
103103 if (port != Integer.MIN_VALUE)
104104 m.put("port", String.valueOf(port));
114114 * @return An AgentMonitorTool restored from the data in the map.
115115 */
116116 @Override
117 protected void restore(Map m) {
118 String l = (String) (m.get("listening"));
117 protected void restore(Map<String, String> m) {
118 String l = m.get("listening");
119119 try {
120 String p = (String) (m.get("port"));
120 String p = m.get("port");
121121 if (p != null && p.length() != 0)
122122 agentPoolSubpanel.setPort(Integer.parseInt(p));
123123
124 String t = (String) (m.get("timeout"));
124 String t = m.get("timeout");
125125 if (t != null && t.length() != 0)
126126 agentPoolSubpanel.setTimeout(Integer.parseInt(t));
127127
177177 add(timeoutField, fc);
178178 timeoutLabel.setLabelFor(timeoutField);
179179
180 listData = new DefaultListModel();
180 listData = new DefaultListModel<>();
181181 list = uif.createList("tool.pool", listData);
182182 list.setPrototypeCellValue("abcdefghiklmnopqrstuvwxyz");
183183 list.setVisibleRowCount(3);
191191 // Ensure any existing entries in the pool are displayed
192192 // Note there is a slight synchronization window between the call of
193193 // elements and that of addObserver.
194 for (Enumeration e = activeAgentPool.elements(); e.hasMoreElements(); ) {
195 Connection conn = (Connection)(e.nextElement());
194 for (Enumeration<Connection> e = activeAgentPool.elements(); e.hasMoreElements(); ) {
195 Connection conn = e.nextElement();
196196 listData.addElement(conn.getName());
197197 }
198198
338338 private JTextField portField;
339339 private JLabel timeoutLabel;
340340 private JTextField timeoutField;
341 private JList list;
342 private DefaultListModel listData;
341 private JList<String> list;
342 private DefaultListModel<String> listData;
343343 }
344344
345345 private class CurrentAgentsSubpanel extends JPanel
351351 setLayout(new GridBagLayout());
352352 uif.setToolTip(this, "tool.curr");
353353
354 listData = new DefaultListModel();
354 listData = new DefaultListModel<>();
355355 list = uif.createList("tool.list.curr", listData);
356356 list.setVisibleRowCount(5);
357357
358358 list.setCellRenderer(new DefaultListCellRenderer() {
359 public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) {
360 String name = ((Entry)o).toString();
359 public Component getListCellRendererComponent(JList<?> list, Object o, int index, boolean isSelected, boolean cellHasFocus) {
360 String name = o.toString();
361361 return super.getListCellRendererComponent(list, name, index, isSelected, cellHasFocus);
362362 }
363363 });
420420 }
421421
422422 public synchronized void valueChanged(ListSelectionEvent ev) {
423 Entry e = (Entry)(list.getSelectedValue());
423 Entry e = list.getSelectedValue();
424424 if (e == null) {
425425 addressField.setText("");
426426 tagField.setText("");
469469 }
470470 else {
471471 for (int i = 0; i < listData.size(); i++) {
472 Entry e = (Entry)(listData.elementAt(i));
472 Entry e = listData.elementAt(i);
473473 if (e.connection == c) {
474474 listData.removeElement(e);
475475 break;
503503 boolean localizeArgs;
504504 }
505505
506 private JList list;
507 private DefaultListModel listData;
506 private JList<Entry> list;
507 private DefaultListModel<Entry> listData;
508508 private Entry selectedEntry;
509509 private JLabel addressLabel;
510510 private JTextField addressField;
6161
6262 //----------------------------------------------------------------------------
6363
64 public Tool restoreTool(Map m) {
64 public Tool restoreTool(Map<String, String> m) {
6565 AgentMonitorTool t = getTool();
6666 t.restore(m);
6767 return t;
00 /*
11 * $Id$
22 *
3 * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
44 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55 *
66 * This code is free software; you can redistribute it and/or modify it
625625 versionLabel.setFont(new Font("SansSerif", Font.BOLD, 24));
626626 infoPanel.add(versionLabel, c);
627627
628 Label copyLabel1 = new Label("Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.");
628 Label copyLabel1 = new Label("Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.");
629629 infoPanel.add(copyLabel1, c);
630630
631631 Label copyLabel2 = new Label("Use is subject to license terms.");
689689 public synchronized void addTask(TaskState task) {
690690 if (tasks.size() >= maxTasks) {
691691 for (int i = 0; i < tasks.size(); i++) {
692 String s = (String) getItem(i);
692 String s = getItem(i);
693693 // skip over active tasks that will be updated later
694694 if (s.startsWith("CONN") || s.startsWith("EXEC"))
695695 continue;
705705
706706 public synchronized TaskState getTask(Connection c) {
707707 for (int i = 0; i < tasks.size(); i++) {
708 TaskState ts = (TaskState)(tasks.elementAt(i));
708 TaskState ts = tasks.elementAt(i);
709709 if (ts.connection == c)
710710 return ts;
711711 }
713713 }
714714
715715 public synchronized TaskState getSelectedTask() {
716 return (TaskState)(tasks.elementAt(super.getSelectedIndex()));
716 return tasks.elementAt(super.getSelectedIndex());
717717 }
718718
719719 public synchronized void removeAll() {
757757 }
758758
759759 private int maxTasks = 10;
760 private Vector tasks = new Vector();
760 private Vector<TaskState> tasks = new Vector<>();
761761 }
762762
763763
972972 }
973973
974974
975 private Vector tasks = new Vector();
975 private Vector<TaskState> tasks = new Vector<>();
976976
977977 private int[] statusCounts = new int[Status.NUM_STATES];
978978 private int exceptionsCount;
00 /*
11 * $Id$
22 *
3 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
44 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55 *
66 * This code is free software; you can redistribute it and/or modify it
142142
143143 public void showTab(String name, boolean visible) {
144144 for (int i = 0; i < entries.size(); i++) {
145 Entry e = (Entry)entries.elementAt(i);
145 Entry e = entries.elementAt(i);
146146 if (e.name.equals(name)) {
147147 if (e.visibleTab != visible) {
148148 e.visibleTab = visible;
156156 public String getNextVisibleTab() {
157157 int currentIndex = Math.max(0, getCurrentIndex());
158158 for (int i = currentIndex + 1; i < entries.size(); i++) {
159 Entry e = (Entry)entries.elementAt(i);
159 Entry e = entries.elementAt(i);
160160 if (e.visibleTab)
161161 return e.name;
162162 }
166166 public String getPrevVisibleTab() {
167167 int currentIndex = getCurrentIndex();
168168 for (int i = currentIndex - 1; i >= 0; i--) {
169 Entry e = (Entry)entries.elementAt(i);
169 Entry e = entries.elementAt(i);
170170 if (e.visibleTab)
171171 return e.name;
172172 }
175175
176176 public Component current() {
177177 for (int i = 0; i < entries.size(); i++) {
178 Entry e = (Entry)entries.elementAt(i);
178 Entry e = entries.elementAt(i);
179179 if (e.comp.isVisible())
180180 return e.comp;
181181 }
184184
185185 public void show(Component comp) {
186186 for (int i = 0; i < entries.size(); i++) {
187 Entry e = (Entry)entries.elementAt(i);
187 Entry e = entries.elementAt(i);
188188 if (e.comp == comp) {
189189 show(e);
190190 return;
194194
195195 public void show(String name) {
196196 for (int i = 0; i < entries.size(); i++) {
197 Entry e = (Entry)entries.elementAt(i);
197 Entry e = entries.elementAt(i);
198198 if (e.name.equals(name)) {
199199 show(e);
200200 return;
214214 int tabHeight = fm.getHeight() + tabpad;
215215 Entry selected = null;
216216 for (int i = 0; i < entries.size(); i++) {
217 Entry e = (Entry)entries.elementAt(i);
217 Entry e = entries.elementAt(i);
218218 if (e.comp.isVisible()) {
219219 selected = e;
220220 break;
233233 int x = border + hgap;
234234 int baseLine = tabHeight + vgap;
235235 for (int i = 0; i < entries.size(); i++) {
236 Entry e = (Entry)entries.elementAt(i);
236 Entry e = entries.elementAt(i);
237237 int tabH = (e.visibleTab || e.comp.isVisible() ? tabHeight : tabHeight / 3);
238238 int w = fm.stringWidth(e.name);
239239 Polygon tab = new Polygon();
281281 FontMetrics fm = getFontMetrics(getFont());
282282 int w = border + 2 * hgap + tabSpace;
283283 for (int i = 0; i < entries.size(); i++) {
284 Entry e = (Entry)entries.elementAt(i);
284 Entry e = entries.elementAt(i);
285285 w += slant + (fm == null ? 0 : fm.stringWidth(e.name)) + slant + tabSpace;
286286 }
287287 return w;
308308
309309 private int getCurrentIndex() {
310310 for (int i = 0; i < entries.size(); i++) {
311 Entry e = (Entry)entries.elementAt(i);
311 Entry e = entries.elementAt(i);
312312 if (e.comp.isVisible())
313313 return i;
314314 }
317317
318318 private Entry getCurrentEntry() {
319319 int i = getCurrentIndex();
320 return (i == -1 ? null : (Entry)(entries.elementAt(i)) );
320 return (i == -1 ? null : entries.elementAt(i));
321321 }
322322
323323 void mousePressed(int mouseX, int mouseY) {
325325 if (vgap < mouseY && mouseY < border + fm.getHeight() + vgap) {
326326 int x = border + hgap;
327327 for (int i = 0; i < entries.size(); i++) {
328 Entry e = (Entry)entries.elementAt(i);
328 Entry e = entries.elementAt(i);
329329 int w = fm.stringWidth(e.name);
330330 x += slant + w + slant + tabSpace;
331331 if (mouseX < x) {
338338
339339
340340 private ItemListener itemListener;
341 private Vector entries = new Vector();
341 private Vector<Entry> entries = new Vector<>();
342342 private int border;
343343 private int slant;
344344 private int tabSpace;
00 /*
11 * $Id$
22 *
3 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
44 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55 *
66 * This code is free software; you can redistribute it and/or modify it
6060 */
6161 public static Map readFile(String name) throws IOException {
6262 try {
63 Class c = Class.forName("java.io.FileReader"); // optional API in Jersonal Java
64 Constructor m = c.getConstructor(new Class[] {String.class});
63 Class<?> c = Class.forName("java.io.FileReader"); // optional API in Jersonal Java
64 Constructor<?> m = c.getConstructor(new Class<?>[] {String.class});
6565 Reader r = (Reader)(m.newInstance(new Object[] {name}));
6666 return new Map(r);
6767 }
132132 (r instanceof BufferedReader ? (BufferedReader)r : new BufferedReader(r))
133133 ;
134134 // data arrives in rows, but we want it in columns
135 Vector from = new Vector();
136 Vector to = new Vector();
135 Vector<String> from = new Vector<>();
136 Vector<String> to = new Vector<>();
137137 String line;
138138 while ((line = in.readLine()) != null) {
139139 line = line.trim();
202202 * Enumerate the entries of the map.
203203 * @return an enumeration of the translation entries within the map
204204 */
205 public Enumeration enumerate() {
206 Vector v = new Vector(fromValues.length);
205 public Enumeration<String[]> enumerate() {
206 Vector<String[]> v = new Vector<>(fromValues.length);
207207 for (int i = 0; i < fromValues.length; i++) {
208208 v.addElement(new String[] {fromValues[i], toValues[i]});
209209 }
4545 super("serial port");
4646
4747 try {
48 Class c = Class.forName(Proxy.class.getName() + "Impl");
48 Class<?> c = Class.forName(Proxy.class.getName() + "Impl");
4949 proxy = (Proxy)(c.newInstance());
5050 }
5151 catch (Throwable ignore) {
110110 class ProxyImpl implements Proxy {
111111 public String[] getPortNames() {
112112 try {
113 Vector v = new Vector();
114 for (Enumeration e = CommPortIdentifier.getPortIdentifiers(); e.hasMoreElements(); ) {
113 Vector<String> v = new Vector<>();
114 for (Enumeration<?> e = CommPortIdentifier.getPortIdentifiers(); e.hasMoreElements(); ) {
115115 CommPortIdentifier p = (CommPortIdentifier)(e.nextElement());
116116 if (p.getPortType() == CommPortIdentifier.PORT_SERIAL)
117117 v.addElement(p.getName());
00 /*
11 * $Id$
22 *
3 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
44 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55 *
66 * This code is free software; you can redistribute it and/or modify it
3030 import java.io.OutputStream;
3131 import java.io.IOException;
3232 import java.net.InetAddress;
33 import java.net.InetSocketAddress;
3334 import java.net.Socket;
3435 import java.util.Hashtable;
3536
183184 }
184185
185186 private static String getHostName(InetAddress addr) {
186 String s = (String) (addressCache.get(addr));
187 String s = addressCache.get(addr);
187188 if (s == null) {
188189 s = addr.getHostName();
189190 addressCache.put(addr, s);
222223 prev = jtSm.setAllowPropertiesAccess(true);
223224 }
224225 try {
225 ServerSocket serverSocket = new ServerSocket(port, backlog);
226 ServerSocket serverSocket = new ServerSocket();
227 // Ensure SO_REUSEADDR is false. (It is only needed if we're
228 // using a fixed port.) The default setting for SO_REUSEADDR
229 // is platform-specific, and Solaris has it on by default.
230 serverSocket.setReuseAddress(false);
231 serverSocket.bind(new InetSocketAddress(port), backlog);
226232 return serverSocket;
227233 } finally {
228234 if (jtSm != null) {
237243 private boolean closed;
238244 private Thread waitThread;
239245 private static Timer timer = new Timer();
240 private static Hashtable addressCache = new Hashtable();
246 private static Hashtable<InetAddress, String> addressCache = new Hashtable<>();
241247 }
2626 -->
2727
2828 <!-- %W% %E% -->
29 <html>
29 <html lang="en">
3030 <head>
3131 <META NAME="hIndent" CONTENT="1">
3232 <LINK REL="stylesheet" TYPE="text/css" HREF="../jthelp.css" TITLE="Style">
3333 <title>Starting a JT Harness Agent</title>
34 <style type="text/css">
35 <!--
36 .style1 {font-size: 9}
37 -->
38 </style>
3934 </head>
4035 <body>
4136 <a name="startAgent"><!-- index:starting a JT Harness agent --><!-- index:JT Harness agent; starting --></a>
5454 <mapID target="agent.window.csh" url="agent/window.html" />
5555 <mapID target="chapter" url="../images/chapter.gif" />
5656 <mapID target="closedbook" url="../images/closedbook.gif" />
57 <mapID target="glossary.ActiveAgent" url="/Users/alekseyof/javatest_os/jtharness/src/com/sun/javatest/agent/help/default/glossary/activeAgent.html" />
58 <mapID target="glossary.Agent" url="/Users/alekseyof/javatest_os/jtharness/src/com/sun/javatest/agent/help/default/glossary/agent.html" />
59 <mapID target="glossary.AgentMonitor" url="/Users/alekseyof/javatest_os/jtharness/src/com/sun/javatest/agent/help/default/glossary/agentMonitor.html" />
60 <mapID target="glossary.AgentPool" url="/Users/alekseyof/javatest_os/jtharness/src/com/sun/javatest/agent/help/default/glossary/agentPool.html" />
61 <mapID target="glossary.Parameters" url="/Users/alekseyof/javatest_os/jtharness/src/com/sun/javatest/agent/help/default/glossary/parameters.html" />
62 <mapID target="glossary.PassiveAgent" url="/Users/alekseyof/javatest_os/jtharness/src/com/sun/javatest/agent/help/default/glossary/passiveAgent.html" />
63 <mapID target="glossary.SerialAgent" url="/Users/alekseyof/javatest_os/jtharness/src/com/sun/javatest/agent/help/default/glossary/serialAgent.html" />
64 <mapID target="glossary.TestManager" url="/Users/alekseyof/javatest_os/jtharness/src/com/sun/javatest/agent/help/default/glossary/testManager.html" />
65 <mapID target="glossary.TestSuite" url="/Users/alekseyof/javatest_os/jtharness/src/com/sun/javatest/agent/help/default/glossary/testSuite.html" />
66 <mapID target="glossary.WorkDirectory" url="/Users/alekseyof/javatest_os/jtharness/src/com/sun/javatest/agent/help/default/glossary/workDirectory.html" />
57 <mapID target="glossary.ActiveAgent" url="glossary/activeAgent.html" />
58 <mapID target="glossary.Agent" url="glossary/agent.html" />
59 <mapID target="glossary.AgentMonitor" url="glossary/agentMonitor.html" />
60 <mapID target="glossary.AgentPool" url="glossary/agentPool.html" />
61 <mapID target="glossary.Parameters" url="glossary/parameters.html" />
62 <mapID target="glossary.PassiveAgent" url="glossary/passiveAgent.html" />
63 <mapID target="glossary.SerialAgent" url="glossary/serialAgent.html" />
64 <mapID target="glossary.TestManager" url="glossary/testManager.html" />
65 <mapID target="glossary.TestSuite" url="glossary/testSuite.html" />
66 <mapID target="glossary.WorkDirectory" url="glossary/workDirectory.html" />
6767 <mapID target="index.agentAdditionalOptionsAdditionalOptionsAutostart" url="agent/additionalOptions.html#additionalOptions.autostart" />
6868 <mapID target="index.agentAdditionalOptionsAdditionalOptionsBoth" url="agent/additionalOptions.html#additionalOptions.both" />
6969 <mapID target="index.agentAdditionalOptionsAdditionalOptionsConcurrencyValue" url="agent/additionalOptions.html#additionalOptions.concurrencyValue" />
00 /*
11 * $Id$
22 *
3 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
44 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55 *
66 * This code is free software; you can redistribute it and/or modify it
105105 */
106106 public Audit(TestFinderQueue tfq, ExcludeList excludeList, WorkDirectory workDir)
107107 {
108 Vector badChecksumTestsV = new Vector();
109 Vector badTestDescriptionsV = new Vector();
110 Vector badTestCaseTestsV = new Vector();
111 Vector badTestsV = new Vector();
108 Vector<TestResult> badChecksumTestsV = new Vector<>();
109 Vector<TestResult> badTestDescriptionsV = new Vector<>();
110 Vector<TestResult> badTestCaseTestsV = new Vector<>();
111 Vector<TestDescription> badTestsV = new Vector<>();
112112
113113 workDir.getTestResultTable().waitUntilReady();
114114
130130 if (!checkTestCases(tr, excludeList))
131131 badTestCaseTestsV.addElement(tr);
132132
133 Map trEnv = tr.getEnvironment();
134 for (Iterator i = trEnv.entrySet().iterator(); i.hasNext(); ) {
135 Map.Entry e = (Map.Entry) (i.next());
136 String key = (String) (e.getKey());
137 String value = (String) (e.getValue());
138 Vector allValuesForKey = (Vector)(envTable.get(key));
133 Map<String, String> trEnv = tr.getEnvironment();
134 for (Map.Entry<String, String> e : trEnv.entrySet() ) {
135 String key = e.getKey();
136 String value = e.getValue();
137 Vector<String> allValuesForKey = envTable.get(key);
139138 if (allValuesForKey == null) {
140 allValuesForKey = new Vector();
139 allValuesForKey = new Vector<>();
141140 envTable.put(key, allValuesForKey);
142141 }
143142 if (!allValuesForKey.contains(value))
166165 }
167166 }
168167
169 for (Enumeration e = envTable.keys(); e.hasMoreElements(); ) {
170 String key = (String)(e.nextElement());
171 Vector allValuesForKey = (Vector)(envTable.get(key));
168 for (Enumeration<String> e = envTable.keys(); e.hasMoreElements(); ) {
169 String key = e.nextElement();
170 Vector<String> allValuesForKey = envTable.get(key);
172171 envCounts[allValuesForKey.size() == 1 ? 0 : 1]++;
173172 }
174173
251250 * The keys to the table are strings; the values are vectors of strings
252251 * containing the various values for that key.
253252 */
254 public Hashtable getEnvTable() {
253 public Hashtable<String, Vector<String>> getEnvTable() {
255254 return envTable;
256255 }
257256
491490 out.println();
492491 out.print(i18n.getString("adt.envList.title"));
493492
494 SortedSet ss = new TreeSet();
495 for (Enumeration e = envTable.keys(); e.hasMoreElements(); ) {
496 String key = (String)(e.nextElement());
493 SortedSet<String> ss = new TreeSet<>();
494 for (Enumeration<String> e = envTable.keys(); e.hasMoreElements(); ) {
495 String key = (e.nextElement());
497496 ss.add(key);
498497 }
499498
500 for (Iterator iter = ss.iterator(); iter.hasNext(); ) {
501 String key = (String) (iter.next());
502 Vector allValuesForKey = (Vector)(envTable.get(key));
499 for (Iterator<String> iter = ss.iterator(); iter.hasNext(); ) {
500 String key = (iter.next());
501 Vector<String> allValuesForKey = envTable.get(key);
503502 if (allValuesForKey.size() == 1) {
504503 if (showAll)
505504 out.println(i18n.getString("adt.envKeyValue",
632631 //if (!a.rootRelativeFile.equals(b.rootRelativeFile))
633632 // return false;
634633
635 Iterator eA = a.getParameterKeys();
636 Iterator eB = b.getParameterKeys();
634 Iterator<String> eA = a.getParameterKeys();
635 Iterator<String> eB = b.getParameterKeys();
637636 while (eA.hasNext() && eB.hasNext()) {
638 String keyA = (String)eA.next();
639 String keyB = (String)eB.next();
637 String keyA = eA.next();
638 String keyB = eB.next();
640639 if (!keyA.equals(keyB)) {
641640 //System.err.println("mismatch " + a.getRootRelativePath() + " a:" + keyA + " b:" + keyB);
642641 return false;
691690 // Create an array of possible date formats to parse dates in .jtr files.
692691 // Most likely is Unix C time in English; the array will be reordered in use
693692 // by moving the recently used entries to the front of the array.
694 Vector v = new Vector();
693 Vector<DateFormat> v = new Vector<>();
695694
696695 // generic Java default
697696 // 10-Sep-99 3:25:11 PM
732731 private Date latestStart;
733732 private DateFormat[] dateFormats;
734733
735 private Hashtable envTable = new Hashtable();
734 private Hashtable<String, Vector<String>> envTable = new Hashtable<>();
736735 private PrintStream out;
737736 private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(Audit.class);
738737 }
5252
5353 //----------------------------------------------------------------------------
5454
55 public boolean parseCommand(String cmd, ListIterator argIter, CommandContext ctx)
55 public boolean parseCommand(String cmd, ListIterator<String> argIter, CommandContext ctx)
5656 throws Command.Fault
5757 {
5858 if (cmd.equalsIgnoreCase(AuditCommand.getName())) {
7878 return "audit";
7979 }
8080
81 AuditCommand(ListIterator argIter) throws Fault {
81 AuditCommand(ListIterator<String> argIter) throws Fault {
8282 super(getName());
8383
8484 while (argIter.hasNext()) {
121121 return "showAudit";
122122 }
123123
124 ShowAuditCommand(ListIterator argIter) {
124 ShowAuditCommand(ListIterator<String> argIter) {
125125 super(getName());
126126 }
127127
8888 return (wd == null ? null : new WorkDirectory[] { wd });
8989 }
9090
91 public void save(Map m) {
91 public void save(Map<String, String> m) {
9292 if (interviewParams == null)
9393 return;
9494
108108 }
109109
110110 @Override
111 protected void restore(Map m) {
112 String tsp = (String) (m.get("testSuite"));
113 String wdp = (String) (m.get("workDir"));
114 String cfp = (String) (m.get("config"));
111 protected void restore(Map<String, String> m) {
112 String tsp = m.get("testSuite");
113 String wdp = m.get("workDir");
114 String cfp = m.get("config");
115115
116116 if (tsp == null && wdp == null && cfp == null)
117117 return;
7272 return t;
7373 }
7474
75 public Tool restoreTool(Map m) {
75 public Tool restoreTool(Map<String, String> m) {
7676 AuditTool t = getTool();
7777 t.restore(m);
7878 return t;
00 /*
11 * $Id$
22 *
3 * Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
44 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55 *
66 * This code is free software; you can redistribute it and/or modify it
6060 }
6161 }
6262
63 private class ListModel extends AbstractListModel {
63 private class ListModel extends AbstractListModel<Object> {
6464 public Object getElementAt(int index) {
6565 return data[index];
6666 }
7878 }
7979
8080 private class Renderer extends DefaultListCellRenderer {
81 public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) {
81 public Component getListCellRendererComponent(JList<?> list, Object o, int index, boolean isSelected, boolean cellHasFocus) {
8282 String name;
8383 if (o instanceof TestResult) {
8484 TestResult tr = (TestResult) o;
9494 }
9595 }
9696
97 protected JList list;
97 protected JList<Object> list;
9898 private ListModel model;
9999 }
00 /*
11 * $Id$
22 *
3 * Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
44 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55 *
66 * This code is free software; you can redistribute it and/or modify it
191191 private void updateTestSuiteChoices() {
192192 // get the paths of currently loaded test suites
193193 // could move this to TestSuite, and use the dirMap cache
194 SortedSet s = new TreeSet();
194 SortedSet<String> s = new TreeSet<>();
195195 Desktop d = tool.getDesktop();
196196 Tool[] tools = d.getTools();
197197 if (tools != null) {
236236
237237 // get the paths of currently loaded work directories
238238 // could move this to WorkDirectory and use the dirMap cache
239 SortedSet s = new TreeSet();
239 SortedSet<String> s = new TreeSet<>();
240240 Desktop d = tool.getDesktop();
241241 Tool[] tools = d.getTools();
242242 if (tools != null) {
290290 }
291291
292292 private void updateConfigFileChoices() {
293 SortedSet s = new TreeSet();
293 SortedSet<String> s = new TreeSet<>();
294294 String wdp = (String) (wdField.getSelectedItem());
295295 try {
296296 WorkDirectory wd = WorkDirectory.open(new File(wdp));
305305 setItems(cfField, s);
306306 }
307307
308 private void setItems(JComboBox field, SortedSet s) {
308 private void setItems(JComboBox<String> field, SortedSet<String> s) {
309309 // first, remove unwanted entries from field
310310 for (int i = field.getItemCount() - 1; i >= 0; i-- ) {
311 String item = (String) (field.getItemAt(i));
311 String item = field.getItemAt(i);
312312 if (s.contains(item)) {
313313 // this item is required, so remove it from the
314314 // set to be added later
320320 }
321321
322322 // those items remaining in s need to be added to the field
323 for (Iterator iter = s.iterator(); iter.hasNext(); )
323 for (Iterator<String> iter = s.iterator(); iter.hasNext(); )
324324 field.addItem(iter.next());
325325 }
326326
328328 private ActionListener okListener;
329329 private JPanel body;
330330
331 private JComboBox tsField;
331 private JComboBox<String> tsField;
332332 private JButton tsBtn;
333333 private TestSuiteChooser testSuiteChooser;
334334
335 private JComboBox wdField;
335 private JComboBox<String> wdField;
336336 private JButton wdBtn;
337337 private WorkDirChooser workDirChooser;
338338
339 private JComboBox cfField;
339 private JComboBox<String> cfField;
340340 private JButton cfBtn;
341341 private JFileChooser configFileChooser;
342342
5959 return new HelpTree.Node(i18n, "cmgr.help." + name);
6060 }
6161
62 public boolean parseCommand(String cmd, ListIterator argIter, CommandContext ctx)
62 public boolean parseCommand(String cmd, ListIterator<String> argIter, CommandContext ctx)
6363 throws Command.Fault
6464 {
6565 if (isMatch(cmd, BatchCommand.getName())) {
00 /*
11 * $Id$
22 *
3 * Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
44 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55 *
66 * This code is free software; you can redistribute it and/or modify it
5252 return new HelpTree.Node(i18n, "cmgr.help.observer", opts);
5353 }
5454
55 ObserverCommand(ListIterator argIter) throws Fault {
55 ObserverCommand(ListIterator<String> argIter) throws Fault {
5656 super(getName());
5757
58 Vector v = null;
58 Vector<String> v = null;
5959
6060 while (argIter.hasNext()) {
6161 String arg = nextArg(argIter);
7272 break;
7373 else {
7474 if (v == null)
75 v = new Vector();
75 v = new Vector<>();
7676 v.add(arg);
7777 }
7878 }
9191
9292 public void run(CommandContext ctx) throws Fault {
9393 try {
94 Class oc = loadClass(className);
94 Class<?> oc = loadClass(className);
9595
9696 Harness.Observer o = null;
9797 if (classArgs == null || classArgs.length == 0) {
9898 o = tryConstructor(oc,
99 new Class[] { },
99 new Class<?>[] { },
100100 new Object[] { });
101101 }
102102 else if (classArgs.length == 1) {
103103 o = tryConstructor(oc,
104 new Class[] { String.class },
104 new Class<?>[] { String.class },
105105 new Object[] { classArgs[0] });
106106 }
107107
108108 if (o == null)
109109 o = tryConstructor(oc,
110 new Class[] { String[].class },
110 new Class<?>[] { String[].class },
111111 new Object[] { classArgs });
112112
113113 if (o == null)
129129 }
130130 }
131131
132 private Harness.Observer tryConstructor(Class obsClass, Class[] argTypes, Object[] args)
132 private Harness.Observer tryConstructor(Class<?> obsClass, Class<?>[] argTypes, Object[] args)
133133 throws IllegalAccessException, InstantiationException, InvocationTargetException
134134 {
135135 try {
136 Constructor c = obsClass.getConstructor(argTypes);
136 Constructor<?> c = obsClass.getConstructor(argTypes);
137137 return (Harness.Observer) (c.newInstance(args));
138138 }
139139 catch (NoSuchMethodException e) {
143143
144144 private void setClassPath(String s) throws Fault {
145145 char pathCh = File.pathSeparatorChar;
146 Vector v = new Vector();
146 Vector<URL> v = new Vector<>();
147147 int start = 0;
148148 for (int i = s.indexOf(pathCh); i != -1; i = s.indexOf(pathCh, start)) {
149149 addClassPathEntry(s.substring(start, i), v);
159159 classLoader = new URLClassLoader(path);
160160 }
161161
162 private Class loadClass(String name) throws ClassNotFoundException {
162 private Class<?> loadClass(String name) throws ClassNotFoundException {
163163 return (classLoader == null ? Class.forName(name) : classLoader.loadClass(name));
164164 }
165165
166 private void addClassPathEntry(String s, Vector v) throws Fault {
166 private void addClassPathEntry(String s, Vector<URL> v) throws Fault {
167167 try {
168168 if (s.length() > 0)
169169 v.add(new File(s).toURL());
2929 import java.text.DateFormat;
3030 import java.util.Date;
3131 import java.util.Iterator;
32 import java.util.ListIterator;
3233
3334 import com.sun.javatest.Harness;
3435 import com.sun.javatest.Parameters;
6768 super(getName());
6869 }
6970
70 RunTestsCommand(Iterator argIter) {
71 RunTestsCommand(ListIterator<String> argIter) {
7172 super(getName());
7273 }
7374
+0
-549
src/com/sun/javatest/cof/COF1_0.xsd less more
0 <?xml version="1.0" encoding="UTF-8" ?>
1
2 <xsd:schema
3 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
4 version="1.0.0">
5
6 <xsd:annotation>
7 <xsd:documentation>
8 Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
9 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10
11 This code is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License version 2 only, as
13 published by the Free Software Foundation. Oracle designates this
14 particular file as subject to the "Classpath" exception as provided
15 by Oracle in the LICENSE file that accompanied this code.
16
17 This code is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 version 2 for more details (a copy is included in the LICENSE file that
21 accompanied this code).
22
23 You should have received a copy of the GNU General Public License version
24 2 along with this work; if not, write to the Free Software Foundation,
25 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26
27 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28 or visit www.oracle.com if you need additional information or have any
29 questions.
30 </xsd:documentation>
31 </xsd:annotation>
32
33 <xsd:simpleType name="IDWithColon">
34 <xsd:annotation>
35 <xsd:documentation>
36 IDs are colon free strings followed by a colon followed by digits.
37 The digits are there to disambiguate entries that are repeated.
38 Repeats can occur for test results, for instance, when a test is
39 run more than once.
40 </xsd:documentation>
41 </xsd:annotation>
42 <xsd:restriction base="xsd:string">
43 <xsd:pattern value="[\w\.\[\]\(\)\{\},_-]+:[0-9]+"/>
44 </xsd:restriction>
45 </xsd:simpleType>
46
47 <xsd:simpleType name="Machine">
48 <xsd:annotation>
49 <xsd:documentation>
50 Machines are identified by name and date. The name must be qualified.
51 Only lower case is accepted in the COF.
52 Host name space specifiers are defined in http://www.ietf.org/rfc/rfc2141.txt . This
53 schema checks for the existence of two or more domains in the name space specifier.
54 </xsd:documentation>
55 </xsd:annotation>
56 <xsd:restriction base="xsd:string">
57 <xsd:pattern value="([a-z0-9][a-z0-9\-]*[a-z0-9]\.){2,}([a-z][a-z0-9\-]*[a-z0-9])"/>
58 </xsd:restriction>
59 </xsd:simpleType>
60
61 <xsd:simpleType name="KeyWord">
62 <xsd:annotation>
63 <xsd:documentation>
64 Keywords are very rough descriptions of test content.
65 </xsd:documentation>
66 </xsd:annotation>
67 <xsd:restriction base="xsd:string">
68 <xsd:enumeration value="DTF"/>
69 <xsd:enumeration value="JPI"/>
70 <xsd:enumeration value="JAWS"/>
71 <xsd:enumeration value="JSS"/>
72 <xsd:enumeration value="demo"/>
73 <xsd:enumeration value="manual"/>
74 </xsd:restriction>
75 </xsd:simpleType>
76
77 <xsd:complexType name="KeyWords" abstract="false">
78 <xsd:sequence>
79 <xsd:element name="keyword" type="KeyWord" minOccurs="1" maxOccurs="unbounded"/>
80 </xsd:sequence>
81 </xsd:complexType>
82
83 <xsd:simpleType name="Bits">
84 <xsd:restriction base="xsd:int">
85 <xsd:enumeration value="32"/>
86 <xsd:enumeration value="64"/>
87 </xsd:restriction>
88 </xsd:simpleType>
89
90 <xsd:simpleType name="DisplayDepth">
91 <xsd:annotation>
92 <xsd:documentation>
93 Display depth is recorded as part of a software configuration.
94 </xsd:documentation>
95 </xsd:annotation>
96 <xsd:restriction base="xsd:int">
97 <xsd:enumeration value="8"/>
98 <xsd:enumeration value="12"/>
99 <xsd:enumeration value="15"/>
100 <xsd:enumeration value="16"/>
101 <xsd:enumeration value="24"/>
102 <xsd:enumeration value="32"/>
103 </xsd:restriction>
104 </xsd:simpleType>
105
106 <xsd:complexType name="OS">
107 <xsd:annotation>
108 <xsd:documentation>
109 Operating system.
110 </xsd:documentation>
111 <xsd:documentation>
112 Name should be one of windows, redhat_linux, turbo_linux,
113 suse_linux, caldera_linux, mandrake_linux, solaris, palmos,
114 psos, symbianos, or vxworks.
115 These names are derived from BugTraq names.
116 </xsd:documentation>
117 <xsd:documentation>
118 Versions are derived from BugTraq names. Allowable version
119 strings for Windows are 2000, 95, 98, ce, me, nt_4.0,
120 pocketpc2000, pocketpc2002, and xp.
121 Allowable version strings for Solaris are 2.6, 2.7, 8, and 9.
122 Linux versioning is sane in comparison with that of Solaris
123 and Windows. Redhat versions are 5.1, 5.2, 6.0, 6.1, 6.2,
124 7.0, 7.1, and 7.2.
125 </xsd:documentation>
126 </xsd:annotation>
127 <xsd:sequence>
128 <xsd:element name="name">
129 <xsd:simpleType>
130 <xsd:restriction base="xsd:string">
131 <xsd:enumeration value="caldera_linux"/>
132 <xsd:enumeration value="mandrake_linux"/>
133 <xsd:enumeration value="palmos"/>
134 <xsd:enumeration value="psos"/>
135 <xsd:enumeration value="redhat_linux"/>
136 <xsd:enumeration value="solaris"/>
137 <xsd:enumeration value="suse_linux"/>
138 <xsd:enumeration value="symbianos"/>
139 <xsd:enumeration value="turbo_linux"/>
140 <xsd:enumeration value="windows"/>
141 <xsd:enumeration value="vxworks"/>
142 </xsd:restriction>
143 </xsd:simpleType>
144 </xsd:element>
145 <xsd:element name="version" type="xsd:string"/>
146 </xsd:sequence>
147 </xsd:complexType>
148
149 <xsd:complexType name="TestAttribute">
150 <xsd:annotation>
151 <xsd:documentation>
152 Test attributes encode test-specific settings that we might want recorded.
153 The motivation for inclusion in the COF is the desire to record locale as
154 set by a test, time zone as set by a test, and the use of the Java command
155 line switches like -client, -server, -d32, or -d64. It is expected that
156 the absence of any use of -client or -server will be reflected by an absence
157 of a TestAttribute element whose name is "client" or "server", respectively.
158 Tests that use both flags should create an element for each setting.
159 Similar considerations govern use of "d32" and "d64".
160 </xsd:documentation>
161 <xsd:documentation>
162 Locale values should be in the usual Java format of strings separated by
163 underscores. For instance, ja, ja_JP, and ja_JP_custom are all valid.
164 Locale values should be in the usual Java format of strings separated
165 by underscores. For instance, ja, ja_JP, and ja_JP_custom are all valid.
166 The first string is a valid ISO Language Code and the second is a valid
167 ISO Country Code. The list of language and country codes are at
168 http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt and
169 http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html ,
170 respectively. The third string in the concatenation is for variants
171 and can contain underscores.
172 </xsd:documentation>
173 <xsd:documentation>
174 Time zone values document the time zone used for a particular test or
175 test case. Time zones should be in the format used by Java. For instance, the
176 string for Pacific Standard Time is "America/Los Angeles". The list of
177 supported time zones is obtained by invoking java.util.TimeZone.getAvailableIDs.
178 Do not use a deprecated three-letter time zone ID.
179 </xsd:documentation>
180 <xsd:documentation>
181 In general, a Java command line flag argument that it is agreed will get tracked as
182 an attribute, say -foo,will get tracked by a test attribute <name>foo</name>
183 without a corresponding value element. A Java command line argument pair
184 "-foo bar" will get tracked by a test attribute <name>foo</name><value>bar</value>.
185 </xsd:documentation>
186 </xsd:annotation>
187 <xsd:sequence>
188 <xsd:element name="name" type="xsd:string" minOccurs="1" maxOccurs="unbounded"/>
189 <xsd:element name="value" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
190 </xsd:sequence>
191 </xsd:complexType>
192
193 <xsd:complexType name="TestAttributes">
194 <xsd:sequence>
195 <xsd:element name="attribute" type="TestAttribute" minOccurs="1" maxOccurs="unbounded"/>
196 </xsd:sequence>
197 </xsd:complexType>
198
199 <xsd:complexType name="Status">
200 <xsd:annotation>
201 <xsd:documentation>
202 Status can be one of pass, fail, vm_fail, error, did_not_run, or ambiguous.
203 Fail is for test failures that the test or test case anticipates. A vm_fail
204 status indicates that a VM failure caused the failure. An example of this is
205 a HotSpot abort. An error status can be used to cover all failures not
206 explained as a test or vm failure. Examples are seg faults in the VM or
207 a harness failure.
208 </xsd:documentation>
209 <xsd:documentation>
210 Status did_not_run is an odd one. It's there because test execution may
211 conditional on the successful completion of a setup step, itself a test.
212 </xsd:documentation>
213 <xsd:documentation>
214 The setting ambiguous is the least self-explanatory of the status codes.
215 I18n tests are run in locales that they do not support. These tests fail,
216 but there failure has no meaning that should get reported back to product
217 development.
218 </xsd:documentation>
219 <xsd:documentation>
220 Expected elements contain text that refers to an expected value. This
221 can be anything. A header, value, body, ..... If the tag log appears,
222 it may be understood that a URL of a log file will appear as the PCDATA
223 for this tag. If present, that URL uses either http or file protocol. If
224 http protocol, the server name will be fully qualified. If file protocol,
225 the full path beginning with /net will be expected. Microsoft file mapping or
226 Unix automounts should not be used.
227 </xsd:documentation>
228 <xsd:documentation>
229 Actual elements contain text that refers to an actual value. This
230 can be anything. A header, value, body, ..... If the tag log appears,
231 it may be understood that a URL of a log file will appear as the PCDATA
232 for this tag. If present, that URL uses either http or file protocol. If
233 http protocol, the server name will be fully qualified. If file protocol,
234 the full path beginning with /net will be expected. Microsoft file mapping or
235 Unix automounts should not be used.
236 </xsd:documentation>
237 </xsd:annotation>
238 <xsd:sequence minOccurs="0" maxOccurs="1">
239 <xsd:element name="expected" type="xsd:string" minOccurs="0" maxOccurs="1"/>
240 <xsd:element name="actual" type="xsd:string" minOccurs="0" maxOccurs="1"/>
241 </xsd:sequence>
242 <xsd:attribute name="value" use="required">
243 <xsd:simpleType>
244 <xsd:restriction base="xsd:string">
245 <xsd:enumeration value="pass"/>
246 <xsd:enumeration value="fail"/>
247 <xsd:enumeration value="ambiguous"/>
248 <xsd:enumeration value="error"/>
249 <xsd:enumeration value="vm_fail"/>
250 <xsd:enumeration value="did_not_run"/>
251 </xsd:restriction>
252 </xsd:simpleType>
253 </xsd:attribute>
254 </xsd:complexType>
255
256 <xsd:complexType name="TestCase" abstract="false">
257 <xsd:annotation>
258 <xsd:documentation>
259 Testcase elements define the test cases of a test that are
260 exercised in the course of a run. The id
261 for a test takes the form test_case_name:unique_id. The information
262 will be gathered using the test_coverage.xml file associated with the test case,
263 if present. The unique_id is unique within the xml file. The unique_id portion
264 is present because test run might contain repetitions.
265 Testcases are often tests run with different command line arguments or
266 environments. Often, the different test cases in a test are in reality
267 different methods inside that test's source code.
268 </xsd:documentation>
269 <xsd:documentation>
270 The starttime and endtime fields use an XML format. Times are in UTC (like
271 those that java.util.Date works with). An acceptable dateTime
272 format is yyyy-mm-ddThh:mm:ss.ff. DateTime format is specified in
273 section 5.4 of ISO 8601.
274 </xsd:documentation>
275 </xsd:annotation>
276 <xsd:sequence>
277 <xsd:element name="name" type="xsd:string"/>
278 <xsd:element name="status" type="Status" minOccurs="0" maxOccurs="1"/>
279 <xsd:element name="starttime" type="xsd:dateTime" minOccurs="0" maxOccurs="1"/>
280 <xsd:element name="endtime" type="xsd:dateTime" minOccurs="0" maxOccurs="1"/>
281 <xsd:element name="attributes" type="TestAttributes" minOccurs="0" maxOccurs="1"/>
282 <xsd:element name="description" type="xsd:string" minOccurs="0" maxOccurs="1"/>
283 </xsd:sequence>
284 <xsd:attribute name="id" type="IDWithColon" use="required"/>
285 </xsd:complexType>
286
287 <xsd:complexType name="TestCases" abstract="false">
288 <xsd:sequence>
289 <xsd:element name="testcase" type="TestCase" minOccurs="1" maxOccurs="unbounded"/>
290 </xsd:sequence>
291 </xsd:complexType>
292
293 <xsd:complexType name="Test" abstract="false">
294 <xsd:annotation>
295 <xsd:documentation>
296 Test elements define all the tests exercised by the test suite. The id
297 for a test takes the form test_name:unique_id. The information
298 will be gathered using the test_coverage.xml file associated with the test,
299 if present. The unique_id is unique within the xml file. The unique_id portion
300 is present because test run might contain repetitions.
301 </xsd:documentation>
302 <xsd:documentation>
303 Status is required if there are zero test cases.
304 Starttime is required if there are zero test cases.
305 Endtime is required if there are zero test cases.
306 The starttime and endtime fields use an XML format. Times are in UTC (like
307 those that java.util.Date works with). An acceptable dateTime
308 format is yyyy-mm-ddThh:mm:ss.ff. DateTime format is specified in
309 section 5.4 of ISO 8601.
310 </xsd:documentation>
311 </xsd:annotation>
312 <xsd:sequence>
313 <xsd:element name="name" type="xsd:string"/>
314 <xsd:element name="appuse" type="IDWithColon" minOccurs="0" maxOccurs="unbounded"/>
315 <xsd:element name="status" type="Status" minOccurs="0" maxOccurs="1"/>
316 <xsd:element name="testcases" type="TestCases" minOccurs="0" maxOccurs="1"/>
317 <xsd:element name="starttime" type="xsd:dateTime" minOccurs="0" maxOccurs="1"/>
318 <xsd:element name="endtime" type="xsd:dateTime" minOccurs="0" maxOccurs="1"/>
319 <xsd:element name="keywords" type="KeyWords" minOccurs="0" maxOccurs="1"/>
320 <xsd:element name="attributes" type="TestAttributes" minOccurs="0" maxOccurs="1"/>
321 <xsd:element name="description" type="xsd:string" minOccurs="0" maxOccurs="1"/>
322 </xsd:sequence>
323 <xsd:attribute name="id" type="IDWithColon" use="required"/>
324 </xsd:complexType>
325
326 <xsd:complexType name="Tests" abstract="false">
327 <xsd:sequence>
328 <xsd:element name="test" type="Test" minOccurs="1" maxOccurs="unbounded"/>
329 </xsd:sequence>
330 </xsd:complexType>
331
332 <xsd:complexType name="TestSuite" abstract="false">
333 <xsd:annotation>
334 <xsd:documentation>
335 Test suite elements contain the test suite name. The name must be the same
336 as one defined in the test_coverage.xml file, if that file is defined.
337 The id element for a suite takes the form test_suite:unique_id. The information
338 will be gathered using the test_coverage.xml file associated with the test
339 suite, if present. The unique_id is unique within the xml file. The
340 unique_id portion is present because test run might contain repetitions.
341 </xsd:documentation>
342 <xsd:documentation>
343 The version field uses an XML format. Times are in UTC (like
344 those that java.util.Date works with). An acceptable dateTime
345 format is yyyy-mm-ddThh:mm:ss.ff. DateTime format is specified in
346 section 5.4 of ISO 8601.
347 </xsd:documentation>
348 <xsd:documentation>
349 The starttime and endtime fields use an XML format. Times are in UTC (like
350 those that java.util.Date works with). An acceptable dateTime
351 format is yyyy-mm-ddThh:mm:ss.ff. DateTime format is specified in
352 section 5.4 of ISO 8601.
353 </xsd:documentation>
354 </xsd:annotation>
355 <xsd:sequence>
356 <xsd:element name="name" type="xsd:string"/>
357 <xsd:element name="version" type="xsd:dateTime" minOccurs="0" maxOccurs="1"/>
358 <xsd:element name="starttime" type="xsd:dateTime" minOccurs="0" maxOccurs="1"/>
359 <xsd:element name="endtime" type="xsd:dateTime" minOccurs="0" maxOccurs="1"/>
360 <xsd:element name="tests" type="Tests" minOccurs="1" maxOccurs="unbounded"/>
361 </xsd:sequence>
362 <xsd:attribute name="id" type="IDWithColon" use="required"/>
363 </xsd:complexType>
364
365 <xsd:complexType name="TestSuites" abstract="false">
366 <xsd:sequence>
367 <xsd:element name="testsuite" type="TestSuite" minOccurs="1" maxOccurs="unbounded"/>
368 </xsd:sequence>
369 </xsd:complexType>
370
371 <xsd:complexType name="Environment">
372 <xsd:annotation>
373 <xsd:documentation>
374 Software configurations are a way to document the software environment used
375 for testing.
376 </xsd:documentation>
377 <xsd:documentation>
378 Machines are identified by name, not Internet address. The name must be
379 fully qualified. Hardware configuration is obtained with a combination of
380 name and date.
381 </xsd:documentation>
382 <xsd:documentation>
383 Locale documents the default locale for the test run. Locale values should be
384 in the usual Java format of strings separated by underscores. For instance, ja,
385 ja_JP, and ja_JP_custom are all valid. The first string is a valid ISO
386 Language Code and the second is a valid ISO Country Code. The list of
387 language and country codes are at
388 http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt and
389 http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html ,
390 respectively. The third string in the concatenation is for variants
391 and can contain underscores.
392 </xsd:documentation>
393 <xsd:documentation>
394 System-locale is that used by the OS to configure OS applications. On Windows
395 systems, system-locale is attached to the OS and cannot be changed.
396 User-locale is that used by the Java API. It is the setting reported out by
397 java.util.Locale.getDefault().
398 </xsd:documentation>
399 <xsd:documentation>
400 Time zone elements document the default time zone for the test run.
401 Time zones should be in the format used by Java. For instance, the
402 string for Pacific Standard Time is "America/Los Angeles". The list of
403 supported time zones is obtained by invoking java.util.TimeZone.getAvailableIDs.
404 Do not use a deprecated three-letter time zone ID.
405 </xsd:documentation>
406 <xsd:documentation>
407 JDK elements use the property java.runtime.version.
408 </xsd:documentation>
409 </xsd:annotation>
410 <xsd:sequence>
411 <xsd:element name="machine" type="Machine"/>
412 <xsd:element name="os" type="OS"/>
413 <xsd:element name="jdk" type="xsd:string" minOccurs="0" maxOccurs="1"/>
414 <xsd:element name="system-locale" type="xsd:string" minOccurs="0" maxOccurs="1"/>
415 <xsd:element name="user-locale" type="xsd:string" minOccurs="0" maxOccurs="1"/>
416 <xsd:element name="timezone" type="xsd:string" minOccurs="0" maxOccurs="1"/>
417 <xsd:element name="bits" type="Bits" minOccurs="0" maxOccurs="1"/>
418 <xsd:element name="displaydepth" type="DisplayDepth" minOccurs="0" maxOccurs="1"/>
419 <xsd:element name="description" type="xsd:string" minOccurs="0" maxOccurs="1"/>
420 <xsd:element name="sw" type="SWEntity" minOccurs="0" maxOccurs="unbounded"/>
421 </xsd:sequence>
422 <xsd:attribute name="id" type="IDWithColon" use="required"/>
423 </xsd:complexType>
424
425 <xsd:complexType name="Environments">
426 <xsd:sequence>
427 <xsd:element name="environment" type="Environment" minOccurs="1" maxOccurs="unbounded"/>
428 </xsd:sequence>
429 </xsd:complexType>
430
431 <xsd:complexType name="SWEntity">
432 <xsd:annotation>
433 <xsd:documentation>
434 Software is tracked in the hardware/software database that backs up
435 the COF XML. The elements in the SW type map to fields in the software
436 table of that database.
437 Type is enumerated. See below.
438 Name is a product name with no version string. For example, "Tomcat".
439 Version is a product version. For instance, "8i".
440 </xsd:documentation>
441 </xsd:annotation>
442 <xsd:sequence>
443 <xsd:element name="type">
444 <xsd:simpleType>
445 <xsd:restriction base="xsd:string">
446 <xsd:enumeration value="appserver"/>
447 <xsd:enumeration value="browser"/>
448 <xsd:enumeration value="database"/>
449 <xsd:enumeration value="editor"/>
450 <xsd:enumeration value="java"/>
451 <xsd:enumeration value="webserver"/>
452 </xsd:restriction>
453 </xsd:simpleType>
454 </xsd:element>
455 <xsd:element name="name" type="xsd:string"/>
456 <xsd:element name="version" type="xsd:string" minOccurs="0" maxOccurs="1"/>
457 <xsd:element name="description" type="xsd:string" minOccurs="0" maxOccurs="1"/>
458 </xsd:sequence>
459 <xsd:attribute name="id" type="IDWithColon" use="required"/>
460 </xsd:complexType>
461
462 <xsd:complexType name="SWEntities" abstract="false">
463 <xsd:sequence>
464 <xsd:element name="swentity" type="SWEntity" minOccurs="1" maxOccurs="unbounded"/>
465 </xsd:sequence>
466 </xsd:complexType>
467
468 <xsd:complexType name="Application" abstract="false">
469 <xsd:attribute name="id" type="IDWithColon" use="required"/>
470 <xsd:attribute name="environmentid" type="IDWithColon" use="required"/>
471 <xsd:attribute name="swentityid" type="IDWithColon" use="required"/>
472 </xsd:complexType>
473
474 <xsd:complexType name="Applications" abstract="false">
475 <xsd:sequence>
476 <xsd:element name="application" type="Application" minOccurs="1" maxOccurs="unbounded"/>
477 </xsd:sequence>
478 </xsd:complexType>
479
480 <xsd:complexType name="Report" abstract="false">
481 <xsd:annotation>
482 <xsd:documentation>
483 The version is the common XML output version. The first version will be 1.0.
484 The date fields use an XML format. Times are in UTC (like
485 those that java.util.Date works with). An acceptable dateTime
486 format is yyyy-mm-ddThh:mm:ss.ff. DateTime format is specified in
487 section 5.4 of ISO 8601.
488 </xsd:documentation>
489 </xsd:annotation>
490 <xsd:sequence>
491 <xsd:element name="date" type="xsd:dateTime"/>
492 <xsd:element name="version" type="xsd:string"/>
493 <xsd:element name="environments" type="Environments"/>
494 <xsd:element name="swentities" type="SWEntities" minOccurs="0" maxOccurs="1"/>
495 <xsd:element name="applications" type="Applications" minOccurs="0" maxOccurs="unbounded"/>
496 <xsd:element name="operator" type="xsd:string" minOccurs="0" maxOccurs="1"/>
497 <xsd:element name="harness" type="xsd:string" minOccurs="0" maxOccurs="1"/>
498 <xsd:element name="testsuites" type="TestSuites" minOccurs="1" maxOccurs="unbounded"/>
499 <xsd:any minOccurs="0" maxOccurs="unbounded" processContents="skip"/>
500 </xsd:sequence>
501 </xsd:complexType>
502
503 <xsd:element name="report" type="Report">
504 <xsd:key name="EnvironmentKey">
505 <xsd:selector xpath="report/environments/environment"/>
506 <xsd:field xpath="@id"/>
507 </xsd:key>
508 <xsd:keyref name="RefToEnvironment" refer="EnvironmentKey">
509 <xsd:selector xpath="report/applications/application"/>
510 <xsd:field xpath="@environmentid"/>
511 </xsd:keyref>
512
513 <xsd:key name="SWEntityKey">
514 <xsd:selector xpath="report/swentities/swentity"/>
515 <xsd:field xpath="@id"/>
516 </xsd:key>
517 <xsd:keyref name="RefToSWEntity" refer="SWEntityKey">
518 <xsd:selector xpath="report/applications/application"/>
519 <xsd:field xpath="@swentityid"/>
520 </xsd:keyref>
521
522 <xsd:key name="ApplicationKey">
523 <xsd:selector xpath="report/applications/application"/>
524 <xsd:field xpath="@id"/>
525 </xsd:key>
526 <xsd:keyref name="RefToApplication" refer="ApplicationKey">
527 <xsd:selector xpath="report/testsuites/testsuite/tests/test/appuse"/>
528 <xsd:field xpath="@id"/>
529 </xsd:keyref>
530
531 <xsd:unique name="UniqueTestSuiteID">
532 <xsd:selector xpath="report/testsuites/testsuite"/>
533 <xsd:field xpath="@id"/>
534 </xsd:unique>
535
536 <xsd:unique name="UniqueTestID">
537 <xsd:selector xpath="report/testsuites/testsuite/tests/test"/>
538 <xsd:field xpath="@id"/>
539 </xsd:unique>
540
541 <xsd:unique name="UniqueTestCaseID">
542 <xsd:selector xpath="report/testsuites/testsuite/tests/test/testcases/testcase"/>
543 <xsd:field xpath="@id"/>
544 </xsd:unique>
545
546 </xsd:element>
547
548 </xsd:schema>
+0
-780
src/com/sun/javatest/cof/COF2_0_2.xsd less more
0 <?xml version="1.0" encoding="UTF-8"?>
1
2 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
3 xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
4 elementFormDefault="unqualified" attributeFormDefault="unqualified"
5 jxb:version="2.0" version="2.0.2">
6
7 <xsd:annotation>
8 <xsd:documentation>
9 Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
10 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
11
12 This code is free software; you can redistribute it and/or modify it
13 under the terms of the GNU General Public License version 2 only, as
14 published by the Free Software Foundation. Oracle designates this
15 particular file as subject to the "Classpath" exception as provided
16 by Oracle in the LICENSE file that accompanied this code.
17
18 This code is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 version 2 for more details (a copy is included in the LICENSE file that
22 accompanied this code).
23
24 You should have received a copy of the GNU General Public License version
25 2 along with this work; if not, write to the Free Software Foundation,
26 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27
28 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
29 or visit www.oracle.com if you need additional information or have any
30 questions.
31 </xsd:documentation>
32 </xsd:annotation>
33
34 <xsd:annotation>
35 <xsd:documentation>
36 Customize Date binding
37 </xsd:documentation>
38 <xsd:appinfo>
39 <jxb:globalBindings>
40 <jxb:javaType name="java.util.Date" xmlType="xsd:dateTime" />
41 </jxb:globalBindings>
42 </xsd:appinfo>
43 </xsd:annotation>
44 <xsd:annotation>
45 <xsd:appinfo>
46 <jxb:schemaBindings>
47 <jxb:nameXmlTransform>
48 <jxb:typeName prefix="COF"/>
49 </jxb:nameXmlTransform>
50 </jxb:schemaBindings>
51 </xsd:appinfo>
52 </xsd:annotation>
53 <xsd:simpleType name="IDWithColon">
54 <xsd:annotation>
55 <xsd:documentation>
56 IDs are colon free strings followed by a colon followed by
57 digits. The digits are there to disambiguate entries that are
58 repeated. Repeats can occur for test results, for instance, when
59 a test is run more than once.
60 </xsd:documentation>
61 </xsd:annotation>
62 <xsd:restriction base="xsd:string">
63 <xsd:pattern value="[\w\.\[\]\(\)\{\},_\-]+:[0-9]+" />
64 </xsd:restriction>
65 </xsd:simpleType>
66
67 <xsd:simpleType name="Machine">
68 <xsd:annotation>
69 <xsd:documentation>
70 Machines are identified by name and date. The name must be
71 qualified. Only lower case is accepted in the COF. Host name
72 space specifiers are defined in
73 http://www.ietf.org/rfc/rfc2141.txt . This schema checks for the
74 existence of two or more domains in the name space specifier.
75 </xsd:documentation>
76 </xsd:annotation>
77 <xsd:restriction base="xsd:string">
78 <xsd:pattern
79 value="([a-z0-9][a-z0-9\-]*[a-z0-9]\.){2,}([a-z][a-z0-9\-]*[a-z0-9])" />
80 </xsd:restriction>
81 </xsd:simpleType>
82
83 <xsd:simpleType name="Bits">
84 <xsd:restriction base="xsd:int">
85 <xsd:enumeration value="32" />
86 <xsd:enumeration value="64" />
87 </xsd:restriction>
88 </xsd:simpleType>
89
90 <xsd:simpleType name="DisplayDepth">
91 <xsd:annotation>
92 <xsd:documentation>
93 Display depth is recorded as part of a software configuration.
94 </xsd:documentation>
95 </xsd:annotation>
96 <xsd:restriction base="xsd:int">
97 <xsd:enumeration value="8" />
98 <xsd:enumeration value="12" />
99 <xsd:enumeration value="15" />
100 <xsd:enumeration value="16" />
101 <xsd:enumeration value="24" />
102 <xsd:enumeration value="32" />
103 </xsd:restriction>
104 </xsd:simpleType>
105
106 <xsd:complexType name="OS">
107 <xsd:annotation>
108 <xsd:documentation>Operating system.</xsd:documentation>
109 <xsd:documentation>
110 OS name elements use the property os.name. OS version elements
111 use the property os.version. OS arch elements use the property
112 os.arch.
113 </xsd:documentation>
114 </xsd:annotation>
115 <xsd:sequence>
116 <xsd:element name="name" type="xsd:string" form="qualified" />
117 <xsd:element name="version" type="xsd:string" form="qualified" />
118 <xsd:element name="arch" type="xsd:string" form="qualified" />
119 </xsd:sequence>
120 </xsd:complexType>
121
122 <xsd:complexType name="SuiteAttribute">
123 <xsd:annotation>
124 <xsd:documentation>
125 The suite attribute work_group can be assigned the name of a
126 business component assigned the job of running this test suite.
127 The value assigned to this overrides that assigned to the test
128 run annotation named work_group.
129 </xsd:documentation>
130 <xsd:documentation>
131 To make databases of test results more uniform, all other suite
132 attribute name/value pairs will be discarded by the QARE system.
133 </xsd:documentation>
134 </xsd:annotation>
135 <xsd:sequence>
136 <xsd:element name="name" type="xsd:string" minOccurs="1"
137 maxOccurs="unbounded" form="qualified" />
138 <xsd:element name="value" type="xsd:string" minOccurs="0"
139 maxOccurs="unbounded" form="qualified" />
140 </xsd:sequence>
141 </xsd:complexType>
142
143 <xsd:complexType name="SuiteAttributes">
144 <xsd:sequence>
145 <xsd:element name="attribute" type="cof:SuiteAttribute"
146 minOccurs="1" maxOccurs="unbounded" form="qualified" />
147 </xsd:sequence>
148 </xsd:complexType>
149
150 <xsd:complexType name="TestAttribute">
151 <xsd:annotation>
152 <xsd:documentation>
153 Test attributes encode test-specific settings that we might want
154 recorded. The motivation for inclusion in the COF is the desire
155 to record locale as set by a test, time zone as set by a test,
156 and the use of the Java command line switches like -client,
157 -server, -d32, or -d64. It is expected that the absence of any
158 use of -client or -server will be reflected by an absence of a
159 TestAttribute element whose name is "client" or "server",
160 respectively.
161 </xsd:documentation>
162 <xsd:documentation>
163 Locale values should be in the usual Java format of strings
164 separated by underscores. For instance, ja, ja_JP, and
165 ja_JP_custom are all valid. Locale values should be in the usual
166 Java format of strings separated by underscores. For instance,
167 ja, ja_JP, and ja_JP_custom are all valid. The first string is a
168 valid ISO Language Code and the second is a valid ISO Country
169 Code. The list of language and country codes are at
170 http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt and
171 http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html ,
172 respectively. The third string in the concatenation is for
173 variants and can contain underscores.
174 </xsd:documentation>
175 <xsd:documentation>
176 Time zone values document the time zone used for a particular
177 test or test case. Time zones should be in the format used by
178 Java. For instance, the string for Pacific Standard Time is
179 "America/Los Angeles". The list of supported time zones is
180 obtained by invoking java.util.TimeZone.getAvailableIDs. Do not
181 use a deprecated three-letter time zone ID.
182 </xsd:documentation>
183 <xsd:documentation>
184 In general, a Java command line flag argument that it is agreed
185 will get tracked as an attribute, say -foo,will get tracked by a
186 test attribute
187 <name>foo</name>
188 without a corresponding value element. A Java command line
189 argument pair "-foo bar" will get tracked by a test attribute
190 <name>foo</name>
191 <value>bar</value>
192 .
193 </xsd:documentation>
194 </xsd:annotation>
195 <xsd:sequence>
196 <xsd:element name="name" type="xsd:string" minOccurs="1"
197 maxOccurs="unbounded" form="qualified" />
198 <xsd:element name="value" type="xsd:string" minOccurs="0"
199 maxOccurs="unbounded" form="qualified" />
200 </xsd:sequence>
201 </xsd:complexType>
202
203 <xsd:complexType name="TestAttributes">
204 <xsd:sequence>
205 <xsd:element name="attribute" type="cof:TestAttribute"
206 minOccurs="1" maxOccurs="unbounded" form="qualified" />
207 </xsd:sequence>
208 </xsd:complexType>
209
210 <xsd:complexType name="Status">
211 <xsd:annotation>
212 <xsd:documentation>
213 Status can be one of pass, fail, vm_fail, error, did_not_run, or
214 ambiguous. Fail is for test failures that the test or test case
215 anticipates. A vm_fail status indicates that a VM failure caused
216 the failure. An example of this is a HotSpot abort. An error
217 status can be used to cover all failures not explained as a test
218 or vm failure. Examples are seg faults in the VM or a harness
219 failure.
220 </xsd:documentation>
221 <xsd:documentation>
222 Status did_not_run is an odd one. It's there because test
223 execution may conditional on the successful completion of a
224 setup step, itself a test.
225 </xsd:documentation>
226 <xsd:documentation>
227 The setting ambiguous is the least self-explanatory of the
228 status codes. I18n tests are run in locales that they do not
229 support. These tests fail, but there failure has no meaning that
230 should get reported back to product development.
231 </xsd:documentation>
232 <xsd:documentation>
233 Expected elements contain text that refers to an expected value.
234 This can be anything. A header, value, body, ..... If the tag
235 log appears, it may be understood that a URL of a log file will
236 appear as the PCDATA for this tag. If present, that URL uses
237 either http or file protocol. If http protocol, the server name
238 will be fully qualified. If file protocol, the full path
239 beginning with /net will be expected. Microsoft file mapping or
240 Unix automounts should not be used.
241 </xsd:documentation>
242 <xsd:documentation>
243 Actual elements contain text that refers to an actual value.
244 This can be anything. A header, value, body, ..... If the tag
245 log appears, it may be understood that a URL of a log file will
246 appear as the PCDATA for this tag. If present, that URL uses
247 either http or file protocol. If http protocol, the server name
248 will be fully qualified. If file protocol, the full path
249 beginning with /net will be expected. Microsoft file mapping or
250 Unix automounts should not be used.
251 </xsd:documentation>
252 </xsd:annotation>
253 <xsd:sequence minOccurs="0" maxOccurs="1">
254 <xsd:element name="expected" type="xsd:string" minOccurs="0"
255 maxOccurs="1" form="qualified" />
256 <xsd:element name="actual" type="xsd:string" minOccurs="0"
257 maxOccurs="1" form="qualified" />
258 </xsd:sequence>
259 <xsd:attribute name="value" use="required">
260 <xsd:simpleType>
261 <xsd:restriction base="xsd:string">
262 <xsd:enumeration value="pass" />
263 <xsd:enumeration value="fail" />
264 <xsd:enumeration value="ambiguous" />
265 <xsd:enumeration value="error" />
266 <xsd:enumeration value="vm_fail" />
267 <xsd:enumeration value="did_not_run" />
268 </xsd:restriction>
269 </xsd:simpleType>
270 </xsd:attribute>
271 </xsd:complexType>
272
273 <xsd:complexType name="TestCase" abstract="false">
274 <xsd:annotation>
275 <xsd:documentation>
276 Testcase elements define the test cases of a test that are
277 exercised in the course of a run. The id for a test takes the
278 form test_case_name:unique_id. The information will be gathered
279 using the test_coverage.xml file associated with the test case,
280 if present. The unique_id is unique within the xml file. The
281 unique_id portion is present because test run might contain
282 repetitions. Testcases are often tests run with different
283 command line arguments or environments. Often, the different
284 test cases in a test are in reality different methods inside
285 that test's source code.
286 </xsd:documentation>
287 <xsd:documentation>
288 The starttime and endtime fields use an XML format. Times are in
289 UTC (like those that java.util.Date works with). An acceptable
290 dateTime format is yyyy-mm-ddThh:mm:ss.ff. DateTime format is
291 specified in section 5.4 of ISO 8601.
292 </xsd:documentation>
293 <xsd:documentation>
294 The analysis setting is meant to allow remote groups to waive or
295 accept the pass/fail status of the test using E-mail.
296 </xsd:documentation>
297 </xsd:annotation>
298 <xsd:sequence>
299 <xsd:element name="name" type="xsd:string" form="qualified" />
300 <xsd:element name="status" type="cof:Status" minOccurs="0"
301 maxOccurs="1" form="qualified" />
302 <xsd:element name="starttime" type="xsd:dateTime" minOccurs="0"
303 maxOccurs="1" form="qualified" />
304 <xsd:element name="endtime" type="xsd:dateTime" minOccurs="0"
305 maxOccurs="1" form="qualified" />
306 <xsd:element name="attributes" type="cof:TestAttributes"
307 minOccurs="0" maxOccurs="1" form="qualified" />
308 <xsd:element name="description" type="xsd:string" minOccurs="0"
309 maxOccurs="1" form="qualified" />
310 </xsd:sequence>
311 <xsd:attribute name="id" type="cof:IDWithColon" use="required" />
312 <xsd:attribute name="analysis" use="optional" default="accept">
313 <xsd:simpleType>
314 <xsd:restriction base="xsd:string">
315 <xsd:enumeration value="accept" />
316 <xsd:enumeration value="waive" />
317 </xsd:restriction>
318 </xsd:simpleType>
319 </xsd:attribute>
320 </xsd:complexType>
321
322 <xsd:complexType name="TestCases" abstract="false">
323 <xsd:sequence>
324 <xsd:element name="testcase" type="cof:TestCase" minOccurs="1"
325 maxOccurs="unbounded" form="qualified" />
326 </xsd:sequence>
327 </xsd:complexType>
328
329 <xsd:complexType name="Test" abstract="false">
330 <xsd:annotation>
331 <xsd:documentation>
332 Test elements define all the tests exercised by the test suite.
333 The id for a test takes the form test_name:unique_id. The
334 information will be gathered using the test_coverage.xml file
335 associated with the test. The unique_id is unique within the xml
336 file. The unique_id portion is present because test run might
337 contain repetitions.
338 </xsd:documentation>
339 <xsd:documentation>
340 Status is required if there are zero test cases. Starttime is
341 required if there are zero test cases. Endtime is required if
342 there are zero test cases. The starttime and endtime fields use
343 an XML format. Times are in UTC (like those that java.util.Date
344 works with). An acceptable dateTime format is
345 yyyy-mm-ddThh:mm:ss.ff. DateTime format is specified in section
346 5.4 of ISO 8601.
347 </xsd:documentation>
348 <xsd:documentation>
349 The analysis setting is meant to allow remote groups to waive or
350 accept the pass/fail status of the test using E-mail. For
351 testcases, the analysis setting provides a default value to
352 apply to the analysis the setting for all testcase results for
353 this test.
354 </xsd:documentation>
355 </xsd:annotation>
356 <xsd:sequence>
357 <xsd:element name="name" type="xsd:string" form="qualified" />
358 <xsd:element name="appuse" type="cof:IDWithColon" minOccurs="0"
359 maxOccurs="unbounded" form="qualified" />
360 <xsd:element name="status" type="cof:Status" minOccurs="0"
361 maxOccurs="1" form="qualified" />
362 <xsd:element name="testcases" type="cof:TestCases" minOccurs="0"
363 maxOccurs="1" form="qualified" />
364 <xsd:element name="starttime" type="xsd:dateTime" minOccurs="0"
365 maxOccurs="1" form="qualified" />
366 <xsd:element name="endtime" type="xsd:dateTime" minOccurs="0"
367 maxOccurs="1" form="qualified" />
368 <xsd:element name="attributes" type="cof:TestAttributes"
369 minOccurs="0" maxOccurs="1" form="qualified" />
370 <xsd:element name="description" type="xsd:string" minOccurs="0"
371 maxOccurs="1" form="qualified" />
372 </xsd:sequence>
373 <xsd:attribute name="id" type="cof:IDWithColon" use="required" />
374 <xsd:attribute name="analysis" use="optional" default="accept">
375 <xsd:simpleType>
376 <xsd:restriction base="xsd:string">
377 <xsd:enumeration value="accept" />
378 <xsd:enumeration value="waive" />
379 </xsd:restriction>
380 </xsd:simpleType>
381 </xsd:attribute>
382 </xsd:complexType>
383
384 <xsd:complexType name="Tests" abstract="false">
385 <xsd:sequence>
386 <xsd:element name="test" type="cof:Test" minOccurs="1"
387 maxOccurs="unbounded" form="qualified" />
388 </xsd:sequence>
389 </xsd:complexType>
390
391 <xsd:complexType name="TestSuite" abstract="false">
392 <xsd:annotation>
393 <xsd:documentation>
394 Test suite elements contain the test suite name. The name must
395 be the same as one defined in the test_coverage.xml file, if
396 that file is defined. The id element for a suite takes the form
397 test_suite:unique_id. The information will be gathered using the
398 test_coverage.xml file associated with the test suite. The
399 unique_id is unique within the xml file. The unique_id portion
400 is present because test run might contain repetitions.
401 </xsd:documentation>
402 <xsd:documentation>
403 The version field uses an XML format. Times are in UTC (like
404 those that java.util.Date works with). An acceptable dateTime
405 format is yyyy-mm-ddThh:mm:ss.ff. DateTime format is specified
406 in section 5.4 of ISO 8601.
407 </xsd:documentation>
408 <xsd:documentation>
409 The starttime and endtime fields use an XML format. Times are in
410 UTC (like those that java.util.Date works with). An acceptable
411 dateTime format is yyyy-mm-ddThh:mm:ss.ff. DateTime format is
412 specified in section 5.4 of ISO 8601.
413 </xsd:documentation>
414 <xsd:documentation>
415 The analysis setting provides a default value to apply to the
416 analysis the setting for all the test and testcase results for
417 this suite.
418 </xsd:documentation>
419 </xsd:annotation>
420 <xsd:sequence>
421 <xsd:element name="name" type="xsd:string" form="qualified" />
422 <xsd:element name="version" type="xsd:dateTime" minOccurs="0"
423 maxOccurs="1" form="qualified" />
424 <xsd:element name="starttime" type="xsd:dateTime" minOccurs="0"
425 maxOccurs="1" form="qualified" />
426 <xsd:element name="endtime" type="xsd:dateTime" minOccurs="0"
427 maxOccurs="1" form="qualified" />
428 <xsd:element name="attributes" type="cof:SuiteAttributes"
429 minOccurs="0" maxOccurs="1" form="qualified" />
430 <xsd:element name="tests" type="cof:Tests" minOccurs="1"
431 maxOccurs="unbounded" form="qualified" />
432 </xsd:sequence>
433 <xsd:attribute name="id" type="cof:IDWithColon" use="required" />
434 <xsd:attribute name="analysis" use="optional" default="accept">
435 <xsd:simpleType>
436 <xsd:restriction base="xsd:string">
437 <xsd:enumeration value="accept" />
438 <xsd:enumeration value="waive" />
439 </xsd:restriction>
440 </xsd:simpleType>
441 </xsd:attribute>
442 </xsd:complexType>
443
444 <xsd:complexType name="TestSuites" abstract="false">
445 <xsd:sequence>
446 <xsd:element name="testsuite" type="cof:TestSuite" minOccurs="1"
447 maxOccurs="unbounded" form="qualified" />
448 </xsd:sequence>
449 </xsd:complexType>
450
451 <xsd:complexType name="Environment">
452 <xsd:annotation>
453 <xsd:documentation>
454 Software configurations are a way to document the software
455 environment used for testing.
456 </xsd:documentation>
457 <xsd:documentation>
458 Machines are identified by name, not Internet address. The name
459 must be fully qualified. Hardware configuration is obtained with
460 a combination of name and date.
461 </xsd:documentation>
462 <xsd:documentation>
463 Locale documents the default locale for the test run. Locale
464 values should be in the usual Java format of strings separated
465 by underscores. For instance, ja, ja_JP, and ja_JP_custom are
466 all valid. The first string is a valid ISO Language Code and the
467 second is a valid ISO Country Code. The list of language and
468 country codes are at
469 http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt and
470 http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html ,
471 respectively. The third string in the concatenation is for
472 variants and can contain underscores.
473 </xsd:documentation>
474 <xsd:documentation>
475 System-locale is that used by the OS to configure OS
476 applications. On Windows systems, system-locale is attached to
477 the OS and cannot be changed. User-locale is that used by the
478 Java API. It is the setting reported out by
479 java.util.Locale.getDefault().
480 </xsd:documentation>
481 <xsd:documentation>
482 Time zone elements document the default time zone for the test
483 run. Time zones should be in the format used by Java. For
484 instance, the string for Pacific Standard Time is "America/Los
485 Angeles". The list of supported time zones is obtained by
486 invoking java.util.TimeZone.getAvailableIDs. Do not use a
487 deprecated three-letter time zone ID.
488 </xsd:documentation>
489 <xsd:documentation>
490 The value assigned encoding is the return value from the Java
491 (new InputStreamReader(System.in)).getEncoding()
492 </xsd:documentation>
493 <xsd:documentation>
494 JDK elements use the property java.runtime.version.
495 </xsd:documentation>
496 </xsd:annotation>
497 <xsd:sequence>
498 <xsd:element name="machine" type="cof:Machine" form="qualified" />
499 <xsd:element name="os" type="cof:OS" form="qualified" />
500 <xsd:element name="jdk" type="xsd:string" minOccurs="0"
501 maxOccurs="1" form="qualified" />
502 <xsd:element name="system-locale" type="xsd:string" minOccurs="0"
503 maxOccurs="1" form="qualified" />
504 <xsd:element name="user-locale" type="xsd:string" minOccurs="0"
505 maxOccurs="1" form="qualified" />
506 <xsd:element name="encoding" type="xsd:string" minOccurs="0"
507 maxOccurs="1" form="qualified" />
508 <xsd:element name="timezone" type="xsd:string" minOccurs="0"
509 maxOccurs="1" form="qualified" />
510 <xsd:element name="bits" type="cof:Bits" minOccurs="0"
511 maxOccurs="1" form="qualified" />
512 <xsd:element name="displaydepth" type="cof:DisplayDepth"
513 minOccurs="0" maxOccurs="1" form="qualified" />
514 <xsd:element name="description" type="xsd:string" minOccurs="0"
515 maxOccurs="1" form="qualified" />
516 <xsd:element name="sw" type="cof:SWEntity" minOccurs="0"
517 maxOccurs="unbounded" form="qualified" />
518 </xsd:sequence>
519 <xsd:attribute name="id" type="cof:IDWithColon" use="required" />
520 </xsd:complexType>
521
522 <xsd:complexType name="Environments">
523 <xsd:sequence>
524 <xsd:element name="environment" type="cof:Environment"
525 minOccurs="1" maxOccurs="unbounded" form="qualified" />
526 </xsd:sequence>
527 </xsd:complexType>
528
529 <xsd:complexType name="SWEntity">
530 <xsd:annotation>
531 <xsd:documentation>
532 Software is tracked in the hardware/software database that backs
533 up the COF XML. The elements in the SW type map to fields in the
534 software table of that database. Type is enumerated. See below.
535 Name is a product name with no version string. For example,
536 "Tomcat". Version is a product version. For instance, "8i".
537 </xsd:documentation>
538 </xsd:annotation>
539 <xsd:sequence>
540 <xsd:element name="name" type="xsd:string" form="qualified" />
541 <xsd:element name="type" form="qualified">
542 <xsd:simpleType>
543 <xsd:restriction base="xsd:string">
544 <xsd:enumeration value="appserver" />
545 <xsd:enumeration value="browser" />
546 <xsd:enumeration value="database" />
547 <xsd:enumeration value="editor" />
548 <xsd:enumeration value="java" />
549 <xsd:enumeration value="webserver" />
550 </xsd:restriction>
551 </xsd:simpleType>
552 </xsd:element>
553 <xsd:element name="version" type="xsd:string" minOccurs="0"
554 maxOccurs="1" form="qualified" />
555 <xsd:element name="description" type="xsd:string" minOccurs="0"
556 maxOccurs="1" form="qualified" />
557 </xsd:sequence>
558 <xsd:attribute name="id" type="cof:IDWithColon" use="required" />
559 </xsd:complexType>
560
561 <xsd:complexType name="SWEntities" abstract="false">
562 <xsd:sequence>
563 <xsd:element name="swentity" type="cof:SWEntity" minOccurs="1"
564 maxOccurs="unbounded" form="qualified" />
565 </xsd:sequence>
566 </xsd:complexType>
567
568 <xsd:complexType name="Application" abstract="false">
569 <xsd:attribute name="id" type="cof:IDWithColon" use="required" />
570 <xsd:attribute name="environmentid" type="cof:IDWithColon"
571 use="required" />
572 <xsd:attribute name="swentityid" type="cof:IDWithColon"
573 use="required" />
574 </xsd:complexType>
575
576 <xsd:complexType name="Applications" abstract="false">
577 <xsd:sequence>
578 <xsd:element name="application" type="cof:Application"
579 minOccurs="1" maxOccurs="unbounded" form="qualified" />
580 </xsd:sequence>
581 </xsd:complexType>
582
583 <xsd:complexType name="ReportAnnotation">
584 <xsd:annotation>
585 <xsd:documentation>
586 Report annotations are name/value pairs that provide information
587 about a test run. They are often test-harness specific or
588 contain information that is added by users after the test run is
589 complete.
590 </xsd:documentation>
591 <xsd:documentation>
592 Some attributes are used by the QARE test database system. One
593 of these is the name of the product under test. The name of the
594 annotation for this is "product". This is typically the name of
595 a major release of the software or hardware you are shipping.
596 </xsd:documentation>
597 <xsd:documentation>
598 Some attributes are used by the QARE test database system. One
599 of these is the name of the version or build of the product
600 under test. The name of the annotation for this is "version".
601 </xsd:documentation>
602 <xsd:documentation>
603 Some attributes are used by the QARE test database system. One
604 of these is the name of your working group. The name of the
605 annotation for this is "work_group". This is the name of the
606 business component responsible for analyzing and tracking the
607 test results from this test run. Note that if a component is
608 specified as a suite attribute that the suite attribute will
609 overrule the assignment made in this annotation.
610 </xsd:documentation>
611 <xsd:documentation>
612 Some attributes are used by the QARE test database system. Test
613 run modes are adjectives whose value might be "BAT", "PIT",
614 "JCov", or "Bundle". The name of the annotation for this is
615 "testrun_mode".
616 </xsd:documentation>
617 <xsd:documentation>
618 Some attributes are used by the QARE test database system. Test
619 cycles are described by an adjective whose value might be
620 "Nightly" or "Weekly". The name of the annotation for this is
621 "testrun_cycle".
622 </xsd:documentation>
623 <xsd:documentation>
624 Some attributes are used by the QARE test database system. Test
625 run type is another test run adjective. It might take one of the
626 values "Quicklook", "Fulllook", or "Smoke". The name of the
627 annotation for this is "testrun_type".
628 </xsd:documentation>
629 <xsd:documentation>
630 Some attributes are used by the QARE test database system. The
631 most important of these has an annotation name of archive. The
632 value of archive is where test failures are copied to for
633 storage. If you are a QARE user, the value should be a full path
634 that is accessible to the QARE application server. For Sun QARE
635 users, this means that mapped file systems are not usable. If
636 you are using this product in a Windows shop, then it is the
637 testing department's job to keep the drive letters used by your
638 tests up to date and consistent.
639 </xsd:documentation>
640 <xsd:documentation>
641 Some attributes are used by the QARE test database system. The
642 annotation named "task_scheduler" is used to identify the
643 scheduler used to start and stop jobs. The only scheduler
644 recognized is DTF.
645 </xsd:documentation>
646 <xsd:documentation>
647 Some attributes are used by the QARE test database system. The
648 annotation named "default_machine" is used to identify a primary
649 machine for labelling purposes. This is important for
650 multi-machine tests. It is common for one of the machines to
651 hold the software that is actually being tested and for the
652 other machines to be mere clients.
653 </xsd:documentation>
654 <xsd:documentation>
655 Some attributes are used by the QARE test database system. One
656 of these is the name of your testing group. The name of the
657 annotation for this is "test_group". An example of such a group
658 is "J2SE QA".
659 </xsd:documentation>
660 </xsd:annotation>
661 <xsd:sequence>
662 <xsd:element name="name" type="xsd:string" minOccurs="1"
663 maxOccurs="unbounded" form="qualified" />
664 <xsd:element name="value" type="xsd:string" minOccurs="1"
665 maxOccurs="unbounded" form="qualified" />
666 </xsd:sequence>
667 </xsd:complexType>
668
669 <xsd:complexType name="ReportAnnotations" abstract="false">
670 <xsd:sequence>
671 <xsd:element name="annotation" type="cof:ReportAnnotation"
672 minOccurs="0" maxOccurs="unbounded" form="qualified" />
673 </xsd:sequence>
674 </xsd:complexType>
675
676 <xsd:complexType name="Report" abstract="false">
677 <xsd:annotation>
678 <xsd:documentation>
679 The version is the common XML output version. The current
680 version is 2.0.0. The date fields use an XML format. Times are
681 in UTC (like those that java.util.Date works with). An
682 acceptable dateTime format is yyyy-mm-ddThh24:mm:ss.ff. DateTime
683 format is specified in section 5.4 of ISO 8601.
684 </xsd:documentation>
685 <xsd:documentation>
686 The analysis setting is meant to allow remote groups to waive or
687 accept the entire test run. It provides an override, not a
688 default, for the analysis settings of the suite, test, and
689 testcase results that are part of the test run. The intent here
690 is to record test runs that were set up incorrectly.
691 </xsd:documentation>
692 </xsd:annotation>
693 <xsd:sequence>
694 <xsd:element name="date" type="xsd:dateTime" form="qualified" />
695 <xsd:element name="version" type="xsd:string" form="qualified" />
696
697 <xsd:element name="environments" type="cof:Environments"
698 form="qualified"><!--
699 <xsd:annotation>
700 <xsd:appinfo>
701 <jxb:property>
702 <jxb:baseType name="java.util.List"></jxb:baseType>
703 </jxb:property>
704 </xsd:appinfo>
705 </xsd:annotation>
706 --></xsd:element>
707 <xsd:element name="swentities" type="cof:SWEntities" minOccurs="0"
708 maxOccurs="1" form="qualified" />
709 <xsd:element name="applications" type="cof:Applications"
710 minOccurs="0" maxOccurs="unbounded" form="qualified" />
711 <xsd:element name="operator" type="xsd:string" minOccurs="0"
712 maxOccurs="1" form="qualified" />
713 <xsd:element name="harness" type="xsd:string" minOccurs="0"
714 maxOccurs="1" form="qualified" />
715 <xsd:element name="testsuites" type="cof:TestSuites" minOccurs="1"
716 maxOccurs="1" form="qualified" />
717 <xsd:element name="annotations" type="cof:ReportAnnotations"
718 minOccurs="1" maxOccurs="1" form="qualified" />
719 <xsd:any minOccurs="0" maxOccurs="unbounded"
720 processContents="skip" />
721 </xsd:sequence>
722 <xsd:attribute name="analysis" use="optional" default="accept">
723 <xsd:simpleType>
724 <xsd:restriction base="xsd:string">
725 <xsd:enumeration value="accept" />
726 <xsd:enumeration value="waive" />
727 </xsd:restriction>
728 </xsd:simpleType>
729 </xsd:attribute>
730 </xsd:complexType>
731
732 <xsd:element name="report" type="cof:Report">
733 <xsd:key name="EnvironmentKey">
734 <xsd:selector xpath="report/environments/environment" />
735 <xsd:field xpath="@id" />
736 </xsd:key>
737 <xsd:keyref name="RefToEnvironment" refer="cof:EnvironmentKey">
738 <xsd:selector xpath="report/applications/application" />
739 <xsd:field xpath="@environmentid" />
740 </xsd:keyref>
741
742 <xsd:key name="SWEntityKey">
743 <xsd:selector xpath="report/swentities/swentity" />
744 <xsd:field xpath="@id" />
745 </xsd:key>
746 <xsd:keyref name="RefToSWEntity" refer="cof:SWEntityKey">
747 <xsd:selector xpath="report/applications/application" />
748 <xsd:field xpath="@swentityid" />
749 </xsd:keyref>
750
751 <xsd:key name="ApplicationKey">
752 <xsd:selector xpath="report/applications/application" />
753 <xsd:field xpath="@id" />
754 </xsd:key>
755 <xsd:keyref name="RefToApplication" refer="cof:ApplicationKey">
756 <xsd:selector
757 xpath="report/testsuites/testsuite/tests/test/appuse" />
758 <xsd:field xpath="@id" />
759 </xsd:keyref>
760
761 <xsd:unique name="UniqueTestSuiteID">
762 <xsd:selector xpath="report/testsuites/testsuite" />
763 <xsd:field xpath="@id" />
764 </xsd:unique>
765
766 <xsd:unique name="UniqueTestID">
767 <xsd:selector xpath="report/testsuites/testsuite/tests/test" />
768 <xsd:field xpath="@id" />
769 </xsd:unique>
770
771 <xsd:unique name="UniqueTestCaseID">
772 <xsd:selector
773 xpath="report/testsuites/testsuite/tests/test/testcases/testcase" />
774 <xsd:field xpath="@id" />
775 </xsd:unique>
776
777 </xsd:element>
778
779 </xsd:schema>
+0
-99
src/com/sun/javatest/cof/COFApplication.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.util.LinkedHashMap;
29
30 public class COFApplication extends COFItem {
31 static LinkedHashMap xmlAttributes;
32 static LinkedHashMap xmlElements;
33 static String xmlTagName;
34 static {
35 xmlTagName = "application";
36 xmlAttributes = new LinkedHashMap();
37 xmlAttributes.put("id", "id");
38 xmlAttributes.put("environmentid", "environmentid");
39 xmlAttributes.put("swentityid", "swentityid");
40 }
41
42 protected String id = "app:0";
43
44 protected String environmentid="env:0";
45
46 protected String swentityid = "swentity:0";
47
48 /**
49 * Gets the value of the id property.
50 *
51 * @return possible object is {@link String }
52 *
53 */
54 public String getId() {
55 return id;
56 }
57
58 LinkedHashMap getItemAttributes() {
59 return xmlAttributes;
60 }
61
62 LinkedHashMap getItemElements() {
63 return xmlElements;
64 }
65
66 String getItemTagName() {
67 return xmlTagName;
68 }
69
70 public void setId(String value) {
71 this.id = value;
72 }
73
74 public String getEnvironmentid() {
75 return environmentid;
76 }
77
78 public void setEnvironmentid(String environmentid) {
79 this.environmentid = environmentid;
80 }
81
82 public String getSwentityid() {
83 return swentityid;
84 }
85
86 public void setSwentityid(String swentityid) {
87 this.swentityid = swentityid;
88 }
89
90 /**
91 * Sets the value of the name property.
92 *
93 * @param value
94 * allowed object is {@link String }
95 *
96 */
97
98 }
+0
-69
src/com/sun/javatest/cof/COFApplications.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.util.ArrayList;
29 import java.util.LinkedHashMap;
30 import java.util.List;
31
32
33 public class COFApplications extends COFItem {
34
35 static LinkedHashMap xmlAttributes;
36
37 static LinkedHashMap xmlElements;
38
39 static String xmlTagName;
40
41 static {
42 xmlElements = new LinkedHashMap();
43 xmlElements.put("application", "application");
44 xmlTagName = "applications";
45 }
46
47 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
48 protected List application;
49
50 LinkedHashMap getItemAttributes() {
51 return xmlAttributes;
52 }
53
54 LinkedHashMap getItemElements() {
55 return xmlElements;
56 }
57 String getItemTagName() {
58 return xmlTagName;
59 }
60
61 public List getApplication() {
62 if (application == null) {
63 application = new ArrayList();
64 }
65 return this.application;
66 }
67
68 }
+0
-129
src/com/sun/javatest/cof/COFData.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import com.sun.javatest.InterviewParameters;
29 import java.io.BufferedInputStream;
30 import java.io.File;
31 import java.io.FileInputStream;
32 import java.io.IOException;
33 import java.io.InputStream;
34 import java.util.HashMap;
35 import java.util.Map;
36 import java.util.Properties;
37 import java.util.Vector;
38
39 public class COFData
40 {
41 public COFData() {
42 }
43
44 COFData(Vector data) throws IOException {
45 for (int i = 0; i < data.size(); i++) {
46 Object o = data.elementAt(i);
47 if (o == null)
48 throw new NullPointerException();
49 else if (o instanceof String) {
50 String s = (String) o;
51 int eq = s.indexOf("=");
52 if (eq < 1)
53 throw new IllegalArgumentException(s);
54 String name = s.substring(0, eq);
55 String value = s.substring(eq + 1);
56 put(name, value);
57 }
58 else if (o instanceof File) {
59 File f = (File) o;
60 InputStream in = new BufferedInputStream(new FileInputStream(f));
61 Properties p = new Properties();
62 try {
63 p.load(in);
64 }
65 finally {
66 in.close();
67 }
68 putAll(p);
69 }
70 else
71 throw new IllegalArgumentException(o.toString());
72 }
73 }
74
75 public String get(String name) {
76 return (String) (data.get(name));
77 }
78
79 public String get(String name, String defaultValue) {
80 String value = (String) (data.get(name));
81 return (value == null ? defaultValue : value);
82 }
83
84 public void put(String name, String value) {
85 data.put(name, value);
86 }
87
88 public void putAll(Map map) {
89 data.putAll(map);
90 }
91
92 private Map data = new HashMap();
93
94 private CustomFilter filter = new CustomFilterAdapter();
95
96 void setCustomFilter(String filterClassName) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
97 Class c = Class.forName(filterClassName, true, ClassLoader.getSystemClassLoader());
98 filter = (CustomFilter) c.newInstance();
99 }
100
101 CustomFilter getCustomFilter() {
102 return filter;
103 }
104
105 private MTL mtl;
106
107 MTL getMtl() {
108 return mtl;
109 }
110
111 void setMtl(MTL mtl) {
112 this.mtl = mtl;
113 }
114
115 public void setInterviewParameters(InterviewParameters ip) {
116 this.ip = ip;
117 }
118
119 public InterviewParameters getInterviewParameters() {
120 return ip;
121 }
122
123 public boolean isInterviewParametersAvailable() {
124 return ip != null;
125 }
126
127 private InterviewParameters ip;
128 }
+0
-604
src/com/sun/javatest/cof/COFEnvironment.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.io.InputStreamReader;
29 import java.io.RandomAccessFile;
30 import java.net.InetAddress;
31 import java.net.UnknownHostException;
32 import java.util.ArrayList;
33 import java.util.LinkedHashMap;
34 import java.util.List;
35 import java.util.StringTokenizer;
36 import java.util.TimeZone;
37
38 import com.sun.javatest.util.I18NResourceBundle;
39
40 /* temp */public/* temp */class COFEnvironment extends COFItem {
41 static String[] propOrder = { "machine", "os", "jdk", "systemLocale",
42 "userLocale", "encoding", "timezone", "bits", "displaydepth",
43 "description", "sw" };
44
45 static String[] propTags = { "machine", "os", "jdk", "system-locale",
46 "user-locale", "encoding", "timezone", "bits", "displaydepth",
47 "description", "sw" };
48
49 static LinkedHashMap xmlAttributes;
50
51 static LinkedHashMap xmlElements;
52
53 static String xmlTagName;
54 private static I18NResourceBundle i18n = I18NResourceBundle
55 .getBundleForClass(Main.class);
56
57 static {
58 xmlElements = new LinkedHashMap();
59 for (int i = 0; i < propOrder.length; i++) {
60 xmlElements.put(propOrder[i], propTags[i]);
61 }
62 xmlAttributes = new LinkedHashMap();
63 xmlAttributes.put("id", "id");
64 xmlTagName = "environment";
65 }
66
67 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
68 protected Integer bits;
69
70 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
71 protected String description;
72
73 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
74 protected Integer displaydepth;
75
76 private String domainName;
77
78 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
79 protected String encoding;
80
81 private String hostName;
82
83 // @XmlAttribute(required = true)
84 protected String id = "env:0";
85
86 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
87 protected String jdk;
88
89 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
90 protected String machine;
91
92 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
93 protected COFOS os;
94
95 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
96 protected List/*<SWEntity>*/sw;
97
98 // @XmlElement(name = "system-locale", namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
99 protected String systemLocale;
100
101 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
102 protected String timezone;
103
104 // @XmlElement(name = "system-locale", namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
105 protected String userLocale;
106 protected COFData data;
107
108 COFEnvironment(COFData data) {
109 this.data = data;
110
111 initDefaultHostInfo();
112 initDefaultOSInfo();
113
114 hostName = data.get("environment.host", hostName);
115 domainName = data.get("environment.domain", domainName);
116 setMachine(data.get("environment.machine", hostName + "." + domainName));
117 os.setName(data.get("environment.os.name", os.getName()));
118 os.setVersion(data.get("environment.os.version", os.getVersion()));
119 os.setArch(data.get("environment.os.arch", os.getArch()));
120 setJdk(data.get("environment.jdk", jdk));
121 setUserLocale(data.get("environment.user-locale", java.util.Locale.getDefault().toString()));
122 setSystemLocale(data.get("environment.system-locale", data
123 .get("LOCALE")));
124 setEncoding(data.get("environment.encoding", (new InputStreamReader(
125 System.in)).getEncoding()));
126 setTimezone(data.get("environment.timezone", TimeZone.getDefault()
127 .getID()));
128 setBits(data.get("environment.bits", null) == null ? null
129 : new Integer(data.get("environment.bits")));
130 setDisplaydepth(data.get("environment.displaydepth", null) == null ? null
131 : new Integer(data.get("environment.displaydepth")));
132 setDescription(data.get("environment.description"));
133 }
134
135 public COFEnvironment(COFData data, String id) {
136 this(data);
137 this.id = id;
138 }
139
140 /**
141 * Gets the value of the bits property.
142 *
143 * @return
144 * possible object is
145 * {@link Integer }
146 *
147 */
148 public Integer getBits() {
149 return bits;
150 }
151
152 private String getCalderaLinuxVersionInfo() {
153 String res = "N/A";
154
155 RandomAccessFile raf = null;
156 try {
157 raf = new RandomAccessFile("/etc/issue", "r");
158 String line;
159 while ((line = raf.readLine()) != null) {
160 StringTokenizer st = new StringTokenizer(line, " ");
161 if (st.countTokens() >= 2) {
162 if (st.nextToken().toUpperCase().equals("VERSION")) {
163 res = st.nextToken();
164 break;
165 }
166 }
167 }
168 } catch (Exception e) {
169 // System.err.println("Something might be wrong with Caldera");
170 // cat.warn("The version number of Caldera cannot be retrieved");
171 } finally {
172 if (raf != null) {
173 try {
174 raf.close();
175 } catch (Exception e) {
176 }
177 }
178 }
179
180 return res;
181 }
182
183 /**
184 * Gets the value of the description property.
185 *
186 * @return
187 * possible object is
188 * {@link String }
189 *
190 */
191 public String getDescription() {
192 return description;
193 }
194
195 /**
196 * Gets the value of the displaydepth property.
197 *
198 * @return
199 * possible object is
200 * {@link Integer }
201 *
202 */
203 public Integer getDisplaydepth() {
204 return displaydepth;
205 }
206
207 /**
208 * Gets the value of the encoding property.
209 *
210 * @return
211 * possible object is
212 * {@link String }
213 *
214 */
215 public String getEncoding() {
216 return encoding;
217 }
218
219 private String getGenericLinuxVersionInfo(String fileName) {
220 String res = "N/A";
221
222 RandomAccessFile raf = null;
223 try {
224 raf = new RandomAccessFile(fileName, "r");
225 StringTokenizer st = new StringTokenizer(raf.readLine(), " ");
226 while (st.hasMoreElements()) {
227 String ele = st.nextToken();
228 if (Character.isDigit(ele.charAt(0))) {
229 res = ele;
230 break;
231 }
232 }
233 } catch (Exception e) {
234 // System.err.println("Something might be wrong with Linux");
235 } finally {
236 if (raf != null) {
237 try {
238 raf.close();
239 } catch (Exception e) {
240 }
241 }
242 }
243
244 return res;
245 }
246
247 /**
248 * Gets the value of the id property.
249 *
250 * @return
251 * possible object is
252 * {@link String }
253 *
254 */
255 public String getId() {
256 return id;
257 }
258
259 LinkedHashMap getItemAttributes() {
260 return xmlAttributes;
261 }
262
263 LinkedHashMap getItemElements() {
264 return xmlElements;
265 }
266
267 String getItemTagName() {
268 return xmlTagName;
269 }
270
271 /**
272 * Gets the value of the jdk property.
273 *
274 * @return
275 * possible object is
276 * {@link String }
277 *
278 */
279 public String getJdk() {
280 return jdk;
281 }
282
283 /**
284 * Gets the value of the machine property.
285 *
286 * @return
287 * possible object is
288 * {@link String }
289 *
290 */
291 public String getMachine() {
292 return machine;
293 }
294
295 /**
296 * Gets the value of the os property.
297 *
298 * @return
299 * possible object is
300 * {@link OS }
301 *
302 */
303 public COFOS getOs() {
304 return os;
305 }
306
307 String[] getPropOrder() {
308 return propOrder;
309 }
310
311 /**
312 * Gets the value of the sw property.
313 *
314 * <p>
315 * This accessor method returns a reference to the live list,
316 * not a snapshot. Therefore any modification you make to the
317 * returned list will be present inside the JAXB object.
318 * This is why there is not a <CODE>set</CODE> method for the sw property.
319 *
320 * <p>
321 * For example, to add a new item, do as follows:
322 * <pre>
323 * getSw().add(newItem);
324 * </pre>
325 *
326 *
327 * <p>
328 * Objects of the following type(s) are allowed in the list
329 * {@link SWEntity }
330 *
331 *
332 */
333 public List/*<SWEntity>*/getSw() {
334 if (sw == null) {
335 sw = new ArrayList/*<SWEntity>*/();
336 }
337 return this.sw;
338 }
339
340 /**
341 * Gets the value of the systemLocale property.
342 *
343 * @return
344 * possible object is
345 * {@link String }
346 *
347 */
348 public String getSystemLocale() {
349 return systemLocale;
350 }
351
352 String getTagName() {
353 return itemTagName;
354 }
355
356 String[] getTags() {
357 return propTags;
358 }
359
360 /**
361 * Gets the value of the timezone property.
362 *
363 * @return
364 * possible object is
365 * {@link String }
366 *
367 */
368 public String getTimezone() {
369 return timezone;
370 }
371
372 /**
373 * Gets the value of the userLocale property.
374 *
375 * @return
376 * possible object is
377 * {@link String }
378 *
379 */
380 public String getUserLocale() {
381 return userLocale;
382 }
383
384 private void initDefaultHostInfo() {
385 domainName = "unknown";
386
387 try {
388 hostName = InetAddress.getLocalHost().getHostName();
389 } catch (UnknownHostException e) {
390 hostName = "unknown";
391 }
392 }
393
394 private void initDefaultOSInfo() {
395 os = new COFOS();
396 os.setName(System.getProperty("os.name"));
397 os.setVersion(System.getProperty("os.version"));
398 os.setArch(System.getProperty("os.arch"));
399
400 // standardize results
401 /* if (osName.equals("sunos") || osName.equals("solaris")) {
402 osName = "solaris";
403 if (osVersion.equals("5.6"))
404 osVersion = "2.6";
405 else if (osVersion.equals("5.7"))
406 osVersion = "2.7";
407 else if (osVersion.equals("5.8"))
408 osVersion = "8";
409 else if (osVersion.equals("5.9"))
410 osVersion = "9";
411 } else if (osName.startsWith("windows")) {
412 osName = "windows";
413 if (osName.indexOf("95") != -1)
414 osVersion = "95";
415 else if (osName.indexOf("98") != -1)
416 osVersion = "98";
417 else if (osName.indexOf("2000") != -1)
418 osVersion = "2000";
419 else if (osName.indexOf("me") != -1)
420 osVersion = "me";
421 else if (osName.indexOf("nt") != -1)
422 osVersion = "nt_4.0";
423 else if (osName.indexOf("xp") != -1)
424 osVersion = "xp";
425 } else if (osName.equals("linux")) {
426 if ((new File("/etc/turbolinux-release")).exists()) {
427 osName = "turbo_linux";
428 osVersion = getGenericLinuxVersionInfo("/etc/turbolinux-release");
429 } else if ((new File("/etc/SuSE-release")).exists()) {
430 osName = "suse_linux";
431 osVersion = getGenericLinuxVersionInfo("/etc/SuSE-release");
432 } else if ((new File("/etc/mandrake-release")).exists()) {
433 osName = "mandrake_linux";
434 osVersion = getGenericLinuxVersionInfo("/etc/mandrake-release");
435 } else if ((new File("/etc/redhat-release")).exists()) {
436 osName = "redhat_linux";
437 osVersion = getGenericLinuxVersionInfo("/etc/redhat-release");
438 } else if ((new File("/etc/lst.cnf")).exists()) {
439 osName = "caldera_linux";
440 osVersion = getCalderaLinuxVersionInfo();
441 } else {
442 osName = "unknown_linux";
443 osVersion = "N/A";
444 }
445 }
446 */}
447
448 /**
449 * Sets the value of the bits property.
450 *
451 * @param value
452 * allowed object is
453 * {@link Integer }
454 *
455 */
456 public void setBits(Integer value) {
457 this.bits = value;
458 }
459
460 /**
461 * Sets the value of the description property.
462 *
463 * @param value
464 * allowed object is
465 * {@link String }
466 *
467 */
468 public void setDescription(String value) {
469 this.description = value;
470 }
471
472 /**
473 * Sets the value of the displaydepth property.
474 *
475 * @param value
476 * allowed object is
477 * {@link Integer }
478 *
479 */
480 public void setDisplaydepth(Integer value) {
481 this.displaydepth = value;
482 }
483
484 /**
485 * Sets the value of the encoding property.
486 *
487 * @param value
488 * allowed object is
489 * {@link String }
490 *
491 */
492 public void setEncoding(String value) {
493 this.encoding = value;
494 }
495
496 /**
497 * Sets the value of the id property.
498 *
499 * @param value
500 * allowed object is
501 * {@link String }
502 *
503 */
504 public void setId(String value) {
505 this.id = value;
506 }
507
508 /**
509 * Sets the value of the jdk property.
510 *
511 * @param value
512 * allowed object is
513 * {@link String }
514 *
515 */
516 public void setJdk(String value) {
517 this.jdk = value;
518 }
519
520 /**
521 * Sets the value of the machine property.
522 *
523 * @param value
524 * allowed object is
525 * {@link String }
526 *
527 */
528 public void setMachine(String value) {
529 if (value.endsWith(".unknown"))
530 try {
531 machine = InetAddress.getLocalHost().getCanonicalHostName();
532 if (machine.indexOf(".") == -1) {
533 if ("false".equals(data.get("showWarnings"))) {
534 System.err.println(i18n.getString("environment.badMachineName", machine));
535 } else {
536 String warningMessage = data.get("warning", "");
537 data.put("warning", warningMessage + i18n.getString("environment.badMachineName") + "\n");
538 }
539 }
540 return;
541 } catch (UnknownHostException e) {
542 if ("false".equals(data.get("showWarnings"))) {
543 System.err.println(i18n.getString("environment.cantGetLocalhostName", e.getMessage()));
544 value = value.substring(0, value.indexOf(".unknown")-1);
545 System.err.println(i18n.getString("environment.badMachineName", value));
546 } else {
547 String warningMessage = data.get("warning", "");
548 value = value.substring(0, value.indexOf(".unknown")-1);
549 data.put("warning", warningMessage + i18n.getString("environment.cantGetLocalhostName", e.getMessage()) + "\n" + i18n.getString("environment.badMachineName", value) + "\n");
550 }
551 }
552 this.machine = value;
553 }
554
555 /**
556 * Sets the value of the os property.
557 *
558 * @param value
559 * allowed object is
560 * {@link OS }
561 *
562 */
563 public void setOs(COFOS value) {
564 this.os = value;
565 }
566
567 /**
568 * Sets the value of the systemLocale property.
569 *
570 * @param value
571 * allowed object is
572 * {@link String }
573 *
574 */
575 public void setSystemLocale(String value) {
576 this.systemLocale = value;
577 }
578
579 /**
580 * Sets the value of the timezone property.
581 *
582 * @param value
583 * allowed object is
584 * {@link String }
585 *
586 */
587 public void setTimezone(String value) {
588 this.timezone = value;
589 }
590
591 /**
592 * Sets the value of the userLocale property.
593 *
594 * @param value
595 * allowed object is
596 * {@link String }
597 *
598 */
599 public void setUserLocale(String value) {
600 this.userLocale = value;
601 }
602
603 }
+0
-124
src/com/sun/javatest/cof/COFEnvironments.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.io.IOException;
29 import java.util.ArrayList;
30 import java.util.LinkedHashMap;
31 import java.util.List;
32
33 import com.sun.javatest.util.XMLWriter;
34
35
36 /**
37 * <p>Java class for Environments complex type.
38 *
39 * <p>The following schema fragment specifies the expected content contained within this class.
40 *
41 * <pre>
42 * &lt;complexType name="Environments">
43 * &lt;complexContent>
44 * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
45 * &lt;sequence>
46 * &lt;element name="environment" type="{http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema}Environment" maxOccurs="unbounded"/>
47 * &lt;/sequence>
48 * &lt;/restriction>
49 * &lt;/complexContent>
50 * &lt;/complexType>
51 * </pre>
52 *
53 *
54 */
55 public class COFEnvironments extends COFItem {
56
57 static LinkedHashMap xmlAttributes;
58
59 static LinkedHashMap xmlElements;
60
61 static String xmlTagName;
62
63 static {
64 xmlElements = new LinkedHashMap();
65 xmlElements.put("environment", "environment");
66 xmlTagName = "environments";
67 }
68
69 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
70 protected List/*<Environment>*/ environment;
71
72 /**
73 * Gets the value of the environment property.
74 *
75 * <p>
76 * This accessor method returns a reference to the live list,
77 * not a snapshot. Therefore any modification you make to the
78 * returned list will be present inside the JAXB object.
79 * This is why there is not a <CODE>set</CODE> method for the environment property.
80 *
81 * <p>
82 * For example, to add a new item, do as follows:
83 * <pre>
84 * getEnvironment().add(newItem);
85 * </pre>
86 *
87 *
88 * <p>
89 * Objects of the following type(s) are allowed in the list
90 * {@link Environment }
91 *
92 *
93 */
94 public List/*<Environment>*/ getEnvironment() {
95 if (environment == null) {
96 environment = new ArrayList/*<Environment>*/();
97 }
98 return this.environment;
99 }
100
101 LinkedHashMap getItemAttributes() {
102 return xmlAttributes;
103 }
104
105 LinkedHashMap getItemElements() {
106 return xmlElements;
107 }
108
109
110 String getItemTagName() {
111 return xmlTagName;
112 }
113
114
115 /* (non-Javadoc)
116 * @see com.sun.javatest.cof.COFItem#write(com.sun.javatest.util.XMLWriter)
117 */
118 void write(XMLWriter out) throws IOException {
119 out.newLine();
120 super.write(out);
121 }
122
123 }
+0
-182
src/com/sun/javatest/cof/COFItem.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.beans.BeanInfo;
29 import java.beans.IntrospectionException;
30 import java.beans.Introspector;
31 import java.beans.PropertyDescriptor;
32 import java.io.IOException;
33 import java.lang.reflect.InvocationTargetException;
34 import java.lang.reflect.Method;
35 import java.util.Arrays;
36 import java.util.Collection;
37 import java.util.Comparator;
38 import java.util.Date;
39 import java.util.Iterator;
40 import java.util.LinkedHashMap;
41
42 import com.sun.javatest.util.XMLWriter;
43
44 abstract class COFItem
45 {
46 BeanInfo bi = null;
47 LinkedHashMap itemAttributes = getItemAttributes();
48 LinkedHashMap itemElements = getItemElements();
49 String itemTagName = getItemTagName();
50 PropertyDescriptor [] pds = null;
51
52 private String[] getAttributeProperties() {
53 return itemAttributes == null? null: (String []) itemAttributes.keySet().toArray(new String[itemAttributes.size()]);
54 }
55 LinkedHashMap getItemAttributes(){
56 return null;
57 }
58 LinkedHashMap getItemElements() {
59 return null;
60 };
61
62 String getItemTagName(){
63 return null;
64 }
65
66 Object getProperty(String name) {
67 if (bi == null) {
68 try {
69 bi = Introspector.getBeanInfo(this.getClass());
70 pds = bi.getPropertyDescriptors();
71 Arrays.sort(pds, new Comparator() {
72 public int compare(Object o1, Object o2) {
73 PropertyDescriptor pd1 = (PropertyDescriptor) o1;
74 PropertyDescriptor pd2 = (PropertyDescriptor) o2;
75 return pd1.getName().compareTo(pd2.getName());
76 }
77 });
78 } catch (IntrospectionException e) {
79 // TODO Auto-generated catch block
80 e.printStackTrace();
81 }
82 }
83
84 if (pds == null) return null;
85
86 Object result = null;
87 int propIndex = Arrays.binarySearch(pds, name, new Comparator() {
88 public int compare(Object o1, Object o2) {
89 PropertyDescriptor pd = (PropertyDescriptor) o1;
90 String propName = (String) o2;
91 return pd.getName().compareTo(propName);
92 }
93
94 });
95
96 if (propIndex < 0 || propIndex >= pds.length) { // no such property
97 // System.out.println("passing "+ name);
98 return null;
99 }
100
101 try {
102
103 Method readMethod = pds[propIndex].getReadMethod();
104 if (readMethod == null) {
105 System.err.println("Error occured for property '" + name + "' - no read method defined. Please contact developers.");
106 return null;
107 }
108 /* null casted to Object[] for suppresing "non-varargs call" warning */
109 result = readMethod.invoke(this,(Object[]) null);
110 } catch (IllegalArgumentException e) {
111 // TODO Auto-generated catch block
112 e.printStackTrace();
113 } catch (IllegalAccessException e) {
114 // TODO Auto-generated catch block
115 e.printStackTrace();
116 } catch (InvocationTargetException e) {
117 // TODO Auto-generated catch block
118 e.printStackTrace();
119 }
120 return result;
121 }
122
123 private String[] getPropOrder() {
124 return itemElements == null? null: (String []) itemElements.keySet().toArray(new String[itemElements.size()]);
125 }
126 void write(XMLWriter out) throws IOException {
127
128 if (itemTagName == null)
129 return;
130 out.startTag(itemTagName);
131 if (itemAttributes != null) {
132 String[] attrOrder = getAttributeProperties();
133 for (int i = 0; i < attrOrder.length; i++) {
134 out.writeAttr(itemAttributes.get(attrOrder[i]).toString(),
135 (String) getProperty(attrOrder[i]));
136 }
137 }
138 if (itemElements != null) {
139 String[] propOrder = getPropOrder();
140 for (int i = 0; i < propOrder.length; i++) {
141 Object propValue = getProperty(propOrder[i]);
142 if (propValue instanceof COFItem) {
143 COFItem item = (COFItem) propValue;
144 item.write(out);
145 continue;
146 } else if (propValue instanceof Collection) {
147 writeCollection(out, propOrder[i]);
148 continue;
149 }
150 if (propValue == null)
151 continue;
152 out.startTag(itemElements.get(propOrder[i]).toString());
153 write(out, propValue);
154 out.endTag(itemElements.get(propOrder[i]).toString());
155 }
156 }
157 out.endTag(itemTagName);
158 }
159 protected void write(XMLWriter out, Object o) throws IOException {
160 if (o instanceof String) {
161 out.write((String)o);
162 } else if (o instanceof Date) {
163 out.writeDate((Date)o);
164 } else out.write(o.toString());
165 }
166 void writeCollection(XMLWriter out, String propName) throws IOException {
167 Collection col = (Collection) getProperty(propName);
168 for (Iterator iter = col.iterator(); iter.hasNext();) {
169 Object value = iter.next();
170 if (value instanceof COFItem) {
171 ((COFItem)value).write(out);
172 } else {
173 out.startTag(itemElements.get(propName).toString());
174 write(out,value);
175 out.endTag(itemElements.get(propName).toString());
176 }
177 }
178
179 }
180
181 }
+0
-178
src/com/sun/javatest/cof/COFOS.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.util.LinkedHashMap;
29
30
31 /**
32 *
33 * OS name elements use the property os.name. OS version elements
34 * use the property os.version. OS arch elements use the property
35 * os.arch.
36 *
37 *
38 * <p>Java class for OS complex type.
39 *
40 * <p>The following schema fragment specifies the expected content contained within this class.
41 *
42 * <pre>
43 * &lt;complexType name="OS">
44 * &lt;complexContent>
45 * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
46 * &lt;sequence>
47 * &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
48 * &lt;element name="version" type="{http://www.w3.org/2001/XMLSchema}string"/>
49 * &lt;element name="arch" type="{http://www.w3.org/2001/XMLSchema}string"/>
50 * &lt;/sequence>
51 * &lt;/restriction>
52 * &lt;/complexContent>
53 * &lt;/complexType>
54 * </pre>
55 *
56 *
57 */
58 public class COFOS extends COFItem{
59
60 static final String [] propOrder = {
61 "name",
62 "version",
63 "arch"
64 };
65 static final String [] tags = {
66 "name",
67 "version",
68 "arch"
69 };
70 static LinkedHashMap xmlAttributes;
71
72 static LinkedHashMap xmlElements;
73
74 static String xmlTagName;
75
76 static {
77 xmlElements = new LinkedHashMap();
78 for (int i = 0;i<propOrder.length;i++) {
79 xmlElements.put(propOrder[i], tags[i]);
80 }
81 xmlTagName = "os";
82 }
83
84 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
85 protected String arch;
86
87 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
88 protected String name;
89
90 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
91 protected String version;
92
93 /**
94 * Gets the value of the arch property.
95 *
96 * @return
97 * possible object is
98 * {@link String }
99 *
100 */
101 public String getArch() {
102 return arch;
103 }
104
105 LinkedHashMap getItemAttributes() {
106 return xmlAttributes;
107 }
108 LinkedHashMap getItemElements() {
109 return xmlElements;
110 }
111
112 String getItemTagName() {
113 return xmlTagName;
114 }
115
116 /**
117 * Gets the value of the name property.
118 *
119 * @return
120 * possible object is
121 * {@link String }
122 *
123 */
124 public String getName() {
125 return name;
126 }
127
128 /**
129 * Gets the value of the version property.
130 *
131 * @return
132 * possible object is
133 * {@link String }
134 *
135 */
136 public String getVersion() {
137 return version;
138 }
139
140 /**
141 * Sets the value of the arch property.
142 *
143 * @param value
144 * allowed object is
145 * {@link String }
146 *
147 */
148 public void setArch(String value) {
149 this.arch = value;
150 }
151
152 /**
153 * Sets the value of the name property.
154 *
155 * @param value
156 * allowed object is
157 * {@link String }
158 *
159 */
160 public void setName(String value) {
161 this.name = value;
162 }
163
164 /**
165 * Sets the value of the version property.
166 *
167 * @param value
168 * allowed object is
169 * {@link String }
170 *
171 */
172 public void setVersion(String value) {
173 this.version = value;
174 }
175
176
177 }
+0
-160
src/com/sun/javatest/cof/COFReportAnnotation.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.util.ArrayList;
29 import java.util.LinkedHashMap;
30 import java.util.List;
31 /*import javax.xml.bind.annotation.XmlAccessType;
32 import javax.xml.bind.annotation.XmlAccessorType;
33 import javax.xml.bind.annotation.XmlElement;
34 import javax.xml.bind.annotation.XmlType;
35 */
36
37 /**
38 *
39 * Some attributes are used by the QARE test database system. One
40 * of these is the name of your testing group. The name of the
41 * annotation for this is "test_group". An example of such a group
42 * is "J2SE QA".
43 *
44 *
45 * <p>Java class for ReportAnnotation complex type.
46 *
47 * <p>The following schema fragment specifies the expected content contained within this class.
48 *
49 * <pre>
50 * &lt;complexType name="ReportAnnotation">
51 * &lt;complexContent>
52 * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
53 * &lt;sequence>
54 * &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"/>
55 * &lt;element name="value" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"/>
56 * &lt;/sequence>
57 * &lt;/restriction>
58 * &lt;/complexContent>
59 * &lt;/complexType>
60 * </pre>
61 *
62 *
63 */
64 /*@XmlAccessorType(XmlAccessType.FIELD)
65 @XmlType(name = "ReportAnnotation", propOrder = {
66 "name",
67 "value"
68 })*/
69 public class COFReportAnnotation extends COFItem{
70
71 static LinkedHashMap xmlAttributes;
72 static LinkedHashMap xmlElements;
73
74 static String xmlTagName;
75
76 static {
77 xmlElements = new LinkedHashMap();
78 xmlElements.put("name", "name");
79 xmlElements.put("value","value");
80 xmlTagName = "annotation";
81 }
82 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
83 // protected List/*<String>*/ name;
84 protected List/*<String>*/ name;
85
86 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
87 protected List/*<String>*/ value;
88
89 LinkedHashMap getItemAttributes() {
90 return xmlAttributes;
91 }
92
93 LinkedHashMap getItemElements() {
94 return xmlElements;
95 }
96
97 String getItemTagName() {
98 return xmlTagName;
99 }
100
101 /**
102 * Gets the value of the name property.
103 *
104 * <p>
105 * This accessor method returns a reference to the live list,
106 * not a snapshot. Therefore any modification you make to the
107 * returned list will be present inside the JAXB object.
108 * This is why there is not a <CODE>set</CODE> method for the name property.
109 *
110 * <p>
111 * For example, to add a new item, do as follows:
112 * <pre>
113 * getName().add(newItem);
114 * </pre>
115 *
116 *
117 * <p>
118 * Objects of the following type(s) are allowed in the list
119 * {@link String }
120 *
121 *
122 */
123 public List/*<String>*/ getName() {
124 if (name == null) {
125 name = new ArrayList/*<String>*/();
126 }
127 return this.name;
128 }
129
130 /**
131 * Gets the value of the value property.
132 *
133 * <p>
134 * This accessor method returns a reference to the live list,
135 * not a snapshot. Therefore any modification you make to the
136 * returned list will be present inside the JAXB object.
137 * This is why there is not a <CODE>set</CODE> method for the value property.
138 *
139 * <p>
140 * For example, to add a new item, do as follows:
141 * <pre>
142 * getValue().add(newItem);
143 * </pre>
144 *
145 *
146 * <p>
147 * Objects of the following type(s) are allowed in the list
148 * {@link String }
149 *
150 *
151 */
152 public List/*<String>*/ getValue() {
153 if (value == null) {
154 value = new ArrayList/*<String>*/();
155 }
156 return this.value;
157 }
158
159 }
+0
-112
src/com/sun/javatest/cof/COFReportAnnotations.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.util.ArrayList;
29 import java.util.LinkedHashMap;
30 import java.util.List;
31
32
33 /**
34 * <p>Java class for ReportAnnotations complex type.
35 *
36 * <p>The following schema fragment specifies the expected content contained within this class.
37 *
38 * <pre>
39 * &lt;complexType name="ReportAnnotations">
40 * &lt;complexContent>
41 * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
42 * &lt;sequence>
43 * &lt;element name="annotation" type="{http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema}ReportAnnotation" maxOccurs="unbounded" minOccurs="0"/>
44 * &lt;/sequence>
45 * &lt;/restriction>
46 * &lt;/complexContent>
47 * &lt;/complexType>
48 * </pre>
49 */
50 /*@XmlAccessorType(XmlAccessType.FIELD)
51 @XmlType(name = "ReportAnnotations", propOrder = {
52 "annotation"
53 })*/
54 public class COFReportAnnotations extends COFItem{
55
56 static LinkedHashMap xmlAttributes;
57 static LinkedHashMap xmlElements;
58
59 static String xmlTagName;
60
61 static {
62 xmlElements = new LinkedHashMap();
63 xmlElements.put("annotation","annotation");
64 xmlTagName = "annotations";
65 }
66
67 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
68 protected List/*<COFReportAnnotation>*/ annotation;
69
70 /**
71 * Gets the value of the annotation property.
72 *
73 * <p>
74 * This accessor method returns a reference to the live list,
75 * not a snapshot. Therefore any modification you make to the
76 * returned list will be present inside the JAXB object.
77 * This is why there is not a <CODE>set</CODE> method for the annotation property.
78 *
79 * <p>
80 * For example, to add a new item, do as follows:
81 * <pre>
82 * getAnnotation().add(newItem);
83 * </pre>
84 *
85 *
86 * <p>
87 * Objects of the following type(s) are allowed in the list
88 * {@link COFReportAnnotation }
89 *
90 *
91 */
92 public List/*<COFReportAnnotation>*/ getAnnotation() {
93 if (annotation == null) {
94 annotation = new ArrayList/*<COFReportAnnotation>*/();
95 }
96 return this.annotation;
97 }
98
99 LinkedHashMap getItemAttributes() {
100 return xmlAttributes;
101 }
102
103 LinkedHashMap getItemElements() {
104 return xmlElements;
105 }
106
107 String getItemTagName() {
108 return xmlTagName;
109 }
110
111 }
+0
-112
src/com/sun/javatest/cof/COFSWEntities.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.util.ArrayList;
29 import java.util.LinkedHashMap;
30 import java.util.List;
31
32
33 /**
34 * <p>Java class for COFSWEntities complex type.
35 *
36 * <p>The following schema fragment specifies the expected content contained within this class.
37 *
38 * <pre>
39 * &lt;complexType name="SWEntities">
40 * &lt;complexContent>
41 * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
42 * &lt;sequence>
43 * &lt;element name="swentity" type="{http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema}SWEntity" maxOccurs="unbounded"/>
44 * &lt;/sequence>
45 * &lt;/restriction>
46 * &lt;/complexContent>
47 * &lt;/complexType>
48 * </pre>
49 */
50 /*@XmlAccessorType(XmlAccessType.FIELD)
51 @XmlType(name = "SWEntities", propOrder = {
52 "swentity"
53 })*/
54 public class COFSWEntities extends COFItem {
55
56 static LinkedHashMap xmlAttributes;
57
58 static LinkedHashMap xmlElements;
59
60 static String xmlTagName;
61
62 static {
63 xmlElements = new LinkedHashMap();
64 xmlElements.put("swentity", "swentity");
65 xmlTagName = "swentities";
66 }
67
68 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
69 protected List/*<SWEntity>*/ swentity;
70
71 LinkedHashMap getItemAttributes() {
72 return xmlAttributes;
73 }
74
75 LinkedHashMap getItemElements() {
76 return xmlElements;
77 }
78 String getItemTagName() {
79 return xmlTagName;
80 }
81
82 /**
83 * Gets the value of the swentity property.
84 *
85 * <p>
86 * This accessor method returns a reference to the live list,
87 * not a snapshot. Therefore any modification you make to the
88 * returned list will be present inside the JAXB object.
89 * This is why there is not a <CODE>set</CODE> method for the swentity property.
90 *
91 * <p>
92 * For example, to add a new item, do as follows:
93 * <pre>
94 * getSwentity().add(newItem);
95 * </pre>
96 *
97 *
98 * <p>
99 * Objects of the following type(s) are allowed in the list
100 * {@link COFSWEntity }
101 *
102 *
103 */
104 public List/*<SWEntity>*/ getSwentity() {
105 if (swentity == null) {
106 swentity = new ArrayList/*<SWEntity>*/();
107 }
108 return this.swentity;
109 }
110
111 }
+0
-248
src/com/sun/javatest/cof/COFSWEntity.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.util.LinkedHashMap;
29
30 /*import javax.xml.bind.annotation.XmlAccessType;
31 import javax.xml.bind.annotation.XmlAccessorType;
32 import javax.xml.bind.annotation.XmlAttribute;
33 import javax.xml.bind.annotation.XmlElement;
34 import javax.xml.bind.annotation.XmlType;
35 */
36
37 /**
38 *
39 * Software is tracked in the hardware/software database that backs
40 * up the COF XML. The elements in the SW type map to fields in the
41 * software table of that database. Type is enumerated. See below.
42 * Name is a product name with no version string. For example,
43 * "Tomcat". Version is a product version. For instance, "8i".
44 *
45 *
46 * <p>Java class for SWEntity complex type.
47 *
48 * <p>The following schema fragment specifies the expected content contained within this class.
49 *
50 * <pre>
51 * &lt;complexType name="SWEntity">
52 * &lt;complexContent>
53 * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
54 * &lt;sequence>
55 * &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
56 * &lt;element name="type">
57 * &lt;simpleType>
58 * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
59 * &lt;enumeration value="appserver"/>
60 * &lt;enumeration value="browser"/>
61 * &lt;enumeration value="database"/>
62 * &lt;enumeration value="editor"/>
63 * &lt;enumeration value="java"/>
64 * &lt;enumeration value="webserver"/>
65 * &lt;/restriction>
66 * &lt;/simpleType>
67 * &lt;/element>
68 * &lt;element name="version" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
69 * &lt;element name="description" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
70 * &lt;/sequence>
71 * &lt;attribute name="id" use="required" type="{http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema}IDWithColon" />
72 * &lt;/restriction>
73 * &lt;/complexContent>
74 * &lt;/complexType>
75 * </pre>
76 *
77 *
78 */
79 /*@XmlAccessorType(XmlAccessType.FIELD)
80 @XmlType(name = "SWEntity", propOrder = {
81 "name",
82 "type",
83 "version",
84 "description"
85 })*/
86 public class COFSWEntity extends COFItem{
87
88 static LinkedHashMap xmlAttributes;
89 static LinkedHashMap xmlElements;
90 static String xmlTagName;
91 static {
92 xmlTagName = "swentity";
93 xmlElements = new LinkedHashMap();
94 xmlElements.put("name","name");
95 xmlElements.put("type","type");
96 xmlElements.put("version","version");
97 xmlElements.put("description","description");
98 xmlAttributes = new LinkedHashMap();
99 xmlAttributes.put("id","id");
100 }
101 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
102 protected String description;
103
104 // @XmlAttribute(required = true)
105 protected String id="swentity:0";
106
107 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
108 protected String name;
109
110 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
111 protected String type;
112
113 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
114 protected String version;
115
116 /**
117 * Gets the value of the description property.
118 *
119 * @return
120 * possible object is
121 * {@link String }
122 *
123 */
124 public String getDescription() {
125 return description;
126 }
127
128 /**
129 * Gets the value of the id property.
130 *
131 * @return
132 * possible object is
133 * {@link String }
134 *
135 */
136 public String getId() {
137 return id;
138 }
139
140 LinkedHashMap getItemAttributes() {
141 return xmlAttributes;
142 }
143
144 LinkedHashMap getItemElements() {
145 return xmlElements;
146 }
147
148 String getItemTagName() {
149 return xmlTagName;
150 }
151
152 /**
153 * Gets the value of the name property.
154 *
155 * @return
156 * possible object is
157 * {@link String }
158 *
159 */
160 public String getName() {
161 return name;
162 }
163
164 /**
165 * Gets the value of the type property.
166 *
167 * @return
168 * possible object is
169 * {@link String }
170 *
171 */
172 public String getType() {
173 return type;
174 }
175
176 /**
177 * Gets the value of the version property.
178 *
179 * @return
180 * possible object is
181 * {@link String }
182 *
183 */
184 public String getVersion() {
185 return version;
186 }
187
188 /**
189 * Sets the value of the description property.
190 *
191 * @param value
192 * allowed object is
193 * {@link String }
194 *
195 */
196 public void setDescription(String value) {
197 this.description = value;
198 }
199
200 /**
201 * Sets the value of the id property.
202 *
203 * @param value
204 * allowed object is
205 * {@link String }
206 *
207 */
208 public void setId(String value) {
209 this.id = value;
210 }
211
212 /**
213 * Sets the value of the name property.
214 *
215 * @param value
216 * allowed object is
217 * {@link String }
218 *
219 */
220 public void setName(String value) {
221 this.name = value;
222 }
223
224 /**
225 * Sets the value of the type property.
226 *
227 * @param value
228 * allowed object is
229 * {@link String }
230 *
231 */
232 public void setType(String value) {
233 this.type = value;
234 }
235 /**
236 * Sets the value of the version property.
237 *
238 * @param value
239 * allowed object is
240 * {@link String }
241 *
242 */
243 public void setVersion(String value) {
244 this.version = value;
245 }
246
247 }
+0
-189
src/com/sun/javatest/cof/COFStatus.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.util.LinkedHashMap;
29
30 /*import javax.xml.bind.annotation.XmlAccessType;
31 import javax.xml.bind.annotation.XmlAccessorType;
32 import javax.xml.bind.annotation.XmlAttribute;
33 import javax.xml.bind.annotation.XmlElement;
34 import javax.xml.bind.annotation.XmlType;*/
35
36
37 /**
38 *
39 * Actual elements contain text that refers to an actual value.
40 * This can be anything. A header, value, body, ..... If the tag
41 * log appears, it may be understood that a URL of a log file will
42 * appear as the PCDATA for this tag. If present, that URL uses
43 * either http or file protocol. If http protocol, the server name
44 * will be fully qualified. If file protocol, the full path
45 * beginning with /net will be expected. Microsoft file mapping or
46 * Unix automounts should not be used.
47 * <p>Java class for Status complex type.
48 *
49 * <p>The following schema fragment specifies the expected content contained within this class.
50 *
51 * <pre>
52 * &lt;complexType name="Status">
53 * &lt;complexContent>
54 * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
55 * &lt;sequence minOccurs="0">
56 * &lt;element name="expected" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
57 * &lt;element name="actual" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
58 * &lt;/sequence>
59 * &lt;attribute name="value" use="required">
60 * &lt;simpleType>
61 * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
62 * &lt;enumeration value="pass"/>
63 * &lt;enumeration value="fail"/>
64 * &lt;enumeration value="ambiguous"/>
65 * &lt;enumeration value="error"/>
66 * &lt;enumeration value="vm_fail"/>
67 * &lt;enumeration value="did_not_run"/>
68 * &lt;/restriction>
69 * &lt;/simpleType>
70 * &lt;/attribute>
71 * &lt;/restriction>
72 * &lt;/complexContent>
73 * &lt;/complexType>
74 * </pre>
75 */
76 /*@XmlAccessorType(XmlAccessType.FIELD)
77 @XmlType(name = "Status", propOrder = {
78 "expected",
79 "actual"
80 })*/
81 public class COFStatus extends COFItem{
82
83 static LinkedHashMap xmlAttributes;
84 static LinkedHashMap xmlElements;
85 static String xmlTagName;
86
87 static {
88 xmlElements = new LinkedHashMap();
89 xmlAttributes = new LinkedHashMap();
90 xmlElements.put("expected","expected");
91 xmlElements.put("actual","actual");
92 xmlAttributes.put("value","value");
93 xmlTagName = "status";
94 }
95
96 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
97 protected String actual;
98
99 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
100 protected String expected;
101
102 // @XmlAttribute(required = true)
103 protected String value;
104
105 /**
106 * Gets the value of the actual property.
107 *
108 * @return
109 * possible object is
110 * {@link String }
111 *
112 */
113 public String getActual() {
114 return actual;
115 }
116
117 /**
118 * Gets the value of the expected property.
119 *
120 * @return
121 * possible object is
122 * {@link String }
123 *
124 */
125 public String getExpected() {
126 return expected;
127 }
128 LinkedHashMap getItemAttributes() {
129 return xmlAttributes;
130 }
131
132 LinkedHashMap getItemElements() {
133 return xmlElements;
134 }
135
136 String getItemTagName() {
137 return xmlTagName;
138 }
139
140 /**
141 * Gets the value of the value property.
142 *
143 * @return
144 * possible object is
145 * {@link String }
146 *
147 */
148 public String getValue() {
149 return value;
150 }
151
152 /**
153 * Sets the value of the actual property.
154 *
155 * @param value
156 * allowed object is
157 * {@link String }
158 *
159 */
160 public void setActual(String value) {
161 this.actual = value;
162 }
163
164 /**
165 * Sets the value of the expected property.
166 *
167 * @param value
168 * allowed object is
169 * {@link String }
170 *
171 */
172 public void setExpected(String value) {
173 this.expected = value;
174 }
175
176 /**
177 * Sets the value of the value property.
178 *
179 * @param value
180 * allowed object is
181 * {@link String }
182 *
183 */
184 public void setValue(String value) {
185 this.value = value;
186 }
187
188 }
+0
-631
src/com/sun/javatest/cof/COFTest.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.io.BufferedReader;
29 import java.io.File;
30 import java.io.IOException;
31 import java.io.StringReader;
32 import java.text.DateFormat;
33 import java.text.ParseException;
34 import java.text.SimpleDateFormat;
35 import java.util.ArrayList;
36 import java.util.Date;
37 import java.util.LinkedHashMap;
38 import java.util.List;
39 import java.util.Vector;
40 import java.util.regex.Matcher;
41 import java.util.regex.Pattern;
42
43 import com.sun.javatest.Status;
44 import com.sun.javatest.TestResult;
45 import com.sun.javatest.TestResult.ReloadFault;
46 import com.sun.javatest.TestResult.ResultFileNotFoundFault;
47 import java.util.Iterator;
48
49 /*import javax.xml.bind.annotation.XmlAccessType;
50 import javax.xml.bind.annotation.XmlAccessorType;
51 import javax.xml.bind.annotation.XmlAttribute;
52 import javax.xml.bind.annotation.XmlElement;
53 import javax.xml.bind.annotation.XmlType;
54 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
55 */
56 /**
57 *
58 * The analysis setting is meant to allow remote groups to waive or
59 * accept the pass/fail status of the test using E-mail. For
60 * testcases, the analysis setting provides a default value to
61 * apply to the analysis the setting for all testcase results for
62 * this test.
63 *
64 *
65 * <p>Java class for Test complex type.
66 *
67 * <p>The following schema fragment specifies the expected content contained within this class.
68 *
69 * <pre>
70 * &lt;complexType name="Test">
71 * &lt;complexContent>
72 * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
73 * &lt;sequence>
74 * &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
75 * &lt;element name="appuse" type="{http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema}IDWithColon" maxOccurs="unbounded" minOccurs="0"/>
76 * &lt;element name="status" type="{http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema}Status" minOccurs="0"/>
77 * &lt;element name="testcases" type="{http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema}TestCases" minOccurs="0"/>
78 * &lt;element name="starttime" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
79 * &lt;element name="endtime" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
80 * &lt;element name="attributes" type="{http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema}TestAttributes" minOccurs="0"/>
81 * &lt;element name="description" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
82 * &lt;/sequence>
83 * &lt;attribute name="analysis" default="accept">
84 * &lt;simpleType>
85 * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
86 * &lt;enumeration value="accept"/>
87 * &lt;enumeration value="waive"/>
88 * &lt;/restriction>
89 * &lt;/simpleType>
90 * &lt;/attribute>
91 * &lt;attribute name="id" use="required" type="{http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema}IDWithColon" />
92 * &lt;/restriction>
93 * &lt;/complexContent>
94 * &lt;/complexType>
95 * </pre>
96 */
97 /*@XmlAccessorType(XmlAccessType.FIELD)
98 @XmlType(name = "Test", propOrder = {
99 "name",
100 "appuse",
101 "status",
102 "testcases",
103 "starttime",
104 "endtime",
105 "attributes",
106 "description"
107 })*/
108 public class COFTest extends COFItem {
109
110 private static final Date badDate = new Date(0);
111 private static final String[] cofStatus = new String[Status.NUM_STATES];
112 static long count = 0;
113 private static DateFormat[] dateFormats;
114 protected final static Pattern idPattern = Pattern.compile(".*[^\\w\\.\\[\\]\\(\\)\\{\\},_\\-]([\\w\\.\\[\\]\\(\\)\\{\\},_\\-]+)");
115 static boolean noTestCases = false;
116 protected final static Pattern testCasePattern = Pattern //.compile("^(\\S+): (Passed\\.|Failed\\.|Error\\.|Not\\ run\\.)(.*)");
117 .compile("^(.*): (Passed\\.|Failed\\.|Error\\.|Not\\ run\\.)(.*)");
118 static LinkedHashMap xmlAttributes;
119 static LinkedHashMap xmlElements;
120 static String xmlTagName;
121
122 static {
123 xmlElements = new LinkedHashMap();
124 xmlAttributes = new LinkedHashMap();
125 xmlElements.put("name", "name");
126 xmlElements.put("appuse", "appuse");
127 xmlElements.put("status", "status");
128 xmlElements.put("testcases", "testcases");
129 xmlElements.put("starttime", "starttime");
130 xmlElements.put("endtime", "endtime");
131 xmlElements.put("attributes", "attributes");
132 xmlElements.put("description", "description");
133 // xmlAttributes.put("analysis", "analysis");
134 xmlAttributes.put("id", "id");
135 xmlTagName = "test";
136
137 initDateFormats();
138 }
139
140 static {
141 cofStatus[Status.PASSED] = "pass";
142 cofStatus[Status.FAILED] = "fail";
143 cofStatus[Status.ERROR] = "error";
144 cofStatus[Status.NOT_RUN] = "did_not_run";
145 }
146 // @XmlAttribute
147 protected String analysis;
148 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
149 protected List/*<String>*/ appuse;
150 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
151 protected COFTestAttributes attributes;
152 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
153 protected String description;
154 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", type = String.class)
155 // @XmlJavaTypeAdapter(Adapter1 .class)
156 protected Date endtime;
157 // @XmlAttribute(required = true)
158 protected String id;
159 final long idNum = count++;
160 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
161 protected String name;
162 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", type = String.class)
163 // @XmlJavaTypeAdapter(Adapter1 .class)
164 protected Date starttime;
165 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
166 protected COFStatus status;
167 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
168 protected COFTestCases testcases;
169 private COFData cofData;
170
171 COFTest(TestResult tr, COFData data) {
172 cofData = data;
173 status = new COFStatus();
174 status.setValue(cofStatus[tr.getStatus().getType()]);
175 status.setActual(tr.getStatus().getReason());
176 fillTestCases(tr);
177 //if (tr.getStatus().isError() || tr.getStatus().isFailed()) {
178 checkLostTestCases(tr);
179 //}
180 setName(tr.getTestName());
181 if (!tr.getStatus().isNotRun()) {
182 setStarttime(parseDate(tr, TestResult.START));
183 setEndtime(parseDate(tr, TestResult.END));
184 }
185 attributes = new COFTestAttributes();
186 attributes.getAttribute().add(
187 new COFTestAttribute("logfile", tr.getWorkRelativePath()));
188 if (data.isInterviewParametersAvailable()) {
189 try {
190 if (!data.getInterviewParameters().getExcludeListFilter().accepts(tr.getDescription())) {
191 attributes.getAttribute().add(new COFTestAttribute("isOnExcludeList", "true"));
192 }
193 } catch(Exception e) {
194 }
195 }
196 String jo = cofData.get("jvmopt", null);
197 if (jo != null) {
198 attributes.getAttribute().add(new COFTestAttribute("javaopt", jo));
199 }
200
201 }
202
203 protected void fillTestCases(TestResult tr) {
204 if (noTestCases) {
205 return;
206 }
207 testcases = new COFTestCases();
208 int sCount = tr.getSectionCount();
209 if (sCount == 0 && tr.getStatus().getType() != Status.NOT_RUN) {
210 try {
211 tr = new TestResult(new File(cofData.get("workdir") + File.separator + tr.getWorkRelativePath()));
212 sCount = tr.getSectionCount();
213 } catch (ResultFileNotFoundFault e) {
214 // warning is out from somewhere else, but again
215 System.err.println(e.getMessage());
216 } catch (ReloadFault e) {
217 System.err.println(tr.getFile());
218 }
219 }
220 for (int i = 0; i < sCount; i++) {
221 try {
222 String sectionOut = tr.getSection(i).getOutput("out1");
223 if (sectionOut == null) {
224 continue;
225 }
226 BufferedReader reader = new BufferedReader(new StringReader(
227 sectionOut));
228 String s = reader.readLine();
229 while (s != null) {
230 Matcher m = testCasePattern.matcher(s);
231 if (m.matches()) {
232 COFTestCase tc = new COFTestCase();
233 COFStatus cStatus = new COFStatus();
234 String tcName = fixIncorrectTestCaseName(m.group(1));
235 if (tcName == null) {
236 s = reader.readLine();
237 continue;
238 }
239 tc.setName(tcName);
240 cStatus.setValue(cofStatus[Status.parse(m.group(2)).getType()]);
241 cStatus.setActual(m.group(3));
242 tc.setStatus(cStatus);
243 testcases.getTestcase().add(tc);
244 }
245 s = reader.readLine();
246 }
247 } catch (ReloadFault e) {
248 // TODO Auto-generated catch block
249 e.printStackTrace();
250 } catch (IOException e) {
251 // TODO Auto-generated catch block
252 e.printStackTrace();
253 }
254 }
255 }
256
257 private void checkLostTestCases(TestResult tr) {
258 MTL mtl = cofData.getMtl();
259
260 if (mtl == null) {
261 // mtl is not specified
262 return;
263 }
264
265 List /*<COFTestCase>*/ jtrCases = testcases.getTestcase();
266 List /*<String>*/ mtlTestCases = mtl.getTestCases(tr.getTestName());
267 if (mtlTestCases != null && mtlTestCases.size() > 0) {
268 // for (COFTestCase jtrCase : jtrCases) {
269 Iterator it = jtrCases.iterator();
270 while (it.hasNext()) {
271 COFTestCase jtrCase = (COFTestCase) it.next();
272 mtlTestCases.remove(jtrCase.name);
273 }
274 if (mtlTestCases.size() > 0) {
275 //for (String testCaseName : mtlTestCases) {
276 it = mtlTestCases.iterator();
277 while(it.hasNext()) {
278 String testCaseName = (String) it.next();
279 COFTestCase nTc = new COFTestCase();
280 COFStatus nStatus = new COFStatus();
281 nTc.setName(testCaseName);
282 String strS = cofStatus[tr.getStatus().getType()];
283 nStatus.setValue(strS);
284 //System.out.println("+ " + tr.getTestName() + " " + tcName + " " + strS );
285 testcases.getTestcase().add(testCaseName);
286 }
287 }
288 }
289 }
290
291 /**
292 * Gets the value of the analysis property.
293 *
294 * @return
295 * possible object is
296 * {@link String }
297 *
298 */
299 public String getAnalysis() {
300 if (analysis == null) {
301 return "accept";
302 } else {
303 return analysis;
304 }
305 }
306
307 /**
308 * Gets the value of the appuse property.
309 *
310 * <p>
311 * This accessor method returns a reference to the live list,
312 * not a snapshot. Therefore any modification you make to the
313 * returned list will be present inside the JAXB object.
314 * This is why there is not a <CODE>set</CODE> method for the appuse property.
315 *
316 * <p>
317 * For example, to add a new item, do as follows:
318 * <pre>
319 * getAppuse().add(newItem);
320 * </pre>
321 *
322 *
323 * <p>
324 * Objects of the following type(s) are allowed in the list
325 * {@link String }
326 *
327 *
328 */
329 public List/*<String>*/ getAppuse() {
330 if (appuse == null) {
331 appuse = new ArrayList/*<String>*/();
332 }
333 return this.appuse;
334 }
335
336 /**
337 * Gets the value of the attributes property.
338 *
339 * @return
340 * possible object is
341 * {@link COFTestAttributes }
342 *
343 */
344 public COFTestAttributes getAttributes() {
345 return attributes;
346 }
347
348 /**
349 * Gets the value of the description property.
350 *
351 * @return
352 * possible object is
353 * {@link String }
354 *
355 */
356 public String getDescription() {
357 return description;
358 }
359
360 /**
361 * Gets the value of the endtime property.
362 *
363 * @return
364 * possible object is
365 * {@link String }
366 *
367 */
368 public Date getEndtime() {
369 return endtime;
370 }
371
372 /**
373 * Gets the value of the id property.
374 *
375 * @return
376 * possible object is
377 * {@link String }
378 *
379 */
380 public String getId() {
381 if (id != null) {
382 return id;
383 }
384 if (name == null) {
385 throw new IllegalStateException("Name was not set.");
386 }
387 Matcher m = idPattern.matcher(name);
388 if (m.matches()) {
389 id = m.group(1) + ":" + idNum;
390 } else {
391 id = "test:" + idNum;
392 }
393 return id;
394 }
395
396 LinkedHashMap getItemAttributes() {
397 return xmlAttributes;
398 }
399
400 LinkedHashMap getItemElements() {
401 return xmlElements;
402 }
403
404 String getItemTagName() {
405 return xmlTagName;
406 }
407
408 /**
409 * Gets the value of the name property.
410 *
411 * @return
412 * possible object is
413 * {@link String }
414 *
415 */
416 public String getName() {
417 return name;
418 }
419
420 /**
421 * Gets the value of the starttime property.
422 *
423 * @return
424 * possible object is
425 * {@link String }
426 *
427 */
428 public Date getStarttime() {
429 return starttime;
430 }
431
432 /**
433 * Gets the value of the status property.
434 *
435 * @return
436 * possible object is
437 * {@link COFStatus }
438 *
439 */
440 public COFStatus getStatus() {
441 return status;
442 }
443
444 /**
445 * Gets the value of the testcases property.
446 *
447 * @return
448 * possible object is
449 * {@link COFTestCases }
450 *
451 */
452 public COFTestCases getTestcases() {
453 return testcases;
454 }
455
456 /**
457 * Sets the value of the id property.
458 *
459 * @param value
460 * allowed object is
461 * {@link String }
462 *
463 */
464 // public void setId(String value) {
465 // this.id = value;
466 // }
467 private static void initDateFormats() {
468 Vector v = new Vector();
469
470 // generic Java default
471 // 10-Sep-99 3:25:11 PM
472 v.addElement(DateFormat.getDateTimeInstance());
473
474 // standard IETF date syntax
475 // Fri, 10 September 1999 03:25:12 PDT
476 v.addElement(new SimpleDateFormat("EEE, dd MMMM yyyy HH:mm:ss zzz"));
477
478 // Unix C time
479 // Fri Sep 10 14:41:37 PDT 1999
480 v.addElement(new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy"));
481
482 // XML time
483 // 1999-09-10T03:25:12.123 (ISO 8601, sect 5.4)
484 v.addElement(new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSS"));
485
486 // allow user-specified format
487 String s = System.getProperty("javatest.date.format");
488 if (s != null) {
489 v.addElement(new SimpleDateFormat(s));
490 }
491
492 dateFormats = new DateFormat[v.size()];
493 v.copyInto(dateFormats);
494 }
495
496 private static Date parseDate(String s) {
497 for (int i = 0; i < dateFormats.length; i++) {
498 try {
499 Date d = dateFormats[i].parse(s);
500 // successfully parsed the date; shuffle the format to the front
501 // to speed up future parses, assuming dates will likely be similar
502 if (i > 0) {
503 DateFormat tmp = dateFormats[i];
504 System.arraycopy(dateFormats, 0, dateFormats, 1, i);
505 dateFormats[0] = tmp;
506 }
507 return d;
508 } catch (ParseException e) {
509 //System.err.println("pattern: " + ((SimpleDateFormat)dateFormats[i]).toPattern());
510 //System.err.println(" value: " + s);
511 //System.err.println("example: " + dateFormats[i].format(new Date()));
512 }
513 }
514
515 return badDate;
516 }
517
518 private static Date parseDate(TestResult tr, String key) {
519 try {
520 String s = tr.getProperty(key);
521 if (s != null && s.length() > 0) {
522 return parseDate(s);
523 }
524 } catch (TestResult.Fault e) {
525 System.err.println(e);
526 }
527 // default, if no entry in test result, or if error reloading test result
528 return badDate;
529 }
530
531 /**
532 * Sets the value of the analysis property.
533 *
534 * @param value
535 * allowed object is
536 * {@link String }
537 *
538 */
539 public void setAnalysis(String value) {
540 this.analysis = value;
541 }
542
543 /**
544 * Sets the value of the attributes property.
545 *
546 * @param value
547 * allowed object is
548 * {@link COFTestAttributes }
549 *
550 */
551 public void setAttributes(COFTestAttributes value) {
552 this.attributes = value;
553 }
554
555 /**
556 * Sets the value of the description property.
557 *
558 * @param value
559 * allowed object is
560 * {@link String }
561 *
562 */
563 public void setDescription(String value) {
564 this.description = value;
565 }
566
567 /**
568 * Sets the value of the endtime property.
569 *
570 * @param value
571 * allowed object is
572 * {@link String }
573 *
574 */
575 public void setEndtime(Date value) {
576 this.endtime = value;
577 }
578
579 /**
580 * Sets the value of the name property.
581 *
582 * @param value
583 * allowed object is
584 * {@link String }
585 *
586 */
587 public void setName(String value) {
588 this.name = value;
589 }
590
591 /**
592 * Sets the value of the starttime property.
593 *
594 * @param value
595 * allowed object is
596 * {@link String }
597 *
598 */
599 public void setStarttime(Date value) {
600 this.starttime = value;
601 }
602
603 /**
604 * Sets the value of the status property.
605 *
606 * @param value
607 * allowed object is
608 * {@link COFStatus }
609 *
610 */
611 public void setStatus(COFStatus value) {
612 this.status = value;
613 }
614
615 /**
616 * Sets the value of the testcases property.
617 *
618 * @param value
619 * allowed object is
620 * {@link COFTestCases }
621 *
622 */
623 public void setTestcases(COFTestCases value) {
624 this.testcases = value;
625 }
626
627 private String fixIncorrectTestCaseName(String tcn) {
628 return cofData.getCustomFilter().transformTestCaseName(tcn);
629 }
630 }
+0
-181
src/com/sun/javatest/cof/COFTestAttribute.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.util.ArrayList;
29 import java.util.LinkedHashMap;
30 import java.util.List;
31 /*import javax.xml.bind.annotation.XmlAccessType;
32 import javax.xml.bind.annotation.XmlAccessorType;
33 import javax.xml.bind.annotation.XmlElement;
34 import javax.xml.bind.annotation.XmlType;
35 */
36
37 /**
38 *
39 * In general, a Java command line flag argument that it is agreed
40 * will get tracked as an attribute, say -foo,will get tracked by a
41 * test attribute
42 *
43 * <pre>
44 * &lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;name xmlns:cof="http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;foo&lt;/name&gt;
45 * </pre>
46 *
47 * without a corresponding value element. A Java command line
48 * argument pair "-foo bar" will get tracked by a test attribute
49 *
50 * <pre>
51 * &lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;name xmlns:cof="http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;foo&lt;/name&gt;
52 * </pre>
53 *
54 * <pre>
55 * &lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;value xmlns:cof="http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;bar&lt;/value&gt;
56 * </pre>
57 *
58 * .
59 *
60 *
61 * <p>Java class for TestAttribute complex type.
62 *
63 * <p>The following schema fragment specifies the expected content contained within this class.
64 *
65 * <pre>
66 * &lt;complexType name="TestAttribute">
67 * &lt;complexContent>
68 * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
69 * &lt;sequence>
70 * &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"/>
71 * &lt;element name="value" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
72 * &lt;/sequence>
73 * &lt;/restriction>
74 * &lt;/complexContent>
75 * &lt;/complexType>
76 * </pre>
77 *
78 *
79 */
80 /*@XmlAccessorType(XmlAccessType.FIELD)
81 @XmlType(name = "TestAttribute", propOrder = {
82 "name",
83 "value"
84 })*/
85 public class COFTestAttribute extends COFItem{
86
87 static LinkedHashMap xmlAttributes;
88 static LinkedHashMap xmlElements;
89
90 static String xmlTagName;
91
92 static {
93 xmlElements = new LinkedHashMap();
94 xmlElements.put("name","name");
95 xmlElements.put("value","value");
96 xmlTagName = "attribute";
97 }
98
99 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
100 protected List/*<String>*/ name;
101
102 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
103 protected List/*<String>*/ value;
104
105 public COFTestAttribute(String name, String value) {
106 this.getName().add(name);
107 this.getValue().add(value);
108 }
109
110 LinkedHashMap getItemAttributes() {
111 return xmlAttributes;
112 }
113
114 LinkedHashMap getItemElements() {
115 return xmlElements;
116 }
117
118 String getItemTagName() {
119 return xmlTagName;
120 }
121
122 /**
123 * Gets the value of the name property.
124 *
125 * <p>
126 * This accessor method returns a reference to the live list,
127 * not a snapshot. Therefore any modification you make to the
128 * returned list will be present inside the JAXB object.
129 * This is why there is not a <CODE>set</CODE> method for the name property.
130 *
131 * <p>
132 * For example, to add a new item, do as follows:
133 * <pre>
134 * getName().add(newItem);
135 * </pre>
136 *
137 *
138 * <p>
139 * Objects of the following type(s) are allowed in the list
140 * {@link String }
141 *
142 *
143 */
144 public List/*<String>*/ getName() {
145 if (name == null) {
146 name = new ArrayList/*<String>*/();
147 }
148 return this.name;
149 }
150
151 /**
152 * Gets the value of the value property.
153 *
154 * <p>
155 * This accessor method returns a reference to the live list,
156 * not a snapshot. Therefore any modification you make to the
157 * returned list will be present inside the JAXB object.
158 * This is why there is not a <CODE>set</CODE> method for the value property.
159 *
160 * <p>
161 * For example, to add a new item, do as follows:
162 * <pre>
163 * getValue().add(newItem);
164 * </pre>
165 *
166 *
167 * <p>
168 * Objects of the following type(s) are allowed in the list
169 * {@link String }
170 *
171 *
172 */
173 public List/*<String>*/ getValue() {
174 if (value == null) {
175 value = new ArrayList/*<String>*/();
176 }
177 return this.value;
178 }
179
180 }
+0
-116
src/com/sun/javatest/cof/COFTestAttributes.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.util.ArrayList;
29 import java.util.LinkedHashMap;
30 import java.util.List;
31 /*import javax.xml.bind.annotation.XmlAccessType;
32 import javax.xml.bind.annotation.XmlAccessorType;
33 import javax.xml.bind.annotation.XmlElement;
34 import javax.xml.bind.annotation.XmlType;
35 */
36
37 /**
38 * <p>Java class for TestAttributes complex type.
39 *
40 * <p>The following schema fragment specifies the expected content contained within this class.
41 *
42 * <pre>
43 * &lt;complexType name="TestAttributes">
44 * &lt;complexContent>
45 * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
46 * &lt;sequence>
47 * &lt;element name="attribute" type="{http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema}TestAttribute" maxOccurs="unbounded"/>
48 * &lt;/sequence>
49 * &lt;/restriction>
50 * &lt;/complexContent>
51 * &lt;/complexType>
52 * </pre>
53 *
54 *
55 */
56 /*@XmlAccessorType(XmlAccessType.FIELD)
57 @XmlType(name = "TestAttributes", propOrder = {
58 "attribute"
59 })*/
60 public class COFTestAttributes extends COFItem{
61
62 static LinkedHashMap xmlAttributes;
63
64 static LinkedHashMap xmlElements;
65 static String xmlTagName;
66
67 static {
68 xmlTagName = "attributes";
69 xmlElements = new LinkedHashMap();
70 xmlElements.put("attribute","attribute");
71 }
72
73 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
74 protected List/*<COFTestAttribute>*/ attribute;
75
76 /**
77 * Gets the value of the attribute property.
78 *
79 * <p>
80 * This accessor method returns a reference to the live list,
81 * not a snapshot. Therefore any modification you make to the
82 * returned list will be present inside the JAXB object.
83 * This is why there is not a <CODE>set</CODE> method for the attribute property.
84 *
85 * <p>
86 * For example, to add a new item, do as follows:
87 * <pre>
88 * getAttribute().add(newItem);
89 * </pre>
90 *
91 *
92 * <p>
93 * Objects of the following type(s) are allowed in the list
94 * {@link COFTestAttribute }
95 *
96 *
97 */
98 public List/*<COFTestAttribute>*/ getAttribute() {
99 if (attribute == null) {
100 attribute = new ArrayList/*<COFTestAttribute>*/();
101 }
102 return this.attribute;
103 }
104
105 LinkedHashMap getItemAttributes() {
106 return xmlAttributes;
107 }
108
109 LinkedHashMap getItemElements() {
110 return xmlElements;
111 }
112 String getItemTagName() {
113 return xmlTagName;
114 }
115 }
+0
-344
src/com/sun/javatest/cof/COFTestCase.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.io.IOException;
29 import java.util.Date;
30 import java.util.LinkedHashMap;
31
32 import com.sun.javatest.util.XMLWriter;
33
34 /*import javax.xml.bind.annotation.XmlAccessType;
35 import javax.xml.bind.annotation.XmlAccessorType;
36 import javax.xml.bind.annotation.XmlAttribute;
37 import javax.xml.bind.annotation.XmlElement;
38 import javax.xml.bind.annotation.XmlType;
39 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
40 */
41
42 /**
43 *
44 * The analysis setting is meant to allow remote groups to waive or
45 * accept the pass/fail status of the test using E-mail.
46 *
47 *
48 * <p>Java class for TestCase complex type.
49 *
50 * <p>The following schema fragment specifies the expected content contained within this class.
51 *
52 * <pre>
53 * &lt;complexType name="TestCase">
54 * &lt;complexContent>
55 * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
56 * &lt;sequence>
57 * &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
58 * &lt;element name="status" type="{http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema}Status" minOccurs="0"/>
59 * &lt;element name="starttime" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
60 * &lt;element name="endtime" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
61 * &lt;element name="attributes" type="{http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema}TestAttributes" minOccurs="0"/>
62 * &lt;element name="description" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
63 * &lt;/sequence>
64 * &lt;attribute name="analysis" default="accept">
65 * &lt;simpleType>
66 * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
67 * &lt;enumeration value="accept"/>
68 * &lt;enumeration value="waive"/>
69 * &lt;/restriction>
70 * &lt;/simpleType>
71 * &lt;/attribute>
72 * &lt;attribute name="id" use="required" type="{http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema}IDWithColon" />
73 * &lt;/restriction>
74 * &lt;/complexContent>
75 * &lt;/complexType>
76 * </pre>
77 *
78 *
79 */
80 /*@XmlAccessorType(XmlAccessType.FIELD)
81 @XmlType(name = "TestCase", propOrder = {
82 "name",
83 "status",
84 "starttime",
85 "endtime",
86 "attributes",
87 "description"
88 })*/
89 public class COFTestCase extends COFItem {
90 static long count = 0;
91
92 static LinkedHashMap xmlAttributes;
93
94 static LinkedHashMap xmlElements;
95
96 static String xmlTagName;
97
98 static {
99 xmlTagName = "testcase";
100 xmlElements = new LinkedHashMap();
101 xmlElements.put("name", "name");
102 xmlElements.put("status", "status");
103 xmlElements.put("starttime", "starttime");
104 xmlElements.put("endtime", "endtime");
105 xmlElements.put("attributes", "attributes");
106 xmlElements.put("description", "description");
107 xmlAttributes = new LinkedHashMap();
108 xmlAttributes.put("id", "id");
109 // xmlAttributes.put("analysis", "analysis");
110 }
111
112 // @XmlAttribute
113 protected String analysis;
114
115 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
116 protected COFTestAttributes attributes;
117
118 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
119 protected String description;
120
121 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", type = String.class)
122 // @XmlJavaTypeAdapter(Adapter1 .class)
123 protected Date endtime;
124
125 // @XmlAttribute(required = true)
126 protected String id;
127
128 final long idNum = count++;
129
130 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
131 protected String name;
132
133 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", type = String.class)
134 // @XmlJavaTypeAdapter(Adapter1 .class)
135 protected Date starttime;
136
137 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
138 protected COFStatus status;
139
140 /**
141 * Gets the value of the analysis property.
142 *
143 * @return
144 * possible object is
145 * {@link String }
146 *
147 */
148 public String getAnalysis() {
149 if (analysis == null) {
150 return "accept";
151 } else {
152 return analysis;
153 }
154 }
155
156 /**
157 * Gets the value of the attributes property.
158 *
159 * @return
160 * possible object is
161 * {@link COFTestAttributes }
162 *
163 */
164 public COFTestAttributes getAttributes() {
165 return attributes;
166 }
167
168 /**
169 * Gets the value of the description property.
170 *
171 * @return
172 * possible object is
173 * {@link String }
174 *
175 */
176 public String getDescription() {
177 return description;
178 }
179
180 /**
181 * Gets the value of the endtime property.
182 *
183 * @return
184 * possible object is
185 * {@link String }
186 *
187 */
188 public Date getEndtime() {
189 return endtime;
190 }
191
192 /**
193 * Gets the value of the id property.
194 *
195 * @return
196 * possible object is
197 * {@link String }
198 *
199 */
200 public String getId() {
201 return name + ":" + idNum;
202 }
203
204 LinkedHashMap getItemAttributes() {
205 return xmlAttributes;
206 }
207
208 LinkedHashMap getItemElements() {
209 return xmlElements;
210 }
211
212 String getItemTagName() {
213 return xmlTagName;
214 }
215
216 /**
217 * Gets the value of the name property.
218 *
219 * @return
220 * possible object is
221 * {@link String }
222 *
223 */
224 public String getName() {
225 return name;
226 }
227
228 /**
229 * Gets the value of the starttime property.
230 *
231 * @return
232 * possible object is
233 * {@link String }
234 *
235 */
236 public Date getStarttime() {
237 return starttime;
238 }
239
240 /**
241 * Gets the value of the status property.
242 *
243 * @return
244 * possible object is
245 * {@link COFStatus }
246 *
247 */
248 public COFStatus getStatus() {
249 return status;
250 }
251
252 /**
253 * Sets the value of the analysis property.
254 *
255 * @param value
256 * allowed object is
257 * {@link String }
258 *
259 */
260 public void setAnalysis(String value) {
261 this.analysis = value;
262 }
263
264 /**
265 * Sets the value of the attributes property.
266 *
267 * @param value
268 * allowed object is
269 * {@link COFTestAttributes }
270 *
271 */
272 public void setAttributes(COFTestAttributes value) {
273 this.attributes = value;
274 }
275
276 /**
277 * Sets the value of the description property.
278 *
279 * @param value
280 * allowed object is
281 * {@link String }
282 *
283 */
284 public void setDescription(String value) {
285 this.description = value;
286 }
287
288 /**
289 * Sets the value of the endtime property.
290 *
291 * @param value
292 * allowed object is
293 * {@link String }
294 *
295 */
296 public void setEndtime(Date value) {
297 this.endtime = value;
298 }
299
300 /**
301 * Sets the value of the name property.
302 *
303 * @param value
304 * allowed object is
305 * {@link String }
306 *
307 */
308 public void setName(String value) {
309 this.name = value;
310 }
311
312 /**
313 * Sets the value of the starttime property.
314 *
315 * @param value
316 * allowed object is
317 * {@link String }
318 *
319 */
320 public void setStarttime(Date value) {
321 this.starttime = value;
322 }
323
324 /**
325 * Sets the value of the status property.
326 *
327 * @param value
328 * allowed object is
329 * {@link COFStatus }
330 *
331 */
332 public void setStatus(COFStatus value) {
333 this.status = value;
334 }
335
336 /* (non-Javadoc)
337 * @see com.sun.javatest.cof.COFItem#write(com.sun.javatest.util.XMLWriter)
338 */
339 void write(XMLWriter out) throws IOException {
340 out.newLine();
341 super.write(out);
342 }
343 }
+0
-133
src/com/sun/javatest/cof/COFTestCases.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.io.IOException;
29 import java.util.ArrayList;
30 import java.util.LinkedHashMap;
31 import java.util.List;
32
33 import com.sun.javatest.util.XMLWriter;
34 /*import javax.xml.bind.annotation.XmlAccessType;
35 import javax.xml.bind.annotation.XmlAccessorType;
36 import javax.xml.bind.annotation.XmlElement;
37 import javax.xml.bind.annotation.XmlType;
38 */
39
40 /**
41 * <p>Java class for TestCases complex type.
42 *
43 * <p>The following schema fragment specifies the expected content contained within this class.
44 *
45 * <pre>
46 * &lt;complexType name="TestCases">
47 * &lt;complexContent>
48 * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
49 * &lt;sequence>
50 * &lt;element name="testcase" type="{http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema}TestCase" maxOccurs="unbounded"/>
51 * &lt;/sequence>
52 * &lt;/restriction>
53 * &lt;/complexContent>
54 * &lt;/complexType>
55 * </pre>
56 *
57 *
58 */
59 /*@XmlAccessorType(XmlAccessType.FIELD)
60 @XmlType(name = "TestCases", propOrder = {
61 "testcase"
62 })*/
63 public class COFTestCases extends COFItem{
64
65 static LinkedHashMap xmlAttributes;
66
67 static LinkedHashMap xmlElements;
68
69 static String xmlTagName;
70
71 static {
72 xmlTagName = "testcases";
73 xmlElements = new LinkedHashMap();
74 xmlElements.put("testcase", "testcase");
75 }
76
77 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
78 protected List/*<COFTestCase>*/ testcase;
79
80 LinkedHashMap getItemAttributes() {
81 return xmlAttributes;
82 }
83
84 LinkedHashMap getItemElements() {
85 return xmlElements;
86 }
87
88
89 String getItemTagName() {
90 return xmlTagName;
91 }
92
93 /**
94 * Gets the value of the testcase property.
95 *
96 * <p>
97 * This accessor method returns a reference to the live list,
98 * not a snapshot. Therefore any modification you make to the
99 * returned list will be present inside the JAXB object.
100 * This is why there is not a <CODE>set</CODE> method for the testcase property.
101 *
102 * <p>
103 * For example, to add a new item, do as follows:
104 * <pre>
105 * getTestcase().add(newItem);
106 * </pre>
107 *
108 *
109 * <p>
110 * Objects of the following type(s) are allowed in the list
111 * {@link COFTestCase }
112 *
113 *
114 */
115 public List/*<COFTestCase>*/ getTestcase() {
116 if (testcase == null) {
117 testcase = new ArrayList/*<COFTestCase>*/();
118 }
119 return this.testcase;
120 }
121
122 /* (non-Javadoc)
123 * @see com.sun.javatest.cof.COFItem#write(com.sun.javatest.util.XMLWriter)
124 */
125 void write(XMLWriter out) throws IOException {
126 if (getTestcase().size() != 0) {
127 out.newLine();
128 super.write(out);
129 }
130 }
131
132 }
+0
-194
src/com/sun/javatest/cof/COFTestSuite.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.io.File;
29 import java.io.IOException;
30 import java.util.Iterator;
31 import java.util.regex.Pattern;
32
33 import com.sun.javatest.Status;
34 import com.sun.javatest.TestResult;
35 import com.sun.javatest.TestResultTable;
36 import com.sun.javatest.TestSuite;
37 import com.sun.javatest.WorkDirectory;
38 import com.sun.javatest.util.I18NResourceBundle;
39 import com.sun.javatest.util.XMLWriter;
40 import java.util.Collection;
41 import java.util.HashMap;
42
43 class COFTestSuite extends COFItem {
44
45 private static final String[] cofStatus = new String[Status.NUM_STATES];
46
47 private static I18NResourceBundle i18n = I18NResourceBundle
48 .getBundleForClass(COFTestSuite.class);
49
50 static {
51 cofStatus[Status.PASSED] = "pass";
52 cofStatus[Status.FAILED] = "fail";
53 cofStatus[Status.ERROR] = "error";
54 cofStatus[Status.NOT_RUN] = "did_not_run";
55 }
56
57 private COFData cofData;
58
59 private boolean legacyMode = false; // modern workdir or not
60
61 private String name;
62
63 protected Pattern testCasePattern = Pattern
64 .compile("^(\\S+): (Passed\\.|Failed\\.|Error\\.|Not\\ run\\.)(.*)");
65
66
67 private TestResultTable trt;
68
69 COFTestSuite(File dir) {
70 trt = new TestResultTable();
71 scan(dir);
72 legacyMode = true;
73 }
74
75 COFTestSuite(File dir, COFData cd) {
76 cofData = cd;
77 trt = new TestResultTable();
78 name = cofData.get("testsuites.testsuite.name");
79 scan(dir);
80 legacyMode = true;
81 }
82
83 COFTestSuite(TestResultTable trt) {
84 this.trt = trt;
85 }
86
87 COFTestSuite(WorkDirectory wd) {
88 this(wd, null);
89 }
90
91 COFTestSuite(WorkDirectory wd, COFData cd) {
92 cofData = cd;
93 TestSuite ts = wd.getTestSuite();
94 name = ts.getID();
95 trt = wd.getTestResultTable();
96 }
97
98 COFTestSuite() {
99 }
100
101 void scan(File dir) {
102 String[] entries = dir.list();
103 if (entries != null) {
104 for (int i = 0; i < entries.length; i++) {
105 File f = new File(dir, entries[i]);
106 if (f.isDirectory())
107 scan(f);
108 else if (TestResult.isResultFile(f)) {
109 try {
110 TestResult tr = new TestResult(f);
111 trt.update(tr);
112 } catch (TestResult.Fault e) {
113 // ignore errors for now
114 // an error handler might report errors to stderr
115 System.err.println(i18n.getString("ts.badTest",
116 new Object[] { f, e.getMessage() }));
117 }
118 }
119 }
120 }
121 }
122
123 void write(XMLWriter out) throws IOException {
124
125 out.startTag("testsuite");
126 out.writeAttr("id", "unknownTestSuite:0");
127
128 // name
129 out.startTag("name");
130 out.write(name == null ? "unknown" : name);
131 out.endTag("name");
132 // version (optional)
133 // tests
134 out.startTag("tests");
135
136 // might need to wait for workdir to fully load
137 if (!legacyMode)
138 trt.waitUntilReady();
139 for (Iterator iter = trt.getIterator(); iter.hasNext();) {
140 TestResult tr = (TestResult) (iter.next());
141 out.newLine();
142 new COFTest(tr, cofData).write(out);
143 }
144 out.endTag("tests");
145 out.endTag("testsuite");
146 }
147
148 public COFEnvironment[] getCOFEnvironments(COFData data) {
149 if (!legacyMode) {
150 trt.waitUntilReady();
151 }
152 HashMap map = new HashMap();
153 String id = cofData.get("environment.id", "env:0").split(":")[0] + ":";
154 int id_n = 0;
155 for (Iterator iter = trt.getIterator(); iter.hasNext();) {
156 TestResult tr = (TestResult) (iter.next());
157 try {
158 String os = tr.getProperty(TestResult.JAVATEST_OS);
159 if (!map.containsKey(os) && os != null) {
160 try {
161 String[] split;
162 split = os.split("[()]");
163 String arch = split[split.length - 1];
164 split = split[0].split(" ", 2);
165 String name = split[0];
166 String version = split[1].trim();
167 data.put("environment.os.arch", arch);
168 data.put("environment.os.name", name);
169 data.put("environment.os.version", version);
170
171 COFEnvironment e = new COFEnvironment(data, id + id_n++);
172 map.put(os, e);
173 } catch (Throwable t) {
174 }
175 }
176 } catch (TestResult.Fault ex) {
177 }
178 }
179 Collection values = map.values();
180 COFEnvironment[] evs;
181 if (values.isEmpty()) {
182 evs = new COFEnvironment[] {new COFEnvironment(data, "env:0")};
183 } else {
184 evs = new COFEnvironment[values.size()];
185 Iterator e = values.iterator();
186 int i = 0;
187 while (e.hasNext()) {
188 evs[i++] = (COFEnvironment) e.next();
189 }
190 }
191 return evs;
192 }
193 }
+0
-126
src/com/sun/javatest/cof/COFTestSuites.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.io.IOException;
29 import java.util.ArrayList;
30 import java.util.LinkedHashMap;
31 import java.util.List;
32
33 import com.sun.javatest.util.XMLWriter;
34
35
36 /**
37 * <p>Java class for TestSuites complex type.
38 *
39 * <p>The following schema fragment specifies the expected content contained within this class.
40 *
41 * <pre>
42 * &lt;complexType name="TestSuites">
43 * &lt;complexContent>
44 * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
45 * &lt;sequence>
46 * &lt;element name="testsuite" type="{http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema}TestSuite" maxOccurs="unbounded"/>
47 * &lt;/sequence>
48 * &lt;/restriction>
49 * &lt;/complexContent>
50 * &lt;/complexType>
51 * </pre>
52 *
53 *
54 */
55 /*@XmlAccessorType(XmlAccessType.FIELD)
56 @XmlType(name = "TestSuites", propOrder = {
57 "testsuite"
58 })*/
59 public class COFTestSuites extends COFItem{
60
61 static LinkedHashMap xmlAttributes;
62
63 static LinkedHashMap xmlElements;
64
65 static String xmlTagName;
66
67 static {
68 xmlElements = new LinkedHashMap();
69 xmlElements.put("testsuite", "testsuite");
70 xmlTagName = "testsuites";
71 }
72
73 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
74 protected List/*<COFTestSuite>*/ testsuite;
75
76 LinkedHashMap getItemAttributes() {
77 return xmlAttributes;
78 }
79
80 LinkedHashMap getItemElements() {
81 return xmlElements;
82 }
83
84 String getItemTagName() {
85 return xmlTagName;
86 }
87
88 /**
89 * Gets the value of the testsuite property.
90 *
91 * <p>
92 * This accessor method returns a reference to the live list,
93 * not a snapshot. Therefore any modification you make to the
94 * returned list will be present inside the JAXB object.
95 * This is why there is not a <CODE>set</CODE> method for the testsuite property.
96 *
97 * <p>
98 * For example, to add a new item, do as follows:
99 * <pre>
100 * getTestsuite().add(newItem);
101 * </pre>
102 *
103 *
104 * <p>
105 * Objects of the following type(s) are allowed in the list
106 * {@link COFTestSuite }
107 *
108 *
109 */
110 public List/*<COFTestSuite>*/ getTestsuite() {
111 if (testsuite == null) {
112 testsuite = new ArrayList/*<COFTestSuite>*/();
113 }
114 return this.testsuite;
115 }
116
117 /* (non-Javadoc)
118 * @see com.sun.javatest.cof.COFItem#write(com.sun.javatest.util.XMLWriter)
119 */
120 void write(XMLWriter out) throws IOException {
121 out.newLine();
122 super.write(out);
123 out.newLine();
124 }
125 }
+0
-43
src/com/sun/javatest/cof/CustomFilter.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26
27 package com.sun.javatest.cof;
28
29 /**
30 * Custom filter and transformer for processed test results
31 */
32 public interface CustomFilter {
33
34 /**
35 * Transforms and/or filters out detected test case names.
36 * @param testCaseName
37 * @return transformed test case name or null if this test case
38 * should be filtered out
39 */
40 String transformTestCaseName(String testCaseName);
41
42 }
+0
-63
src/com/sun/javatest/cof/CustomFilterAdapter.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26
27 package com.sun.javatest.cof;
28
29 public class CustomFilterAdapter implements CustomFilter {
30
31 public String transformTestCaseName(String tcn) {
32 // Try to
33 if (isJavaIdentifier(tcn)) {
34 return tcn;
35 }
36
37 // The following algorithm is not very effective
38 // but simple. It executes very rarely,
39 // i.e. about 5 times of 3600 testcases
40 for (int i = 1; i < tcn.length(); i++) {
41 String p = tcn.substring(i);
42 if (isJavaIdentifier(p)) {
43 return p;
44 }
45 }
46 return null;
47 }
48
49 // See JLS 3 / 3.8
50 private boolean isJavaIdentifier(String jid) {
51 for (int i = 0; i < jid.length(); i++) {
52 char c = jid.charAt(i);
53 if ( i == 0 && !Character.isJavaIdentifierStart(c)) {
54 return false;
55 }
56 if ( i > 0 && !Character.isJavaIdentifierPart(c) && c != '.') {
57 return false;
58 }
59 }
60 return true;
61 }
62 }
+0
-56
src/com/sun/javatest/cof/ID.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.util.HashMap;
29 import java.util.Map;
30
31 class ID
32 {
33 static class Factory {
34 ID create(String base) {
35 Integer last = (Integer) (map.get(base));
36 int index = (last == null ? 0 : last.intValue() + 1);
37 map.put(base, new Integer(index));
38 return new ID(base, index);
39 }
40
41 Map map = new HashMap();
42 };
43
44 private ID(String base, int index) {
45 this.base = base;
46 this.index = index;
47 }
48
49 public String toString() {
50 return (base + ":" + index);
51 }
52
53 private String base;
54 private int index;
55 }
+0
-86
src/com/sun/javatest/cof/MTL.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.io.*;
29 import java.nio.charset.StandardCharsets;
30 import java.util.ArrayList;
31 import java.util.HashMap;
32 import java.util.List;
33 import java.util.StringTokenizer;
34
35 /**
36 * Reads and stores master test list content
37 */
38 public class MTL {
39
40 private final File mtl;
41 private HashMap<String, ArrayList<String>> table;
42
43 MTL(File mtlFile) {
44 mtl = mtlFile;
45 }
46
47 private void init() {
48 if (table == null) {
49 table = new HashMap<String, ArrayList<String>>();
50 BufferedReader r = null;
51 try {
52 r = new BufferedReader(new InputStreamReader(new FileInputStream(mtl), StandardCharsets.UTF_8));
53 String line;
54 while ((line = r.readLine()) != null) {
55 StringTokenizer st = new StringTokenizer(line);
56 ArrayList<String> cases = new ArrayList<String>();
57 String testName = null;
58 if (st.hasMoreTokens()) {
59 testName = st.nextToken();
60 }
61 while (st.hasMoreTokens()) {
62 cases.add(st.nextToken());
63 }
64 if (testName != null) {
65 table.put(testName, cases);
66 }
67 }
68 } catch (IOException ex) {
69 throw new IllegalArgumentException(ex);
70 } finally {
71 try {
72 if (r != null)
73 r.close();
74 } catch (IOException ex) {
75 ex.printStackTrace();
76 }
77 }
78 }
79 }
80
81 List<String> getTestCases(String name) {
82 init();
83 return table.get(name);
84 }
85 }
+0
-466
src/com/sun/javatest/cof/Main.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import com.sun.javatest.InterviewParameters;
29
30 import java.io.*;
31 import java.nio.channels.FileChannel;
32 import java.nio.charset.StandardCharsets;
33 import java.util.Vector;
34
35 import com.sun.javatest.TestSuite;
36 import com.sun.javatest.WorkDirectory;
37 import com.sun.javatest.util.I18NResourceBundle;
38 import com.sun.javatest.util.XMLWriter;
39
40 public class Main {
41 /**
42 * Thrown when a bad command line argument is encountered.
43 */
44 public static class BadArgs extends Exception {
45 /**
46 * Serialization support
47 */
48 private static final long serialVersionUID = 4638654313770205243L;
49
50 /**
51 * Create a BadArgs exception.
52 * @param i18n A resource bundle in which to find the detail message.
53 * @param key The key for the detail message.
54 */
55 BadArgs(I18NResourceBundle i18n, String key) {
56 super(i18n.getString(key));
57 }
58
59 /**
60 * Create a BadArgs exception.
61 * @param i18n A resource bundle in which to find the detail message.
62 * @param key The key for the detail message.
63 * @param arg An argument to be formatted with the detail message by
64 * {@link java.text.MessageFormat#format}
65 */
66 BadArgs(I18NResourceBundle i18n, String key, Object arg) {
67 super(i18n.getString(key, arg));
68 }
69
70 /**
71 * Create a BadArgs exception.
72 * @param i18n A resource bundle in which to find the detail message.
73 * @param key The key for the detail message.
74 * @param args An array of arguments to be formatted with the detail message by
75 * {@link java.text.MessageFormat#format}
76 */
77 BadArgs(I18NResourceBundle i18n, String key, Object[] args) {
78 super(i18n.getString(key, args));
79 }
80 }
81
82 /**
83 * This exception is used to report problems that occur while the program is running.
84 */
85 public static class Fault extends Exception {
86 /**
87 * Serialization support
88 */
89 private static final long serialVersionUID = -4066018402688615825L;
90
91 /**
92 * Create a Fault.
93 * @param i18n A resource bundle in which to find the detail message.
94 * @param s The key for the detail message.
95 */
96 Fault(I18NResourceBundle i18n, String s) {
97 super(i18n.getString(s));
98 }
99
100 /**
101 * Create a Fault.
102 * @param i18n A resource bundle in which to find the detail message.
103 * @param s The key for the detail message.
104 * @param o An argument to be formatted with the detail message by
105 * {@link java.text.MessageFormat#format}
106 */
107 Fault(I18NResourceBundle i18n, String s, Object o) {
108 super(i18n.getString(s, o));
109 }
110
111 /**
112 * Create a Fault.
113 * @param i18n A resource bundle in which to find the detail message.
114 * @param s The key for the detail message.
115 * @param o An array of arguments to be formatted with the detail message by
116 * {@link java.text.MessageFormat#format}
117 */
118 Fault(I18NResourceBundle i18n, String s, Object[] o) {
119 super(i18n.getString(s, o));
120 }
121
122 Fault(Exception t) {
123 super(t.getMessage(), t);
124 }
125 }
126
127 private static final String COF_SCHEMA = "COF2_0_2.xsd";
128
129 private static I18NResourceBundle i18n = I18NResourceBundle
130 .getBundleForClass(Main.class);
131
132 private static File suiteCopy;
133
134 private static void exit(int exitCode) {
135 System.exit(exitCode);
136 throw new Error();
137 }
138
139 public static void main(String[] args) {
140
141 PrintWriter out = new PrintWriter(System.err);
142
143 try {
144 Main m = new Main();
145 m.run(args, out);
146 out.flush();
147 exit(0);
148 } catch (BadArgs e) {
149 out.println(e.getMessage());
150 //showCommandLineHelp(out);
151 out.flush();
152 exit(1);
153 } catch (Fault e) {
154 out.println(e.getMessage());
155 out.flush();
156 exit(2);
157 }
158 }
159
160 private static TestSuite openTestSuite(File path) throws Fault {
161 try {
162 return TestSuite.open(path);
163 } catch (FileNotFoundException e) {
164 // should not happen, because of prior dir.exists() check
165 throw new Fault(i18n, "main.cantFindTestSuite", path);
166 } catch (TestSuite.Fault f) {
167 throw new Fault(i18n, "main.cantOpenTestSuite", new Object[] {
168 path, f });
169 }
170 }
171
172 private static WorkDirectory openWorkDirectory(File wdPath, File tsPath)
173 throws Fault {
174 try {
175 WorkDirectory wd;
176 if (tsPath == null)
177 wd = WorkDirectory.open(wdPath);
178 else {
179 // with non default suite WorkDirectory.open overwrites
180 // original suite.
181 // so copy before open
182 File original = new File(wdPath.getPath()+"/jtData/testsuite");
183 suiteCopy = File.createTempFile("cof",".tmp");
184 copyFile(original, suiteCopy);
185 wd = WorkDirectory.open(wdPath, openTestSuite(tsPath));
186 }
187 return wd;
188 } catch (FileNotFoundException e) {
189 // should not happen, because of prior dir.exists() check
190 throw new Fault(i18n, "main.cantFindWorkDir", wdPath);
191 } catch (WorkDirectory.Fault f) {
192 throw new Fault(i18n, "main.cantOpenWorkDir", new Object[] {
193 wdPath, f });
194 } catch (IOException e) {
195 throw new RuntimeException(e);
196 }
197 }
198
199 private static void showCommandLineHelp(PrintWriter out) {
200 String progName = System.getProperty("program", "java " + Main.class
201 .getName());
202
203 out.println(i18n.getString("main.cmdLine.proto", progName));
204 out.println();
205 out.println(i18n.getString("main.cmdLine.optHead"));
206 out.println(i18n.getString("main.cmdLine.file"));
207 out.println(i18n.getString("main.cmdLine.help"));
208 out.println(i18n.getString("main.cmdLine.out"));
209 out.println(i18n.getString("main.cmdLine.ts"));
210 out.println(i18n.getString("main.cmdLine.xsd"));
211 out.println(i18n.getString("main.cmdLine.no-testcases"));
212 out.println(i18n.getString("main.cmdLine.mtl"));
213 out.println(i18n.getString("main.cmdLine.filter"));
214 out.println(i18n.getString("main.cmdLine.data"));
215 out.println();
216 out.println(i18n.getString("main.cmdLine.filesHead"));
217 out.println(i18n.getString("main.cmdLine.dir"));
218 out.println();
219 out.println(i18n.getString("main.copyright.txt"));
220 }
221
222
223 public static void setGenerateTestCases(boolean enable) {
224 COFTest.noTestCases = !enable;
225 if (!enable)
226 COFTest.xmlElements.remove("testcases");
227 else
228 COFTest.xmlElements.put("testcases", "testcases");
229 }
230
231 void run(String[] args, PrintWriter log) throws BadArgs, Fault {
232 boolean helpFlag = false;
233 xsdFlag = false;
234 String jtiPath = null;
235 File outputFile = null;
236 File mtlFile = null;
237
238 String filterClass = null;
239
240 if (args.length == 0)
241 helpFlag = true;
242 else {
243 for (int i = 0; i < args.length; i++) {
244 if (args[i].equals("-o") && (i + 1 < args.length)) {
245 outputFile = new File(args[++i]);
246 } else if (args[i].equalsIgnoreCase("-jti") && (i + 1 < args.length)) {
247 jtiPath = args[++i];
248 if (tsPath != null) {
249 tsPath = null;
250 log.println("main.tswithjti");
251 }
252 } else if (args[i].equals("-f") && (i + 1 < args.length)) {
253 data.add(new File(args[++i]));
254 } else if (args[i].equalsIgnoreCase("-help") || args[i]
255 .equalsIgnoreCase("-usage")
256 || args[i].equalsIgnoreCase("/?")) {
257 helpFlag = true;
258 } else if (args[i].equalsIgnoreCase("-no-testcases")) {
259 COFTest.noTestCases = true;
260 COFTest.xmlElements.remove("testcases");
261 } else if (args[i].equalsIgnoreCase("-xsd")) {
262 xsdFlag = true;
263 } else if (args[i].equalsIgnoreCase("-mtl") && (i + 1 < args.length)) {
264 mtlFile = new File(args[++i]);
265 } else if (args[i].equalsIgnoreCase("-ts") && (i + 1 < args.length)) {
266 if (jtiPath != null) {
267 tsPath = new File(args[++i]);
268 } else {
269 i++;
270 }
271 } else if (args[i].equalsIgnoreCase("-filter") && (i + 1 < args.length)) {
272 filterClass = args[++i];
273 } else if (args[i].startsWith("-")) {
274 throw new BadArgs(i18n, "main.badOpt", args[i]);
275 } else if (args[i].indexOf("=") != -1) {
276 data.add(args[i]);
277 } else if (i == args.length - 1) {
278 // currently, only accept one directory;
279 // we could accept more and turn them into
280 // separate testsuites in the report, but
281 // would have trouble identifying environments
282 // for them
283 if (jtiPath == null) {
284 dir = new File(args[i]);
285 }
286 } else
287 throw new BadArgs(i18n, "main.badArg", args[i]);
288 }
289 }
290
291 if (helpFlag) {
292 showCommandLineHelp(log);
293 if (dir == null && outputFile == null)
294 return;
295 }
296
297 if (outputFile == null)
298 throw new BadArgs(i18n, "main.noOutputFile");
299
300 if (jtiPath == null) {
301 if (dir == null)
302 throw new BadArgs(i18n, "main.noResults");
303
304 if (!dir.exists())
305 throw new BadArgs(i18n, "main.cantFindResults");
306 }
307
308 COFData cofData;
309 try {
310 cofData = new COFData(data);
311 if (mtlFile != null) {
312 cofData.setMtl(new MTL(mtlFile));
313 }
314 } catch (IllegalArgumentException e) {
315 throw new Fault(i18n, "main.badOpt", e.toString());
316 } catch (IOException e) {
317 throw new Fault(i18n, "main.cantReadFile", e);
318 }
319
320 if (filterClass != null) {
321 try {
322 cofData.setCustomFilter(filterClass);
323 } catch (Exception ex) {
324 // InstantiationException
325 // ClassNotFoundException
326 // IllegalAccessException
327 // - just print an error and use default
328 ex.printStackTrace();
329 }
330 }
331
332 if (jtiPath != null) {
333 File jtiFile = new File(jtiPath);
334 if (!InterviewParameters.isInterviewFile(jtiFile)) {
335 throw new Fault(i18n, "jti.isNotInterview");
336 }
337 if (!jtiFile.exists()) {
338 throw new Fault(i18n, "jti.notExists");
339 }
340 if (!jtiFile.canRead()) {
341 throw new Fault(i18n, "jti.cantRead");
342 }
343
344 try {
345 ip = InterviewParameters.open(jtiFile);
346 cofData.setInterviewParameters(ip);
347 } catch (Exception ex) {
348 throw new Fault(ex);
349 }
350 }
351
352 Report report = fillReport(cofData);
353 writeReport(report, outputFile);
354 }
355
356 public void writeReport(Report r, File outputFile) throws Fault {
357 // creating report
358 try {
359 XMLWriter out = new XMLWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), StandardCharsets.UTF_8)));
360 r.write(out);
361 out.close();
362 } catch (IOException e) {
363 throw new Fault(i18n, "main.cantWriteFile", new Object[]{
364 outputFile, e});
365 }
366
367 if (xsdFlag) {
368 File xsdFile = new File(outputFile.getAbsoluteFile().getParent(),
369 COF_SCHEMA);
370 try {
371 InputStream in = new BufferedInputStream(getClass().getResourceAsStream(COF_SCHEMA));
372 OutputStream out = new BufferedOutputStream(
373 new FileOutputStream(xsdFile));
374 byte[] buf = new byte[4096];
375 int n;
376 while ((n = in.read(buf, 0, buf.length)) != -1) {
377 out.write(buf, 0, n);
378 }
379 in.close();
380 out.close();
381 } catch (IOException e) {
382 throw new Fault(i18n, "main.cantWriteFile", new Object[]{
383 xsdFile, e});
384 }
385 }
386 if (suiteCopy != null) {
387 File original = new File(dir.getPath() + "/jtData/testsuite");
388 copyFile(suiteCopy, original);
389 suiteCopy.delete();
390 }
391 }
392
393 public Report fillReport(COFData cofData) throws Fault {
394 COFTestSuite cof_ts;
395
396 if (ip != null) {
397 WorkDirectory wd = ip.getWorkDirectory();
398 cofData.put("workdir", wd.getPath());
399 cof_ts = new COFTestSuite(wd, cofData);
400 } else {
401 if (WorkDirectory.isWorkDirectory(dir)) {
402 cofData.put("workdir", dir.getAbsolutePath());
403 cof_ts = new COFTestSuite(openWorkDirectory(dir, tsPath), cofData);
404 } else {
405 cof_ts = new COFTestSuite(dir, cofData);
406 }
407 }
408
409 COFEnvironment[] cof_envs = cof_ts.getCOFEnvironments(cofData); // returns at least one default Environment
410
411 Report r = new Report(cof_envs, cof_ts);
412 r.setHarness(cofData.get("report.harness"));
413
414 COFSWEntities entities = new COFSWEntities();
415 COFSWEntity entity = new COFSWEntity();
416 entity.setId(cofData.get("swentity.id", "sw:0"));
417 entity.setName(cofData.get("swentity.name", "JDK"));
418 entity.setType(cofData.get("swentity.type", "java"));
419 entity.setVersion(cofData.get("swentity.version"));
420 entity.setDescription(cofData.get("swentity.description"));
421 entities.getSwentity().add(entity);
422 r.setSwentities(entities);
423
424 COFApplications apps= new COFApplications();
425 COFApplication app = new COFApplication();
426 app.setEnvironmentid(cof_envs[0].getId());
427 app.setSwentityid(entity.getId());
428 apps.getApplication().add(app);
429 r.setApplications(apps);
430 return r;
431 }
432
433 public static void copyFile(File in, File out) {
434 try {
435 FileChannel sourceChannel = new FileInputStream(in).getChannel();
436 FileChannel destinationChannel = new FileOutputStream(out).getChannel();
437 sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel);
438 sourceChannel.close();
439 destinationChannel.close();
440 } catch (FileNotFoundException e) {
441 System.out.println(e.getLocalizedMessage());
442 } catch (IOException e) {
443 System.out.println(e.getLocalizedMessage());
444 }
445 }
446
447 public void setXsdFlag(boolean xsd) {
448 this.xsdFlag = xsd;
449 }
450
451 public boolean getXsdFlag() {
452 return xsdFlag;
453 }
454
455 public void setInterviewParameters(InterviewParameters ip) {
456 this.ip = ip;
457 }
458
459 File dir = null;
460 File tsPath = null;
461 Vector data = new Vector();
462 InterviewParameters ip = null;
463 private boolean xsdFlag = false;
464
465 }
+0
-432
src/com/sun/javatest/cof/Report.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.cof;
27
28 import java.util.ArrayList;
29 import java.util.Date;
30 import java.util.LinkedHashMap;
31 import java.util.List;
32
33 public class Report extends COFItem {
34 static final String COF_SCHEMA = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema";
35
36 static final String COF_SCHEMA_LOCATION = "http://hestia.sfbay.sun.com/projects/COF/2003/2_0_2/Schema/COF2_0_2.xsd";
37
38 static final String VERSION = "2.0.2";
39
40 static final LinkedHashMap xmlAttributes;
41
42 static final LinkedHashMap xmlElements;
43
44 static String xmlTagName;
45
46 private static final String XSI_NS = "http://www.w3.org/2001/XMLSchema-instance";
47
48 static {
49 xmlElements = new LinkedHashMap();
50 xmlAttributes = new LinkedHashMap();
51 xmlElements.put("date", "date");
52 xmlElements.put("version", "version");
53 xmlElements.put("environments", "environments");
54 xmlElements.put("swentities", "swentities");
55 xmlElements.put("applications", "applications");
56 xmlElements.put("operator", "operator");
57 xmlElements.put("harness", "harness");
58 xmlElements.put("testsuites", "testsuites");
59 xmlElements.put("annotations", "annotations");
60 xmlAttributes.put("xsiNS", "xmlns:xsi");
61 xmlAttributes.put("cofNS", "xmlns:cof");
62 xmlAttributes.put("targetNS", "xmlns");
63 xmlAttributes.put("schemaLocation", "xsi:schemaLocation");
64 xmlTagName = "report";
65
66 }
67
68 // @XmlAttribute
69 protected String analysis;
70
71 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
72 protected COFReportAnnotations annotations;
73
74 // @XmlAnyElement
75 protected List/*<Element>*/any;
76
77 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
78 protected COFApplications applications;
79
80 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true, type = String.class)
81 protected Date date;
82
83 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
84 protected COFEnvironments environments;
85
86 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
87 protected String harness;
88
89 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
90 protected String operator;
91
92 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
93 protected COFSWEntities swentities;
94
95 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
96 protected COFTestSuites testsuites;
97
98 // @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
99 protected String version;
100
101 Report() {
102 setDate(new Date());
103 setVersion(VERSION);
104 setAnnotations(new COFReportAnnotations());
105 }
106
107 Report(COFEnvironment env, COFTestSuite ts) {
108 this();
109 getEnvironments().getEnvironment().add(env);
110 getTestsuites().getTestsuite().add(ts);
111 }
112
113 Report(COFEnvironment[] envs, COFTestSuite ts) {
114 this();
115 for (int i = 0; i < envs.length; i++) {
116 getEnvironments().getEnvironment().add(envs[i]);
117 }
118 getTestsuites().getTestsuite().add(ts);
119 }
120
121 void addEnvironment(COFEnvironment env) {
122 getEnvironments().getEnvironment().add(env);
123 }
124
125 void addTestSuite(COFTestSuite ts) {
126 getTestsuites().getTestsuite().add(ts);
127 }
128
129 /**
130 * Gets the value of the analysis property.
131 *
132 * @return
133 * possible object is
134 * {@link String }
135 *
136 */
137 public String getAnalysis() {
138 if (analysis == null) {
139 return "accept";
140 } else {
141 return analysis;
142 }
143 }
144
145 /**
146 * Gets the value of the annotations property.
147 *
148 * @return
149 * possible object is
150 * {@link COFReportAnnotations }
151 *
152 */
153 public COFReportAnnotations getAnnotations() {
154 return annotations;
155 }
156
157 /**
158 * Gets the value of the any property.
159 *
160 * <p>
161 * This accessor method returns a reference to the live list,
162 * not a snapshot. Therefore any modification you make to the
163 * returned list will be present inside the JAXB object.
164 * This is why there is not a <CODE>set</CODE> method for the any property.
165 *
166 * <p>
167 * For example, to add a new item, do as follows:
168 * <pre>
169 * getAny().add(newItem);
170 * </pre>
171 *
172 *
173 * <p>
174 * Objects of the following type(s) are allowed in the list
175 * {@link Element }
176 *
177 *
178 */
179 public List/*<Element>*/getAny() {
180 if (any == null) {
181 any = new ArrayList/*<Element>*/();
182 }
183 return this.any;
184 }
185
186 /**
187 * Gets the value of the applications property.
188 */
189 public COFApplications getApplications() {
190 return applications;
191 }
192
193 /**
194 * @return Returns the cofNS.
195 */
196 public String getCofNS() {
197 return COF_SCHEMA;
198 }
199
200 /**
201 * Gets the value of the date property.
202 *
203 * @return
204 * possible object is
205 * {@link String }
206 *
207 */
208 public Date getDate() {
209 return date;
210 }
211
212 /**
213 * Gets the value of the environments property.
214 *
215 * @return
216 * possible object is
217 * {@link Environments }
218 *
219 */
220 public COFEnvironments getEnvironments() {
221 if (environments == null)
222 environments = new COFEnvironments();
223 return environments;
224 }
225
226 /**
227 * Gets the value of the harness property.
228 *
229 * @return
230 * possible object is
231 * {@link String }
232 *
233 */
234 public String getHarness() {
235 return harness;
236 }
237
238 LinkedHashMap getItemAttributes() {
239 return xmlAttributes;
240 }
241
242 LinkedHashMap getItemElements() {
243 return xmlElements;
244 }
245
246 String getItemTagName() {
247 return xmlTagName;
248 }
249
250 /**
251 * Gets the value of the operator property.
252 *
253 * @return
254 * possible object is
255 * {@link String }
256 *
257 */
258 public String getOperator() {
259 return operator;
260 }
261
262 /**
263 * @return Returns the schemaLocation.
264 */
265 public String getSchemaLocation() {
266 return COF_SCHEMA + " " + COF_SCHEMA_LOCATION;
267 }
268
269 /**
270 * Gets the value of the swentities property.
271 *
272 * @return
273 * possible object is
274 * {@link COFSWEntities }
275 *
276 */
277 public COFSWEntities getSwentities() {
278 return swentities;
279 }
280
281 /**
282 * @return Returns the targetNS.
283 */
284 public String getTargetNS() {
285 return COF_SCHEMA;
286 }
287
288 /**
289 * Gets the value of the testsuites property.
290 *
291 * @return
292 * possible object is
293 * {@link TestSuites }
294 *
295 */
296 public COFTestSuites getTestsuites() {
297 if (testsuites == null)
298 testsuites = new COFTestSuites();
299 return testsuites;
300 }
301
302 /**
303 * Gets the value of the version property.
304 *
305 * @return
306 * possible object is
307 * {@link String }
308 *
309 */
310 public String getVersion() {
311 return version;
312 }
313
314 /**
315 * @return Returns the xsiNS.
316 */
317 public String getXsiNS() {
318 return XSI_NS;
319 }
320
321 /**
322 * Sets the value of the analysis property.
323 *
324 * @param value
325 * allowed object is
326 * {@link String }
327 *
328 */
329 public void setAnalysis(String value) {
330 this.analysis = value;
331 }
332
333 /**
334 * Sets the value of the annotations property.
335 *
336 * @param value
337 * allowed object is
338 * {@link COFReportAnnotations }
339 *
340 */
341 public void setAnnotations(COFReportAnnotations value) {
342 this.annotations = value;
343 }
344
345 /**
346 * Sets the value of the date property.
347 *
348 * @param value
349 * allowed object is
350 * {@link String }
351 *
352 */
353 public void setDate(Date value) {
354 this.date = value;
355 }
356
357 /**
358 * Sets the value of the environments property.
359 *
360 * @param value
361 * allowed object is
362 * {@link Environments }
363 *
364 */
365 public void setEnvironments(COFEnvironments value) {
366 this.environments = value;
367 }
368
369 /**
370 * Sets the value of the harness property.
371 *
372 * @param value
373 * allowed object is
374 * {@link String }
375 *
376 */
377 public void setHarness(String value) {
378 this.harness = value;
379 }
380
381 /**
382 * Sets the value of the operator property.
383 *
384 * @param value
385 * allowed object is
386 * {@link String }
387 *
388 */
389 public void setOperator(String value) {
390 this.operator = value;
391 }
392
393 /**
394 * Sets the value of the swentities property.
395 *
396 * @param value
397 * allowed object is
398 * {@link COFSWEntities }
399 *
400 */
401 public void setSwentities(COFSWEntities value) {
402 this.swentities = value;
403 }
404
405 public void setApplications(COFApplications value) {
406 this.applications = value;
407 }
408 /**
409 * Sets the value of the testsuites property.
410 *
411 * @param value
412 * allowed object is
413 * {@link TestSuites }
414 *
415 */
416 public void setTestsuites(COFTestSuites value) {
417 this.testsuites = value;
418 }
419
420 /**
421 * Sets the value of the version property.
422 *
423 * @param value
424 * allowed object is
425 * {@link String }
426 *
427 */
428 public void setVersion(String value) {
429 this.version = value;
430 }
431 }
+0
-59
src/com/sun/javatest/cof/i18n.properties less more
0 #
1 # $Id$
2 #
3 #
4 # Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 #
7 # This code is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License version 2 only, as
9 # published by the Free Software Foundation. Oracle designates this
10 # particular file as subject to the "Classpath" exception as provided
11 # by Oracle in the LICENSE file that accompanied this code.
12 #
13 # This code is distributed in the hope that it will be useful, but WITHOUT
14 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 # version 2 for more details (a copy is included in the LICENSE file that
17 # accompanied this code).
18 #
19 # You should have received a copy of the GNU General Public License version
20 # 2 along with this work; if not, write to the Free Software Foundation,
21 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 #
23 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
24 # or visit www.oracle.com if you need additional information or have any
25 # questions.
26 #
27
28 main.badArg=Bad argument: ''{0}''
29 main.badOpt=Bad option: ''{0}''
30 main.cantFindResults=Cannot find specified results directory ({0})
31 main.cantFindTestSuite=Cannot find specified test suite ({0})
32 main.cantFindWorkDir=Cannot find specified work directory ({0})
33 main.cantOpenTestSuite=Cannot open specified test suite ({0}) --\n{1}
34 main.cantOpenWorkDir=Cannot open specified work directory ({0}) --\n{1}
35 main.cantReadFile=Cannot read file --\n{0}
36 main.cantWriteFile=Cannot write file ({0}) --\n{1}
37 main.cmdLine.dir=\ dir Directory containing results to include in report
38 main.cmdLine.file =\ -f file Specify values to be used in the report
39 main.cmdLine.help =\ -help, -usage Show this message.
40 main.cmdLine.out =\ -o file The name of the output file
41 main.cmdLine.ts =\ -ts Explicitly specify test suite, to override default in work directory
42 main.cmdLine.xsd =\ -xsd Write out the schema file as well as the report
43 main.cmdLine.no-testcases=\ -no-testcases Don't include testcases information into report
44 main.cmdLine.mtl =\ -mtl file Specify JCK's master test list file
45 main.cmdLine.filter =\ -filter classname Specify a class name implementing custom filter
46 main.cmdLine.data =\ name=value Specify a value to be used in the report
47 main.cmdLine.filesHead=Files
48 main.cmdLine.optHead=Options
49 main.cmdLine.proto=Usage\n {0} options... dir
50 main.copyright.txt=Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
51 main.noOutputFile=No output file specified
52 main.noResults=No results specified to put in report
53 environment.badMachineName=Warning: Machine cononical name doesn''t contain domain name: {0} . Generated report will not be valid against schema.\nUse -f switch to specify file containing correct "environment.machine" property.
54 environment.cantGetLocalhostName=WARNING: Can''t get canonical name of localhost: {0}\nUsing defaults
55 ts.badTest={0}: {1}
56 jti.isNotInterview=Specified file is not interview
57 jti.notExists=Specified jti file does not exist
58 jti.cantRead=Can't read jti file - permission denied
108108 }
109109
110110 TT_BasicNode spot = root;
111 ArrayList<TT_TreeNode> list = new ArrayList(path.length + 1);
111 ArrayList<TT_TreeNode> list = new ArrayList<>(path.length + 1);
112112 list.add(root);
113113 for (int i = 1; i < path.length; i++) {
114114 try {
202202 synchronized (cache) {
203203 synchronized(BP_FilteredOutSubpanel.this) {
204204 // resync with this node cache
205 Vector[] newData = cache.addObserver(cacheWatcher, true);
205 Vector<TestResult>[] newData = cache.addObserver(cacheWatcher, true);
206206
207207 // add tests into the list model - this doesn't make the data
208208 // live though
293293 "br.list.enter"));
294294
295295 String[] actions = { };
296 popupTable = uif.createPopupMenu("br", actions, (ActionListener)tableListener);
296 popupTable = uif.createPopupMenu("br", actions, tableListener);
297297
298298 actions = new String[] { "action.cpnamelist", "action.cpnamestr" };
299 popupTable.add(uif.createMenu("br.cp", actions, (ActionListener)tableListener));
299 popupTable.add(uif.createMenu("br.cp", actions, tableListener));
300300
301301 // this is necessary to make sure that the split pane can resize
302302 // this panel. without setting the min., the panel seems to take
373373 }
374374 else if (column == 1) {
375375 synchronized (liveData) {
376 Object tst = (liveData.get(row));
376 TestResult tst = liveData.get(row);
377377 Object r = null;
378378
379379 if (cache != null && r == null) {
380 r = cache.getRejectReason((TestResult)tst);
380 r = cache.getRejectReason(tst);
381381 }
382382
383383 if (r == null)
400400 /**
401401 * @param suppressNotify Actively request that no update be scheduled.
402402 */
403 void addTest(Object tr, boolean suppressNotify) {
403 void addTest(TestResult tr, boolean suppressNotify) {
404404 synchronized (vLock) {
405405 // make sure this item is not already in the list
406406 if (!inQueue.contains(tr)) {
420420 * Remove the given test from the list.
421421 * Ignored if the test is not in the list.
422422 */
423 void removeTest(Object tr) {
423 void removeTest(TestResult tr) {
424424 synchronized (vLock) {
425425 rmQueue.addElement(tr);
426426
453453 // the event thread
454454 synchronized (pendingEvents) {
455455 for (int i = 0; i < pendingEvents.size(); i++) {
456 TableNotifier tn = (TableNotifier)(pendingEvents.get(i));
456 TableNotifier tn = pendingEvents.get(i);
457457 tn.cancel();
458458 } // for
459459 }
460460
461 inQueue = new Vector();
462 rmQueue = new Vector();
463 liveData = new LinkedList();
461 inQueue = new Vector<>();
462 rmQueue = new Vector<>();
463 liveData = new LinkedList<>();
464464
465465 isUpdateScheduled = false;
466466 }
558558 return;
559559
560560 while (rmQueue.size() > 0) {
561 TestResult target = (TestResult)(rmQueue.remove(0));
561 TestResult target = rmQueue.remove(0);
562562 int targetIndex = liveData.indexOf(target);
563563 if (targetIndex != -1) {
564564 synchronized (liveData) {
659659
660660 // must sync. on vLock anytime you access inQueue or liveData
661661 private final Object vLock = new Object(); // lock for inQueue & rmQueue
662 private Vector inQueue; // queue of items to be added to live data
663 private Vector rmQueue; // queue of items to be removed from live data
664 private LinkedList liveData; // to allow manual synchronization
665 Vector pendingEvents = new Vector();
662 private Vector<TestResult> inQueue; // queue of items to be added to live data
663 private Vector<TestResult> rmQueue; // queue of items to be removed from live data
664 private LinkedList<TestResult> liveData; // to allow manual synchronization
665 Vector<TableNotifier> pendingEvents = new Vector<>();
666666
667667 volatile boolean isUpdateScheduled; // are updates waiting in inQueue or rmQueue
668668
443443 } else if (column == 1) {
444444 synchronized (liveData) {
445445 if ((liveData.get(row)) instanceof TestResult)
446 return (getSelectedProperty((TestResult) (liveData.get(row))));
446 return getSelectedProperty(liveData.get(row));
447447 else
448448 // should not happen
449449 return uif.getI18NString("br.list.notAvailable.txt");
463463 * @param suppressNotify
464464 * Actively request that no update be scheduled.
465465 */
466 void addTest(Object tr, boolean suppressNotify) {
466 void addTest(TestResult tr, boolean suppressNotify) {
467467 synchronized (vLock) {
468468 // make sure this item is not already in the list
469469 if (!inQueue.contains(tr) && !liveData.contains(tr))
488488 * @param mode
489489 * Indicates ascending (0) or descending (1) sorting
490490 */
491 void sortTests(LinkedList v, int column, boolean mode) {
491 void sortTests(LinkedList<TestResult> v, int column, boolean mode) {
492492 synchronized (vLock) {
493493 inQueue = sort(v, mode);
494494
502502 * Remove the given test from the list. Ignored if the test is not in
503503 * the list.
504504 */
505 void removeTest(Object tr) {
505 void removeTest(TestResult tr) {
506506 synchronized (vLock) {
507507 rmQueue.addElement(tr);
508508 // try not to saturate the GUI event thread
530530 private String getSelectedProperty(TestResult tst) {
531531 try {
532532 if (show.equals("title"))
533 return ((TestResult) tst).getDescription().getTitle();
533 return tst.getDescription().getTitle();
534534 else if (show.equals("keywords")) {
535 String[] s = ((TestResult) tst).getDescription().getKeywords();
535 String[] s = tst.getDescription().getKeywords();
536536 if (s.length == 0)
537537 return (uif.getI18NString("br.list.noKeywords.txt"));
538538 else {
544544 return (sb.toString());
545545 }
546546 } else if (show.equals(TestResult.EXEC_STATUS)) {
547 String tmpStr = ((TestResult) tst).getStatus().getReason();
547 String tmpStr = tst.getStatus().getReason();
548548 return tmpStr == null || tmpStr.equals("") ?
549549 uif.getI18NString("br.list.notAvailable.txt") : tmpStr;
550550 }
551 return ((TestResult) tst).getProperty(show) == null ? uif.getI18NString("br.list.notAvailable.txt")
552 : ((TestResult) tst).getProperty(show);
551 return tst.getProperty(show) == null ? uif.getI18NString("br.list.notAvailable.txt")
552 : tst.getProperty(show);
553553 } catch (TestResult.Fault f) {
554554 }
555555 return (""); // should not be here
563563 // the event thread
564564 synchronized (pendingEvents) {
565565 for (int i = 0; i < pendingEvents.size(); i++) {
566 TableNotifier tn = (TableNotifier) (pendingEvents.get(i));
566 TableNotifier tn = pendingEvents.get(i);
567567 tn.cancel();
568568 } // for
569569 }
570570
571 inQueue = new Vector();
572 rmQueue = new Vector();
573 liveData = new LinkedList();
571 inQueue = new Vector<>();
572 rmQueue = new Vector<>();
573 liveData = new LinkedList<>();
574574
575575 isUpdateScheduled = false;
576576 }
577577
578 private Vector sort(LinkedList v, boolean mode) {
578 private Vector<TestResult> sort(LinkedList<TestResult> v, boolean mode) {
579579
580580 o = new Object[v.size()];
581581
584584 else if (SORTING_COLUMN == 1) {
585585 for (int i = 0; i < v.size(); i++) {
586586 if (v.get(i) instanceof TestResult)
587 o[i] = getSelectedProperty((TestResult) v.get(i));
587 o[i] = getSelectedProperty(v.get(i));
588588 else
589589 o[i] = ""; // should not happen
590590 }
611611 aaa[i] = rows[rows.length - i - 1].index;
612612 }
613613
614 Vector temp = new Vector(v.size());
614 Vector<TestResult> temp = new Vector<>(v.size());
615615
616616 for (int i = 0; i < v.size(); i++)
617617 temp.addElement(v.get(aaa[i]));
619619 return temp;
620620 }
621621
622 private class Sorter implements Comparable {
622 private class Sorter implements Comparable<Sorter> {
623623 public int index;
624624
625 public int compareTo(Object other) {
626 Sorter otherRow = (Sorter) other;
625 public int compareTo(Sorter otherRow) {
626
627627 if (o[index] instanceof TestResult) {
628 return ((Comparable) ((TestResult) o[index]).getTestName()).
628 return (((TestResult) o[index]).getTestName()).
629629 compareTo(((TestResult) o[otherRow.index]).getTestName());
630630 } else if (o[index] instanceof String) {
631 return ((Comparable) o[index]).compareTo(o[otherRow.index]);
631 return ((String) o[index]).compareTo((String)o[otherRow.index]);
632632 } else {
633633 return index - otherRow.index; // should not happen
634634 }
680680 }
681681
682682 for (int i = 0; i < BATCH_SIZE; i++) {
683 Object o = inQueue.remove(0);
683 TestResult o = inQueue.remove(0);
684684
685685 liveData.add(o);
686686 }
734734 return;
735735
736736 while (rmQueue.size() > 0) {
737 TestResult target = (TestResult) (rmQueue.remove(0));
737 TestResult target = rmQueue.remove(0);
738738 int targetIndex = liveData.indexOf(target);
739739 if (targetIndex != -1) {
740740 synchronized (liveData) {
835835 private final Object vLock = new Object(); // lock for inQueue &
836836 // rmQueue
837837
838 private Vector inQueue; // queue of items to be added to live data
839
840 private Vector rmQueue; // queue of items to be removed from live data
841
842 private LinkedList liveData; // to allow manual synchronization
843
844 Vector pendingEvents = new Vector();
838 private Vector<TestResult> inQueue; // queue of items to be added to live data
839
840 private Vector<TestResult> rmQueue; // queue of items to be removed from live data
841
842 private LinkedList<TestResult> liveData; // to allow manual synchronization
843
844 Vector<TableNotifier> pendingEvents = new Vector<>();
845845
846846 volatile boolean isUpdateScheduled; // are updates waiting in inQueue or
847847 // rmQueue
13561356
13571357 private String show = TestResult.EXEC_STATUS;
13581358
1359 private Vector[] newData;
1359 private Vector<TestResult>[] newData;
13601360
13611361 private boolean updateRequired;
13621362 }
100100 init(null);
101101 }
102102
103 BasicCustomTestFilter(Map map, ExecModel e, UIFactory uif) {
103 BasicCustomTestFilter(Map<String, String> map, ExecModel e, UIFactory uif) {
104104 super(map, e);
105105 this.uif = uif;
106106 init(map);
123123 // must be notified of changes
124124 @Override
125125 public void addObserver(Observer o) {
126 obs = (Observer[]) DynamicArray.append(obs, o);
126 obs = DynamicArray.append(obs, o);
127127 }
128128
129129 @Override
130130 public void removeObserver(Observer o) {
131 obs = (Observer[]) DynamicArray.remove(obs, o);
131 obs = DynamicArray.remove(obs, o);
132132 }
133133
134134 @Override
148148 }
149149
150150 @Override
151 boolean load(Map map) {
151 boolean load(Map<String, String> map) {
152152 boolean result = super.load(map);
153153 activeSettings = new SettingsSnapshot(map);
154154 putSettings(activeSettings);
160160 }
161161
162162 @Override
163 boolean save(Map map) {
163 boolean save(Map<String, String> map) {
164164 boolean result = super.save(map);
165165 activeSettings.save(map);
166166
273273 }
274274
275275 // ----- PRIVATE -----
276 private void init(Map map) {
276 private void init(Map<String, String> map) {
277277 if (NAME == null) {
278278 NAME = uif.getI18NString("basicTf.name");
279279 }
327327 if (nowSettings.keywordsEnabled) {
328328 try {
329329 String[] validKeywords = ts.getKeywords();
330 HashSet validKeywordsSet;
330 HashSet<String> validKeywordsSet;
331331 if (validKeywords == null) {
332332 validKeywordsSet = null;
333333 } else {
334 validKeywordsSet = new HashSet(Arrays.asList(validKeywords));
334 validKeywordsSet = new HashSet<>(Arrays.asList(validKeywords));
335335 }
336336
337337 Keywords kw = Keywords.create(kwModeToType(nowSettings.keyChoice),
727727 c.weightx = 2;
728728 c.weighty = 2;
729729 c.fill = GridBagConstraints.BOTH;
730 jtxFiles = new DefaultListModel();
730 jtxFiles = new DefaultListModel<String>();
731731 jtxFileList = uif.createList("basicTf.exclude.file", jtxFiles);
732732 jtxFileList.setEnabled(jtxCheckBox.isSelected());
733733 uif.setAccessibleInfo(jtxFileList, "basicTf.exclude.file");
882882 private ButtonGroup keyBtnGrp;
883883 private JRadioButton keyAllBtn;
884884 private JRadioButton keyMatchBtn;
885 private JComboBox keywordsChoice;
885 private JComboBox<String> keywordsChoice;
886886 private JTextField keywordsField;
887887 private static final String ALL_OF = "allOf";
888888 private static final String ANY_OF = "anyOf";
906906
907907 // jtx info fields
908908 private JTextField jtxMode;
909 private JList jtxFileList;
910 private DefaultListModel jtxFiles;
909 private JList<?> jtxFileList;
910 private DefaultListModel<String> jtxFiles;
911911 private static String NAME, REASON, DESCRIPTION;
912912
913913 /**
995995 keyString = "";
996996 }
997997
998 SettingsSnapshot(Map m) {
998 SettingsSnapshot(Map<String, String> m) {
999999 this();
10001000 load(m);
10011001 }
10501050 return true;
10511051 } // equals()
10521052
1053 void save(Map map) {
1053 void save(Map<String, String> map) {
10541054 map.put(MAP_URL_ENABLE, booleanToInt(urlsEnabled));
10551055 map.put(MAP_KEY_ENABLE, booleanToInt(keywordsEnabled));
10561056 map.put(MAP_STATUS_ENABLE, booleanToInt(statusEnabled));
10671067 map.put(MAP_KEY_STRING, keyString);
10681068 }
10691069
1070 void load(Map map) {
1071 urlsEnabled = intToBoolean((String) (map.get(MAP_URL_ENABLE)));
1072 keywordsEnabled = intToBoolean((String) (map.get(MAP_KEY_ENABLE)));
1073 statusEnabled = intToBoolean((String) (map.get(MAP_STATUS_ENABLE)));
1074 jtxEnabled = intToBoolean((String) (map.get(MAP_JTX_ENABLE)));
1075 tsfEnabled = intToBoolean((String) (map.get(MAP_TSF_ENABLE)));
1070 void load(Map<String, String> map) {
1071 urlsEnabled = intToBoolean((map.get(MAP_URL_ENABLE)));
1072 keywordsEnabled = intToBoolean((map.get(MAP_KEY_ENABLE)));
1073 statusEnabled = intToBoolean((map.get(MAP_STATUS_ENABLE)));
1074 jtxEnabled = intToBoolean((map.get(MAP_JTX_ENABLE)));
1075 tsfEnabled = intToBoolean((map.get(MAP_TSF_ENABLE)));
10761076
10771077 for (int i = 0; i < Status.NUM_STATES; i++) {
1078 statusFields[i] = intToBoolean((String) (map.get(MAP_STATUS_PREFIX + i)));
1078 statusFields[i] = intToBoolean((map.get(MAP_STATUS_PREFIX + i)));
10791079 } // for
10801080
1081 initialUrls = StringArray.split((String) (map.get(MAP_URLS)));
1082
1083 keyChoice = (String) (map.get(MAP_KEY_CHOICE));
1084 keyString = (String) (map.get(MAP_KEY_STRING));
1081 initialUrls = StringArray.split((map.get(MAP_URLS)));
1082
1083 keyChoice = map.get(MAP_KEY_CHOICE);
1084 keyString = map.get(MAP_KEY_STRING);
10851085
10861086 validate();
10871087 }
298298 return filterNames;
299299 }
300300
301 public void save(Map map) {
301 public void save(Map<String, String> map) {
302302 if (wd != null)
303303 map.put("workDir", wd.getPath());
304304 // save name of interview file
306306 map.put("config", config.getFile().getPath());
307307 }
308308
309 public void restore(Map map) throws Fault {
309 public void restore(Map<String, String> map) throws Fault {
310310 if (map == null)
311311 return;
312312
313 String wdPath = (String)map.get("workDir");
313 String wdPath = map.get("workDir");
314314 if (wdPath == null) {
315315 return;
316316 }
326326 throw new Fault(e);
327327 }
328328
329 String ipPath = (String)map.get("config");
329 String ipPath = map.get("config");
330330 if (ipPath == null) {
331331 return;
332332 }
169169 return Arrays.asList(getToolBarActions());
170170 }
171171
172 public void save(Map m) {
172 public void save(Map<String, String> m) {
173173 if (testSuite != null && testSuite.getRoot() != null)
174174 m.put("testSuite", testSuite.getRoot().getPath());
175175
177177 session.save(m);
178178 }
179179
180 public void restore(Map m) {
180 public void restore(Map<String, String> m) {
181181 try {
182182 session.restore(m);
183183 } catch (Fault e) {
222222 InterviewParameters ip = (InterviewParameters)p;
223223 InterviewParameters clone = ip.getWorkDirectory().getTestSuite().createInterview();
224224 clone.setWorkDirectory(ip.getWorkDirectory());
225 HashMap data = new HashMap();
225 HashMap<String, String> data = new HashMap<>();
226226 ip.save(data);
227227 clone.load(data, false);
228228 return clone;
12941294 update(timeoutFactor, c.getTimeoutFactorParameters(), MutableTimeoutFactorParameters.class);
12951295 }
12961296
1297 private void update(JMenuItem mi, Object o, Class c) {
1297 private void update(JMenuItem mi, Object o, Class<?> c) {
12981298 mi.setVisible(o != null && c.isAssignableFrom(o.getClass()));
12991299 }
13001300
272272 private EditableFileList envFilesField;
273273 private JFileChooser envFilesChooser;
274274 private JLabel envNameLabel;
275 private JComboBox envNameField;
275 private JComboBox<String> envNameField;
276276
277277 }
3030 import java.awt.GridBagLayout;
3131 import java.awt.event.ActionEvent;
3232 import java.awt.event.ActionListener;
33 import java.util.Map;
3334 import javax.swing.JButton;
3435 import javax.swing.JLabel;
3536 import javax.swing.JMenu;
4243 import com.sun.interview.Help;
4344 import com.sun.interview.Interview;
4445 import com.sun.interview.Question;
46 import com.sun.interview.wizard.QuestionRenderer;
4547 import com.sun.interview.wizard.WizPane;
4648 import com.sun.javatest.InterviewParameters;
4749 import com.sun.javatest.tool.UIFactory;
118120 add(wizPane, BorderLayout.CENTER);
119121 }
120122
121 protected void setCustomRenderers(java.util.Map customRenderers) {
123 protected void setCustomRenderers(Map<Class<? extends Question>, QuestionRenderer> customRenderers) {
122124 wizPane.setCustomRenderers(customRenderers);
123125 }
124126
9393 try {
9494 TestSuite ts = config.getTestSuite();
9595 String[] validKeywords = ts.getKeywords();
96 HashSet validKeywordsSet;
96 HashSet<String> validKeywordsSet;
9797 if (validKeywords == null)
9898 validKeywordsSet = null;
9999 else
100 validKeywordsSet = new HashSet(Arrays.asList(validKeywords));
100 validKeywordsSet = new HashSet<String>(Arrays.asList(validKeywords));
101101
102102 String kc = (String) (keywordsChoice.getSelectedItem());
103103 String type;
285285 private class KeywordChooser extends JDialog {
286286
287287 private JScrollPane sp;
288 private JList lst;
288 private JList<String> lst;
289289 private JButton ok, cancel;
290290
291291 KeywordChooser(Dialog parent, String [] keywords, Listener listener ) {
307307 GridBagConstraints gbc;
308308
309309 sp = new JScrollPane();
310 lst = new JList(keywords);
310 lst = new JList<>(keywords);
311311
312312 ok = uif.createButton("keywordChooser.insert", new ActionListener() {
313313 public void actionPerformed(ActionEvent e) {
397397 private KeywordsParameters keywordsParameters;
398398 private MutableKeywordsParameters mutableKeywordsParameters;
399399 private JCheckBox selectCheck;
400 private JComboBox keywordsChoice;
400 private JComboBox<String> keywordsChoice;
401401 private JTextField keywordsField;
402402 private JButton keywordBtn;
403403 private JPopupMenu keywordPopup;
9191
9292
9393 void showTab(int id) {
94 Class c;
94 Class<?> c;
9595 switch (id) {
9696 case TESTS_PANE:
9797 c = CE_TestsPane.class;
3333 import java.io.File;
3434 import java.io.IOException;
3535 import java.util.HashMap;
36 import java.util.Map;
3637 import javax.swing.BorderFactory;
3738 import javax.swing.Box;
3839 import javax.swing.JButton;
209210 try {
210211 c = config.getTestSuite().createInterview();
211212 createdNew = true;
212 HashMap data = new HashMap();
213 Map<String, String> data = new HashMap<>();
213214 config.save(data);
214215 c.load(data, false);
215216 }
190190 TestResultTable trt = wd.getTestResultTable();
191191
192192 File file = chooser.getSelectedFile();
193 ArrayList<String> paths = new ArrayList();
194 ArrayList<String> badPaths = new ArrayList();
195 Set seen = new HashSet();
193 ArrayList<String> paths = new ArrayList<>();
194 ArrayList<String> badPaths = new ArrayList<>();
195 Set<String> seen = new HashSet<>();
196196 FileReader fr = null;
197197 BufferedReader in = null;
198198 try {
252252 }
253253 }
254254
255 testsField.setSelection((String[]) (paths.toArray(new String[paths.size()])));
255 testsField.setSelection(paths.toArray(new String[paths.size()]));
256256 }
257257
258258 private TestsParameters testsParameters;
221221 }
222222 }
223223
224 Writer fw = null;
225 Writer out = null;
226 try {
227 fw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8));
228 out = new BufferedWriter(fw);
229 TextPane pane = (TextPane)body.getMediaPane(body.TEXT);
224 try (Writer fw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8));
225 Writer out = new BufferedWriter(fw)) {
226 TextPane pane = (TextPane) body.getMediaPane(body.TEXT);
230227 out.write(pane.getText());
231 out.close();
232228 }
233229 catch (IOException e) {
234230 if (!file.canWrite())
238234 else
239235 uif.showError("cb.save.error", new Object[] { file, e } );
240236 }
241 finally {
242 // attempt to close buffered writer first
243 // followed by the underlying writer for leak prevention
244 if (out != null){
245 try { out.close(); } catch (IOException e) { }
246 }
247
248 if (fw != null){
249 try { fw.close(); } catch (IOException e) { }
250 }
251 } // finally
252237 }
253238
254239 private void doPrintSetup() {
7979 * @throws IllegalStateException If the instance name is not present in the map or
8080 * the exec model argument is null.
8181 */
82 protected ConfigurableTestFilter(Map map, ExecModel e) {
82 protected ConfigurableTestFilter(Map<String, String> map, ExecModel e) {
8383 if (e == null)
8484 throw new IllegalArgumentException(i18n.getString("ctf.nullExec"));
8585
133133 * false if the operation failed.
134134 * @throws IllegalStateException If the instance name is not present in the map.
135135 */
136 boolean load(Map map) {
137 instanceName = (String)(map.get(INSTANCE_KEY));
136 boolean load(Map<String, String> map) {
137 instanceName = map.get(INSTANCE_KEY);
138138
139139 if (instanceName == null)
140140 throw new IllegalStateException(i18n.getString("ctf.mapNoName"));
149149 * @param map The map to save to.
150150 * @return True if saving was successful, false if the operation failed.
151151 */
152 boolean save(Map map) {
152 boolean save(Map<String, String> map) {
153153 map.put(INSTANCE_KEY, instanceName);
154154
155155 return true;
292292 if (parentTool != null) {
293293 TestResultTable trt = parentTool.getActiveTestResultTable();
294294
295 Map pathMap = new HashMap();
295 Map<String, String> pathMap = new HashMap<>();
296296 parentTool.saveTreeState(pathMap);
297297
298298 if (trt != null)
596596 testSuite = ts;
597597 }
598598
599 public Map getCustomRenderersMap() {
599 public Map<Class<? extends Question>, QuestionRenderer> getCustomRenderersMap() {
600600 return customRenderers;
601601 }
602602
610610 protected void registerCustomQuestionRenderer(Class<? extends Question> question,
611611 QuestionRenderer renderer) {
612612 if (customRenderers == null) {
613 customRenderers = new HashMap();
613 customRenderers = new HashMap<>();
614614 }
615615 customRenderers.put(question, renderer);
616616 }
746746 protected InterviewParameters currentConfig = null;
747747 protected InterviewParameters currentTemplate = null;
748748 private ExecTool parentTool;
749 private Map customRenderers;
749 private Map<Class<? extends Question>, QuestionRenderer> customRenderers;
750750
751751 private volatile boolean pendingRefresh = false;
752752
4646 /**
4747 * Saves current state to the map
4848 */
49 public void save(Map m);
49 public void save(Map<String, String> m);
5050
5151 /**
5252 * Restores saved state from the map
5353 */
54 public void restore(Map m);
54 public void restore(Map<String, String> m);
5555
5656 /**
5757 * Returts menu to be added to the menu mar
6262 /**
6363 * Does nothing
6464 */
65 public void save(Map m) {
65 public void save(Map<String, String> m) {
6666 }
6767
6868 /**
6969 * Does nothing
7070 */
71 public void restore(Map m) {
71 public void restore(Map<String, String> m) {
7272 }
7373
7474 /**
9999 }
100100 }
101101
102 public void save(Map m) {
102 public void save(Map<String, String> m) {
103103 // nothing to save
104104 }
105105
106 public void restore(Map m) {
106 public void restore(Map<String, String> m) {
107107 // nothing to restore
108108 }
109109
6262 */
6363 public class ET_FilterHandler implements ET_FilterControl, Session.Observer {
6464 ET_FilterHandler(JComponent parent, ExecModel model, Harness h, UIFactory uif,
65 Map map) {
65 Map<String, String> map) {
6666 this(parent, model, uif);
6767 setHarness(h);
6868 restore(map);
7373 this.model = model;
7474 this.parentComponent = parent;
7575
76 allFilters = new Vector();
76 allFilters = new Vector<>();
7777
7878 }
7979
159159 return fHandler;
160160 }
161161
162 private TestFilter getDefaultFilter(Map map) {
162 private TestFilter getDefaultFilter(Map<String, String> map) {
163163 if (map != null) {
164 String pref = (String)(map.get(ExecTool.ACTIVE_FILTER));
164 String pref = (map.get(ExecTool.ACTIVE_FILTER));
165165
166166 // try to use filter indicated in preference
167167 for (int i = 0; i < allFilters.size(); i++) {
168168 if (allFilters.elementAt(i).getClass().getName().equals(pref))
169 return (TestFilter)allFilters.elementAt(i);
169 return allFilters.elementAt(i);
170170 } // for
171171 }
172172
245245 /**
246246 * Save internal state.
247247 */
248 public void save(Map m) {
248 public void save(Map<String, String> m) {
249249 // -------- saved to given map (desktop) -------
250250 Preferences prefs = Preferences.access();
251251 TestFilter aFilter = fHandler.getActiveFilter();
264264
265265 ConstrainedPreferenceMap cpm = new ConstrainedPreferenceMap(prefs);
266266 // using meta_ prefix for info not written by the filter itself
267 PrefixMap pm = new PrefixMap(cpm, FILTER_PREFIX + prefIndex);
267 PrefixMap<String> pm = new PrefixMap<>(cpm, FILTER_PREFIX + prefIndex);
268268
269269 // it's really a special case to have a pref. entry which does not
270270 // have a tsId associated
280280
281281 prefs.save();
282282 }
283 public void restore(Map m) {
283 public void restore(Map<String, String> m) {
284284 this.map = m;
285285 fHandler.setFilter(getDefaultFilter(m));
286286 }
323323 if (prefIndex >= 0) {
324324 // load previous settings
325325 ConstrainedPreferenceMap cpm = new ConstrainedPreferenceMap(prefs);
326 PrefixMap pm = new PrefixMap(cpm, FILTER_PREFIX + prefIndex);
326 PrefixMap<String> pm = new PrefixMap<>(cpm, FILTER_PREFIX + prefIndex);
327327
328328 if (bctf == null) { // init
329329 bctf = new BasicCustomTestFilter(pm, model, uif);
440440 private ExecModel model;
441441 private UIFactory uif;
442442 private JComponent parentComponent;
443 private Map map; // saved desktop map to restore from
443 private Map<String, String> map; // saved desktop map to restore from
444444
445445 // filters
446446 private LastRunFilter ltrFilter; // last test run
448448 private BasicCustomTestFilter bctf; // "custom" filter
449449 private AllTestsFilter allFilter;
450450 private TestFilter certFilter; // "certification" filter
451 protected Vector allFilters;
451 protected Vector<TestFilter> allFilters;
452452
453453 // custom filter info
454454 private TestSuite lastTs;
471471 * This class is completely private and only implements what we
472472 * want to use here.
473473 */
474 private static class ConstrainedPreferenceMap implements Map {
474 private static class ConstrainedPreferenceMap implements Map<String, String> {
475475 ConstrainedPreferenceMap(Preferences p) {
476476 prefs = p;
477477 }
488488 throw new UnsupportedOperationException();
489489 }
490490
491 public Set entrySet() {
492 throw new UnsupportedOperationException();
493 }
494
495 public Object get(Object key) {
491 public Set<Map.Entry<String, String>> entrySet() {
492 throw new UnsupportedOperationException();
493 }
494
495 public String get(Object key) {
496496 if (!(key instanceof String))
497497 throw new IllegalArgumentException("key must be a string");
498498
503503 throw new UnsupportedOperationException();
504504 }
505505
506 public Set keySet() {
507 throw new UnsupportedOperationException();
508 }
509
510 public Object put(Object key, Object value) {
511 if (!(key instanceof String) ||
512 !(value instanceof String))
513 throw new IllegalArgumentException("both args must be strings");
514
515 prefs.setPreference((String)key, (String)value);
516
506 public Set<String> keySet() {
507 throw new UnsupportedOperationException();
508 }
509
510 public String put(String key, String value) {
511 prefs.setPreference(key, value);
517512 return null;
518513 }
519514
520 public void putAll(Map t) {
521 throw new UnsupportedOperationException();
522 }
523
524 public Object remove(Object key) {
515 public void putAll(Map<? extends String, ? extends String> t) {
516 throw new UnsupportedOperationException();
517 }
518
519 public String remove(Object key) {
525520 throw new UnsupportedOperationException();
526521 }
527522
529524 throw new UnsupportedOperationException();
530525 }
531526
532 public Collection values() {
533 throw new UnsupportedOperationException();
534 }
535
536 // custom methods
537 public void put(String key, String value) {
538 prefs.setPreference(key, value);
527 public Collection<String> values() {
528 throw new UnsupportedOperationException();
539529 }
540530
541531 public String get(String key) {
542 return (String)(prefs.getPreference(key));
532 return prefs.getPreference(key);
543533 }
544534
545535 private Preferences prefs;
4545 public void initialize();
4646 public JComponent getViewComponent();
4747
48 void saveTreeState(Map m);
49 void restoreTreeState(Map m);
48 void saveTreeState(Map<String, String> m);
49 void restoreTreeState(Map<String, String> m);
5050
5151 }
208208 }
209209 };
210210
211 private class EnvEntryComparator implements Comparator {
211 private class EnvEntryComparator implements Comparator<TestEnvironment.Element> {
212212 EnvEntryComparator(int sortMode, String[] inherits) {
213213 this.sortMode = sortMode;
214214 this.inherits = inherits;
215215 }
216216
217 public int compare(Object o1, Object o2) {
218 TestEnvironment.Element e1 = (TestEnvironment.Element)o1;
219 TestEnvironment.Element e2 = (TestEnvironment.Element)o2;
217 public int compare(TestEnvironment.Element e1, TestEnvironment.Element e2) {
220218 // the following should be a switch statement, but JDK
221219 // 1.1.7 can't compile it: doesn't recognize KEY etc as
222220 // constants.
275273 if (currEnv == null)
276274 elems = null;
277275 else {
278 Collection e = currEnv.elements();
279 elems = (TestEnvironment.Element[]) (e.toArray(new TestEnvironment.Element[e.size()]));
276 Collection<TestEnvironment.Element> e = currEnv.elements();
277 elems = e.toArray(new TestEnvironment.Element[e.size()]);
280278 Arrays.sort(elems, new EnvEntryComparator(KEY, currEnv.getInherits()));
281279 }
282280 int newRowCount = getRowCount();
322320 return headings[columnIndex];
323321 }
324322
325 public Class getColumnClass(int columnIndex) {
323 public Class<?> getColumnClass(int columnIndex) {
326324 return String.class;
327325 }
328326
289289 // The following operation is slow and should arguably be
290290 // done by a worker thread, perhaps using the nested List class as
291291 // a Runnable.
292 SortedSet sortedEntries = new TreeSet(new Comparator() {
293 public int compare(Object o1, Object o2) {
294 String s1 = entryToString((ExcludeList.Entry)o1);
295 String s2 = entryToString((ExcludeList.Entry)o2);
292 SortedSet<ExcludeList.Entry> sortedEntries = new TreeSet<>(new Comparator<ExcludeList.Entry>() {
293 public int compare(ExcludeList.Entry o1, ExcludeList.Entry o2) {
294 String s1 = entryToString(o1);
295 String s2 = entryToString(o2);
296296 return s1.compareTo(s2);
297297 }
298298 });
299299
300300 if (list != null) {
301 for (Iterator iter = list.getIterator(false); iter.hasNext(); ) {
301 for (Iterator<?> iter = list.getIterator(false); iter.hasNext(); ) {
302302 ExcludeList.Entry ee = (ExcludeList.Entry) (iter.next());
303303 sortedEntries.add(ee);
304304 }
316316 // model never changes, so ignore listener
317317 }
318318
319 public Class getColumnClass(int columnIndex) {
319 public Class<?> getColumnClass(int columnIndex) {
320320 // for now, all are strings
321321 return String.class;
322322 }
7171 final List<ET_Control> controls = new ArrayList<ET_Control>();
7272
7373 JMenuBar menuBar = null;
74 HashMap map = new HashMap();
7574 private boolean shouldPauseTree;
7675 private PageFormat pageFormat;
7776
7877 public ExecTool(ExecToolManager mgr, TestSuite ts) throws Session.Fault {
79 super((ToolManager)mgr, "exec", "browse.window.csh");
78 super(mgr, "exec", "browse.window.csh");
8079 this.testSuite = ts;
8180 String testSuiteName = testSuite.getName();
8281 if (testSuiteName != null)
222221 v.add(null);
223222 }
224223 }
225 Action[] toolBarActions = (Action[])v.toArray(new Action[v.size()]);
224 Action[] toolBarActions = v.toArray(new Action[v.size()]);
226225
227226 Preferences p = Preferences.access();
228227
295294 }
296295
297296 @Override
298 protected void save(Map m) {
297 protected void save(Map<String, String> m) {
299298 for (ET_Control c:controls) {
300299 c.save(m);
301300 }
302301 }
303302
304303 @Override
305 protected void restore(Map m) {
304 protected void restore(Map<String, String> m) {
306305 for (ET_Control c:controls) {
307306 c.restore(m);
308307 }
626625 }
627626 }
628627
629 void saveTreeState(Map m) {
628 void saveTreeState(Map<String, String> m) {
630629 testTreePanel.saveTreeState(m);
631630 }
632631
633 void restoreTreeState(Map m) {
632 void restoreTreeState(Map<String, String> m) {
634633 testTreePanel.restoreTreeState(m);
635634 }
636635
301301 if (conManager != null && conManager.getFeatureManager().isEnabled(
302302 FeatureManager.SINGLE_TEST_MANAGER)) {
303303 Tool[] tools = d.getTools();
304 ArrayList list = new ArrayList();
304 ArrayList<Tool> list = new ArrayList<>();
305305 for (int i = 0; i < tools.length; i++) {
306306 if (tools[i] instanceof ExecTool) {
307307 ExecTool tool = (ExecTool) tools[i];
346346 }
347347
348348 @Override
349 protected void save(Map m) {
349 protected void save(Map<String, String> m) {
350350 }
351351
352352 @Override
353 protected void restore(Map m) {
353 protected void restore(Map<String, String> m) {
354354 }
355355
356356 }
395395 }
396396 }
397397
398 public Tool restoreTool(Map m) throws Fault {
398 public Tool restoreTool(Map<String, String> m) throws Fault {
399399 try {
400400 //
401 String tsp = (String) (m.get("testSuite"));
401 String tsp = m.get("testSuite");
402402 TestSuite ts = TestSuite.open(new File(tsp));
403403 ExecTool et = new ExecTool(this, ts);
404404 et.restore(m);
429429 }
430430 }
431431
432 private static InterviewParameters getInterview(Map m) throws Interview.Fault {
433 String tsp = (String) (m.get("testSuite"));
434 String wdp = (String) (m.get("workDir"));
435 String cfp = (String) (m.get("config"));
432 private static InterviewParameters getInterview(Map<String, String> m) throws Interview.Fault {
433 String tsp = (m.get("testSuite"));
434 String wdp = (m.get("workDir"));
435 String cfp = (m.get("config"));
436436 if (isEmpty(tsp) && isEmpty(wdp) && isEmpty(cfp))
437437 return null;
438438
527527 }
528528
529529 void showError(String key) {
530 showError(key, (String[]) null);
530 showError(key, null);
531531 }
532532
533533 void showError(String key, Object arg) {
4141 static protected String[] cNames = {"File Name", "Name", "Description"};
4242
4343 // Types of the columns.
44 static protected Class[] cTypes = { String.class,
44 static protected Class<?>[] cTypes = { String.class,
4545 String.class, String.class};
4646
4747 private FileTableFilter filter = null;
4848
4949 private FileTableNode root;
50 private ArrayList data;
51 private LinkedHashMap fileData;
50 private ArrayList<FileTableNode> data;
51 private LinkedHashMap<String, String[]> fileData;
5252 private boolean allowTraversDirs;
5353 private File defTemplateDir;
5454
8181 return cNames[column];
8282 }
8383
84 public Class getColumnClass(int column) {
84 public Class<?> getColumnClass(int column) {
8585 return cTypes[column];
8686 }
8787
100100
101101 private void init(final File file) {
102102 root = new FileTableNode(file, 'r');
103 data = new ArrayList();
103 data = new ArrayList<>();
104104
105105 // if(allowTraversDirs) {
106106 // data.add(new FileTableNode(root.getFile(), 'u'));
135135
136136 public Object getValueAt(int rowIndex, int columnIndex) {
137137 if (rowIndex < 0 || rowIndex >= data.size() ) return null;
138 FileTableNode f = (FileTableNode) data.get(rowIndex);
138 FileTableNode f = data.get(rowIndex);
139139 File file = f.getFile();
140140 if (file == null) return null;
141141 if (columnIndex == 0) return f;//file.getName();
147147
148148 public File getNode(int rowIndex) {
149149 if (rowIndex < 0 || rowIndex >= data.size() ) return null;
150 return ((FileTableNode) data.get(rowIndex)).getFile();
150 return (data.get(rowIndex)).getFile();
151151 }
152152
153153
165165
166166 private String[] getInfo(File file) {
167167
168 if (fileData == null) fileData = new LinkedHashMap() {
169 protected boolean removeEldestEntry(Map.Entry eldest) {
168 if (fileData == null) fileData = new LinkedHashMap<String, String[]>() {
169 protected boolean removeEldestEntry(Map.Entry<String, String[]> eldest) {
170170 return size() > 500;
171171 }
172172 };
173173 String key = file.getAbsolutePath();
174 String[] value = (String[]) fileData.get(key);
174 String[] value = fileData.get(key);
175175 if (value != null) {
176176 return value;
177177 }
101101 return;
102102
103103 // record this filter officially
104 filters = (TestFilter[])DynamicArray.append(filters, f);
104 filters = DynamicArray.append(filters, f);
105105
106106 // register as change observer if possible
107107 if (f instanceof ObservableTestFilter) {
134134 return;
135135
136136 // remove this filter officially
137 filters = (TestFilter[])DynamicArray.remove(filters, f);
137 filters = DynamicArray.remove(filters, f);
138138
139139 if (f instanceof ObservableTestFilter)
140140 ((ObservableTestFilter)f).removeObserver(listener);
201201
202202 synchronized FilterSelectionHandler createFilterSelectionHandler() {
203203 FilterSelectionHandler fsh = new FilterSelectionHandler(this, uif);
204 handlers = (FilterSelectionHandler[])DynamicArray.append(handlers, fsh);
204 handlers = DynamicArray.append(handlers, fsh);
205205
206206 return fsh;
207207 }
213213 if (obs == null)
214214 obs = new Observer[0];
215215
216 obs = (Observer[])DynamicArray.append(obs, o);
216 obs = DynamicArray.append(obs, o);
217217 }
218218
219219 public synchronized void removeObserver(Observer o) {
220 obs = (Observer[])DynamicArray.remove(obs, o);
220 obs = DynamicArray.remove(obs, o);
221221 }
222222
223223 /**
402402 leftList.setSelectedIndex(index);
403403
404404 // update right panel
405 selectedFilter = (TestFilter)(listModel.elementAt(index));
405 selectedFilter = listModel.elementAt(index);
406406 if (selectedFilter instanceof ConfigurableTestFilter) {
407407 if (mode == -1 || mode == UNEDITABLE) {
408408 nameCards.show(namePanel, NAMING_ACTIVE);
416416 ConfigurableTestFilter ctf = (ConfigurableTestFilter)selectedFilter;
417417 namingName.setText(ctf.getName());
418418
419 String cardKey = (String)(configPanelHash.get(ctf));
419 String cardKey = configPanelHash.get(ctf);
420420 configCards.show(configPanel, cardKey);
421421 }
422422 else if (selectedFilter instanceof TestFilter) {
503503 selectIndex(0); // the default
504504 }
505505
506 private ListModel createListModel() {
507 listModel = new DefaultListModel();
506 private ListModel<TestFilter> createListModel() {
507 listModel = new DefaultListModel<>();
508508
509509 for (int i = 0; i < filters.length; i++)
510510 listModel.addElement(filters[i]);
687687 private JPanel createConfigPanel() {
688688 configCards = new CardLayout();
689689 configPanel = new JPanel(configCards);
690 configPanelHash = new Hashtable();
690 configPanelHash = new Hashtable<>();
691691
692692 // insert panels?
693693 configPanel.add(CONFIG_EMPTY, EMPTY_CONFIG);
809809 }
810810
811811 private JSplitPane split;
812 private JList leftList;
813 private DefaultListModel listModel;
812 private JList<TestFilter> leftList;
813 private DefaultListModel<TestFilter> listModel;
814814 private int lastSelected = -1;
815815 private TestFilter selectedFilter;
816816
842842 // config panel
843843 private CardLayout configCards;
844844 private JPanel configPanel;
845 private Hashtable configPanelHash;
845 private Hashtable<ConfigurableTestFilter, String> configPanelHash;
846846 private int configCounter; // to make a unique string
847847
848848 private JComponent EMPTY_CONFIG;
8989 if (obs == null)
9090 obs = new Observer[0];
9191
92 obs = (Observer[])DynamicArray.append(obs, o);
92 obs = DynamicArray.append(obs, o);
9393 }
9494
9595 public void removeObserver(Observer o) {
96 obs = (Observer[])DynamicArray.remove(obs, o);
96 obs = DynamicArray.remove(obs, o);
9797 }
9898
9999 /**
349349 private UIFactory uif;
350350
351351 private TestFilter activeFilter;
352 private JComboBox selectBox;
352 private JComboBox<TestFilter> selectBox;
353353 private JButton configButton;
354354 private JMenu editMenu;
355355 private ButtonGroup menuGroup;
6464
6565 import com.sun.interview.Interview;
6666 import com.sun.interview.Question;
67 import com.sun.interview.wizard.QuestionRenderer;
6768 import com.sun.javatest.InterviewParameters;
6869 import com.sun.javatest.TestSuite;
6970 import com.sun.javatest.WorkDirectory;
749750 return false;
750751 }
751752
752 Map aQuestions = a.getAllQuestions();
753 Map bQuestions = b.getAllQuestions();
754
755 Set keys = new TreeSet();
753 Map<String, Question> aQuestions = a.getAllQuestions();
754 Map<String, Question> bQuestions = b.getAllQuestions();
755
756 Set<String> keys = new TreeSet<>();
756757 keys.addAll(aQuestions.keySet());
757758 keys.addAll(bQuestions.keySet());
758759
759 for (Iterator iter = keys.iterator(); iter.hasNext(); ) {
760 String key = (String) (iter.next());
761 Question aq = (Question) aQuestions.get(key);
762 Question bq = (Question) bQuestions.get(key);
760 for (Iterator<String> iter = keys.iterator(); iter.hasNext(); ) {
761 String key = (iter.next());
762 Question aq = aQuestions.get(key);
763 Question bq = bQuestions.get(key);
763764 if (aq == null || bq == null) {
764765 return false;
765766 }
787788 }
788789 }
789790 // Checking external values
790 Set aKeys = a.getPropertyKeys();
791 Set bKeys = b.getPropertyKeys();
791 Set<String> aKeys = a.getPropertyKeys();
792 Set<String> bKeys = b.getPropertyKeys();
792793
793794 if (aKeys == null || bKeys == null) {
794795 return aKeys == bKeys;
798799 return false;
799800 }
800801
801 for (Iterator iter = aKeys.iterator(); iter.hasNext(); ) {
802 String key = (String)iter.next();
802 for (Iterator<String> iter = aKeys.iterator(); iter.hasNext(); ) {
803 String key = iter.next();
803804 if (!bKeys.contains(key)) {
804805 return false;
805806 }
935936 JMenu fileMenu = uif.createMenu("ce.file", fileMenuItems, listener);
936937
937938 FileHistory h = FileHistory.getFileHistory(viewConfig.getWorkDirectory(), getHistoryFileName());
938 FileHistory.Listener l = new FileHistory.Listener(h, 0, (ActionListener)listener);
939 FileHistory.Listener l = new FileHistory.Listener(h, 0, listener);
939940 recentConfigMenu = uif.createMenu("ce.history");
940941 recentConfigMenu.setEnabled(h.getLatestEntry() != null);
941942 recentConfigMenu.addMenuListener(l);
11921193 throws Interview.Fault
11931194 {
11941195 //System.err.println("CE.copy from " + (from==mainConfig?"main":from==viewConfig?"view":from.toString()) + " to " + (to==mainConfig?"main":to==viewConfig?"view":to.toString()));
1195 HashMap data = new HashMap();
1196 Map<String, String> data = new HashMap<>();
11961197 from.save(data);
11971198 to.load(data, false);
11981199 to.setTemplate(from.isTemplate());
15571558 private Listener listener;
15581559 //private TemplatesUI templatesUI;
15591560
1560 private Map customRenderersMap;
1561 private Map<Class<? extends Question>, QuestionRenderer> customRenderersMap;
15611562 private ActionListener closeListener;
15621563 //private ExecModel model;
15631564 private final List<Observer> observers = new ArrayList<Observer>();
15871588 static final String VIEW_PREF = "exec.config.view";
15881589
15891590
1590 public void setCustomRenderers(Map renderersMap) {
1591 public void setCustomRenderers(Map<Class<? extends Question>, QuestionRenderer> renderersMap) {
15911592 customRenderersMap = renderersMap;
15921593 if (fullView != null) {
15931594 fullView.setCustomRenderers(customRenderersMap);
6666 if (bank == null)
6767 return null;
6868 else {
69 ArrayList al = bank[position];
69 ArrayList<JMenuItem> al = bank[position];
7070 if (al.size() == 0)
7171 return null;
7272 else {
9898 if (bank == null) {
9999 bank = new ArrayList[NUM_POSITIONS];
100100 for (int i = 0; i < NUM_POSITIONS; i++)
101 bank[i] = new ArrayList();
101 bank[i] = new ArrayList<>();
102102 }
103103
104104 bank[position].add(item);
128128 public static final int TOOLS_OTHER = 17;
129129
130130 private static final int NUM_POSITIONS = 18;
131 private ArrayList[] bank;
131 private ArrayList<JMenuItem>[] bank;
132132 }
145145 state.put(USER_TOOLBAR_PREF + getId(), Boolean.toString(visible));
146146 }
147147
148 void save(Map map) {
148 void save(Map<String, Object> map) {
149149 map.putAll(state);
150150 }
151151
152152 /**
153153 * Accepts Map with parameters from ExecTool
154154 **/
155 void load(Map map) {
156 for (Object okey : map.keySet()) {
157 String key = (String)okey;
155 void load(Map<String, Object> map) {
156 for (String okey : map.keySet()) {
157 String key = okey;
158158 String tbKey = USER_TOOLBAR_PREF + getId();
159159 if (key.contains(tbKey)) {
160160 state.put(okey, map.get(okey));
231231 private boolean inMenu = false;
232232 private ResourceBundle theBundle;
233233 private String id;
234 private Map state = new HashMap();
234 private Map<String, Object> state = new HashMap<>();
235235 }
975975
976976
977977 private class CustomRenderer extends JComponent
978 implements ListCellRenderer {
978 implements ListCellRenderer<Object> {
979979 public Component getListCellRendererComponent(
980 JList list, Object value, int index, boolean isSelected,
980 JList<?> list, Object value, int index, boolean isSelected,
981981 boolean cellHasFocus) {
982982 if (!(value instanceof JSeparator) && !(value instanceof JCheckBox)) {
983983 DefaultListCellRenderer defRend = new DefaultListCellRenderer();
11341134 }
11351135
11361136 public void actionPerformed(ActionEvent e) {
1137 JComboBox cb = (JComboBox) e.getSource();
1137 JComboBox<?> cb = (JComboBox<?>) e.getSource();
11381138 Object o = cb.getSelectedItem();
11391139 if (o instanceof FilterComboboxItem) {
11401140 FilterComboboxItem fc = (FilterComboboxItem) o;
12991299 LoggerFactory.getLocalizedLevelName(Level.FINE) } ;
13001300
13011301 private DefaultMutableTreeNode treeRoot;
1302 private JComboBox filterCombo;
1302 private JComboBox<?> filterCombo;
13031303 private JTree filterTree ;
13041304
13051305 private boolean noWindow = false;
335335 private JButton selectButt;
336336 private JButton magButt;
337337
338 private JComboBox selector;
338 private JComboBox<Monitor> selector;
339339 private JPopupMenu popMenu;
340340 private ActionListener actionListener = new SelectionListener();
341341 private ActionListener zoomListener;
8181 }
8282
8383 void addObserver(Observer o) {
84 obs = (Observer[])DynamicArray.append(obs, o);
84 obs = DynamicArray.append(obs, o);
8585 }
8686
8787 void removeObserver(Observer o) {
88 obs = (Observer[])DynamicArray.remove(obs, o);
88 obs = DynamicArray.remove(obs, o);
8989 }
9090
9191 /**
324324 private Observer[] obs = new Observer[0];
325325 private volatile int[] stats;
326326
327 private ArrayList<TestResult> runningTests = new ArrayList(5);
327 private ArrayList<TestResult> runningTests = new ArrayList<>(5);
328328 private final Object vLock = new Object();
329329
330330 /**
4040 import java.util.HashMap;
4141 import java.util.Iterator;
4242 import javax.imageio.ImageIO;
43 import javax.imageio.ImageReader;
4344 import javax.imageio.stream.ImageInputStream;
4445 import javax.sound.midi.InvalidMidiDataException;
4546 import javax.sound.midi.MidiFileFormat;
8081 listener = new Listener();
8182 initGUI();
8283
83 modesToPanes = new HashMap();
84 modesToPanes = new HashMap<>();
8485
8586 addMediaPane(TEXT, textPane);
8687 addMediaPane(AUDIO, musicPane);
102103 }
103104
104105 public MediaPane getMediaPane(int mode) {
105 return (MediaPane)modesToPanes.get(mode);
106 return modesToPanes.get(mode);
106107 }
107108
108109 public void clear() {
557558 private JTextField noteField;
558559 private NavigationPane navPane;
559560
560 private HashMap modesToPanes;
561 private HashMap<Integer, MediaPane> modesToPanes;
561562 }
562563
563564
657658 String ext = filename.substring(filename.lastIndexOf('.') + 1);
658659 ext = ext.toLowerCase();
659660
660 return (String)extensionsToMIME.get(ext);
661 return extensionsToMIME.get(ext);
661662 }
662663
663664 public void showTextArea() {
717718 private RTFEditorKit rtfKit;
718719
719720
720 private static HashMap extensionsToMIME;
721 private static HashMap<String, String> extensionsToMIME;
721722 static {
722 extensionsToMIME = new HashMap();
723 extensionsToMIME = new HashMap<>();
723724 extensionsToMIME.put("html", "text/html");
724725 extensionsToMIME.put("htm", "text/html");
725726 extensionsToMIME.put("htmls", "text/html");
958959 public static boolean isImageResource(URL url) {
959960 String file = url.getFile();
960961 String ext = file.substring(file.lastIndexOf('.')+1);
961 Iterator iter = ImageIO.getImageReadersBySuffix(ext);
962 Iterator<ImageReader> iter = ImageIO.getImageReadersBySuffix(ext);
962963 return iter.hasNext();
963964 }
964965
965966 public static boolean isImageFormatSupported(URL url) {
966967 try {
967968 ImageInputStream iis = ImageIO.createImageInputStream(new File(url.getFile()));
968 Iterator iter = ImageIO.getImageReaders(iis);
969 Iterator<ImageReader> iter = ImageIO.getImageReaders(iis);
969970 if(!iter.hasNext())
970971 return false;
971972 } catch (IOException exc) {
9090 setLayout(new GridBagLayout());
9191 setMinimumSize(new Dimension(150, 100));
9292
93 listModel = new DefaultListModel();
93 listModel = new DefaultListModel<>();
9494 nodeList = uif.createList("ms.nlist", listModel);
9595 GridBagConstraints gbc = new GridBagConstraints();
9696 gbc.weightx= 1.0;
166166
167167 private TestTreeModel ttm;
168168 private TreePanelModel tpm;
169 private JList nodeList;
170 private DefaultListModel listModel;
169 private JList<?> nodeList;
170 private DefaultListModel<Object> listModel;
171171 private Object[] nodes;
172172
173173 private UIFactory uif;
209209 }
210210
211211
212 private DefaultComboBoxModel createModel() {
212 private DefaultComboBoxModel<URL> createModel() {
213213 if (model == null)
214 model = new DefaultComboBoxModel();
214 model = new DefaultComboBoxModel<>();
215215 return model;
216216 }
217217
248248 if (index == 0)
249249 return null;
250250
251 return (URL) (entries.elementAt(--index));
251 return entries.elementAt(--index);
252252 }
253253
254254 boolean hasNext() {
259259 if (index == entries.size() - 1)
260260 return null;
261261
262 return (URL) (entries.elementAt(++index));
262 return entries.elementAt(++index);
263263 }
264264
265265 void add(URL u) {
284284 index = -1;
285285 }
286286
287 private Vector entries = new Vector();
287 private Vector<URL> entries = new Vector<>();
288288 private int index;
289289 }
290290
303303 sf = new StringFitter(getFontMetrics(getFont()));
304304 }
305305
306 public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) {
306 public Component getListCellRendererComponent(JList<?> list, Object o, int index, boolean isSelected, boolean cellHasFocus) {
307307 String name = null;
308308 if (o instanceof URL) {
309309 URL url = (URL) o;
366366 private JButton backBtn;
367367 private JButton forwardBtn;
368368
369 private JComboBox selectBox;
370
371 private DefaultComboBoxModel model;
369 private JComboBox<URL> selectBox;
370
371 private DefaultComboBoxModel<URL> model;
372372 private Listener listener = new Listener();
373373 private JToolBar toolBar;
374374
111111 * The dialog is done. Notify the observer to keep a snapshot of
112112 * current state.
113113 */
114 public void update(Map l);
114 public void update(Map<String, String> l);
115115
116116 // starting
117117 public void writingReport();
140140
141141 // ---------------------------------------------------------------------------
142142
143 void setLastState(Map h) {
144 String rd = (String) (h.get(REPORT_DIR));
145 String filter = (String) (h.get(FILTER));
143 void setLastState(Map<String, String> h) {
144 String rd = (h.get(REPORT_DIR));
145 String filter = (h.get(FILTER));
146146
147147 if (dirField == null)
148148 initGUI();
156156 updateCofCheckboxStates();
157157 }
158158
159 Map getLastState() {
160 String rd = (String) (dirField.getText());
159 Map<String, String> getLastState() {
160 String rd = dirField.getText();
161161 String filter = filterHandler.getActiveFilter().getName();
162 Map lastState = new HashMap();
162 Map<String, String> lastState = new HashMap<>();
163163
164164 if (rd != null && rd.length() > 0)
165165 lastState.put(REPORT_DIR, rd);
171171 }
172172
173173 void addObserver(Observer o) {
174 obs = (Observer[])DynamicArray.append(obs, o);
174 obs = DynamicArray.append(obs, o);
175175 }
176176
177177 void removeObserver(Observer o) {
178 obs = (Observer[])DynamicArray.remove(obs, o);
178 obs = DynamicArray.remove(obs, o);
179179 }
180180
181181 // Notify the observers that a change has been made.
182 private void notifyUpdate(Map s) {
182 private void notifyUpdate(Map<String, String> s) {
183183 for (Observer o : obs) {
184184 o.update(s);
185185 }
298298 tabs.setTabPlacement(SwingConstants.TOP);
299299 tabs.setBorder(BorderFactory.createEmptyBorder());
300300
301 listModel = new DefaultListModel();
301 listModel = new DefaultListModel<>();
302302
303303 // populate list and card panel
304304 final CardLayout cards = new CardLayout();
380380 if (itemCount > 9) itemCount = 9;
381381 for (int i = 1; i <= itemCount; ++i) {
382382 list.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(i + '0', InputEvent.ALT_DOWN_MASK), ACTION_MAP_KEY);
383 JCheckBox box = ((JCheckBox)listModel.getElementAt(i - 1));
383 JCheckBox box = listModel.getElementAt(i - 1);
384384 box.setMnemonic(i + '0');
385385 box.setText(Character.toString((char)('0' + i)) + " " + box.getText());
386386 }
387387
388388 if (listModel.size() == 10){
389389 list.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('0', InputEvent.ALT_DOWN_MASK), ACTION_MAP_KEY);
390 JCheckBox box = ((JCheckBox)listModel.getElementAt(9));
390 JCheckBox box = listModel.getElementAt(9);
391391 box.setMnemonic('0');
392392 box.setText("0 " + box.getText());
393393 }
780780 return 0;
781781 }
782782
783 customBoxes = new HashMap();
783 customBoxes = new HashMap<>();
784784
785785 for (int i = 0; i < customReports.length; i++) {
786786 JCheckBox cb = new JCheckBox(customReports[i].getName());
815815 */
816816 private boolean hasSelectedCheckBox() {
817817 for (int i = 0; i < listModel.getSize(); i++) {
818 if (((JCheckBox)listModel.getElementAt(i)).isSelected()) {
818 if (listModel.getElementAt(i).isSelected()) {
819819 return true;
820820 }
821821 }
845845 }
846846 else {
847847 String[] names = Report.getHtmlReportFilenames();
848 ArrayList possible = new ArrayList();
848 ArrayList<File> possible = new ArrayList<>();
849849
850850 for (int i = 0; i < names.length; i++) {
851851 File rpt = new File(reportDir, names[i]);
862862 long newestTime = 0;
863863
864864 for (int i = 0; i < possible.size(); i++) {
865 File file = (File)(possible.get(i));
865 File file = possible.get(i);
866866 if (file.lastModified() > newestTime) {
867867 newestF = file;
868868 newestTime = file.lastModified();
898898
899899 private ArrayList<CustomReport> getActiveCustomReports() {
900900
901 ArrayList customReps = new ArrayList();
901 ArrayList<CustomReport> customReps = new ArrayList<>();
902902 if (customBoxes != null && customBoxes.size() > 0) {
903 Iterator it = customBoxes.keySet().iterator();
903 Iterator<JCheckBox> it = customBoxes.keySet().iterator();
904904 while (it.hasNext()) {
905 JCheckBox box = (JCheckBox)(it.next());
905 JCheckBox box = (it.next());
906906 if (box.isSelected()) {
907907 customReps.add(customBoxes.get(box));
908908 }
921921
922922 if (!cbHtml.isSelected()) {
923923 for (int i = 0; i < htmlGroup.size(); i++)
924 ((JCheckBox)(htmlGroup.get(i))).setEnabled(false);
924 htmlGroup.get(i).setEnabled(false);
925925 }
926926 else {
927927 for (int i = 0; i < htmlGroup.size(); i++)
928 ((JCheckBox)(htmlGroup.get(i))).setEnabled(true);
928 htmlGroup.get(i).setEnabled(true);
929929 for (int i = 0; i < configGroup.size(); i++)
930 ((JCheckBox)(configGroup.get(i))).setEnabled(cbConfig.isSelected());
930 configGroup.get(i).setEnabled(cbConfig.isSelected());
931931 }
932932 }
933933
10781078 }
10791079 }
10801080 else if (src == okBtn) {
1081 String s = (String) dirField.getText();
1081 String s = dirField.getText();
10821082
10831083 // check null input
10841084 if (s == null || s.length() == 0) {
10951095 }
10961096
10971097 // validate custom reports
1098 Iterator it = getActiveCustomReports().iterator();
1098 Iterator<CustomReport> it = getActiveCustomReports().iterator();
10991099 while (it.hasNext()) {
1100 CustomReport cr = (CustomReport) it.next();
1100 CustomReport cr = it.next();
11011101 String error = cr.validateOptions();
11021102 if (error != null) {
11031103 for (int i = 0; i < listModel.getSize(); i++ ) {
1104 JCheckBox cb = (JCheckBox)listModel.elementAt(i);
1104 JCheckBox cb = listModel.elementAt(i);
11051105 if (cb.getName().equals(cr.getReportId())) {
11061106 list.setSelectedIndex(i);
11071107 }
13661366 * @param p parent Panel
13671367 * @param cardLayout The CardLayout for options
13681368 */
1369 SelectListener(JList lst, JPanel p, CardLayout cardLayout ) {
1369 SelectListener(JList<?> lst, JPanel p, CardLayout cardLayout ) {
13701370 list = lst;
13711371 listModel = list.getModel();
13721372 lastSelected = listModel.getElementAt(0);
14081408 tab.setEnabled(box.isSelected());
14091409 }
14101410 if (customBoxes != null) {
1411 CustomReport rep = (CustomReport) customBoxes.get(box);
1411 CustomReport rep = customBoxes.get(box);
14121412 if (rep != null && rep.getOptionPanes() != null) {
14131413 for (int i = 0; i < rep.getOptionPanes().length; i++) {
14141414 rep.getOptionPanes()[i].setEnabled(box.isSelected());
14291429 else if (box == cbCof)
14301430 infoArea.setText(uif.getI18NString("nrd.info.cof.txt"));
14311431 else if (customBoxes != null) {
1432 CustomReport rep = (CustomReport) customBoxes.get(box);
1432 CustomReport rep = customBoxes.get(box);
14331433 if (rep != null)
14341434 infoArea.setText(rep.getDescription());
14351435 }
14761476 }
14771477
14781478 Object lastSelected;
1479 JList list;
1480 ListModel listModel;
1479 JList<?> list;
1480 ListModel<?> listModel;
14811481 JPanel panel;
14821482 CardLayout cards;
14831483 JButton okBtn = null; // should be disable iff all check boxes are off
15001500 */
15011501 public void propertyChange(PropertyChangeEvent evt) {
15021502 if ("enabled".equals(evt.getPropertyName())) {
1503 boolean oldV = ((Boolean) evt.getOldValue()).booleanValue();
1504 boolean newV = ((Boolean) evt.getNewValue()).booleanValue();
1503 boolean oldV = (Boolean) evt.getOldValue();
1504 boolean newV = (Boolean) evt.getNewValue();
15051505 if (oldV && !newV) {
15061506 // disable
1507 Iterator chIt = collectChildren(theContainer, new ArrayList()).iterator();
1508 enabledComp = new HashSet();
1509 while (chIt.hasNext()) {
1510 Component c = (Component) chIt.next();
1507 enabledComp = new HashSet<>();
1508 for (Component c: collectChildren(theContainer, new ArrayList<Component>())) {
15111509 if (c.isEnabled()) {
15121510 enabledComp.add(c);
15131511 c.setEnabled(false);
15141512 }
15151513 }
1516
15171514 } else if (!oldV && newV && enabledComp != null) {
15181515 // enable
1519 Iterator chIt = collectChildren(theContainer, new ArrayList()).iterator();
1520 while (chIt.hasNext()) {
1521 Component c = (Component) chIt.next();
1516 for (Component c: collectChildren(theContainer, new ArrayList<Component>())) {
15221517 if (enabledComp.contains(c)) {
15231518 c.setEnabled(true);
15241519 }
15301525 /**
15311526 * Recursively gathers all children components
15321527 */
1533 private Collection collectChildren(Container comp, Collection c) {
1528 private Collection<Component> collectChildren(Container comp, Collection<Component> c) {
15341529 Component [] ch = comp.getComponents();
15351530 for(int i = 0; i < ch.length; i++) {
15361531 c.add(ch[i]);
15421537 }
15431538
15441539 private Container theContainer;
1545 private HashSet enabledComp;
1546 }
1547
1548 private class CheckBoxListCellRenderer implements ListCellRenderer {
1540 private HashSet<Component> enabledComp;
1541 }
1542
1543 private class CheckBoxListCellRenderer implements ListCellRenderer<JComponent> {
15491544 public Component getListCellRendererComponent(
1550 JList list,
1551 Object value,
1545 JList<? extends JComponent> list,
1546 JComponent value,
15521547 int index,
15531548 boolean isSelected,
15541549 boolean cellHasFocus) {
15551550 // assert: value is a JCheckBox
1556 JComponent comp = (JComponent)value;
1551 JComponent comp = value;
15571552 if (isSelected) {
15581553 comp.setOpaque(true);
15591554 comp.setBackground(list.getSelectionBackground());
15731568
15741569 private ReportDirChooser reportDirChooser;
15751570
1576 private DefaultListModel listModel;
1577 private JList list;
1571 private DefaultListModel<JCheckBox> listModel;
1572 private JList<? extends JComponent> list;
15781573 private JTextArea infoArea;
15791574 private CustomReport[] customReports;
1580 private HashMap customBoxes;
1575 private HashMap<JCheckBox, CustomReport> customBoxes;
15811576
15821577 private JComponent[] panes;
15831578 private JCheckBox cbHtml;
16101605 private JCheckBox cbBak;
16111606 private JTextField numBak;
16121607
1613 private ArrayList htmlGroup = new ArrayList();
1614 private ArrayList configGroup = new ArrayList();
1615 private ArrayList kflGroup = new ArrayList();
1608 private ArrayList<JCheckBox> htmlGroup = new ArrayList<>();
1609 private ArrayList<JCheckBox> configGroup = new ArrayList<>();
1610 private ArrayList<JCheckBox> kflGroup = new ArrayList<>();
16161611
16171612 private File reportDir;
16181613 private JButton browseBtn;
8080 }
8181
8282 @Override
83 public void load(Map m) {
83 public void load(Map<String, String> m) {
8484 super.load(m);
85 String p = (String) (m.get(ExecTool.TOOLBAR_PREF));
85 String p = m.get(ExecTool.TOOLBAR_PREF);
8686 toolBarChk.setSelected(p == null || p.equals("true"));
87 p = (String) (m.get(ExecTool.FILTER_WARN_PREF));
87 p = m.get(ExecTool.FILTER_WARN_PREF);
8888 filterWarnChk.setSelected(p == null || p.equals("true"));
89 p = (String) (m.get(TP_OutputSubpanel.LINE_WRAP_PREF));
89 p = m.get(TP_OutputSubpanel.LINE_WRAP_PREF);
9090 // selected by default
9191 wrapResChk.setSelected((p == null ? true : p.equals("true")));
9292 }
9393
9494 @Override
95 public void save(Map m) {
95 public void save(Map<String, String> m) {
9696 super.save(m);
9797 m.put(ExecTool.TOOLBAR_PREF, String.valueOf(toolBarChk.isSelected()));
9898 m.put(ExecTool.FILTER_WARN_PREF, String.valueOf(filterWarnChk.isSelected()));
175175 }
176176
177177 @Override
178 public void load(Map m) {
179 String mp = (String) (m.get(InterviewEditor.MORE_INFO_PREF));
178 public void load(Map<String, String> m) {
179 String mp = m.get(InterviewEditor.MORE_INFO_PREF);
180180 moreInfoChk.setSelected(mp == null || mp.equals("true"));
181181 }
182182
183183 @Override
184 public void save(Map m) {
184 public void save(Map<String, String> m) {
185185 m.put(InterviewEditor.MORE_INFO_PREF, String.valueOf(moreInfoChk.isSelected()));
186186 }
187187
236236 }
237237
238238 @Override
239 public void load(Map m) {
240 String mp = (String) (m.get(ReportManager.BUGRPT_URL_PREF));
239 public void load(Map<String, String> m) {
240 String mp = m.get(ReportManager.BUGRPT_URL_PREF);
241241 bugUrlTf.setText(mp);
242242 }
243243
244244 @Override
245 public void save(Map m) {
245 public void save(Map<String, String> m) {
246246 m.put(ReportManager.BUGRPT_URL_PREF, bugUrlTf.getText());
247247 }
248248
306306 }
307307
308308 @Override
309 public void load(Map m) {
310 String mp = (String) (m.get("javatest.executionOrder"));
309 public void load(Map<String, String> m) {
310 String mp = m.get("javatest.executionOrder");
311311 if (mp == null) {
312312 mp = "default";
313313 }
322322 defaultRadio.setSelected(true);
323323 }
324324
325 mp = (String) (m.get(ExecTool.TESTS2RUN_PREF));
325 mp = m.get(ExecTool.TESTS2RUN_PREF);
326326 tests2RunChk.setSelected((mp == null ? false : mp.equals("true")));
327 mp = (String) (m.get("javatest.sortExecution"));
327 mp = m.get("javatest.sortExecution");
328328 testSortingChk.setSelected((mp == null ? false : mp.equals("false")));
329329 }
330330
331331 @Override
332 public void save(Map m) {
332 public void save(Map<String, String> m) {
333333 m.put(ExecTool.TESTS2RUN_PREF, String.valueOf(tests2RunChk.isSelected()));
334334 m.put("javatest.sortExecution", Boolean.toString(!testSortingChk.isSelected()));
335335
474474 }
475475
476476 private void initRunningCard() {
477 testListData = new DefaultListModel();
478 final JList list = uif.createList("pm.runlist", testListData);
477 testListData = new DefaultListModel<>();
478 final JList<?> list = uif.createList("pm.runlist", testListData);
479479 list.setBorder(BorderFactory.createEtchedBorder());
480480 list.setCellRenderer(RenderingUtilities.createTestListRenderer());
481481 list.addMouseListener(new MouseAdapter() {
513513 private JComponent runningCard;
514514
515515 private JTextField fileField;
516 private DefaultListModel testListData;
517 private JList testList;
516 private DefaultListModel<TestResult> testListData;
518517 private String rootDir;
519518 }
520519
4646 import java.io.InputStream;
4747 import java.io.FileInputStream;
4848 import java.net.URL;
49 import java.util.Properties;
50 import java.util.Set;
51 import java.util.TreeSet;
52 import java.util.Vector;
49 import java.util.*;
5350 import javax.swing.BorderFactory;
5451 import javax.swing.ButtonGroup;
5552 import javax.swing.Icon;
269266 private void doBack() {
270267 int n = history.size();
271268 if (n > 0) {
272 Pane p = (Pane) (history.remove(n - 1));
269 Pane p = history.remove(n - 1);
273270 setPane(p);
274271 }
275272 }
333330 // indicates using jtm or jti templates
334331 private boolean jtmTemplate = true;
335332
336 private Properties configData;
333 private Map<String, String> configData;
337334 private File configFile;
338335 private Properties jtmData;
339336 private File jtmFile;
364361 private JButton doneBtn;
365362 private Listener listener = new Listener();
366363 private KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
367 private Vector history = new Vector();
364 private Vector<Pane> history = new Vector<>();
368365 private boolean allowConfigLoadOutsideDefault;
369366 private File defaultConfigSavePath;
370367 private boolean allowConfigSaveOutsideDefault;
535532
536533 private JLabel label;
537534 private JTextField field;
538 private JComboBox combo;
535 private JComboBox<String> combo;
539536 private JComponent currPathComp;
540537 private JButton button;
541538 private DocumentListener listener;
714711
715712 Pane getNext() {
716713
717 return (task == NEW || task == BROWSE ? (Pane) testSuitePane
718 : task == RESUME ? (Pane) openWorkDirPane
714 return (task == NEW || task == BROWSE ? testSuitePane
715 : task == RESUME ? openWorkDirPane
719716 : null);
720717 }
721718
841838 }
842839 }
843840
844 return (task == NEW ? (Pane) newWorkDirPane : (Pane) endPane);
841 return (task == NEW ? newWorkDirPane : endPane);
845842 }
846843
847844
848845
849846 if (configData != null) {
850 String configDataInterview = (String) (configData.get("INTERVIEW"));
847 String configDataInterview = configData.get("INTERVIEW");
851848
852849 if (configDataInterview != null
853850 && !config.getClass().getName().equals(configDataInterview)) {
864861 }
865862 }
866863
867 return (config == null ? null : task == NEW ? (Pane) newWorkDirPane : (Pane) endPane);
864 return (config == null ? null : task == NEW ? newWorkDirPane : endPane);
868865
869866 }
870867
889886 }
890887
891888 try {
892 InputStream in = new BufferedInputStream(new FileInputStream(f));
893
894 try {
889
890 try (InputStream in = new BufferedInputStream(new FileInputStream(f))) {
895891 data.clear();
896892 data.load(in);
897893 file = f;
900896 // can get IllegalArgumentException if the file is corrupt
901897 uif.showError("qsw.cfg.cantReadFile", e);
902898 return null;
903 }
904 finally {
905 in.close();
906899 }
907900 }
908901 catch (IOException e) {
949942 // - installation directory and its parent
950943 // - current directory
951944
952 Set s = new TreeSet();
945 Set<String> s = new TreeSet<>();
953946 if (configData != null) {
954 String configTestSuite = (String) (configData.get("TESTSUITE"));
947 String configTestSuite = configData.get("TESTSUITE");
955948 if (configTestSuite != null)
956949 s.add(configTestSuite);
957950 }
966959 s.add(installParentDir.getPath());
967960
968961 if (s.size() > 0)
969 testSuitePanel.setSuggestions((String[]) (s.toArray(new String[s.size()])));
962 testSuitePanel.setSuggestions( s.toArray(new String[s.size()]));
970963 }
971964
972965 void updateNextButton() {
10391032 }
10401033
10411034
1042 return (task == NEW || task == BROWSE ? (Pane) configPane
1043 : task == RESUME ? (Pane) openWorkDirPane
1035 return (task == NEW || task == BROWSE ? configPane
1036 : task == RESUME ? openWorkDirPane
10441037 : null);
10451038
10461039 // return (config == null ? null : task == NEW ? (Pane) newWorkDirPane : (Pane) endPane);
4040 import com.sun.javatest.util.I18NResourceBundle;
4141
4242 class RenderingUtilities {
43 static ListCellRenderer createTestListRenderer() {
43 static ListCellRenderer<Object> createTestListRenderer() {
4444 return new TestCellRenderer(i18n);
4545 }
4646
47 static ListCellRenderer createTRTNodeRenderer() {
47 static ListCellRenderer<Object> createTRTNodeRenderer() {
4848 return new TestCellRenderer(i18n);
4949 }
5050
51 static ListCellRenderer createFilterListRenderer() {
51 static ListCellRenderer<TestFilter> createFilterListRenderer() {
5252 return new FilterCellRenderer(i18n);
5353 }
5454
6262 /**
6363 * Render a list of tests (TestResult objects).
6464 */
65 static class TestCellRenderer extends JLabel implements ListCellRenderer {
65 static class TestCellRenderer extends JLabel implements ListCellRenderer<Object> {
6666 public TestCellRenderer(I18NResourceBundle i18n) {
6767 setOpaque(false);
6868 this.i18n = i18n;
6969 }
7070
71 public Component getListCellRendererComponent(JList list,
71 public Component getListCellRendererComponent(JList<?> list,
7272 Object value, int index, boolean isSelected, boolean cellHasFocus) {
7373 if (value == null) // very strange...
7474 return this;
106106 return this;
107107 }
108108
109 private void setBasicAttribs(boolean isSelected, JList list) {
109 private void setBasicAttribs(boolean isSelected, JList<?> list) {
110110 // Hopefully safe to share...will help with saving space
111111 // This border is to provide space between the text and the
112112 // side of the widget, helping readability.
132132 * Render a list of test filters with their descriptive name.
133133 * @see com.sun.javatest.TestFilter#getName()
134134 */
135 static class FilterCellRenderer extends JLabel implements ListCellRenderer {
135 static class FilterCellRenderer extends JLabel implements ListCellRenderer<TestFilter> {
136136 public FilterCellRenderer(I18NResourceBundle i18n) {
137137 setOpaque(false);
138138 this.i18n = i18n;
139139 }
140140
141 public Component getListCellRendererComponent(JList list,
142 Object value, int index, boolean isSelected, boolean cellHasFocus) {
141 public Component getListCellRendererComponent(JList<? extends TestFilter> list,
142 TestFilter value, int index, boolean isSelected, boolean cellHasFocus) {
143143
144144 String name = null;
145145
146 TestFilter filter = (TestFilter)value;
146 TestFilter filter = value;
147147 name = filter.getName();
148148
149149 //setToolTipText(filter.getDescription());
158158 return this;
159159 }
160160
161 private void setColors(boolean isSelected, JList list) {
161 private void setColors(boolean isSelected, JList<?> list) {
162162 if (isSelected) {
163163 setOpaque(true);
164164 setForeground(list.getSelectionForeground());
118118 getReportBrowser(), model);
119119
120120 newReportD.addObserver(new NewReportDialog.Observer() {
121 public void update(Map l) {
121 public void update(Map<String, String> l) {
122122 lastState = l;
123123 String lastReportDir =
124 (String) (lastState.get(NewReportDialog.REPORT_DIR));
124 lastState.get(NewReportDialog.REPORT_DIR);
125125
126126 if (lastReportDir != null)
127127 history.add(new File(lastReportDir));
210210 }
211211 }
212212
213 public void save(Map parentMap) {
213 public void save(Map<String, String> parentMap) {
214214 if (lastState != null && lastState.size() > 0) {
215 PrefixMap pm = new PrefixMap(parentMap, REPORT_PREFIX);
215 PrefixMap<String> pm = new PrefixMap<>(parentMap, REPORT_PREFIX);
216216 pm.putAll(lastState);
217217 }
218218 }
219219
220 public void restore(Map parentMap) {
220 public void restore(Map<String, String> parentMap) {
221221 if (parentMap == null)
222222 return;
223223
224224 try {
225 PrefixMap pm = new PrefixMap(parentMap, REPORT_PREFIX);
225 PrefixMap<String> pm = new PrefixMap<>(parentMap, REPORT_PREFIX);
226226 if (pm == null) return;
227227
228228 Object[] keys = pm.keySet().toArray();
229229 if (lastState == null)
230 lastState = new HashMap();
230 lastState = new HashMap<>();
231231
232232 for (int i = 0; i < keys.length; i++) {
233233 String key = (String) keys[i];
234 String value = (String) pm.get(keys[i]);
234 String value = pm.get(keys[i]);
235235
236236 if (value != null)
237237 lastState.put(key, value);
327327 private FileHistory.Listener reportHistoryListener;
328328 private FileHistory history;
329329 private File lastOpenPath;
330 private Map lastState;
330 private Map<String, String> lastState;
331331 private ExecModel model;
332332 private NewReportDialog newReportD;
333333 private ReportBrowser reportBrowser;
170170 return Arrays.asList(getToolBarActions());
171171 }
172172
173 public void save(Map m) {
174 }
175 public void restore(Map m) {
173 public void save(Map<String, String> m) {
174 }
175 public void restore(Map<String, String> m) {
176176 }
177177
178178 public synchronized void dispose() {
280280 new Object[] {params.getEnv().getName()});
281281 p.setLayout(new BorderLayout());
282282 p.add(msg, BorderLayout.NORTH);
283 DefaultListModel model = new DefaultListModel();
283 DefaultListModel<String> model = new DefaultListModel<>();
284284 for (int i = paths.length; i > 0; i--)
285285 model.add(model.getSize(), paths[model.getSize()]);
286286
287 JList list = uif.createList("rh.confirmList", model);
287 JList<?> list = uif.createList("rh.confirmList", model);
288288 p.add(uif.createScrollPane(list,
289289 ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
290290 ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
370370 * @since 4.2.1
371371 */
372372 static String[] reprocessTests2Run(final String[] requested, final String[] iTests) {
373 ArrayList<String> result = new ArrayList();
373 ArrayList<String> result = new ArrayList<>();
374374 outer:
375375 for (int i = 0; i < requested.length; i++) {
376376 String curr = requested[i];
148148 * @param map
149149 * @throws com.sun.javatest.exec.Session.Fault
150150 */
151 public void save(Map map);
151 public void save(Map<String, String> map);
152152
153153
154154 /**
163163 * @param map
164164 * @throws com.sun.javatest.exec.Session.Fault
165165 */
166 public void restore(Map map) throws Fault;
166 public void restore(Map<String, String> map) throws Fault;
167167
168168 /**
169169 * Disposes configuration. Critical when heavy objects were used.
5353 return;
5454 }
5555
56 for (Iterator iter = td.getParameterKeys(); iter.hasNext(); ) {
57 String key = (String)(iter.next());
56 for (Iterator<String> iter = td.getParameterKeys(); iter.hasNext(); ) {
57 String key = (iter.next());
5858 String val = td.getParameter(key);
5959 updateEntry(key, val);
6060 }
9393 private void initGUI() {
9494 setLayout(new BorderLayout());
9595
96 tocEntries = new DefaultListModel();
96 tocEntries = new DefaultListModel<>();
9797 toc = uif.createList("test.out.toc", tocEntries);
9898 toc.setCellRenderer(new TOCRenderer());
9999 toc.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
548548 return null;
549549
550550 for (int i = 0; i < tocEntries.size(); i++) {
551 TOCEntry entry = (TOCEntry) (tocEntries.get(i));
551 TOCEntry entry = tocEntries.get(i);
552552 if (entry.getSection() == section) {
553553 // found match, select this entry
554554 return entry;
643643
644644 private JEditorPane htmlArea;
645645
646 private DefaultListModel tocEntries;
646 private DefaultListModel<TOCEntry> tocEntries;
647647 private Listener listener = new Listener();
648648 private TRObserver observer = new TRObserver();
649649
663663 int index = toc.getSelectedIndex();
664664 if (index != -1) {
665665 for (int i = index + 1; i < tocEntries.size(); i++) {
666 TOCEntry entry = (TOCEntry) (tocEntries.get(i));
666 TOCEntry entry = tocEntries.get(i);
667667 String entryOutputName = entry.getOutputName();
668668 if (entryOutputName == null)
669669 // name not found, reached next section entry
681681 int sectIndex = Integer.parseInt(desc);
682682 TestResult.Section s = subpanelTest.getSection(sectIndex);
683683 for (int i = 0; i < tocEntries.size(); i++) {
684 TOCEntry entry = (TOCEntry) (tocEntries.get(i));
684 TOCEntry entry = tocEntries.get(i);
685685 if (entry.getSection() == s) {
686686 // found match, select this entry
687687 toc.setSelectedIndex(i);
699699 }
700700
701701 public void valueChanged(ListSelectionEvent e) {
702 JList l = (JList) (e.getSource());
703 TOCEntry entry = (TOCEntry) (l.getSelectedValue());
702 JList<TOCEntry> l = (JList<TOCEntry>) (e.getSource());
703 TOCEntry entry = (l.getSelectedValue());
704704 if (entry == null)
705705 return;
706706 titleField.setText(entry.getTitle());
876876 }
877877
878878 private class TOCRenderer extends DefaultListCellRenderer {
879 public Component getListCellRendererComponent(JList list,
879 public Component getListCellRendererComponent(JList<?> list,
880880 Object value,
881881 int index,
882882 boolean isSelected,
8989 table.reset();
9090 }
9191
92 protected void updateEntries(Map map) {
93 for (Iterator i = map.entrySet().iterator(); i.hasNext(); ) {
94 Map.Entry e = (Map.Entry) (i.next());
95 String key = (String) (e.getKey());
96 String val = (String) (e.getValue());
92 protected void updateEntries(Map<String, String> map) {
93 for (Map.Entry<String, String> e : map.entrySet()) {
94 String key = (e.getKey());
95 String val = (e.getValue());
9796 if (val != null && !val.trim().isEmpty()) {
9897 table.updateEntry(key, val);
9998 }
115114 addComponentListener(this);
116115 setLayout(null);
117116 setBackground(Color.white);
118 entries = new TreeMap();
117 entries = new TreeMap<>();
119118
120119 // space to go around text
121120 Border bsp = BorderFactory.createEmptyBorder(2, 4, 2, 4); // top, left, bottom, right
143142
144143 void updateEntry(String key, String value) {
145144 //System.err.println("TP_PS.Table: updateEntry " + key + "=" + value);
146 Entry e = (Entry) (entries.get(key));
145 Entry e = entries.get(key);
147146 if (e == null) {
148147 e = new Entry(key, value);
149148 entries.put(key, e);
240239
241240 int y = (inScrollPane ? 0 : h);
242241
243 for (Iterator iter = entries.values().iterator(); iter.hasNext(); ) {
244 Entry e = (Entry) (iter.next());
242 for (Iterator<Entry> iter = entries.values().iterator(); iter.hasNext(); ) {
243 Entry e = (iter.next());
245244 // need to take insets into account for value, since we are dealing
246245 // with the elemental view inside the valueField
247246 Insets vi = e.valueText.getInsets();
258257 public Dimension getMinimumSize() {
259258 //System.err.println("TP_PS.Table: minimumLayoutSize");
260259 int h = (inScrollPane ? 0 : nameLabel.getPreferredSize().height);
261 for (Iterator iter = entries.values().iterator(); iter.hasNext(); ) {
262 Entry e = (Entry) (iter.next());
260 for (Iterator<Entry> iter = entries.values().iterator(); iter.hasNext(); ) {
261 Entry e = (iter.next());
263262 h += e.valueText.getMinimumSize().height;
264263 }
265264 return new Dimension(maxNameStringWidth + 400, h);
268267 public Dimension getPreferredSize() {
269268 //System.err.println("TP_PS.Table: preferredLayoutSize");
270269 int h = (inScrollPane ? 0 : nameLabel.getPreferredSize().height);
271 for (Iterator iter = entries.values().iterator(); iter.hasNext(); ) {
272 Entry e = (Entry) (iter.next());
270 for (Iterator<Entry> iter = entries.values().iterator(); iter.hasNext(); ) {
271 Entry e = (iter.next());
273272 h += e.valueText.getPreferredSize().height;
274273 }
275274 return new Dimension(maxNameStringWidth + 400, h);
354353 }
355354 }
356355
357 private SortedMap entries;
356 private SortedMap<String, Entry> entries;
358357 private int maxNameStringWidth = 100;
359358 private JTextField nameLabel;
360359 private JTextField valueLabel;
5858 }
5959
6060 private void updateEntries() {
61 for (Enumeration e = subpanelTest.getPropertyNames(); e.hasMoreElements(); ) {
61 for (Enumeration<String> e = subpanelTest.getPropertyNames(); e.hasMoreElements(); ) {
6262 try {
63 String key = (String)(e.nextElement());
63 String key = (e.nextElement());
6464 String val = subpanelTest.getProperty(key);
6565 updateEntry(key, val);
6666 }
4444 */
4545 public class TT_BasicNode extends TT_TreeNode {
4646
47 TT_BasicNode(TT_BasicNode parent, TRT_TreeNode tn, Comparator comp) {
47 TT_BasicNode(TT_BasicNode parent, TRT_TreeNode tn, Comparator<String> comp) {
4848 this.comp = comp;
4949 this.parent = parent;
5050 this.tn = tn;
5151 }
5252 // ------- interface methods --------
53 public Enumeration children() {
54 updateNode();
55
56 ArrayList<TreeNode> copy = null;
53 public Enumeration<TT_TreeNode> children() {
54 updateNode();
55
56 ArrayList<TT_TreeNode> copy = null;
5757 synchronized (children) {
5858 // shallow copy child list?
59 copy = (ArrayList<TreeNode>) children.clone();
60 }
61
62 final Iterator it = copy.iterator();
63 return new Enumeration() {
59 copy = new ArrayList<>(children);
60 }
61
62 final Iterator<TT_TreeNode> it = copy.iterator();
63 return new Enumeration<TT_TreeNode>() {
6464
6565 public boolean hasMoreElements() {
6666 return it.hasNext();
6767 }
6868
69 public Object nextElement() {
69 public TT_TreeNode nextElement() {
7070 return it.next();
7171 }
7272 };
266266 }
267267 }
268268
269 TreeModelEvent addTest(final TT_TestNode tn, Comparator sortComparator) {
269 TreeModelEvent addTest(final TT_TestNode tn, Comparator<String> sortComparator) {
270270 if (updateNode()) {
271271 //Debug.println("Ignoring add of " + tn.getDisplayName());
272272 return null;
301301 private int recursiveIns(final int lPos, final int rPos,
302302 final TT_TreeNode tn,
303303 final String dispName,
304 final Comparator sortComparator) {
304 final Comparator<String> sortComparator) {
305305 synchronized (children) { // should already be locked!
306306 int diff = rPos-lPos;
307307 int pos = (diff/2) + lPos;
454454
455455 private final ArrayList<TT_TreeNode> children = new ArrayList<TT_TreeNode>();
456456 private TRT_TreeNode tn;
457 private Comparator comp;
457 private Comparator<String> comp;
458458 private final AtomicBoolean isUpdated = new AtomicBoolean(false);
459459 private boolean debug = Debug.getBoolean(TT_BasicNode.class);
460460 }
6464 // all the states plus filtered out
6565 testLists = new Vector[Status.NUM_STATES + 1];
6666 for (int i = 0; i < Status.NUM_STATES + 1; i++) {
67 testLists[i] = new Vector();
67 testLists[i] = new Vector<>();
6868 }
6969 }
7070
517517 }
518518
519519 TestFilter getRejectReason(TestResult tr) {
520 return (TestFilter) (rejectReasons.get(tr));
520 return rejectReasons.get(tr);
521521 }
522522
523523 /**
531531 * @return A copy of the Vectors that contain the current list of tests. Null if
532532 * <tt>needSnapshot</tt> is false.
533533 */
534 synchronized Vector[] addObserver(TT_NodeCacheObserver obs, boolean needSnapshot) {
534 synchronized Vector<TestResult>[] addObserver(TT_NodeCacheObserver obs, boolean needSnapshot) {
535535 // snapshot the current data
536536 // must be done before adding the observer to ensure correct data
537537 // delivery to client
538538
539 Vector[] cp = null;
539 Vector<TestResult>[] cp = null;
540540 if (needSnapshot) {
541541 cp = new Vector[testLists.length];
542542 for (int i = 0; i < testLists.length; i++) {
543 cp[i] = (Vector) (testLists[i].clone());
543 cp[i] = (Vector<TestResult>) (testLists[i].clone());
544544 }
545545 }
546546
547547 if (obs != null) {
548 observers = (TT_NodeCacheObserver[]) DynamicArray.append(observers, obs);
548 observers = DynamicArray.append(observers, obs);
549549 }
550550
551551 return cp;
556556 // THEN itself (the GUI component) for proper locking sequence, since the
557557 // highest contention is for this cache object.
558558 synchronized void removeObserver(TT_NodeCacheObserver obs) {
559 observers = (TT_NodeCacheObserver[]) DynamicArray.remove(observers, obs);
559 observers = DynamicArray.remove(observers, obs);
560560 }
561561
562562 // ------------- PRIVATE -----------------
576576 continue;
577577 }
578578
579 TestResult tr = (TestResult) it.next();
579 TestResult tr = it.next();
580580 TestDescription td = tr.getDescription();
581581 TestFilter rejector = null;
582582 boolean wouldAccept = false;
722722 /**
723723 * Determine the index of a particular test in a vector.
724724 */
725 private int searchList(TestResult target, Vector list) {
725 private int searchList(TestResult target, Vector<?> list) {
726726 int possible = list.indexOf(target);
727727 return possible;
728728 }
790790 private TestFilter filter;
791791 private int[] stats = new int[Status.NUM_STATES];
792792 private int localRejectCount;
793 private Hashtable rejectReasons = new Hashtable();
793 private Hashtable<TestResult, TestFilter> rejectReasons = new Hashtable<>();
794794 private final FilterObserver fObs = new FilterObserver();
795795 private TT_NodeCacheObserver[] observers = new TT_NodeCacheObserver[0];
796 private Vector[] testLists; // could use unsynchronized data structure
796 private Vector<TestResult>[] testLists; // could use unsynchronized data structure
797797 private volatile int state;
798798 private volatile boolean valid = true;
799799 private static final int NOT_COMPUTED = 0;
4141 this.parent = parent;
4242 }
4343 // ------- interface methods --------
44 public Enumeration children() {
44 public Enumeration<?> children() {
4545 throw new UnsupportedOperationException("Not supported.");
4646 }
4747
6565 if (parent == null)
6666 return new TT_TreeNode[] {this};
6767
68 LinkedList<TT_TreeNode> l = new LinkedList();
68 LinkedList<TT_TreeNode> l = new LinkedList<>();
6969 l.add(this);
7070
7171 TT_TreeNode spot = parent;
169169 // check if there are any environment entries recorded
170170 boolean hasEnv;
171171 try {
172 Map map = currTest.getEnvironment();
172 Map<String, String> map = currTest.getEnvironment();
173173 hasEnv = (map != null && map.size() > 0);
174174 }
175175 catch (TestResult.Fault f) {
243243 envPanel = new TP_EnvSubpanel(uif);
244244 outputPanel = new TP_OutputSubpanel(uif);
245245
246 Vector<TP_Subpanel> vpanels = new Vector();
246 Vector<TP_Subpanel> vpanels = new Vector<>();
247247 vpanels.add(descPanel);
248248
249249 FeatureManager fm = contextManager.getFeatureManager();
266266 if (contextManager != null ) {
267267 CustomTestResultViewer[] cv = contextManager.getCustomResultViewers();
268268 if (cv != null) {
269 customViewTable = new HashMap();
269 customViewTable = new HashMap<>();
270270 panels = new TP_Subpanel[stdPanels.length + cv.length];
271271 System.arraycopy(stdPanels, 0, panels, 0, stdPanels.length);
272272 for (int i=0; i < cv.length; i++) {
292292 if (c instanceof TP_Subpanel) {
293293 updatePanel(currTest, (TP_Subpanel) c);
294294 } if (c instanceof CustomTestResultViewer) {
295 updatePanel(currTest, (TP_CustomSubpanel) customViewTable.get(c));
295 updatePanel(currTest, customViewTable.get(c));
296296 }
297297 }
298298 });
369369 private TP_EnvSubpanel envPanel;
370370 private TP_OutputSubpanel outputPanel;
371371 private JTextField statusField;
372 private HashMap customViewTable;
372 private HashMap<CustomTestResultViewer, TP_Subpanel> customViewTable;
373373
374374 //
375375 private Harness harness;
129129 return;
130130
131131 if (currModel instanceof TestTreeModel) {
132 final TreePath[] paths = ((TestTreeModel)currModel).urlsToPaths(selectedUrls);
132 final TreePath[] paths = currModel.urlsToPaths(selectedUrls);
133133
134134 if (!EventQueue.isDispatchThread()) {
135135 EventQueue.invokeLater(new Runnable() {
170170 return null;
171171
172172 TreePath[] paths = new TreePath[0];
173 Enumeration e = getDescendantToggledPaths(new TreePath(currModel.getRoot()));
173 Enumeration<TreePath> e = getDescendantToggledPaths(new TreePath(currModel.getRoot()));
174174
175175 while (e != null && e.hasMoreElements()) {
176 TreePath tp = (TreePath)(e.nextElement());
176 TreePath tp = (e.nextElement());
177177 if (!isVisible(tp)) // if we can't see it, we don't care
178178 continue;
179179 if (!isExpanded(tp)) // if it's not expanded, we don't need it
180180 continue;
181181
182 paths = (TreePath[])DynamicArray.append(paths, tp);
182 paths = DynamicArray.append(paths, tp);
183183 } // while
184184
185185 return paths;
196196 return;
197197
198198 if (currModel instanceof TestTreeModel) {
199 final TreePath[] paths = ((TestTreeModel)currModel).urlsToPaths(openUrls);
199 final TreePath[] paths = currModel.urlsToPaths(openUrls);
200200
201201 if (!EventQueue.isDispatchThread() || queue) {
202202 EventQueue.invokeLater(new Runnable() {
7373 this.filterHandler = filterHandler;
7474 this.uif = uif;
7575
76 cache = new Hashtable();
77 cacheQueue = new LinkedList();
78 suspendedQueue = new LinkedList();
76 cache = new Hashtable<>();
77 cacheQueue = new LinkedList<>();
78 suspendedQueue = new LinkedList<>();
7979
8080 cacheWorker = new CacheWorker();
8181 cacheWorker.setPriority(Thread.MIN_PRIORITY + 1);
117117
118118 // TreeModel methods
119119 public void addTreeModelListener(TreeModelListener l) {
120 treeModelListeners = (TreeModelListener[]) DynamicArray.append(treeModelListeners, l);
120 treeModelListeners = DynamicArray.append(treeModelListeners, l);
121121 }
122122
123123 public Object getChild(Object parent, int index) {
174174 }
175175
176176 public void removeTreeModelListener(TreeModelListener l) {
177 treeModelListeners = (TreeModelListener[]) DynamicArray.remove(treeModelListeners, l);
177 treeModelListeners = DynamicArray.remove(treeModelListeners, l);
178178 }
179179
180180 public void valueForPathChanged(TreePath path, Object newValue) {
265265 TT_NodeCache ni = null;
266266
267267 synchronized (htLock) {
268 ni = (TT_NodeCache) (cache.get(transPath[i].getTableNode()));
268 ni = cache.get(transPath[i].getTableNode());
269269 //ni = getNodeInfo(transPath[i].getTableNode(), false);
270270 } // sync
271271
463463 }
464464
465465 for (int i = 0; i < treeModelListeners.length; i++) {
466 ((TreeModelListener) treeModelListeners[i]).treeNodesRemoved(tme);
466 treeModelListeners[i].treeNodesRemoved(tme);
467467 }
468468 }
469469
489489 if (tme == null) return;
490490
491491 for (int i = 0; i < treeModelListeners.length; i++) {
492 ((TreeModelListener) treeModelListeners[i]).treeNodesInserted(tme);
492 treeModelListeners[i].treeNodesInserted(tme);
493493 }
494494
495495 }
498498 if (path == null || path.length() == 0 || root == null) {
499499 return null;
500500 }
501 ArrayList<TT_TreeNode> al = new ArrayList();
501 ArrayList<TT_TreeNode> al = new ArrayList<>();
502502 al.add(root);
503503 TT_BasicNode spot = root;
504504
583583 TT_TreeNode[] transTarget = new TT_TreeNode[1];
584584 if (target instanceof TestResult &&
585585 transPath[transPath.length - 1] instanceof TT_BasicNode) {
586 TT_TestNode mtn = ((TT_BasicNode) (transPath[transPath.length - 1])).findByName((TestResult) target);
586 TT_TestNode mtn = transPath[transPath.length - 1].findByName((TestResult) target);
587587 if (mtn != null) {
588588 transTarget[0] = mtn;
589589 } else {
590590 return null; // no matching test
591591 }
592592 } else {
593 TT_TreeNode mtn = ((TT_BasicNode) (transPath[transPath.length - 1])).findByName(
593 TT_TreeNode mtn = transPath[transPath.length - 1].findByName(
594594 ((TestResultTable.TreeNode) target).getName());
595595 if (mtn != null) {
596596 transTarget[0] = mtn;
649649 }
650650
651651 TreePath[] urlsToPaths(String[] urls) {
652 ArrayList<TreePath> result = new ArrayList();
652 ArrayList<TreePath> result = new ArrayList<>();
653653
654654 for (int i = 0; i < urls.length; i++) {
655655 TreePath thisOne = urlToPath(urls[i]);
816816 (trt.getTestFinder() == null ? null : trt.getTestFinder().getComparator()));
817817
818818 // prime relevant nodes with root and first level
819 relevantNodes = Collections.synchronizedSet(new HashSet());
820 relevantTests = Collections.synchronizedSet(new HashSet());
819 relevantNodes = Collections.synchronizedSet(new HashSet<TT_TreeNode>());
820 relevantTests = Collections.synchronizedSet(new HashSet<TestResult>());
821821
822822 addRelevantNode((TT_TreeNode) getRoot());
823823 TT_BasicNode tn = ((TT_BasicNode) getRoot());
996996 */
997997 void invalidateNodeInfo() {
998998 synchronized (htLock) {
999 Enumeration e = cache.keys();
999 Enumeration<TestResultTable.TreeNode> e = cache.keys();
10001000 while (e.hasMoreElements()) {
10011001 (cache.get(e.nextElement())).invalidate();
10021002 } // while
10031003
1004 cache = new Hashtable();
1005 cacheQueue = new LinkedList();
1006 suspendedQueue = new LinkedList();
1004 cache = new Hashtable<>();
1005 cacheQueue = new LinkedList<>();
1006 suspendedQueue = new LinkedList<>();
10071007 }
10081008
10091009 // reprocess any needed nodes
1010 Iterator it = relevantNodes.iterator();
1010 Iterator<TT_TreeNode> it = relevantNodes.iterator();
10111011 while (it.hasNext()) {
1012 TT_TreeNode tn = (TT_TreeNode) it.next();
1012 TT_TreeNode tn = it.next();
10131013 if (tn instanceof TT_BasicNode) {
10141014 getNodeInfo(((TT_BasicNode) tn).getTableNode(), false);
10151015 }
11001100 private Parameters params;
11011101 private FilterSelectionHandler filterHandler;
11021102 private TestFilter lastFilter;
1103 private Comparator sortComparator;
1103 private Comparator<String> sortComparator;
11041104 private TreeModelListener[] treeModelListeners = new TreeModelListener[0];
11051105 private boolean statsForwarded;
11061106 private boolean disposed;
13131313 TT_NodeCache selection = null;
13141314
13151315 if (suspendedQueue.size() > 0) {
1316 selection = (TT_NodeCache) (suspendedQueue.removeLast());
1316 selection = suspendedQueue.removeLast();
13171317 } else if (cacheQueue.size() > 0) {
1318 selection = (TT_NodeCache) (cacheQueue.removeLast());
1318 selection = cacheQueue.removeLast();
13191319 }
13201320 if (selection != null &&
13211321 selection.getNode().isRoot() && // trying to avoid root
13361336 // basically equivalent
13371337 TT_NodeCache selected = null;
13381338 int depth = -1;
1339 LinkedList theList = cacheQueue;
1339 LinkedList<TT_NodeCache> theList = cacheQueue;
13401340 boolean notDone = true;
13411341 int count = 0;
13421342
13501350 }
13511351
13521352 while (notDone) {
1353 TT_NodeCache possible = (TT_NodeCache) (theList.get(count));
1353 TT_NodeCache possible = (theList.get(count));
13541354 int thisDepth = TestResultTable.getObjectPath(possible.getNode()).length;
13551355
13561356 if (thisDepth > depth) {
13951395
13961396 // switch event format if the node is the root
13971397 if (node.isRoot() && getRoot() != null) {
1398 e = new TreeModelEvent(this, new Object[]{getRoot()}, (int[]) null, (Object[]) null);
1398 e = new TreeModelEvent(this, new Object[]{getRoot()}, null, null);
13991399 } else {
14001400 // full path to the node, inclusive
14011401 //TestResultTable.TreeNode[] fp = TestResultTable.getObjectPath(node);
14831483 }
14841484
14851485 for (int i = 0; i < l.length; i++) {
1486 ((TreeModelListener) l[i]).treeNodesChanged(e);
1486 l[i].treeNodesChanged(e);
14871487 }
14881488 break;
14891489 case STRUCT:
14901490 for (int i = 0; i < l.length; i++) {
1491 ((TreeModelListener) l[i]).treeStructureChanged(e);
1491 l[i].treeStructureChanged(e);
14921492 }
14931493 break;
14941494 case INS:
14951495 for (int i = 0; i < l.length; i++) {
1496 ((TreeModelListener) l[i]).treeNodesInserted(e);
1496 l[i].treeNodesInserted(e);
14971497 }
14981498 break;
14991499 case DEL:
15001500 for (int i = 0; i < l.length; i++) {
1501 ((TreeModelListener) l[i]).treeNodesRemoved(e);
1501 l[i].treeNodesRemoved(e);
15021502 }
15031503 break;
15041504 default:
00 /*
11 * $Id$
22 *
3 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
44 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55 *
66 * This code is free software; you can redistribute it and/or modify it
106106 */
107107 public TestTreePanel(UIFactory uif, Harness h, ExecModel em,
108108 FilterSelectionHandler fh, JComponent parent,
109 Map map) {
109 Map<String, String> map) {
110110 this(parent, em, uif);
111111 setHarness(h);
112112 this.filterHandler = fh;
211211 // time, so we need to make sure to make use of the preferences
212212 if (params == null && stateMap != null) {
213213 // trying to retrieve previous state
214 String tmp = (String) (stateMap.get(OPEN_PATHS_PREF));
214 String tmp = stateMap.get(OPEN_PATHS_PREF);
215215 if (tmp != null) {
216216 paths = StringArray.split(tmp);
217217 }
287287
288288 private TreePath[] getTreePaths(String[] paths) {
289289 if (paths != null) {
290 ArrayList<TreePath> translatedPaths = new ArrayList(paths.length);
290 ArrayList<TreePath> translatedPaths = new ArrayList<>(paths.length);
291291
292292 for (int i = 0; i < paths.length; i++) {
293293 // the paths need to be reconditioned because the JTree will not
310310
311311
312312 @Override
313 public void saveTreeState(Map m) {
313 public void saveTreeState(Map<String, String> m) {
314314 String[] paths = getOpenPaths();
315315 m.put(OPEN_PATHS_PREF, StringArray.join(paths));
316316 }
317317
318318 @Override
319 public void restoreTreeState(Map m) {
319 public void restoreTreeState(Map<String, String> m) {
320320 if (m != null) {
321 String tmp = (String) (m.get(OPEN_PATHS_PREF));
321 String tmp = m.get(OPEN_PATHS_PREF);
322322 if (tree != null && tmp != null && tmp.length() > 0) {
323323 tree.restorePaths(StringArray.split(tmp), true);
324324 }
326326 }
327327
328328 @Override
329 public void save(Map m) {
329 public void save(Map<String, String> m) {
330330 // save the open paths
331331 Preferences.access();
332332 saveTreeState(m);
333333 }
334334
335335 @Override
336 public void restore(Map m) {
336 public void restore(Map<String, String> m) {
337337 stateMap = m;
338338 restoreTreeState(stateMap);
339339 }
348348 }
349349
350350 TreePath[] paths = tree.snapshotOpenPaths();
351 Vector urls = new Vector();
351 Vector<String> urls = new Vector<>();
352352
353353 if (paths != null) {
354354 for (int i = 0; i < paths.length; i++) {
440440 //createNodeListString(createNodeList(what)));
441441
442442 String[] paths = createNodeList(what);
443 DefaultListModel model = new DefaultListModel();
443 DefaultListModel<String> model = new DefaultListModel<>();
444444 for (int i = paths.length; i > 0; i--) {
445445 model.add(model.getSize(), paths[model.getSize()]);
446446 }
696696 // createNodeListString(createNodeList(what)));
697697
698698 String[] paths = createNodeList(what);
699 DefaultListModel model = new DefaultListModel();
699 DefaultListModel<String> model = new DefaultListModel<>();
700700 for (int i = paths.length; i > 0; i--) {
701701 model.add(model.getSize(), paths[model.getSize()]);
702702 }
713713 Object item = what[i].getLastPathComponent();
714714 if (item instanceof TT_TestNode) {
715715 ackTargets[i] = ((TT_TestNode) item).getLongPath();
716 ackNodes = (TT_TreeNode[])DynamicArray.append(ackNodes, (TT_TestNode)item, TT_TreeNode.class);
716 ackNodes = DynamicArray.append(ackNodes, (TT_TestNode)item, TT_TreeNode.class);
717717 } else if (item instanceof TT_BasicNode) {
718 ackNodes = (TT_TreeNode[])DynamicArray.append(ackNodes, (TT_BasicNode)item, TT_TreeNode.class);
718 ackNodes = DynamicArray.append(ackNodes, (TT_BasicNode)item, TT_TreeNode.class);
719719 TT_BasicNode tn = (TT_BasicNode) item;
720720 if (tn.isRoot()) {
721721 ackTargets = new String[1];
760760 ack = true;
761761
762762 if (tn instanceof TT_BasicNode) {
763 ackNodes = new TT_TreeNode[] {((TT_BasicNode) tn)};
763 ackNodes = new TT_TreeNode[] {tn};
764764 }
765765 } // else
766766
798798 try {
799799 // this may take a long while...
800800 if (finalTargets[i] instanceof String) {
801 changes = trt.refreshIfNeeded((String) finalTargets[i]);
801 changes = trt.refreshIfNeeded(finalTargets[i]);
802802 }
803803 } // try
804804 catch (TestResultTable.Fault f) {
818818 for (int i = 0; i < finalNodes.length; i++) {
819819 try {
820820 if (finalNodes[i] instanceof TT_TestNode)
821 changes = trt.refreshIfNeeded(((TT_TestNode)finalNodes[i]).getLongPath());
821 changes = trt.refreshIfNeeded(finalNodes[i].getLongPath());
822822 else {
823823 changes = trt.refreshIfNeeded(((TT_BasicNode)finalNodes[i]).getTableNode());
824824 if (changes) trt.prune(((TT_BasicNode)finalNodes[i]).getTableNode());
11231123 switch (cms[i].getMenuApplication()) {
11241124 case JavaTestContextMenu.TESTS_AND_FOLDERS:
11251125 if (mixedMenus == null) {
1126 mixedMenus = new ArrayList();
1126 mixedMenus = new ArrayList<>();
11271127 }
11281128 mixedMenus.add(cms[i]);
11291129 break;
11301130 case JavaTestContextMenu.TESTS_ONLY:
11311131 if (testMenus == null) {
1132 testMenus = new ArrayList();
1132 testMenus = new ArrayList<>();
11331133 }
11341134 testMenus.add(cms[i]);
11351135 break;
11361136 case JavaTestContextMenu.FOLDERS_ONLY:
11371137 if (folderMenus == null) {
1138 folderMenus = new ArrayList();
1138 folderMenus = new ArrayList<>();
11391139 }
11401140 folderMenus.add(cms[i]);
11411141 break;
11421142 case JavaTestContextMenu.CUSTOM:
11431143 if (customMenus == null) {
1144 customMenus = new ArrayList();
1144 customMenus = new ArrayList<>();
11451145 }
11461146 customMenus.add(cms[i]);
11471147 break;
12631263 TestResult tr = ((TT_TestNode) item).getTestResult();
12641264 if (testMenus != null) {
12651265 for (int i = 0; i < testMenus.size(); i++) {
1266 ((JavaTestContextMenu) (testMenus.get(i))).getMenu().setEnabled(true);
1267 ((JavaTestContextMenu) (testMenus.get(i))).updateState(tr);
1266 testMenus.get(i).getMenu().setEnabled(true);
1267 testMenus.get(i).updateState(tr);
12681268 } // for
12691269 }
12701270 if (customMenus != null) {
12711271 for (int i = 0; i < customMenus.size(); i++) {
1272 ((JavaTestContextMenu) (customMenus.get(i))).updateState(tr);
1272 customMenus.get(i).updateState(tr);
12731273 } // for
12741274 }
12751275 if (mixedMenus != null) {
12761276 for (int i = 0; i < mixedMenus.size(); i++) {
1277 ((JavaTestContextMenu) (mixedMenus.get(i))).getMenu().setEnabled(true);
1278 ((JavaTestContextMenu) (mixedMenus.get(i))).updateState(tr);
1277 mixedMenus.get(i).getMenu().setEnabled(true);
1278 mixedMenus.get(i).updateState(tr);
12791279 } // for
12801280 }
12811281 if (folderMenus != null) {
12821282 for (int i = 0; i < folderMenus.size(); i++) {
1283 ((JavaTestContextMenu) (folderMenus.get(i))).getMenu().setEnabled(false);
1283 folderMenus.get(i).getMenu().setEnabled(false);
12841284 } // for
12851285 }
12861286 } else if (item instanceof TT_BasicNode) {
12901290
12911291 if (testMenus != null) {
12921292 for (int i = 0; i < testMenus.size(); i++) {
1293 ((JavaTestContextMenu) (testMenus.get(i))).getMenu().setEnabled(false);
1293 testMenus.get(i).getMenu().setEnabled(false);
12941294 } // for
12951295 }
12961296 if (customMenus != null) {
12971297 for (int i = 0; i < customMenus.size(); i++) {
1298 ((JavaTestContextMenu) (customMenus.get(i))).updateState(url);
1298 customMenus.get(i).updateState(url);
12991299 } // for
13001300 }
13011301 if (mixedMenus != null) {
13021302 for (int i = 0; i < mixedMenus.size(); i++) {
1303 ((JavaTestContextMenu) (mixedMenus.get(i))).getMenu().setEnabled(true);
1304 ((JavaTestContextMenu) (mixedMenus.get(i))).updateState(url);
1303 mixedMenus.get(i).getMenu().setEnabled(true);
1304 mixedMenus.get(i).updateState(url);
13051305 } // for
13061306 }
13071307 if (folderMenus != null) {
13081308 for (int i = 0; i < folderMenus.size(); i++) {
1309 ((JavaTestContextMenu) (folderMenus.get(i))).getMenu().setEnabled(true);
1310 ((JavaTestContextMenu) (folderMenus.get(i))).updateState(url);
1309 folderMenus.get(i).getMenu().setEnabled(true);
1310 folderMenus.get(i).updateState(url);
13111311 } // for
13121312 }
13131313 } else { // should not happen!
13141314 if (testMenus != null) {
13151315 for (int i = 0; i < testMenus.size(); i++) {
1316 ((JavaTestContextMenu) (testMenus.get(i))).getMenu().setEnabled(false);
1316 testMenus.get(i).getMenu().setEnabled(false);
13171317 } // for
13181318 }
13191319 if (customMenus != null) {
13201320 for (int i = 0; i < customMenus.size(); i++) {
1321 ((JavaTestContextMenu) (customMenus.get(i))).getMenu().setEnabled(false);
1321 customMenus.get(i).getMenu().setEnabled(false);
13221322 } // for
13231323 }
13241324 if (mixedMenus != null) {
13251325 for (int i = 0; i < mixedMenus.size(); i++) {
1326 ((JavaTestContextMenu) (mixedMenus.get(i))).getMenu().setEnabled(false);
1326 mixedMenus.get(i).getMenu().setEnabled(false);
13271327 } // for
13281328 }
13291329 if (folderMenus != null) {
13301330 for (int i = 0; i < folderMenus.size(); i++) {
1331 ((JavaTestContextMenu) (folderMenus.get(i))).getMenu().setEnabled(false);
1331 folderMenus.get(i).getMenu().setEnabled(false);
13321332 } // for
13331333 }
13341334
13361336 throw new JavaTestError("Unknown node type from JTree!");
13371337 }
13381338 } else { // multiple nodes selected
1339 ArrayList tests = new ArrayList();
1340 ArrayList folders = new ArrayList();
1339 ArrayList<TestResult> tests = new ArrayList<>();
1340 ArrayList<String> folders = new ArrayList<>();
13411341
13421342 for (int i = 0; i < paths.length; i++) {
13431343 Object item = paths[i];
13591359
13601360 TestResult[] t = null;
13611361 if (tests.size() > 0) {
1362 t = (TestResult[])tests.toArray(new TestResult[tests.size()]);
1362 t = tests.toArray(new TestResult[tests.size()]);
13631363 }
13641364
13651365 String[] f = null;
13661366 if (folders.size() > 0) {
1367 f = (String[])folders.toArray(new String[folders.size()]);
1367 f = folders.toArray(new String[folders.size()]);
13681368 // currently enable/disabled state is only determined by the menu's
13691369 // ability to deal with multi selection
13701370 }
13711371
13721372 if (testMenus != null) {
13731373 for (int i = 0; i < testMenus.size(); i++) {
1374 JavaTestContextMenu m = (JavaTestContextMenu) (testMenus.get(i));
1374 JavaTestContextMenu m = testMenus.get(i);
13751375 m.getMenu().setEnabled(m.isMultiSelectAllowed());
13761376 m.updateState(f, t);
13771377 } // for
13781378 }
13791379 if (customMenus != null) {
13801380 for (int i = 0; i < customMenus.size(); i++) {
1381 JavaTestContextMenu m = (JavaTestContextMenu) (customMenus.get(i));
1381 JavaTestContextMenu m = customMenus.get(i);
13821382 m.getMenu().setEnabled(m.isMultiSelectAllowed());
13831383 m.updateState(f, t);
13841384 } // for
13851385 }
13861386 if (mixedMenus != null) {
13871387 for (int i = 0; i < mixedMenus.size(); i++) {
1388 JavaTestContextMenu m = (JavaTestContextMenu) (mixedMenus.get(i));
1388 JavaTestContextMenu m = mixedMenus.get(i);
13891389 m.getMenu().setEnabled(m.isMultiSelectAllowed());
13901390 m.updateState(f, t);
13911391 } // for
13921392 }
13931393 if (folderMenus != null) {
13941394 for (int i = 0; i < folderMenus.size(); i++) {
1395 JavaTestContextMenu m = (JavaTestContextMenu) (folderMenus.get(i));
1395 JavaTestContextMenu m = folderMenus.get(i);
13961396 m.getMenu().setEnabled(m.isMultiSelectAllowed());
13971397 m.updateState(f, t);
13981398 } // for
15821582 * @param prefix i18n bundle prefix
15831583 * @param args Arguments for the user message string, which is prefix.txt.
15841584 */
1585 private int showConfirmListDialog(String prefix, Object[] args, ListModel model) {
1585 private int showConfirmListDialog(String prefix, Object[] args, ListModel<?> model) {
15861586 // resources needed:
15871587 // prefix.title
15881588 JPanel p = uif.createPanel("ttp.confirmPanel", false);
15901590 p.setLayout(new BorderLayout());
15911591 p.add(msg, BorderLayout.NORTH);
15921592
1593 JList list = uif.createList("treep.nodeList", model);
1593 JList<?> list = uif.createList("treep.nodeList", model);
15941594 p.add(uif.createScrollPane(list,
15951595 ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
15961596 ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
16141614 private ExecModel execModel;
16151615 private JComponent parent;
16161616 private Thread bgThread; // in case disposal is required
1617 private Map stateMap; // startup state, read-only
1617 private Map<String, String> stateMap; // startup state, read-only
16181618 private volatile boolean disposed;
16191619 private PanelModel pm;
16201620 private TestTree tree;
16281628 private JMenuItem purgeMI;
16291629 private JMenuItem runMI;
16301630 private String activeTest;
1631 private ArrayList testMenus, folderMenus, mixedMenus, customMenus;
1631 private ArrayList<JavaTestContextMenu> testMenus, folderMenus, mixedMenus, customMenus;
16321632 private TestTreeModel treeModel;
16331633 private Deck deck;
16341634 private JPanel deckPanel;
19471947 private class PanelModel implements TreePanelModel, Harness.Observer, TestResultTable.Observer {
19481948
19491949 PanelModel() {
1950 runningTests = new Hashtable();
1951 activeNodes = new Hashtable();
1950 runningTests = new Hashtable<>();
1951 activeNodes = new Hashtable<>();
19521952 }
19531953
19541954 public void pauseWork() {
21072107 Object[] nodes = tp.getPath();
21082108
21092109 for (int i = 0; i < nodes.length; i++) {
2110 Object hit = activeNodes.get(nodes[i]);
2110 Integer hit = activeNodes.get(nodes[i]);
21112111 if (hit == null) // not currently an active node
21122112 {
21132113 activeNodes.put(nodes[i], ONE);
21142114 } else {
21152115 activeNodes.put(nodes[i],
2116 new Integer(1 + (((Integer) hit).intValue())));
2116 new Integer(1 + hit));
21172117 }
21182118 }
21192119 }
21422142
21432143 if (nodes != null) {
21442144 for (int i = 0; i < nodes.length; i++) {
2145 Object hit = activeNodes.get(nodes[i]);
2145 Integer hit = activeNodes.get(nodes[i]);
21462146 if (hit == null) {
21472147 // should only really happen when test run finished, not
21482148 // during the run
21512151 if (hit == ONE) {
21522152 activeNodes.remove(nodes[i]);
21532153 } else {
2154 int currHits = ((Integer) hit).intValue();
2154 int currHits = hit.intValue();
21552155 activeNodes.put(nodes[i],
21562156 (currHits == 2 ? ONE : new Integer(--currHits)));
21572157 }
22072207 // ignore
22082208 }
22092209 private Hashtable<String,TestResult> runningTests;
2210 private Hashtable activeNodes;
2211 private Integer ONE = new Integer(1);
2210 private Hashtable<Object, Integer> activeNodes;
2211 private Integer ONE = Integer.valueOf(1);
22122212 }
22132213 }
8282 * no tool bar for this key.
8383 **/
8484 public JavaTestToolBar getToolBar(String toolBarID) {
85 return (JavaTestToolBar) store.get(toolBarID);
85 return store.get(toolBarID);
8686 }
8787
8888 /**
9191 **/
9292 public JavaTestToolBar[] getToolBars() {
9393 JavaTestToolBar[] ret = new JavaTestToolBar[0];
94 ret = (JavaTestToolBar[]) store.values().toArray(ret);
94 ret = store.values().toArray(ret);
9595 return ret;
9696 }
9797
103103 **/
104104 boolean removeToolBar(String toolBarID) {
105105 if (store.containsKey(toolBarID)) {
106 final JavaTestToolBar tb = (JavaTestToolBar) store.get(toolBarID);
106 final JavaTestToolBar tb = store.get(toolBarID);
107107
108108 if (panel != null)
109109 SwingUtilities.invokeLater(new Runnable() {
137137 * Saves visible state.
138138 * Invoked from ExecTool's save
139139 **/
140 void save(Map m) {
140 void save(Map<String, Object> m) {
141141 if (m != null) {
142142 for (JavaTestToolBar tb : store.values()) {
143143 tb.save(m);
145145 }
146146 }
147147
148 void load(Map m) {
148 void load(Map<String, Object> m) {
149149 if (m != null) {
150150 for (JavaTestToolBar tb : store.values()) {
151151 tb.load(m);
8686 synchronized (target.getTreeLock()) {
8787 int realW = target.getSize().width;
8888 int commponentsPerRow = 0;
89 ArrayList hs = new ArrayList();
89 ArrayList<Integer> hs = new ArrayList<>();
9090 if (realW == 0) {
9191 return super.preferredLayoutSize(target);
9292 }
139139 // fill in separators between rows
140140 separators = new int[hs.size()];
141141 for (int i = 0; i < hs.size(); i++) {
142 separators[i] = ((Integer)hs.get(i)).intValue();
142 separators[i] = hs.get(i).intValue();
143143 }
144144 return dim;
145145 }
9797 }
9898
9999 @Override
100 public void save(Map map) {
100 public void save(Map<String, String> map) {
101101 if (templ.getFile() != null) {
102102 map.put("template", templ.getFile().getPath());
103103 }
106106
107107
108108 @Override
109 public void restore(Map map) throws Fault {
109 public void restore(Map<String, String> map) throws Fault {
110110 super.restore(map);
111111 restoreTemplate(map);
112112 }
113113
114 protected void restoreTemplate(Map map) {
115 String templPath = (String) map.get("template");
114 protected void restoreTemplate(Map<String, String> map) {
115 String templPath = map.get("template");
116116 if (templPath != null) {
117117 try {
118118 if (!new File(templPath).exists() && getWorkDirectory() != null) {
210210 // simulate files to be scanned for child nodes
211211 TestTree.Node[] children = node.children;
212212 if (children != null) {
213 for (int i = 0; i < children.length; i++) {
214 File f = (relPath.length() == 0 ? new File(children[i].name) :
215 new File(relPath, children[i].name));
213 for (TestTree.Node child : children) {
214 File f = (relPath.length() == 0 ? new File(child.name) :
215 new File(relPath, child.name));
216216 foundFile(f);
217217 }
218218 }
467467 TestDescription get(File root, File file, int index) throws IOException {
468468 bais.reset();
469469 bais.skip(index);
470 Map m = new HashMap();
470 Map<String, String> m = new HashMap<>();
471471 DataInputStream in = new DataInputStream(bais);
472472 int n = readInt(in);
473473 for (int i = 0; i < n; i++) {
3131 import java.io.FileOutputStream;
3232 import java.io.IOException;
3333 import java.io.PrintStream;
34 import java.util.Arrays;
35 import java.util.Comparator;
36 import java.util.HashMap;
37 import java.util.HashSet;
38 import java.util.Iterator;
39 import java.util.Map;
40 import java.util.Set;
41 import java.util.TreeMap;
42 import java.util.Vector;
34 import java.util.*;
4335 import java.util.zip.ZipEntry;
4436 import java.util.zip.ZipOutputStream;
4537
245237 if (log != null)
246238 log.println("Writing " + outFile);
247239
248 FileOutputStream fos = new FileOutputStream(outFile);
249 ZipOutputStream zos = null;
250 try {
251 zos = new ZipOutputStream(new BufferedOutputStream(fos));
240 try (FileOutputStream fos = new FileOutputStream(outFile);
241 ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(fos))) {
252242 zos.setMethod(ZipOutputStream.DEFLATED);
253243 zos.setLevel(9);
254244 ZipEntry stringZipEntry = stringTable.write(zos);
255245 ZipEntry testTableZipEntry = testTable.write(zos);
256246 ZipEntry testTreeZipEntry = testTree.write(zos);
257 zos.close();
258247
259248 // report statistics
260249 if (log != null) {
269258 }
270259 else {
271260 return 0;
272 }
273 }
274 finally {
275 // attempt to close zip writer first
276 // followed by the underlying writer for leak prevention
277 if (zos != null){
278 try { zos.close(); } catch (IOException e) { }
279 }
280
281 if (fos != null){
282 try { fos.close(); } catch (IOException e) { }
283261 }
284262 }
285263 }
299277 throw new NullPointerException();
300278
301279 try {
302 Class c = Class.forName(finder);
280 Class<?> c = Class.forName(finder);
303281 testFinder = (TestFinder) (c.newInstance());
304282 testFinder.init(args, ts, null);
305283 }
362340 throw new IllegalArgumentException();
363341
364342 File rootDir = finder.getRootDir();
365 Set allFiles = new HashSet();
343 Set<File> allFiles = new HashSet<>();
366344
367345 TestTree.Node r = null;
368346 for (int i = 0; i < files.length; i++) {
391369 /**
392370 * Read the tests from a file in test suite
393371 */
394 private TestTree.Node read0(TestFinder finder, File file, TestTree testTree, Set allFiles)
372 private TestTree.Node read0(TestFinder finder, File file, TestTree testTree, Set<File> allFiles)
395373 {
396374 // keep track of which files we have read, and ignore duplicates
397375 if (allFiles.contains(file))
407385 return null;
408386
409387 Arrays.sort(files);
410 Arrays.sort(tests, new Comparator() {
411 public int compare(Object o1, Object o2) {
412 TestDescription td1 = (TestDescription) o1;
413 TestDescription td2 = (TestDescription) o2;
388 Arrays.sort(tests, new Comparator<TestDescription>() {
389 public int compare(TestDescription td1, TestDescription td2) {
414390 return td1.getRootRelativeURL().compareTo(td2.getRootRelativeURL());
415391 }
416392 });
417393
418 Vector v = new Vector();
394 Vector<TestTree.Node> v = new Vector<>();
419395 for (int i = 0; i < files.length; i++) {
420396 TestTree.Node n = read0(finder, files[i], testTree, allFiles);
421397 if (n != null)
472448 * increase its use count.
473449 */
474450 void add(String s) {
475 Entry e = (Entry) (map.get(s));
451 Entry e = map.get(s);
476452 if (e == null) {
477453 e = new Entry();
478454 map.put(s, e);
484460 * Add all the strings used in a test description to the table.
485461 */
486462 void add(TestDescription test) {
487 for (Iterator i = test.getParameterKeys(); i.hasNext(); ) {
488 String key = (String) (i.next());
463 for (Iterator<String> i = test.getParameterKeys(); i.hasNext(); ) {
464 String key = (i.next());
489465 String param = test.getParameter(key);
490466 add(key);
491467 add(param);
511487 * Get the index of a string in the table.
512488 */
513489 int getIndex(String s) {
514 Entry e = (Entry) (map.get(s));
490 Entry e = map.get(s);
515491 if (e == null)
516492 throw new IllegalArgumentException();
517493 return e.index;
536512 * Write the contents of the table to a stream
537513 */
538514 void write(DataOutputStream o) throws IOException {
539 Vector v = new Vector(map.size());
515 Vector<String> v = new Vector<>(map.size());
540516 v.addElement("");
541517 int nextIndex = 1;
542 for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
543 Map.Entry e = (Map.Entry) (iter.next());
544 String key = (String) (e.getKey());
545 Entry entry = (Entry) (e.getValue());
518 for (Iterator<Map.Entry<String, Entry>> iter = map.entrySet().iterator(); iter.hasNext(); ) {
519 Map.Entry<String, Entry> e = iter.next();
520 String key = e.getKey();
521 Entry entry = e.getValue();
546522 if (entry.isFrequent()) {
547523 entry.index = nextIndex++;
548524 v.addElement(key);
551527
552528 writeInt(o, v.size());
553529 for (int i = 0; i < v.size(); i++)
554 o.writeUTF((String) (v.elementAt(i)));
530 o.writeUTF(v.elementAt(i));
555531
556532 writtenSize = nextIndex;
557533 }
565541 * string, zero will be written, followed by the value of the string itself.
566542 */
567543 void writeRef(String s, DataOutputStream o) throws IOException {
568 Entry e = (Entry) (map.get(s));
544 Entry e = map.get(s);
569545 if (e == null)
570546 throw new IllegalArgumentException();
571547
577553 }
578554 }
579555
580 private TreeMap map = new TreeMap();
556 private Map<String, Entry> map = new TreeMap<>();
581557 private int writtenSize;
582558
583559 /**
644620 * written stream.
645621 */
646622 int getIndex(TestDescription td) {
647 Entry e = (Entry) (testMap.get(td));
623 Entry e = testMap.get(td);
648624 if (e == null)
649625 throw new IllegalArgumentException();
650626 return e.index;
676652 void write(DataOutputStream o) throws IOException {
677653 writeInt(o, tests.size());
678654 for (int i = 0; i < tests.size(); i++) {
679 TestDescription td = (TestDescription) (tests.elementAt(i));
680 Entry e = (Entry) (testMap.get(td));
655 TestDescription td = tests.elementAt(i);
656 Entry e = testMap.get(td);
681657 e.index = o.size();
682658 write(td, o);
683659 }
690666 private void write(TestDescription td, DataOutputStream o) throws IOException {
691667 // should consider using load/save here
692668 writeInt(o, td.getParameterCount());
693 for (Iterator i = td.getParameterKeys(); i.hasNext(); ) {
694 String key = (String) (i.next());
669 for (Iterator<String> i = td.getParameterKeys(); i.hasNext(); ) {
670 String key = (i.next());
695671 String value = td.getParameter(key);
696672 stringTable.writeRef(key, o);
697673 stringTable.writeRef(value, o);
698674 }
699675 }
700676
701 private HashMap testMap = new HashMap();
702 private Vector tests = new Vector();
677 private Map<TestDescription, Entry> testMap = new HashMap<>();
678 private Vector<TestDescription> tests = new Vector<>();
703679 private StringTable stringTable;
704680
705681 /**
823799 if (!other.name.equals(name))
824800 throw new IllegalArgumentException(name + ":" + other.name);
825801
826 TreeMap mergedChildrenMap = new TreeMap();
802 TreeMap<String, Node> mergedChildrenMap = new TreeMap<>();
827803 for (int i = 0; i < children.length; i++) {
828804 Node child = children[i];
829805 mergedChildrenMap.put(child.name, child);
830806 }
831807 for (int i = 0; i < other.children.length; i++) {
832808 Node otherChild = other.children[i];
833 Node c = (Node) (mergedChildrenMap.get(otherChild.name));
809 Node c = mergedChildrenMap.get(otherChild.name);
834810 mergedChildrenMap.put(otherChild.name,
835811 (c == null ? otherChild : otherChild.merge(c)));
836812 }
837813 Node[] mergedChildren =
838 (Node[]) (mergedChildrenMap.values().toArray(new Node[mergedChildrenMap.size()]));
814 mergedChildrenMap.values().toArray(new Node[mergedChildrenMap.size()]);
839815
840816 TestDescription[] mergedTests;
841817 if (tests.length + other.tests.length == 0)
2727
2828 import java.io.*;
2929 import java.nio.charset.StandardCharsets;
30 import java.util.Comparator;
31 import java.util.Hashtable;
32 import java.util.SortedSet;
33 import java.util.TreeSet;
30 import java.util.*;
3431
3532 import com.sun.javatest.TestDescription;
3633 import com.sun.javatest.TestEnvironment;
147144 */
148145 public void readEntries(File file) throws Fault {
149146 //System.err.println("reading " + file);
150 SortedSet s = new TreeSet(new Comparator() {
151 public int compare(Object o1, Object o2) {
152 int n = ((Entry)o1).compareTo((Entry)o2);
147 SortedSet<Entry> s = new TreeSet<>(new Comparator<Entry>() {
148 public int compare(Entry o1, Entry o2) {
149 int n = o1.compareTo(o2);
153150 // this gives us the reverse of the order we want, so ...
154151 return -n;
155152 }
156153 });
157154
158 BufferedReader in = null;
159 try {
160 in = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8));
155 try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
161156 String line;
162157 int lineNum = 0;
163158 while ((line = in.readLine()) != null) {
187182 throw new Fault(i18n, "cham.ioError",
188183 new Object[] {file, e});
189184 }
190 finally {
191 // attempt to close buffered writer first
192 // followed by the underlying writer for leak prevention
193 if (in != null){
194 try { in.close(); } catch (IOException e) { }
195 }
196 }
197185
198186 entryFile = file;
199 entries = (Entry[]) (s.toArray(new Entry[s.size()]));
187 entries = s.toArray(new Entry[s.size()]);
200188
201189 //for (int i = 0; i < entries.length; i++)
202190 // System.err.println(entries[i].prefix + " " + entries[i].suffix);
289277 currEntry = null;
290278 }
291279
292 private Object newInstance(Class c) throws Fault {
280 private Object newInstance(Class<?> c) throws Fault {
293281 try {
294282 return c.newInstance();
295283 }
303291 }
304292 }
305293
306 private Class loadClass(String className) throws Fault {
294 private Class<?> loadClass(String className) throws Fault {
307295 try {
308296 if (loader == null)
309297 return Class.forName(className);
329317 private boolean ignoreCase;
330318 private Entry currEntry;
331319 private ClassLoader loader;
332 private Hashtable excludeList = new Hashtable();
320 private Map<String, String> excludeList = new HashMap<>();
333321
334322 private static final String[] excludeNames = {
335323 "SCCS", "deleted_files"
8282 return super.decodeArg(args, i);
8383 } // decodeArg()
8484
85 private Map initTable(String[] entries) {
86 Map map = new HashMap();
85 private Map<String, String> initTable(String[] entries) {
86 Map<String, String> map = new HashMap<>();
8787 for (int i = 0; i < entries.length; i++)
8888 map.put(entries[i].toLowerCase(), entries[i]);
8989 return map;
9090 } // initTable()
9191
92 private Map addTableItem(Map entries, String name, String value) {
92 private Map<String, String> addTableItem(Map<String, String> entries, String name, String value) {
9393 entries.put(name, value);
9494 return entries;
9595 } // addTableItem()
9696
9797 private boolean verify;
98 private Map validEntries;
99 private Map validKeywords;
98 private Map<String, String> validEntries;
99 private Map<String, String> validKeywords;
100100
101101 private static final String TESTSUITE_HTML = "testsuite.html";
102102 // end of code for JCKTagTestFinder emulation
106106 public void init(String [] args, File testSuiteRoot, TestEnvironment env) throws Fault {
107107 // grab all environment variables open for expansion
108108 if (expandVars == null) {
109 expandVars = new HashMap(3);
110 expandVarLen = new HashMap(3);
111
112 for (Iterator i = env.keys().iterator(); i.hasNext(); ) {
109 expandVars = new HashMap<>(3);
110 expandVarLen = new HashMap<>(3);
111
112 for (Iterator<String> i = env.keys().iterator(); i.hasNext(); ) {
113113 try {
114 String n = (String) (i.next());
114 String n = (i.next());
115115
116116 if (! n.startsWith("expand."))
117117 continue;
126126 String stem = fqvName.substring(0, pos);
127127
128128 // checking lengths of co-joined variables
129 Integer len = (Integer) expandVarLen.get(stem);
129 Integer len = expandVarLen.get(stem);
130130 if (len == null) {
131131 // add to hashtable of valid stems
132132 expandVarLen.put(stem, new Integer(v.length));
165165 super.init(args, testSuiteRoot, env);
166166 } // init()
167167
168 protected void foundTestDescription(Map entries, File file, int line) {
168 protected void foundTestDescription(Map<String, String> entries, File file, int line) {
169169 // cross-product and loop call up
170 String origId = (String) entries.get("id");
170 String origId = entries.get("id");
171171 if (origId == null)
172172 origId = "";
173 Map loopVars = new HashMap(3);
173 Map<String, Integer> loopVars = new HashMap<>(3);
174174 foundTestDescription_1(entries, file, line, loopVars, origId);
175175 } // foundTestDescription()
176176
177 private void foundTestDescription_1(Map entries, File file, int line, Map loopVars, String id) {
178 for (Iterator iter = entries.keySet().iterator(); iter.hasNext(); ) {
179 String name = (String) (iter.next());
180 String value = (String) entries.get(name);
177 private void foundTestDescription_1(Map<String, String> entries, File file, int line, Map<String, Integer> loopVars, String id) {
178 for (Iterator<String> iter = entries.keySet().iterator(); iter.hasNext(); ) {
179 String name = iter.next();
180 String value = entries.get(name);
181181 // System.out.println("------ NAME: " + name + " VALUE: " + value);
182182
183183 if (name.equals("title") || name.equals("test") || name.equals("id"))
217217 continue;
218218
219219 String [] valueList;
220 if ((valueList = (String []) expandVars.get(varName)) == null) {
220 if ((valueList = expandVars.get(varName)) == null) {
221221 //String [] msgs = {"unable to find `expand' definition in environment",
222222 //words[i]};
223223 //error(msgs);
225225 }
226226
227227 String saveId = id;
228 Integer idx = (Integer) loopVars.get(stem);
228 Integer idx = loopVars.get(stem);
229229 if (idx != null){
230230 int j = idx.intValue();
231231 words[i] = valueList[j];
245245 boolean loopy = !(qualifier.equals(""));
246246 if (loopy) loopVars.put(stem, new Integer(j));
247247 // clone needed here because we over-wrote words[i]
248 foundTestDescription_1((Map)(((HashMap)entries).clone()), file, line,
248 foundTestDescription_1(new HashMap<>(entries), file, line,
249249 loopVars, id);
250250 if (loopy) loopVars.remove(stem);
251251
257257 }
258258 // clone may not be necessary, check for TestDescription upgrades
259259 // super.foundTestDescription(entries, file, line);
260 super.foundTestDescription((Map)(((HashMap)entries).clone()), file, line);
260 super.foundTestDescription(new HashMap<>(entries), file, line);
261261 } // foundTestDescription_1()
262262
263 protected void processEntry(Map entries, String name, String value) {
263 protected void processEntry(Map<String, String> entries, String name, String value) {
264264 // System.out.println("NAME: " + name + " VALUE: " + value);
265265 if (name.equals("expand")) {
266266 if (testStems != null) {
267267 error(i18n, "expand.multipleTags");
268268 }
269 testStems = new HashMap(3);
269 testStems = new HashMap<>(3);
270270 String [] stems = StringArray.split(value);
271271 for (int i = 0 ; i < stems.length; i++)
272272 testStems.put(stems[i], TRUE);
310310 //----------member variables------------------------------------------------
311311
312312 private static final String TRUE = "true";
313 private Map testStems = null;
314 private Map expandVars;
315 private Map expandVarLen;
313 private Map<String, String> testStems = null;
314 private Map<String, String[]> expandVars;
315 private Map<String, Integer> expandVarLen;
316316
317317 private String[] stdValidEntries = {
318318 // required
2727
2828 import java.io.*;
2929 import java.nio.charset.StandardCharsets;
30 import java.util.HashMap;
3031 import java.util.Hashtable;
32 import java.util.Map;
3133 import java.util.Vector;
3234
3335 import com.sun.javatest.TestFinder;
4850 // init the tables used when scanning directories
4951 // if necessary, the tables could be dynamically updated by the
5052 // init args; this is not currently supported
51 excludeList = new Hashtable(excludeNames.length);
53 excludeList = new Hashtable<>(excludeNames.length);
5254 for (int i = 0; i < excludeNames.length; i++)
5355 excludeList.put(excludeNames[i], excludeNames[i]);
5456
55 extensionTable = new Hashtable(extensions.length);
57 extensionTable = new Hashtable<>(extensions.length);
5658 for (int i = 0; i < extensions.length; i++)
5759 extensionTable.put(extensions[i], extensions[i]);
5860 }
343345 String value = scanValue();
344346 skipSpace();
345347 if (att.equals("class") && "TestDescription".equals(value)) {
346 params = new Hashtable();
348 params = new Hashtable<>();
347349 endTestDescriptionTag = "table";
348350 } else if (att.equals("id"))
349351 id = value;
357359 skipTag();
358360 if (params != null) {
359361 endTableRow();
360 tableRow = new Vector();
362 tableRow = new Vector<>();
361363 }
362364 }
363365
366368 // ensure any outstanding <td> is closed
367369 endTableData();
368370 if (tableRow.size() == 2)
369 processEntry(params, (String)tableRow.elementAt(0), (String)tableRow.elementAt(1));
371 processEntry(params, tableRow.elementAt(0), tableRow.elementAt(1));
370372 tableRow = null;
371373 }
372374 }
402404 String value = scanValue();
403405 skipSpace();
404406 if (att.equals("class") && "TestDescription".equals(value)) {
405 params = new Hashtable();
407 params = new Hashtable<>();
406408 endTestDescriptionTag = "dl";
407409 } else if (att.equals("id"))
408410 id = value;
504506 if (att.equals("name")) {
505507 lastName = value;
506508 Integer here = new Integer(line);
507 Integer prev = (Integer)namesInFile.put(value, here);
509 Integer prev = namesInFile.put(value, here);
508510 if (prev != null) {
509511 error(i18n, "html.multipleName",
510512 new Object[] {value, context, here, prev});
583585
584586 //----------member variables------------------------------------------------
585587
586 private Hashtable namesInFile = new Hashtable();
587 private Hashtable excludeList;
588 private Map<String, Integer> namesInFile = new HashMap<>();
589 private Map<String, String> excludeList;
588590 private static final String[] excludeNames = {"SCCS", "deleted_files"};
589 private Hashtable extensionTable;
591 private Map<String, String> extensionTable;
590592 private static final String[] extensions = {".html", ".htm"};
591593
592594 /**
613615 private StringBuffer text;
614616
615617 private String endTestDescriptionTag;
616 private Hashtable params;
618 private Hashtable<String, String> params;
617619 private String defTerm; // collects test description parameter name
618 private Vector tableRow; // collects test description info from <TR><TD>....</TD>....etc...</TR>
620 private Vector<String> tableRow; // collects test description info from <TR><TD>....</TD>....etc...</TR>
619621 private String lastName;
620622
621623 private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(HTMLTestFinder.class);
7575 TestEnvironment env) throws Fault {
7676 String delegateClassName = args[0];
7777 try {
78 Class delegateClass = Class.forName(delegateClassName, true, ClassLoader.getSystemClassLoader());
78 Class<?> delegateClass = Class.forName(delegateClassName, true, ClassLoader.getSystemClassLoader());
7979 delegate = (TestFinder)(delegateClass.newInstance());
8080 args = shift(args, 1);
8181 delegate.init(args, testSuiteRoot, env);
222222 TestFinder testFinder;
223223
224224 try {
225 Class c = Class.forName(finder);
225 Class<?> c = Class.forName(finder);
226226 testFinder = (TestFinder) (c.newInstance());
227227 testFinder.init(args, ts, null);
228228 }
257257 TestDescription td = tests[i];
258258 out.println(" " + td.getRootRelativeURL());
259259 if (fullTests) {
260 for (Iterator iter = td.getParameterKeys(); iter.hasNext(); ) {
261 String key = (String) (iter.next());
260 for (Iterator<String> iter = td.getParameterKeys(); iter.hasNext(); ) {
261 String key = (iter.next());
262262 String value = td.getParameter(key);
263263 out.print(" ");
264264 out.print(key);
154154 * A class to read files of a particular extension.
155155 * The class must be a subtype of CommentStream
156156 */
157 public void addExtension(String extn, Class commentStreamClass) {
157 public void addExtension(String extn, Class<? extends CommentStream> commentStreamClass) {
158158 if (!extn.startsWith("."))
159159 throw new IllegalArgumentException("extension must begin with `.'");
160160 if (!CommentStream.class.isAssignableFrom(commentStreamClass))
168168 * @param extn The extension in question
169169 * @return the class previously registered with addExtension
170170 */
171 public Class getClassForExtension(String extn) {
172 return (Class)extensionTable.get(extn);
171 public Class<? extends CommentStream> getClassForExtension(String extn) {
172 return extensionTable.get(extn);
173173 }
174174
175175 /**
250250 if (dot == -1)
251251 return;
252252 String extn = name.substring(dot);
253 Class csc = (Class)(extensionTable.get(extn));
253 Class<? extends CommentStream> csc = extensionTable.get(extn);
254254 if (csc == null) {
255255 error(i18n, "tag.noParser", new Object[] {file, extn});
256256 return;
257257 }
258258 CommentStream cs = null;
259259 try {
260 cs = (CommentStream)(csc.newInstance());
260 cs = csc.newInstance();
261261 }
262262 catch (InstantiationException e) {
263263 error(i18n, "tag.cantCreateClass", new Object[] {csc.getName(), extn});
275275
276276 String comment;
277277 while ((comment = cs.readComment()) != null) {
278 Map tagValues = parseComment(comment, file);
278 Map<String, String> tagValues = parseComment(comment, file);
279279 if (tagValues.isEmpty())
280280 continue;
281281
319319 * @param currFile The name of the file currently being read.
320320 * @return A map containing the name-value pairs read from the comment.
321321 */
322 protected Map parseComment(String comment, File currFile) {
323 Map tagValues = new HashMap();
322 protected Map<String, String> parseComment(String comment, File currFile) {
323 Map<String, String> tagValues = new HashMap<>();
324324 int tagStart = 0;
325325 int tagEnd = 0;
326326
398398 //----------member variables------------------------------------------------
399399
400400 private File currFile;
401 private HashMap excludeList = new HashMap();
402 private HashMap extensionTable = new HashMap();
401 private Map<String, String> excludeList = new HashMap<>();
402 private Map<String, Class<? extends CommentStream>> extensionTable = new HashMap<>();
403403 private boolean fastScan = false;
404404 private String initialTag = "test";
405405
9393 return currentTestFinder.getFiles();
9494 }
9595
96 public Comparator getComparator() {
96 public Comparator<String> getComparator() {
9797 return currentTestFinder.getComparator();
9898 }
9999
100 public void setComparator(Comparator c) {
100 public void setComparator(Comparator<String> c) {
101101 currentTestFinder.setComparator(c);
102102 }
103103
5353
5454
5555 <ol start="3">
56 <li><p>Use the Expression,
56 <li>Use the Expression,
5757 Insert Operator, and Insert Keyword buttons to build an expression in the
58 text field by using any logical combination of the following actions:</p></li>
59
60 <ul>
61 <li><p>Click the Expression button to display a list of expressions that
62 can be constructed. From the list, choose the type of expression that
63 you are building.</p></li>
64 <li><p>Click the Insert Keyword button to display the list of keywords provided
65 by the test suite for use in filtering tests (this is only available
66 if the test suite has information). From the list, choose the keywords
67 used in the expression.</p></li>
68 <li><p>Click the Insert Operator button to display a list of operators that
69 you can use to construct boolean expressions in the text field. From
70 the list, choose the operator used in the expression.<br><br>See Keyword Expressions for descriptions and examples of keyword expressions
71 that can be constructed.</p></li>
72 </ul>
58 text field by using any logical combination of the following actions:
59 <ul>
60 <li><p>Click the Expression button to display a list of expressions that
61 can be constructed. From the list, choose the type of expression that
62 you are building.</p></li>
63 <li><p>Click the Insert Keyword button to display the list of keywords provided
64 by the test suite for use in filtering tests (this is only available
65 if the test suite has information). From the list, choose the keywords
66 used in the expression.</p></li>
67 <li><p>Click the Insert Operator button to display a list of operators that
68 you can use to construct boolean expressions in the text field. From
69 the list, choose the operator used in the expression.<br><br>See Keyword Expressions for descriptions and examples of keyword expressions
70 that can be constructed.</p></li>
71 </ul>
72 </li>
7373 </ol>
74
7475 <ol start="4">
7576 <li><p>Change additional template settings or click the Done button to save the changes
7677 in the template.</p></li>
5252 bar.</li>
5353 <li> Click a question in the Template Editor.</li>
5454 <li>Set a bookmark for the highlighted question by performing one of the following
55 actions:</li>
55 actions:
5656 <ul>
57 <li>Click to the left of the highlighted question text.</li>
58 <li>Choose Bookmarks <b>&gt;</b> Mark Current Question in the menu bar.</li>
59 <li>Right click the highlighted question and choose the Mark Current Question
60 menu item in the pop-up menu.</li>
61 </ul>
57 <li>Click to the left of the highlighted question text.</li>
58 <li>Choose Bookmarks <b>&gt;</b> Mark Current Question in the menu bar.</li>
59 <li>Right click the highlighted question and choose the Mark Current Question
60 menu item in the pop-up menu.</li>
61 </ul>
62 </li>
6263 </ol>
6364
6465 <h2 class="proc">Display Questions With Bookmarks</h2>
6768 <ul>
6869 <li>Click the Bookmarks <b>&gt;</b> Show Only Bookmarked Questions checkbox
6970 in the menu bar.<br><br>The Template Editor displays bookmarked questions in the following
70 manner:</li>
71 manner:
7172 <ul>
72 <li>The first question in the interview is displayed.</li>
73 <li>Questions with bookmarks are displayed.</li>
74 <li>If the interview is complete (all questions have valid answers) the final
75 question is displayed.</li>
76 <li>If the interview is incomplete (one or more questions have invalid or
77 incomplete answers), the questions from the last marked question to the
78 first question with an invalid or incomplete answer are displayed.</li>
79 <li>Sequences of questions not described by a previous category are grouped
80 and represented by three dashes (---) in the list of questions. These groups
81 can be opened to display the complete sequence of questions.</li>
82 </ul>
73 <li>The first question in the interview is displayed.</li>
74 <li>Questions with bookmarks are displayed.</li>
75 <li>If the interview is complete (all questions have valid answers) the final
76 question is displayed.</li>
77 <li>If the interview is incomplete (one or more questions have invalid or
78 incomplete answers), the questions from the last marked question to the
79 first question with an invalid or incomplete answer are displayed.</li>
80 <li>Sequences of questions not described by a previous category are grouped
81 and represented by three dashes (---) in the list of questions. These groups
82 can be opened to display the complete sequence of questions.</li>
83 </ul>
84 </li>
8385
8486 </ul>
8587
8890 <p>Groups of hidden questions without bookmarks
8991 are represented by three dashes (---) in the list of questions. </p>
9092
91 <p><!--CopyOff--><img src="../../images/hg_proc.gif" alt="This is the start of a procedure" longdesc="SetMarkersTE.html"><!--CopyOn-->
92 <ol>To open a group
93 of hidden questions, perform the following steps:</p>
93 <p><!--CopyOff--><img src="../../images/hg_proc.gif" alt="This is the start of a procedure" longdesc="SetMarkersTE.html"><!--CopyOn-->To
94 open a group of hidden questions, perform the following steps:</p>
95 <ol>
9496 <li>Click the --- section in the list.</li>
9597 <li>Click the Bookmarks <b>&gt;</b> Open --- Group menu item from
9698 the menu bar or right click the highlighted --- section and choose Open --- Group
126128 Current Question from the pop-up menu.</li>
127129 </ol>
128130 <h2 class="proc">Remove All Bookmarks</h2>
129 <!--CopyOff--><p><img src="../../images/hg_proc.gif" alt="This is the start of a procedure" longdesc="SetMarkersTE.html"><!--CopyOn-->To
131 <p><!--CopyOff--><img src="../../images/hg_proc.gif" alt="This is the start of a procedure" longdesc="SetMarkersTE.html"><!--CopyOn-->To
130132 remove the bookmarks from the template, perform the following step:</p>
131133
132134 <ul>
135137 </ul>
136138
137139 <h2 class="proc">Remove a Bookmark From a Question</h2>
138 <!--CopyOff--><p><img src="../../images/hg_proc.gif" alt="This is the start of a procedure" longdesc="SetMarkersTE.html"><!--CopyOn-->To remove the bookmarks from a question in the template, perform the
140 <p><!--CopyOff--><img src="../../images/hg_proc.gif" alt="This is the start of a procedure" longdesc="SetMarkersTE.html"><!--CopyOn-->To remove the bookmarks from a question in the template, perform the
139141 following steps:</p>
140142 <ol>
141143 <li>Click the question in the question list.</li>
4343 to create and edit templates that can be used to run tests on multiple test systems
4444 or test platform. </p>
4545 <p class="Note">
46 <!--CopyOff--><IMG SRC="../../images/hg_note.gif" ALT="The following text is a Note" longdesc="createTemplate.html"></br>
46 <!--CopyOff--><IMG SRC="../../images/hg_note.gif" ALT="The following text is a Note" longdesc="createTemplate.html">
4747 <!--CopyOn-->
4848 Your test suite might not enable creating
4949 or editing templates. The menu items and features described here <b><u>will not appear in your user interface</u></b> if your test suite does not support templates. </p>
6363 <li>Use the test tree or a test list to specify the tests that are run.<br><br>See
6464 the following topics for detailed information about using the test tree or
6565 load list to
66 specify tests:</li>
66 specify tests:
6767 <ul>
68 <li><a href="#testTree">Specifying Tests in the Test Tree</a> </li>
69 <li><a href="#testList">Loading a Test List </a></li>
70 </ul>
68 <li><a href="#testTree">Specifying Tests in the Test Tree</a> </li>
69 <li><a href="#testList">Loading a Test List </a></li>
70 </ul>
71 </li>
7172 </ol>
7273
7374 <ol start="5">
153154 or similar utilities to identify lines that specify the tests with failed
154155 or error results.</p>
155156 <p>Example lines from <code>summary.txt</code>: </p>
156
157 <ol><li><code>
157 <p><code>
158158 BigNum/compareTest.html Failed. exit code 1<br>
159159 BigNum/equalsTest.html Failed. exit code 1<br>
160160 BigNum/longConstrTest.html Failed. exit code 1<br>
169169 lists/LinkedList/removeTest.html Failed. exit code 1<br>
170170 lists/SortedList/equalsTest.html Failed. exit code 1<br>
171171 lists/SortedList/insertTest.html Failed. exit code 1<br>
172 lists/SortedList/removeTest.html Failed. exit code 1</code></li></ol>
172 lists/SortedList/removeTest.html Failed. exit code 1</code>
173 </li> </ol>
173174
174175
175176 <ol start="2">
147147 stream to provide standard error information from the test section. Many
148148 tests only use the log stream and include tracing as well as standard error
149149 information when writing to the log output.</li>
150 </ul></p>
150 </ul>
151151 <p>
152152 The contents of each output section varies from test suite to test suite. Refer
153153 to your test suite documentation for detailed descriptions of the test section
4545 <li type="disc"><p>By default the list has two columns, Name and Title. Click a heading to sort the list.
4646 <li type="disc"><p>To display alternate information in the second column, right-click on the column heading and make a selection from the Description or Runtime context menus.<br>
4747
48 <center><img src="../../images/statusAltInfo.gif" alt="Additional test information" longdesc="Additional test information for can be displayed in the second column"></center></p>
48 <center><img src="../../images/statusAltInfo.gif" alt="Additional test information" longdesc="Additional test information for can be displayed in the second column"></center>
4949
5050 <li><p>Double click the test name or press Enter to display the test in the test tree and to view its unfiltered test information. See <a href="testInfo.html">Displaying Test Information</a> for additional information.</p></li>
5151 </ul>
8484 <li>unchecked the Save Desktop State on Exit option in the Preferences dialog box<li>provided test suite or work
8585 directory information on the command line when starting the harness
8686 <li>used the <code>-newDesktop</code> on the command line when starting the harness</ul>
87 </p>
8887 <p><a href="../ui/appearancePrefs.html#appearancePrefs.shutdown">See Shutdown Options.</a> </p>
8988 <hr>
9089
4040 <CODE>java -cp</CODE> [<EM>jt-dir</EM><CODE>/lib/</CODE>]
4141 <CODE>javatest.jar com.sun.javatest.EditJTI <br>
4242 -o</CODE> <EM>my-newconfig</EM><CODE>.jti test.serialport.midPort=/dev/term/a
43 test.connection.httpsCert="\"CN=&lt:Somebody&gt;, OU=&lt;People&gt;, O=&lt;Organisation&gt;, L=&lt;Location&gt;, ST=&lt;State&gt;,
43 test.connection.httpsCert="\"CN=&lt;Somebody&gt;, OU=&lt;People&gt;, O=&lt;Organisation&gt;, L=&lt;Location&gt;, ST=&lt;State&gt;,
4444 C=US\""</CODE><EM>myoriginal</EM><CODE>.jti</CODE></P>
4545
4646 <hr>
4141 </ul>
4242 <p>The test harness has two interfaces, a command-line interface (CLI), and a graphical user interface (GUI).</p>
4343 <ul>
44 <li>The command-line interface provides scriptable test harness functionality for configuring and executing tests and creating reports. Information about using the command-line interface can be found in the following topics:</P>
44 <li>The command-line interface provides scriptable test harness functionality for configuring and executing tests and creating reports. Information about using the command-line interface can be found in the following topics:
4545 <UL>
4646 <LI><A href="commandLine.html">Command-Line Summary</A></LI>
4747 <LI><A href="setupCommands.html">Set-up Commands</A></LI>
144144 <p>
145145 Users can workaround this problem by explicitly changing the codepage to one compatible with the Unicode characters for the Cyrillic locale. For the Russian locale example:
146146 <br>
147 <code>> chcp 1251</code>
147 <code> chcp 1251</code>
148148 <br>
149149 Or users can force the JVM to use the default codepage for the terminal:
150150 <br>
151 <code>java -Dfile.encoding=cp866 -jar ...
151 <code>java -Dfile.encoding=cp866 -jar ... </code>
152152 </p>
153153
154154 <p>
110110 </ol>
111111 <ol start="8">
112112
113 <li><p>Search the configuration file for the specific characters or character strings that must be changed. </p></li>
113 <li><p>Search the configuration file for the specific characters or character strings that must be changed. </p>
114114
115115 <p>See <a href="../confEdit/searchConfiguration.html">Searching a Configuration</a> for
116116 a detailed description of how the current configuration can be searched for
117 a character or string of characters.</p>
117 a character or string of characters.</p></li>
118118 </ol>
119119 <ol start="9">
120120 <li><p>Click the Done button to save your changes to the configuration file</p></li>
6767 </li>
6868 <li><p>Click the Next button.</p>
6969 <p>
70 The harness displays the Report Options panel.
71 <center><img src="../../images/JT41mergeReport2.gif" alt="Merge Report wizard panel 2" longdesc="mergeReports.html"></center></p>
70 The harness displays the Report Options panel.</p>
71 <center><img src="../../images/JT41mergeReport2.gif" alt="Merge Report wizard panel 2" longdesc="mergeReports.html"></center>
7272 </li>
7373 <li><p>In the Report Options panel, specify how conflicts
7474 between merged reports are handled.</p></li>
9696 Conflict dialog box for each conflict that is detected.</p>
9797
9898 <center><img src="../../images/JT4reportConverterConflict.gif" alt="Resolve conflict dialog box" longdesc="mergeReports.html"></center>
99 </p></blockquote></li>
99 </blockquote></li>
100100 </ol>
101101 <ul>
102102 <li><p>If you only click the Resolve using most recent checkbox and click the
105105 <li><p>If you select a report in the list, the tool enables the Resolve remaining
106106 conflicts using selected report checkbox. If you only click the Resolve
107107 remaining conflicts using selected report checkbox and click the Resolve
108 button, the tool resolves all conflicts in the generated tests.
109 <center><img src="../../images/JT4reportConverterConflict2.gif" alt="Report Converter conflict dialog box" longdesc="mergeReports.html"></center></p></li>
108 button, the tool resolves all conflicts in the generated tests.</p>
109 <center><img src="../../images/JT4reportConverterConflict2.gif" alt="Report Converter conflict dialog box" longdesc="mergeReports.html"></center></li>
110110 </ul>
111111
112112
2626 -->
2727
2828
29 <html>
29 <html lang="en">
3030 <head>
3131 <title>
3232 Creating Reports
102102 <p>Check "Backup Options settings" to enable the report backup option, and specify the number of backups preserved.</p>
103103
104104 <p>When "Backup old reports" is enabled, the harness saves the previous reports by appending a tilde and a sequential number to the existing directory names (such as <code>html~1~</code>). This effectively moves them out of the way, making way for the new report(s). The links inside the backup <code>index.html</code> file are rewritten to refer to the correct (renamed) subdirectory name. For example, a report directory with one backup would look like: </p>
105 <table>
105 <table summary="example of a report directory with ine backup">
106 <tr><th>directory:</th></tr>
106107 <tr><td>
107108 <pre>
108109 html/
233234 <li><p>From the configuration editor, select Configure &gt; Edit Configuration.</p></li>
234235 <li><p>Under Parameters, select "Specify a Known Failures List?" and choose Yes.
235236 Once Yes is chosen the parameter "Specify Known Failures List Files" is active. </p></li>
236 <li><p>Choose one or more KFL files, as described in the configuration editor's <a href="../../../moreInfo/default/KnownFailuresListInterview/customFiles.html">KnownFailuresListInterview</a>.</p> The files you choose are stored in your user preferences and are considered the defaults.
237 <li><p>Choose one or more KFL files, as described in the configuration editor's <a href="../confEdit/kfl.html">KnownFailuresListInterview</a>.</p> The files you choose are stored in your user preferences and are considered the defaults.
237238 </ol>
238239 <p>If you have specified KFL files in the configuration editor it's preferable to modify the list using the configuration editor. If you want to modify the list of KFL files from the command line, See <a href="../../default/command/knownFailureAnalysis.html">Specifying Known Failures Lists with kfl</a> in the <em>Command Line Interface User's Guide</em>.
239240
1919 You should have received a copy of the GNU General Public License version
2020 2 along with this work; if not, write to the Free Software Foundation,
2121 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22
22
2323 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2424 or visit www.oracle.com if you need additional information or have any
2525 questions.
4444 <!--CopyOff--><p><img src="../../images/hg_proc.gif" alt="This is the start of a procedure" longdesc="reportBrowser.html">
4545 To display reports in the report browser:</p><!--CopyOn-->
4646 <ol>
47 <li><p>Choose Report <b>&gt;</b> Open Report from the menu bar.</p></li>
47 <li><p>Choose Report <b>&gt;</b> Open Report from the menu bar.</p>
4848
4949 <blockquote>
5050 <p>The harness opens a file chooser dialog box for you
5454 <img src="../../images/JT4reportViewer.gif" alt="First page of the report viewer" longdesc="reportBrowser.html">
5555 </p></center>
5656 </blockquote>
57 </li>
5758 </ol>
5859
5960 <ol start="2">
60 <li><p>Choose the report format from the directory listing.</p></li>
61 <li><p>Choose the report format from the directory listing.</p>
6162
6263 <ul>
6364 <li> <p>If you choose the HTML format version of the reports, a second directory
6465 listing is displayed. On the toolbar, you can use the report browser's back button (&lt;) to return to the initial report page. You can also click the file name showing on the toolbar to open a dropdown of recently visited files and directories.</p>
65 <p><center>
66 <center>
6667 <img src="../../images/JT4reportViewer2.gif" alt="html page of the report viewer" longdesc="reportBrowser.html">
67 </center></p></li>
68 </center></li>
6869 <li>
6970 <p>If you choose the text format version of the report, the browser
7071 displays a <code>summary.txt</code> hyperlink to the summary page. The summary
7172 page provides a text list of tests that were run and their test result status. </p>
72 <p><center>
73 <center>
7374 <img src="../../images/JT4reportViewerText.gif" alt="text page of the report viewer" longdesc="reportBrowser.html">
74 </center></p>
75 </center>
7576 </li>
7677 <li> <p>If you choose the XML format version of the report, the browser
7778 displays a <code>report.xml</code> hyperlink to the XML report page. The
7879 XML Report page provides a report of the configuration values used to run
7980 the tests, the tests that were run, and their test result status. </p>
8081 <p>This output is for automated processing purposes. It is not designed for human readability.</p>
81 <p><center>
82 <center>
8283 <img src="../../images/JT4reportViewerXML.gif" alt="text page of the report viewer" longdesc="reportBrowser.html">
83 </center></p>
84 </center>
8485 </li>
85
8686 </ul>
87 </li>
8788 </ol>
8889
8990 <ol start="3">
108108 <li><p>Folder view - When you click a folder icon in the test tree, the harness displays a Summary tab, a Documentation tab, five status tabs, and a status field containing information from the work directory about a folder and its descendants. See <a href="../browse/folderInfo.html">Displaying Folder Information</A> for detailed information about browsing folder information.</p></li>
109109 <li><p>Test view - When you click a test icon in the test tree or double click its name in the Folder view, the harness displays six tabbed panes that contain detailed information about the test. See <a href="../browse/testInfo.html">Displaying Test Information</A> for detailed information about browsing test information.</p></li>
110110 </ul>
111 </td></p>
111 </td>
112112 </tr>
113113 </table>
114114
3939 <p><img src="../../images/log_svcmonitor_small.gif" alt="view services" longdesc="monitoring services and logs"></p>
4040 <p>See <a href="../ui/logViewer.html">Log Viewer</a> for a detailed description of the Log Viewer.</p>
4141
42 <ul></ul>
43
4442 <hr>
4543
4644 <p><a href="../copyright.html">Copyright</a> &copy; 2010, Oracle and/or its affiliates. All rights reserved.</p>
5858 <li>Type an integer value in the corresponding text box, or use the spinners to the right of the field to increase or decrease the value.</li>
5959 </ul>
6060 Repeat this process for H, S, and B, then click OK.</li>
61 <li>To set the Red, Green, and Blue values, click the RGB tab.</li>
62 <ul>
63 <li>Pick a value using the horizontal slider.</li>
64 <li>Type an integer value in the corresponding text box, or use the spinners to the right of the field to increase or decrease the value.</li>
65 </ul>
61 <li>To set the Red, Green, and Blue values, click the RGB tab.
62 <ul>
63 <li>Pick a value using the horizontal slider.</li>
64 <li>Type an integer value in the corresponding text box, or use the spinners to the right of the field to increase or decrease the value.</li>
65 </ul>
66 </li>
6667 </ul>
6768
6869
4949 <ul>
5050 <li>Tool Bar: Check Displayed to see the toolbar. If you enable or disable this option you must restart JavaTest to see the change.<center><img src="../../images/uiToolbar.gif" alt="standard UI toolbar" longdesc="standard UI toolbar"></center></li>
5151 <li>View Filters: Enables a warning message that is displayed if the <a href="../browse/viewFilters.html">All Tests filter</a> is selected for a test run.</li>
52 <a name="testExecOrder"> <!-- index:execution order --><!-- index:order --></a>
53 <li>Test Execution: </li>
54 <ul><li>Execution from tree popup includes configuration Test to Run setting: </li>
55 <li>Disable sort of Tests to Run when specified from input file: This allows you to set the test execution order. Traditionally tests are run in the order they appear in the main test tree. This order is generally determined by the test suite architect. By selecting this option, the order execution will follow that in the input file for the Tests to Run section in the configuration. That is, the tests will be executed in the order they appear in that file, rather than being sorted and then executed. The default state of this checkbox is unchecked. See </li></ul>
52 <li><a name="testExecOrder"> <!-- index:execution order --><!-- index:order --></a>Test Execution:
53 <ul><li>Execution from tree popup includes configuration Test to Run setting: </li>
54 <li>Disable sort of Tests to Run when specified from input file: This allows you to set the test execution order. Traditionally tests are run in the order they appear in the main test tree. This order is generally determined by the test suite architect. By selecting this option, the order execution will follow that in the input file for the Tests to Run section in the configuration. That is, the tests will be executed in the order they appear in that file, rather than being sorted and then executed. The default state of this checkbox is unchecked. See </li></ul>
5655 <li>Test Run Messages: Wrap Test Output in the <a href="../../default/browse/messagesTab.html#messagesTab">Test Run Messages Pane</a>.</li>
57
5856 </ul>
5957
6058
127127
128128 void addRegistredURL(String url) {
129129 if (url != null) {
130 regURLs = (String[])DynamicArray.append(regURLs, url);
130 regURLs = DynamicArray.append(regURLs, url);
131131 if (debug) System.out.println("PROV-registered URL (" + url + ") in " + this);
132132 }
133133 }
135135 void removeRegisteredURL(String url) {
136136 for (int i = 0; i < regURLs.length; i++) {
137137 if (regURLs[i].equals(url)) {
138 regURLs = (String[])DynamicArray.remove(regURLs, i);
138 regURLs = DynamicArray.remove(regURLs, i);
139139 break;
140140 }
141141 } // for
120120 /**
121121 * Prints the contents of any dictionary in a two column table.
122122 */
123 public static void writeDictionary(PrintWriter out, Dictionary dict,
123 public static void writeDictionary(PrintWriter out, Dictionary<String, String> dict,
124124 String keyHeader, String valHeader) {
125125 // XXX should include HTML filtering of strings
126126
147147 buf.append("</tr>");
148148 }
149149 else {
150 Enumeration keys = dict.keys();
150 Enumeration<?> keys = dict.keys();
151151 while (keys.hasMoreElements()) {
152152 Object key = keys.nextElement();
153153 out.println("<tr>");
2828 import java.util.Enumeration;
2929 import java.util.Hashtable;
3030 import java.io.PrintWriter;
31 import java.util.Iterator;
32 import java.util.Map;
3133
3234 import com.sun.javatest.util.DynamicArray;
3335 import com.sun.javatest.util.I18NResourceBundle;
259261
260262 boolean result;
261263 String file = url[0];
262 url = (String[])DynamicArray.remove(url, 0);
264 url = DynamicArray.remove(url, 0);
263265
264266 if (debug) System.out.println(" PR-Partial insert of " + file);
265267
302304 }
303305
304306 String file = url[0];
305 url = (String[])DynamicArray.remove(url, 0);
307 url = DynamicArray.remove(url, 0);
306308
307309 if (debug) System.out.println(" PR-(del)Partial remove of " + file);
308310
366368 currC = url.charAt(pos);
367369 switch (currC) {
368370 case '/': if (pos > start+1)
369 result = (String[])DynamicArray.append(result, url.substring(start, pos));
371 result = DynamicArray.append(result, url.substring(start, pos));
370372 start = pos + 1;
371373 pos++;
372374 break;
379381 }
380382
381383 if (!done && pos >= urlLen && (pos - start) >= 1)
382 result = (String[])DynamicArray.append(result, url.substring(start, pos));
384 result = DynamicArray.append(result, url.substring(start, pos));
383385
384386 if (debug)
385387 System.out.println("PR-Dissolved url " + url + " into " + result.length + " files.");
390392 /**
391393 * Maps the url to a HandlerEntry
392394 */
393 protected Hashtable url2prov = new Hashtable();
395 protected Map<String, Object> url2prov = new Hashtable<>();
394396
395397 private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(ProviderRegistry.class);
396398 protected static boolean debug = Boolean.getBoolean("debug." + ProviderRegistry.class.getName());
429431 }
430432
431433 protected static class IndexHandler extends JThttpProvider {
432 IndexHandler(Hashtable ht) {
434 IndexHandler(Map<String, Object> ht) {
433435 urlMap = ht;
434436 }
435437
466468 HandlerEntry entry;
467469
468470 // XXX should use set of unique entries
469 Enumeration enum_ = urlMap.elements();
470 while(enum_.hasMoreElements()) {
471 Object next = enum_.nextElement();
471 for (Object next: urlMap.values()) {
472472 if (next instanceof HandlerEntry) {
473473 entry = (HandlerEntry)next;
474474
487487 out.println();
488488 }
489489
490 private Hashtable urlMap;
490 private Map<String, Object> urlMap;
491491 }
492492 }
493493
162162 out.println("</body></html>");
163163 }
164164
165 private static Hashtable urlMap;
166165
167166 private Socket soc;
168167 private PrintWriter out;
2727
2828 import java.util.Hashtable;
2929 import java.io.PrintWriter;
30 import java.util.Map;
3031
3132 import com.sun.javatest.util.I18NResourceBundle;
3233
7778 * @return The object's handler, or null if none if registered.
7879 */
7980 public static JThttpProvider getObjectHandler(Object what) {
80 return (JThttpProvider)(obj2prov.get(what));
81 return obj2prov.get(what);
8182 }
8283
8384 public static void associateObject(Object what, JThttpProvider prov) {
104105 * Good for associating a first-class JT Harness object with a provider.
105106 * For example, map a TestResultTable instance to it's HTTP handler.
106107 */
107 protected static final Hashtable obj2prov = new Hashtable();
108 protected static final Map<Object, JThttpProvider> obj2prov = new Hashtable<>();
108109 private static final I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(RootRegistry.class);
109110
110111 static {
148148 * Set the key-value pairs encoded in this URL.
149149 * Not implemented yet.
150150 */
151 public void setProperties(Dictionary props) {
151 public void setProperties(Dictionary<String, String> props) {
152152 }
153153
154154 /**
258258 // verify all entries defined
259259 cachedEnvError = null;
260260 cachedEnvErrorArgs = null;
261 for (Iterator i = cachedEnv.elements().iterator();
261 for (Iterator<TestEnvironment.Element> i = cachedEnv.elements().iterator();
262262 i.hasNext() && cachedEnvError == null; ) {
263 TestEnvironment.Element entry = (TestEnvironment.Element) (i.next());
263 TestEnvironment.Element entry = (i.next());
264264 if (entry.getValue().indexOf("VALUE_NOT_DEFINED") >= 0) {
265265 cachedEnv = null;
266266 String eText =
323323 return super.getChoices();
324324 }
325325
326 public void save(Map data) {
326 public void save(Map<String, String> data) {
327327 ensureInitialized();
328328 super.save(data);
329329 }
363363 ensureInitializedForTestSuite();
364364
365365 String defaultValue = CUSTOM;
366 Vector v = new Vector(4);
366 Vector<String> v = new Vector<>(4);
367367
368368 v.add(null); // always
369369
2828 import java.util.Arrays;
2929 import java.util.HashSet;
3030 import java.util.Map;
31 import java.util.Set;
32
3133 import com.sun.interview.FinalQuestion;
3234 import com.sun.interview.Interview;
3335 import com.sun.interview.Question;
196198 super.setValue(modeValue);
197199 }
198200
199 public void load(Map data) {
200 Object m = data.get(tag + ".mode");
201 Object v = data.get(tag + ".value");
201 public void load(Map<String, String> data) {
202 String m = data.get(tag + ".mode");
203 String v = data.get(tag + ".value");
202204 //System.err.println("KI.load: m=" + m + " v=" + v);
203205 if (m == null)
204206 super.load(data); // support existing interview files
205207 else if (m instanceof String && (v == null || v instanceof String)) {
206 String ms = (String) m;
207 String vs = (String) v;
208 String ms = m;
209 String vs = v;
208210 if (ms.equals("allOf"))
209211 setValue(ALL_OF, vs);
210212 else if (ms.equals("anyOf"))
214216 }
215217 }
216218
217 public void save(Map data) {
219 public void save(Map<String, String> data) {
218220 super.save(data); // for backwards compatibility
219221 String modeText = (mode == ANY_OF ? "anyOf" : mode == ALL_OF ? "allOf" : "expr");
220222 data.put(tag + ".mode", modeText);
268270 }
269271
270272 String[] validKeywords = ts.getKeywords();
271 HashSet validKeywordsSet;
273 Set<String> validKeywordsSet;
272274 if (validKeywords == null)
273275 validKeywordsSet = null;
274276 else
275 validKeywordsSet = new HashSet(Arrays.asList(validKeywords));
277 validKeywordsSet = new HashSet<>(Arrays.asList(validKeywords));
276278
277279 int mode = qKeywords.getMode();
278280 String modeName = (mode == ANY_OF ? Keywords.ANY_OF
6969 }
7070
7171 public TestEnvironment getEnv() {
72 HashMap envProps = new HashMap();
72 Map<String, String> envProps = new HashMap<>();
7373 export(envProps);
7474 try {
7575 String name = qName.getValue();
106106 return qEnvEnd;
107107 }
108108
109 public void export(Map data) {
109 public void export(Map<String, String> data) {
110110 data.put("script.mode", "precompile");
111111 data.put("command.compile.java", System.getProperty("command.compile.java"));
112112 }
121121 return qName;
122122 }
123123
124 public void export(Map data) {
124 public void export(Map<String, String> data) {
125125 data.put("script.mode", "developer");
126126 data.put("command.compile.java", System.getProperty("command.compile.java"));
127127 }
152152 return qCmdType;
153153 }
154154
155 public void export(Map data) {
155 public void export(Map<String, String> data) {
156156 data.put("description", String.valueOf(value));
157157 }
158158 };
181181 }
182182
183183 @Override
184 public void export(Map data) {
184 public void export(Map<String, String> data) {
185185 String cmd;
186186 if (value != null && value.equals(OTHER_VM)) {
187187 cmd = getOtherVMExecuteCommand();
2727
2828 import java.io.*;
2929 import java.nio.charset.StandardCharsets;
30 import java.util.ArrayList;
31 import java.util.Arrays;
32 import java.util.TreeSet;
30 import java.util.*;
3331
3432 import com.sun.interview.ChoiceQuestion;
3533 import com.sun.interview.ErrorQuestion;
153151 return null;
154152 }
155153
156 TreeSet ts = new TreeSet(Arrays.asList(v));
157 return (String[]) (ts.toArray(new String[ts.size()]));
154 TreeSet<String> ts = new TreeSet<>(Arrays.asList(v));
155 return ts.toArray(new String[ts.size()]);
158156
159157 }
160158
211209
212210 @Override
213211 public void setValue(String newValue) {
214 if (newValue != value) {
212 if ( !Objects.equals(newValue, value) ) {
215213 cachedTestsError = null;
216214 cachedTestsErrorArgs = null;
217215 cachedTestsValue = null;
278276 };
279277
280278 protected String[] getTests(File file) {
281 ArrayList<String> paths = new ArrayList();
279 ArrayList<String> paths = new ArrayList<>();
282280 try {
283281 BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8));
284282 String line;
303301 return null ;
304302 }
305303
306 return (String[]) (paths.toArray(new String[paths.size()]));
304 return paths.toArray(new String[paths.size()]);
307305 }
308306
309307 private Question qCantFindFileError = new ErrorQuestion(this, "cantFindFile") {
486484 return;
487485 }
488486 else {
489 ArrayList v = new ArrayList();
487 ArrayList<String> v = new ArrayList<>();
490488 StringBuilder sb = new StringBuilder();
491489 for (int i = 0; i < tests.length; i++) {
492490 String test = tests[i];
8181 protected void setup(String executeClass) {
8282
8383 try {
84 Class junitTestCaseClass = getClassLoader().loadClass(executeClass);
84 Class<?> junitTestCaseClass = getClassLoader().loadClass(executeClass);
8585 testCaseClass = junitTestCaseClass;
8686
8787
9494 t.printStackTrace(log);
9595 }
9696
97 protected Class testCaseClass;
97 protected Class<?> testCaseClass;
9898 }
151151 * @param file The file to scan
152152 */
153153 protected void scanFile(File file) {
154 testMethods = new ArrayList(); // new every time we visit a new class
155 tdValues = new HashMap();
154 testMethods = new ArrayList<>(); // new every time we visit a new class
155 tdValues = new HashMap<>();
156156
157157 String name = file.getName();
158158 int dot = name.indexOf('.');
6262 if (tests == null) {
6363 return Status.failed("No test cases found in test.");
6464 }
65 Iterator iterator = ((Set)tests.entrySet()).iterator();
65 Iterator<Map.Entry<String, Method>> iterator = tests.entrySet().iterator();
6666 while (iterator.hasNext()) {
67 Method method = (Method)((Map.Entry)iterator.next()).getValue();
67 Method method = iterator.next().getValue();
6868 Status status = null;
6969 try {
7070 status = invokeTestCase(method);
9494 protected void setup(String executeClass) {
9595 TestCase test;
9696 try {
97 Class tc = getClassLoader().loadClass(executeClass);
97 Class<?> tc = getClassLoader().loadClass(executeClass);
9898 String name = tc.getName();
9999 String constructor = tc.getConstructors()[0].toGenericString();
100100 test = (constructor.indexOf("java.lang.String") > -1)?
143143 if(m == null || excludeTestCases.contains(m.getName())){
144144 continue;
145145 }
146 Class[] paramTypes = m.getParameterTypes();
147 Class returnType = m.getReturnType();
146 Class<?>[] paramTypes = m.getParameterTypes();
147 Class<?> returnType = m.getReturnType();
148148 String name = m.getName();
149149 if ((paramTypes.length == 0) &&
150150 Void.TYPE.isAssignableFrom(returnType) && name.startsWith("test") ) {
160160 protected SortedMap <String, Method> tests;
161161
162162 protected String testCases[] = null;
163 protected Vector excludeTestCases = new Vector();
163 protected Vector<String> excludeTestCases = new Vector<>();
164164 }
5252
5353 public TestEnvironment getEnv() {
5454 try {
55 return new TestEnvironment("junitenv", new HashMap(), "junit");
55 return new TestEnvironment("junitenv", new HashMap<String, String>(), "junit");
5656 }
5757 catch (TestEnvironment.Fault f) {
5858 f.printStackTrace();
153153 * @param file The file to scan
154154 */
155155 protected void scanFile(File file) {
156 testMethods = new ArrayList(); // new every time we visit a new class
157 tdValues = new HashMap();
156 testMethods = new ArrayList<>(); // new every time we visit a new class
157 tdValues = new HashMap<>();
158158
159159 String name = file.getName();
160160 if (verbose)
331331
332332 //----------member variables------------------------------------------------
333333
334 protected ArrayList<String> requiredSuperclass = new ArrayList();
334 protected ArrayList<String> requiredSuperclass = new ArrayList<>();
335335 protected String initialTag = "test";
336336 protected final MethodFinderVisitor mfv = new MethodFinderVisitor();
337337 protected static final I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(JUnitSuperTestFinder.class);
3232 import java.io.File;
3333 import java.util.ArrayList;
3434 import java.util.HashMap;
35 import java.util.List;
3536 import java.util.Map;
3637
3738 /**
119120 * A class to read files of a particular extension.
120121 * The class must be a subtype of CommentStream
121122 */
122 public void addExtension(String extn, Class commentStreamClass) {
123 public void addExtension(String extn, Class<?> commentStreamClass) {
123124 if (!extn.startsWith("."))
124125 throw new IllegalArgumentException("extension must begin with `.'");
125126 if (commentStreamClass != null && !CommentStream.class.isAssignableFrom(commentStreamClass))
133134 * @param extn The extension in question
134135 * @return the class previously registered with addExtension
135136 */
136 public Class getClassForExtension(String extn) {
137 return (Class)extensionTable.get(extn);
137 public Class<?> getClassForExtension(String extn) {
138 return extensionTable.get(extn);
138139 }
139140
140141 /**
145146 }
146147
147148 protected boolean verbose = false;
148 protected Map tdValues = new HashMap();
149 protected Map<String, String> tdValues = new HashMap<>();
149150 protected boolean scanClasses = false;
150151 protected File currFile;
151 protected HashMap excludeList = new HashMap();
152 protected HashMap extensionTable = new HashMap();
153 protected ArrayList<String> testMethods;
152 protected Map<String, String> excludeList = new HashMap<>();
153 protected Map<String, Class<?>> extensionTable = new HashMap<>();
154 protected List<String> testMethods;
154155 protected static final String[] excludeNames = {
155156 "SCCS", "deleted_files", ".svn"
156157 };
4949 // by the corresponding TestSuite class.
5050 }
5151
52 protected boolean runTests(Iterator testIter) throws InterruptedException {
52 protected boolean runTests(Iterator<TestDescription> testIter) throws InterruptedException {
5353 WorkDirectory wd = getWorkDirectory();
5454 TestDescription td = null;
5555 //for (TestDescription td: testIter) {
5656 for (; testIter.hasNext() ;) {
57 td = (TestDescription)(testIter.next());
57 td = testIter.next();
5858 TestResult tr = new TestResult(td);
5959 TestResult.Section outSection = tr.createSection("Main");
6060
8484 this.loader = loader;
8585
8686 try {
87 Class c = loader.loadClass("com.sun.javatest.junit.JUnitMultiTest");
87 Class<?> c = loader.loadClass("com.sun.javatest.junit.JUnitMultiTest");
8888 } catch (ClassNotFoundException e) {
8989 e.printStackTrace();
9090 }
3636 * Basic implementation of a test suite for JUnit tests.
3737 */
3838 public class JUnitTestSuite extends TestSuite {
39 public JUnitTestSuite(File root, Map props, ClassLoader loader) throws TestSuite.Fault {
39 public JUnitTestSuite(File root, Map<String, String> props, ClassLoader loader) throws TestSuite.Fault {
4040 super(root, props, loader);
4141 try {
4242 if (getTestsDir() != null)
5555 // will need to add options to test suite to be passed to runner
5656 // for ex. - to run setup/teardown, etc...
5757 try {
58 Class c = loadClass("com.sun.javatest.junit.JUnitTestRunner");
58 Class<?> c = loadClass("com.sun.javatest.junit.JUnitTestRunner");
5959 JUnitTestRunner tr = (JUnitTestRunner)(c.newInstance());
6060 tr.setClassLoader(getClassLoader());
6161 return tr;
104104
105105 Status status = null;
106106 try {
107 Class c;
107 Class<?> c;
108108 if (loader == null)
109109 c = Class.forName(className);
110110 else
181181 else
182182 loader = new PathClassLoader(classpath);
183183
184 Class compilerClass;
184 Class<?> compilerClass;
185185 if (compilerClassName != null) {
186186 compilerClass = getClass(loader, compilerClassName);
187187 if (compilerClass == null)
200200
201201 Object[] compileMethodArgs;
202202 Method compileMethod = getMethod(compilerClass, "compile", // JDK1.4+
203 new Class[] { String[].class, PrintWriter.class });
203 new Class<?>[] { String[].class, PrintWriter.class });
204204 if (compileMethod != null)
205205 compileMethodArgs = new Object[] { args, ref };
206206 else {
207207 compileMethod = getMethod(compilerClass, "compile", // JDK1.1-3
208 new Class[] { String[].class });
208 new Class<?>[] { String[].class });
209209 if (compileMethod != null)
210210 compileMethodArgs = new Object[] { args };
211211 else
217217 compiler = null;
218218 else {
219219 Object[] constrArgs;
220 Constructor constr = getConstructor(compilerClass, // JDK1.1-2
221 new Class[] { OutputStream.class, String.class });
220 Constructor<?> constr = getConstructor(compilerClass, // JDK1.1-2
221 new Class<?>[] { OutputStream.class, String.class });
222222 if (constr != null)
223223 constrArgs = new Object[] { new WriterStream(ref), compilerName };
224224 else {
225 constr = getConstructor(compilerClass, new Class[0]); // JDK1.3
225 constr = getConstructor(compilerClass, new Class<?>[0]); // JDK1.3
226226 if (constr != null)
227227 constrArgs = new Object[0];
228228 else
264264 }
265265 }
266266
267 private Class getClass(ClassLoader loader, String name) {
267 private Class<?> getClass(ClassLoader loader, String name) {
268268 try {
269269 return (loader == null ? Class.forName(name) : loader.loadClass(name));
270270 }
273273 }
274274 }
275275
276 private Constructor getConstructor(Class c, Class[] argTypes) {
276 private Constructor<?> getConstructor(Class<?> c, Class<?>[] argTypes) {
277277 try {
278278 return c.getConstructor(argTypes);
279279 }
287287 }
288288 }
289289
290 private Method getMethod(Class c, String name, Class[] argTypes) {
290 private Method getMethod(Class<?> c, String name, Class<?>[] argTypes) {
291291 try {
292292 return c.getMethod(name, argTypes);
293293 }
6363 } // for
6464
6565 String prefix = "script.";
66 Set testKeys = td.getKeywordTable();
67 Vector choices = new Vector(); // the set of choices
68 Vector matches = new Vector(); // the set of matches
66 Set<String> testKeys = td.getKeywordTable();
67 Vector<String> choices = new Vector<>(); // the set of choices
68 Vector<String> matches = new Vector<>(); // the set of matches
6969 int wordsMatchingInMatches = 0;// the number of words matching
7070
7171 findMatch:
72 for (Iterator iter = env.keys().iterator(); iter.hasNext(); ) {
73 String key = (String) (iter.next());
72 for (Iterator<String> iter = env.keys().iterator(); iter.hasNext(); ) {
73 String key = (iter.next());
7474
7575 // if the key does not begin with the `script.' prefix, ignore key
7676 if (!key.startsWith(prefix))
110110 if (debug)
111111 trOut.println("new best match, " + keys.length + " keys");
112112
113 matches = new Vector();
113 matches = new Vector<>();
114114 wordsMatchingInMatches = keys.length;
115115 }
116116
135135 trOut.println(s);
136136 trOut.println("The keyword combinations for scripts in this environment are: ");
137137 for (int i = 0; i < choices.size(); i++) {
138 trOut.println((String)choices.elementAt(i));
138 trOut.println(choices.elementAt(i));
139139 } // for
140140
141141 setStatus(Status.error(s));
152152 return;
153153 } // else if
154154
155 String bestScript = (String)matches.elementAt(0);
155 String bestScript = matches.elementAt(0);
156156 //trOut.report.println("BEST " + bestScript);
157157
158158 try {
176176 printStrArr(trOut, msgs);
177177
178178 try {
179 Class c = Class.forName(command[0]);
179 Class<?> c = Class.forName(command[0]);
180180
181181 Script script = (Script)c.newInstance();
182182 String[] scriptArgs = new String[command.length - 1];
8383 */
8484 public void setStatusForExit(int exitCode, Status status) {
8585 if (statusTable == null) {
86 statusTable = new Hashtable();
86 statusTable = new Hashtable<>();
8787 if (defaultStatus == null)
8888 defaultStatus = Status.error("unrecognized exit code");
8989 }
103103 */
104104 public void setDefaultStatus(Status status) {
105105 if (statusTable == null)
106 statusTable = new Hashtable();
106 statusTable = new Hashtable<>();
107107 defaultStatus = status;
108108 }
109109
279279 if (inheritEnv) {
280280 // copy env from system
281281 // then apply cmdEnv
282 ArrayList<String> out = new ArrayList();
282 ArrayList<String> out = new ArrayList<>();
283283 Map<String,String> sysenv = System.getenv();
284284 Set<String> keys = sysenv.keySet();
285285 for (String key : keys) {
400400 if (logStatus != null)
401401 return logStatus;
402402 else if (statusTable != null) {
403 Status s = (Status)(statusTable.get(new Integer(exitCode)));
403 Status s = statusTable.get(Integer.valueOf(exitCode));
404404 return (s == null ? defaultStatus.augment("exit code: " + exitCode) : s);
405405 }
406406 else if (exitCode == 0)
504504 Boolean.getBoolean("javatest.processCommand.useFailedOnException");
505505
506506 private static int serial;
507 private Hashtable statusTable;
507 private Map<Integer, Status> statusTable;
508508 private Status defaultStatus;
509509 private File execDir;
510510 private boolean inheritEnv =
3030 import java.lang.reflect.Method;
3131 import java.util.Enumeration;
3232 import java.util.Hashtable;
33 import java.util.Map;
3334 import java.util.Vector;
3435 import com.sun.javatest.Status;
3536 import com.sun.javatest.Test;
136137 * select and exclude calls that have been made, if any.
137138 * @return An enumeration of the test cases.
138139 */
139 public Enumeration enumerate() {
140 Vector v = new Vector();
140 public Enumeration<Method> enumerate() {
141 Vector<Method> v = new Vector<>();
141142 if (selectedCases.isEmpty()) {
142143 Method[] methods = testClass.getMethods();
143144 for (int i = 0; i < methods.length; i++) {
144145 Method m = methods[i];
145146 if (excludedCases.get(m.getName()) == null) {
146 Class[] paramTypes = m.getParameterTypes();
147 Class returnType = m.getReturnType();
147 Class<?>[] paramTypes = m.getParameterTypes();
148 Class<?> returnType = m.getReturnType();
148149 if ((paramTypes.length == 0) && Status.class.isAssignableFrom(returnType))
149150 v.addElement(m);
150151 }
151152 }
152153 }
153154 else {
154 for (Enumeration e = selectedCases.elements(); e.hasMoreElements(); ) {
155 Method m = (Method)(e.nextElement());
155 for (Method m : selectedCases.values()) {
156156 if (excludedCases.get(m.getName()) == null)
157157 v.addElement(m);
158 }
158 }
159159 }
160160 return v.elements();
161161 }
175175 // see if test object provides Status invokeTestCase(Method m)
176176 Method invoker;
177177 try {
178 invoker = testClass.getMethod("invokeTestCase", new Class[] {Method.class});
178 invoker = testClass.getMethod("invokeTestCase", new Class<?>[] {Method.class});
179179 if (!Status.class.isAssignableFrom(invoker.getReturnType()))
180180 invoker = null;
181181 }
184184 }
185185
186186 MultiStatus ms = new MultiStatus(log);
187 for (Enumeration e = enumerate(); e.hasMoreElements(); ) {
188 Method m = (Method)(e.nextElement());
187 for (Enumeration<Method> e = enumerate(); e.hasMoreElements(); ) {
188 Method m = (e.nextElement());
189189 Status s;
190190 try {
191191 if (invoker != null)
250250 }
251251
252252 private String[] split(String s) {
253 Vector v = new Vector();
253 Vector<String> v = new Vector<>();
254254 int start = 0;
255255 for (int i = s.indexOf(','); i != -1; i = s.indexOf(',', start)) {
256256 v.addElement(s.substring(start, i));
264264 }
265265
266266 private Object test;
267 private Class testClass;
268 private Hashtable selectedCases = new Hashtable();
269 private Hashtable excludedCases = new Hashtable();
267 private Class<?> testClass;
268 private Map<String, Method> selectedCases = new Hashtable<>();
269 private Map<String, Method> excludedCases = new Hashtable<>();
270270 private PrintWriter log;
271271
272272 private static final Object[] noArgs = { };
273 private static final Class[] noArgTypes = { };
273 private static final Class<?>[] noArgTypes = { };
274274 }
426426
427427
428428 private class MessageCache extends LinkedHashMap<LiteLogRecord, String> {
429 protected boolean removeEldestEntry(Map.Entry eldest) {
429 protected boolean removeEldestEntry(Map.Entry<LiteLogRecord, String> eldest) {
430430 return size() > PAGE_SIZE*2;
431431 }
432432 }
435435 selectBox.setSelectedItem(s);
436436 }
437437
438 private DefaultComboBoxModel createModel() {
438 private DefaultComboBoxModel<URL> createModel() {
439439 if (model == null)
440 model = new DefaultComboBoxModel();
440 model = new DefaultComboBoxModel<>();
441441 return model;
442442 }
443443
450450 private JButton backBtn;
451451 private JButton forwardBtn;
452452
453 private JComboBox selectBox;
453 private JComboBox<URL> selectBox;
454454 private JPanel head;
455455 private JPanel body;
456456 private JTextField noteField;
461461
462462 private History history;
463463
464 private DefaultComboBoxModel model;
464 private DefaultComboBoxModel<URL> model;
465465 private Listener listener = new Listener();
466466 private JToolBar toolBar;
467467 private UIFactory uif;
485485 if (index == 0)
486486 return null;
487487
488 return (URL) (entries.elementAt(--index));
488 return entries.elementAt(--index);
489489 }
490490
491491 boolean hasNext() {
496496 if (index == entries.size() - 1)
497497 return null;
498498
499 return (URL) (entries.elementAt(++index));
499 return entries.elementAt(++index);
500500 }
501501
502502 void add(URL u) {
521521 index = -1;
522522 }
523523
524 private Vector entries = new Vector();
524 private Vector<URL> entries = new Vector<>();
525525 private int index;
526526 }
527527
561561 //------------------------------------------------------------------------------------
562562
563563 private class Renderer extends DefaultListCellRenderer {
564 public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) {
564 public Component getListCellRendererComponent(JList<?> list, Object o, int index, boolean isSelected, boolean cellHasFocus) {
565565 String name = null;
566566 if (o instanceof URL) {
567567 URL url = (URL) o;
6464 private JButton resolveButton;
6565 private JButton cancelButton;
6666
67 private DefaultListModel listModel;
68 private JList list;
67 private DefaultListModel<String> listModel;
68 private JList<?> list;
6969
7070 private int selectedIndex;
7171 private boolean bPreferredReport;
105105 chooseTextPanel.add(chooseText);
106106
107107 // Build list box
108 listModel=new DefaultListModel();
108 listModel=new DefaultListModel<>();
109109 for (int i=0; i< reportsList.length; i++) {
110110 listModel.addElement(reportsList[i]);
111111 }
170170 return false;
171171 }
172172
173 List mergedList = new ArrayList();
173 List<String> mergedList = new ArrayList<>();
174174 for (int i = 0; i < merged.length; i++) {
175175 merged[i] = merged[i].trim();
176176 if ( !"".equals(merged[i])) {
208208 boolean error = false; // block "next" button if any error occurred (should be false to unblock)
209209 ArrayList<String> used = new ArrayList<String>();
210210 for (int i = 0; i < merged.size(); i++) {
211 JTextField tField = (JTextField) merged.get(i);
211 JTextField tField = merged.get(i);
212212 String s = tField.getText().trim();
213213 tField.setBackground(UIFactory.getDefaultInputColor());
214214 if (!"".equals(s)) { // do nothing, if value is empty
224224 } else {
225225 error = true;
226226 tField.setBackground(UIFactory.getInvalidInputColor());
227 ((JTextField)merged.get(used.indexOf(s))).setBackground(UIFactory.getInvalidInputColor());
227 (merged.get(used.indexOf(s))).setBackground(UIFactory.getInvalidInputColor());
228228 }
229229 }
230230 }
242242 setName("tool.merged");
243243 setLayout(new GridBagLayout());
244244
245 merged = new ArrayList();
246 this.mergedBtns = new ArrayList();
245 merged = new ArrayList<>();
246 this.mergedBtns = new ArrayList<>();
247247
248248 addMore = uif.createButton("files.addmore", new ActionListener() {
249249 public void actionPerformed(ActionEvent e) {
287287 Object src = e.getSource();
288288 for (int i = 0; i < mergedBtns.size(); i++) {
289289 if (src == mergedBtns.get(i)) {
290 chooseXmlReportFile((JTextField) merged
290 chooseXmlReportFile( merged
291291 .get(i));
292292 }
293293 }
308308 this.updateUI();
309309 }
310310
311 private java.util.List mergedBtns;
311 private java.util.List<JButton> mergedBtns;
312312 private JButton addMore;
313313
314314 }
378378 String formatVersion = "formatVersion=\"v1\"";
379379
380380 if (!f.getName().endsWith(".xml")) return false;
381 BufferedReader r = null;
382 try {
383 r = new BufferedReader(new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8));
381 try (BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8))) {
384382 boolean hasSchema, hasVersion = false;
385383
386384 // line 1
395393 return (hasSchema && hasVersion);
396394 } catch (IOException ex) {
397395 return false;
398 } finally {
399 try {
400 if (r != null) r.close();
401 } catch (IOException ex) {
402 // nothing...
403 }
404396 }
405397 }
406398
441433 String[] getXmlFiles() {
442434 int l=0;
443435 for (int i = 0; i < merged.size(); i++) {
444 String s = ((JTextField)merged.get(i)).getText().trim();
436 String s = merged.get(i).getText().trim();
445437 if (!"".equals(s)) l++;
446438 }
447439
448440 String[] result = new String[l];
449441 l = 0;
450442 for (int i = 0; i < merged.size(); i++) {
451 String s = ((JTextField)merged.get(i)).getText().trim();
443 String s = merged.get(i).getText().trim();
452444 if (!"".equals(s)) {
453 result[l++] = ((JTextField)merged.get(i)).getText().trim();
445 result[l++] = s;
454446 }
455447 }
456448 return result;
457449 }
458450
459 private List merged;
451 private List<JTextField> merged;
460452 static final String OK = "OK";
461453
462454 private class Listener extends ComponentAdapter implements ActionListener, FocusListener, KeyListener {
4444 /**
4545 * @param in array of files with XML reports
4646 * @param out file to put results
47 * @param confilctResolver ConflictResolver to resolve conflicts during merge
47 * @param conflictResolver ConflictResolver to resolve conflicts during merge
4848 */
49 public boolean merge(File[] in, File out, ConflictResolver confilctResolver) throws SAXException,
49 public boolean merge(File[] in, File out, ConflictResolver conflictResolver) throws SAXException,
5050 ParserConfigurationException, IOException{
5151 // Maps with statistics
52 Map[] inputs = new Map[in.length];
52 Map<?, ?>[] inputs = new Map<?, ?>[in.length];
5353 // read statistics
5454 for (int i = 0; i < in.length; i++) {
5555 XMLReportReader reader = new XMLReportReader();
56 Map map = reader.readIDs(in[i]);
56 Map<?, ?> map = reader.readIDs(in[i]);
5757 inputs[i] = map;
5858 }
5959
6060 // shift word workgroups id renaming
6161 int allCnt = 0;
6262 // rename id's and find conflicts
63 Set all = new HashSet();
64 List confilcts = new ArrayList();
63 Set<String> all = new HashSet<>();
64 List<String> conflicts = new ArrayList<>();
6565 for (int i = 0; i < in.length; i++) {
6666 int workdirsInFile = 0;
67 Iterator it = inputs[i].keySet().iterator();
68 Map newMap = new HashMap();
67 Iterator<?> it = inputs[i].keySet().iterator();
68 Map<Object, Object> newMap = new HashMap<>();
6969 while (it.hasNext()) {
7070 Object o = it.next();
7171 // this is workdir ID
7878 // this is test result url
7979 if (o instanceof String) {
8080 String url = (String) o;
81 if (all.contains(url) && !confilcts.contains(url)) {
82 confilcts.add(url);
81 if (all.contains(url) && !conflicts.contains(url)) {
82 conflicts.add(url);
8383 }
8484 all.add(url);
8585 TestResultDescr td = (TestResultDescr)inputs[i].get(o);
9393 }
9494
9595 // resolve each conflict
96 for (int c = 0; c < confilcts.size(); c++) {
97 String url = (String)confilcts.get(c);
98 ArrayList tds = new ArrayList();
96 for (int c = 0; c < conflicts.size(); c++) {
97 String url = conflicts.get(c);
98 List<TestResultDescr> tds = new ArrayList<>();
9999 for(int i = 0; i < in.length; i++) {
100100 TestResultDescr td = (TestResultDescr) inputs[i].get(url);
101101 if (td != null) {
103103 tds.add(td);
104104 }
105105 }
106 TestResultDescr[] tda = (TestResultDescr[])tds.toArray(new TestResultDescr[0]);
107 int res = confilctResolver.resolve(url, tda);
106 TestResultDescr[] tda = tds.toArray(new TestResultDescr[0]);
107 int res = conflictResolver.resolve(url, tda);
108108 if (res < 0) {
109109 // cancel
110110 return false;
4444 import java.awt.event.MouseEvent;
4545 import java.beans.PropertyChangeEvent;
4646 import java.beans.PropertyChangeListener;
47 import java.util.ArrayList;
48 import java.util.Collection;
49 import java.util.HashMap;
50 import java.util.HashSet;
51 import java.util.Iterator;
52 import java.util.List;
47 import java.util.*;
5348
5449 import javax.swing.BorderFactory;
5550 import javax.swing.DefaultListModel;
9994 }
10095
10196 CustomReport[] getCustomSelected() {
102 return (CustomReport[])getActiveCustomReports().
103 toArray(new CustomReport[0]);
97 return getActiveCustomReports().toArray(new CustomReport[0]);
10498 }
10599 protected void initGUI() {
106100 setName("opts");
146140 BorderFactory.createEmptyBorder(12,12,12,12)));
147141
148142
149 listModel = new DefaultListModel();
143 listModel = new DefaultListModel<>();
150144
151145 // populate list and card panel
152146 final CardLayout cards = new CardLayout();
181175
182176
183177 if (customBoxes != null && list != null) {
184 CustomReport val = (CustomReport)(customBoxes.get(list.getSelectedValue()));
178 CustomReport val = customBoxes.get(list.getSelectedValue());
185179 if (val != null)
186180 descriptionArea.setText(val.getDescription());
187181 }
246240 private int getCustomReports(JPanel p) {
247241 int result = 0;
248242 Tool[] tools = desktop.getTools();
249 List customReportsList = new ArrayList();
243 List<CustomReport> customReportsList = new ArrayList<>();
250244 for (int i = 0; i < tools.length; i++) {
251245 if (tools[i] instanceof ExecTool) {
252246 // should not be using report types from ExecTool
266260 }
267261 } // for
268262
269 customReports = (CustomReport[]) customReportsList
263 customReports = customReportsList
270264 .toArray(new CustomReport[0]);
271265 if (customReports == null || customReports.length == 0) {
272266 customReports = null;
273267 return 0;
274268 }
275269
276 customBoxes = new HashMap();
270 customBoxes = new HashMap<>();
277271
278272 for (int i = 0; i < customReports.length; i++) {
279273 JCheckBox cb = new JCheckBox(customReports[i].getName());
300294 return result;
301295 }
302296
303 private ArrayList getActiveCustomReports() {
304
305 ArrayList customReps = new ArrayList();
297 private ArrayList<CustomReport> getActiveCustomReports() {
298
299 ArrayList<CustomReport> customReps = new ArrayList<>();
306300 if (customBoxes != null && customBoxes.size() > 0) {
307 Iterator it = customBoxes.keySet().iterator();
301 Iterator<JCheckBox> it = customBoxes.keySet().iterator();
308302 while (it.hasNext()) {
309 JCheckBox box = (JCheckBox)(it.next());
303 JCheckBox box = it.next();
310304 if (box.isSelected()) {
311305 customReps.add(customBoxes.get(box));
312306 }
327321 * @param p parent Panel
328322 * @param cardLayout The CardLayout for options
329323 */
330 SelectListener(JList lst, JPanel p, CardLayout cardLayout) {
324 SelectListener(JList<JCheckBox> lst, JPanel p, CardLayout cardLayout) {
331325 list = lst;
332326 listModel = list.getModel();
333327 lastSelected = listModel.getElementAt(0);
349343
350344 public void valueChanged(ListSelectionEvent e) {
351345 int index = list.getSelectedIndex();
352 JCheckBox box = (JCheckBox) (listModel.getElementAt(index));
346 JCheckBox box = (listModel.getElementAt(index));
353347
354348 if (lastSelected != box) {
355349 cards.show(panel, box.getName());
370364 }
371365
372366 if (customBoxes != null) {
373 CustomReport rep = (CustomReport) customBoxes.get(box);
367 CustomReport rep = customBoxes.get(box);
374368 if(rep != null) {
375369 if (rep.getOptionPanes() != null) {
376370 for (int i = 0; i < rep.getOptionPanes().length; i++) {
384378 }
385379
386380 private void process(final int index) {
387 JCheckBox box = (JCheckBox) (listModel.getElementAt(index));
381 JCheckBox box = (listModel.getElementAt(index));
388382
389383 if (lastSelected == box) {
390384 box.doClick();
401395 }
402396
403397 Object lastSelected;
404 JList list;
405 ListModel listModel;
398 JList<JCheckBox> list;
399 ListModel<JCheckBox> listModel;
406400 JPanel panel;
407401 CardLayout cards;
408402 double emptyCBW = new JCheckBox("").getPreferredSize().getWidth() + 2;
429423 boolean newV = ((Boolean) evt.getNewValue()).booleanValue();
430424 if (oldV && !newV) {
431425 // disable
432 Iterator chIt = collectChildren(theContainer,
433 new ArrayList()).iterator();
434 enabledComp = new HashSet();
426 Iterator<Component> chIt = collectChildren(theContainer,
427 new ArrayList<Component>()).iterator();
428 enabledComp = new HashSet<>();
435429 while (chIt.hasNext()) {
436 Component c = (Component) chIt.next();
430 Component c = chIt.next();
437431 if (c.isEnabled()) {
438432 enabledComp.add(c);
439433 c.setEnabled(false);
442436
443437 } else if (!oldV && newV && enabledComp != null) {
444438 // enable
445 Iterator chIt = collectChildren(theContainer,
446 new ArrayList()).iterator();
439 Iterator<Component> chIt = collectChildren(theContainer,
440 new ArrayList<Component>()).iterator();
447441 while (chIt.hasNext()) {
448 Component c = (Component) chIt.next();
442 Component c = chIt.next();
449443 if (enabledComp.contains(c)) {
450444 c.setEnabled(true);
451445 }
457451 /**
458452 * Recursively gathers all children components
459453 */
460 private Collection collectChildren(Container comp, Collection c) {
454 private Collection<Component> collectChildren(Container comp, Collection<Component> c) {
461455 Component[] ch = comp.getComponents();
462456 for (int i = 0; i < ch.length; i++) {
463457 c.add(ch[i]);
470464
471465 private Container theContainer;
472466
473 private HashSet enabledComp;
474 }
475
476 private class CheckBoxListCellRenderer implements ListCellRenderer {
477 public Component getListCellRendererComponent(JList list, Object value,
467 private Set<Component> enabledComp;
468 }
469
470 private class CheckBoxListCellRenderer implements ListCellRenderer<JCheckBox> {
471 public Component getListCellRendererComponent(JList<? extends JCheckBox> list, JCheckBox comp,
478472 int index, boolean isSelected, boolean cellHasFocus) {
479473 // assert: value is a JCheckBox
480 JComponent comp = (JComponent) value;
481474 if (isSelected) {
482475 comp.setOpaque(true);
483476 comp.setBackground(UIFactory.Colors.TEXT_HIGHLIGHT_COLOR.getValue());
494487 return new JButton[] { backBtn, okBtn, cancelBtn, helpBtn };
495488 }
496489
497 private DefaultListModel listModel;
498 private JList list;
490 private DefaultListModel<JCheckBox> listModel;
491 private JList<JCheckBox> list;
499492 private CustomReport[] customReports;
500493 private JTextArea descriptionArea;
501 private HashMap customBoxes;
494 private Map<JCheckBox, CustomReport> customBoxes;
502495 private JCheckBox cbXml;
503496 private JButton backBtn;
504497 private JButton okBtn;
5050 // be safely loaded, before the JFileChooser starts running its background
5151 // thread, exposing a JVM bug in class loading.
5252 static {
53 Class reportClass = Report.class;
53 Class<?> reportClass = Report.class;
5454 }
5555
5656 /**
9494 }
9595
9696 @Override
97 protected void restore(Map map) {
98 }
99
100 protected void save(Map m) {
97 protected void restore(Map<String, String> map) {
98 }
99
100 protected void save(Map<String, String> m) {
101101 }
102102
103103 private void initGUI(){
6262 return new Action[] { a };
6363 }
6464
65 public Tool restoreTool(Map m) {
65 public Tool restoreTool(Map<String, String> m) {
6666 ReportTool t = getTool();
6767 t.restore(m);
6868 return t;
6262 private static final String JAXP_SCHEMA_SOURCE =
6363 "http://java.sun.com/xml/jaxp/properties/schemaSource";
6464
65 Map readIDs(File file) throws SAXException, IOException, ParserConfigurationException {
65 Map<Object, Object> readIDs(File file) throws SAXException, IOException, ParserConfigurationException {
6666 XMLReader reader = XMLReportReader.createXMLReader(true);
6767 IDHandler handler = new IDHandler();
6868 reader.setContentHandler(handler);
106106
107107
108108 private static class IDHandler extends DefaultHandler {
109 private Map map = new HashMap();
109 private Map<Object, Object> map = new HashMap<>();
110110
111111 private long time = 0;
112112
124124 map.put(id, id);
125125 }
126126 if (qualifiedName.equals(Scheme.REPORT)) {
127 String dateStr = (String) attributes
127 String dateStr = attributes
128128 .getValue(Scheme.REPORT_GENTIME);
129129 try {
130130 time = XMLReportWriter.ISO8601toDate(dateStr).getTime();
134134 }
135135 }
136136
137 public Map getMap() {
137 public Map<Object, Object> getMap() {
138138 return map;
139139 }
140140 }
123123 ser.startElement("", "", Scheme.REPORT, atts);
124124 }
125125
126 public void write(File[] file, Map[] map) throws SAXException,
126 public void write(File[] file, Map<?, ?>[] map) throws SAXException,
127127 ParserConfigurationException, IOException {
128128 try {
129129 ser.startDocument();
170170
171171 // id -> new_id mapping
172172 // url -> new_TestDescr mapping
173 private Map map;
174
175 public CopyHandler(ContentHandler ser, boolean isWorkDir, Map map) {
173 private Map<?, ?> map;
174
175 public CopyHandler(ContentHandler ser, boolean isWorkDir, Map<?, ?> map) {
176176 this.ser = ser;
177177 if (ser instanceof LexicalHandler) {
178178 lh = (LexicalHandler) ser;
192192 AttributesImpl newAttrs = new AttributesImpl();
193193 for (int i = 0; i < attrs.getLength(); i++) {
194194 if (attrs.getQName(i).equals(Scheme.WD_ID)) {
195 String id = String.valueOf((Integer) map.get(Integer
195 String id = String.valueOf(map.get(Integer
196196 .valueOf(attrs.getValue(i))));
197197 newAttrs.addAttribute(attrs.getURI(i), attrs
198198 .getLocalName(i), attrs.getQName(i), attrs
+0
-102
src/com/sun/javatest/report/COFReport.java less more
0 /*
1 * $Id$
2 *
3 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26 package com.sun.javatest.report;
27
28 import com.sun.javatest.cof.COFData;
29 import com.sun.javatest.cof.Main;
30 import com.sun.javatest.cof.Main.Fault;
31 import com.sun.javatest.util.I18NResourceBundle;
32 import java.io.File;
33 import java.io.IOException;
34 import java.util.Collections;
35 import java.util.List;
36 import java.util.logging.Level;
37 import java.util.logging.Logger;
38
39 public class COFReport implements ReportFormat {
40
41 @Override
42 public ReportLink write(ReportSettings s, File dir) throws IOException {
43 COFData data = new COFData();
44 data.setInterviewParameters(s.getInterview());
45
46 File outputFile = new File(dir.getAbsolutePath() + File.separator + FNAME);
47
48 if (!s.isCOFTestCasesEnabled()) {
49 Main.setGenerateTestCases(s.isCOFTestCasesEnabled());
50 }
51
52 Main cofMain = new Main();
53 cofMain.setInterviewParameters(s.getInterview());
54 try {
55 com.sun.javatest.cof.Report report = cofMain.fillReport(data);
56 cofMain.writeReport(report, outputFile);
57 } catch (Fault ex) {
58 Logger.getLogger(COFReport.class.getName()).log(Level.SEVERE, null, ex);
59 }
60
61 String warning = data.get("warning");
62 if (warning != null) {
63 // System.out.println(warning);
64 }
65
66 return new ReportLink(i18n.getString("index.coftype.txt"),
67 getBaseDirName(), i18n.getString("index.desc.cof"), outputFile);
68 }
69
70 @Override
71 public String getReportID() {
72 return ID;
73 }
74
75 @Override
76 public String getBaseDirName() {
77 return ID;
78 }
79
80 @Override
81 public boolean acceptSettings(ReportSettings s) {
82 return s.isCOFEnabled();
83 }
84
85 @Override
86 public List<ReportFormat> getSubReports() {
87 return Collections.<ReportFormat>emptyList();
88 }
89
90 @Override
91 public String getTypeName() {
92 return ID;
93 }
94
95 private final String FNAME = "cof.xml";
96
97 private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(COFReport.class);
98
99 private static final String ID = "cof";
100
101 }
2828 import java.io.File;
2929 import java.io.IOException;
3030 import java.text.NumberFormat;
31 import java.util.Comparator;
32 import java.util.Iterator;
33 import java.util.SortedSet;
34 import java.util.TreeSet;
31 import java.util.*;
3532
3633 import com.sun.interview.WizPrint;
3734 import com.sun.javatest.ExcludeList;
382379 out.endTag(HTMLWriterEx.H2);
383380 }
384381
385 SortedSet envTable = new TreeSet(new StringArrayComparator());
386
387 for (Iterator i = env.elements().iterator(); i.hasNext(); ) {
388 TestEnvironment.Element envElem = (TestEnvironment.Element) (i.next());
382 Set<String[]> envTable = new TreeSet<>(new StringArrayComparator());
383
384 for (Iterator<TestEnvironment.Element> i = env.elements().iterator(); i.hasNext(); ) {
385 TestEnvironment.Element envElem = (i.next());
389386 String[] envTableRow = {envElem.getKey(), envElem.getValue()};
390387 envTable.add(envTableRow);
391388 }
392389
393390 out.startTag(HTMLWriterEx.TABLE);
394391 out.writeAttr(HTMLWriterEx.BORDER, 1);
395 for (Iterator i = envTable.iterator(); i.hasNext(); ) {
396 String[] envEntry = (String[]) (i.next());
392 for (Iterator<String[]> i = envTable.iterator(); i.hasNext(); ) {
393 String[] envEntry = (i.next());
397394 out.startTag(HTMLWriterEx.TR);
398395
399396 for (int j = 0; j < envEntry.length; j++ ) {
418415 out.writeI18N("config.excl.none");
419416 }
420417 else {
421 SortedSet sortedEntries = new TreeSet(new ExcludeListEntryComparator());
422 for (Iterator iter = excludeList.getIterator(false); iter.hasNext(); )
423 sortedEntries.add(iter.next());
418 SortedSet<ExcludeList.Entry> sortedEntries = new TreeSet<>(new ExcludeListEntryComparator());
419 for (Iterator<?> iter = excludeList.getIterator(false); iter.hasNext(); )
420 sortedEntries.add((ExcludeList.Entry)iter.next());
424421
425422 out.startTag(HTMLWriterEx.TABLE);
426423 out.writeAttr(HTMLWriterEx.BORDER, 1);
442439 out.endTag(HTMLWriterEx.TH);
443440 out.endTag(HTMLWriterEx.TR);
444441
445 for (Iterator iter = sortedEntries.iterator(); iter.hasNext(); ) {
446 ExcludeList.Entry e = (ExcludeList.Entry) (iter.next());
442 for (Iterator<ExcludeList.Entry> iter = sortedEntries.iterator(); iter.hasNext(); ) {
443 ExcludeList.Entry e = (iter.next());
447444 out.startTag(HTMLWriterEx.TR);
448445 writeTD(out, e.getRelativeURL());
449446 writeTD(out, e.getTestCases());
478475 out.endTag(HTMLWriterEx.TD);
479476 }
480477
481 private static class ExcludeListEntryComparator implements Comparator
478 private static class ExcludeListEntryComparator implements Comparator<ExcludeList.Entry>
482479 {
483 public int compare(Object o1, Object o2) {
484 ExcludeList.Entry e1 = (ExcludeList.Entry) o1;
485 ExcludeList.Entry e2 = (ExcludeList.Entry) o2;
480 public int compare(ExcludeList.Entry e1, ExcludeList.Entry e2) {
486481 int x = compare(e1.getRelativeURL(), e2.getRelativeURL());
487482 if (x == 0)
488483 x = compare(e1.getTestCases(), e2.getTestCases());
7878 } else {
7979 // make it!
8080 env.tmpXmlReportFile = File.createTempFile("jtrep", "tmp");
81 FileOutputStream fos = new FileOutputStream(env.tmpXmlReportFile);
82 try {
83 Writer fw = new BufferedWriter(new OutputStreamWriter(fos, XMLReportMaker.XML_CHARSET));
81 try (FileOutputStream fos = new FileOutputStream(env.tmpXmlReportFile);
82 Writer fw = new BufferedWriter(new OutputStreamWriter(fos, XMLReportMaker.XML_CHARSET))) {
8483 XMLReport xr = new XMLReport();
8584 xr.write(fw, env);
86 fw.close();
87 }
88 finally {
89 if (fos != null){
90 try { fos.close(); } catch (IOException e) { }
91 }
9285 }
9386 xmlSrc = env.tmpXmlReportFile;
9487 }
132132 if (customReports == null || customReports.length == 0) {
133133 return NO_REPORTS;
134134 }
135 return (List<CustomReport>) Arrays.asList(customReports);
135 return Arrays.asList(customReports);
136136 }
137137
138138
139139 private CustomReport theCustomReport;
140 private ArrayList<ReportFormat> subreports = new ArrayList<ReportFormat>();
141 private static final List<CustomReport> NO_REPORTS = (List<CustomReport>) Collections.EMPTY_LIST;
140 private ArrayList<ReportFormat> subreports = new ArrayList<>();
141 private static final List<CustomReport> NO_REPORTS = Collections.emptyList();
142142
143143
144144 }
2626 package com.sun.javatest.report;
2727
2828 import com.sun.javatest.Status;
29 import com.sun.javatest.TestResult;
2930 import com.sun.javatest.util.I18NResourceBundle;
3031 import java.io.BufferedWriter;
3132 import java.io.File;
5152 setResults(s.getSortedResults());
5253
5354
54 ArrayList mainSecs = new ArrayList(3);
55 ArrayList auxSecs = new ArrayList(3);
55 List<HTMLSection> mainSecs = new ArrayList<>(3);
56 List<HTMLSection> auxSecs = new ArrayList<>(3);
5657
5758 // optional section
5859 ConfigSection cs = new ConfigSection(this, s, dir, i18n);
240241 return new BufferedWriter(osw);
241242 }
242243
243 public void setResults(TreeSet[] results) {
244 public void setResults(TreeSet<TestResult>[] results) {
244245 this.results = results;
245246 }
246247
247 TreeSet[] getResults() {
248 TreeSet<TestResult>[] getResults() {
248249 return results;
249250 }
250251
297298
298299 private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(HTMLReport.class);
299300
300 private TreeSet[] results;
301 private TreeSet<TestResult>[] results;
301302 private KflSorter kflSorter;
302303
303304 // The name of the root file for a set of report files.
3131 import java.io.*;
3232 import java.nio.charset.StandardCharsets;
3333 import java.util.HashSet;
34 import java.util.Set;
35 import java.util.SortedSet;
3436 import java.util.TreeSet;
3537
3638
6567 }
6668 }
6769
68 private void writeTestSet(String f, String id, TreeSet<KflSorter.TestDiff> tests) {
70 private void writeTestSet(String f, String id, SortedSet<KflSorter.TestDiff> tests) {
6971 // add file validation
7072 try {
7173 Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, f)), StandardCharsets.UTF_8));
115117 return;
116118 }
117119
118 HashSet<String> hs = new HashSet();
120 Set<String> hs = new HashSet<>();
119121
120122 for (int i = 0; i < e.length; i++) {
121123 String[] bugs = e[i].getBugIdStrings();
147149 writer.write("\n");
148150 }
149151
150 private void writeTestCaseSet(String f, String id, TreeSet<KflSorter.TestDiff> tests) {
152 private void writeTestCaseSet(String f, String id, SortedSet<KflSorter.TestDiff> tests) {
151153 writeTestSet(f, id, tests);
152154 }
153155
2828 import java.io.*;
2929 import java.nio.charset.StandardCharsets;
3030 import java.util.HashSet;
31 import java.util.Set;
3132 import java.util.SortedSet;
3233
3334 import com.sun.javatest.KnownFailuresList;
365366 }
366367
367368 String urlPrefix = Preferences.access().getPreference(ReportManager.BUGRPT_URL_PREF, null);
368 HashSet<String> hs = new HashSet();
369 Set<String> hs = new HashSet<>();
369370
370371 for (int i = 0; i < e.length; i++) {
371372 String[] bugs = e[i].getBugIdStrings();
3333 import java.io.BufferedReader;
3434 import java.io.IOException;
3535 import java.io.StringReader;
36 import java.util.Iterator;
37 import java.util.LinkedHashMap;
38 import java.util.Map;
39 import java.util.TreeSet;
36 import java.util.*;
4037 import java.util.regex.Matcher;
4138 import java.util.regex.Pattern;
4239
6764 KflSorter(KnownFailuresList kfl, TestResultTable trt, boolean testcases) {
6865 this.kfl = kfl;
6966 this.trt = trt;
70 missing = new TreeSet();
71 newFailures = new TreeSet();
72 otherErrors = new TreeSet();
73 fail2notrun = new TreeSet();
74 fail2error = new TreeSet();
75 fail2pass = new TreeSet();
76 fail2fail = new TreeSet();
77
78 tc_missing = new TreeSet();
79 tc_fail2pass = new TreeSet();
80 tc_fail2error = new TreeSet();
81 tc_fail2notrun = new TreeSet();
82 tc_newFailures = new TreeSet();
67 missing = new TreeSet<>();
68 newFailures = new TreeSet<>();
69 otherErrors = new TreeSet<>();
70 fail2notrun = new TreeSet<>();
71 fail2error = new TreeSet<>();
72 fail2pass = new TreeSet<>();
73 fail2fail = new TreeSet<>();
74
75 tc_missing = new TreeSet<>();
76 tc_fail2pass = new TreeSet<>();
77 tc_fail2error = new TreeSet<>();
78 tc_fail2notrun = new TreeSet<>();
79 tc_newFailures = new TreeSet<>();
8380
8481 enableTestCases = testcases;
8582 }
113110 * @return Number of comparison errors encountered.
114111 */
115112 synchronized int run(TestResultTable.TreeIterator iter) {
116 TreeSet[] lists = new TreeSet[Status.NUM_STATES];
113 TreeSet<TestResult>[] lists = new TreeSet[Status.NUM_STATES];
117114 int totalFound = 0;
118115
119116 for (; iter.hasNext();) {
120 TestResult tr = (TestResult) (iter.next());
117 TestResult tr = iter.next();
121118 Status s = tr.getStatus();
122 TreeSet list = lists[s == null ? Status.NOT_RUN : s.getType()];
119 TreeSet<TestResult> list = lists[s == null ? Status.NOT_RUN : s.getType()];
123120 list.add(tr);
124121 totalFound++;
125122 }
134131 * @param tests
135132 * @return Number of comparison problems encountered.
136133 */
137 synchronized int run(TreeSet[] tests) {
134 synchronized int run(TreeSet<?>[] tests) {
138135 Iterator<KnownFailuresList.Entry> it = kfl.getIterator(false);
139136 int probs = 0;
140137 int tcprobs = 0;
405402 */
406403 private int addAllTestCases(final KnownFailuresList.Entry entry,
407404 final String url, final TestResult tr,
408 Transitions t, TreeSet set) {
405 Transitions t, Set<TestDiff> set) {
409406 // could check enableTestCases flag before processing
410407 // add all test cases from this entry
411408 int problems = 0;
424421
425422 private int addListedTestCases(final KnownFailuresList.Entry entry,
426423 final String url, final TestResult tr,
427 Transitions t, TreeSet set) {
424 Transitions t, TreeSet<?> set) {
428425 int problems = 0;
429426
430427 String[] tcs = entry.getTestCaseList();
484481 */
485482 private int addStatusTestCases(
486483 final String url, final TestResult tr, int status,
487 Transitions t, Map<String, Status> trtcs, TreeSet set) {
484 Transitions t, Map<String, Status> trtcs, Set<TestDiff> set) {
488485 // could check enableTestCases flag before processing
489486 int problems = 0;
490487
534531 return false;
535532 }
536533
537 synchronized TreeSet<TestDiff> getSet(Transitions id) {
534 synchronized SortedSet<TestDiff> getSet(Transitions id) {
538535 switch (id) {
539536 case FAIL2PASS: return fail2pass;
540537 case FAIL2MISSING: return missing;
563560
564561
565562 private static Map<String, Status> getTestCases(final TestResult tr) {
566 Map result = new LinkedHashMap();
563 Map<String, Status> result = new LinkedHashMap<>();
567564
568565 if (tr.isShrunk() && tr.isReloadable())
569566 tr.getSectionTitles();
621618 * based on the KFL. Using this class allows the analysis to be done once
622619 * then queried again and again for different purposes.
623620 */
624 public static class TestDiff implements Comparable {
621 public static class TestDiff implements Comparable<TestDiff> {
625622 public TestDiff(String url, TestResult tr, Transitions type) {
626623 this.tr = tr;
627624 this.url = url;
702699 }
703700
704701 @Override
705 public int compareTo(Object o) {
706 TestDiff e = (TestDiff) o;
702 public int compareTo(TestDiff e) {
707703 int n = getName().compareTo(e.getName());
708704 /* if (n == 0) {
709705 if (testCase == null && e.testCase == null)
734730 // public void passToFail(TestResult tr);
735731 // public void failToPass(TestResult tr);
736732 // }
737 protected TreeSet<TestDiff> fail2pass;
738 protected TreeSet<TestDiff> fail2error;
739 protected TreeSet<TestDiff> fail2notrun;
740 protected TreeSet<TestDiff> missing;
741 protected TreeSet<TestDiff> newFailures;
742 protected TreeSet<TestDiff> otherErrors;
743 protected TreeSet<TestDiff> fail2fail;
744
745 protected TreeSet<TestDiff> tc_missing;
746 protected TreeSet<TestDiff> tc_fail2pass;
747 protected TreeSet<TestDiff> tc_fail2error;
748 protected TreeSet<TestDiff> tc_fail2notrun;
749 protected TreeSet<TestDiff> tc_newFailures;
733 protected SortedSet<TestDiff> fail2pass;
734 protected SortedSet<TestDiff> fail2error;
735 protected SortedSet<TestDiff> fail2notrun;
736 protected SortedSet<TestDiff> missing;
737 protected SortedSet<TestDiff> newFailures;
738 protected SortedSet<TestDiff> otherErrors;
739 protected SortedSet<TestDiff> fail2fail;
740
741 protected SortedSet<TestDiff> tc_missing;
742 protected SortedSet<TestDiff> tc_fail2pass;
743 protected SortedSet<TestDiff> tc_fail2error;
744 protected SortedSet<TestDiff> tc_fail2notrun;
745 protected SortedSet<TestDiff> tc_newFailures;
750746
751747 protected KnownFailuresList kfl;
752748 //protected TestCaseList tcl;
5555
5656 File[] initFiles = s.getInitialFiles();
5757
58 SortedSet tests = new TreeSet(new TestResultsByFileComparator());
58 SortedSet<TestResult> tests = new TreeSet<>(new TestResultsByFileComparator());
5959 int width = 0;
6060
61 Iterator iter = null;
61 Iterator<TestResult> iter = null;
6262 try {
6363 if (initFiles == null) {
6464 iter = resultTable.getIterator(new TestFilter[] {s.filter});
7272 } // catch
7373
7474 for (; iter.hasNext(); ) {
75 TestResult tr = (TestResult) (iter.next());
75 TestResult tr = iter.next();
7676 // build a list of TestResults, sorted by test name
7777 width = Math.max(width, tr.getTestName().length());
7878 tests.add(tr);
8080
8181 TextWriter out = new TextWriter(openWriter(dir, files[SMRY_TXT]));
8282 for (iter = tests.iterator(); iter.hasNext(); ) {
83 TestResult tr = (TestResult) (iter.next());
83 TestResult tr = iter.next();
8484 String u = tr.getTestName();
8585 out.print(u);
8686 for (int sp = u.length(); sp < width; sp++)
350350 this.index = index;
351351 }
352352
353 public Vector getLinks() {
354 Vector links = new Vector();
353 public Vector<String> getLinks() {
354 Vector<String> links = new Vector<>();
355355 StringBuilder content = new StringBuilder();
356 BufferedReader r = null;
357 try {
358 r = new BufferedReader(new InputStreamReader(new FileInputStream(index), StandardCharsets.UTF_8));
356 try (BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(index), StandardCharsets.UTF_8))) {
359357 String line;
360358 while( (line = r.readLine()) != null ) {
361359 content.append(line);
362360 content.append("\n");
363361 }
364362 } catch (IOException e) {}
365 finally {
366 try { if (r != null) r.close(); } catch (IOException e) {}
367 }
368363
369364 int i = 0;
370365 while (i < (content.length() - 1) ) {
412407 */
413408 private void updateIndexLinks(File index, int backupNumb) {
414409 StringBuilder sb = new StringBuilder();
415 BufferedReader r = null;
416 try {
417 r = new BufferedReader(new InputStreamReader(new FileInputStream(index), StandardCharsets.UTF_8));
410 try (BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(index), StandardCharsets.UTF_8))) {
418411 String line;
419412 while( (line = r.readLine()) != null ) {
420413 sb.append(line);
421414 sb.append("\n");
422415 }
423416 } catch (IOException e) {}
424 finally {
425 try { if (r != null) r.close(); } catch (IOException e) {}
426 }
427417
428418 String oldId = backupNumb == 1 ? "" : "~" + (backupNumb - 1) + "~";
429419 String newId = "~" + backupNumb + "~";
430420
431421 File reportDir = index.getParentFile();
432422 File[] files = reportDir.listFiles();
433 ArrayList subdirs = new ArrayList();
423 List<File> subdirs = new ArrayList<>();
434424 for(int i = 0; i < files.length; i ++) {
435425 if(files[i].isDirectory() &&
436426 files[i].getName().lastIndexOf(newId) != -1) {
439429 }
440430
441431 LinkFinder finder = new LinkFinder(index);
442 Vector links = finder.getLinks();
432 Vector<String> links = finder.getLinks();
443433 for(int i = 0; i < links.size(); i++) {
444 String link = (String)links.get(i);
434 String link = links.get(i);
445435 for(int j = 0; j < subdirs.size(); j++) {
446 String newName = ((File)subdirs.get(j)).getName();
436 String newName = subdirs.get(j).getName();
447437 String oldName = newName.replaceAll(newId, oldId);
448438 if(link.lastIndexOf(oldName) != -1) {
449439 StringBuilder newLink = new StringBuilder(link);
456446 }
457447 }
458448
459 Writer writer = null;
460 try {
461 writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(index), StandardCharsets.UTF_8));
449 try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(index), StandardCharsets.UTF_8))) {
462450 writer.write(sb.toString());
463451 writer.flush();
464 writer.close();
465452 }
466453 catch (IOException ex) {}
467 finally {
468 try { if (writer != null) writer.close(); } catch (IOException e) {}
469 }
470454 }
471455
472456
500484 }
501485
502486 private void fillIndexFile(File index, ReportSettings s, List<ReportLink> links) {
503 Writer writer = null;
504 try {
505 writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(index), StandardCharsets.UTF_8));
487 try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(index), StandardCharsets.UTF_8))) {
506488 HTMLWriterEx out = new HTMLWriterEx(writer);
507489 out.setI18NResourceBundle(i18n);
508490
541523
542524 } catch (IOException e) {
543525 //return;
544 }
545 finally {
546 try { if (writer != null) writer.close(); } catch (IOException e) {}
547526 }
548527 }
549528
597576 private void notifyStartGenListeners(ReportSettings s, String reportID) {
598577 if(startGenListeners != null) {
599578 for(int i = 0; i < startGenListeners.size(); i ++) {
600 StartGenListener sgl = (StartGenListener)startGenListeners.get(i);
579 StartGenListener sgl = startGenListeners.get(i);
601580 sgl.startReportGeneration(s, reportID);
602581 }
603582 }
624603
625604 public void addStartGenListener(StartGenListener l) {
626605 if(startGenListeners == null) {
627 startGenListeners = new ArrayList();
606 startGenListeners = new ArrayList<>();
628607 }
629608
630609 startGenListeners.add(l);
648627 public static final String MARKER_FILE_NAME = "reportdir.dat";
649628 public static final String INDEX_FILE_NAME = "index.html";
650629
651 private ArrayList startGenListeners;
630 private List<StartGenListener> startGenListeners;
652631 }
6262 return new HelpTree.Node(i18n, "rm.help." + name);
6363 }
6464
65 public boolean parseCommand(String cmd, ListIterator argIter, CommandContext ctx)
65 public boolean parseCommand(String cmd, ListIterator<String> argIter, CommandContext ctx)
6666 throws Command.Fault
6767 {
6868 if (isMatch(cmd, ReportCommand.getName())) {
100100 return "report";
101101 }
102102
103 ReportCommand(ListIterator argIter) throws Fault {
103 ReportCommand(ListIterator<String> argIter) throws Fault {
104104 super(getName());
105105
106106 if (!argIter.hasNext())
124124 return "writeReport";
125125 }
126126
127 WriteReportCommand(Iterator argIter) throws Fault {
127 WriteReportCommand(Iterator<String> argIter) throws Fault {
128128 super(getName());
129129
130130 while (argIter.hasNext()) {
447447 *
448448 * @return Map for data exchange
449449 */
450 public Map getExchangeData() {
450 public Map<?, ?> getExchangeData() {
451451 if (exchangeData == null) {
452 exchangeData = new HashMap();
452 exchangeData = new HashMap<>();
453453 }
454454 return exchangeData;
455455 }
462462 File[] initFiles = getInitialFiles();
463463 sortedResults = new TreeSet[Status.NUM_STATES];
464464 for (int i = 0; i < sortedResults.length; i++) {
465 sortedResults[i] = new TreeSet(new TestResultsByNameComparator());
466 }
467 Iterator iter;
465 sortedResults[i] = new TreeSet<>(new TestResultsByNameComparator());
466 }
467 Iterator<TestResult> iter;
468468 try {
469469 TestFilter[] fs = null;
470470 // Note: settings.filter should not really be null, modernized clients
479479 throw new JavaTestError(ReportSettings.i18n.getString("result.testResult.err"));
480480 }
481481 for (; iter.hasNext();) {
482 TestResult tr = (TestResult) (iter.next());
482 TestResult tr = (iter.next());
483483 Status s = tr.getStatus();
484 TreeSet list = sortedResults[s == null ? Status.NOT_RUN : s.getType()];
484 TreeSet<TestResult> list = sortedResults[s == null ? Status.NOT_RUN : s.getType()];
485485 list.add(tr);
486486 }
487487 }
488488
489 private static class TestResultsByNameComparator implements Comparator {
489 private static class TestResultsByNameComparator implements Comparator<TestResult> {
490490
491491 @Override
492 public int compare(Object o1, Object o2) {
493 TestResult tr1 = (TestResult) o1;
494 TestResult tr2 = (TestResult) o2;
492 public int compare(TestResult tr1, TestResult tr2) {
495493 return tr1.getTestName().compareTo(tr2.getTestName());
496494 }
497495 }
514512 return kflSorter;
515513 }
516514
517 TreeSet[] getSortedResults() {
515 TreeSet<TestResult>[] getSortedResults() {
518516 return sortedResults;
519517 }
520518
526524 return customReports;
527525 }
528526
529 private TreeSet[] sortedResults;
527 private TreeSet<TestResult>[] sortedResults;
530528 private KflSorter kflSorter;
531529 File xmlReportFile = null;
532530 File tmpXmlReportFile = null;
533531 private File[] mif = new File[0];
534 private HashMap exchangeData;
532 private HashMap<?, ?> exchangeData;
535533 private InterviewParameters ip;
536534
537535 private List<CustomReport> customReports = Collections.emptyList();
4242 */
4343 class ResultSection extends HTMLSection {
4444 ResultSection(HTMLReport parent, ReportSettings settings, File dir, I18NResourceBundle i18n,
45 TreeSet[] sortedResults) {
45 TreeSet<TestResult>[] sortedResults) {
4646 super(i18n.getString("result.title"), settings, dir, parent);
4747 this.i18n = i18n;
4848
5757 initFiles = settings.getInitialFiles();
5858 lists = sortedResults;
5959
60 for (TreeSet s: sortedResults)
60 for (TreeSet<TestResult> s: sortedResults)
6161 totalFound += s.size();
6262 /*
6363 lists = new TreeSet[Status.NUM_STATES];
115115
116116 for (int i = 0; i < lists.length; i++ ) {
117117 String reportFile = HTMLReport.files[fileCodes[i]];
118 TreeSet l = lists[i];
118 TreeSet<TestResult> l = lists[i];
119119
120120 int n = l.size();
121121 if (n > 0) {
186186
187187 if (hasGroupedReport(i)) {
188188 // re-sort it
189 TreeSet newS = new TreeSet(new TestResultsByStatusAndTitleComparator());
189 TreeSet<TestResult> newS = new TreeSet<>(new TestResultsByStatusAndTitleComparator());
190190 newS.addAll(lists[i]);
191191 lists[i] = newS;
192192
199199
200200 ReportWriter out = openAuxFile(fileCodes[i], headings[i], i18n);
201201 try {
202 TreeSet list = lists[i];
202 TreeSet<TestResult> list = lists[i];
203203 if (list.size() > 0) {
204204 boolean inList = false;
205205
206 for (Iterator iter = list.iterator(); iter.hasNext(); ) {
207 TestResult e = (TestResult) (iter.next());
206 for (Iterator<TestResult> iter = list.iterator(); iter.hasNext(); ) {
207 TestResult e = (iter.next());
208208 String title;
209209 try {
210210 TestDescription e_td = e.getDescription();
246246 ReportWriter out = openAuxFile(groupedFileCodes[i], headings[i], i18n);
247247 out.write(i18n.getString("result.groupByStatus"));
248248 try {
249 TreeSet list = lists[i];
249 TreeSet<TestResult> list = lists[i];
250250 if (list.size() > 0) {
251251 boolean inList = false;
252252 String currentHead = null;
253 for (Iterator iter = list.iterator(); iter.hasNext(); ) {
254 TestResult e = (TestResult) (iter.next());
253 for (Iterator<TestResult> iter = list.iterator(); iter.hasNext(); ) {
254 TestResult e = (iter.next());
255255 String title;
256256 try {
257257 TestDescription e_td = e.getDescription();
307307 private TestResultTable resultTable;
308308 private File[] initFiles;
309309
310 TreeSet[] lists;
310 TreeSet<TestResult>[] lists;
311311 private int totalFound;
312312
313313 private final int[] fileCodes = {
5656 initFiles = settings.getInitialFiles();
5757
5858 resultTable = settings.getInterview().getWorkDirectory().getTestResultTable();
59 Iterator iter = null;
59 Iterator<TestResult> iter = null;
6060 try {
6161 iter = (initFiles == null) ?
6262 resultTable.getIterator(new TestFilter[] {settings.filter}) :
6868 } // catch
6969
7070 for (; iter.hasNext(); ) {
71 TestResult tr = (TestResult) (iter.next());
71 TestResult tr = iter.next();
7272
7373 try {
7474 Status s = tr.getStatus();
7878 Arrays.sort(keys);
7979 String sortedKeys = StringArray.join(keys);
8080
81 int[] v = (int[])(keywordTable.get(sortedKeys));
81 int[] v = keywordTable.get(sortedKeys);
8282 if (v == null) {
8383 v = new int[Status.NUM_STATES];
8484 keywordTable.put(sortedKeys, v);
140140 head[c] = i18n.getString("stats.total");
141141 }
142142
143 Vector v = new Vector();
144 for (Iterator iter = keywordTable.entrySet().iterator(); iter.hasNext(); ) {
145 Map.Entry e = (Map.Entry) (iter.next());
146 String k = (String) (e.getKey());
147 int[] kv = (int[]) (e.getValue());
143 Vector<String[]> v = new Vector<>();
144 for (Iterator<Map.Entry<String, int[]>> iter = keywordTable.entrySet().iterator(); iter.hasNext(); ) {
145 Map.Entry<String, int[]> e = (iter.next());
146 String k = (e.getKey());
147 int[] kv = (e.getValue());
148148 String[] newEntry = new String[ncols];
149149 int c = 0, total = 0;
150150 newEntry[c++] = k;
158158 sortedInsert:
159159 {
160160 for (int i = 0; i < v.size(); i++) {
161 String[] entry = (String[])v.elementAt(i);
161 String[] entry = v.elementAt(i);
162162 if (k.compareTo(entry[0]) < 0) {
163163 v.insertElementAt(newEntry, i);
164164 break sortedInsert;
229229
230230 private TestResultTable resultTable;
231231 private File[] initFiles;
232 private Map keywordTable = new HashMap();
232 private Map<String, int[]> keywordTable = new HashMap<>();
233233 private int[] statusTotals = new int[Status.NUM_STATES];
234234 private final I18NResourceBundle i18n;
235235
2727
2828 import java.util.Comparator;
2929
30 class StringArrayComparator implements Comparator {
31 public int compare(Object o1, Object o2) {
32 String[] a = (String[])o1;
33 String[] b = (String[])o2;
30 class StringArrayComparator implements Comparator<String[]> {
31 public int compare(String[] a, String[] b) {
3432 for (int i = 0; i < Math.min(a.length, b.length); i++) {
3533 int c = compare(a[i], b[i]);
3634 if (c != 0)
3030 import com.sun.javatest.TestDescription;
3131 import com.sun.javatest.TestResult;
3232
33 class TestResultsByFileComparator implements Comparator {
34 public int compare(Object o1, Object o2) {
35 TestResult a = (TestResult)o1;
36 TestResult b = (TestResult)o2;
33 class TestResultsByFileComparator implements Comparator<TestResult> {
34 public int compare(TestResult a, TestResult b) {
3735
3836 // The simplest way to compare two URLs would be to compare their
3937 // external forms, but generating them generates garbage at a
3030 import com.sun.javatest.Status;
3131 import com.sun.javatest.TestResult;
3232
33 class TestResultsByStatusAndTitleComparator implements Comparator {
34 public int compare(Object o1, Object o2) {
35 TestResult tr1 = (TestResult)o1;
36 TestResult tr2 = (TestResult)o2;
33 class TestResultsByStatusAndTitleComparator implements Comparator<TestResult> {
34 public int compare(TestResult tr1, TestResult tr2) {
3735 Status s1 = tr1.getStatus();
3836 Status s2 = tr2.getStatus();
3937 if (s1.getType() != s2.getType())
2929
3030 import com.sun.javatest.TestResult;
3131
32 class TestResultsByTitleComparator implements Comparator {
33 public int compare(Object o1, Object o2) {
34 TestResult tr1 = (TestResult)o1;
35 TestResult tr2 = (TestResult)o2;
32 class TestResultsByTitleComparator implements Comparator<TestResult> {
33 public int compare(TestResult tr1, TestResult tr2) {
3634
3735 return compare(tr1.getTestName(), tr2.getTestName());
3836 }
143143 maker.sTestResults();
144144
145145 File[] initFiles = sett.getInitialFiles();
146 Iterator iter = null;
146 Iterator<TestResult> iter = null;
147147 TestResultTable resultTable = sett.getInterview().getWorkDirectory().getTestResultTable();
148148
149149 try {
153153 iter = resultTable.getIterator(initFiles, new TestFilter[] {sett.getTestFilter()});
154154 }
155155 for (; iter.hasNext(); ) {
156 TestResult tr = (TestResult) (iter.next());
156 TestResult tr = (iter.next());
157157 writeResult(maker, tr);
158158 }
159159 maker.eTestResults();
202202 String time = testResult.getProperty(TestResult.END);
203203
204204 maker.sResultProps(time);
205 Enumeration en = testResult.getPropertyNames();
205 Enumeration<String> en = testResult.getPropertyNames();
206206 while (en.hasMoreElements()) {
207 String key = (String) en.nextElement();
208 String val = (String) testResult.getProperty(key);
207 String key = en.nextElement();
208 String val = testResult.getProperty(key);
209209 if (!TestResult.END.equals(key)) {
210210 maker.makeProperty(key, val);
211211 }
215215
216216 private void writeEnvironment(final XMLReportMaker maker, final TestResult testResult) throws SAXException {
217217
218 Iterator keysIt;
218 Iterator<String> keysIt;
219219 try {
220 Map m = testResult.getEnvironment();
220 Map<String, String> m = testResult.getEnvironment();
221221 keysIt = m.keySet().iterator();
222222 maker.sTestEnvironment();
223223 while (keysIt.hasNext()) {
224 String key = (String) keysIt.next();
225 String val = (String) m.get(key);
224 String key = keysIt.next();
225 String val = m.get(key);
226226 maker.makeProperty(key, val);
227227 }
228228 maker.eTestEnvironment();
235235 maker.sDescriptionData();
236236
237237 TestDescription td = testResult.getDescription();
238 Iterator keysIt = td.getParameterKeys();
238 Iterator<String> keysIt = td.getParameterKeys();
239239
240240 maker.makeProperty("$root", td.getRootDir());
241241 maker.makeProperty("$file", td.getFile().getPath());
242242
243243 while (keysIt.hasNext()) {
244 String key = (String) keysIt.next();
244 String key = keysIt.next();
245245 // dump keywords separately
246246 if (!"keywords".equals(key)) {
247 String val = (String) td.getParameter(key);
247 String val = td.getParameter(key);
248248 maker.makeProperty(key, val);
249249 }
250250 }
295295 maker.sEnvironment(name, descr);
296296 TestEnvironment env = sett.getInterview().getEnv();
297297 if (env != null) {
298 for (Iterator i = env.elements().iterator(); i.hasNext(); ) {
299 TestEnvironment.Element envElem = (TestEnvironment.Element) (i.next());
298 for (Iterator<TestEnvironment.Element> i = env.elements().iterator(); i.hasNext(); ) {
299 TestEnvironment.Element envElem = (i.next());
300300 maker.makeProperty(envElem.getKey(), envElem.getValue());
301301 }
302302 }
9191 throw new MalformedParamsException
9292 ("Path to ANT binary doesn't specified", p);
9393 }
94 List<String> command = new LinkedList();
94 List<String> command = new LinkedList<>();
9595 command.add(antBin);
9696
9797 String workDir = p.remove(ANT_WORKDIR);
100100 params.setWorkDirectory(new File(workDir));
101101 }
102102
103 Map<String, String> env = new TreeMap();
103 Map<String, String> env = new TreeMap<>();
104104 for (String name : p.keySet()) {
105105 if (name.startsWith(ANT_ENV)) {
106106 env.put(name.substring(ANT_ENV.length()), p.remove(name));
198198 }
199199
200200 public Set<TestPath> readTestServiceMap() {
201 Set<TestPath> result = new HashSet();
201 Set<TestPath> result = new HashSet<>();
202202
203203 if (props == null) {
204204 return result;
196196 * values are {@link com.sun.javatest.services.Service} objects.
197197 */
198198 public Map<String, Service> getAllServices() {
199 return new HashMap(services);
199 return new HashMap<>(services);
200200 }
201201
202202 /**
205205 * @return IDs for currently used services.
206206 */
207207 public Set<String> getActiveServices() {
208 return new TreeSet(activeServices);
208 return new TreeSet<>(activeServices);
209209 }
210210
211211 public void startService(String sID) {
287287
288288 public void startingTestRun(Parameters params) {
289289 if (mode == StartMode.UP_FRONT) {
290 Set<String> active = new TreeSet();
290 Set<String> active = new TreeSet<>();
291291 try {
292 Iterator iter = harness.getTestsIterator(null);
292 Iterator<TestResult> iter = harness.getTestsIterator(null);
293293 active = selectActiveServices(iter);
294294 } catch (Harness.Fault f) {
295295 commonLog.log(Level.SEVERE, f.getMessage());
366366 this.mode = mode;
367367 }
368368
369 private Set<String> selectActiveServices(Iterator iter) {
370 Set<String> active = new TreeSet();
371 Set<TestPath> copy = new HashSet(testServiceMap);
369 private Set<String> selectActiveServices(Iterator<TestResult> iter) {
370 Set<String> active = new TreeSet<>();
371 Set<TestPath> copy = new HashSet<>(testServiceMap);
372372 TestResult tr;
373373 TestDescription td;
374374 while (!copy.isEmpty() && active.size() < services.size() &&
375 (tr = (TestResult)iter.next()) != null ) {
375 (tr = iter.next()) != null ) {
376376 try {
377377 td = tr.getDescription();
378 HashSet<TestPath> toRemove = new HashSet();
378 HashSet<TestPath> toRemove = new HashSet<>();
379379 for (TestPath p : copy) {
380380 if (p.matches(td)) {
381381 for (String sId : p.getServices()) {
391391 }
392392
393393 private synchronized void stopServices() {
394 Set<String> toRemove = new TreeSet();
394 Set<String> toRemove = new TreeSet<>();
395395 for (String s : activeServices) {
396396 if (stopService0(s)) {
397397 toRemove.add(s);
408408 }
409409
410410 private class WritingThread extends Thread {
411 private Map<String, Writer> outs = new HashMap();
412 private Map<String, Writer> errs = new HashMap();
413
414 private Map<String, InputStreamReader> sOuts = new HashMap();
415 private Map<String, InputStreamReader> sErrs = new HashMap();
411 private Map<String, Writer> outs = new HashMap<>();
412 private Map<String, Writer> errs = new HashMap<>();
413
414 private Map<String, InputStreamReader> sOuts = new HashMap<>();
415 private Map<String, InputStreamReader> sErrs = new HashMap<>();
416416
417417 public WritingThread() {
418418 setDaemon(true);
473473
474474 public synchronized void setOutputWriter(String sID, Writer out) {
475475 if (outs == null) {
476 outs = new HashMap();
476 outs = new HashMap<>();
477477 }
478478 outs.put(sID, out);
479479 }
480480
481481 public synchronized void setErrorWriter(String sID, Writer err) {
482482 if (errs == null) {
483 errs = new HashMap();
483 errs = new HashMap<>();
484484 }
485485 errs.put(sID, err);
486486 }
518518
519519 char[] buf = new char[1000];
520520
521 List<String> toRemove = new LinkedList();
521 List<String> toRemove = new LinkedList<>();
522522
523523 String[] idCopy;
524524 synchronized (this) {
559559
560560 private class WatchDog extends Thread {
561561 private boolean stop;
562 private Set<Observer> observers = new HashSet();
562 private Set<Observer> observers = new HashSet<>();
563563 private int pause;
564564 private Set<String> active;
565565 private Object sync;
664664 }
665665
666666 @Override
667 public boolean parseCommand(String cmd, ListIterator argIter, CommandContext ctx) throws Command.Fault {
667 public boolean parseCommand(String cmd, ListIterator<String> argIter, CommandContext ctx) throws Command.Fault {
668668 if (isMatch(cmd, ServiceStartCommand.getName())) {
669669 if (!argIter.hasNext()) {
670670 return false;
671671 }
672 String val = (String)argIter.next();
672 String val = argIter.next();
673673 for (StartMode m : StartMode.values()) {
674674 if (m.getKey().equalsIgnoreCase(val)) {
675675 mode = m;
4141
4242 private Properties externalProps;
4343
44 private HashMap<String, String> lastResolution;
44 private Map<String, String> lastResolution;
4545
4646 private Map<String, Set<String>> varMap;
4747
5858 this.common = common;
5959
6060 externalProps = new Properties();
61 varMap = new HashMap();
62 varProps = new HashMap();
63 constProps = new HashMap();
61 varMap = new HashMap<>();
62 varProps = new HashMap<>();
63 constProps = new HashMap<>();
6464 }
6565
6666 /**
153153 */
154154 public Map<String, String> resolveProperties() {
155155 if (lastResolution != null) {
156 return (Map)lastResolution.clone();
157 }
158
159 HashMap<String, String> result = new HashMap();
156 return new HashMap<>(lastResolution);
157 }
158
159 Map<String, String> result = new HashMap<>();
160160 result.putAll(constProps);
161161
162 Map<String, String> justResolved = new HashMap();
162 Map<String, String> justResolved = new HashMap<>();
163163 justResolved.putAll(constProps);
164164
165165 if (common != null) {
176176 result.putAll(justResolved);
177177 }
178178
179 lastResolution = new HashMap(result);
179 lastResolution = new HashMap<>(result);
180180
181181 return result;
182182 }
184184 private Map<String, String> resolveVars(Map<String, ParametrizeValue> varProps,
185185 Map<String, String> resolved) {
186186
187 Map<String, String> result = new HashMap();
187 Map<String, String> result = new HashMap<>();
188188
189189 for (String key : resolved.keySet()) {
190190 if (varMap.containsKey(key)) {
205205 }
206206
207207 private Map<String, ParametrizeValue> copyVarProps() {
208 Map<String, ParametrizeValue> copy = new HashMap();
208 Map<String, ParametrizeValue> copy = new HashMap<>();
209209 for (String key : varProps.keySet()) {
210210 copy.put(key, varProps.get(key).copy());
211211 }
222222 value = new ParametrizeValue();
223223 Term t = new Term();
224224 t.setValue(key, true);
225 List<Term> l = new LinkedList();
225 List<Term> l = new LinkedList<>();
226226 l.add(t);
227227 value.setValue(l);
228228 }
251251 varMap.get(paramName).add(key);
252252 }
253253 else {
254 HashSet<String> usages = new HashSet();
254 Set<String> usages = new HashSet<>();
255255 usages.add(key);
256256 varMap.put(paramName, usages);
257257 }
262262 varMap.get(key).add(key);
263263 }
264264 else {
265 HashSet<String> usages = new HashSet();
265 Set<String> usages = new HashSet<>();
266266 usages.add(key);
267267 varMap.put(key, usages);
268268 }
303303 private int varNumb;
304304
305305 public ParametrizeValue() {
306 terms = new LinkedList();
306 terms = new LinkedList<>();
307307 varNumb = 0;
308308 }
309309
139139 }
140140
141141 public Set<TestPath> readTestServiceMap() {
142 Set<TestPath> result = new HashSet();
142 Set<TestPath> result = new HashSet<>();
143143
144144 if (doc == null) {
145145 return result;
217217 }
218218
219219 private Map<String, Service> readServices(Document doc, ServiceProperties common) {
220 Map<String, Service> result = new TreeMap();
220 Map<String, Service> result = new TreeMap<>();
221221
222222 if (doc == null) {
223223 return result;
227227 Node child = root.getFirstChild();
228228 while (child != null) {
229229 if(child instanceof Element &&
230 ((Element)child).getNodeName().equals("service")) {
230 child.getNodeName().equals("service")) {
231231 try {
232232 Element elem = (Element) child;
233233
8181 out.println("Exclude list is empty.");
8282 else {
8383 out.println("<table border=1>");
84 for (Iterator iter = excludeList.getIterator(false); iter.hasNext(); ) {
84 for (Iterator<?> iter = excludeList.getIterator(false); iter.hasNext(); ) {
8585 ExcludeList.Entry entry = (ExcludeList.Entry) (iter.next());
8686 String[] bugIds = entry.getBugIdStrings();
8787 StringBuffer bugIdText = new StringBuffer();
116116 try {
117117 TestDescription td = tr.getDescription();
118118 out.println("<table>");
119 for (Iterator iter = td.getParameterKeys(); iter.hasNext(); ) {
120 String key = (String) (iter.next());
119 for (Iterator<String> iter = td.getParameterKeys(); iter.hasNext(); ) {
120 String key = (iter.next());
121121 String value = td.getParameter(key);
122122 if (key.equals("$root") || key.equals("$file") || key.equals("testsuite") || key.equals("file"))
123123 out.println("<tr><td align=top>" + key + "<td><a href=\"" + value + "\">" + filter(value, false) + "</a>");
150150 out.println("<h2><a name=tr>Test Result properties</a></h2>");
151151 try {
152152 out.println("<table>");
153 for (Enumeration e = tr.getPropertyNames(); e.hasMoreElements(); ) {
154 String key = (String)(e.nextElement());
153 for (Enumeration<String> e = tr.getPropertyNames(); e.hasMoreElements(); ) {
154 String key = (e.nextElement());
155155 out.println("<tr><td>" + key + "<td>" + filter(tr.getProperty(key), true));
156156 }
157157 }
166166 // test environment
167167 out.println("<h2><a name=env>Test Environment</a></h2>");
168168 try {
169 Map env = tr.getEnvironment();
169 Map<String, String> env = tr.getEnvironment();
170170 if (env.size() == 0) {
171171 out.println("<tr><td>No environment details found");
172172 }
173173 else {
174174 out.println("<table>");
175 for (Iterator i = env.entrySet().iterator(); i.hasNext(); ) {
176 Map.Entry e = (Map.Entry) (i.next());
177 String key = (String) (e.getKey());
178 String value = (String) (e.getValue());
175 for (Iterator<Map.Entry<String, String>> i = env.entrySet().iterator(); i.hasNext(); ) {
176 Map.Entry<String, String> e = (i.next());
177 String key = (e.getKey());
178 String value = (e.getValue());
179179 out.println("<tr><td>" + key + "<td>" + filter(value, true));
180180 }
181181 out.println("</table>");
116116 return i18n.getString("colorprefs.name");
117117 }
118118
119 public void save(Map m) {
119 public void save(Map<String, String> m) {
120120 super.save(m);
121121 Component[] components = inputColors.getComponents();
122122 for(Component c: components) {
101101 * The name will be saved as the first entry as the argument array.
102102 */
103103 protected Command(String name) {
104 args = new Vector();
104 args = new Vector<>();
105105 args.add(name);
106106 }
107107
118118 * @param argIter the iterator from which to get the next argument
119119 * @return the next argument from the iterator
120120 */
121 protected String nextArg(Iterator argIter) {
122 String s = (String) argIter.next();
121 protected String nextArg(Iterator<String> argIter) {
122 String s = argIter.next();
123123 addArg(s);
124124 return s;
125125 }
129129 * entry from the argument array.
130130 * @param argIter the iterator from which teh argument was obtained
131131 */
132 protected void putbackArg(ListIterator argIter) {
132 protected void putbackArg(ListIterator<String> argIter) {
133133 argIter.previous();
134134 args.remove(args.size() - 1);
135135 }
156156 for (int i = 0; i < args.size(); i++) {
157157 if (sb.length() > 0)
158158 sb.append(' ');
159 String arg = (String) (args.elementAt(i));
159 String arg = args.elementAt(i);
160160 boolean hasSpace = (arg.indexOf(' ') != -1);
161161 boolean hasQuote = (arg.indexOf('"') != -1);
162162 boolean hasEscape = (arg.indexOf('\\') != -1);
279279 }
280280 }
281281
282 private Vector args;
282 private Vector<String> args;
283283 }
3333 import java.io.IOException;
3434 import java.io.PrintWriter;
3535 import java.util.HashMap;
36 import java.util.Properties;
3736 import java.util.Vector;
3837
3938 import com.sun.javatest.Harness;
4342 import com.sun.javatest.TestSuite;
4443 import com.sun.javatest.WorkDirectory;
4544
46 import com.sun.javatest.util.DynamicArray;
47 import com.sun.javatest.util.HelpTree;
48 import com.sun.javatest.util.I18NResourceBundle;
45 import com.sun.javatest.util.*;
46
4947 import java.util.Map;
5048
5149 /**
163161 boolean foundAction = false;
164162
165163 for (int i = 0; i < commands.size(); i++) {
166 Command cmd = (Command) (commands.elementAt(i));
164 Command cmd = commands.elementAt(i);
167165 foundAction |= cmd.isActionCommand();
168166
169167 // can't cache this ... may change while we execute commands
195193 * @see #getHarnessObservers
196194 */
197195 public void addHarnessObserver(Harness.Observer o) {
198 harnessObservers = (Harness.Observer[]) (DynamicArray.append(harnessObservers, o));
196 harnessObservers = DynamicArray.append(harnessObservers, o);
199197 }
200198
201199 /**
530528 /**
531529 * restore filter setting if -ts -preferred were specified
532530 */
533 void setDesktopData(Map desktopData) {
531 void setDesktopData(Map<String, String> desktopData) {
534532 this.desktopData = desktopData;
535533 }
536534
537 Map getDesktopData() {
535 Map<String, String> getDesktopData() {
538536 return desktopData;
539537 }
540538
607605 || WorkDirectory.isEmptyDirectory(workDirectoryPath))) {
608606
609607 // first, determine where the test suite is
610 Properties configData;
608 Map<String, String> configData;
611609 File tsPath;
612610
613611 // get test suite path if we don't have it
615613 if (configFilePath == null)
616614 throw new Fault(i18n, "cc.noTestSuite");
617615
618 configData = new Properties();
619616
620617 try {
621 InputStream in = new BufferedInputStream(new FileInputStream(configFilePath));
622 try {
623 configData.load(in);
618 try (InputStream in = new BufferedInputStream(new FileInputStream(configFilePath))) {
619 configData = Properties.load(in);
624620 }
625621 catch (RuntimeException e) {
626622 // can get IllegalArgumentException if the file is corrupt
627623 throw new Fault(i18n, "cc.cantReadConfig", new Object[] { configFilePath, e });
628 }
629 finally {
630 in.close();
631624 }
632625 }
633626 catch (FileNotFoundException e) {
638631 new Object[] { configFilePath, e });
639632 }
640633
641 String tsp = (String) (configData.get("TESTSUITE"));
634 String tsp = configData.get("TESTSUITE");
642635 if (tsp == null)
643636 throw new Fault(i18n, "cc.noTestSuiteInConfigFile", configFilePath);
644637
793786 public boolean isDesktopRequired() {
794787 int mode = Command.DEFAULT_DTMODE;
795788 for (int i = 0; i < commands.size(); i++) {
796 Command cmd = (Command) (commands.elementAt(i));
789 Command cmd = commands.elementAt(i);
797790 mode = Math.max(mode, cmd.getDesktopMode());
798791 }
799792 return (mode == Command.DESKTOP_NOT_REQUIRED_DTMODE ? false : true);
905898 if (verboseQuiet)
906899 return false;
907900
908 Boolean b = (Boolean) (verboseOptionValues.get(name.toLowerCase()));
901 Boolean b = verboseOptionValues.get(name.toLowerCase());
909902 return (b == null ? defaultValue : b.booleanValue());
910903 }
911904
10541047 //-------------------------------------------------------------------------
10551048
10561049
1057 private Vector commands = new Vector();
1050 private Vector<Command> commands = new Vector<>();
10581051
10591052 //private TestSuite testSuite;
10601053 //private WorkDirectory workDir;
10611054 private File testSuitePath;
10621055 private File workDirectoryPath;
10631056 private String defaultWorkDirPath;
1064 private Map desktopData;
1057 private Map<String, String> desktopData;
10651058 private boolean autoCreateWorkDirectory;
10661059 private File configFilePath;
10671060
10731066 private PrintWriter out;
10741067 private int[] cumulativeTestStats = new int[Status.NUM_STATES];
10751068
1076 private HashMap verboseOptionValues = new HashMap(); // HashMap<String, Boolean>
1069 private Map<String, Boolean> verboseOptionValues = new HashMap<>();
10771070 private boolean verboseMax;
10781071 private boolean verboseQuiet;
10791072 private boolean verboseDate = true;
5656 * @throws Command.Fault if the command is recognized by this command manager
5757 * but could not be successfully parsed or otherwise handled.
5858 */
59 public abstract boolean parseCommand(String cmd, ListIterator argIter, CommandContext ctx)
59 public abstract boolean parseCommand(String cmd, ListIterator<String> argIter, CommandContext ctx)
6060 throws Command.Fault;
6161
6262 /**
126126 }
127127
128128 // scan args, converting them to commands
129 for (ListIterator iter = getIterator(trim(args)); iter.hasNext(); ) {
130 String arg = (String) (iter.next());
129 for (ListIterator<String> iter = getIterator(trim(args)); iter.hasNext(); ) {
130 String arg = iter.next();
131131 decodeArg(arg, iter, ctx);
132132 }
133133 }
134134
135 private void decodeArg(String arg, ListIterator argIter, CommandContext ctx)
135 private void decodeArg(String arg, ListIterator<String> argIter, CommandContext ctx)
136136 throws CommandParser.Fault
137137 {
138138 // special case for Windows-like help option
151151 String cmd = arg.substring(1);
152152 if (cmd.equals("read")) {
153153 if (argIter.hasNext()) {
154 String arg2 = ((String) (argIter.next()));
154 String arg2 = argIter.next();
155155 // consider supporting URLs here
156156 File f = new File(arg2);
157157 read(f, ctx);
246246
247247 nextLine:
248248 while ((line = p.readLine()) != null) {
249 ListIterator iter = getIterator(line);
250 String cmd = ((String) (iter.next()));
249 ListIterator<String> iter = getIterator(line);
250 String cmd = iter.next();
251251
252252 if (cmd.equals("read")) {
253253 if (iter.hasNext()) {
254 String arg = ((String) (iter.next()));
254 String arg = iter.next();
255255 // consider supporting URLs here
256256 File f = new File(arg);
257257 if (!f.isAbsolute())
293293 return trimArgs;
294294 }
295295
296 private static ListIterator getIterator(final String[] args) {
297 return (new ListIterator() {
298 public void add(Object o) {
296 private static ListIterator<String> getIterator(final String[] args) {
297 return (new ListIterator<String>() {
298 public void add(String o) {
299299 throw new UnsupportedOperationException();
300300 }
301301
307307 return (index > 0);
308308 }
309309
310 public Object next() {
310 public String next() {
311311 return (index < args.length ? args[index++] : null);
312312 }
313313
315315 return index;
316316 }
317317
318 public Object previous() {
318 public String previous() {
319319 return (index > 0 ? args[--index] : null);
320320 }
321321
327327 throw new UnsupportedOperationException();
328328 }
329329
330 public void set(Object obj) {
330 public void set(String obj) {
331331 throw new UnsupportedOperationException();
332332 }
333333
9292 }
9393
9494 HelpTree.Node getHelp(I18NResourceBundle i18n, String prefix, Object[] childData) {
95 Vector v = new Vector();
95 Vector<HelpTree.Node> v = new Vector<>();
9696 for (int i = 0; i < childData.length; i++) {
9797 Object data = childData[i];
9898 if (data instanceof HelpTree.Node)
99 v.add(data);
99 v.add((HelpTree.Node)data);
100100 else if (data instanceof String)
101101 v.add(new HelpTree.Node(i18n, prefix + "." + data));
102102 else if (data instanceof String[]) {
112112 return new HelpTree.Node(i18n, prefix, childNodes);
113113 }
114114
115 public boolean parseCommand(String cmd, ListIterator argIter, CommandContext ctx)
115 public boolean parseCommand(String cmd, ListIterator<String> argIter, CommandContext ctx)
116116 throws Command.Fault
117117 {
118118 if (isMatch(cmd, ConcurrencyCommand.getName())) {
210210 return new OpenCommand(file);
211211 }
212212
213 private static Map commandFactory;
214213 private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(ConfigManager.class);
215214
216215 //--------------------------------------------------------------------------
221220 return "concurrency";
222221 }
223222
224 ConcurrencyCommand(ListIterator argIter) throws Fault {
223 ConcurrencyCommand(ListIterator<String> argIter) throws Fault {
225224 super(getName());
226225
227226 if (!argIter.hasNext())
270269 return "config";
271270 }
272271
273 ConfigCommand(ListIterator argIter) throws Fault {
272 ConfigCommand(ListIterator<String> argIter) throws Fault {
274273 super(getName());
275274
276275 if (!argIter.hasNext())
335334 return "writeConfig";
336335 }
337336
338 WriteConfigCommand(ListIterator argIter) throws Fault {
337 WriteConfigCommand(ListIterator<String> argIter) throws Fault {
339338 super(getName());
340339
341340 if (!argIter.hasNext())
380379 return "env";
381380 }
382381
383 EnvCommand(ListIterator argIter) throws Fault {
382 EnvCommand(ListIterator<String> argIter) throws Fault {
384383 super(getName());
385384
386385 if (!argIter.hasNext())
411410 return new String[] { "envfile", "envfiles" };
412411 }
413412
414 EnvFilesCommand(ListIterator argIter) throws Fault {
413 EnvFilesCommand(ListIterator<String> argIter) throws Fault {
415414 super(getNames()[0]);
416415
417 Vector v = new Vector();
416 Vector<File> v = new Vector<>();
418417
419418 while (argIter.hasNext()) {
420419 String arg = nextArg(argIter);
455454 return "excludeList";
456455 }
457456
458 ExcludeListCommand(ListIterator argIter) throws Fault {
457 ExcludeListCommand(ListIterator<String> argIter) throws Fault {
459458 super(getName());
460459
461460 // in time, we should support -none, -default, -latest etc
462 Vector v = new Vector();
461 Vector<File> v = new Vector<>();
463462
464463 while (argIter.hasNext()) {
465464 String arg = nextArg(argIter);
500499 return "kfl";
501500 }
502501
503 KflCommand(ListIterator argIter) throws Fault {
502 KflCommand(ListIterator<String> argIter) throws Fault {
504503 super(getName());
505504
506505 // in time, we should support -none, -default, -latest etc
507 Vector v = new Vector();
506 Vector<File> v = new Vector<>();
508507
509508 while (argIter.hasNext()) {
510509 String arg = nextArg(argIter);
551550 cmdForFile = getCommandForFile(file);
552551 }
553552
554 OpenCommand(ListIterator argIter) throws Fault {
553 OpenCommand(ListIterator<String> argIter) throws Fault {
555554 super(getName());
556555
557556 if (!argIter.hasNext())
606605 return "keywords";
607606 }
608607
609 KeywordsCommand(ListIterator argIter) throws Fault {
608 KeywordsCommand(ListIterator<String> argIter) throws Fault {
610609 super(getName());
611610
612611 // could support -all -any
735734 return new HelpTree.Node(i18n, "cnfg.params", opts);
736735 }
737736
738 ParamsCommand(ListIterator argIter) throws Fault {
737 ParamsCommand(ListIterator<String> argIter) throws Fault {
739738 super(getName());
740739
741 Vector v = new Vector();
740 Vector<String> v = new Vector<>();
742741 while (argIter.hasNext())
743742 v.add(nextArg(argIter));
744743 String[] args = new String[v.size()];
769768 return "priorStatus";
770769 }
771770
772 PriorStatusCommand(ListIterator argIter) throws Fault {
771 PriorStatusCommand(ListIterator<String> argIter) throws Fault {
773772 super(getName());
774773
775774 if (!argIter.hasNext())
820819 if (s == null)
821820 return null;
822821
823 Vector v = new Vector();
822 Vector<String> v = new Vector<>();
824823 int start = -1;
825824 for (int i = 0; i < s.length(); i++) {
826825 if (Character.isLetterOrDigit(s.charAt(i))) {
854853 return "set";
855854 }
856855
857 SetCommand(ListIterator argIter) throws Fault {
856 SetCommand(ListIterator<String> argIter) throws Fault {
858857 super(getName());
859858
860859 if (!argIter.hasNext())
878877 InterviewParameters p = getConfig(ctx);
879878 Question[] path = p.getPath();
880879 if (file != null) {
881 Map values = loadFile(file);
880 Map<String, String> values = loadFile(file);
882881 for (int i = 0; i < path.length; i++) {
883882 Question q = path[i];
884 String v = (String) (values.get(q.getTag()));
883 String v = (values.get(q.getTag()));
885884 if (v != null) {
886885 setValue(q, v);
887886 path = p.getPath();
966965 return (sb.toString());
967966 }
968967
969 private Map loadFile(File file) throws Fault {
970 FileInputStream fis = null;
971 InputStream in = null;
972 try {
973 fis = new FileInputStream(file);
974 in = new BufferedInputStream(fis);
975 Properties props = new Properties();
976 props.load(in);
977 in.close();
978 return props;
968 private Map<String, String> loadFile(File file) throws Fault {
969 try (FileInputStream fis = new FileInputStream(file);
970 InputStream in = new BufferedInputStream(fis)) {
971 return com.sun.javatest.util.Properties.load(in);
979972 }
980973 catch (FileNotFoundException e) {
981974 throw new Fault(i18n, "cnfg.set.cantFindFile", file);
983976 catch (IOException e) {
984977 throw new Fault(i18n, "cnfg.set.cantReadFile",
985978 new Object[] { file, e.getMessage() });
986 }
987 finally {
988 if (in != null){
989 try { in.close(); } catch (IOException e) { }
990 }
991
992 if (fis != null){
993 try { fis.close(); } catch (IOException e) { }
994 }
995979 }
996980 }
997981
1011995 return "setX";
1012996 }
1013997
1014 SetXCommand(ListIterator argIter) throws Fault {
998 SetXCommand(ListIterator<String> argIter) throws Fault {
1015999 super(getName());
10161000
10171001 if (!argIter.hasNext())
10341018 public void run(CommandContext ctx) throws Fault {
10351019 InterviewParameters p = getConfig(ctx);
10361020 if (file != null) {
1037 Map values = loadFile(file);
1038 Set keys = values.keySet();
1039 Iterator it = keys.iterator();
1021 Map<String, String> values = loadFile(file);
1022 Set<String> keys = values.keySet();
1023 Iterator<String> it = keys.iterator();
10401024 String name = null;
10411025 for (int i = 0; it.hasNext(); i++) {
1042 name = (String)(it.next());
1026 name = it.next();
10431027 /* could do it this way to reject unknown props
10441028 String v = p.retrieveProperty(name);
10451029 if (v != null) {
10461030 p.storeProperty(name, (String)(values.get(name)));
10471031 }
10481032 */
1049 p.storeProperty(name, (String)(values.get(name)));
1033 p.storeProperty(name, (values.get(name)));
10501034 }
10511035 }
10521036 else {
10541038 }
10551039 }
10561040
1057 private Map loadFile(File file) throws Fault {
1058 FileInputStream fis = null;
1059 try {
1060 fis = new FileInputStream(file);
1061 InputStream in = new BufferedInputStream(fis);
1062 Properties props = new Properties();
1063 props.load(in);
1064 in.close();
1065 return props;
1041 private Map<String, String> loadFile(File file) throws Fault {
1042 try (FileInputStream fis = new FileInputStream(file);
1043 InputStream in = new BufferedInputStream(fis)) {
1044 return com.sun.javatest.util.Properties.load(in);
10661045 }
10671046 catch (FileNotFoundException e) {
10681047 throw new Fault(i18n, "cnfg.set.cantFindFile", file);
10711050 throw new Fault(i18n, "cnfg.set.cantReadFile",
10721051 new Object[] { file, e.getMessage() });
10731052 }
1074 finally {
1075 if (fis != null){
1076 try { fis.close(); } catch (IOException e) { }
1077 }
1078 }
10791053 }
10801054
10811055 private File file;
10911065 return "tests";
10921066 }
10931067
1094 TestsCommand(ListIterator argIter) throws Fault {
1068 TestsCommand(ListIterator<String> argIter) throws Fault {
10951069 super(getName());
10961070
1097 Vector v = new Vector();
1071 Vector<String> v = new Vector<>();
10981072
10991073 while (argIter.hasNext()) {
11001074 // could possibly support @file or similar syntax here for a list of tests
11371111 return new String[] { "testsuite", "ts" };
11381112 }
11391113
1140 TestSuiteCommand(ListIterator argIter) throws Fault {
1114 TestSuiteCommand(ListIterator<String> argIter) throws Fault {
11411115 super(getNames()[0]);
11421116
11431117 while (argIter.hasNext()) {
12781252 // seem to be another good place in the current architecture.
12791253 // although perhaps it would be good to defer this processing to a
12801254 // little later in the command processing?
1281 Properties p = Desktop.getPreviousDesktop(null);
1282 String s = p.getProperty("tool.count");
1255 Map<String, String> p = Desktop.getPreviousDesktop(null);
1256 String s = p.get("tool.count");
12831257 if (s != null) {
12841258 int count = Integer.parseInt(s);
12851259 for (int i = 0; i < count; i++) {
1286 s = p.getProperty("tool." + i + ".class");
1260 s = p.get("tool." + i + ".class");
12871261 if ("com.sun.javatest.exec.ExecTool".equals(s)) {
1288 s = p.getProperty("tool." + i + ".testSuite");
1262 s = p.get("tool." + i + ".testSuite");
12891263
12901264 // this tool instance does not have a test suite
12911265 if (s == null)
13091283 }
13101284
13111285 if (s1.equals(s2)) {
1312 s = p.getProperty("tool." + i + ".workDir");
1286 s = p.get("tool." + i + ".workDir");
13131287 if (s != null &&
13141288 WorkDirectory.isUsableWorkDirectory(
13151289 new File(s))) {
13191293 // we found WD,
13201294 // try to restore filter now
13211295
1322 s = p.getProperty("tool." + i + ".filter");
1323 Map data = collectSpecificData("tool." + i + ".", p);
1296 s = p.get("tool." + i + ".filter");
1297 Map<String, String> data = collectSpecificData("tool." + i + ".", p);
13241298
13251299 if (s != null) {
13261300 ctx.setDesktopData(data);
13471321 private File path;
13481322 private boolean preferFlag;
13491323
1350 private Map collectSpecificData(String prefix, Properties p) {
1351 Set<Entry<Object, Object>> s = p.entrySet();
1352 Iterator<Entry<Object, Object>> it = s.iterator();
1353 HashMap res = new HashMap();
1324 private Map<String, String> collectSpecificData(String prefix, Map<String, String> p) {
1325 Set<Entry<String, String>> s = p.entrySet();
1326 Iterator<Entry<String, String>> it = s.iterator();
1327 Map<String, String> res = new HashMap<>();
13541328 while (it.hasNext()) {
1355 Entry en = it.next();
1329 Entry<String, String> en = it.next();
13561330 if (en.getKey().toString().startsWith(prefix)) {
1357 String key = (String) en.getKey();
1331 String key = en.getKey();
13581332 key = key.substring(prefix.length());
13591333 if ("-workDir-config-class-mgr-".contains(key)) {
13601334 //if ("-class-mgr-".contains(key)) {
13751349 return "timeoutfactor";
13761350 }
13771351
1378 TimeoutFactorCommand(ListIterator argIter) throws Fault {
1352 TimeoutFactorCommand(ListIterator<String> argIter) throws Fault {
13791353 super(getName());
13801354
13811355 if (!argIter.hasNext())
14231397 return new String[] { "workdirectory", "workdir", "wd" };
14241398 }
14251399
1426 WorkDirectoryCommand(ListIterator argIter) throws Fault {
1400 WorkDirectoryCommand(ListIterator<String> argIter) throws Fault {
14271401 super(getNames()[0]);
14281402
14291403 while (argIter.hasNext()) {
2828 import com.sun.javatest.InterviewParameters;
2929 import com.sun.javatest.InterviewPropagator;
3030
31 import java.util.Map;
3132 import java.util.Properties;
3233
3334 /**
4142 * @param interview - current InterviewParameters.
4243 * @param templateData - loaded actual template's values. Can be null
4344 */
44 public void notify(EventType evt, InterviewParameters interview, Properties templateData) {}
45 public void notify(EventType evt, InterviewParameters interview, Map<String, String> templateData) {}
4546
4647 /**
4748 * Returns the question's text. This text is used in the template propagation dialog only
6263 * @param interview
6364 * @return true if the interview was changed
6465 */
65 public boolean preprocessData(Properties templateData, InterviewParameters interview) {
66 public boolean preprocessData(Map<String, String> templateData, InterviewParameters interview) {
6667 return false;
6768 }
6869
467467 }
468468
469469 private void copyMenuListeners(JMenu src, JMenu dst) {
470 MenuListener[] ll = (MenuListener[]) (src.getListeners(MenuListener.class));
470 MenuListener[] ll = src.getListeners(MenuListener.class);
471471 for (int i = 0; i < ll.length; i++)
472472 dst.addMenuListener(ll[i]);
473473 }
521521 * @param m The map object to which to write the state of the desktop
522522 * @see #restoreDesktop
523523 */
524 protected abstract void saveDesktop(Map m);
524 protected abstract void saveDesktop(Map<String, String> m);
525525
526526 /**
527527 * Save the state of the current tools on the desktop to a map object.
528528 * @param m The map object to which to write the state of the desktop
529529 * @see #restoreDesktop
530530 */
531 protected void saveTools(Map m) {
531 protected void saveTools(Map<String, String> m) {
532532 Tool[] tools = getTools();
533533 m.put("tool.count", String.valueOf(tools.length));
534534 for (int i = 0; i < tools.length; i++)
535 saveTool(new PrefixMap(m, "tool." + String.valueOf(i)), tools[i]);
535 saveTool(new PrefixMap<>(m, "tool." + String.valueOf(i)), tools[i]);
536536 }
537537
538538 /**
541541 * @param t the tool to be saved
542542 * @see #restoreTool
543543 */
544 protected void saveTool(Map m, Tool t) {
544 protected void saveTool(Map<String, String> m, Tool t) {
545545 m.put("mgr", t.getManager().getClass().getName());
546546 m.put("class", t.getClass().getName());
547547 m.put("selected", String.valueOf(t == getSelectedTool()));
553553 * @param m The map object from which to restore the state of the desktop
554554 * @see #saveDesktop
555555 */
556 protected abstract void restoreDesktop(Map m);
556 protected abstract void restoreDesktop(Map<String, String> m);
557557
558558 /**
559559 * Restore the state of the saved tools from a map object.
560560 * @param m The map object from which to restore the state of the saved tools
561561 * @see #saveTools
562562 */
563 protected void restoreTools(Map m) {
563 protected void restoreTools(Map<String, String> m) {
564564 try {
565 String c = (String) (m.get("tool.count"));
565 String c = m.get("tool.count");
566566 if (c != null) {
567567 int count = Integer.parseInt(c);
568568 for (int i = 0; i < count; i++) {
569569 try {
570570 String prefix = "tool." + i;
571 Map toolMap = new PrefixMap(m, prefix);
571 Map<String, String> toolMap = new PrefixMap<>(m, prefix);
572572 restoreTool(toolMap, prefix);
573573 }
574574 catch (ToolManager.Fault e) {
605605 * @throws IllegalAccessException if the tool's restore method does not have public access
606606 * @throws InvocationTargetException if the tool's restore method threw an exception
607607 */
608 protected Tool restoreTool(Map m, String name) throws Fault, ToolManager.Fault
608 protected Tool restoreTool(Map<String, String> m, String name) throws Fault, ToolManager.Fault
609609 {
610 String mgrClassName = (String) (m.get("mgr"));
610 String mgrClassName = m.get("mgr");
611611 if (mgrClassName == null) {
612612 // backwards compatibility with 3.1
613 String toolClassName = (String) (m.get("class"));
613 String toolClassName = m.get("class");
614614 if (toolClassName != null && toolClassName.endsWith("Tool")) {
615615 String n = toolClassName.substring(0, toolClassName.length()) + "Manager";
616616 try {
647647 * @param m the map in which the information is to be recorded
648648 * @see #restoreBounds
649649 */
650 protected static void saveBounds(Component c, Map m) {
650 protected static void saveBounds(Component c, Map<String, String> m) {
651651 Rectangle r = c.getBounds();
652652 m.put("x", String.valueOf(r.x));
653653 m.put("y", String.valueOf(r.y));
663663 * @param m the map in which the information is to be recorded
664664 * @see #saveBounds
665665 */
666 protected static void restoreBounds(Component c, Map m) {
666 protected static void restoreBounds(Component c, Map<String, String> m) {
667667 try {
668 String xs = (String) (m.get("x"));
669 String ys = (String) (m.get("y"));
670 String ws = (String) (m.get("w"));
671 String hs = (String) (m.get("h"));
668 String xs = (m.get("x"));
669 String ys = (m.get("y"));
670 String ws = (m.get("w"));
671 String hs = (m.get("h"));
672672 if (xs != null && ys != null && ws != null && hs != null) {
673673 Rectangle restored = new Rectangle(Integer.parseInt(xs),
674674 Integer.parseInt(ys),
706706
707707 // keep a private list of all the outstanding frames, so that
708708 // when the collection becomes empty, we can lower the ExitCount.
709 private static Collection allFrames = new Vector();
709 private static Collection<JFrame> allFrames = new Vector<>();
710710
711711 // counter for unique name generation
712712 private static int frameIndex;
790790
791791 } // for
792792
793 List fileHistory = desktop.getFileHistory();
793 List<Desktop.FileHistoryEntry> fileHistory = desktop.getFileHistory();
794794 // if (!fileHistory.isEmpty()) {
795795 JMenu hm = uif.createMenu("dt.file.recentwd");
796796 if (!fileHistory.isEmpty()) {
797797 int n = 0;
798798
799 for (Iterator i = fileHistory.iterator(); i.hasNext(); ) {
800 Desktop.FileHistoryEntry h = (Desktop.FileHistoryEntry) (i.next());
799 for (Iterator<Desktop.FileHistoryEntry> i = fileHistory.iterator(); i.hasNext(); ) {
800 Desktop.FileHistoryEntry h = (i.next());
801801 if (!h.file.exists())
802802 continue;
803803 String s = uif.getI18NString("dt.file.historyX.mit",
4545 import java.lang.reflect.InvocationTargetException;
4646 import java.lang.reflect.Method;
4747 import java.net.URL;
48 import java.util.ArrayList;
49 import java.util.Arrays;
50 import java.util.HashMap;
51 import java.util.HashSet;
52 import java.util.Iterator;
53 import java.util.LinkedList;
54 import java.util.List;
55 import java.util.Properties;
56 import java.util.Set;
57 import java.util.Vector;
48 import java.util.*;
5849 import javax.swing.BorderFactory;
5950 import javax.swing.Icon;
6051 import javax.swing.JButton;
7768 import com.sun.javatest.tool.jthelp.HelpBroker;
7869 import com.sun.javatest.tool.jthelp.HelpSet;
7970 import com.sun.javatest.tool.jthelp.JTHelpBroker;
80 import com.sun.javatest.util.BackupPolicy;
71 import com.sun.javatest.util.*;
8172 import com.sun.javatest.report.HTMLWriterEx;
82 import com.sun.javatest.util.I18NResourceBundle;
83 import com.sun.javatest.util.LogFile;
84 import com.sun.javatest.util.SortedProperties;
73 import com.sun.javatest.util.Properties;
74
8575 import java.awt.print.Printable;
8676 import java.awt.print.PrinterJob;
8777 import javax.print.Doc;
176166 break;
177167 case CommandContext.METAL_LAF:
178168 try {
179 Class nimbusClass = Class.forName("javax.swing.plaf.metal.MetalLookAndFeel");
169 Class<?> nimbusClass = Class.forName("javax.swing.plaf.metal.MetalLookAndFeel");
180170 UIManager.setLookAndFeel((LookAndFeel) nimbusClass.newInstance());
181171 } catch (Throwable e) {
182172 }
183173 break;
184174 case CommandContext.NIMBUS_LAF:
185175 try {
186 Class nimbusClass = Class.forName("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
176 Class<?> nimbusClass = Class.forName("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
187177 UIManager.setLookAndFeel((LookAndFeel) nimbusClass.newInstance());
188178 } catch (Throwable e) {
189179 }
408398 // this is to avoid a class dependency to exec package, which is
409399 // normally not allowed in this package
410400 Method m = mgr.getClass().getMethod("startTool",
411 new Class[] { InterviewParameters.class} );
401 new Class<?>[] { InterviewParameters.class} );
412402
413403 return (Tool) m.invoke(mgr, new Object[] { ip });
414404 }
458448 * @param c the class of the desired tool manager.
459449 * @return a tool manager of the desired type, or null if none found
460450 */
461 public ToolManager getToolManager(Class c) {
451 public ToolManager getToolManager(Class<?> c) {
462452 for (int i = 0; i < toolManagers.length; i++) {
463453 ToolManager m = toolManagers[i];
464454 if (c.isInstance(m))
510500 */
511501 public void addToFileHistory(File f, FileOpener fo) {
512502 // if it is already in the history, remove it
513 for (Iterator i = fileHistory.iterator(); i.hasNext(); ) {
514 FileHistoryEntry h = (FileHistoryEntry) (i.next());
503 for (Iterator<FileHistoryEntry> i = fileHistory.iterator(); i.hasNext(); ) {
504 FileHistoryEntry h = i.next();
515505 if (h.fileOpener == fo && h.file.equals(f)) {
516506 i.remove();
517507 break;
531521 * @return a list of the current entries on the file history associated with this desktop
532522 * @see #addToFileHistory
533523 */
534 List getFileHistory()
524 List<FileHistoryEntry> getFileHistory()
535525 {
536526 return fileHistory;
537527 }
656646 return false;
657647 }
658648
659 Vector v = new Vector();
649 Vector<String> v = new Vector<>();
660650
661651 Tool[] tools = getTools();
662652 for (int ti = 0; ti < tools.length; ti++) {
831821 if (f == null)
832822 return;
833823
834 Properties p = new SortedProperties();
824 SortedMap<String, String> p = new TreeMap<>();
835825
836826 int s = getStyle();
837827 if (s < NUM_STYLES) {
846836
847837 p.put("file.count", String.valueOf(fileHistory.size()));
848838 int n = 0;
849 for (Iterator i = fileHistory.iterator(); i.hasNext(); ) {
850 FileHistoryEntry h = (FileHistoryEntry) (i.next());
839 for (Iterator<FileHistoryEntry> i = fileHistory.iterator(); i.hasNext(); ) {
840 FileHistoryEntry h = i.next();
851841 p.put("fileHistory." + n + ".type", h.fileOpener.getFileType());
852842 p.put("fileHistory." + n + ".path", h.file.getPath());
853843 n++;
857847 File dir = f.getParentFile();
858848 if (dir != null && !dir.exists())
859849 dir.mkdirs();
860 FileOutputStream fos = null;
861 try {
862 fos = new FileOutputStream(f);
863 OutputStream out = new BufferedOutputStream(fos);
864 p.store(out, "JT Harness Desktop");
865 out.close();
866 }
867 finally {
868 if (fos != null){
869 try { fos.close(); } catch (IOException e) { }
870 }
871 } // finally
850 try (FileOutputStream fos = new FileOutputStream(f);
851 OutputStream out = new BufferedOutputStream(fos)) {
852 Properties.store(p, out, "JT Harness Desktop");
853 }
872854 }
873855 catch (IOException e) {
874856 System.err.println(uif.getI18NString("dt.cantWriteDt.txt", e.getMessage()));
896878 * @param file the file from which to load the data
897879 */
898880 public void restore(final File file) {
899 Properties p = getPreviousDesktop(file);
881 Map<String, String> p = getPreviousDesktop(file);
900882 restore0(p);
901883 }
902884
904886 restoreHistory(getPreviousDesktop(getDesktopFile()));
905887 }
906888
907 private void restore0(final Properties p) {
889 private void restore0(final Map<String, String> p) {
908890 //System.err.println("DT: restore " + file);
909891 if (!EventQueue.isDispatchThread()) {
910892 invokeOnEventThread(new Runnable() {
976958
977959 }
978960
979 private void restoreHistory(Properties p) {
980 HashMap allOpeners = new HashMap();
961 private void restoreHistory(Map<String, String> p) {
962 HashMap<String, FileOpener> allOpeners = new HashMap<>();
981963 for (int i = 0; i < toolManagers.length; i++) {
982964 ToolManager m = toolManagers[i];
983965 FileOpener[] mgrOpeners = m.getFileOpeners();
991973
992974 try {
993975 fileHistory.clear();
994 String c = (String) (p.get("file.count"));
976 String c = p.get("file.count");
995977 if (c != null) {
996978 int count = Integer.parseInt(c);
997979 for (int i = 0; i < count; i++) {
998980 try {
999 String ft = (String) (p.get("fileHistory." + i + ".type"));
1000 FileOpener fo = (FileOpener) (allOpeners.get(ft));
981 String ft = p.get("fileHistory." + i + ".type");
982 FileOpener fo = allOpeners.get(ft);
1001983 if (fo != null) {
1002 String path = (String) (p.get("fileHistory." + i + ".path"));
984 String path = p.get("fileHistory." + i + ".path");
1003985 if (path != null && path.length() > 0)
1004986 fileHistory.add(new FileHistoryEntry(fo, new File(path)));
1005987 }
10181000 }
10191001 }
10201002
1021 static Properties getPreviousDesktop(File file) {
1003 static Map<String, String> getPreviousDesktop(File file) {
10221004 if (file == null)
10231005 file = getDesktopFile();
10241006
1025 Properties p = new Properties();
1007 Map<String, String> stringPropsMap = new HashMap<>();
10261008
10271009 if (file != null && file.exists()) {
1028 FileInputStream fis = null;
1029 try {
1030 fis = new FileInputStream(file);
1031 InputStream in = new BufferedInputStream(fis);
1032 p.load(in);
1033 in.close();
1010 try (FileInputStream fis = new FileInputStream(file);
1011 InputStream in = new BufferedInputStream(fis)) {
1012 stringPropsMap = Properties.load(in);
10341013 }
10351014 catch (IOException e) {
10361015 // I18N
10371016 System.err.println("Error reading desktop file: " + e);
10381017 }
1039 finally {
1040 if (fis != null){
1041 try { fis.close(); } catch (IOException e) { }
1042 }
1043 }
1044 }
1045
1046 return p;
1018 }
1019
1020 return stringPropsMap;
10471021 }
10481022
10491023 /**
10561030 if(colorPane == null)
10571031 colorPane = new ColorPrefsPane(uif);
10581032
1059 Vector v = new Vector();
1033 Vector<PreferencesPane> v = new Vector<>();
10601034 v.addElement(prefsPane);
10611035 v.addElement(colorPane);
10621036 for (int i = 0; i < toolManagers.length; i++) {
10851059 * Null if none.
10861060 */
10871061 private PreferencesPane[] getCustomPreferences() {
1088 ArrayList al = new ArrayList();
1089
1090 HashSet customPrefsClasses = new HashSet();
1062 List<PreferencesPane> al = new ArrayList<>();
1063
1064 Set<String> customPrefsClasses = new HashSet<>();
10911065
10921066 Tool[] tools = getTools();
10931067 for (int i = 0; i < tools.length; i++) {
14631437
14641438 try {
14651439 ManagerLoader ml = new ManagerLoader(ToolManager.class, System.err);
1466 ml.setManagerConstructorArgs(new Class[] { Desktop.class }, new Object[] { this });
1467 Set s = ml.loadManagers(TOOLMGRLIST);
1468 toolManagers = (ToolManager[]) (s.toArray(new ToolManager[s.size()]));
1440 ml.setManagerConstructorArgs(new Class<?>[] { Desktop.class }, new Object[] { this });
1441 Set<?> s = ml.loadManagers(TOOLMGRLIST);
1442 toolManagers = s.toArray(new ToolManager[s.size()]);
14691443 }
14701444 catch (IOException e) {
14711445 throw new JavaTestError(uif.getI18NResourceBundle(),
16331607 private PrintRequestAttributeSet printAttrs;
16341608 private boolean restoreOnStart;
16351609
1636 private LinkedList fileHistory = new LinkedList();
1610 private LinkedList<FileHistoryEntry> fileHistory = new LinkedList<>();
16371611 private static final int FILE_HISTORY_MAX_SIZE = 10;
16381612
16391613 private static Preferences preferences = Preferences.access();
6767
6868 //----------------------------------------------------------------------------
6969
70 public boolean parseCommand(String cmd, ListIterator argIter, CommandContext ctx)
70 public boolean parseCommand(String cmd, ListIterator<String> argIter, CommandContext ctx)
7171 throws Command.Fault
7272 {
7373 if (cmd.equalsIgnoreCase("newDesktop") || cmd.equalsIgnoreCase("cleanDesktop")) {
110110
111111 private static class SetLafCommand extends Command {
112112
113 private SetLafCommand(ListIterator argIter, CommandContext ctx) throws Fault {
113 private SetLafCommand(ListIterator<String> argIter, CommandContext ctx) throws Fault {
114114 super("laf");
115115
116116 if (!argIter.hasNext()) {
119119
120120 int laf;
121121
122 String lafName = (String) argIter.next();
122 String lafName = argIter.next();
123123 if ("nimbus".equalsIgnoreCase(lafName)) {
124124 laf = CommandContext.NIMBUS_LAF;
125125 } else if ("metal".equalsIgnoreCase(lafName)) {
3232 import java.awt.event.ActionListener;
3333 import java.util.Enumeration;
3434 import java.util.Map;
35 import javax.swing.*;
3536 import javax.swing.plaf.basic.BasicComboBoxRenderer;
36 import javax.swing.Box;
37 import javax.swing.ButtonGroup;
38 import javax.swing.ButtonModel;
39 import javax.swing.JCheckBox;
40 import javax.swing.JComboBox;
41 import javax.swing.JLabel;
42 import javax.swing.JList;
43 import javax.swing.JPanel;
44 import javax.swing.JRadioButton;
4537
4638 /**
4739 * Preferences for the desktop itself.
7466 }
7567
7668 @Override
77 public void load(Map m) {
78 String styleName = (String) (m.get(Desktop.STYLE_PREF));
69 public void load(Map<String, String> m) {
70 String styleName = m.get(Desktop.STYLE_PREF);
7971 if (styleName == null)
8072 styleName = Desktop.styleNames[desktop.getStyle()];
8173
82 for (Enumeration e = styleGrp.getElements(); e.hasMoreElements(); ) {
74 for (Enumeration<AbstractButton> e = styleGrp.getElements(); e.hasMoreElements(); ) {
8375 JRadioButton rb = (JRadioButton)e.nextElement();
8476 if (rb.getActionCommand().equals(styleName)) {
8577 rb.setSelected(true);
8779 }
8880 }
8981 // tooltips
90 String tipState = (String) (m.get(Desktop.TTIP_PREF));
82 String tipState = m.get(Desktop.TTIP_PREF);
9183 ttipsCheck.setSelected(tipState == null || tipState.equalsIgnoreCase("true"));
9284
9385 boolean complete = false; // used for delay and duration code
9486
95 String tipDelay = (String) (m.get(Desktop.TTIP_DELAY));
87 String tipDelay = m.get(Desktop.TTIP_DELAY);
9688 try {
9789 int delay = Integer.parseInt(tipDelay);
9890
10395 }
10496 else {
10597 for (int i = 1; i < ttDelay.getItemCount(); i++) {
106 if ( ((Integer)(ttDelay.getItemAt(i))).intValue() == delay ) {
98 if ( ttDelay.getItemAt(i).intValue() == delay ) {
10799 ttDelay.setSelectedIndex(i);
108100 i = ttDelay.getItemCount(); // stop loop
109101 complete = true;
124116 ttDelay.setSelectedIndex(1);
125117
126118 complete = false;
127 String tipDuration = (String) (m.get(Desktop.TTIP_DURATION));
119 String tipDuration = m.get(Desktop.TTIP_DURATION);
128120 try {
129121 int duration = Integer.parseInt(tipDuration);
130122 if (duration == Desktop.TTIP_DURATION_FOREVER) {
155147 syncTooltipPrefs();
156148
157149 // save on exit
158 String saveState = (String) (m.get(Desktop.SAVE_ON_EXIT_PREF));
150 String saveState = m.get(Desktop.SAVE_ON_EXIT_PREF);
159151 saveCheck.setSelected(saveState == null || "true".equalsIgnoreCase(saveState)); // true (null) by default
160 String restoreState = (String) (m.get(Desktop.RESTORE_ON_START_PREF)); // false by default
152 String restoreState = m.get(Desktop.RESTORE_ON_START_PREF); // false by default
161153 restoreCheck.setSelected(restoreState == null || "true".equalsIgnoreCase(restoreState));
162154 }
163155
164156 @Override
165 public void save(Map m) {
157 public void save(Map<String, String> m) {
166158 ButtonModel bm = styleGrp.getSelection();
167159 if (bm != null) {
168160 String styleName = bm.getActionCommand();
352344 private UIFactory uif;
353345 private ButtonGroup styleGrp;
354346 private JCheckBox ttipsCheck;
355 private JComboBox ttDelay;
356 private JComboBox ttDuration;
347 private JComboBox<Integer> ttDelay;
348 private JComboBox<Integer> ttDuration;
357349 private JCheckBox saveCheck;
358350 private JCheckBox restoreCheck;
359351
3232 import java.awt.event.ActionListener;
3333 import java.awt.event.MouseEvent;
3434 import java.awt.event.MouseListener;
35 import java.io.File;
3536 import java.lang.reflect.Array;
3637 import javax.accessibility.Accessible;
3738 import javax.accessibility.AccessibleContext;
7879 public EditableList(UIFactory uif, String uiKey) {
7980 this.uif = uif;
8081 setLayout(new BorderLayout());
81 listModel = new DefaultListModel(); // need to force the type of model
82 listModel = new DefaultListModel<>(); // need to force the type of model
8283 listModel.addListDataListener(listener);
8384 list = uif.createList(uiKey, listModel);
8485 list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
156157 * @return an array containing the items currently in the list
157158 * @see #setItems
158159 */
159 public Object[] getItems(Class c) {
160 public Object[] getItems(Class<?> c) {
160161 Object[] items = (Object[]) (Array.newInstance(c, listModel.size()));
161162 listModel.copyInto(items);
162163 return items;
334335
335336 private class Renderer
336337 extends DefaultListCellRenderer {
337 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
338 public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
338339 return super.getListCellRendererComponent(list,
339340 getDisplayValue(value),
340341 index,
452453 /**
453454 * The list model that contains the elements of the list.
454455 */
455 protected DefaultListModel listModel;
456 private JList list;
456 protected DefaultListModel<Object> listModel;
457 private JList<Object> list;
457458 private JButton addBtn;
458459 private JButton removeBtn;
459460 private JButton upBtn;
3434 import com.sun.javatest.TestEnvironment;
3535 import com.sun.javatest.util.HelpTree;
3636 import com.sun.javatest.util.I18NResourceBundle;
37 import com.sun.javatest.util.Properties;
3738
3839 /**
3940 * A command manager to handle the command line options for adding
5455
5556 // set basic defaults
5657 String[] stdSysProps = {"user.dir", "user.home"};
57 Map m = new HashMap();
58 Map<String, String> m = new HashMap<>();
5859 for (int i = 0; i < stdSysProps.length; i++) {
5960 String name = stdSysProps[i];
6061 m.put(name, System.getProperty(name));
6869 return new HelpTree.Node(i18n, "env", opts);
6970 }
7071
71 public boolean parseCommand(String cmd, ListIterator argIter, CommandContext ctx)
72 public boolean parseCommand(String cmd, ListIterator<String> argIter, CommandContext ctx)
7273 throws Command.Fault
7374 {
7475 if (cmd.equalsIgnoreCase("EsysProps")) {
99100 }
100101
101102 public void run(CommandContext ctx) throws Fault {
102 Map m = new HashMap(1); // would be nice to have a singleton map
103 Map<String, String> m = new HashMap<>(1); // would be nice to have a singleton map
103104 m.put(name, value);
104105 TestEnvironment.addDefaultPropTable(i18n.getString("env.def.cmdLine"), m);
105106 }
117118
118119 public void run(CommandContext ctx) throws Fault {
119120 try {
120 Map sysProps;
121 Map<String, String> sysProps;
121122 SecurityManager sc = System.getSecurityManager();
122123 if (sc instanceof JavaTestSecurityManager) {
123124 // open up the properties access permission to get system props.
124125 boolean prev = ((JavaTestSecurityManager) sc).setAllowPropertiesAccess(true);
125126 try {
126 sysProps = System.getProperties();
127 sysProps = Properties.convertToStringProps( System.getProperties() );
127128 }
128129 finally {
129130 ((JavaTestSecurityManager) sc).setAllowPropertiesAccess(prev);
132133 else {
133134 // if not JTSecurityManager, try to get properties anyway
134135 // and handle the exception if we can't get them
135 sysProps = System.getProperties();
136 sysProps = Properties.convertToStringProps( System.getProperties() );
136137 }
137138 TestEnvironment.addDefaultPropTable(i18n.getString("env.def.sysProps"), sysProps);
138139 }
3030 import java.io.*;
3131 import java.lang.ref.WeakReference;
3232 import java.nio.charset.StandardCharsets;
33 import java.util.Date;
34 import java.util.HashMap;
35 import java.util.Iterator;
36 import java.util.Vector;
37 import java.util.WeakHashMap;
33 import java.util.*;
3834 import javax.swing.JMenu;
3935 import javax.swing.JMenuItem;
4036 import javax.swing.event.MenuEvent;
6157 */
6258 public static FileHistory getFileHistory(WorkDirectory wd, String name) {
6359 if (cache == null)
64 cache = new WeakHashMap(8);
60 cache = new WeakHashMap<>(8);
6561
6662 // first, get a map for all files in this wd
67 HashMap map = (HashMap) (cache.get(wd));
63 Map<String, FileHistory> map = cache.get(wd);
6864 if (map == null) {
69 map = new HashMap(8);
65 map = new HashMap<>(8);
7066 cache.put(wd, map);
7167 }
7268
7369 // then, get the FileHistory for the specified file
74 FileHistory h = (FileHistory) (map.get(name));
70 FileHistory h = map.get(name);
7571 if (h == null) {
7672 h = new FileHistory(wd, name);
7773 map.put(name, h);
9086 */
9187 public static FileHistory getFileHistory(File wdFile, String name) {
9288 if (cache == null)
93 cache = new WeakHashMap(8);
89 cache = new WeakHashMap<>(8);
9490
9591 if (!WorkDirectory.isWorkDirectory(wdFile))
9692 return null;
9793
9894 // let's find in the cache work dir corresponding to the path
99 Iterator it = cache.keySet().iterator();
95 Iterator<WorkDirectory> it = cache.keySet().iterator();
10096 WorkDirectory wd = null;
10197 while (it.hasNext()) {
102 WorkDirectory tempWD = ((WorkDirectory)it.next());
98 WorkDirectory tempWD = it.next();
10399 if (tempWD.getRoot().equals(wdFile)) {
104100 wd = tempWD;
105101 break;
142138 // collecting up to count entries. Non-existent entries are
143139 // skipped but not deleted because they might be for other
144140 // platforms.
145 Vector v = new Vector();
141 Vector<File> v = new Vector<>();
146142 for (int i = 0; i < entries.size() && v.size() < count; i++) {
147 File f = (File) (entries.elementAt(i));
143 File f = entries.elementAt(i);
148144 if (f.exists())
149145 v.add(f);
150146 }
168164 // skipped but not deleted because they might be for other
169165 // platforms.
170166 for (int i = 0; i < entries.size(); i++) {
171 File f = (File) (entries.elementAt(i));
167 File f = entries.elementAt(i);
172168 if (f.exists())
173169 return f;
174170 }
180176 ensureEntriesUpToDate();
181177
182178 for (int i = 0; i < entries.size(); i++) {
183 File f = (File) (entries.elementAt(i));
179 File f = entries.elementAt(i);
184180 if (f.exists()) {
185181 return f;
186182 } else {
200196
201197
202198 private FileHistory(WorkDirectory workDir, String name) {
203 workDirRef = new WeakReference(workDir); // just used for logging errors
199 workDirRef = new WeakReference<>(workDir); // just used for logging errors
204200 this.name = name;
205201 historyFile = workDir.getSystemFile(name);
206202 }
212208
213209 private void readEntries() {
214210 if (entries == null)
215 entries = new Vector();
211 entries = new Vector<>();
216212 else
217213 entries.clear();
218214
229225 br.close();
230226 }
231227 catch (IOException e) {
232 WorkDirectory workDir = (WorkDirectory) (workDirRef.get());
228 WorkDirectory workDir = workDirRef.get();
233229 workDir.log(i18n, "fh.cantRead", new Object[] { name, e } );
234230 }
235231
251247 bw.close();
252248 }
253249 catch (IOException e) {
254 WorkDirectory workDir = (WorkDirectory) (workDirRef.get());
250 WorkDirectory workDir = workDirRef.get();
255251 workDir.log(i18n, "fh.cantWrite", new Object[] { name, e } );
256252 }
257253
398394 private ActionListener clientListener;
399395 }
400396
401 private WeakReference workDirRef;
397 private WeakReference<WorkDirectory> workDirRef;
402398 private String name;
403399 private File historyFile;
404400 private long historyFileLastModified;
405 private Vector entries;
401 private Vector<File> entries;
406402
407403 /**
408404 * The name of the client property used to access the File that identifies
411407 */
412408 public static final String FILE = "file";
413409
414 private static WeakHashMap cache;
410 private static WeakHashMap<WorkDirectory, Map<String, FileHistory>> cache;
415411 private static final String FILE_HISTORY = "fileHistory";
416412 private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(FileHistory.class);
417413
2525 */
2626 package com.sun.javatest.tool;
2727
28 import java.awt.Color;
29 import java.awt.Component;
30 import java.awt.Container;
31 import java.awt.FocusTraversalPolicy;
32 import java.awt.Frame;
33 import java.awt.GridBagConstraints;
34 import java.awt.GridBagLayout;
35 import java.awt.KeyboardFocusManager;
36 import java.awt.Window;
28 import java.awt.*;
3729 import java.awt.event.ActionEvent;
3830 import java.awt.event.WindowAdapter;
3931 import java.awt.event.WindowEvent;
397389 if (c == null)
398390 return null;
399391
400 Set s = c.getFocusTraversalKeys(mode);
392 Set<AWTKeyStroke> s = c.getFocusTraversalKeys(mode);
401393 StringBuffer sb = new StringBuffer();
402 for (Iterator iter = s.iterator(); iter.hasNext(); ) {
394 for (Iterator<AWTKeyStroke> iter = s.iterator(); iter.hasNext(); ) {
403395 if (sb.length() > 0)
404396 sb.append(", ");
405397 sb.append(iter.next());
562554
563555 void write(Writer out) throws IOException {
564556 for (int i = 0; i <entries.size(); i++) {
565 Entry e = (Entry) (entries.elementAt(i));
557 Entry e = entries.elementAt(i);
566558 e.write(out);
567559 }
568560 }
570562 public void setEnabled(boolean enabled) {
571563 super.setEnabled(enabled);
572564 for (int i = 0; i <entries.size(); i++) {
573 Entry e = (Entry) (entries.elementAt(i));
565 Entry e = entries.elementAt(i);
574566 e.setParentEnabled(enabled);
575567 }
576568 }
588580 entries.add(entry);
589581 }
590582
591 private Vector entries = new Vector();
583 private Vector<Entry> entries = new Vector<>();
592584 private Entry name;
593585 private Entry path;
594586 private Entry type;
7171 // rundll32 allows to open a file in appropriate default application
7272 Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
7373 } else if (os.startsWith("Mac OS")) {
74 Class fileMgr = Class.forName("com.apple.eio.FileManager");
74 Class<?> fileMgr = Class.forName("com.apple.eio.FileManager");
7575 Method openURL = fileMgr.getDeclaredMethod("openURL",
76 new Class[]{String.class});
76 new Class<?>[]{String.class});
7777 openURL.invoke(null, new Object[]{url});
7878 } else {
7979 String[] commands = {
3434 import java.io.PrintWriter;
3535 import java.net.URL;
3636 import java.text.DateFormat;
37 import java.util.Arrays;
38 import java.util.Iterator;
39 import java.util.ListIterator;
40 import java.util.TreeMap;
37 import java.util.*;
4138
4239 import com.sun.javatest.Harness;
4340 import com.sun.javatest.ProductInfo;
4744 import com.sun.javatest.util.HelpTree;
4845 import com.sun.javatest.util.I18NResourceBundle;
4946 import com.sun.javatest.util.WrapWriter;
50 import java.util.ArrayList;
5147
5248 /**
5349 * A manager for command line help.
9591 * and false otherwise
9692 */
9793 @Override
98 public boolean parseCommand(String cmd, ListIterator argIter, CommandContext ctx) {
94 public boolean parseCommand(String cmd, ListIterator<String> argIter, CommandContext ctx) {
9995 if (cmd.equalsIgnoreCase("help")
10096 || cmd.equalsIgnoreCase("usage")
10197 || cmd.equalsIgnoreCase("?")) {
102 ArrayList v = new ArrayList();
98 List<String> v = new ArrayList<>();
10399 while (argIter.hasNext()) {
104 v.add(((String) (argIter.next())).toLowerCase());
100 v.add(argIter.next().toLowerCase());
105101 }
106102 commandLineHelpFlag = true;
107 commandLineHelpQuery = (String[]) (v.toArray(new String[v.size()]));
103 commandLineHelpQuery = v.toArray(new String[v.size()]);
108104 return true;
109105 }
110106
173169 }
174170
175171 // sort the command manager help nodes according to their name
176 TreeMap tm = new TreeMap();
172 TreeMap<String, HelpTree.Node> tm = new TreeMap<>();
177173 for (int i = 0; i < commandManagers.length; i++) {
178174 HelpTree.Node n = commandManagers[i].getHelp();
179175 tm.put(n.getName(), n);
180176 }
181177
182 for (Iterator iter = tm.values().iterator(); iter.hasNext(); ) {
183 commandHelpTree.addNode((HelpTree.Node) (iter.next()));
178 for (Iterator<HelpTree.Node> iter = tm.values().iterator(); iter.hasNext(); ) {
179 commandHelpTree.addNode((iter.next()));
184180 }
185181
186182 // now add file types
3030 import java.awt.event.ActionEvent;
3131 import java.awt.event.ActionListener;
3232 import java.text.DateFormat;
33 import java.util.ArrayList;
34 import java.util.Arrays;
35 import java.util.Comparator;
36 import java.util.Date;
37 import java.util.Iterator;
38 import java.util.Set;
39 import java.util.TreeSet;
40 import java.util.WeakHashMap;
33 import java.util.*;
4134
4235 import javax.swing.JButton;
4336 import javax.swing.JComponent;
9083 }
9184
9285 // first, collect the set of active test suites
93 Set loadedTestSuites = new TreeSet(new Comparator() {
86 Set<TestSuite> loadedTestSuites = new TreeSet<>(new Comparator<TestSuite>() {
9487 @Override
95 public int compare(Object o1, Object o2) {
96 TestSuite ts1 = (TestSuite) o1;
97 TestSuite ts2 = (TestSuite) o2;
88 public int compare(TestSuite o1, TestSuite o2) {
89 TestSuite ts1 = o1;
90 TestSuite ts2 = o2;
9891 return ts1.getName().compareTo(ts2.getName());
9992 }
10093 });
124117 // for the active test suites, add any available help sets to the menu
125118 // e.g. those specified in the testsuite.jtt
126119 int count = 0;
127 for (Iterator iter = loadedTestSuites.iterator(); iter.hasNext(); ) {
128 TestSuite ts = (TestSuite) (iter.next());
120 for (Iterator<TestSuite> iter = loadedTestSuites.iterator(); iter.hasNext(); ) {
121 TestSuite ts = (iter.next());
129122 JMenuItem[] menuItems = getMenuItems(ts, count);
130123 if (menuItems != null && menuItems.length > 0) {
131124 for (int i = 0; i < menuItems.length; i++) {
201194 * for each of the fields holding the "about" text
202195 */
203196 private void showAbout(String title, String s, String contKey, String fieldKey) {
204 ArrayList v = new ArrayList();
197 List<String> v = new ArrayList<>();
205198 int start = 0;
206199 int end = 0;
207200
212205 v.add(s.substring(start));
213206
214207 //JTextField[] tfs = new JTextField[v.size()];
215 ArrayList<JComponent> tfs = new ArrayList();
208 ArrayList<JComponent> tfs = new ArrayList<>();
216209 for (int i = 0; i < v.size(); i++) {
217 JTextField tf = new JTextField((String)v.get(i));
210 JTextField tf = new JTextField(v.get(i));
218211 tf.setBorder(null);
219212 tf.setHorizontalAlignment(JTextField.CENTER);
220213 tf.setOpaque(false);
264257 }
265258
266259 private HelpBroker getHelpBroker(HelpSet hs) {
267 HelpBroker hb = (HelpBroker) (helpBrokerTable.get(hs));
260 HelpBroker hb = helpBrokerTable.get(hs);
268261 if (hb == null) {
269262 //hb = hs.createHelpBroker(); // pres. attributes work with this on JH 2.0_02
270263 hb = new JTHelpBroker();
274267 }
275268
276269 private JMenuItem[] getMenuItems(TestSuite ts, int count) {
277 HelpSet[] docs = (HelpSet[]) (docTable.get(ts));
270 HelpSet[] docs = docTable.get(ts);
278271 if (docs == null) {
279272 try {
280273 docs = Help.getAdditionalDocs(ts);
293286 return null;
294287 }
295288
296 ArrayList<JMenuItem> v = new ArrayList();
289 ArrayList<JMenuItem> v = new ArrayList<>();
297290 for (int i = 0; i < docs.length; i++) {
298291 final HelpSet doc = docs[i];
299292
327320
328321 private Listener listener;
329322
330 private static WeakHashMap docTable = new WeakHashMap(); // gives HelpSet[] for TestSuite
331 private static WeakHashMap helpBrokerTable = new WeakHashMap(); // gives HelpBroker for HelpSet
323 private static Map<TestSuite, HelpSet[]> docTable = new WeakHashMap<>(); // gives HelpSet[] for TestSuite
324 private static Map<HelpSet, HelpBroker> helpBrokerTable = new WeakHashMap<>(); // gives HelpBroker for HelpSet
332325
333326 private static final String HELP = "help";
334327 private static final String ABOUT_JAVA = "aboutJava";
5555
5656 //----------------------------------------------------------------------------
5757
58 public boolean parseCommand(String cmd, ListIterator argIter, CommandContext ctx)
58 public boolean parseCommand(String cmd, ListIterator<String> argIter, CommandContext ctx)
5959 throws Command.Fault
6060 {
6161 if (isMatch(cmd, HttpCommand.getName())) {
5050 return new HelpTree.Node(i18n, "logm.help." + name);
5151 }
5252
53 public boolean parseCommand(String cmd, ListIterator argIter, CommandContext ctx)
53 public boolean parseCommand(String cmd, ListIterator<String> argIter, CommandContext ctx)
5454 throws Command.Fault
5555 {
5656 if (isPrefixMatch(cmd, VerboseCommand.getName())) {
7878 return "log";
7979 }
8080
81 LogCommand(ListIterator argIter) throws Fault {
81 LogCommand(ListIterator<String> argIter) throws Fault {
8282 super(getName());
8383
8484 if (!argIter.hasNext())
118118
119119 public Tool[] getTools() {
120120 Tool[] tools = new Tool[internalFrames.size()];
121 return (Tool[]) internalFrames.keySet().toArray(tools);
121 return internalFrames.keySet().toArray(tools);
122122 }
123123
124124 public void addTool(Tool t) {
185185
186186 public void removeTool(Tool t) {
187187 //System.err.println("MDI: remove " + t);
188 JInternalFrame f = (JInternalFrame) (internalFrames.get(t));
188 JInternalFrame f = internalFrames.get(t);
189189 if (f != null) {
190190 desktopPane.remove(f);
191191 internalFrames.remove(t);
210210 }
211211
212212 public void setSelectedTool(Tool t) {
213 JInternalFrame f = (JInternalFrame) (internalFrames.get(t));
213 JInternalFrame f = internalFrames.get(t);
214214 if (f != null) {
215215 try {
216216 f.setIcon(false);
276276 // seem to have no effect, so after 2 calls we seem to have stable results.
277277 f.pack();
278278 Dimension size = f.getSize();
279 JInternalFrame tf = (JInternalFrame) (internalFrames.get(tool));
279 JInternalFrame tf = internalFrames.get(tool);
280280 Rectangle tb = tf.getBounds();
281281 f.setLocation(Math.max(0, tb.x + (tb.width - size.width) / 2),
282282 Math.max(0, tb.y + (tb.height - size.height ) / 2) );
307307 }
308308 }
309309
310 protected void saveDesktop(Map m) {
311 saveBounds(mainFrame, new PrefixMap(m, "dt"));
310 protected void saveDesktop(Map<String, String> m) {
311 saveBounds(mainFrame, new PrefixMap<>(m, "dt"));
312312 saveTools(m);
313313 }
314314
315 protected void restoreDesktop(Map m) {
316 restoreBounds(mainFrame, new PrefixMap(m, "dt"));
315 protected void restoreDesktop(Map<String, String> m) {
316 restoreBounds(mainFrame, new PrefixMap<>(m, "dt"));
317317 restoreTools(m);
318318 }
319319
320 protected void saveTool(Map m, Tool t) {
320 protected void saveTool(Map<String, String> m, Tool t) {
321321 super.saveTool(m, t);
322 JInternalFrame f = (JInternalFrame) (internalFrames.get(t));
323 saveBounds(f, new PrefixMap(m, "dt"));
324 }
325
326 protected Tool restoreTool(Map m, String name) throws Fault, ToolManager.Fault
322 JInternalFrame f = internalFrames.get(t);
323 saveBounds(f, new PrefixMap<>(m, "dt"));
324 }
325
326 protected Tool restoreTool(Map<String, String> m, String name) throws Fault, ToolManager.Fault
327327 {
328328 Tool t = super.restoreTool(m, name);
329 JInternalFrame f = (JInternalFrame) (internalFrames.get(t));
330 restoreBounds(f, new PrefixMap(m, "dt"));
329 JInternalFrame f = internalFrames.get(t);
330 restoreBounds(f, new PrefixMap<>(m, "dt"));
331331 f.setVisible(true);
332332 return t;
333333 }
390390 }
391391
392392 private JInternalFrame[] getVisibleInternalFrames() {
393 Vector v = new Vector();
393 Vector<Component> v = new Vector<>();
394394 for (int i = 0; i < desktopPane.getComponentCount(); i++) {
395395 Component c = desktopPane.getComponent(i);
396396 if (c instanceof JInternalFrame && c.isVisible())
402402 }
403403
404404 private JFrame mainFrame;
405 private HashMap internalFrames = new HashMap(17);
405 private Map<Tool, JInternalFrame> internalFrames = new HashMap<>(17);
406406 private JDesktopPane desktopPane;
407407 private Listener listener = new Listener();
408408
561561 }
562562
563563 public void titleChanged(Tool src, String newValue) {
564 JInternalFrame f = (JInternalFrame) (internalFrames.get(src));
564 JInternalFrame f = internalFrames.get(src);
565565 f.setTitle(newValue);
566566 //System.err.println("Tool title changed: " + newValue);
567567 }
3030 import java.io.IOException;
3131 import java.io.PrintWriter;
3232 import java.text.MessageFormat;
33 import java.util.Map;
3334 import java.util.Set;
3435
3536 import com.sun.javatest.Harness;
264265 serviceManager = new ServiceManager.ServiceCommandManager();
265266 try {
266267 ManagerLoader ml = new ManagerLoader(CommandManager.class, System.err);
267 Set mgrs = ml.loadManagers(CMDMGRLIST);
268 Set<Object> mgrs = ml.loadManagers(CMDMGRLIST);
268269 mgrs.add(desktopManager);
269270 mgrs.add(helpManager);
270271 mgrs.add(serviceManager);
271 commandManagers = (CommandManager[]) mgrs.toArray(new CommandManager[mgrs.size()]);
272 commandManagers = mgrs.toArray(new CommandManager[mgrs.size()]);
272273 helpManager.setCommandManagers(commandManagers);
273274 }
274275 catch (IOException e) {
444445 }
445446 desktop.restoreHistory();
446447 Tool tool = desktop.addDefaultTool(ip);
447 java.util.Map data = ctx.getDesktopData();
448 Map<String, String> data = ctx.getDesktopData();
448449 if (data != null) {
449450 tool.restore(data);
450451 }
4646
4747 class ManagerLoader
4848 {
49 ManagerLoader(Class managerClass, PrintStream log) {
49 ManagerLoader(Class<?> managerClass, PrintStream log) {
5050 setManagerClass(managerClass);
5151 setLog(log);
5252 }
5353
54 void setManagerClass(Class managerClass) {
54 void setManagerClass(Class<?> managerClass) {
5555 this.managerClass = managerClass;
5656 }
5757
58 void setManagerConstructorArgs(Class[] argTypes, Object[] args) {
58 void setManagerConstructorArgs(Class<?>[] argTypes, Object[] args) {
5959 constrArgTypes = argTypes;
6060 constrArgs = args;
6161 }
6464 this.log = log;
6565 }
6666
67 Set loadManagers(String resourceName)
67 Set<Object> loadManagers(String resourceName)
6868 throws IOException
6969 {
7070
71 Enumeration e = ResourceLoader.getResources(resourceName, getClass());
72 Set mgrs = new HashSet();
71 Enumeration<URL> e = ResourceLoader.getResources(resourceName, getClass());
72 Set<Object> mgrs = new HashSet<>();
7373 URLClassLoader altLoader = null;
7474
7575 while (e.hasMoreElements()) {
76 URL entry = (URL)(e.nextElement());
76 URL entry = e.nextElement();
7777 try {
7878 BufferedReader in = new BufferedReader(new InputStreamReader(entry.openStream()));
7979 String line;
155155 }
156156
157157 try {
158 Class c = Class.forName(className, true, cl);
158 Class<?> c = Class.forName(className, true, cl);
159159 Object mgr = newInstance(c);
160160 if (managerClass.isInstance(mgr)) {
161161 return mgr;
171171 return null;
172172 }
173173
174 private Object newInstance(Class c)
174 private Object newInstance(Class<?> c)
175175 throws IllegalAccessException, InstantiationException, NoSuchMethodException
176176 {
177177 if (constrArgTypes == null || constrArgTypes.length == 0) {
179179 }
180180
181181 try {
182 Constructor constr = c.getConstructor(constrArgTypes);
182 Constructor<?> constr = c.getConstructor(constrArgTypes);
183183 return constr.newInstance(constrArgs);
184184 }
185185 catch (InvocationTargetException e) {
209209 URL u = ResourceLoader.getExtUrl(new File(s));
210210
211211 if (u != null) {
212 urls = (URL[]) (DynamicArray.append(urls, u));
212 urls = DynamicArray.append(urls, u);
213213 someCPok = true;
214214 }
215215 } // for
239239 log.println(i18n.getString(key, args));
240240 }
241241
242 private Class managerClass;
243 private Constructor constr;
244 private Class[] constrArgTypes;
242 private Class<?> managerClass;
243 private Constructor<?> constr;
244 private Class<?>[] constrArgTypes;
245245 private Object[] constrArgs;
246246 private PrintStream log;
247247
2727
2828 import com.sun.javatest.util.DynamicArray;
2929 import com.sun.javatest.util.I18NResourceBundle;
30 import com.sun.javatest.util.SortedProperties;
30 import com.sun.javatest.util.Properties;
31
3132 import java.io.BufferedInputStream;
3233 import java.io.BufferedOutputStream;
3334 import java.io.File;
3738 import java.io.IOException;
3839 import java.io.InputStream;
3940 import java.io.OutputStream;
40 import java.util.Enumeration;
4141 import java.util.Hashtable;
42 import java.util.Properties;
42 import java.util.Map;
43 import java.util.TreeMap;
4344
4445 /**
4546 * A class which provides a collection of user preferences,
9798 private Preferences(File file) {
9899 prefsFile = file;
99100 isUpToDate = true;
100 Properties p = new SortedProperties();
101 props = new TreeMap<String, String>();
101102
102103 try {
103104 if (prefsFile != null) {
104105 InputStream in = new BufferedInputStream(new FileInputStream(prefsFile));
105 p.load(in);
106 props = Properties.loadSorted(in);
106107 in.close();
107 fileModifiedTime = prefsFile.lastModified();
108 fileModifiedTime = prefsFile.lastModified();
108109 }
109110 }
110111 catch (FileNotFoundException ignore) {
112113 catch (IOException ignore) {
113114 // ??
114115 }
115 props = p;
116116 }
117117
118118 /**
128128 if (!parentDir.exists())
129129 parentDir.mkdirs();
130130 OutputStream out = new BufferedOutputStream(new FileOutputStream(prefsFile));
131 props.store(out, "JT Harness Preferences");
131 Properties.store(props, out, "JT Harness Preferences");
132132 out.close();
133133 isUpToDate = true;
134134 fileModifiedTime = prefsFile.lastModified();
159159 * @see #setPreference
160160 */
161161 public String getPreference(String name, String defaultValue) {
162 String v = (String) (props.get(name));
162 String v = props.get(name);
163163 if (v == null)
164164 v = defaultValue;
165165 return v;
176176 isUpToDate = false;
177177 props.put(name, newValue);
178178 // notify observers
179 for (Enumeration e = observers.keys(); e.hasMoreElements(); ) {
180 String prefix = (String)(e.nextElement());
179 for (String prefix: observers.keySet()) {
181180 if (name.startsWith(prefix)) {
182 Observer[] obs = (Observer[])observers.get(prefix);
181 Observer[] obs = observers.get(prefix);
183182 for (int i = 0; i < obs.length; i++) {
184183 obs[i].updated(name, newValue);
185184 }
199198 public void addObserver(String prefix, Observer o) {
200199 // very crude observer storage for now; results in o(n) per preference
201200 // cost when updating preferences
202 Observer[] obs = (Observer[])observers.get(prefix);
201 Observer[] obs = observers.get(prefix);
203202 if (obs == null)
204203 obs = new Observer[] { o };
205204 else
206 obs = (Observer[])DynamicArray.append(obs, o);
205 obs = DynamicArray.append(obs, o);
207206 observers.put(prefix, obs);
208207 }
209208
234233 * @see #addObserver
235234 */
236235 public void removeObserver(String prefix, Observer o) {
237 Observer[] obs = (Observer[])observers.get(prefix);
236 Observer[] obs = observers.get(prefix);
238237 if (obs != null) {
239 obs = (Observer[])DynamicArray.remove(obs, o);
238 obs = DynamicArray.remove(obs, o);
240239 observers.put(prefix, obs);
241240 }
242241 }
261260 * Access method for props to be used by PreferencesPane
262261 * @return props
263262 */
264 Properties getProperties() {
263 Map<String, String> getProperties() {
265264 return props;
266265 }
267266
268267 private File prefsFile;
269 private Properties props;
270 private Hashtable observers = new Hashtable();
268 private Map<String, String> props;
269 private Map<String, Observer[]> observers = new Hashtable<>();
271270 private boolean isUpToDate;
272271 private long fileModifiedTime;
273272
112112 * @param m the map from which to load the user preferences into the
113113 * GUI components
114114 */
115 public void load(Map m) {
115 public void load(Map<String, String> m) {
116116 PreferencesPane[] p = getChildPanes();
117117 if (p != null) {
118118 for (int i = 0; i < p.length; i++)
126126 * @param m the map to which to save the user preferences from the
127127 * GUI components
128128 */
129 public void save(Map m) {
129 public void save(Map<String, String> m) {
130130 PreferencesPane[] p = getChildPanes();
131131 if (p != null) {
132132 for (int i = 0; i < p.length; i++)
447447 }
448448
449449 private void setPreferences(PreferencesPane[] panes) {
450 Map m = new Map() {
450 Map<String, String> m = new Map<String, String>() {
451451
452452 public void clear() {
453453 throw new UnsupportedOperationException();
461461 return props.containsValue(value);
462462 }
463463
464 public Set entrySet() {
464 public Set<Map.Entry<String, String>> entrySet() {
465465 return props.entrySet();
466466 }
467467
469469 return props.equals(o);
470470 }
471471
472 public Object get(Object key) {
472 public String get(Object key) {
473473 return props.get(key);
474474 }
475475
481481 return props.isEmpty();
482482 }
483483
484 public Set keySet() {
484 public Set<String> keySet() {
485485 return props.keySet();
486486 }
487487
488 public Object put(Object key, Object value) {
489 Object oldValue = props.get(key);
488 public String put(String key, String value) {
489 String oldValue = props.get(key);
490490 if (oldValue == null || !oldValue.equals(value)) {
491 preferences.setPreference((String) key, (String) value);
491 preferences.setPreference(key, value);
492492 }
493493 return oldValue;
494494 }
495495
496 public void putAll(Map m) {
496 public void putAll(Map<? extends String, ? extends String> m) {
497497 throw new UnsupportedOperationException();
498498 }
499499
500 public Object remove(Object key) {
500 public String remove(Object key) {
501501 throw new UnsupportedOperationException();
502502 }
503503
505505 return props.size();
506506 }
507507
508 public Collection values() {
508 public Collection<String> values() {
509509 return props.values();
510510 }
511511 };
568568
569569 private JFrame owner;
570570 private Preferences preferences;
571 private Properties props;
571 private Map<String, String> props;
572572
573573 private HelpBroker helpBroker;
574574 private PreferencesPane[] panes;
169169 public void windowClosed(WindowEvent e) {
170170 JFrame f = (JFrame) (e.getSource());
171171 //removeToolMenuItemsFromFrameMenuBar(f);
172 frames = (JFrame[]) (DynamicArray.remove(frames, f));
172 frames = DynamicArray.remove(frames, f);
173173
174174 if (f.getContentPane() instanceof Tool) {
175175 Tool t = (Tool) (f.getContentPane());
193193 //f.setLocation(screenSize.width/2 - size.width/2, screenSize.height/2 - size.height/2);
194194 f.setVisible(visible);
195195
196 frames = (JFrame[]) (DynamicArray.append(frames, f));
196 frames = DynamicArray.append(frames, f);
197197
198198 t.setDeskView(this);
199199
205205 public void removeTool(Tool t) {
206206 //System.err.println("SDI: remove " + t);
207207 JFrame f = getFrameForTool(t);
208 frames = (JFrame[]) (DynamicArray.remove(frames, f)); // remove it from list of frames
208 frames = DynamicArray.remove(frames, f); // remove it from list of frames
209209 f.setVisible(false); // hide it before we start disassembling it
210210
211211 removeToolMenuItemsFromFrameMenuBar(f, t);
281281 return d;
282282 }
283283
284 protected void saveDesktop(Map m) {
285 saveBounds(console, new PrefixMap(m, "dt.console"));
284 protected void saveDesktop(Map<String, String> m) {
285 saveBounds(console, new PrefixMap<>(m, "dt.console"));
286286 saveTools(m);
287287 }
288288
289 protected void restoreDesktop(Map m) {
290 restoreBounds(console, new PrefixMap(m, "dt.console"));
289 protected void restoreDesktop(Map<String, String> m) {
290 restoreBounds(console, new PrefixMap<>(m, "dt.console"));
291291 restoreTools(m);
292292 }
293293
294 protected void saveTool(Map m, Tool t) {
294 protected void saveTool(Map<String, String> m, Tool t) {
295295 super.saveTool(m, t);
296 saveBounds(getFrameForTool(t), new PrefixMap(m, "dt"));
297 }
298
299 protected Tool restoreTool(Map m, String name) throws Fault, ToolManager.Fault
296 saveBounds(getFrameForTool(t), new PrefixMap<>(m, "dt"));
297 }
298
299 protected Tool restoreTool(Map<String, String> m, String name) throws Fault, ToolManager.Fault
300300 {
301301 Tool t = super.restoreTool(m, name);
302 restoreBounds(getFrameForTool(t), new PrefixMap(m, "dt"));
302 restoreBounds(getFrameForTool(t), new PrefixMap<>(m, "dt"));
303303 return t;
304304 }
305305
8282
8383 // perhaps would be nice to have getTools(Comparator) and have it return a sorted
8484 // array of tools
85 Arrays.sort(tools, new Comparator() {
86 public int compare(Object o1, Object o2) {
87 Long l1 = new Long(((Tool)o1).getCreationTime());
88 Long l2 = new Long(((Tool)o2).getCreationTime());
85 Arrays.sort(tools, new Comparator<Tool>() {
86 public int compare(Tool o1, Tool o2) {
87 Long l1 = new Long(o1.getCreationTime());
88 Long l2 = new Long(o2.getCreationTime());
8989 return (l1.compareTo(l2));
9090 }
9191 });
192192 KeyboardFocusManager fm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
193193 Component fo = fm.getPermanentFocusOwner();
194194 if (fo == null || !fo.isShowing()) {
195 Container target = (contents.getTabCount() > 0 ? (Container) contents : (Container) mainFrame);
195 Container target = contents.getTabCount() > 0 ? contents : mainFrame;
196196 Container fcr = (target.isFocusCycleRoot() ? target : target.getFocusCycleRootAncestor());
197197 FocusTraversalPolicy ftp = fcr.getFocusTraversalPolicy();
198198 Component c = (target.isFocusable() ? target : ftp.getComponentAfter(fcr, target));
327327 return d;
328328 }
329329
330 protected void saveDesktop(Map m) {
331 saveBounds(mainFrame, new PrefixMap(m, "dt"));
330 protected void saveDesktop(Map<String, String> m) {
331 saveBounds(mainFrame, new PrefixMap<>(m, "dt"));
332332 saveTools(m);
333333 int sel = contents.getSelectedIndex();
334334 if (sel >= 0)
335335 m.put("dt.selected", String.valueOf(sel));
336336 }
337337
338 protected void restoreDesktop(Map m) {
339 restoreBounds(mainFrame, new PrefixMap(m, "dt"));
338 protected void restoreDesktop(Map<String, String> m) {
339 restoreBounds(mainFrame, new PrefixMap<>(m, "dt"));
340340 if (getDesktop().getRestoreOnStart()) {
341341 restoreTools(m);
342342
343343 try {
344 String s = (String) (m.get("dt.selected"));
344 String s = m.get("dt.selected");
345345 if (s != null) {
346346 int sel = Integer.parseInt(s);
347347 if (0 <= sel && sel < contents.getTabCount()) {
380380 }
381381
382382 private String getUniqueTabTitle(String base, Component ignoreable) {
383 Set s = new HashSet();
383 Set<String> s = new HashSet<>();
384384 for (int i = 0; i < contents.getTabCount(); i++) {
385385 if (contents.getComponentAt(i) != ignoreable)
386386 s.add(contents.getTitleAt(i));
8282 * @see #removeObserver
8383 */
8484 synchronized public void addObserver(Observer o) {
85 observers = (Observer[])DynamicArray.append(observers, o);
85 observers = DynamicArray.append(observers, o);
8686 }
8787
8888 /**
9292 * @see #addObserver
9393 */
9494 synchronized public void removeObserver(Observer o) {
95 observers = (Observer[])DynamicArray.remove(observers, o);
95 observers = DynamicArray.remove(observers, o);
9696 }
9797
9898 //--------------------------------------------------------------------------
309309 * @param m the map in which to store the significant state
310310 * of the tool
311311 */
312 protected abstract void save(Map m);
312 protected abstract void save(Map<String, String> m);
313313
314314
315315 /**
318318 * @param m the map in which to store the significant state
319319 * of the tool
320320 */
321 protected abstract void restore(Map m);
321 protected abstract void restore(Map<String, String> m);
322322
323323
324324 /**
387387 if (toolDialogs == null)
388388 return new ToolDialog[0];
389389
390 ArrayList l = new ArrayList();
391 for (Iterator iter = toolDialogs.iterator(); iter.hasNext(); ) {
392 WeakReference r = (WeakReference) (iter.next());
393 ToolDialog td = (ToolDialog) (r.get());
390 ArrayList<ToolDialog> l = new ArrayList<>();
391 for (Iterator<WeakReference<ToolDialog>> iter = toolDialogs.iterator(); iter.hasNext(); ) {
392 WeakReference<ToolDialog> r = iter.next();
393 ToolDialog td = r.get();
394394 if (td == null)
395395 iter.remove();
396396 else
397397 l.add(td);
398398 }
399399
400 return (ToolDialog[]) (l.toArray(new ToolDialog[l.size()]));
400 return l.toArray(new ToolDialog[l.size()]);
401401 }
402402
403403 /**
409409 throw new NullPointerException();
410410
411411 if (toolDialogs == null)
412 toolDialogs = new ArrayList();
413
414 toolDialogs.add(new WeakReference(td));
412 toolDialogs = new ArrayList<>();
413
414 toolDialogs.add(new WeakReference<>(td));
415415 }
416416
417417 void setDeskView(DeskView view) {
431431 private String shortTitle;
432432 private String helpID;
433433 private long creationTime;
434 private List toolDialogs;
434 private List<WeakReference<ToolDialog>> toolDialogs;
435435 private DeskView deskView;
436436 private Observer[] observers = new Observer[0];
437437 private static int toolIndex;
162162 }
163163 else {
164164 if (misc == null)
165 misc = new HashMap();
165 misc = new HashMap<>();
166166 oldVal = misc.get(key);
167167 if (equal(newVal, oldVal))
168168 return;
188188 }
189189
190190 public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
191 listeners = (WeakReference[]) DynamicArray.append(listeners, new WeakReference(listener));
191 listeners = DynamicArray.append(listeners, new WeakReference<>(listener));
192192 }
193193
194194 public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
195 WeakReference[] l = listeners;
195 WeakReference<PropertyChangeListener>[] l = listeners;
196196 int size = l.length;
197197 for (int i = size - 1; i >= 0; i--) {
198198 if (l[i].get() == listener)
207207
208208 private void firePropertyChangeEvent(String name, Object oldVal, Object newVal) {
209209 PropertyChangeEvent ev = null; // lazy create event if needed
210 WeakReference[] l = listeners;
210 WeakReference<PropertyChangeListener>[] l = listeners;
211211 if (l.length > 0) {
212212 for (int i = l.length - 1; i >= 0; i--) {
213 PropertyChangeListener pcl = (PropertyChangeListener) (l[i].get());
213 PropertyChangeListener pcl = (l[i].get());
214214 if (pcl != null) {
215215 if (ev == null)
216216 ev = new PropertyChangeEvent(this, name, oldVal, newVal);
235235 private String desc;
236236 private Integer mnemonic;
237237 private Icon icon;
238 private Map misc;
238 private Map<String, Object> misc;
239239 private boolean enabled = true;
240240
241 private WeakReference[] listeners = new WeakReference[0];
241 private WeakReference<PropertyChangeListener>[] listeners = new WeakReference[0];
242242 }
250250 if (dialog instanceof Window) {
251251 return dialog;
252252 }
253 return (Frame) (SwingUtilities.getAncestorOfClass(Frame.class, dialog));
253 return SwingUtilities.getAncestorOfClass(Frame.class, dialog);
254254 }
255255
256256 /**
196196 * @return the tool that was started
197197 * @throws ToolManager.Fault if there is a problem restoring the tool
198198 */
199 public abstract Tool restoreTool(Map m) throws Fault;
199 public abstract Tool restoreTool(Map<String, String> m) throws Fault;
200200
201201 //----------------------------------------------------------------------------
202202
411411 * @param c the class used to determine the i18n properties
412412 * @param helpBroker the help broker to be used when creating help buttons
413413 */
414 public UIFactory(Class c, HelpBroker helpBroker) {
414 public UIFactory(Class<?> c, HelpBroker helpBroker) {
415415 this(c, null, helpBroker);
416416 }
417417
436436 * @param p the parent component to be used for any dialogs that are created
437437 * @param helpBroker the help broker to be used when creating help buttons
438438 */
439 public UIFactory(Class c, Component p, HelpBroker helpBroker) {
439 public UIFactory(Class<?> c, Component p, HelpBroker helpBroker) {
440440 this.helpBroker = helpBroker;
441441 clientClass = c;
442442 parent = p;
11601160 * @return the choice item that was created
11611161 * @see #createLiteralChoice
11621162 */
1163 public JComboBox createChoice(final String uiKey, final String[] choiceKeys) {
1163 public JComboBox<String> createChoice(final String uiKey, final String[] choiceKeys) {
11641164 return createChoice(uiKey, choiceKeys, false);
11651165 }
11661166
11781178 * @return a choice box with the attributes indicated by the parameters
11791179 * @see #createChoice(String,String[])
11801180 */
1181 public JComboBox createChoice(final String uiKey, final String[] choiceKeys, boolean editable) {
1181 public JComboBox<String> createChoice(final String uiKey, final String[] choiceKeys, boolean editable) {
11821182 // create a cache of the presentation string, for use when
11831183 // rendering, but otherwise, let the JComboBox work in terms of the
11841184 // choiceKeys
11861186 for (int i = 0; i < choices.length; i++)
11871187 choices[i] = getI18NString(uiKey + "." + choiceKeys[i] + ".chc");
11881188
1189 JComboBox choice = new JComboBox(choiceKeys);
1189 JComboBox<String> choice = new JComboBox<>(choiceKeys);
11901190 choice.setName(uiKey);
11911191 setToolTip(choice, uiKey);
11921192 setAccessibleName(choice, uiKey);
12051205 }
12061206
12071207 choice.setRenderer(new DefaultListCellRenderer() {
1208 public Component getListCellRendererComponent(JList list, Object o, int index,
1208 public Component getListCellRendererComponent(JList<?> list, Object o, int index,
12091209 boolean isSelected, boolean cellHasFocus) {
12101210 Object c = o;
12111211 for (int i = 0; i < choiceKeys.length; i++) {
12311231 * @param uiKey the base name of the resources to be used for the menu
12321232 * @return the choice component that was created
12331233 */
1234 public JComboBox createChoice(String uiKey) {
1234 public <E> JComboBox<E> createChoice(String uiKey) {
12351235 return createChoice(uiKey, false);
12361236 }
12371237
12441244 * @return the choice component that was created
12451245 * @see #createChoice(String)
12461246 */
1247 public JComboBox createChoice(String uiKey, boolean editable) {
1248 return createChoice(uiKey, editable, (JLabel) null);
1247 public <E> JComboBox<E> createChoice(String uiKey, boolean editable) {
1248 return createChoice(uiKey, editable, null);
12491249 }
12501250
12511251 /**
12571257 * @see #createChoice(String)
12581258 * @see javax.swing.JLabel#setLabelFor
12591259 */
1260 public JComboBox createChoice(String uiKey, JLabel label) {
1260 public <E> JComboBox<E> createChoice(String uiKey, JLabel label) {
12611261 return createChoice(uiKey, false, label);
12621262 }
12631263
12741274 * @see #createChoice(String)
12751275 * @see javax.swing.JLabel#setLabelFor
12761276 */
1277 public JComboBox createChoice(String uiKey, boolean editable, JLabel label) {
1278 JComboBox choice = new JComboBox();
1277 public <E> JComboBox<E> createChoice(String uiKey, boolean editable, JLabel label) {
1278 JComboBox<E> choice = new JComboBox<>();
12791279 choice.setName(uiKey);
12801280 setToolTip(choice, uiKey);
12811281
13181318 * @return the choice item that was created
13191319 * @see #createChoice
13201320 */
1321 public JComboBox createLiteralChoice(String uiKey, Object[] choices) {
1322 JComboBox choice = new JComboBox(choices);
1321 public <E> JComboBox<E> createLiteralChoice(String uiKey, E[] choices) {
1322 JComboBox<E> choice = new JComboBox<>(choices);
13231323 choice.setName(uiKey);
13241324 setToolTip(choice, uiKey);
13251325 return choice;
14571457 * @param uiKey the base name of the resource to be used (currently ignored)
14581458 * @return the list that was created
14591459 */
1460 public JList createList(String uiKey) {
1461 JList list = new JList();
1460 public <E> JList<E> createList(String uiKey) {
1461 JList<E> list = new JList<>();
14621462 list.setName(uiKey);
14631463 setAccessibleInfo(list, uiKey);
14641464 return list;
14771477 * @param model the data model for this list
14781478 * @return the list that was created
14791479 */
1480 public JList createList(String uiKey, ListModel model) {
1481 JList list = new JList(model);
1480 public <E> JList<E> createList(String uiKey, ListModel<E> model) {
1481 JList<E> list = new JList<>(model);
14821482 list.setName(uiKey);
14831483 setAccessibleInfo(list, uiKey);
14841484 return list;
35513551 }
35523552 };
35533553
3554 private Class clientClass;
3554 private Class<?> clientClass;
35553555 private Component parent;
35563556 private I18NResourceBundle i18n;
35573557 private HelpBroker helpBroker;
35703570 */
35713571 public static class UIFactoryExt extends UIFactory {
35723572 private I18NResourceBundle i18n_alt;
3573 private Class altClass;
3574
3575 public UIFactoryExt(UIFactory uif, Class altClass) {
3573 private Class<?> altClass;
3574
3575 public UIFactoryExt(UIFactory uif, Class<?> altClass) {
35763576 super(uif.clientClass, uif.parent, uif.helpBroker);
35773577 i18n_alt = I18NResourceBundle.getBundleForClass(altClass);
35783578 this.altClass = altClass;
6464
6565 private static void ensureAllOptionsInitialized() {
6666 if (allOptions == null) {
67 allOptions = new TreeMap();
67 allOptions = new TreeMap<>();
6868 allOptions.put(MAX, new HelpTree.Node(i18n, "verb.max"));
6969 allOptions.put(QUIET, new HelpTree.Node(i18n, "verb.quiet"));
7070 }
7171 }
72 private static Map allOptions;
72 private static Map<String, HelpTree.Node> allOptions;
7373
7474 //--------------------------------------------------------------------------
7575
121121 }
122122
123123 public void run(CommandContext ctx) throws Fault {
124 for (Iterator iter = optionValues.entrySet().iterator(); iter.hasNext(); ) {
125 Map.Entry e = (Map.Entry) (iter.next());
126 String name = (String) (e.getKey());
127 boolean value = ((Boolean) (e.getValue())).booleanValue();
124 for (Map.Entry<String, Boolean> e : optionValues.entrySet()) {
125 String name = (e.getKey());
126 boolean value = e.getValue().booleanValue();
128127 if (name.equalsIgnoreCase(MAX))
129128 ctx.setVerboseMax(value);
130129 else if (name.equalsIgnoreCase(QUIET))
141140
142141 HelpTree.Node[] nodes = new HelpTree.Node[allOptions.size()];
143142 int i = 0;
144 for (Iterator iter = allOptions.values().iterator(); iter.hasNext(); )
145 nodes[i++] = (HelpTree.Node) (iter.next());
143 for (Iterator<HelpTree.Node> iter = allOptions.values().iterator(); iter.hasNext(); )
144 nodes[i++] = iter.next();
146145
147146 return new HelpTree.Node(i18n, "verb", nodes);
148147 }
151150 return CMD;
152151 }
153152
154 private HashMap optionValues = new HashMap(); // HashMap<name,boolean>
153 private Map<String, Boolean> optionValues = new HashMap<>();
155154
156155 private static final String CMD = "verbose";
157156 private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(VerboseCommand.class);
265265 private SelectedWorkDirApprover swda;
266266
267267 private Dimension size;
268 private LinkedHashMap fileData;
269 private LinkedHashMap wdData;
268 private Map<String, String[]> fileData;
269 private Map<String, Boolean> wdData;
270270
271271 public String getName(File f) {
272272 String retValue;
284284
285285
286286 private boolean isWorkDir(File dir) {
287 if (wdData == null) wdData = new LinkedHashMap() {
288 protected boolean removeEldestEntry(Map.Entry eldest) {
287 if (wdData == null) wdData = new LinkedHashMap<String, Boolean>() {
288 protected boolean removeEldestEntry(Map.Entry<String, Boolean> eldest) {
289289 return size() > 500;
290290 }
291291 };
296296 }
297297
298298 String key = dir.getAbsolutePath();
299 Boolean value = (Boolean) wdData.get(key);
299 Boolean value = wdData.get(key);
300300 if (value != null) {
301301 return value.booleanValue();
302302 }
307307
308308 private String[] getInfo(File file) {
309309
310 if (fileData == null) fileData = new LinkedHashMap() {
311 protected boolean removeEldestEntry(Map.Entry eldest) {
310 if (fileData == null) fileData = new LinkedHashMap<String, String[]>() {
311 protected boolean removeEldestEntry(Map.Entry<String, String[]> eldest) {
312312 return size() > 500;
313313 }
314314 };
315315 String key = file.getAbsolutePath();
316 String[] value = (String[]) fileData.get(key);
316 String[] value = fileData.get(key);
317317 if (value != null) {
318318 return value;
319319 }
3434 import java.net.URLConnection;
3535 import java.util.ArrayList;
3636 import java.util.HashMap;
37 import java.util.Map;
3738
3839 public class HelpSet {
3940
154155 return result;
155156 }
156157
157 public HashMap<String, URL> getLocalMap() {
158 public Map<String, URL> getLocalMap() {
158159 return localMap;
159160 }
160161
128128 File helpVersion = new File(destDir, HELP_VERSION_NAME);
129129
130130 JarFile jar = new JarFile(jarFile);
131 Enumeration enumEntries = jar.entries();
131 Enumeration<JarEntry> enumEntries = jar.entries();
132132
133133 int total = 0;
134134 while (enumEntries.hasMoreElements()) {
135 JarEntry file = (JarEntry) enumEntries.nextElement();
135 JarEntry file = enumEntries.nextElement();
136136 if (isHelpFile(file)) {
137137 total++;
138138 }
149149 enumEntries = jar.entries();
150150
151151 while (enumEntries.hasMoreElements()) {
152 JarEntry file = (JarEntry) enumEntries.nextElement();
152 JarEntry file = enumEntries.nextElement();
153153 File f = new java.io.File(destDir + java.io.File.separator + file.getName());
154154 if (isHelpFile(file)) {
155155 f.getParentFile().mkdirs();
3535 public class JTHelpProgressBar extends Component implements PropertyChangeListener {
3636
3737 private JProgressBar progressBar;
38 private SwingWorker task;
38 private SwingWorker<Void, Void> task;
3939 private JDialog frame;
4040 private JPanel сontentPane;
4141 private UIFactory uif;
4242
4343
44 public JTHelpProgressBar(SwingWorker progressTask) {
44 public JTHelpProgressBar(SwingWorker<Void, Void> progressTask) {
4545 uif = new UIFactory(this, null);
4646
4747 task = progressTask;
582582 SelectionTreeNode lastNode = firstNode;
583583
584584 while (lastNode.getChildCount() > 0) {
585 lastNode = (SelectionTreeNode) lastNode.getChildAt(lastNode.getChildCount() - 1);
585 lastNode = lastNode.getChildAt(lastNode.getChildCount() - 1);
586586 }
587587
588588 if (!isRootVisible()) {
713713 }
714714
715715 public String[] getSelection() {
716 Vector v = new Vector();
716 Vector<String> v = new Vector<>();
717717 getSelection((SelectionTreeNode) getModel().getRoot(), v);
718718
719719 String[] paths = new String[v.size()];
721721 return paths;
722722 }
723723
724 private void getSelection(SelectionTreeNode node, Vector v) {
724 private void getSelection(SelectionTreeNode node, Vector<String> v) {
725725 switch (node.getSelectionType()) {
726726 case UNSELECTED:
727727 break;
100100 prevNode = node;
101101 int childCount;
102102 while ((childCount = prevNode.getChildCount()) > 0) {
103 prevNode = (SelectionTreeNode) prevNode.getChildAt(childCount - 1);
103 prevNode = prevNode.getChildAt(childCount - 1);
104104 }
105105 children.add(node);
106106 }
293293 }
294294 } else {
295295 depth++;
296 result = getPathToRoot((SelectionTreeNode) aNode.getParent(), depth);
296 result = getPathToRoot(aNode.getParent(), depth);
297297 result[result.length - depth] = aNode;
298298 }
299299
8383 String prefix = file.getName() + "~";
8484 String suffix = "~";
8585 int maxBackupIndex = 0;
86 Vector backups = new Vector();
86 Vector<Integer> backups = new Vector<>();
8787 nextFile:
8888 if (dirFiles != null) {
8989 for (int i = 0; i < dirFiles.length; i++) {
115115 // delete old backups
116116 int numBackupsToKeep = getNumBackupsToKeep(file);
117117 for (int i = 0; i < backups.size(); i++) {
118 int index = ((Integer)(backups.elementAt(i))).intValue();
118 int index = (backups.elementAt(i)).intValue();
119119 if (index <= (maxBackupIndex-numBackupsToKeep)) {
120120 File backupToGo = new File(file.getPath() + "~" + index + "~");
121121 // let SecurityExceptions out, but otherwise ignore failures
2727
2828 import java.io.File;
2929 import java.util.HashSet;
30 import java.util.Set;
3031 import java.util.Vector;
3132 import java.io.FileFilter;
3233 import java.io.IOException;
6566 String prefix = file.getName() + "~";
6667 String suffix = "~";
6768 int maxBackupIndex = 0;
68 Vector backups = new Vector();
69 Vector<Integer> backups = new Vector<>();
6970
7071 boolean renamed;
7172 java.util.Arrays.sort(list);
99100
100101 int maxIndex = 0;
101102 for(int j = 0; j < backups.size(); j++) {
102 int index = ((Integer)backups.get(j)).intValue();
103 int index = backups.get(j).intValue();
103104 maxIndex = index > maxIndex ? index : maxIndex;
104105 if(index > maxBackups) {
105106 File oldBackup = new File(filename + "~" + backups.get(j) + "~");
132133 String prefix = file.getName() + "~";
133134 String suffix = "~";
134135 int maxBackupIndex = 0;
135 Vector backups = new Vector();
136 Vector<Integer> backups = new Vector<>();
136137
137138 java.util.Arrays.sort(list);
138139 for (int i = list.length - 1; i >= 0; i--) {
166167 // backups.addElement(new Integer(1));
167168
168169 for(int j = 0; j < backups.size(); j++) {
169 int index = ((Integer)backups.get(j)).intValue();
170 int index = backups.get(j).intValue();
170171 if(index > maxBackups) {
171172 File oldBackup = new File(filename + "~" + backups.get(j) + "~");
172173 deleteDir(oldBackup);
191192 return;
192193 }
193194
194 HashSet layers = new HashSet();
195 Set<Integer> layers = new HashSet<>();
195196 String suffix = "~";
196197 for(int i = 0; i < files.length; i++) {
197198 if(files[i].isDirectory()) {
131131 * a return value of zero.
132132 * @return the debugging setting for the specified class
133133 */
134 public static boolean getBoolean(Class c) {
134 public static boolean getBoolean(Class<?> c) {
135135 init(false);
136136
137137 if (!masterSwitch)
155155 * of just the classname.
156156 * @return the debugging setting for the specified class
157157 */
158 public static boolean getBoolean(Class c, String suffix) {
158 public static boolean getBoolean(Class<?> c, String suffix) {
159159 init(false);
160160
161161 if (!masterSwitch)
199199 * @return the debugging setting for the given class, or 0 if no class
200200 * was specified
201201 */
202 public static int getInt(Class c) {
202 public static int getInt(Class<?> c) {
203203 init(false);
204204
205205 if (!masterSwitch || c == null)
223223 * null will result in a lookup of just the classname.
224224 * @return the debugging setting for the class
225225 */
226 public static int getInt(Class c, String suffix) {
226 public static int getInt(Class<?> c, String suffix) {
227227 init(false);
228228
229229 if (!masterSwitch || c == null)
316316 return;
317317 }
318318
319 Enumeration keys = props.propertyNames();
319 Enumeration<?> keys = props.propertyNames();
320320
321321 dProps = new Properties();
322322 wildProps = new WildcardProperties();
347347 *
348348 * @param c Must not be null.
349349 */
350 private static String getName(Class c) {
350 private static String getName(Class<?> c) {
351351 // null checking skipped
352352
353353 String name = c.getName();
454454 String lowerKey = key.toLowerCase();
455455 String target = trimTarget(lowerKey);
456456
457 Enumeration keys = propertyNames();
457 Enumeration<?> keys = propertyNames();
458458 while (keys.hasMoreElements()) {
459459 String k = (String)(keys.nextElement());
460460 String lowerK = k.toLowerCase();
3232 import java.io.IOException;
3333 import java.net.URL;
3434 import java.util.Hashtable;
35 import java.util.Map;
3536
3637 /**
3738 * This class loader loads classes from files a specified directory.
7172 * @return the class that was loaded
7273 * @throws ClassNotFoundException if the class was not found.
7374 */
74 protected Class loadClass(String name, boolean resolve)
75 protected Class<?> loadClass(String name, boolean resolve)
7576 throws ClassNotFoundException {
7677
7778 // check the cache first
78 Class cl = (Class)classes.get(name);
79 Class<?> cl = classes.get(name);
7980
8081 // not found in the cache?
8182 if (cl == null) {
171172
172173 //----------internal methods------------------------------------------------
173174
174 private synchronized Class locateClass(String name)
175 private synchronized Class<?> locateClass(String name)
175176 throws ClassNotFoundException {
176177 //This check is currently necessary; we just
177178 // check the cache at the one call site, but that was not
178179 // synchronized, so there is a very small remote chance another
179180 // caller has just loaded this class.
180 Class cl = (Class)classes.get(name);
181 Class<?> cl = classes.get(name);
181182 if (cl != null)
182183 return cl;
183184
186187 File file = new File(loadDir, cname);
187188
188189 try {
189 InputStream in = new FileInputStream(file);
190190 byte[] data;
191 try {
191 try (InputStream in = new FileInputStream(file)) {
192192 int len = in.available();
193193 data = new byte[len];
194194 for (int total = 0; total < data.length; ) {
195195 total += in.read(data, total, data.length - total);
196196 }
197197 }
198 finally {
199 if (in != null)
200 in.close();
201 }
202198 // the next line may throw LinkageError, which we let
203199 // escape to the caller
204200 cl = defineClass(name, data, 0, data.length);
221217 //----------Data members----------------------------------------------------
222218
223219 private File loadDir;
224 private Hashtable classes = new Hashtable();
220 private Map<String, Class<?>> classes = new Hashtable<>();
225221 }
4747 * @throws IllegalArgumentException If newObj is null.
4848 * @throws ArrayStoreException If there is a type mismatch between oldArr and newObj.
4949 */
50 public static Object[] append(Object[] oldArr, Object newObj) {
51 Object[] newArr;
50 public static <T> T[] append(T[] oldArr, T newObj) {
51 T[] newArr;
5252
5353 if (oldArr == null) {
5454 if (newObj != null) {
55 newArr = (Object[])(Array.newInstance(newObj.getClass(), 1));
55 newArr = (T[])(Array.newInstance(newObj.getClass(), 1));
5656 newArr[0] = newObj;
5757 }
5858 else {
6060 }
6161 }
6262 else {
63 newArr = (Object[])(Array.newInstance(getArrayClass(oldArr), oldArr.length+1));
63 newArr = (T[])(Array.newInstance(getArrayClass(oldArr), oldArr.length+1));
6464 System.arraycopy(oldArr, 0, newArr, 0, oldArr.length);
6565 newArr[newArr.length-1] = newObj;
6666 }
7979 * @throws IllegalArgumentException If newObj is null.
8080 * @throws ArrayStoreException If there is a type mismatch between oldArr and newObj.
8181 */
82 public static Object[] append(Object[] oldArr, Object newObj, Class arrayClass) {
83 Object[] localArr;
82 public static <T> T[] append(T[] oldArr, T newObj, Class<? extends T> arrayClass) {
83 T[] localArr;
8484
8585 if (oldArr == null && arrayClass != null)
86 localArr = (Object[])(Array.newInstance(arrayClass, 0));
86 localArr = (T[])(Array.newInstance(arrayClass, 0));
8787 else
8888 localArr = oldArr;
8989
9999 * the first array, containing the elements of the first array, followed
100100 * by the elements of the second array.
101101 */
102 public static Object[] join(Object[] array1, Object[] array2) {
102 public static <T> T[] join(T[] array1, T[] array2) {
103103 if (array1 == null)
104104 return array2;
105105
106106 if (array2 == null)
107107 return array1;
108108
109 Class type = array1.getClass().getComponentType();
109 Class<?> type = array1.getClass().getComponentType();
110110 int size = array1.length + array2.length;
111 Object[] newArray = (Object[]) Array.newInstance(type, size);
111 T[] newArray = (T[]) Array.newInstance(type, size);
112112 System.arraycopy(array1, 0, newArray, 0, array1.length);
113113 System.arraycopy(array2, 0, newArray, array1.length, array2.length);
114114 return newArray;
126126 * operation.
127127 * @return A new array with the object inserted into it at the specified location.
128128 */
129 public static Object[] insert(Object[] oldArr, Object newObj, int location) {
130 Object[] newArr;
129 public static <T> T[] insert(T[] oldArr, T newObj, int location) {
130 T[] newArr;
131131
132132 if (oldArr == null) {
133133 if (newObj != null) {
134 newArr = (Object[])(Array.newInstance(newObj.getClass(), 1));
134 newArr = (T[])(Array.newInstance(newObj.getClass(), 1));
135135 newArr[0] = newObj;
136136 }
137137 else {
142142 if (location > oldArr.length)
143143 throw new IllegalArgumentException("Index location too large (" + location +
144144 ").");
145 newArr = (Object[])(Array.newInstance(getArrayClass(oldArr), oldArr.length+1));
145 newArr = (T[])(Array.newInstance(getArrayClass(oldArr), oldArr.length+1));
146146
147147 if (location == 0) {
148148 newArr[0] = newObj;
176176 * @exception ArrayStoreException May occur if all the objects in the
177177 * array do not match.
178178 */
179 public static Object[] remove(Object[] oldArr, int index) {
180 Object[] newArr;
179 public static <T> T[] remove(T[] oldArr, int index) {
180 T[] newArr;
181181
182182 if (oldArr == null)
183183 throw new IllegalArgumentException("Cannot remove from null array.");
187187 }
188188 else if (index == 0) {
189189 // chop the head
190 newArr = (Object[])(Array.newInstance(getArrayClass(oldArr), oldArr.length-1));
190 newArr = (T[])(Array.newInstance(getArrayClass(oldArr), oldArr.length-1));
191191 System.arraycopy(oldArr, 1, newArr, 0, oldArr.length-1);
192192 }
193193 else if (index == oldArr.length-1) {
194194 // chop the tail
195 newArr = (Object[])(Array.newInstance(getArrayClass(oldArr), oldArr.length-1));
195 newArr = (T[])(Array.newInstance(getArrayClass(oldArr), oldArr.length-1));
196196 System.arraycopy(oldArr, 0, newArr, 0, oldArr.length-1);
197197 }
198198 else {
199199 // chop the middle
200 newArr = (Object[])(Array.newInstance(getArrayClass(oldArr), oldArr.length-1));
200 newArr = (T[])(Array.newInstance(getArrayClass(oldArr), oldArr.length-1));
201201 System.arraycopy(oldArr, 0, newArr, 0, index);
202202 System.arraycopy(oldArr, index+1, newArr, index,
203203 oldArr.length-index-1);
215215 * @param victim The object to remove from the array. May be null.
216216 * @return Zero length array if the last element is removed.
217217 */
218 public static Object[] remove(Object[] oldArr, Object victim) {
219 Object[] newArr;
218 public static <T> T[] remove(T[] oldArr, T victim) {
219 T[] newArr;
220220
221221 if (oldArr == null) {
222222 newArr = oldArr;
241241 * @param target The reference to search for; can be null.
242242 * @return The array index of the target.
243243 */
244 public static int find(Object[] arr, Object target) {
244 public static <T> int find(T[] arr, T target) {
245245 int index = -1;
246246
247247 for(int i = 0; i < arr.length; i++) {
260260 * @param arr The array to examine.
261261 * @return The class of objects that the given array can hold.
262262 */
263 protected static Class getArrayClass(Object[] arr) {
263 protected static Class<?> getArrayClass(Object[] arr) {
264264 if(arr != null) {
265265 return arr.getClass().getComponentType();
266266 } else {
3030 * A simple variable length first-in first-out queue.
3131 */
3232
33 public class Fifo
33 public class Fifo<E>
3434 {
3535 /**
3636 * Create a buffer with a default initial size.
4747 */
4848 public Fifo(int initialSlots) {
4949 bufSize = initialSlots;
50 buf = new Object[bufSize];
50 buf = (E[]) new Object[bufSize];
5151 insertSlot = 0;
5252 removeSlot = 0;
5353 entries = 0;
7777 *
7878 * @param obj The object to be inserted. It must not be null.
7979 */
80 public synchronized void insert(Object obj) {
80 public synchronized void insert(E obj) {
8181 if (obj == null)
8282 throw new NullPointerException();
8383
8484 if (entries == bufSize) {
8585 int newBufSize = 2 * bufSize;
86 Object[] newBuf = new Object[newBufSize];
86 E[] newBuf = (E[]) new Object[newBufSize];
8787 int saveEntries = entries;
8888 for (int i = 0; entries > 0; i++) {
8989 newBuf[i] = remove();
106106 * @return The next object in line to be removed, if one is available,
107107 * or null if none are available.
108108 */
109 public synchronized Object remove() {
109 public synchronized E remove() {
110110 if (entries == 0)
111111 return null;
112112
113 Object o = buf[removeSlot];
113 E o = buf[removeSlot];
114114 buf[removeSlot] = null;
115115 removeSlot = (removeSlot + 1) % bufSize;
116116 entries--;
134134
135135 private final static int defaultInitialSlots = 16;
136136
137 private Object[] buf; // The circular array to hold the entries
137 private E[] buf; // The circular array to hold the entries
138138 private int bufSize; // The size of the array: buf.length
139139 private int insertSlot; // The next slot to store an entry
140140 private int removeSlot; // The next slot from which to remove an entry
3636 private final int SIZE = 500;
3737
3838 // we can't use generics in util package but this is actually Map<String, Boolean>
39 private Map map = Collections.synchronizedMap( new LinkedHashMap() {
40 protected boolean removeEldestEntry(Map.Entry eldest) {
39 private Map<String, Boolean> map = Collections.synchronizedMap( new LinkedHashMap<String, Boolean>() {
40 protected boolean removeEldestEntry(Map.Entry<String, Boolean> eldest) {
4141 return size() > SIZE;
4242 }
4343 });
4747 }
4848
4949 public Boolean get(File f) {
50 return (Boolean) map.get(f.getAbsolutePath());
50 return map.get(f.getAbsolutePath());
5151 }
5252
5353 public void clear() {
167167 this(node, null);
168168 }
169169
170 private Selection(Map map) {
170 private Selection(Map<Node, Selection> map) {
171171 this(null, map);
172172 }
173173
174 private Selection(Node node, Map map) {
174 private Selection(Node node, Map<Node, Selection> map) {
175175 this.node = node;
176176 this.map = map;
177177 }
178178
179179 private Node node;
180 private Map map;
180 private Map<Node, Selection> map;
181181 }
182182
183183 /**
200200 * @param node the node to be added to the tree
201201 */
202202 public void addNode(Node node) {
203 nodes = (Node[]) DynamicArray.append(nodes, node);
203 nodes = DynamicArray.append(nodes, node);
204204 }
205205
206206 /**
285285 }
286286
287287 private Selection find(String[] words, int mode) {
288 Map map = null;
288 Map<Node, Selection> map = null;
289289
290290 for (int i = 0; i < nodes.length; i++) {
291291 Node node = nodes[i];
292292 Selection s = find(node, words, mode);
293293 if (s != null) {
294294 if (map == null)
295 map = new TreeMap(nodeComparator);
295 map = new TreeMap<>(nodeComparator);
296296 map.put(node, s);
297297 }
298298 }
315315 if (node.children == null)
316316 return null;
317317
318 Map map = null;
318 Map<Node, Selection> map = null;
319319
320320 for (int i = 0; i < node.children.length; i++) {
321321 Node child = node.children[i];
322322 Selection s = find(child, words, mode);
323323 if (s != null) {
324324 if (map == null)
325 map = new TreeMap(nodeComparator);
325 map = new TreeMap<>(nodeComparator);
326326 map.put(child, s);
327327 }
328328 }
412412 return nodeComparator;
413413 }
414414
415 private void write(WrapWriter out, Map m) throws IOException {
415 private void write(WrapWriter out, Map<Node, Selection> m) throws IOException {
416416 int margin = out.getLeftMargin();
417 for (Iterator iter = m.entrySet().iterator(); iter.hasNext(); ) {
418 Map.Entry e = (Map.Entry) (iter.next());
419 Node node = (Node) (e.getKey());
420 Selection s = (Selection) (e.getValue());
417 for (Iterator<Map.Entry<Node, Selection>> iter = m.entrySet().iterator(); iter.hasNext(); ) {
418 Map.Entry<Node, Selection> e = iter.next();
419 Node node = (e.getKey());
420 Selection s = (e.getValue());
421421 if (s.map == null)
422422 write(out, node);
423423 else {
4848 * @param c the class for which to obtain the resource bundle
4949 * @return the appropriate resource bundle for the class
5050 */
51 public static I18NResourceBundle getBundleForClass(Class c) {
51 public static I18NResourceBundle getBundleForClass(Class<?> c) {
5252 String cn = c.getName();
5353 int dot = cn.lastIndexOf('.');
5454 String rn = (dot == -1 ? "i18n" : cn.substring(0, dot) + ".i18n");
169169 * Load the actual resource bundle, if it has not yet been loaded,
170170 * then hand the request off to that bundle.
171171 */
172 public Enumeration getKeys() {
172 public Enumeration<String> getKeys() {
173173 if (delegate == null) {
174174 delegate = AccessController.doPrivileged(
175175 new PrivilegedAction<ResourceBundle>() {
106106 private LineParser(File file, Reader in) {
107107 this.file = file;
108108 this.in = in;
109 currLine = new Vector();
109 currLine = new Vector<>();
110110 lineNumber = 1;
111111 ch = ' ';
112112 }
276276 private int ch;
277277 private int lineNumber;
278278 private StringBuffer currWord;
279 private Vector currLine;
279 private Vector<String> currLine;
280280
281281 private static final I18NResourceBundle i18n =
282282 I18NResourceBundle.getBundleForClass(LineParser.class);
2929 import java.applet.Applet;
3030 import java.util.Hashtable;
3131 import java.util.Enumeration;
32 import java.util.Map;
33 import java.util.Set;
3234
3335 /**
3436 * This class provides a means whereby tools can temporarily give access
4244
4345 private static AppletContext context = null;
4446
45 private static Hashtable applets = new Hashtable();
47 private static Map<String, Applet> applets = new Hashtable<>();
4648
4749 private static Applet agentApplet = null;
4850
8385 * @return the applet that has been registered with the given name
8486 */
8587 public static synchronized Applet getApplet(String name) {
86 return (Applet) applets.get(name);
88 return applets.get(name);
8789 }
8890
8991 /**
9092 * Get an enumeration of all the names that have been used to register applets.
9193 * @return an enumeration of all the names that have been used to register applets
9294 */
93 public static synchronized Enumeration getAppletNames() {
94 return applets.keys();
95 public static synchronized Set<String> getAppletNames() {
96 return applets.keySet();
9597 }
9698
9799 /**
3737 */
3838 public class OrderedTwoWayTable {
3939 public OrderedTwoWayTable() {
40 keys = new Vector();
41 values = new Vector();
40 keys = new Vector<>();
41 values = new Vector<>();
4242 }
4343
4444 /**
120120 * @param target the object to search for
121121 * @return the index of the target in the vector, or -1 if not found
122122 */
123 protected int findIndex(Vector data, Object target) {
123 protected int findIndex(Vector<?> data, Object target) {
124124 for (int i = 0; i < data.size(); i++)
125125 if (data.elementAt(i) == target)
126126 return i;
128128 return -1;
129129 }
130130
131 private Vector keys, values;
131 private Vector<Object> keys, values;
132132 }
133133
134134
3030 import java.io.InputStream;
3131 import java.io.IOException;
3232 import java.util.Hashtable;
33 import java.util.Map;
3334 import java.util.Vector;
3435 import java.util.zip.ZipEntry;
3536 import java.util.zip.ZipFile;
9091 * @return the class that was loaded
9192 * @throws ClassNotFoundException if the class was not found.
9293 */
93 protected Class loadClass(String name, boolean resolve)
94 throws ClassNotFoundException {
95
96 Class cl = (Class)classes.get(name);
94 protected Class<?> loadClass(String name, boolean resolve)
95 throws ClassNotFoundException {
96
97 Class<?> cl = classes.get(name);
9798
9899 if (cl == null) {
99100 try {
111112 }
112113
113114
114 private synchronized Class locateClass(String name)
115 private synchronized Class<?> locateClass(String name)
115116 throws ClassNotFoundException {
116117 //System.err.println("locateClass: " + name);
117 Class c = (Class)classes.get(name);
118 Class<?> c = classes.get(name);
118119 if (c != null)
119120 return c;
120121
133134 throw new ClassNotFoundException(name);
134135 }
135136
136 private Class locateClassInDir(String name, File dir)
137 private Class<?> locateClassInDir(String name, File dir)
137138 throws ClassNotFoundException {
138139 //System.err.println("locateClassInDir: " + name + " " + dir);
139140 String cname = name.replace('.', '/') + ".class";
147148 }
148149 }
149150
150 private Class locateClassInJar(String name, File jarFile)
151 private Class<?> locateClassInJar(String name, File jarFile)
151152 throws ClassNotFoundException {
152153 //System.err.println("locateClassInJar: " + name + " " + jarFile);
153154 String cname = name.replace('.', '/') + ".class";
154155 try {
155 ZipFile z = (ZipFile)zips.get(jarFile);
156 ZipFile z = zips.get(jarFile);
156157 if (z == null) {
157158 z = new ZipFile(jarFile);
158159 zips.put(jarFile, z);
168169 }
169170 }
170171
171 private Class readClass(String name, InputStream in, int size) throws IOException {
172 private Class<?> readClass(String name, InputStream in, int size) throws IOException {
172173 byte[] data = new byte[size];
173174 try {
174175 for (int total = 0; total < size; ) {
183184
184185 private File[] split(String s) {
185186 char pathCh = File.pathSeparatorChar;
186 Vector v = new Vector();
187 Vector<File> v = new Vector<>();
187188 int start = 0;
188189 for (int i = s.indexOf(pathCh); i != -1; i = s.indexOf(pathCh, start)) {
189190 add(s.substring(start, i), v);
196197 return path;
197198 }
198199
199 private void add(String s, Vector v) {
200 private void add(String s, Vector<File> v) {
200201 if (s.length() != 0)
201202 v.addElement(new File(s));
202203 }
203204
204205 private File[] path;
205 private Hashtable classes = new Hashtable();
206 private Hashtable zips = new Hashtable();
206 private Map<String, Class<?>> classes = new Hashtable<>();
207 private Map<File, ZipFile> zips = new Hashtable<>();
207208 }
3737 * A map whose entries are stored in a parent map by prefixing
3838 * the key names with a specific string.
3939 */
40 public class PrefixMap implements Map
40 public class PrefixMap<V> implements Map<String, V>
4141 {
4242 /**
4343 * Create a map whose entries are stored in a parent map
4646 * @param prefix the prefix with which to prefix the entries in the
4747 * parent map
4848 */
49 public PrefixMap(Map map, String prefix) {
49 public PrefixMap(Map<String, V> map, String prefix) {
5050 this.map = map;
5151 this.prefix = prefix + ".";
5252 }
5353
5454 public void clear() {
55 for (Iterator i = map.keySet().iterator(); i.hasNext(); ) {
56 String key = (String) (i.next());
55 for (Iterator<String> i = map.keySet().iterator(); i.hasNext(); ) {
56 String key = i.next();
5757 if (key.startsWith(prefix))
5858 i.remove();
5959 }
7979 }
8080
8181 public boolean containsValue(Object value) {
82 for (Iterator i = map.entrySet().iterator(); i.hasNext(); ) {
83 Map.Entry e = (Map.Entry) (i.next());
84 String key = (String) (e.getKey());
82 for (Iterator<Map.Entry<String, V>> i = map.entrySet().iterator(); i.hasNext(); ) {
83 Map.Entry<String, V> e = i.next();
84 String key = e.getKey();
8585 if (key.startsWith(prefix) && e.getValue().equals(value))
8686 return true;
8787 }
8888 return false;
8989 }
9090
91 public Set entrySet() {
92 Map m = new HashMap();
93 for (Iterator i = map.entrySet().iterator(); i.hasNext(); ) {
94 Map.Entry e = (Map.Entry) (i.next());
95 String key = (String) (e.getKey());
91 public Set<Map.Entry<String, V>> entrySet() {
92 Map<String, V> m = new HashMap<String, V>();
93 for (Iterator<Map.Entry<String, V>> i = map.entrySet().iterator(); i.hasNext(); ) {
94 Map.Entry<String, V> e = i.next();
95 String key = e.getKey();
9696 if (key.startsWith(prefix))
9797 m.put(key.substring(prefix.length()), e.getValue());
9898 }
9999 return m.entrySet();
100100 }
101101
102 public Object get(Object key) {
102 public V get(Object key) {
103103 return map.get(prefix + key);
104104 }
105105
108108 }
109109
110110 public boolean isEmpty() {
111 for (Iterator i = map.keySet().iterator(); i.hasNext(); ) {
112 String key = (String) (i.next());
111 for (Iterator<String> i = map.keySet().iterator(); i.hasNext(); ) {
112 String key = i.next();
113113 if (key.startsWith(prefix))
114114 return false;
115115 }
116116 return true;
117117 }
118118
119 public Set keySet() {
120 Set s = new HashSet();
121 for (Iterator i = map.keySet().iterator(); i.hasNext(); ) {
122 String key = (String) (i.next());
119 public Set<String> keySet() {
120 Set<String> s = new HashSet<>();
121 for (Iterator<String> i = map.keySet().iterator(); i.hasNext(); ) {
122 String key = i.next();
123123 if (key.startsWith(prefix))
124124 s.add(key.substring(prefix.length()));
125125 }
126126 return s;
127127 }
128128
129 public Object put(Object key, Object value) {
129 public V put(String key, V value) {
130130 return map.put(prefix + key, value);
131131 }
132132
133 public void putAll(Map t) {
134 for (Iterator i = t.entrySet().iterator(); i.hasNext(); ) {
135 Map.Entry e = (Map.Entry) (i.next());
136 String key = (String) (e.getKey());
133 public void putAll(Map<? extends String, ? extends V> t) {
134 for (Iterator<? extends Entry<? extends String, ? extends V>> i = t.entrySet().iterator(); i.hasNext(); ) {
135 Map.Entry<? extends String, ? extends V> e = i.next();
136 String key = e.getKey();
137137 put(key, e.getValue());
138138 }
139139 }
140140
141 public Object remove(Object key) {
141 public V remove(Object key) {
142142 return map.remove(prefix + key);
143143 }
144144
145145 public int size() {
146146 int n = 0;
147 for (Iterator i = map.keySet().iterator(); i.hasNext(); ) {
148 String key = (String) (i.next());
147 for (Iterator<String> i = map.keySet().iterator(); i.hasNext(); ) {
148 String key = (i.next());
149149 if (key.startsWith(prefix))
150150 n++;
151151 }
152152 return n;
153153 }
154154
155 public Collection values() {
156 Collection c = new Vector();
157 for (Iterator i = map.entrySet().iterator(); i.hasNext(); ) {
158 Map.Entry e = (Map.Entry) (i.next());
159 String key = (String) (e.getKey());
155 public Collection<V> values() {
156 Collection<V> c = new Vector<>();
157 for (Iterator<Map.Entry<String, V>> i = map.entrySet().iterator(); i.hasNext(); ) {
158 Map.Entry<String, V> e = i.next();
159 String key = e.getKey();
160160 if (key.startsWith(prefix))
161161 c.add(e.getValue());
162162 }
163163 return c;
164164 }
165165
166 private Map map;
166 private Map<String, V> map;
167167 private String prefix;
168168 }
2828 // Modified from JDK java.util.Properties to use Reader/Writer as well as
2929 // InputStream/OutputStream
3030
31 import java.io.BufferedWriter;
32 import java.io.IOException;
33 //import java.io.InputStream;
34 //import java.io.InputStreamReader;
35 //import java.io.OutputStream;
36 //import java.io.OutputStreamWriter;
37 //import java.io.PrintStream;
38 import java.io.PrintWriter;
39 import java.io.Reader;
40 import java.io.Writer;
41 import java.util.Date;
42 import java.util.Enumeration;
43 import java.util.Hashtable;
44 import java.util.Vector;
31 import java.io.*;
32 import java.util.*;
4533
4634 /**
4735 * The <code>Properties</code> class represents a persistent set of
5846 * InputStream/OutputStream, to fix locale/codepage problems.
5947 */
6048 public
61 class Properties extends Hashtable {
49 class Properties extends Hashtable<String, String> {
6250 /**
6351 * A property list that contains default values for any keys not
6452 * found in this property list.
8472 */
8573 public Properties(Properties defaults) {
8674 this.defaults = defaults;
75 }
76
77 /**
78 * Utility method that writes the given map of strings to the given output stream with provided comments
79 * using {@code java.util.Properties.store(java.io.OutputStream, String)} method.
80 */
81 public static void store(Map<String, String> stringProps, OutputStream out, String comments) throws IOException {
82 java.util.Properties properties = new java.util.Properties();
83 properties.putAll(stringProps);
84 properties.store(out, comments);
85 }
86
87 /**
88 * Reads a property list from the given input stream
89 * using {@code java.util.Properties.load(java.io.InputStream inStream)} method
90 * and stores properties into a {@code Map<String, String>} that is returned.
91 */
92 public static Map<String, String> load(InputStream inputStream) throws IOException {
93 return populate(new HashMap<String, String>(), inputStream);
94 }
95
96 /**
97 * Reads a property list from the given input stream
98 * using {@code java.util.Properties.load(java.io.InputStream inStream)} method
99 * and stores string properties into a {@code SortedMap<String, String>} that is returned.
100 */
101 public static SortedMap<String, String> loadSorted(InputStream inputStream) throws IOException {
102 return populate(new TreeMap<String, String>(), inputStream);
103 }
104
105 /**
106 * Populated a map of strings using {@code java.util.Properties.load(java.io.InputStream)} method
107 */
108 private static <M extends Map<String, String>> M populate(M stringProps, InputStream inputStream) throws IOException {
109 java.util.Properties p = new java.util.Properties();
110 p.load(inputStream);
111 return extractStringPropsTo(stringProps, p);
112 }
113
114 /**
115 * Converts the given properties to {@code Map<String, String>} instance
116 * picking only string properties from the given {@code java.util.Properties} instance.
117 */
118 public static Map<String, String> convertToStringProps(java.util.Properties properties) {
119 return extractStringPropsTo(new HashMap<String, String>(), properties);
120 }
121
122 private static <M extends Map<String, String>> M extractStringPropsTo(M stringProps, java.util.Properties p) {
123 for (String name : p.stringPropertyNames()) {
124 stringProps.put(name, p.getProperty(name));
125 }
126 return stringProps;
87127 }
88128
89129 // /**
108148 * input stream.
109149 */
110150 public synchronized void load(Reader in) throws IOException {
111 Vector v = load0(in, false);
151 Vector<String> v = load0(in, false);
112152 for (int i = 0; i < v.size(); i+=2) {
113153 put(v.elementAt(i), v.elementAt(i + 1));
114154 }
115155 }
116156
117157
118 static Vector load0(Reader in, boolean breakOnEmptyLine) throws IOException {
158 static Vector<String> load0(Reader in, boolean breakOnEmptyLine) throws IOException {
119159
120160 // This could be used if we switch to JDK 1.6, where Properties support I/O
121161 // through Reader and Writer
144184 //
145185 //
146186
147 Vector v = new Vector();
187 Vector<String> v = new Vector<>();
148188 int ch = 0;
149189
150190 //// eat any preceding whitespace
330370 out[outLen++] = aChar;
331371 }
332372 } else {
333 out[outLen++] = (char)aChar;
373 out[outLen++] = aChar;
334374 }
335375 }
336376 return new String (out, 0, outLen);
376416 prnt.write('#');
377417 prnt.println(new Date());
378418
379 for (Enumeration e = keys() ; e.hasMoreElements() ;) {
380 String key = (String)e.nextElement();
381 String val = (String)get(key);
419 for (Enumeration<String> e = keys() ; e.hasMoreElements() ;) {
420 String key = e.nextElement();
421 String val = get(key);
382422 key = saveConvert(key, true, false);
383423 /* No need to escape embedded and trailing spaces for value, hence
384424 * pass false to flag.
495535 * @see com.sun.javatest.util.Properties#defaults
496536 * @since JDK1.0
497537 */
498 public Enumeration propertyNames() {
499 Hashtable h = new Hashtable();
538 public Enumeration<String> propertyNames() {
539 Hashtable<String, String> h = new Hashtable<>();
500540 enumerate(h);
501541 return h.keys();
502542 }
526566 */
527567 public void list(PrintWriter out) {
528568 out.println("-- listing properties --");
529 Hashtable h = new Hashtable();
569 Hashtable<String, String> h = new Hashtable<>();
530570 enumerate(h);
531 for (Enumeration e = h.keys() ; e.hasMoreElements() ;) {
532 String key = (String)e.nextElement();
533 String val = (String)h.get(key);
571 for (Enumeration<String> e = h.keys() ; e.hasMoreElements() ;) {
572 String key = e.nextElement();
573 String val = h.get(key);
534574 if (val.length() > 40) {
535575 val = val.substring(0, 37) + "...";
536576 }
542582 * Enumerates all key/value pairs in the specified hastable.
543583 * @param h the hashtable
544584 */
545 private synchronized void enumerate(Hashtable h) {
585 private synchronized void enumerate(Map<String, String> h) {
546586 if (defaults != null) {
547587 defaults.enumerate(h);
548588 }
549 for (Enumeration e = keys() ; e.hasMoreElements() ;) {
550 String key = (String)e.nextElement();
589 for (Enumeration<String> e = keys() ; e.hasMoreElements() ;) {
590 String key = e.nextElement();
551591 h.put(key, get(key));
552592 }
553593 }
2626 package com.sun.javatest.util;
2727
2828 import java.io.BufferedWriter;
29 import java.util.Enumeration;
30 import java.util.Vector;
29 import java.util.*;
3130 import java.io.IOException;
3231 import java.io.Reader;
3332 import java.io.Writer;
10099 * Create a immutable PropertyArray object from a standard Properties object.
101100 * @param props the object from which to initialize the array
102101 */
103 public PropertyArray(Properties props) {
102 public PropertyArray(Map<String, String> props) {
104103 dataA = getArray(props);
105104
106105 locked = true;
132131 * @return an array containing the names of the properties in even-numbered
133132 * entries, and the corresponding values in the adjacent odd-numbered entries
134133 */
135 public static String[] getArray(Properties props) {
136 Enumeration values = props.elements();
137 Enumeration keys = props.keys();
138 Vector data = new Vector(props.size(),2);
139
140 for (; keys.hasMoreElements() ;) {
141 insert(data, (String)(keys.nextElement()),
142 (String)(values.nextElement()));
134 public static String[] getArray(Map<String, String> props) {
135 Vector<String> data = new Vector<>(props.size(),2);
136 for (Map.Entry<String, String> entry : props.entrySet()) {
137 insert(data, entry.getKey(), entry.getValue());
143138 }
144139
145140 String[] arr = new String[data.size()];
158153 * supplied.
159154 */
160155 public static String[] put(String[] data, String key, String value) {
161 Vector vec;
156 Vector<String> vec;
162157 String[] arr;
163158 String old = null;
164159
231226 * @return an array that does not contain the named property
232227 */
233228 public static String[] remove(String[] data, String key) {
234 Vector vec = copyOutOf(data);
229 Vector<String> vec = copyOutOf(data);
235230 int lower = 0;
236231 int upper = vec.size() - 2;
237232 int mid = 0;
243238 }
244239
245240 // goes at the end
246 String last = (String)vec.elementAt(upper);
241 String last = vec.elementAt(upper);
247242 int cmp = key.compareTo(last);
248243 if (cmp > 0) {
249244 return data;
252247 while (lower <= upper) {
253248 // in next line, take care to ensure that mid is always even
254249 mid = lower + ((upper - lower) / 4) * 2;
255 String e = (String)(vec.elementAt(mid));
250 String e = (vec.elementAt(mid));
256251 cmp = key.compareTo(e);
257252 if (cmp < 0) {
258253 upper = mid - 2;
263258 else {
264259 // strings equal, zap key and value
265260 vec.removeElementAt(mid);
266 old = (String)(vec.elementAt(mid));
261 old = vec.elementAt(mid);
267262 vec.removeElementAt(mid);
268263 break;
269264 }
275270 }
276271
277272 /**
278 * Get a standard Properties object from an array of properties.
273 * Get a standard Map object from an array of properties.
279274 * @param data an array of sequential name value properties
280 * @return a Properties object containing data from the array
281 */
282 public static Properties getProperties(String[] data) {
283 Properties props = new Properties();
275 * @return a Map object containing data from the array
276 */
277 public static Map<String, String> getProperties(String[] data) {
278 Map<String, String> props = new HashMap<>();
284279
285280 if (data != null && data.length > 0) {
286281 for (int i = 0; i < data.length; i+=2) {
361356 */
362357 public static String[] load(Reader in) throws IOException {
363358
364 Vector v = Properties.load0(in, true);
365 Vector sorted = new Vector(v.size());
359 Vector<String> v = Properties.load0(in, true);
360 Vector<String> sorted = new Vector<>(v.size());
366361 for (int i = 0; i < v.size(); i+=2) {
367 insert(sorted, (String)v.elementAt(i), (String)v.elementAt(i + 1));
362 insert(sorted, v.elementAt(i), v.elementAt(i + 1));
368363 }
369364
370365 String[] data = new String[sorted.size()];
377372 * @param props an array of sequential name value properties
378373 * @return an enumeration of the properties in the array
379374 */
380 public static Enumeration enumerate(final String[] props) {
381 return new Enumeration() {
375 public static Enumeration<String> enumerate(final String[] props) {
376 return new Enumeration<String>() {
382377 int pos = 0;
383378
384379 public boolean hasMoreElements() {
385380 return (props != null && pos < props.length);
386381 }
387382
388 public Object nextElement() {
383 public String nextElement() {
389384 if (props == null || pos >= props.length) {
390385 return null;
391386 }
404399 * Get the data in this PropertyArray as a standard Properties object.
405400 * @return a Properties object containing the same data as this PropertyArray
406401 */
407 public Properties getProperties() {
402 public Map<String, String> getProperties() {
408403 return getProperties(dataA);
409404 }
410405
470465 "A key or value was null. Null keys and values are illegal");
471466 }
472467
473 Vector vec = copyOutOf(dataA);
468 Vector<String> vec = copyOutOf(dataA);
474469 old = insert(vec, key, value);
475470 dataA = new String[vec.size()];
476471 vec.copyInto(dataA);
503498 *
504499 * @param vec Vector to add data to. Must not be null!
505500 */
506 private static String insert(Vector vec, String key, String value) {
501 private static String insert(Vector<String> vec, String key, String value) {
507502 int lower = 0;
508503 int upper = vec.size() - 2;
509504 int mid = 0;
517512 }
518513
519514 // goes at the end
520 String last = (String)vec.elementAt(upper);
515 String last = vec.elementAt(upper);
521516 int cmp = key.compareTo(last);
522517 if (cmp > 0) {
523518 vec.addElement(key);
528523 while (lower <= upper) {
529524 // in next line, take care to ensure that mid is always even
530525 mid = lower + ((upper - lower) / 4) * 2;
531 String e = (String)(vec.elementAt(mid));
526 String e = vec.elementAt(mid);
532527 cmp = key.compareTo(e);
533528 if (cmp < 0) {
534529 upper = mid - 2;
539534 else {
540535 // strings equal
541536 vec.removeElementAt(mid);
542 old = (String)(vec.elementAt(mid));
537 old = vec.elementAt(mid);
543538 vec.removeElementAt(mid);
544539 break;
545540 }
556551 return old;
557552 }
558553
559 private static Vector copyOutOf(String[] data) {
560 Vector vec = null;
554 private static Vector<String> copyOutOf(String[] data) {
555 Vector<String> vec = null;
561556
562557 if (data == null) {
563 vec = new Vector(0,2);
558 vec = new Vector<>(0,2);
564559 }
565560 else {
566 vec = new Vector(data.length,2);
561 vec = new Vector<>(data.length,2);
567562
568563 for (int i = 0; i < data.length; i++) {
569564 vec.addElement(data[i]);
2525 */
2626 package com.sun.javatest.util;
2727
28
2829 import java.util.Iterator;
2930
3031 /**
3233 * performance reasons or to help find out the number of items returned by an
3334 * iterator before accessing them.
3435 */
35 public class ReadAheadIterator implements Iterator
36 public class ReadAheadIterator<T> implements Iterator<T>
3637 {
3738 /**
3839 * A constant indicating that no read ahead is required.
6061 * @see #LIMITED
6162 * @see #FULL
6263 */
63 public ReadAheadIterator(Iterator source, int mode) {
64 public ReadAheadIterator(Iterator<T> source, int mode) {
6465 this(source, mode, DEFAULT_LIMITED_READAHEAD);
6566 }
6667
7576 * @see #LIMITED
7677 * @see #FULL
7778 */
78 public ReadAheadIterator(Iterator source, int mode, int amount) {
79 public ReadAheadIterator(Iterator<T> source, int mode, int amount) {
7980 this.source = source;
8081 setMode(mode, amount);
8182 }
172173 || (worker == null ? source.hasNext() : sourceHasNext));
173174 }
174175
175 public synchronized Object next() {
176 public synchronized T next() {
176177 // see if there are items in the read ahead queue
177 Object result = queue.remove();
178 T result = queue.remove();
178179
179180 if (result == null) {
180181 // queue is empty: check whether to read source directly, or rely on the worker thread
255256 // sourceHasNext is true, which means there is another item
256257 // to be read, so read it, and also check whether there is
257258 // another item after that
258 Object srcNext = source.next();
259 T srcNext = source.next();
259260 boolean srcHasNext = source.hasNext();
260261
261262 // get the lock to update the queue and sourceHasNext;
295296 /**
296297 * The queue to hold the items that have been read from the underlying source iterator.
297298 */
298 private final Fifo queue = new Fifo();
299 private final Fifo<T> queue = new Fifo<>();
299300
300301 /**
301302 * The underlying source iterator. If the worker thread is running, it alone
303304 * along with everything else.
304305 * @see #worker
305306 */
306 private final Iterator source;
307 private final Iterator<T> source;
307308
308309 /**
309310 * A value indicating whether the underlying source iterator has more values to be read.
3838 public class SortedProperties extends Properties
3939 {
4040 // override Keys() to return a sorted set
41 public Enumeration keys() {
42 Set s = new TreeSet(); // ordered
43 for (Enumeration e = super.keys(); e.hasMoreElements(); ) {
41 public Enumeration<Object> keys() {
42 Set<Object> s = new TreeSet<>(); // ordered
43 for (Enumeration<?> e = super.keys(); e.hasMoreElements(); ) {
4444 s.add(e.nextElement());
4545 }
4646
47 final Iterator iter = s.iterator();
48 return new Enumeration() {
47 final Iterator<?> iter = s.iterator();
48 return new Enumeration<Object>() {
4949 public boolean hasMoreElements() {
5050 return iter.hasNext();
5151 }
4747 if (s == null)
4848 return empty;
4949
50 Vector v = new Vector();
50 Vector<String> v = new Vector<>();
5151 int start = -1;
5252 for (int i = 0; i < s.length(); i++) {
5353 if (white(s.charAt(i))) {
129129 if (list == null || list.length() == 0)
130130 return null;
131131
132 Vector v = new Vector();
132 Vector<String> v = new Vector<>();
133133 int pos = 0;
134134 while (true) {
135135 int nextD = list.indexOf(delim, pos);
8585 if (values == null)
8686 initValues();
8787
88 return (String) (values.get(name));
88 return values.get(name);
8989 }
9090
9191 /**
9393 * execution context.
9494 * @return a map containing all the known environment variables.
9595 */
96 public static Map getAll() {
97 return getAll(new HashMap());
96 public static Map<String, String> getAll() {
97 return getAll(new HashMap<String, String>());
9898 }
9999
100100 /**
104104 * environment variables in the current execution context.
105105 * @return the argument map.
106106 */
107 public static Map getAll(Map m) {
107 public static Map<String, String> getAll(Map<String, String> m) {
108108 if (values == null)
109109 initValues();
110110
113113 }
114114
115115 private static void initValues() {
116 values = new HashMap();
116 values = new HashMap<>();
117117
118118 if (command == null)
119119 command = getDefaultCommand();
170170 }
171171
172172 private static String command;
173 private static Map values;
173 private static Map<String, String> values;
174174 private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(SysEnv.class);
175175 }
113113 //System.out.println("timeout set for " + obj + " at " + (new Date(absCallbackTime)));
114114 Entry e = new Entry(obj, absCallbackTime);
115115 for (int i = 0; i < entries.size(); i++) {
116 Entry ee = (Entry)(entries.elementAt(i));
116 Entry ee = entries.elementAt(i);
117117 if (e.expiration < ee.expiration) {
118118 entries.insertElementAt(e, i);
119119 return e;
159159 wait();
160160 } else {
161161 long now = System.currentTimeMillis();
162 Entry e = (Entry)(entries.elementAt(0));
162 Entry e = entries.elementAt(0);
163163 if (e.expiration <= now) {
164164 // time to call back e.obj; do so and remove it from list
165165 entries.removeElementAt(0);
213213
214214 //-----member variables-------------------------------------------------------
215215
216 private Vector entries = new Vector();
216 private Vector<Entry> entries = new Vector<>();
217217 private boolean acceptingRequests = true;
218218 }
206206 public void addFiles(File baseDir, String[] paths) {
207207 if (paths == null)
208208 return;
209 List/*<File>*/ files = new ArrayList/*<File>*/();
209 List<File> files = new ArrayList<File>();
210210 if (inFiles != null)
211211 files.addAll(Arrays.asList(inFiles));
212212 for (int i = 0; i < paths.length; i++)
213213 files.add(new File(baseDir, paths[i]));
214 inFiles = (File[]) files.toArray(new File[files.size()]);
214 inFiles = files.toArray(new File[files.size()]);
215215 }
216216
217217 private void run() throws BadArgs, IOException {
230230 if (mapOutFile != null && mapDir == null)
231231 mapDir = mapOutFile.getParentFile();
232232
233 glossary = new TreeMap();
233 glossary = new TreeMap<>();
234234
235235 read(inFiles);
236236
272272
273273 char currLetter = 0;
274274
275 for (Iterator iter = glossary.values().iterator(); iter.hasNext(); ) {
276 Entry e = (Entry) (iter.next());
275 for (Iterator<Entry> iter = glossary.values().iterator(); iter.hasNext(); ) {
276 Entry e = (iter.next());
277277 if (!e.matches(keyword))
278278 continue;
279279
372372 private File mapDir;
373373 private File xmlOutFile;
374374 private String keyword;
375 private Map glossary;
375 private Map<String, Entry> glossary;
376376
377377 }
378378
552552 String link = file.getName();
553553 if (link.endsWith(".html"))
554554 link = link.substring(0, link.length() - 5);
555 out.write("\n<!-- file: " + file + " -->\n<a name=\"" + link + "\">");
555 out.write("\n<!-- file: " + file + " -->\n<a name=\"" + link + "\"></a>");
556556 }
557557 else {
558558 copyMode = NO_COPY;
805805 // hIndent = Integer.parseInt(content);
806806 // }
807807 if (name.equalsIgnoreCase("glossaryKeywords")) {
808 keywords = new HashSet(Arrays.asList(split(content)));
808 keywords = new HashSet<>(Arrays.asList(split(content)));
809809 }
810810 }
811811
982982 }
983983
984984 private static String[] split(String s) {
985 Vector v = new Vector();
985 Vector<String> v = new Vector<>();
986986 int start = -1;
987987 for (int i = 0; i < s.length(); i++) {
988988 char c = s.charAt(i);
10061006 private File file;
10071007 private String head1;
10081008 private String text;
1009 private Set keywords;
1009 private Set<String> keywords;
10101010
10111011 private Reader in;
10121012 private Writer out;
201201 public void addFiles(String[] paths) {
202202 if (paths == null)
203203 return;
204 List/*<File>*/ files = new ArrayList/*<File>*/();
204 List<File> files = new ArrayList<File>();
205205 if (inFiles != null)
206206 files.addAll(Arrays.asList(inFiles));
207207 for (int i = 0; i < paths.length; i++)
208208 files.add(new File(paths[i]));
209 inFiles = (File[]) files.toArray(new File[files.size()]);
209 inFiles = files.toArray(new File[files.size()]);
210210 }
211211
212212 private void run() throws BadArgs, IOException {
520520
521521 char currLetter = 0;
522522
523 for (Iterator iter = root.iterator(); iter.hasNext(); ) {
524 Node node = (Node) (iter.next());
523 for (Iterator<Node> iter = root.iterator(); iter.hasNext(); ) {
524 Node node = (iter.next());
525525 String name = node.getName();
526526 char initial = Character.toUpperCase(name.charAt(0));
527527 if (Character.isLetter(initial) && initial != currLetter) {
596596 }
597597
598598 if (node.getChildCount() > 0) {
599 for (Iterator iter = node.iterator(); iter.hasNext(); ) {
600 Node child = (Node) (iter.next());
599 for (Iterator<Node> iter = node.iterator(); iter.hasNext(); ) {
600 Node child = (iter.next());
601601 write(xmlOut, mapOut, htmlOut, child, depth + 1);
602602 }
603603
607607 }
608608
609609 private static String[] split(String s, char sep) {
610 Vector v = new Vector();
610 Vector<String> v = new Vector<>();
611611 int start = -1;
612612 for (int i = 0; i < s.length(); i++) {
613613 char c = s.charAt(i);
628628 }
629629
630630 private static File[] splitPath(String s) {
631 Vector v = new Vector();
631 Vector<File> v = new Vector<>();
632632 int start = -1;
633633 for (int i = 0; i < s.length(); i++) {
634634 char c = s.charAt(i);
731731 private String currName;
732732 private Node root;
733733
734 private static Iterator nullIterator = new Iterator() {
734 private static Iterator<Node> nullIterator = new Iterator<Node>() {
735735 public boolean hasNext() {
736736 return false;
737737 }
738 public Object next() {
738 public Node next() {
739739 return null;
740740 }
741741 public void remove() {
742742 }
743743 };
744744
745 private Comparator indexComparator = new Comparator() {
746 public int compare(Object o1, Object o2) {
747 Node n1 = (Node) o1;
748 Node n2 = (Node) o2;
745 private Comparator<Node> indexComparator = new Comparator<Node>() {
746 public int compare(Node n1, Node n2) {
749747 return n1.getName().compareToIgnoreCase(n2.getName());
750748 }
751749
777775
778776 Node getChild(String name) {
779777 if (children != null) {
780 for (Iterator iter = children.iterator(); iter.hasNext(); ) {
781 Node child = (Node) (iter.next());
778 for (Iterator<Node> iter = children.iterator(); iter.hasNext(); ) {
779 Node child = iter.next();
782780 if (child.name.equals(name))
783781 return child;
784782 }
798796 return (children == null ? 0 : children.size());
799797 }
800798
801 Iterator iterator() {
799 Iterator<Node> iterator() {
802800 return (children == null ? nullIterator : children.iterator());
803801 }
804802
805803 private void add(Node child) {
806804 if (children == null)
807 children = new TreeSet(indexComparator);
805 children = new TreeSet<Node>(indexComparator);
808806 children.add(child);
809807 }
810808
811809 private String name;
812 private Set children;
810 private Set<Node> children;
813811 private String info;
814812 }
815813
124124
125125 public static class Ant extends MatchingTask {
126126 private Main m = new Main();
127 private List/*<FileSet>*/ fileSets = new ArrayList/*<FileSet>*/();
127 private List<FileSet> fileSets = new ArrayList<FileSet>();
128128
129129 public void setOutFile(File file) {
130130 m.outFile = file;
135135 }
136136
137137 public void execute() {
138 for (Iterator iter = fileSets.iterator(); iter.hasNext(); ) {
139 FileSet fs = (FileSet) iter.next();
138 for (Iterator<FileSet> iter = fileSets.iterator(); iter.hasNext(); ) {
139 FileSet fs = iter.next();
140140 FileScanner s = fs.getDirectoryScanner(getProject());
141141 m.addFiles(s.getBasedir(), s.getIncludedFiles());
142142 }
153153 public void addFiles(File baseDir, String[] paths) {
154154 if (paths == null)
155155 return;
156 List/*<File>*/ files = new ArrayList/*<File>*/();
156 List<File> files = new ArrayList<File>();
157157 if (inFiles != null)
158158 files.addAll(Arrays.asList(inFiles));
159159 for (int i = 0; i < paths.length; i++)
160160 files.add(new File(baseDir, paths[i]));
161 inFiles = (File[]) files.toArray(new File[files.size()]);
161 inFiles = files.toArray(new File[files.size()]);
162162 }
163163
164164 private void run() throws BadArgs, IOException
170170 if (outFile == null)
171171 throw new BadArgs("no output file specified");
172172
173 map = new TreeMap();
173 map = new TreeMap<>();
174174
175175 for (int i = 0; i < inFiles.length; i++)
176176 read(inFiles[i]);
183183 out.println("<map version=\"1.0\">");
184184
185185 int maxLen = 0;
186 for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
187 Map.Entry e = (Map.Entry) (iter.next());
188 String target = (String) (e.getKey());
189 String url = (String) (e.getValue());
186 for (Iterator<Map.Entry<String, String>> iter = map.entrySet().iterator(); iter.hasNext(); ) {
187 Map.Entry<String, String> e = iter.next();
188 String target = e.getKey();
189 String url = e.getValue();
190190 maxLen = Math.max(maxLen, target.length());
191191 }
192192
193 for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
194 Map.Entry e = (Map.Entry) (iter.next());
195 String target = (String) (e.getKey());
196 String url = (String) (e.getValue());
193 for (Iterator<Map.Entry<String, String>> iter = map.entrySet().iterator(); iter.hasNext(); ) {
194 Map.Entry<String, String> e = iter.next();
195 String target = e.getKey();
196 String url = e.getValue();
197197 out.print(" <mapID target=\"" + target + "\" ");
198198 for (int i = target.length(); i < maxLen; i++)
199199 out.print(' ');
411411
412412 private File[] inFiles;
413413 private File outFile;
414 private Map map;
414 private Map<String, String> map;
415415
416416 private Reader in;
417417 private int c;