How to Switch Transports

LegacyForumLegacyForum Posts: 1,669 ✭✭
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:
Sign In or Register to comment.