的路徑在HTTP請求默認值沒有在HTTP請求的路徑開始時加入。將上下文根myDataSharer添加到HTTP請求中的路徑。
如果你不想每個都重複一遍,那麼有一個配置元素你可以在其中定義proeprties,並且以後可以像這樣引用$ {my.propertie}。
此外,你應該添加一個顯示請求和響應數據的元素,我認爲它被稱爲結果樹或類似的東西。
編輯1:看起來很曖昧的另一件事是登錄請求的路徑。該URL是否正確?難道不是j_acegi_security_check
?那是在登錄表單的動作中出現的網址嗎?
編輯2:在Tomcat中有用於測試安全的示例性應用:
http://example.com:8080/examples/jsp/security/protected/login.jsp
在使用者是在CONF/Tomcat的users.xml中。添加一個與角色:role1上這樣的:
<role rolename="role1"/>
<user username="test" password="test" roles="role1"/>
啓動服務器,你應該能夠登錄。那就試試這個JMeter測試計劃:我在登錄電子加前一個額外的請求,以獲得該cookie
<jmeterTestPlan version="1.2" properties="1.8">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Plan de Pruebas" enabled="true">
<boolProp name="TestPlan.functional_mode">false</boolProp>
<stringProp name="TestPlan.comments"></stringProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Grupo de Hilos" enabled="true">
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
<longProp name="ThreadGroup.start_time">1157555458000</longProp>
<stringProp name="ThreadGroup.on_sample_error">stoptest</stringProp>
<stringProp name="ThreadGroup.ramp_time">0</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<stringProp name="LoopController.loops">1</stringProp>
<boolProp name="LoopController.continue_forever">false</boolProp>
</elementProp>
<longProp name="ThreadGroup.end_time">1157555458000</longProp>
</ThreadGroup>
<hashTree>
<CookieManager guiclass="CookiePanel" testclass="CookieManager" testname="Gestor de Cookies HTTP" enabled="true">
<boolProp name="CookieManager.clearEachIteration">false</boolProp>
<collectionProp name="CookieManager.cookies"/>
</CookieManager>
<hashTree/>
<HTTPSampler guiclass="HttpTestSampleGui" testclass="HTTPSampler" testname="Petición HTTP" enabled="true">
<stringProp name="HTTPSampler.domain">localhost</stringProp>
<stringProp name="HTTPSampler.FILE_NAME"></stringProp>
<stringProp name="HTTPSampler.path">/examples/jsp/security/protected/login.jsp</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.FILE_FIELD"></stringProp>
<stringProp name="HTTPSampler.mimetype"></stringProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<stringProp name="HTTPSampler.port">8080</stringProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<stringProp name="HTTPSampler.monitor">false</stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
</HTTPSampler>
<hashTree/>
<HTTPSampler guiclass="HttpTestSampleGui" testclass="HTTPSampler" testname="Petición HTTP" enabled="true">
<stringProp name="HTTPSampler.domain">localhost</stringProp>
<stringProp name="HTTPSampler.FILE_NAME"></stringProp>
<stringProp name="HTTPSampler.path">/examples/jsp/security/protected/j_security_check</stringProp>
<stringProp name="HTTPSampler.method">POST</stringProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="" elementType="HTTPArgument">
<boolProp name="HTTPArgument.use_equals">true</boolProp>
<boolProp name="HTTPArgument.always_encode">false</boolProp>
<stringProp name="Argument.name">j_username</stringProp>
<stringProp name="Argument.value">test</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="" elementType="HTTPArgument">
<boolProp name="HTTPArgument.use_equals">true</boolProp>
<boolProp name="HTTPArgument.always_encode">false</boolProp>
<stringProp name="Argument.name">j_password</stringProp>
<stringProp name="Argument.value">test</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
</elementProp>
<stringProp name="HTTPSampler.FILE_FIELD"></stringProp>
<stringProp name="HTTPSampler.mimetype"></stringProp>
<boolProp name="HTTPSampler.auto_redirects">true</boolProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<stringProp name="HTTPSampler.port">8080</stringProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<stringProp name="HTTPSampler.monitor">false</stringProp>
<stringProp name="HTTPSampler.protocol">http</stringProp>
</HTTPSampler>
<hashTree/>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="Ver Árbol de Resultados" enabled="true">
<objProp>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>false</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
</value>
<name>saveConfig</name>
</objProp>
<stringProp name="filename"></stringProp>
<boolProp name="ResultCollector.error_logging">false</boolProp>
</ResultCollector>
<hashTree/>
</hashTree>
</hashTree>
</hashTree>
</jmeterTestPlan>
看。如果你不這樣做,登錄將失敗,408代碼。
如果你得到這個工作,那麼你的應用程序可以用同樣的方式進行測試。
另一件看起來很引人注目的事情就是登錄請求的路徑。該URL是否正確?它不應該是j_acegi_security_check嗎?那是在登錄表單的動作中出現的網址嗎? – rodrigoap 2009-09-23 17:28:50
您是使用Acegi還是Spring Security? – rodrigoap 2009-09-23 18:06:29
都不是。我的應用程序使用默認的Apache Tomcat安全性。 – 2009-09-23 19:10:03