Permalink
Browse files

break servlet-3.0 examples into separate subprojects

  • Loading branch information...
1 parent e9a8f06 commit b5a7655dee79f5ce3b37b1e01d4a3e5f8d37d4ed @earldouglas earldouglas committed Sep 17, 2012
View
@@ -15,9 +15,9 @@
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
- <stringProp name="LoopController.loops">10</stringProp>
+ <intProp name="LoopController.loops">10000</intProp>
</elementProp>
- <stringProp name="ThreadGroup.num_threads">1000</stringProp>
+ <stringProp name="ThreadGroup.num_threads">10</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<longProp name="ThreadGroup.start_time">1347296476000</longProp>
<longProp name="ThreadGroup.end_time">1347296476000</longProp>
@@ -49,6 +49,70 @@
<Summariser guiclass="SummariserGui" testclass="Summariser" testname="localhost:9000/fast" enabled="true"/>
<hashTree/>
</hashTree>
+ <ResultCollector guiclass="SummaryReport" testclass="ResultCollector" testname="Summary Report" enabled="true">
+ <boolProp name="ResultCollector.error_logging">false</boolProp>
+ <objProp>
+ <name>saveConfig</name>
+ <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>true</xml>
+ <fieldNames>false</fieldNames>
+ <responseHeaders>false</responseHeaders>
+ <requestHeaders>false</requestHeaders>
+ <responseDataOnError>false</responseDataOnError>
+ <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
+ <assertionsResultsToSave>0</assertionsResultsToSave>
+ <bytes>true</bytes>
+ </value>
+ </objProp>
+ <stringProp name="filename"></stringProp>
+ </ResultCollector>
+ <hashTree/>
+ <ResultCollector guiclass="GraphVisualizer" testclass="ResultCollector" testname="Graph Results" enabled="true">
+ <boolProp name="ResultCollector.error_logging">false</boolProp>
+ <objProp>
+ <name>saveConfig</name>
+ <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>true</xml>
+ <fieldNames>false</fieldNames>
+ <responseHeaders>false</responseHeaders>
+ <requestHeaders>false</requestHeaders>
+ <responseDataOnError>false</responseDataOnError>
+ <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
+ <assertionsResultsToSave>0</assertionsResultsToSave>
+ <bytes>true</bytes>
+ </value>
+ </objProp>
+ <stringProp name="filename"></stringProp>
+ </ResultCollector>
+ <hashTree/>
</hashTree>
</hashTree>
</jmeterTestPlan>
View
@@ -15,7 +15,7 @@
<collectionProp name="Arguments.arguments">
<elementProp name="loops" elementType="Argument">
<stringProp name="Argument.name">loops</stringProp>
- <stringProp name="Argument.value">10</stringProp>
+ <stringProp name="Argument.value">100</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="host" elementType="Argument">
@@ -45,17 +45,17 @@
</elementProp>
<elementProp name="fastThreads" elementType="Argument">
<stringProp name="Argument.name">fastThreads</stringProp>
- <stringProp name="Argument.value">100</stringProp>
+ <stringProp name="Argument.value">5</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="mediumThreads" elementType="Argument">
<stringProp name="Argument.name">mediumThreads</stringProp>
- <stringProp name="Argument.value">75</stringProp>
+ <stringProp name="Argument.value">3</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="slowThreads" elementType="Argument">
<stringProp name="Argument.name">slowThreads</stringProp>
- <stringProp name="Argument.value">25</stringProp>
+ <stringProp name="Argument.value">2</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
View
@@ -0,0 +1,19 @@
+name := "scamper-scalatra"
+
+organization := "com.versal"
+
+version := "0.1-SNAPSHOT"
+
+scalaVersion := "2.9.1"
+
+seq(webSettings :_*)
+
+classpathTypes ~= (_ + "orbit")
+
+libraryDependencies ++= Seq(
+ "org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "compile,container" artifacts (Artifact("javax.servlet", "jar", "jar"))
+ , "org.eclipse.jetty" % "jetty-webapp" % "8.1.4.v20120524" % "compile,container" artifacts (Artifact("jetty-webapp", "jar", "jar"))
+ , "org.scalatra" %% "scalatra" % "2.0.4"
+)
+
+port in container.Configuration := 9000
@@ -0,0 +1,2 @@
+libraryDependencies += "com.github.siasia" %% "xsbt-web-plugin" % "0.12.0-0.2.11.1"
+
@@ -0,0 +1,41 @@
+package scamper
+
+import org.eclipse.jetty.server.nio.SelectChannelConnector
+import org.eclipse.jetty.server.Server
+import org.eclipse.jetty.util.thread.QueuedThreadPool
+import org.eclipse.jetty.webapp.WebAppContext
+
+import javax.servlet.http.HttpServletResponse
+
+object Responder {
+
+ def sleep(ms: Long): Long = {
+ val start = System.currentTimeMillis
+ Thread.sleep(ms)
+ val stop = System.currentTimeMillis
+ stop - start
+ }
+
+ def fast(res: HttpServletResponse) { res.getWriter().write("<h1>slept for %d ms</h1>".format(sleep(0))) }
+ def medium(res: HttpServletResponse) { res.getWriter().write("<h1>slept for %d ms</h1>".format(sleep(150))) }
+ def slow(res: HttpServletResponse) { res.getWriter().write("<h1>slept for %d ms</h1>".format(sleep(300))) }
+}
+
+object Launcher extends App {
+
+ val server = new Server()
+
+ val connector = new SelectChannelConnector()
+ connector.setPort(9000)
+ connector.setThreadPool(new QueuedThreadPool(24))
+
+ server.addConnector(connector)
+
+ val webapp = new WebAppContext()
+ webapp.setContextPath("/")
+ webapp.setWar("src/main/webapp")
+ server.setHandler(webapp)
+
+ server.start()
+ server.join()
+}
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0"
+ >
+
+ <servlet>
+ <servlet-name>scalatra</servlet-name>
+ <servlet-class>scamper.ScamperScalatraServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>scalatra</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
@@ -0,0 +1,19 @@
+name := "scamper-servlet-3.0-async"
+
+organization := "com.versal"
+
+version := "0.1-SNAPSHOT"
+
+scalaVersion := "2.9.1"
+
+seq(webSettings :_*)
+
+classpathTypes ~= (_ + "orbit")
+
+libraryDependencies ++= Seq(
+ "org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "compile,container" artifacts (Artifact("javax.servlet", "jar", "jar"))
+ , "org.eclipse.jetty" % "jetty-webapp" % "8.1.4.v20120524" % "compile,container" artifacts (Artifact("jetty-webapp", "jar", "jar"))
+ , "org.scalatra" %% "scalatra" % "2.0.4"
+)
+
+port in container.Configuration := 9000
@@ -0,0 +1,2 @@
+libraryDependencies += "com.github.siasia" %% "xsbt-web-plugin" % "0.12.0-0.2.11.1"
+
@@ -17,13 +17,13 @@ object AsyncExecutor {
class AsyncServlet extends HttpServlet {
override def doGet(req: HttpServletRequest, res: HttpServletResponse) =
req.getRequestURI() match {
- case "/async/fast" =>
+ case "/fast" =>
req.setAttribute("org.apache.catalina.ASYNC_SUPPORTED", true)
AsyncExecutor.execute(req.startAsync())(Responder.fast(res))
- case "/async/medium" =>
+ case "/medium" =>
req.setAttribute("org.apache.catalina.ASYNC_SUPPORTED", true)
AsyncExecutor.execute(req.startAsync())(Responder.medium(res))
- case "/async/slow" =>
+ case "/slow" =>
req.setAttribute("org.apache.catalina.ASYNC_SUPPORTED", true)
AsyncExecutor.execute(req.startAsync())(Responder.slow(res))
}
@@ -0,0 +1,41 @@
+package scamper
+
+import org.eclipse.jetty.server.nio.SelectChannelConnector
+import org.eclipse.jetty.server.Server
+import org.eclipse.jetty.util.thread.QueuedThreadPool
+import org.eclipse.jetty.webapp.WebAppContext
+
+import javax.servlet.http.HttpServletResponse
+
+object Responder {
+
+ def sleep(ms: Long): Long = {
+ val start = System.currentTimeMillis
+ Thread.sleep(ms)
+ val stop = System.currentTimeMillis
+ stop - start
+ }
+
+ def fast(res: HttpServletResponse) { res.getWriter().write("<h1>slept for %d ms</h1>".format(sleep(0))) }
+ def medium(res: HttpServletResponse) { res.getWriter().write("<h1>slept for %d ms</h1>".format(sleep(150))) }
+ def slow(res: HttpServletResponse) { res.getWriter().write("<h1>slept for %d ms</h1>".format(sleep(300))) }
+}
+
+object Launcher extends App {
+
+ val server = new Server()
+
+ val connector = new SelectChannelConnector()
+ connector.setPort(9000)
+ connector.setThreadPool(new QueuedThreadPool(24))
+
+ server.addConnector(connector)
+
+ val webapp = new WebAppContext()
+ webapp.setContextPath("/")
+ webapp.setWar("src/main/webapp")
+ server.setHandler(webapp)
+
+ server.start()
+ server.join()
+}
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0"
+ >
+
+ <servlet>
+ <servlet-name>async</servlet-name>
+ <servlet-class>scamper.AsyncServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>async</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<jmeterTestPlan version="1.2" properties="2.3">
- <hashTree>
- <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
- <stringProp name="TestPlan.comments"></stringProp>
- <boolProp name="TestPlan.functional_mode">false</boolProp>
- <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>
- <stringProp name="TestPlan.user_define_classpath"></stringProp>
- </TestPlan>
- <hashTree>
- <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
- <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
- <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
- <boolProp name="LoopController.continue_forever">false</boolProp>
- <stringProp name="LoopController.loops">10</stringProp>
- </elementProp>
- <stringProp name="ThreadGroup.num_threads">1000</stringProp>
- <stringProp name="ThreadGroup.ramp_time">1</stringProp>
- <longProp name="ThreadGroup.start_time">1347296476000</longProp>
- <longProp name="ThreadGroup.end_time">1347296476000</longProp>
- <boolProp name="ThreadGroup.scheduler">false</boolProp>
- <stringProp name="ThreadGroup.duration"></stringProp>
- <stringProp name="ThreadGroup.delay"></stringProp>
- </ThreadGroup>
- <hashTree>
- <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="localhost:9000/async/fast" enabled="true">
- <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
- <collectionProp name="Arguments.arguments"/>
- </elementProp>
- <stringProp name="HTTPSampler.domain">localhost</stringProp>
- <stringProp name="HTTPSampler.port">9000</stringProp>
- <stringProp name="HTTPSampler.connect_timeout"></stringProp>
- <stringProp name="HTTPSampler.response_timeout"></stringProp>
- <stringProp name="HTTPSampler.protocol"></stringProp>
- <stringProp name="HTTPSampler.contentEncoding"></stringProp>
- <stringProp name="HTTPSampler.path">/async/fast</stringProp>
- <stringProp name="HTTPSampler.method">GET</stringProp>
- <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
- <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
- <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
- <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
- <boolProp name="HTTPSampler.monitor">false</boolProp>
- <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
- </HTTPSamplerProxy>
- <hashTree/>
- <Summariser guiclass="SummariserGui" testclass="Summariser" testname="localhost:9000/async/fast" enabled="true"/>
- <hashTree/>
- </hashTree>
- </hashTree>
- </hashTree>
-</jmeterTestPlan>
Oops, something went wrong. Retry.

0 comments on commit b5a7655

Please sign in to comment.