1 /*
2 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 */
24
25 package client.test.runner;
26
27 import client.test.runner.interview.LookAndFeelQuestion;
28 import client.test.runner.interview.PipelineGroupQuestion;
29 import client.util.CtrUtils;
30 import com.sun.interview.*;
31 import com.sun.javatest.Parameters.EnvParameters;
32 import com.sun.javatest.TestEnvironment;
33 import com.sun.javatest.interview.BasicInterviewParameters;
34 import java.io.File;
35 import java.io.IOException;
36 import java.net.UnknownHostException;
37 import java.util.HashMap;
38 import java.util.Map;
39
40 /**
41 *
42 * @author vshubov
43 */
44 public class BasicFXInterview extends BasicInterviewParameters
45 implements EnvParameters {
46
110 public static final String RUN_MODE_JNLP = "jnlp";
111
112 /**
113 *
114 */
115 public final static String BROWSER_PARAM_NAME = "browserPath";
116
117 /**
118 *
119 */
120 public final static String JAVAWS_PARAM_NAME = "javawsPath";
121
122 /**
123 *
124 */
125 public final static String JAVA_PARAM_NAME = "javaPath";
126
127 /**
128 *
129 */
130 public final static String VM_OPTIONS_PARAM_NAME = "vmOptions";
131
132 /**
133 *
134 */
135 public final static String TESTSUITE_ID = "testsuiteID";
136
137 private String javaFXHome;
138 private String extOut;
139
140 /**
141 *
142 * @throws Fault
143 */
144 public BasicFXInterview() throws Fault {
145 super(null);
146 }
147
148 /**
149 *
192 data.put(TESTSUITE_ID, id);
193 super.export(data);
194 }
195
196 /**
197 *
198 * @return
199 */
200 public boolean isRemoteRun() {
201 return YesNoQuestion.YES.equals(qRemoteRun.getValue());
202 }
203
204 /**
205 *
206 * @return
207 */
208 public File getJavaPath(){
209 return qJavaPath.getValue();
210 }
211
212 /**
213 *
214 * @return
215 */
216 protected Question getLastQuestion(){
217 return getEnvSuccessorQuestion();
218 }
219
220 /**
221 *
222 */
223 protected StringQuestion qName = new StringQuestion(this, "name") {
224 @Override
225 public String getText() {
226 return getSummary();
227 }
228
229 @Override
230 public String getSummary() {
231 return "Configuration name";
713 extOut = (String) data.get(EXTERNALOUTPUT);
714 if (extOut != null) {
715 setValue(new File(extOut));
716 }
717 }
718 }
719 };
720
721 private StringQuestion qProxy = new StringQuestion(this, "proxy") {
722
723 {
724 clear();
725 }
726 @Override
727 public void clear() {
728 setValue("");
729 }
730
731 @Override
732 public String getText() {
733 return "Proxy settings in format: host:port\nE.g. www-proxy.us.oracle.com:80";
734 }
735
736 @Override
737 public String getSummary() {
738 return "Proxy settings";
739 }
740
741 @Override
742 public Question getNext() {
743 String val = getValue();
744 if (val == null || val.trim().length() == 0 || CtrUtils.getProxyUrl(val) != null) {
745 return qVmOptions;
746 } else {
747 return null;
748 }
749 }
750
751 @Override
752 public void export(Map data) {
753 data.put(PROXY_PARAM_NAME, value);
754 }
755
756 @Override
757 public void load(Map data) {
758 String v = (String) data.get(PROXY_PARAM_NAME);
759 setValue(v != null ? v : "");
760 }
761 };
762
763 private LookAndFeelQuestion qLookAndFeelGroup = new LookAndFeelQuestion (this, qProxy);
764 private ChoiceQuestion qPipelineGroup = new PipelineGroupQuestion (this, getLastQuestion());
765
766
767 private static boolean isWindows() {
768 return System.getProperty("os.name").toLowerCase().contains("windows");
769 }
770 private StringQuestion qVmOptions = new StringQuestion(this, VM_OPTIONS_PARAM_NAME) {
771
772 @Override
773 public String getText() {
774 return "Set VM Options for test run (desktop mode only).\nE.g. -Dprism.verbose=true";
775 }
776
777 @Override
778 public String getSummary() {
779 return "VM Options";
780 }
781
782 @Override
783 public void clear() {
784 setValue("");
785 }
786
787 @Override
788 public Question getNext() {
789 return qPipelineGroup;//getLastQuestion();
790 }
791
792 @Override
793 public void export(Map data) {
794 data.put(VM_OPTIONS_PARAM_NAME, value);
795 }
796
797 @Override
798 public void load(Map data) {
799 String newValue = (String) data.get(VM_OPTIONS_PARAM_NAME);
800 setValue(newValue != null ? newValue : "");
801 }
802 };
803
804
805
806 private static class ExecutablesFileFilter implements FileFilter {
807 @Override
808 public boolean accept(File file) {
809 return file.exists() && file.canExecute();
810 }
811
812 @Override
813 public boolean acceptsDirectories() {
814 return false;
815 }
816
817 @Override
818 public String getDescription() {
819 return "Executable files";
820 }
821 }
822 private static Runnable ieFix = new Runnable() {
823 @Override
824 public void run() {
825 if (!alreadyRun) {
826 alreadyRun = true; // we prefer this to be run only once but it's not big enough deal to introduce syncronization
827 System.out.println("NB: For internet explorer test run registry would be modified to run IE as one process and allow ActiveX from localhost.");
828 try {
829 System.out.println("'" + IE_TABS_LOCK_PATH + "\\" + IE_TABS_LOCK_KEY + "' key is being set to 0.\n");
830 //TODO: in the perfect world we would read current value and restore it after test run
831 Runtime.getRuntime().exec("reg add \"" + IE_TABS_LOCK_PATH + "\" /v " + IE_TABS_LOCK_KEY + " /t REG_DWORD /d 0 /f");
832
833 System.out.println("'" + IE_ACTIVEX_PATH + "\\" + IE_ACTIVEX_KEY + "' key is being set to 0.\n");
834 Runtime.getRuntime().exec("reg add \"" + IE_ACTIVEX_PATH + "\" /v " + IE_ACTIVEX_KEY + " /t REG_DWORD /d 0 /f");
835
836 System.out.println("'" + IE_ACTIVEX_LOCAL_PATH + "\\" + IE_ACTIVEX_LOCAL_KEY + "' key is being set to 0.\n");
837 Runtime.getRuntime().exec("reg add \"" + IE_ACTIVEX_LOCAL_PATH + "\" /v " + IE_ACTIVEX_LOCAL_KEY + " /t REG_DWORD /d 0 /f");
838 } catch (IOException ex) {
839 ex.printStackTrace();
840 }
841 }
|
1 /*
2 * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 */
24
25 package client.test.runner;
26
27 import static client.test.runner.InterviewUtils.*;
28 import client.test.runner.interview.LookAndFeelQuestion;
29 import client.test.runner.interview.PipelineGroupQuestion;
30 import client.util.CtrUtils;
31 import com.sun.interview.*;
32 import com.sun.javatest.Parameters.EnvParameters;
33 import com.sun.javatest.TestEnvironment;
34 import com.sun.javatest.interview.BasicInterviewParameters;
35 import java.io.File;
36 import java.io.IOException;
37 import java.net.UnknownHostException;
38 import java.util.HashMap;
39 import java.util.Map;
40
41 /**
42 *
43 * @author vshubov
44 */
45 public class BasicFXInterview extends BasicInterviewParameters
46 implements EnvParameters {
47
111 public static final String RUN_MODE_JNLP = "jnlp";
112
113 /**
114 *
115 */
116 public final static String BROWSER_PARAM_NAME = "browserPath";
117
118 /**
119 *
120 */
121 public final static String JAVAWS_PARAM_NAME = "javawsPath";
122
123 /**
124 *
125 */
126 public final static String JAVA_PARAM_NAME = "javaPath";
127
128 /**
129 *
130 */
131 public final static String ADD_EXPORTS_PARAM_NAME = "addExports";
132
133 /**
134 *
135 */
136 public final static String XPATCH_PARAM_NAME = "XPatch";
137
138 /**
139 *
140 */
141 public final static String ENABLE_ADD_EXPORTS_PARAM_NAME = "addExportsEnabled";
142
143 /**
144 *
145 */
146 public final static String VM_OPTIONS_PARAM_NAME = "vmOptions";
147
148 /**
149 *
150 */
151 public final static String TESTSUITE_ID = "testsuiteID";
152
153 private String javaFXHome;
154 private String extOut;
155
156 /**
157 *
158 * @throws Fault
159 */
160 public BasicFXInterview() throws Fault {
161 super(null);
162 }
163
164 /**
165 *
208 data.put(TESTSUITE_ID, id);
209 super.export(data);
210 }
211
212 /**
213 *
214 * @return
215 */
216 public boolean isRemoteRun() {
217 return YesNoQuestion.YES.equals(qRemoteRun.getValue());
218 }
219
220 /**
221 *
222 * @return
223 */
224 public File getJavaPath(){
225 return qJavaPath.getValue();
226 }
227
228 public String getXPatch() {
229 return qXPatch.getValue();
230 }
231
232 /**
233 *
234 * @return
235 */
236 protected Question getLastQuestion(){
237 return getEnvSuccessorQuestion();
238 }
239
240 /**
241 *
242 */
243 protected StringQuestion qName = new StringQuestion(this, "name") {
244 @Override
245 public String getText() {
246 return getSummary();
247 }
248
249 @Override
250 public String getSummary() {
251 return "Configuration name";
733 extOut = (String) data.get(EXTERNALOUTPUT);
734 if (extOut != null) {
735 setValue(new File(extOut));
736 }
737 }
738 }
739 };
740
741 private StringQuestion qProxy = new StringQuestion(this, "proxy") {
742
743 {
744 clear();
745 }
746 @Override
747 public void clear() {
748 setValue("");
749 }
750
751 @Override
752 public String getText() {
753 return "Proxy settings in format: host:port\nE.g. proxy.example.com:80";
754 }
755
756 @Override
757 public String getSummary() {
758 return "Proxy settings";
759 }
760
761 @Override
762 public Question getNext() {
763 String val = getValue();
764 if (val == null || val.trim().length() == 0 || CtrUtils.getProxyUrl(val) != null) {
765 return qXPatch;
766 } else {
767 return null;
768 }
769 }
770
771 @Override
772 public void export(Map data) {
773 data.put(PROXY_PARAM_NAME, value);
774 }
775
776 @Override
777 public void load(Map data) {
778 String v = (String) data.get(PROXY_PARAM_NAME);
779 setValue(v != null ? v : "");
780 }
781 };
782
783 private LookAndFeelQuestion qLookAndFeelGroup = new LookAndFeelQuestion (this, qProxy);
784 private ChoiceQuestion qPipelineGroup = new PipelineGroupQuestion (this, getLastQuestion());
785
786 private StringQuestion qXPatch = new StringQuestion(this, XPATCH_PARAM_NAME) {
787
788 @Override
789 public String getText() {
790 return "Set -Xpatch directory for the test run. "
791 + "\nE.g. build/shim-modules";
792 }
793
794 @Override
795 public String getSummary() {
796 return "-Xpatch";
797 }
798
799 @Override
800 public void clear() {
801 setValue("");
802 }
803
804 @Override
805 public Question getNext() {
806 return qEnableAddExports;
807 }
808
809 @Override
810 public void export(Map data) {
811 data.put(XPATCH_PARAM_NAME, value);
812 }
813
814 @Override
815 public void load(Map data) {
816 String newValue = (String) data.get(XPATCH_PARAM_NAME);
817 setValue(newValue != null ? newValue : "");
818 }
819 };
820
821 private YesNoQuestion qEnableAddExports = new YesNoQuestion(this, ENABLE_ADD_EXPORTS_PARAM_NAME, YesNoQuestion.YES) {
822 @Override
823 public Question getNext() {
824 if (getValue().equals(YES)) {
825 return qAddExports;
826 }
827 return qVmOptions;
828 }
829
830 @Override
831 public String getText() {
832 return "Do you wish to add -XaddExports JVM argument when running tests? "
833 + "\nAnswer Yes when running with JDK 9 Jigsaw."
834 + "\nAnswer No when running with JDK 8 and prior.";
835 }
836
837 @Override
838 public String getSummary() {
839 return "Add -XaddExports?";
840 }
841
842 @Override
843 public void export(Map data) {
844 data.put(ENABLE_ADD_EXPORTS_PARAM_NAME, getValue());
845 }
846
847 @Override
848 public void load(Map data) {
849 if (data.containsKey(ENABLE_ADD_EXPORTS_PARAM_NAME)) {
850 setValue((String) data.get(ENABLE_ADD_EXPORTS_PARAM_NAME));
851 }
852 }
853 };
854
855 private StringQuestion qAddExports = new StringQuestion(this, ADD_EXPORTS_PARAM_NAME) {
856
857 @Override
858 public String getText() {
859 return "Set -XaddExports values for the test run. "
860 + "Individual tests can use @addExports annotation "
861 + "to add more specific entries to -XaddExports JVM argument."
862 + "\nE.g. javafx.graphics/com.sun.prism=ALL-UNNAMED,javafx.base/com.sun.javafx.runtime=ALL-UNNAMED";
863 }
864
865 @Override
866 public String getSummary() {
867 return "-XaddExports";
868 }
869
870 @Override
871 public void clear() {
872 setValue("");
873 }
874
875 @Override
876 public Question getNext() {
877 return qVmOptions;
878 }
879
880 @Override
881 public void export(Map data) {
882 data.put(ADD_EXPORTS_PARAM_NAME, value);
883 }
884
885 @Override
886 public void load(Map data) {
887 String newValue = (String) data.get(ADD_EXPORTS_PARAM_NAME);
888 setValue(newValue != null ? newValue : "");
889 }
890 };
891
892 private StringQuestion qVmOptions = new StringQuestion(this, VM_OPTIONS_PARAM_NAME) {
893
894 @Override
895 public String getText() {
896 return "Set VM Options for test run (desktop mode only).\nE.g. -Dprism.verbose=true";
897 }
898
899 @Override
900 public String getSummary() {
901 return "VM Options";
902 }
903
904 @Override
905 public void clear() {
906 setValue("");
907 }
908
909 @Override
910 public Question getNext() {
911 return qPipelineGroup;//getLastQuestion();
912 }
913
914 @Override
915 public void export(Map data) {
916 data.put(VM_OPTIONS_PARAM_NAME, value);
917 }
918
919 @Override
920 public void load(Map data) {
921 String newValue = (String) data.get(VM_OPTIONS_PARAM_NAME);
922 setValue(newValue != null ? newValue : "");
923 }
924 };
925
926 private static Runnable ieFix = new Runnable() {
927 @Override
928 public void run() {
929 if (!alreadyRun) {
930 alreadyRun = true; // we prefer this to be run only once but it's not big enough deal to introduce syncronization
931 System.out.println("NB: For internet explorer test run registry would be modified to run IE as one process and allow ActiveX from localhost.");
932 try {
933 System.out.println("'" + IE_TABS_LOCK_PATH + "\\" + IE_TABS_LOCK_KEY + "' key is being set to 0.\n");
934 //TODO: in the perfect world we would read current value and restore it after test run
935 Runtime.getRuntime().exec("reg add \"" + IE_TABS_LOCK_PATH + "\" /v " + IE_TABS_LOCK_KEY + " /t REG_DWORD /d 0 /f");
936
937 System.out.println("'" + IE_ACTIVEX_PATH + "\\" + IE_ACTIVEX_KEY + "' key is being set to 0.\n");
938 Runtime.getRuntime().exec("reg add \"" + IE_ACTIVEX_PATH + "\" /v " + IE_ACTIVEX_KEY + " /t REG_DWORD /d 0 /f");
939
940 System.out.println("'" + IE_ACTIVEX_LOCAL_PATH + "\\" + IE_ACTIVEX_LOCAL_KEY + "' key is being set to 0.\n");
941 Runtime.getRuntime().exec("reg add \"" + IE_ACTIVEX_LOCAL_PATH + "\" /v " + IE_ACTIVEX_LOCAL_KEY + " /t REG_DWORD /d 0 /f");
942 } catch (IOException ex) {
943 ex.printStackTrace();
944 }
945 }
|