json 데이터 post에서 exception 에러

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

json 데이터 post에서 exception 에러

Jake Kim
안녕하세요. REST API 서버에 대해 성능 테스트를 하려고 하는데요.
json 데이터를 post로 넘기는데 exception 에러가 나고있습니다.
간단한 스크립트인것 같은데 원인을 찾지 못하고 있습니다.

혹시 어느 부분이 잘못된 것인지 도움을 얻고자 합니다.


# -*- coding:utf-8 -*-

# A simple example using the HTTP plugin that shows the retrieval of a
# single page via HTTP.
#
# This script is automatically generated by ngrinder.
#
# @author admin
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from net.grinder.plugin.http import HTTPRequest
from net.grinder.plugin.http import HTTPPluginControl
from HTTPClient import NVPair
from java.lang import Exception
from java.lang import System
from org.json import JSONObject


control = HTTPPluginControl.getConnectionDefaults()
# if you don't want that HTTPRequest follows the redirection, please modify the following option 0.
# control.followRedirects = 1
# if you want to increase the timeout, please modify the following option.
control.timeout = 6000

test1 = Test(1, "Test1")
request1 = test1.wrap(HTTPRequest(url="https:/xx.xx.xx.xx"))

# Make any method call on request1 increase TPS
test1.record(request1)

log = grinder.logger.info
err = grinder.logger.error

class TestRunner:
    # initlialize a thread
    def __init__(self):
        grinder.statistics.delayReports=True
        pass

    # test method      
    def __call__(self):
        strbody = '{\"country\": \"ko\"}'
        strHeader = [NVPair('Content-type', 'application/json')]
        result = request1.POST('/account', strbody, strHeader)

        #jsonObject = JSONObject(result.getText())
        log("result Auth: %s" % result.getText())
       
        if result.getStatusCode() == 200 :
            grinder.statistics.forLastTest.success = 1
        elif result.getStatusCode() in (301, 302) :
            grinder.logger.warn("Warning. The response may not be correct. The response code was %d." %  result.getStatusCode())
            grinder.statistics.forLastTest.success = 1
        else :
            grinder.statistics.forLastTest.success = 0

-------------------------------------------------------------------------------------------------

2015-11-20 15:36:46,914 ERROR Aborted run: Java exception calling TestRunner
net.grinder.scriptengine.jython.JythonScriptExecutionException: Java exception calling TestRunner
        result = request1.POST('/account', strbody, strHeader)
        File "${NGRINDER_HOME}\script\admin\SST.py", line 44, in __call__
java.lang.NullPointerException: null