/* * @(#)EnvironmentInterview.java 1.21 01/07/24 Jonathan Gibbons * * Copyright 2001 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * * Copyright 2001 Sun Microsystems, Inc. Tous droits réservés. * Distribueé par des licences qui en restreignent l'utilisation. */ package com.sun.demotck.interview; import java.util.Map; import com.sun.interview.Interview; import com.sun.interview.Question; import com.sun.interview.ChoiceQuestion; import com.sun.interview.FileQuestion; import com.sun.interview.FinalQuestion; import com.sun.interview.NullQuestion; import com.sun.interview.StringQuestion; import com.sun.interview.WizPrint; public class EnvironmentInterview extends DemoTCKEnvInterview { public EnvironmentInterview(DemoTCKParameters parent) { super(parent, "env"); this.parent = parent; setFirstQuestion(qEnvName); } String getName() { return qEnvName.getValue(); } void setName(String name) { qEnvName.setValue(name); } DemoTCKParameters getRootInterview() { return parent; } //---------------------------------------------------------------------------- // // Please provide a short identifier which will be used to name the // configuration you are creating here. private StringQuestion qEnvName = new StringQuestion(this, "envName") { private /*static*/ boolean isValidIdentifier(String s) { if (s == null || s.equals("")) return false; if (!Character.isUnicodeIdentifierStart(s.charAt(0))) return false; for (int i = 1; i < s.length(); i++) { if (!Character.isUnicodeIdentifierPart(s.charAt(i))) return false; } return true; } public void setValue(String value) { valid = isValidIdentifier(value); super.setValue(value); } protected Question getNext() { if (valid) return qDescription; else return null; } public void export(Map data) { data.put(envEntry("testsuite"), "com.sun.demotck.lib.DemoTCKTestSuite"); data.put(envEntry("script"), "com.sun.demotck.lib.DemoTCKScript"); data.put(envEntry("finder"), "com.sun.demotck.lib.DemoTCKTestFinder"); data.put("env.report-only.script", "com.sun.javatest.lib.ReportScript"); data.put("env.report-only.finder", "com.sun.demotck.lib.DemoTCKTestFinder"); } private boolean valid; }; String envEntry(String e) { return "env." + qEnvName.getValue() + "." + e; } //---------------------------------------------------------------------------- // // Please provide a short description which can be used to identify // the configuration you are creating here. private Question qDescription = new StringQuestion(this, "description") { protected void export(Map data) { data.put(envEntry("description"), value); } protected Question getNext() { if (value == null || value.trim().equals("")) return null; else return callInterview(iRuntime, qEnd); } }; //---------------------------------------------------------------------------- // important: these must match the names used by System.getProperty("os.name"); // verified for JDK 1.1.8; static final String WINDOWS95 = "Windows 95"; static final String WINDOWS98 = "Windows 98"; static final String WINDOWSNT = "Windows NT"; static final String WINDOWS2000 = "Windows 2000"; // not verified static final String[] allOSChoices = {null, WINDOWS95, WINDOWS98, WINDOWSNT, WINDOWS2000}; static final String[] stdOSChoices = {null, WINDOWS95, WINDOWS98, WINDOWSNT, WINDOWS2000}; //---------------------------------------------------------------------------- private final DemoTCKParameters parent; private final Interview iRuntime = new RuntimeInterview(this); private final Question qEnd = new FinalQuestion(this); }