What you're trying to do is modify the process flow of your application with probes.  Probekit isn't really made for this.  Probes are typically used to collect detailed runtime information about the application being instrumented.  Changing the normal process flow of your application with Probekit is not recommended.

Now, having said that, it's still possible to throw an exception in your fragment code.  

1) First you'll need to add in the "throw new IOException();" to your code fragment.
2) Add java.io.IOException to your imports page
3) Switch to the Java class created for your probe and add "throws Exception" to the appropriate method header

There will be a red X on your probekit source file, but it won't cause any problems.  Also, every time you change your probe in the probekit source file, you'll need to add in the "throws Exception" to the method header.

Thanks,

Navid Mehregani



"Alex Soto" <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]

20/07/2006 02:52 AM

Please respond to
TPTP Tracing and Profiling Tools Project developer discussions <tptp-tracing-profiling-tools-dev@eclipse.org>

To
"TPTP Tracing and Profiling Tools Project developer discussions" <tptp-tracing-profiling-tools-dev@eclipse.org>
cc
Subject
Re: [tptp-tracing-profiling-tools-dev] And more things        about        exceptions in Probe Insertion





sorry for my bad explanation, i try to explain with an example. I have a
method that writes information to disk. This method throws IOException
if cannot write information to disk (disk is full, ...). So if i have a
class called SaveInformation with a method saveInformation, that uses a
class called IOUtils that has a method writeDisk, i would have something
like:

void saveInformation(...) {

try{

   IOUtils.writeDisk(....);

catch(IOEXception e) {
   e.printStackTrace();
}

}


If i want a 100% of code coverage i need that writeDisk throws a
IOException, of course i could think that for example create a directory
without permissions, but this would be bad because every testing machine
would need this directory. For this reason if i could create a
ProbeInsertion that  simply when someone called writeDisk, the probe
insertion fragment throws new IOEXception(), a 100% of code coverage
would reach, and the tester would not to create extra resources like
directories.


Thank you very much.

Navid Mehregani wrote:
>
> I don't quite understand why you want to do this.  Can you explain
> what you mean by : "So i can simulate all IOExceptions without having
> to think in real files
> that would throw this kind of exception."
>
> Unfortunately fragments can't throw an exception.  The Java method
> generated for them don't specify this in their header and you can't
> modify the generated Java class yourself.  It'll just get overwritten
> by the Probekit editor.  I might be able to help you out if you
> further explain the logic behind what you're doing.
>
> Navid Mehregani
>
>
>
> *"Alex Soto" <[EMAIL PROTECTED]>*
> Sent by: [EMAIL PROTECTED]
>
> 19/07/2006 09:23 AM
> Please respond to
> TPTP Tracing and Profiling Tools Project developer discussions
> <tptp-tracing-profiling-tools-dev@eclipse.org>
>
>
>                  
> To
>                  "TPTP Tracing and Profiling Tools Project developer discussions"
> <tptp-tracing-profiling-tools-dev@eclipse.org>
> cc
>                  
> Subject
>                  [tptp-tracing-profiling-tools-dev] And more things about exceptions  
>      in Probe Insertion
>
>
>
>                  
>
>
>
>
>
> Hello, i think that everybody has noted that i m betting seriously in
> TPTP and Probe Insertion. Ok, the problem now is that i want to simulate
> an IOException using probeinsertion. My injected code is as simple as
> if(methodname.equals("method")) {
>
>    throw new IOException();
> }
>
> So i can simulate all IOExceptions without having to think in real files
> that would throw this kind of exception. The problem is that the method
> _entry doesn't throw any exception so it is impossible to simulate
> because the exception isn't propagated. Only adding throws Throwable to
> this method, this problem would be required. But if i added manually,
> then when i try probekit eclipse editor, an error occurs, and all the
> information is deleted. Is there any way to throw specific expcetions in
> fragment code? With runtime exception would be great, but for example
> IOException extends from Exception.
>
> Thank you very much for your attention.



La información contenida en el presente e-mail es confidencial y está reservada para el uso exclusivo de su destinatario. Se prohíbe estrictamente la distribución, copia o utilización de esta información sin el previo permiso de su destinatario. Si usted no fuera el destinatario, por favor notifíquelo inmediatamente al remitente y elimine el presente mensaje de su sistema informático.

Information contained in this e-mail is confidential and is intended for the use of the addressee only. Any dissemination, distribution, copying or use of this communication without prior permission of the addressee is strictly prohibited. If you are not the intended addressee, please notify the sender immediately by reply and then delete this message from your computer system.
_______________________________________________
tptp-tracing-profiling-tools-dev mailing list
tptp-tracing-profiling-tools-dev@eclipse.org
https://dev.eclipse.org/mailman/listinfo/tptp-tracing-profiling-tools-dev

_______________________________________________
tptp-tracing-profiling-tools-dev mailing list
tptp-tracing-profiling-tools-dev@eclipse.org
https://dev.eclipse.org/mailman/listinfo/tptp-tracing-profiling-tools-dev

Reply via email to