Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

How to Switch Transports

Options
LegacyForum
LegacyForum Posts: 1,664 ✭✭
edited December 2016 in SOAtest
The first script changes all tests in the suite to HTTP 1.0 with close-connection. The second script changes all tests in the suite to HTTP 1.1 with keep-alive and chunking.

Set to HTTP 1.0:
CODE
from java.lang import *
from com.parasoft.api import *
from com.parasoft.util import Util
from webtool.messaging import *

def setTestToolSettingsA(input,context):
toolTest = context.getParentContext()
testSuite = toolTest.getParentTestSuite()
updateTestSuite(testSuite, context)

def updateTestSuite(testSuite, context):
Application.showMessage("Processing Test Suite: " + testSuite.getName())
tests = testSuite.getTests()
itr = tests.iterator()
while itr.hasNext():
test = itr.next()
if Util.shortClassName(test.getClass()) == "TestSuite":
#recur
updateTestSuite(test, context)
elif Util.shortClassName(test.getClass()) == "SOAPRPCToolTest":
#SOAP test
updateSOAPTest(test, context)

def updateSOAPTest(test, context):
Application.showMessage("Test: " + test.getName())
transportProp = test.getTool().getTransportProperties()
transportProp.setTransport(0); #HTTP 1.0
curHTTPProp = transportProp.getHTTPProperties()
# new HTTP Properties args
branch = curHTTPProp.getParentBranch()
headers = curHTTPProp.getHTTPHeaders()
auth = curHTTPProp.getAuthentication()
keyName = curHTTPProp.getSSLProperties().getKeyStoreDataName()
newHTTPProp = HTTPProperties(branch, 0, headers, auth, keyName)
newHTTPProp.setUseChunking(0) #no chunking
transportProp.setHTTPProperties(newHTTPProp)


Set to HTTP 1.1:
CODE
from java.lang import *
from com.parasoft.api import *
from com.parasoft.util import Util
from webtool.messaging import *

def setTestToolSettingsB(input,context):
toolTest = context.getParentContext()
testSuite = toolTest.getParentTestSuite()
updateTestSuite(testSuite, context)

def updateTestSuite(testSuite, context):
Application.showMessage("Processing Test Suite: " + testSuite.getName())
tests = testSuite.getTests()
itr = tests.iterator()
while itr.hasNext():
test = itr.next()
if Util.shortClassName(test.getClass()) == "TestSuite":
#recur
updateTestSuite(test, context)
elif Util.shortClassName(test.getClass()) == "SOAPRPCToolTest":
#SOAP test
updateSOAPTest(test, context)

def updateSOAPTest(test, context):
Application.showMessage("Test: " + test.getName())
transportProp = test.getTool().getTransportProperties()
transportProp.setTransport(1); #HTTP 1.0
curHTTPProp = transportProp.getHTTPProperties()
# new HTTP Properties args
branch = curHTTPProp.getParentBranch()
headers = curHTTPProp.getHTTPHeaders()
auth = curHTTPProp.getAuthentication()
keyName = curHTTPProp.getSSLProperties().getKeyStoreDataName()
newHTTPProp = HTTPProperties(branch, 1, headers, auth, keyName)
newHTTPProp.setUseChunking(1) #no chunking
transportProp.setHTTPProperties(newHTTPProp)
Tagged: