Skip to main content

Please review CR 6496109 fix

7 replies [Last post]
bbk
Offline
Joined: 2006-10-13

Please review CR 6496109 fix:
-------------------------------------------

Details are:
- verified that fix is applicable to latest JDTS
- verified that fix is applicable to cases when configuration, which
was previously created, does not contain a reference to a template.

-------------------------------------------------
Index: ConfigManager.java
===================================================================
--- ConfigManager.java (revision 276)
+++ ConfigManager.java (working copy)
@@ -27,6 +27,7 @@

package com.sun.javatest.tool;

+import com.sun.javatest.TestEnvironment;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -56,6 +57,7 @@
import com.sun.javatest.Parameters;
import com.sun.javatest.Status;
import com.sun.javatest.TestSuite;
+import com.sun.javatest.TemplateUtilities;
import com.sun.javatest.WorkDirectory;
import com.sun.javatest.util.DirectoryClassLoader;
//import com.sun.javatest.util.PathClassLoader;
@@ -1391,6 +1393,29 @@
catch (CommandContext.Fault e) {
throw new Fault(e);
}
+
+
+ InterviewParameters cfg;
+
+ try {
+ cfg = ctx.getConfig();
+ } catch (CommandContext.Fault e) {
+ throw new Fault(e);
+ }
+
+ if (cfg.getTemplatePath() == null)
+ return;
+
+ try {
+ TemplateUtilities.setTemplateFile(
+ ctx.getWorkDirectory(),
+ new File(cfg.getTemplatePath()),
+ true);
+ } catch (IOException errorWritingTemplateInfo) {
+ throw new Fault(i18n, "cnfg.writeTemplate.cantWriteTemplateRef");
+ } catch(CommandContext.Fault ctxF) {
+ throw new Fault(ctxF);
+ }
}

/*OLD
Index: i18n.properties
===================================================================
--- i18n.properties (revision 276)
+++ i18n.properties (working copy)
@@ -189,6 +189,7 @@
cnfg.writeConfig.cantWrite=Cannot write to the location {0}
cnfg.writeConfig.writeErr=Unable to write file {0} due to error:\n{1}
cnfg.writeConfig.badConfig=Unable to write the configuration to {0} because of an error:\n{1}
+cnfg.writeTemplate.cantWriteTemplateRef=Error writing template file reference in work directory: {0}

dt.autoExit.txt=The JT Harness will exit automatically in {0} seconds.\n\nClick OK to exit immediately; or, click Cancel to leave the JT Harness harness open.
dt.cantLoadHist.txt=Error loading saved file:

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bbk
Offline
Joined: 2006-10-13

Applied the change

bkurotsu
Offline
Joined: 2004-12-13

Suggest:
throw new Fault(i18n, "cnfg.writeTemplate.cantWriteTemplateRef",
errorWritingTemplateInfo.getMessage());

This would put the IOE explanation message into the fault being created. And we would hope that the IOE provided useful info.

bbk
Offline
Joined: 2006-10-13

Thanks for finding this.

No, suggestion wouldn't be helpful to realize the reason for the problem.
(It would be difficult to realize the reason for IOException).

I've just missed passing a name of WorkDirectory as a second argument value.

Brian Kurotsuchi

Also, you can include multiple args, the path and IOE if you want. Packaged as
an Object[] as the last arg to the Fault.

jtharness@mobileandembedded.org wrote:
> Thanks for finding this.
>
> No, suggestion wouldn't be helpful to realize the reason for the problem.
> (It would be difficult to realize the reason for IOException).
>
> I've just missed passing a name of WorkDirectory as a second argument value.
> [Message sent by forum member 'bbk' (bbk)]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jtharness.dev.java.net
For additional commands, e-mail: interest-help@jtharness.dev.java.net

bbk
Offline
Joined: 2006-10-13

See diff at:
-----
https://jtharness.dev.java.net/source/browse/jtharness/branches/users/bb...
-----
Good point! I would like to develop it and create a separate thread:
(below is short summary of discussion between me and Mike):

Currently, TemplateUtilities.setTemplateFile() throws IOE,

wouldnt throw IOException if an attempt to create a template file
has failed under some circumstances (e.g, no space on disk or file exists etc).

One need to
- correct TemplateUtilities to handle IOExceptions (at least in this particular place).

- introduce a class TemplateUtilities.Fault extends exception,

wrap IOExceptions in TemplateUtilities.Faults and change TemplateUtilities methods
signatures appropriately.

Justification is:
calls to TemplateUtilities methods might cause IOExceptions in
several places and by different reasons in each methods, and while for developer it might be enough to look at stack trace to find exception source, javatest customer (who has no access to javatest sources) may need to see the message that points at misconfiguration or typo in the URL. Wrapping IOExceptions into TemplateUtilities.Faults with TemplateUtilities-layer methods will simplify users' life.

ersh
Offline
Joined: 2006-10-18

How error message with parameter can be formatted? Either remove parameter or process it.

+ } catch (IOException errorWritingTemplateInfo) {
+ throw new Fault(i18n, "cnfg.writeTemplate.cantWriteTemplateRef");
+ } catch(CommandContext.Fault ctxF) {

+cnfg.writeTemplate.cantWriteTemplateRef=Error writing template file reference in work directory: {0}

ersh
Offline
Joined: 2006-10-18

Please provide more understandable diff (make private brunch and send proper url using either java.net's toos)