new to grinder!!!!!!!!!!!!!!

anand vinoth <anand_vinoth-/[email protected]> Tue, 3 Jan 2006 04:39:16 -0800 (PST)
Newsgroups gmane.comp.java.grinder.announce,gmane.comp.java.grinder.user,gmane.comp.java.grinder.devel
Message-ID <[email protected]>
--0-1455642904-1136291956=:6205
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

hello friends, iam anand working in a software concern as java Tester,iam=
 new to grinder iam using Junit as a tool for my tests i found griner as =
a tool for multithreading and it works really good but i need to be exper=
t in grinder,i have one doubt hope u will help me Thanks in advance.follo=
wing code is my grinder.py file and its working fine when i tried enhanci=
ng its gives error iam not able to find out please help me,i have pasted =
it below go through log files also.And onmore thing is its not showing fo=
r errors.Actually i need to know what is the syntax i should implement to=
 catch the exception comes from the .java source file.let me paste my sim=
ple java code also below i just written one src file and testing it which=
 returns a string.i want to print that result in file in grinder and too =
i need to know how to catch throwed exception in grinder?
  =20
  grinder.py file:
  =20
    from net.grinder.script import Test
  from net.grinder.script.Grinder import grinder
  from java.lang import String
  from com.kstc.test import Testhelloworld
  =20
  test1 =3D Test(1, "JUnit HelloWorld Test")
  th1 =3D test1.wrap(Testhelloworld())
 =20
  =20
  class TestRunner:
  def __call__(self):
  result=3Dth1.testhelloworld()=20
  =20
  when i tried to get the out put  of the result and print it in the file=
 its not working giving error Invalid Syntax.the following is the code:
  =20
  from net.grinder.script import Test
  from net.grinder.script.Grinder import grinder
  from java.lang import String
  from com.kstc.test import Testhelloworld
  =20
  test1 =3D Test(1, "JUnit HelloWorld Test")
  th1 =3D test1.wrap(Testhelloworld())
  =20
  def writeToFile(text):
  filename =3D grinder.getFilenameFactory().createFilename(
  "page", "-%d.html" % grinder.runNumber)
  file =3D open(filename, "w")
  print >> file, text
  file.close()
  =20
 =20
  class TestRunner:
  def __call__(self):
  statistics =3D grinder.statistics
  result=3Dth1.testhelloworld()=20
  grinder.logger.output("The last test took %d milliseconds" % statistics=
.time)=20
  try:=20
  writeToFile(result)
  except IoError, ioe:
  grinder.logger.output("Exception :" ,ioe)=20
  =20
  =20
  please find the Error_log file :
  =20
  1/3/06 5:57:23 PM (process ): Error running worker process (Jython erro=
r encountered initialising test script)
net.grinder.engine.process.JythonScriptExecutionException: Jython error e=
ncountered initialising test script
 at net.grinder.engine.process.JythonScript.<init>(JythonScript.java:81)
 at net.grinder.engine.process.GrinderProcess.run(GrinderProcess.java:223=
)
 at net.grinder.engine.process.GrinderProcess.main(GrinderProcess.java:10=
9)
Caused by: Traceback (innermost last):
  (no code object) at line 0
