{"id":1404,"date":"2015-06-29T00:00:58","date_gmt":"2015-06-28T15:00:58","guid":{"rendered":"http:\/\/www.otwo.jp\/blog\/?p=1404"},"modified":"2017-03-29T10:27:39","modified_gmt":"2017-03-29T01:27:39","slug":"jmeter_study2","status":"publish","type":"post","link":"https:\/\/www.otwo.jp\/blog\/jmeter_study2\/","title":{"rendered":"\u3010JMeter\u8b1b\u5ea7\u2461\uff08\u5168\uff13\u56de\uff09\u3011\u6b63\u898f\u8868\u73fe\u62bd\u51fa\uff0fBeanShell PostProcessor"},"content":{"rendered":"<p>\u3069\u3046\u3082\u3001\u958b\u767a2\u90e8\u3067\u30b5\u30fc\u30d0\u62c5\u5f53\u3057\u3066\u308b\u5c71\u672c\u3067\u3059\u3002<\/p>\n<p>\u4eca\u56de\u3082\u524d\u56de\u306b\u5f15\u304d\u7d9a\u304dJMeter\uff08\u30b8\u30a7\u30a4\u30e1\u30fc\u30bf\u30fc\uff09\u306b\u3064\u3044\u3066\u306e\u6295\u7a3f\u3067\u3059\u3002<\/p>\n<p>\u524d\u56de\u306f\u5909\u6570\u5468\u308a\u306e\u6a5f\u80fd\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u307e\u3057\u305f\u304c\u3001<br \/>\n\u4eca\u56de\u306f\u30b5\u30fc\u30d0\u30fc\u304b\u3089\u8fd4\u5374\u3055\u308c\u305fjson\u306e\u5185\u5bb9\u3092\u5f8c\u7d9a\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3067\u5229\u7528\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p><!--more--><br \/>\n\u25bc\u5168\u8a18\u4e8b\u306f\u3053\u3061\u3089\u3010JMeter\u8b1b\u5ea7\u2462\uff08\u5168\uff13\u56de\uff09\u3011<br \/>\n<a href=\"http:\/\/www.otwo.jp\/blog\/server\/jmeter_study1\/\">\u3010JMeter\u8b1b\u5ea7\u2460\uff08\u5168\uff13\u56de\uff09\u3011\u30ab\u30a6\u30f3\u30bf\uff0fRandom Variable\uff0fCSV Data Set Config<\/a><br \/>\n<a href=\"http:\/\/www.otwo.jp\/blog\/server\/jmeter_study2\/\">\u3010JMeter\u8b1b\u5ea7\u2461\uff08\u5168\uff13\u56de\uff09\u3011\u6b63\u898f\u8868\u73fe\u62bd\u51fa\uff0fBeanShell PostProcessor<\/a><br \/>\n<a href=\"http:\/\/www.otwo.jp\/blog\/server\/jmeter_study_3\/\">\u3010JMeter\u8b1b\u5ea7\u2462\uff08\u5168\uff13\u56de\uff09\u3011BeanShell PreProcessor<\/a><br \/>\n<\/br><\/p>\n<hr \/>\n<p>json\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5\u306f\u3044\u304f\u3064\u304b\u65b9\u6cd5\u306f\u3042\u308a\u307e\u3059\u304c\u3001<br \/>\n\u4eca\u56de\u306f\u4ee5\u4e0b\u306e2\u3064\u306e\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u6b63\u898f\u8868\u73fe\u62bd\u51fa<\/li>\n<li>BeanShell PostProcessor<\/li>\n<\/ul>\n<p>\u5c1a\u3001\u30b5\u30fc\u30d0\u3092\u4ee5\u4e0b\u306ejson\u3092\u8fd4\u5374\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n<\/br><\/p>\n<pre class=\"brush: python\r; notranslate\">{\"token\":\"399f386b09eceddc472a4bd9c077c5f9\",\"user_data\":{\"user_id\":1,\"user_name\":\"otwo\"}}\r\n<\/pre>\n<h1>\n\u6b63\u898f\u8868\u73fe\u62bd\u51fa<br \/>\n<\/h1>\n<p>\u5358\u7d14\u306ajson\u306e\u5834\u5408\u306f\u6b63\u898f\u8868\u73fe\u62bd\u51fa\u3092\u4f7f\u3046\u3068\u697d\u3061\u3093\u3067\u3059\u3002<br \/>\n\u4e0b\u306e\u4f8b\u3067\u306fHTTP\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u5f8c\u51e6\u7406\u3068\u3057\u3066\u6b63\u898f\u8868\u73fe\u62bd\u51fa\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001<br \/>\n\u30b5\u30fc\u30d0\u304b\u3089\u8fd4\u5374\u3055\u308c\u305fjson\u304b\u3089token\u3092\u62bd\u51fa\u3057\u3001<br \/>\n\u5f8c\u7d9a\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3067\u30d8\u30c3\u30c0\u30fc\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n<\/br><br \/>\n<a href=\"http:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221737.png\" target=\"_blank\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221737.png\" alt=\"201505221737\" width=\"1000\" height=\"543\" class=\"alignnone size-full wp-image-1410\" srcset=\"https:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221737.png 1000w, https:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221737-300x162.png 300w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221738.png\" target=\"_blank\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221738.png\" alt=\"201505221738\" width=\"1000\" height=\"543\" class=\"alignnone size-full wp-image-1411\" srcset=\"https:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221738.png 1000w, https:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221738-300x162.png 300w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221739.png\" target=\"_blank\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221739.png\" alt=\"201505221739\" width=\"1000\" height=\"543\" class=\"alignnone size-full wp-image-1412\" srcset=\"https:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221739.png 1000w, https:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221739-300x162.png 300w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/a><br \/>\n<\/br><br \/>\n\u3053\u306e\u3088\u3046\u306b\u5358\u7d14\u306ajson\u3067\u3042\u308c\u3070\u6b63\u898f\u8868\u73fe\u62bd\u51fa\u3092\u5229\u7528\u3059\u308b\u3068\u4fbf\u5229\u3067\u3059\u3002<\/p>\n<h1>\nBeanShell PostProcessor<br \/>\n<\/h1>\n<p>json\u304c\u8907\u96d1\u306a\u69cb\u9020\u306b\u306a\u3063\u3066\u304f\u308b\u3068\u6b63\u898f\u8868\u73fe\u62bd\u51fa\u3067\u306f\u306a\u304b\u306a\u304b\u9762\u5012\u3067\u3059\u3002<br \/>\n\u305d\u3046\u3044\u3046\u5834\u5408\u306fBeanShell PostProcessor\u3092\u4f7f\u3046\u3068json\u3092\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u3057\u3066\u6271\u3048\u308b\u306e\u3067\u4fbf\u5229\u3067\u3059\u3002<br \/>\nBeanShell PostProcessor\u306fHTTP\u30ea\u30af\u30a8\u30b9\u30c8\u306a\u3069\u306e\u5f8c\u51e6\u7406\u3068\u3057\u3066BeanShell\u3092\u5b9f\u884c\u3059\u308b\u6a5f\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u306a\u306e\u3067\u3001json\u304b\u3089\u62bd\u51fa\u3057\u305f\u30c7\u30fc\u30bf\u3092\u52a0\u5de5\u3059\u308b\u3053\u3068\u306a\u3093\u304b\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>BeanShell\u304b\u3089json\u3092\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u3057\u3066\u6271\u3046\u306b\u306f\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u5fc5\u8981\u306a\u306e\u3067\u3001<br \/>\n\u2193\u304b\u3089java-json.jar\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066JMeter\u306elib\u30d5\u30a9\u30eb\u30c0\u306b\u3076\u3063\u3053\u3093\u3067JMeter\u3092\u518d\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/www.java2s.com\/Code\/Jar\/j\/Downloadjavajsonjar.htm\" target=\"_blank\">http:\/\/www.java2s.com\/Code\/Jar\/j\/Downloadjavajsonjar.htm<\/a><\/p>\n<p><\/br><br \/>\n<a href=\"http:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221827.png\" target=\"_blank\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221827.png\" alt=\"201505221827\" width=\"1000\" height=\"543\" class=\"alignnone size-full wp-image-1413\" srcset=\"https:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221827.png 1000w, https:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221827-300x162.png 300w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/a><\/p>\n<p><\/br><\/p>\n<pre class=\"brush: python\r; notranslate\">import org.json.JSONObject;\r\n\r\nlog.info(\"BeanShell PostProcessor Start\");\r\n\r\nString body = prev.getResponseDataAsString();\r\nlog.info(\"response body=\" + body);\r\n\r\nJSONObject json = new JSONObject(body);\r\n\r\nString token = json.get(\"token\");\r\nString user_id = String.valueOf(json.get(\"user_data\").get(\"user_id\"));\r\nString user_name = json.get(\"user_data\").get(\"user_name\");\r\n\r\nlog.info(\"token = \" + token);\r\nlog.info(\"user_id = \" + user_id);\r\nlog.info(\"user_name = \" + user_name);\r\n\r\nvars.put(\"token\", token);\r\nvars.put(\"user_id\", user_id);\r\nvars.put(\"user_name\", user_name);\r\n\r\nlog.info(\"BeanShell PostProcessor End\");\r\n<\/pre>\n<p><\/br><\/p>\n<p>\u2191\u304cBeanShell\u3067\u5b9f\u88c5\u3057\u305f\u5185\u5bb9\u3067\u3059\u3002<br \/>\nprev.getResponseDataAsString()\u3067json\u6587\u5b57\u5217\u3092\u53d6\u5f97\u3057\u3066\u3001JSONObject\u306b\u3088\u308a\u30d1\u30fc\u30b9\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\nlog.info()\u3067\u30ed\u30b0\u51fa\u529b\u3082\u3067\u304d\u308b\u306e\u3067\u3001BeanShell\u306e\u30c7\u30d0\u30c3\u30b0\u3082\u3057\u3084\u3059\u3044\u3067\u3059\u3002<br \/>\nvars.put()\u3067\u30e6\u30fc\u30b6\u30fc\u5909\u6570\u3092\u5b9a\u7fa9\u3057\u3066\u5f8c\u7d9a\u306e\u51e6\u7406\u3067\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n<\/br><br \/>\n<a href=\"http:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221828.png\" target=\"_blank\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221828.png\" alt=\"201505221828\" width=\"1000\" height=\"543\" class=\"alignnone size-full wp-image-1407\" srcset=\"https:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221828.png 1000w, https:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221828-300x162.png 300w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221829.png\" target=\"_blank\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221829.png\" alt=\"201505221829\" width=\"1000\" height=\"543\" class=\"alignnone size-full wp-image-1408\" srcset=\"https:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221829.png 1000w, https:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221829-300x162.png 300w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221830.png\" target=\"_blank\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221830.png\" alt=\"201505221830\" width=\"1000\" height=\"543\" class=\"alignnone size-full wp-image-1409\" srcset=\"https:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221830.png 1000w, https:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2015\/06\/201505221830-300x162.png 300w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/a><\/p>\n<p><\/br><br \/>\n\u3053\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u3001\u6b63\u898f\u8868\u73fe\u62bd\u51fa\u3068\u9055\u3044\u3001json\u3092\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u3057\u3066\u6271\u3046\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u3067\u3001<br \/>\njson\u306e\u69cb\u9020\u3055\u3048\u5206\u304b\u308c\u3070\u8907\u96d1\u306a\u5185\u5bb9\u3067\u3042\u3063\u3066\u3082\u76f4\u611f\u7684\u306b\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<hr \/>\n<p>\u4ed6\u306b\u3082json\u306fjavascript\u3060\u3068\u6587\u5b57\u5217\u3092\u305d\u306e\u307e\u307e\u8a55\u4fa1\u3067\u304d\u308b\u3093\u3067\u3001<br \/>\nBSF PostProcessor\u3067javascript\u3092\u4f7f\u3046\u306e\u3082\u697d\u306a\u3093\u3067\u3059\u304c\u3001<br \/>\n\u30cf\u30c3\u30b7\u30e5\u751f\u6210\u3084\u30a8\u30f3\u30b3\u30fc\u30c9\u306a\u3069\u3092\u4f7f\u3044\u305f\u3044\u3068\u304d\u306b\u3001<br \/>\n\u500b\u3005\u306b\u5b9f\u88c5\u3059\u308b\u5fc5\u8981\u304c\u3042\u3063\u305f\u306e\u3067BeanShell\u306b\u3057\u307e\u3057\u305f^^;<br \/>\nBSF\u7528\u306b\u5171\u901a\u95a2\u6570\u307f\u305f\u3044\u306a\u306e\u304c\u5b9a\u7fa9\u3067\u304d\u305f\u3089\u3088\u304b\u3063\u305f\u3093\u3067\u3059\u304c\u3001\u5206\u304b\u3089\u3093\u304b\u3063\u305f\u3067\u3059orz<\/p>\n<p>\u3044\u304b\u304c\u3067\u3057\u305f\u3067\u3057\u3087\u3046\u304b\u3002<br \/>\n\u4eca\u56de\u306f\u5f8c\u51e6\u7406\u3067json\u3092\u30d1\u30fc\u30b9\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<br \/>\n\u6b21\u56de\u306fJMeter\u304b\u3089json\u3092POST\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3059\u308b\u4e88\u5b9a\u3067\u3059\uff01\uff01<\/p>\n<p>\u3067\u306f\u3067\u306f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3069\u3046\u3082\u3001\u958b\u767a2\u90e8\u3067\u30b5\u30fc\u30d0\u62c5\u5f53\u3057\u3066\u308b\u5c71\u672c\u3067\u3059\u3002 \u4eca\u56de\u3082\u524d\u56de\u306b\u5f15\u304d\u7d9a\u304dJMeter\uff08\u30b8\u30a7\u30a4\u30e1\u30fc\u30bf\u30fc\uff09\u306b\u3064\u3044\u3066\u306e\u6295\u7a3f\u3067\u3059\u3002 \u524d\u56de\u306f\u5909\u6570\u5468\u308a\u306e\u6a5f\u80fd\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u307e\u3057\u305f\u304c\u3001 \u4eca\u56de\u306f\u30b5\u30fc\u30d0\u30fc\u304b\u3089\u8fd4\u5374\u3055\u308c\u305fjson\u306e\u5185\u5bb9\u3092\u5f8c\u7d9a\u306e\u30ea\u30af\u30a8 [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":1557,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[9],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/posts\/1404"}],"collection":[{"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/comments?post=1404"}],"version-history":[{"count":17,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/posts\/1404\/revisions"}],"predecessor-version":[{"id":2907,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/posts\/1404\/revisions\/2907"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/media\/1557"}],"wp:attachment":[{"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/media?parent=1404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/categories?post=1404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/tags?post=1404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}