[ptt-users] omission in post parameters

Geoff Meakin geoffm at gamesys.co.uk
Sat Jan 6 11:25:02 PST 2007


Oops ! 

I dont know why thats there sorry!

-Geoff



-----Original Message-----
From: users-bounces at lists.pushtotest.com on behalf of Frank Cohen
Sent: Sat 06/01/2007 16:46
To: TestMaker users list
Subject: Re: [ptt-users] omission in post parameters 
 
Hi Geoff: I'm curious about the following:

>         try:
>
>             self.body.setContentType(contenttype)
>
>         except:
>
>             print "Unexpected error:", sys.exc_info()[0]
>
>             self.body.setContentType(contenttype)

So if you get an exception while setting the content type, the code  
prints the error, and then tries to set the content type again?

-Frank



On Dec 4, 2006, at 5:59 AM, Geoff Meakin wrote:

> Hi Frank,
>
>
>
> I have solved my problem by tweaking an agentbase function and a  
> tool java class and include the code below- feel free to add it  
> into the source if you feel its appropriate (personally I think  
> it's a really useful thing to be able to do).
>
>
>
> It now allows you to control the content type of a http-post, and  
> also post a pure value as well as key=value.
>
>
>
> In agentbase.py, post now reads:
>
>
>
>     def post( self, url, params=None, contenttype='application/x- 
> www-form-urlencoded' ):
>
>
>
> And after setting the protocol I do:
>
>
>
>         try:
>
>             self.body.setContentType(contenttype)
>
>         except:
>
>             print "Unexpected error:", sys.exc_info()[0]
>
>             self.body.setContentType(contenttype)
>
>
>
> And I have modified com/pushtotest/tool/protocolhandler/ 
> HTTPBody.java as follows:
>
>
>
> In the class declaration:
>
>
>
>     private String contenttype = "application/x-www-form-urlencoded";
>
>
>
> Modified addHeaders() method:
>
>
>
>         public void addHeaders( HttpURLConnection con ) {
>
>         con.setRequestProperty("Content-Type", contenttype);
>
>     }
>
>
>
> New method: setContentType:
>
>
>
>     public void setContentType( String newtype )
>
>     {
>
>         contenttype=newtype;
>
>     }
>
>
>
> Finally I have modified the method paramsAsString() as follows:
>
>
>
>  ...
>
>         for (int i=0; i < size; i++) {
>
>             nkv = (keyvalue) params.elementAt( i );
>
>
>
>             String key = nkv.getKey();
>
>             String value = nkv.getValue();
>
>
>
>             if (key.length()==0) {
>
>                 buffer.append(value);
>
>             } else {
>
>                 buffer.append(key).append("=").append(value);
>
>             }
>
>
>
> Cheers
>
> -Geoff
>
>
>
> From: users-bounces at lists.pushtotest.com [mailto:users- 
> bounces at lists.pushtotest.com] On Behalf Of Geoff Meakin
> Sent: 01 December 2006 10:59
> To: TestMaker users list; users at lists.pushtotest.com
> Subject: RE: [ptt-users] omission in post parameters
>
>
>
> Hi,
>
> I have just read the w3c recs and spec, and note that basically you  
> can POST what you like as part of a POST request, but what is legal  
> depends on the Content-Type header declaration.
>
> Therefore for a application/x-www-form-urlencoded they do indeed  
> have to be key/value pairs, encoded properly.
>
> Therefore in this respect my application under test breaks the w3c  
> recs (nice)
>
> However, we are now modifying the Content-Type to text/xml, which  
> allows you to POST just xml.
>
> How would I do this in testmaker please?
>
> I.e. come up with something that looks like this:
>
> POST /url HTTP/1.1
> Host: foo.bar.com
> Content-Type: text/xml
> ..... more headers .....
>
> <some><xml></xml></some>
>
>
> Thanks
> -Geoff
>
>
>
> -----Original Message-----
> From: users-bounces at lists.pushtotest.com on behalf of  
> Mark.Lutton at thomson.com
> Sent: Thu 30/11/2006 18:55
> To: users at lists.pushtotest.com
> Subject: FW: [ptt-users] omission in post parameters
>
> I don't think it is meaningful to have a single value without a  
> key.  Here is an example of a POST request, which I got from http:// 
> www.jmarshall.com/easy/html/ :
>
> POST /path/script.cgi HTTP/1.0
> From: frog at jmarshall.com
> User-Agent: HTTPTool/1.0
> Content-Type: application/x-www-form-urlencoded
> Content-Length: 32
>
> home=Cosby&favorite+flavor=flies
>
> You could also do this in the URL by putting the parameters into  
> the query:
>
>   http://hostname.com/path/script.cgi?home=Cosby&favorite+flavor=flies
>
> But I don't know what the following means:
>
>  http://hostname.com/path/script.cgi?Cosby
>
> Likewise:
>
> POST /path/script.cgi HTTP/1.0
> From: frog at jmarshall.com
> User-Agent: HTTPTool/1.0
> Content-Type: application/x-www-form-urlencoded
> Content-Length: 5
>
> Cosby
>
>
> In both cases Cosby looks like the key, not the value.  On the  
> server side, what would ServletRequest.getParameterMap() return?
>
> A parameter value can be an array of strings; a single string is  
> equivalent to an array containing one string.  Is this what you are  
> thinking of?  I don't know the syntax for an array of values but I  
> guess it would be like this:
>
>    self.params=[ [ '''key''', [ '''value1''', '''value2''',  
> '''value3''' ] ] ]
>
> So the following two would be equivalent:
>
>    self.params= [ [ '''key''', [ '''value''' ] ] ]
>
>    self.params= [ [ '''key''', '''value''' ] ]
>
>
> Mark Lutton
> Business Intelligence Services, a Thomson Business
>
>
> ________________________________
>
> From: users-bounces at lists.pushtotest.com on behalf of Geoff Meakin
> Sent: Thu 11/30/2006 12:59 PM
> To: TestMaker users list
> Subject: [ptt-users] omission in post parameters
>
>
>
> Hi all,
>
> Does anyone know how to post a singleton parameter
>
> Normally:
>
> self.params= [ [ '''key''', '''value''' ] ]
> self.post(url)
>
> However it should be possibly to also post:
>
> self.params= [ [ '''value''' ] ]
> self.post(url)
>
> but doing this leads to an index out of bounds.
>
> I've checked HTTPBody.java and it DOES NOT have a method:
> addParameter(String value)
>
> If anyone can help with how to do this, it would be gratefully
> appreciated!
> Or indeed any other thoughts... am a bit stuck out here!
>
> Cheers
> -Geoff
>
>
>
> -----Original Message-----
> From: users-bounces at lists.pushtotest.com
> [mailto:users-bounces at lists.pushtotest.com] On Behalf Of Kyle Bell
> Sent: 30 November 2006 15:40
> To: TestMaker users list
> Subject: Re: [ptt-users] TestMaker 5 completion specification
>
> Frank,
>
> I know you were looking for some example code associated with SIP
> enabled instant messaging clients.  Follow the link below and click on
> the Sip Communicator.  This is a NIST sponsored IM and telephony  
> client.
>
> http://snad.ncsl.nist.gov/proj/iptel/
>
> Regards,
>
> -Kyle
>
> On Wed, 2006-11-29 at 08:03 -0800, Frank Cohen wrote:
> > That explains it. :-( Oh well. Thanks for finding this. I'll see  
> what
>
> > I can do when I write the TM 5 build scripts. Maybe I'll write my  
> own
>
> > zip handler. -Frank
> >
> >
> > On Nov 29, 2006, at 7:42 AM, Kyle Bell wrote:
> >
> > > Frank,
> > >
> > > I found this tidbit from the ant user manual -> core tasks -> zip:
> > >
> > > Starting with Ant 1.5.2, <zip> can store Unix permissions  
> inside the
> > > archive (see description of the filemode and dirmode attributes  
> for
> > > <zipfileset>). Unfortunately there is no portable way to store  
> these
> > > permissions. Ant uses the algorithm used by Info-Zip's
> > > implementation of
> > > the zip and unzip commands - these are the default versions of zip
> and
> > > unzip for many Unix and Unix-like systems.
> > >
> > >
> > > Please note that the zip format allows multiple files of the same
> > > fully-
> > > qualified name to exist within a single archive. This has been
> > > documented as causing various problems for unsuspecting users. If
> you
> > > wish to avoid this behavior you must set the duplicate  
> attribute to
> a
> > > value other than its default, "add".
> > >
> > > This likely explains your issue.  The options available for the
> > > duplicate attribute are as follows:
> > >
> > > duplicate -> behavior when a duplicate file is found. Valid values
> are
> > > "add", "preserve", and "fail". The default value is "add".
> > >
> > > In your zip task you may try specifying "preserve" as the value
> rather
> > > than the default of "add" and see where that takes you...
> > >
> > > Hope this helps...
> > >
> > > -Kyle
> > >
> > >
> > >
> > > On Mon, 2006-11-27 at 10:52 -0800, Frank Cohen wrote:
> > >> Hi Kyle: Thanks for the feedback. See below. -Frank
> > >> On Nov 27, 2006, at 9:41 AM, Kyle Bell wrote:
> > >>
> > >>> Frank,
> > >>>
> > >>> Nice feature list.  I especially appreciate the first new  
> feature
>
> > >>> idea
> > >>> by Bongos Amigos.  I've not spent any time finding a good use  
> for
> > >>> those
> > >>> generated XML files and this would make them immediately  
> useful...
> > >>
> > >> Attached is an example TestScenario XML file. I'd love  
> feedback on
>
> > >> it.
> > >>
> > >>> Another enhancement or bug as it may be seen that I'd like to  
> see
> > >>> addressed is the ability to kill a running TestCase from the
> > >>> TestMaker
> > >>> IDE which is not being controlled by XSTest.  If a test case is
> > >>> running
> > >>> within the browser (perhaps it was written to run in an infinite
> > >>> loop
> > >>> correctly or by accident), I've not found a way to kill this
> running
> > >>> process as the "stop the agent" button appears not to be
> effective.
> > >>
> > >> Interesting. When you click the stop button TestMaker kills the
> > >> thread running the script. That's not a very nice way to do  
> it, but
> > >> it's something necessary. I suppose another way would be to  
> have a
> > >> signal to the running test case to stop. I'll give this some
> thought.
> > >> Thanks for making me aware of the problem.
> > >>
> > >>
> > >>
> > >>> Also, could I get you to make a small change to your ANT script
> > >>> which
> > >>> packages your distribution?  I had previously suggested (and you
> > >>> implemented) a change to make the permissions 755 on  
> TestMaker.sh
>
> > >>> when
> > >>> you perform your packaging.  Could I talk you into doing the  
> same
>
> > >>> with
> > >>> TestMaker.bat?  I also run TestMaker in some Windows systems  
> and I
> > >>> find
> > >>> myself doing this within a cygwin environment as well.  Cygwin
> > >>> requires
> > >>> executable permissions on batch files for execution purposes and
> > >>> this
> > >>> would prevent the step of changing permissions for other  
> TestMaker
> > >>> users
> > >>> running in this environment.
> > >>
> > >> I'm ok with making that change.
> > >>
> > >> Maybe you can help me with a different problem. The way the
> build.xml
> > >> script is written now, the .sh files are correctly set with  
> the 755
> > >> permissions, but the resulting Zip file has two copies of the .sh
> > >> files. It's totally weird to me to see WinZip on Windows ask  
> if it
> > >> can overwrite the .sh files. Any idea what I'm doing wrong?
> > >>
> > >>
> > >>>
> > >>> Since you included my suggestion for a SIP UAC/UAS I now wish I
> had
> > >>> edited it a little more closely...  :o)  I'm unsure how you plan
> to
> > >>> implement this feature in a single day (I rather thought  
> there was
> > >>> more
> > >>> than a days work there) but kudos if you can accomplish it.   
> I'll
> be
> > >>> working this week on a piece of code to handle new connection
> > >>> requests
> > >>> on a UAS.  If you are interested in the code once I get it
> polished,
> > >>> I'll happily hand it over.  I borrowed the design idea from  
> Simon
> > >>> Foster's "Forwarding and Redirecting Network Ports" section  
> 13.13
> > >>> of the
> > >>> "Python Cookbook", O'Reilly publishing.
> > >>
> > >> All the days are just estimates right now. I'm meeting with the
> > >> engineers this week to get their estimate. Please send me the  
> code
> > >> you create. I'd love to see your approach.
> > >>
> > >>>
> > >>> In the future, you may also use your recorder on SIP  
> messaging by
> > >>> redirecting your instant messenger to TestMaker as a proxy.   
> This
> > >>> kinda
> > >>> opens up a whole new realm of possibilities here as well...
> > >>
> > >> Totally agree with you on this. The proxy would easily  
> extended to
> > >> record SIP sessions and create test cases.
> > >>
> > >>>
> > >>> Thanks for the terrific work, Frank.  If I come up with more
> > >>> commentary,
> > >>> I'll pass it along.
> > >>>
> > >>> -Kyle
> > >>>
> > >>>
> > >>> On Wed, 2006-11-22 at 17:08 -0800, Frank Cohen wrote:
> > >>>> Work on TestMaker 5 continues. I wrote up a specification of  
> the
> > >>>> remaining projects to complete. I expect PushToTest will  
> fund the
> > >>>> development of the projects in this specification. I would love
> to
> > >>>> hear your feedback, suggestions, and prioritization.
> > >>>>
> > >>>> Download the TestMaker 5 completion specification document at:
> > >>>> http://downloads.pushtotest.com/tm5/TM5_Specification.pdf
> > >>>>
> > >>>> The document is 444K in Adobe Acrobat format. Please post your
> > >>>> feedback to this list.
> > >>>>
> > >>>> Thanks.
> > >>>>
> > >>>> -Frank
> > >>>>
> > >>>> --
> > >>>> Frank Cohen, PushToTest, http://www.PushToTest.com, phone  
> 408 374
> > >>>> 7426
> > >>>> Enterprise test automation solutions to check and monitor Web-
> > >>>> enabled
> > >>>> applications for functionality, scalability and reliability.
> > >>>>
> > >>>>
> > >>>>
> > >>>> _______________________________________________
> > >>>> Users mailing list
> > >>>> Users at lists.pushtotest.com
> > >>>> http://lists.pushtotest.com/mailman/listinfo/users
> > >>>>
> > >>>
> > >>> _______________________________________________
> > >>> Users mailing list
> > >>> Users at lists.pushtotest.com
> > >>> http://lists.pushtotest.com/mailman/listinfo/users
> > >>>
> > >>
> > >> _______________________________________________
> > >> Users mailing list
> > >> Users at lists.pushtotest.com
> > >> http://lists.pushtotest.com/mailman/listinfo/users
> > >
> > > _______________________________________________
> > > Users mailing list
> > > Users at lists.pushtotest.com
> > > http://lists.pushtotest.com/mailman/listinfo/users
> > >
> >
> > _______________________________________________
> > Users mailing list
> > Users at lists.pushtotest.com
> > http://lists.pushtotest.com/mailman/listinfo/users
> >
>
> _______________________________________________
> Users mailing list
> Users at lists.pushtotest.com
> http://lists.pushtotest.com/mailman/listinfo/users
> _______________________________________________
> Users mailing list
> Users at lists.pushtotest.com
> http://lists.pushtotest.com/mailman/listinfo/users
>
>
> _______________________________________________
> Users mailing list
> Users at lists.pushtotest.com
> http://lists.pushtotest.com/mailman/listinfo/users
>
> _______________________________________________
> Users mailing list
> Users at lists.pushtotest.com
> http://lists.pushtotest.com/mailman/listinfo/users

_______________________________________________
Users mailing list
Users at lists.pushtotest.com
http://lists.pushtotest.com/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cake.pushtotest.com/pipermail/users/attachments/20070106/98ba8c38/attachment-0001.htm


More information about the Users mailing list