[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit HTMLPage.java,1.7,1.8 WebResponse.java,1.
Brought to you by:
russgold
From: Russell G. <rus...@us...> - 2002-08-30 18:17:51
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv5119/src/com/meterware/httpunit Modified Files: HTMLPage.java WebResponse.java Log Message: Added support for location property Index: HTMLPage.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLPage.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- HTMLPage.java 30 Aug 2002 15:20:08 -0000 1.7 +++ HTMLPage.java 30 Aug 2002 18:17:48 -0000 1.8 @@ -157,8 +157,25 @@ WebImage wi = getImageWithName( propertyName ); if (wi != null) return wi.getScriptableObject(); - return super.get( propertyName ); + if (propertyName.equalsIgnoreCase( "location" )) { + return getResponse().getScriptableObject().get( "location" ); + } else { + return super.get( propertyName ); + } } + + + /** + * Sets the value of the named property. Will throw a runtime exception if the property does not exist or + * cannot accept the specified value. + **/ + public void set( String propertyName, Object value ) { + if (propertyName.equalsIgnoreCase( "location" )) { + getResponse().getScriptableObject().set( "location", value ); + } else { + super.set( propertyName, value ); + } + } public String getTitle() throws SAXException { Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.77 retrieving revision 1.78 diff -u -r1.77 -r1.78 --- WebResponse.java 23 Aug 2002 19:33:13 -0000 1.77 +++ WebResponse.java 30 Aug 2002 18:17:48 -0000 1.78 @@ -534,6 +534,37 @@ runScript( getReceivedPage().getScripts() ); doEvent( getReceivedPage().getOnLoadEvent() ); } + + + /** + * Returns the value of the named property. Will return null if the property does not exist. + **/ + public Object get( String propertyName ) { + if (propertyName.equalsIgnoreCase( "location" )) { + return WebResponse.this._url.toExternalForm(); + } else { + return super.get( propertyName ); + } + } + + + /** + * Sets the value of the named property. Will throw a runtime exception if the property does not exist or + * cannot accept the specified value. + **/ + public void set( String propertyName, Object value ) { + if (propertyName.equalsIgnoreCase( "location" )) { + try { + getClient().getResponse( new GetMethodWebRequest( _url, value.toString(), _frameName ) ); + } catch (IOException e) { + throw new RuntimeException( "Error handling 'location=': " + e ); + } catch (SAXException e) { + throw new RuntimeException( "Error handling 'location=': " + e ); + } + } else { + super.set( propertyName, value ); + } + } } |