From: Mick F. <mic...@li...> - 2005-06-29 16:04:59
|
Thanks everyone for input on this. In the end I opted for the following in my applet: /** * If we're running a cobertura-instrumented Applet, we need to flush out the data, as not all Browsers * call System.exit(0), which is the normal flush trigger. If the cobertura classes are not available * we do nothing - this is the normal situation. */ public void destroy() { try { Class c = Class.forName("net.sourceforge.cobertura.coveragedata.ProjectData"); Method m = c.getMethod("saveGlobalProjectData", new Class[0]); m.invoke(null, new Object[0]); } catch (Exception e) {} } Regards, Mick. > -----Original Message----- > From: Mark Doliner [mailto:Mar...@sa...] > Sent: 29 June 2005 15:57 > To: Mick Francis > Cc: cob...@li... > Subject: RE: [Cobertura-devel] Use with Applets > > > The static method > net.sourceforge.cobertura.coveragedata.ProjectData.saveGlobalP > rojectData() should cause the currently bufferred coverage > data to be flushed to cobertura.ser (or whichever file you've > specified), if it helps > -Mark > > > -----Original Message----- > > From: Mick Francis [mailto:mic...@li...] > > Sent: Wednesday, June 29, 2005 10:50 AM > > To: Jared Richardson; je...@th...; Mark Doliner > > Cc: cob...@li... > > Subject: RE: [Cobertura-devel] Use with Applets > > > > Hi Jared, > > > > Thanks for the reply. > > > > While I was downloading HotJava, I thought I'd try a 'hack' > > and put a System.exit(0) in the destroy() method of the > > Applet, and it worked! > > Clearly this is no good for normal running, but I can enable > > the System.exit(0) in a properties file when it comes to test time. > > > > I wonder if there's a method in the cobertura classes I can > > call to force the writing rather than it waiting for exit? > > That way I could just test for the existence of the class, > > and call the method if it's there - no properties file > > jiggery-pokery that way... > > > > Regards, > > > > Mick. > > > > -----Original Message----- > > From: Jared Richardson [mailto:Jar...@sa...] > > Sent: 29 June 2005 15:35 > > To: Mick Francis; je...@th...; Mark Doliner > > Cc: cob...@li... > > Subject: RE: [Cobertura-devel] Use with Applets > > > > > > Try downloading HotJava from Sun. It has a much cleaner > > applet implementation and might get the ser file. I haven't > > tried this, but for coverage purposes, it shouldn't matter > > which browser you use, right? > > > > http://java.sun.com/products/archive/hotjava/ > > > > Jared > > > > Ship It! is shipping! > > http://www.jaredrichardson.net <http://www.jaredrichardson.net> > > http://www.pragmaticprogrammer.com/titles/prj/ > > <http://www.pragmaticprogrammer.com/titles/prj/> > > > > > > ________________________________ > > > > From: > > cob...@li... > > [mailto:cob...@li...] On > > Behalf Of Mick Francis > > Sent: Wednesday, June 29, 2005 10:28 AM > > To: 'je...@th...'; Mark Doliner > > Cc: cob...@li... > > Subject: RE: [Cobertura-devel] Use with Applets > > > > > > Hi Jeremy, > > > > Thanks for the reply. > > > > The Applet runs in Internet Explorer. I've > > looked at the .class files in the .jar, and they all contain > > instrumentation. The fact that it works when I run the 'main' > > method (added for testing) from the command line (using > > exactly the same .jar file) implies to me that the problem > > lies somewhere in the Applet mechanism... > > > > Mick. > > > > -----Original > > > > > > > > > > This message has been scanned for viruses by MailController > > <http://www.mailcontroller.altohiway.com/> . > > > > > |