Skip to main content

please review suggested fix for 'CR 6661995 provide ability to extend tes'

1 reply [Last post]
fyodr
Offline
Joined: 2007-12-27

Index: com/sun/javatest/interview/TestsInterview.java
===================================================================
--- com/sun/javatest/interview/TestsInterview.java (revision 766)
+++ com/sun/javatest/interview/TestsInterview.java (working copy)
@@ -162,18 +162,47 @@
private static final String FILE = "file";
private static final String TREE = "tree";

- private ChoiceQuestion qTreeOrFile = new ChoiceQuestion(this, "treeOrFile") {
- {
- setChoices(new String[] { TREE, FILE }, true);
- }
+ /**
+ * Represents Tests Selection Choice Question. Exctracted to separate class
+ * for extensibility purposes
+ */
+ public class TreeOrFileChoiceQuestion extends ChoiceQuestion{

- protected Question getNext() {
+ public TreeOrFileChoiceQuestion(Interview interview, String tag) {
+ super(interview, tag);
+ setChoices(getTestSelectionChoices(), true);
+ }
+
+ /**
+ * Should be overriden if more selection choices are needed
+ * @return array of test selection choices
+ */
+ protected String[] getTestSelectionChoices(){
+ return new String[] { TREE, FILE };
+ }
+
+ @Override
+ protected Question getNext() {
if (value == TREE)
return qTestTree;
else
return qTestFile;
- }
- };
+ }
+
+ }
+
+ protected TreeOrFileChoiceQuestion qTreeOrFile = createTreeOrFileChoiceQuestion(this, "treeOrFile");
+
+ /**
+ * creation of {#link TreeOrFileChoiceQuestion} is extracted into separate class
+ * to enable 'hooks' and return {#link TreeOrFileChoiceQuestion} sub class
+ * @param interview
+ * @param tag
+ * @return insctance of TreeOrFileChoiceQuestion
+ */
+ protected TreeOrFileChoiceQuestion createTreeOrFileChoiceQuestion(Interview interview, String tag){
+ return new TreeOrFileChoiceQuestion(interview, tag);
+ }

//----------------------------------------------------------------------------
//
@@ -409,7 +438,7 @@
//
// End

- private Question qEnd = new FinalQuestion(this);
+ protected Question qEnd = new FinalQuestion(this);

//----------------------------------------------------------------------------

Index: com/sun/javatest/interview/BasicInterviewParameters.java
===================================================================
--- com/sun/javatest/interview/BasicInterviewParameters.java (revision 766)
+++ com/sun/javatest/interview/BasicInterviewParameters.java (working copy)
@@ -61,7 +61,7 @@
// leave this to the subtype to decide whether to provide or not
//setHelpSet("/com/sun/javatest/moreInfo/moreInfo.hs");

- iTests = new TestsInterview(this);
+ iTests = createTestsInterview(this);
iExcludeList = new ExcludeListInterview(this);
iKeywords = new KeywordsInterview(this);
iPriorStatus = new PriorStatusInterview(this);
@@ -70,7 +70,7 @@

setFirstQuestion(qProlog);
}
-
+
/**
* Create a BasicInterviewParameters object.
* @param tag the tag used to qualify questions in this interview
@@ -83,6 +83,18 @@
this(tag);
setTestSuite(ts);
}
+
+ /**
+ * creation of {#link TestsInterview} is extracted into separate class
+ * to enable 'hooks' and return {#link TestsInterview} sub class
+ * @param parent
+ * @return instance of {#link TestsInterview}
+ * @throws com.sun.interview.Interview.Fault
+ */
+ protected TestsInterview createTestsInterview(InterviewParameters parent)
+ throws InterviewParameters.Fault{
+ return new TestsInterview(parent);
+ }