SyntaxError: ('inconsistent dedent', ('E:\\Projects\\Grinder\\grinder.py'=
, 20, 8, '       grinder.logger.output("The last test took %d millisecond=
s" % statistics.time)                           '))
   at org.python.core.parser.fixParseError(parser.java)
 at org.python.core.parser.parse(parser.java)
 at org.python.core.Py.compile_flags(Py.java)
 at org.python.core.__builtin__.execfile_flags(__builtin__.java)
 at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java)
 at net.grinder.engine.process.JythonScript.<init>(JythonScript.java:78)
 ... 2 more

  =20
  My java Code and Testing :
  =20
  import junit.framework.Assert;
import junit.framework.TestCase;
/*
 * Created on Dec 23, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
 =20
/**
 * @author Administrator
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class Testhelloworld extends TestCase {
=20
 public void setup(){ =20
 }
=20
 public String testhelloworld(){ =20
  Example e =3D new Example();
  String actual =3D e.displayHello();
  String expected =3D "Successful";
  testpass(actual,expected);
  return actual;
 }
=20
 private void testpass(String actual,String expected) {
  try {  =20
   Assert.assertEquals(expected,actual);
   System.out.println("TESTCASE SUCCEEDED");
  }catch (Error e){
   System.out.println("TESTCASE FAILED");
   throw e ;
  } =20
 }
   public static void main(String[] args) {
  new Testhelloworld().testhelloworld();
//  junit.textui.TestRunner.run(Testhelloworld.class);
 }
=20
 class Example {
  public  void main(String args[]) {
   System.out.println("Hello World :");
  }
 =20
  public String displayHello() {
   System.out.println("Hello World :");
   return "Successful";
  }
 }
  }

  =20


	=09
---------------------------------
Yahoo! Shopping
 Find Great Deals on Holiday Gifts at Yahoo! Shopping=20
--0-1455642904-1136291956=:6205
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

<DIV id=3DRTEContent>hello friends, iam anand working in a software conce=
rn as java Tester,iam new to grinder iam using Junit as a tool for my tes=
ts i found griner as a tool for multithreading and it works really good b=
ut i need to be expert in grinder,i have one doubt hope u will help me Th=
anks in advance.following code is my grinder.py file and its working fine=
 when i tried enhancing its gives error iam not able to find out please h=
elp me,i have pasted it below go through log files also.And onmore thing =
is its not showing for errors.Actually i need to know what is the syntax =
i should implement to catch the exception comes from the .java source fil=
e.let me paste my simple java code also below i just written one src file=
 and testing it which returns a string.i want to print that result in fil=
e in grinder and too i need to know how to catch throwed exception in gri=
nder?</DIV>  <DIV>&nbsp;</DIV>  <DIV><STRONG>grinder.py file:</STRONG></D=
IV>  <DIV>&nbsp;</DIV>  <DIV><FONT size=3D2>=20
 <div>from net.grinder.script import Test</div>  <div>from net.grinder.sc=
ript.Grinder import grinder</div>  <div>from java.lang import String</div=
>  <div>from com.kstc.test import Testhelloworld</div>  <div>&nbsp;</div>=
  <div>test1 =3D Test(1, "JUnit HelloWorld Test")</div>  <div>th1 =3D tes=
t1.wrap(Testhelloworld())</div>  <div></div>  <div>&nbsp;</div>  <div>cla=
ss TestRunner:</div>  <div>def __call__(self):</div>  <div>result=3Dth1.t=
esthelloworld() </div>  <div>&nbsp;</div>  <div>when i tried to get the o=
ut put&nbsp; of the result and print it in the file its not working givin=
g error Invalid Syntax.the following is the code:</div>  <div>&nbsp;</div=
><FONT size=3D2>  <div>from net.grinder.script import Test</div>  <div>fr=
om net.grinder.script.Grinder import grinder</div>  <div>from java.lang i=
mport String</div>  <div>from com.kstc.test import Testhelloworld</div>  =
<div>&nbsp;</div>  <div>test1 =3D Test(1, "JUnit HelloWorld Test")</div> =
 <div>th1 =3D test1.wrap(Testhelloworld())</div>=20
 <div>&nbsp;</div>  <div>def writeToFile(text):</div>  <div>filename =3D =
grinder.getFilenameFactory().createFilename(</div>  <div>"page", "-%d.htm=
l" % grinder.runNumber)</div>  <div>file =3D open(filename, "w")</div>  <=
div>print &gt;&gt; file, text</div>  <div>file.close()</div>  <div>&nbsp;=
</div>  <div></div>  <div>class TestRunner:</div>  <div>def __call__(self=
):</div>  <div>statistics =3D grinder.statistics</div>  <div>result=3Dth1=
.testhelloworld() </div>  <div>grinder.logger.output("The last test took =
%d milliseconds" % statistics.time) </div>  <div>try: </div>  <div>writeT=
oFile(result)</div>  <div>except IoError, ioe:</div>  <div>grinder.logger=
.output("Exception :" ,ioe) </div></FONT>  <div>&nbsp;</div>  <div>&nbsp;=
</div>  <div><STRONG>please find the Error_log file :</STRONG></div>  <di=
v>&nbsp;</div>  <div>1/3/06 5:57:23 PM (process ): Error running worker p=
rocess (Jython error encountered initialising test script)<BR>net.grinder=
.engine.process.JythonScriptExecutionException: Jython
 error encountered initialising test script<BR>&nbsp;at net.grinder.engin=
e.process.JythonScript.&lt;init&gt;(JythonScript.java:81)<BR>&nbsp;at net=
.grinder.engine.process.GrinderProcess.run(GrinderProcess.java:223)<BR>&n=
bsp;at net.grinder.engine.process.GrinderProcess.main(GrinderProcess.java=
:109)<BR>Caused by: Traceback (innermost last):<BR>&nbsp; (no code object=
) at line 0<BR>SyntaxError: ('inconsistent dedent', ('E:\\Projects\\Grind=
er\\grinder.py', 20, 8, '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; grinder.log=
ger.output("The last test took %d milliseconds" % statistics.time)&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp; '))</div>  <div>&nbsp;at org.python.core.parser.fixParseError(parser.=
java)<BR>&nbsp;at org.python.core.parser.parse(parser.java)<BR>&nbsp;at o=
rg.python.core.Py.compile_flags(Py.java)<BR>&nbsp;at
 org.python.core.__builtin__.execfile_flags(__builtin__.java)<BR>&nbsp;at=
 org.python.util.PythonInterpreter.execfile(PythonInterpreter.java)<BR>&n=
bsp;at net.grinder.engine.process.JythonScript.&lt;init&gt;(JythonScript.=
java:78)<BR>&nbsp;... 2 more<BR></div>  <div>&nbsp;</div>  <div><STRONG>M=
y java Code and Testing</STRONG> <STRONG>:</STRONG></div>  <div>&nbsp;</d=
iv>  <div>import junit.framework.Assert;<BR>import junit.framework.TestCa=
se;<BR>/*<BR>&nbsp;* Created on Dec 23, 2005<BR>&nbsp;*<BR>&nbsp;* TODO T=
o change the template for this generated file go to<BR>&nbsp;* Window - P=
references - Java - Code Style - Code Templates<BR>&nbsp;*/</div>  <div><=
BR>/**<BR>&nbsp;* @author Administrator<BR>&nbsp;*<BR>&nbsp;* TODO To cha=
nge the template for this generated type comment go to<BR>&nbsp;* Window =
- Preferences - Java - Code Style - Code Templates<BR>&nbsp;*/<BR>public =
class Testhelloworld extends TestCase {<BR>&nbsp;<BR>&nbsp;public void
 setup(){&nbsp;&nbsp;<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;public String testhel=
loworld(){&nbsp;&nbsp;<BR>&nbsp;&nbsp;Example e =3D new Example();<BR>&nb=
sp;&nbsp;String actual =3D e.displayHello();<BR>&nbsp;&nbsp;String expect=
ed =3D "Successful";<BR>&nbsp;&nbsp;testpass(actual,expected);<BR>&nbsp;&=
nbsp;return actual;<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;private void testpass(S=
tring actual,String expected) {<BR>&nbsp;&nbsp;try {&nbsp;&nbsp;&nbsp;<BR=
>&nbsp;&nbsp; Assert.assertEquals(expected,actual);<BR>&nbsp;&nbsp;&nbsp;=
System.out.println("TESTCASE SUCCEEDED");<BR>&nbsp;&nbsp;}catch (Error e)=
{<BR>&nbsp;&nbsp;&nbsp;System.out.println("TESTCASE FAILED");<BR>&nbsp;&n=
bsp;&nbsp;throw e ;<BR>&nbsp;&nbsp;}&nbsp;&nbsp;<BR>&nbsp;}</div>  <div>&=
nbsp;public static void main(String[] args) {<BR>&nbsp;&nbsp;new Testhell=
oworld().testhelloworld();<BR>//&nbsp;&nbsp;junit.textui.TestRunner.run(T=
esthelloworld.class);<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;class Example {<BR>&n=
bsp;&nbsp;public&nbsp; void main(String args[])
 {<BR>&nbsp;&nbsp;&nbsp;System.out.println("Hello World :");<BR>&nbsp;&nb=
sp;}<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;public String displayHello() {<BR>&nb=
sp;&nbsp;&nbsp;System.out.println("Hello World :");<BR>&nbsp;&nbsp;&nbsp;=
return "Successful";<BR>&nbsp;&nbsp;}<BR>&nbsp;}</div>  <div>}<BR></div> =
 <div>&nbsp;</div></FONT></DIV><p>
		<hr size=3D1>Yahoo! Shopping<br>=20
Find Great Deals on Holiday Gifts at <a href=3D"http://us.rd.yahoo.com/ma=
il_us/footer/shopping/*http://shopping.yahoo.com/;_ylc=3DX3oDMTE2bzVzaHJt=
BF9TAzk1OTQ5NjM2BHNlYwNtYWlsdGFnBHNsawNob2xpZGF5LTA1=20
">Yahoo! Shopping</a>=20
--0-1455642904-1136291956=:6205--


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click