Author: keith Date: Thu Feb 12 01:59:16 2009 New Revision: 30711 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=30711
Log: adding patch to branch uthor: keith Date: Wed Sep 3 04:29:35 2008 New Revision: 21428 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=21428 Log: Adding in a test for testing the JSON support in the MashupServer Added: branches/mashup/java/1.5/java/modules/integration/test-resources/scripts/WSRequestTest.js branches/mashup/java/1.5/java/modules/integration/test/org/wso2/mashup/integration/WSRequestHostObjectIntegrationTest.java Modified: branches/mashup/java/1.5/java/modules/integration/test/org/wso2/mashup/integration/IntegrationTestSuite.java Added: branches/mashup/java/1.5/java/modules/integration/test-resources/scripts/WSRequestTest.js URL: http://wso2.org/svn/browse/wso2/branches/mashup/java/1.5/java/modules/integration/test-resources/scripts/WSRequestTest.js?pathrev=30711 ============================================================================== --- (empty file) +++ branches/mashup/java/1.5/java/modules/integration/test-resources/scripts/WSRequestTest.js Thu Feb 12 01:59:16 2009 @@ -0,0 +1,34 @@ +/* + * Copyright 2007,2008 WSO2, Inc. http://www.wso2.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +testJSON.outputType="#raw"; +function testJSON(){ + var request = new WSRequest(); + var options = new Array(); + options.HTTPInputSerialization = "application/json/badgerfish"; + options.HTTPLocation = "weather/{city}"; + var payload = <POSTWeather><city>kandy</city><weatherDetails>22</weatherDetails></POSTWeather>; + var result; + try { + request.open(options,"http://localhost:11001/services/system/RESTSample/", false); + request.send(payload); + result = request.responseE4X; + } catch (e) { + system.log(e.toString(),"error"); + result = e.toString(); + } + return result +} Modified: branches/mashup/java/1.5/java/modules/integration/test/org/wso2/mashup/integration/IntegrationTestSuite.java URL: http://wso2.org/svn/browse/wso2/branches/mashup/java/1.5/java/modules/integration/test/org/wso2/mashup/integration/IntegrationTestSuite.java?rev=30711&r1=30710&r2=30711&view=diff ============================================================================== --- branches/mashup/java/1.5/java/modules/integration/test/org/wso2/mashup/integration/IntegrationTestSuite.java (original) +++ branches/mashup/java/1.5/java/modules/integration/test/org/wso2/mashup/integration/IntegrationTestSuite.java Thu Feb 12 01:59:16 2009 @@ -50,6 +50,7 @@ suite.addTestSuite(SystemHostObjectIntegrationTest.class); suite.addTestSuite(ScraperTest.class); suite.addTestSuite(E4XTest.class); + suite.addTestSuite(WSRequestHostObjectIntegrationTest.class); return new TestSetup(suite) { protected void setUp() throws Exception { Added: branches/mashup/java/1.5/java/modules/integration/test/org/wso2/mashup/integration/WSRequestHostObjectIntegrationTest.java URL: http://wso2.org/svn/browse/wso2/branches/mashup/java/1.5/java/modules/integration/test/org/wso2/mashup/integration/WSRequestHostObjectIntegrationTest.java?pathrev=30711 ============================================================================== --- (empty file) +++ branches/mashup/java/1.5/java/modules/integration/test/org/wso2/mashup/integration/WSRequestHostObjectIntegrationTest.java Thu Feb 12 01:59:16 2009 @@ -0,0 +1,50 @@ +/* + * Copyright 2006-2008 WSO2, Inc. http://www.wso2.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wso2.mashup.integration; + +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.client.ServiceClient; +import org.apache.axis2.client.Options; +import org.apache.axiom.om.OMElement; +import junit.framework.TestCase; + +public class WSRequestHostObjectIntegrationTest extends IntegrationTestSuite + implements IntegrationTestConstants{ + + private EndpointReference endpointReference; + + private ServiceClient sender; + + public void setUp() throws java.lang.Exception { + super.setUp(); + sender = new ServiceClient(); + endpointReference = + new EndpointReference(host + ":" + port + "/" + serviceRoot + "/system/WSRequestTest"); + } + + public void testJSON() throws Exception { + Options options = new Options(); + options.setTo(endpointReference); + options.setAction( + "http://services.mashup.wso2.org/WSRequestTest/ServiceInterface/testJSONRequest"); + sender.setOptions(options); + OMElement result = sender.sendReceive(null); + TestCase.assertNotNull(result); + TestCase.assertEquals("<ws:POSTWeatherResponse " + + "xmlns:ws=\"http://services.mashup.wso2.org/RESTSample?xsd\">" + + "<return>kandy</return></ws:POSTWeatherResponse>", result.toString()); + } +} _______________________________________________ Mashup-dev mailing list [email protected] https://wso2.org/cgi-bin/mailman/listinfo/mashup-dev