/**
* Specify whether or not to include standard questions in the
@@ -301,7 +313,7 @@

private TestSuite testSuite;
private WorkDirectory workDir;
- private TestsInterview iTests;
+ protected TestsInterview iTests;
private ExcludeListInterview iExcludeList;
private KeywordsInterview iKeywords;
private PriorStatusInterview iPriorStatus;

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
fyodr
Offline
Joined: 2007-12-27

I had to do more changes, pls, review updated change:
Index: com/sun/javatest/interview/TestsInterview.java
===================================================================
--- com/sun/javatest/interview/TestsInterview.java (revision 766)
+++ com/sun/javatest/interview/TestsInterview.java (working copy)
@@ -82,8 +82,10 @@
if (qNeedTests.getValue() == YesNoQuestion.YES) {
if (qTreeOrFile.getValue() == TREE)
return qTestTree.getValue();
- else
+ else if(qTreeOrFile.getValue() == FILE)
return getTests(qTestFile.getValue());
+ else
+ return null;
}
else
return null;
@@ -124,8 +126,10 @@
String[] v;
if (qTreeOrFile.getValue() == TREE)
v = qTestTree.getValue();
- else
+ else if (qTreeOrFile.getValue() == FILE)
v = getTests(qTestFile.getValue());
+ else
+ v = null;

if (v == null)
return null;
@@ -162,18 +166,47 @@
private static final String FILE = "file";
private static final String TREE = "tree";

- private ChoiceQuestion qTreeOrFile = new ChoiceQuestion(this, "treeOrFile") {
- {
- setChoices(new String[] { TREE, FILE }, true);
- }
+ /**
+ * Represents Tests Selection Choice Question. Exctracted to separate class
+ * for extensibility purposes
+ */
+ public class TreeOrFileChoiceQuestion extends ChoiceQuestion{

- protected Question getNext() {
+ public TreeOrFileChoiceQuestion(Interview interview, String tag) {
+ super(interview, tag);
+ setChoices(getTestSelectionChoices(), true);
+ }
+
+ /**
+ * Should be overriden if more selection choices are needed
+ * @return array of test selection choices
+ */
+ protected String[] getTestSelectionChoices(){
+ return new String[] { TREE, FILE };
+ }
+
+ @Override
+ protected Question getNext() {
if (value == TREE)
return qTestTree;
else
return qTestFile;
- }
- };
+ }
+
+ }
+
+ protected TreeOrFileChoiceQuestion qTreeOrFile = createTreeOrFileChoiceQuestion(this, "treeOrFile");
+
+ /**
+ * creation of {#link TreeOrFileChoiceQuestion} is extracted into separate class
+ * to enable 'hooks' and return {#link TreeOrFileChoiceQuestion} sub class
+ * @param interview
+ * @param tag
+ * @return insctance of TreeOrFileChoiceQuestion
+ */
+ protected TreeOrFileChoiceQuestion createTreeOrFileChoiceQuestion(Interview interview, String tag){
+ return new TreeOrFileChoiceQuestion(interview, tag);
+ }

//----------------------------------------------------------------------------
//
@@ -318,7 +351,7 @@
}
};

- private TreeQuestion qTestTree = new TreeQuestion(this, "tests", model) {
+ protected TreeQuestion qTestTree = new TreeQuestion(this, "tests", model) {
/* Ugly, this would seem to be helpful, but it precludes getting to the
ErrorQuestion
public boolean isValueValid() {
@@ -409,7 +442,7 @@
//
// End

- private Question qEnd = new FinalQuestion(this);
+ protected Question qEnd = new FinalQuestion(this);

//----------------------------------------------------------------------------

Index: com/sun/javatest/interview/BasicInterviewParameters.java
===================================================================
--- com/sun/javatest/interview/BasicInterviewParameters.java (revision 766)
+++ com/sun/javatest/interview/BasicInterviewParameters.java (working copy)
@@ -61,7 +61,7 @@
// leave this to the subtype to decide whether to provide or not
//setHelpSet("/com/sun/javatest/moreInfo/moreInfo.hs");

- iTests = new TestsInterview(this);
+ iTests = createTestsInterview(this);
iExcludeList = new ExcludeListInterview(this);
iKeywords = new KeywordsInterview(this);
iPriorStatus = new PriorStatusInterview(this);
@@ -70,7 +70,7 @@

setFirstQuestion(qProlog);
}
-
+
/**
* Create a BasicInterviewParameters object.
* @param tag the tag used to qualify questions in this interview
@@ -83,6 +83,18 @@
this(tag);
setTestSuite(ts);
}
+
+ /**
+ * creation of {#link TestsInterview} is extracted into separate class
+ * to enable 'hooks' and return {#link TestsInterview} sub class
+ * @param parent
+ * @return instance of {#link TestsInterview}
+ * @throws com.sun.interview.Interview.Fault
+ */
+ protected TestsInterview createTestsInterview(InterviewParameters parent)
+ throws InterviewParameters.Fault{
+ return new TestsInterview(parent);
+ }

/**
* Specify whether or not to include standard questions in the
@@ -301,7 +313,7 @@

private TestSuite testSuite;
private WorkDirectory workDir;
- private TestsInterview iTests;
+ protected TestsInterview iTests;
private ExcludeListInterview iExcludeList;
private KeywordsInterview iKeywords;
private PriorStatusInterview iPriorStatus;
Index: com/sun/interview/TreeQuestion.java
===================================================================
--- com/sun/interview/TreeQuestion.java (revision 766)
+++ com/sun/interview/TreeQuestion.java (working copy)
@@ -323,7 +323,7 @@
data.put(tag, join(value));
}

- private static String[] split(String s) {
+ public static String[] split(String s) {
if (s == null)
return empty;

@@ -350,7 +350,7 @@
return a;
}

- private static String join(String[] paths) {
+ public static String join(String[] paths) {
if (paths == null || paths.length == 0)
return "";

@@ -368,7 +368,7 @@
return sb.toString();
}

- private static boolean white(char c) {
+ public static boolean white(char c) {
return (c == ' ' || c == '\t' || c == '\n');
}