You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sirona.apache.org by rm...@apache.org on 2014/02/09 18:36:28 UTC

svn commit: r1566325 - in /incubator/sirona/trunk/agent/performance/web: ./ src/main/java/org/apache/sirona/web/jsp/factory/ src/main/java/org/apache/sirona/web/lifecycle/ src/main/java/org/apache/sirona/web/registration/ src/test/java/org/apache/siron...

Author: rmannibucau
Date: Sun Feb  9 17:36:28 2014
New Revision: 1566325

URL: http://svn.apache.org/r1566325
Log:
SIRONA-28 jsp stats

Added:
    incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/jsp/factory/
    incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/jsp/factory/JspPerformanceFactory.java
    incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/jsp/factory/SironaPageContext.java
    incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/lifecycle/LazyJspMonitoringFilterActivator.java
    incubator/sirona/trunk/agent/performance/web/src/test/java/org/apache/sirona/test/web/Clients.java
    incubator/sirona/trunk/agent/performance/web/src/test/java/org/apache/sirona/test/web/JspMonitoringTest.java
Modified:
    incubator/sirona/trunk/agent/performance/web/pom.xml
    incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/registration/WebSironaInitializer.java
    incubator/sirona/trunk/agent/performance/web/src/test/java/org/apache/sirona/test/web/RequestPerformanceTest.java

Modified: incubator/sirona/trunk/agent/performance/web/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/performance/web/pom.xml?rev=1566325&r1=1566324&r2=1566325&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/performance/web/pom.xml (original)
+++ incubator/sirona/trunk/agent/performance/web/pom.xml Sun Feb  9 17:36:28 2014
@@ -36,6 +36,12 @@
     </dependency>
     <dependency>
       <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-el_2.2_spec</artifactId>
+      <version>1.0.4</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
       <artifactId>geronimo-servlet_3.0_spec</artifactId>
     </dependency>
 

Added: incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/jsp/factory/JspPerformanceFactory.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/jsp/factory/JspPerformanceFactory.java?rev=1566325&view=auto
==============================================================================
--- incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/jsp/factory/JspPerformanceFactory.java (added)
+++ incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/jsp/factory/JspPerformanceFactory.java Sun Feb  9 17:36:28 2014
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sirona.web.jsp.factory;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.jsp.JspApplicationContext;
+import javax.servlet.jsp.JspEngineInfo;
+import javax.servlet.jsp.JspFactory;
+import javax.servlet.jsp.PageContext;
+
+public class JspPerformanceFactory extends JspFactory {
+    private final JspFactory delegate;
+
+    public JspPerformanceFactory(final JspFactory defaultFactory) {
+        delegate = defaultFactory;
+    }
+
+    @Override
+    public PageContext getPageContext(final Servlet servlet, final ServletRequest servletRequest,
+                                      final ServletResponse servletResponse, final String s,
+                                      final boolean b, int i, final boolean b2) {
+        final PageContext pageContext = delegate.getPageContext(servlet, servletRequest, servletResponse, s, b, i, b2);
+        return new SironaPageContext(pageContext);
+    }
+
+    @Override
+    public void releasePageContext(final PageContext pageContext) {
+        delegate.releasePageContext(pageContext);
+    }
+
+    @Override
+    public JspApplicationContext getJspApplicationContext(final ServletContext servletContext) {
+        // open door to wrap expression factory/el stuff
+        return delegate.getJspApplicationContext(servletContext);
+    }
+
+    @Override
+    public JspEngineInfo getEngineInfo() {
+        return delegate.getEngineInfo();
+    }
+}

Added: incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/jsp/factory/SironaPageContext.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/jsp/factory/SironaPageContext.java?rev=1566325&view=auto
==============================================================================
--- incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/jsp/factory/SironaPageContext.java (added)
+++ incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/jsp/factory/SironaPageContext.java Sun Feb  9 17:36:28 2014
@@ -0,0 +1,245 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sirona.web.jsp.factory;
+
+import org.apache.sirona.Role;
+import org.apache.sirona.aop.AbstractPerformanceInterceptor;
+
+import javax.el.ELContext;
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.servlet.jsp.ErrorData;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.PageContext;
+import javax.servlet.jsp.el.ExpressionEvaluator;
+import javax.servlet.jsp.el.VariableResolver;
+import javax.servlet.jsp.tagext.BodyContent;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Enumeration;
+
+public class SironaPageContext extends PageContext {
+    private final PageContext delegate;
+    private final AbstractPerformanceInterceptor.Context monitor;
+    private boolean done = false;
+
+    public SironaPageContext(final PageContext pageContext) {
+        delegate = pageContext;
+        monitor = new JspInterceptor().before(this, extractJspName());
+    }
+
+    @Override
+    public void initialize(final Servlet servlet, final ServletRequest request, final ServletResponse response,
+                           final String errorPageURL, final boolean needsSession,
+                           final int bufferSize, final boolean autoFlush) throws IOException, IllegalStateException, IllegalArgumentException {
+        delegate.initialize(servlet, request, response, errorPageURL, needsSession, bufferSize, autoFlush);
+    }
+
+    @Override
+    public void release() {
+        delegate.release();
+        if (!done) {
+            monitor.stop();
+            done = true;
+        }
+    }
+
+    @Override
+    public HttpSession getSession() {
+        return delegate.getSession();
+    }
+
+    @Override
+    public Object getPage() {
+        return delegate.getPage();
+    }
+
+    @Override
+    public ServletRequest getRequest() {
+        return delegate.getRequest();
+    }
+
+    @Override
+    public ServletResponse getResponse() {
+        return delegate.getResponse();
+    }
+
+    @Override
+    public Exception getException() {
+        return delegate.getException();
+    }
+
+    @Override
+    public ServletConfig getServletConfig() {
+        return delegate.getServletConfig();
+    }
+
+    @Override
+    public ServletContext getServletContext() {
+        return delegate.getServletContext();
+    }
+
+    @Override
+    public void forward(final String relativeUrlPath) throws ServletException, IOException {
+        delegate.forward(relativeUrlPath);
+    }
+
+    @Override
+    public void include(final String relativeUrlPath) throws ServletException, IOException {
+        delegate.include(relativeUrlPath);
+    }
+
+    @Override
+    public void include(final String relativeUrlPath, final boolean flush) throws ServletException, IOException {
+        delegate.include(relativeUrlPath, flush);
+    }
+
+    @Override
+    public void handlePageException(final Exception e) throws ServletException, IOException {
+        monitor.stopWithException(e);
+        done = true;
+        delegate.handlePageException(e);
+    }
+
+    @Override
+    public void handlePageException(final Throwable t) throws ServletException, IOException {
+        monitor.stopWithException(t);
+        done = true;
+        delegate.handlePageException(t);
+    }
+
+    @Override
+    public BodyContent pushBody() {
+        return delegate.pushBody();
+    }
+
+    @Override
+    public ErrorData getErrorData() {
+        return delegate.getErrorData();
+    }
+
+    @Override
+    public void setAttribute(final String name, final Object value) {
+        delegate.setAttribute(name, value);
+    }
+
+    @Override
+    public void setAttribute(final String name, final Object value, final int scope) {
+        delegate.setAttribute(name, value, scope);
+    }
+
+    @Override
+    public Object getAttribute(final String name) {
+        return delegate.getAttribute(name);
+    }
+
+    @Override
+    public Object getAttribute(final String name, final int scope) {
+        return delegate.getAttribute(name, scope);
+    }
+
+    @Override
+    public Object findAttribute(final String name) {
+        return delegate.findAttribute(name);
+    }
+
+    @Override
+    public void removeAttribute(final String name) {
+        delegate.removeAttribute(name);
+    }
+
+    @Override
+    public void removeAttribute(final String name, final int scope) {
+        delegate.removeAttribute(name, scope);
+    }
+
+    @Override
+    public int getAttributesScope(final String name) {
+        return delegate.getAttributesScope(name);
+    }
+
+    @Override
+    public Enumeration<String> getAttributeNamesInScope(final int scope) {
+        return delegate.getAttributeNamesInScope(scope);
+    }
+
+    @Override
+    public JspWriter getOut() {
+        return delegate.getOut();
+    }
+
+    @Override
+    public ExpressionEvaluator getExpressionEvaluator() {
+        return delegate.getExpressionEvaluator();
+    }
+
+    @Override
+    public ELContext getELContext() {
+        return delegate.getELContext();
+    }
+
+    @Override
+    public VariableResolver getVariableResolver() {
+        return delegate.getVariableResolver();
+    }
+
+    @Override
+    public JspWriter pushBody(final Writer writer) {
+        return delegate.pushBody(writer);
+    }
+
+    @Override
+    public JspWriter popBody() {
+        return delegate.popBody();
+    }
+
+    protected String extractJspName() {
+        final ServletRequest request = getRequest();
+        if (HttpServletRequest.class.isInstance(request)) {
+            return HttpServletRequest.class.cast(request).getRequestURI();
+        }
+        return request.getServletContext().getContextPath();
+    }
+
+    private static class JspInterceptor extends AbstractPerformanceInterceptor<SironaPageContext> {
+        @Override
+        protected Object proceed(final SironaPageContext invocation) throws Throwable {
+            throw new UnsupportedOperationException("shouldn't be called");
+        }
+
+        @Override
+        protected String getCounterName(final SironaPageContext invocation) {
+            return invocation.extractJspName();
+        }
+
+        @Override
+        protected Role getRole() {
+            return Role.JSP;
+        }
+
+        @Override
+        protected Context before(final SironaPageContext invocation, final String name) {
+            return super.before(invocation, name);
+        }
+    }
+}

Added: incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/lifecycle/LazyJspMonitoringFilterActivator.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/lifecycle/LazyJspMonitoringFilterActivator.java?rev=1566325&view=auto
==============================================================================
--- incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/lifecycle/LazyJspMonitoringFilterActivator.java (added)
+++ incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/lifecycle/LazyJspMonitoringFilterActivator.java Sun Feb  9 17:36:28 2014
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sirona.web.lifecycle;
+
+import org.apache.sirona.web.jsp.factory.JspPerformanceFactory;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.jsp.JspFactory;
+import java.io.IOException;
+
+public class LazyJspMonitoringFilterActivator implements Filter {
+    private volatile JspFactory defaultFactory = null;
+    private JspPerformanceFactory wrapper = null;
+
+    @Override
+    public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException {
+        if (defaultFactory == null) {
+            synchronized (this) {
+                if (defaultFactory == defaultFactory) {
+                    defaultFactory = JspFactory.getDefaultFactory();
+                    if (!JspPerformanceFactory.class.isInstance(defaultFactory)) {
+                        wrapper = new JspPerformanceFactory(defaultFactory);
+                        JspFactory.setDefaultFactory(wrapper);
+                    }
+                }
+            }
+        }
+        filterChain.doFilter(servletRequest, servletResponse);
+    }
+
+    @Override
+    public void destroy() {
+        if (wrapper != null && wrapper == JspFactory.getDefaultFactory()) {
+            JspFactory.setDefaultFactory(defaultFactory);
+        }
+    }
+
+    @Override
+    public void init(final FilterConfig filterConfig) throws ServletException {
+        // no-op: too eagerly to init anything, defaultFactory will surely be null
+    }
+}

Modified: incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/registration/WebSironaInitializer.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/registration/WebSironaInitializer.java?rev=1566325&r1=1566324&r2=1566325&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/registration/WebSironaInitializer.java (original)
+++ incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/registration/WebSironaInitializer.java Sun Feb  9 17:36:28 2014
@@ -20,6 +20,7 @@ import org.apache.sirona.configuration.C
 import org.apache.sirona.repositories.Repository;
 import org.apache.sirona.util.Environment;
 import org.apache.sirona.web.discovery.GaugeDiscoveryListener;
+import org.apache.sirona.web.lifecycle.LazyJspMonitoringFilterActivator;
 import org.apache.sirona.web.lifecycle.SironaLifecycle;
 import org.apache.sirona.web.servlet.SironaFilter;
 import org.apache.sirona.web.session.SironaSessionListener;
@@ -33,8 +34,8 @@ import java.util.EnumSet;
 import java.util.Set;
 
 public class WebSironaInitializer implements ServletContainerInitializer {
+    private static final String JSP_ACTIVATED = Configuration.CONFIG_PROPERTY_PREFIX + "web.jsp.activated";
     private static final String ACTIVATED = Configuration.CONFIG_PROPERTY_PREFIX + "web.activated";
-    private static final String FALSE = Boolean.FALSE.toString();
 
     @Override
     public void onStartup(final Set<Class<?>> classes, final ServletContext ctx) throws ServletException {
@@ -42,12 +43,14 @@ public class WebSironaInitializer implem
             return;
         }
 
+        final String falseStr = Boolean.FALSE.toString();
+
         final String activated = ctx.getInitParameter(ACTIVATED);
-        if (FALSE.equalsIgnoreCase(Configuration.getProperty(ACTIVATED, activated))) {
+        if (falseStr.equalsIgnoreCase(Configuration.getProperty(ACTIVATED, activated))) {
             return;
         }
 
-        final String monStatus = Boolean.toString(!FALSE.equalsIgnoreCase(ctx.getInitParameter(SironaFilter.MONITOR_STATUS)));
+        final String monStatus = Boolean.toString(!falseStr.equalsIgnoreCase(ctx.getInitParameter(SironaFilter.MONITOR_STATUS)));
         ctx.setAttribute(SironaFilter.MONITOR_STATUS, monStatus);
 
         ctx.addListener(SironaSessionListener.class);
@@ -58,7 +61,7 @@ public class WebSironaInitializer implem
 
         String ignoredUrls = ctx.getInitParameter(SironaFilter.IGNORED_URLS);
         String monitoredUrls = ctx.getInitParameter(Configuration.CONFIG_PROPERTY_PREFIX + "web.monitored-urls");
-        if (!"false".equalsIgnoreCase(monitoredUrls)) {
+        if (!falseStr.equalsIgnoreCase(monitoredUrls)) {
             if (monitoredUrls == null) {
                 monitoredUrls = "/*";
             }
@@ -82,5 +85,11 @@ public class WebSironaInitializer implem
                 filter.setInitParameter(SironaFilter.IGNORED_URLS, ignoredUrls);
             }
         }
+
+        // default is false for jsp monitoring since it brings things only in specific cases
+        if (Boolean.TRUE.toString().equalsIgnoreCase(Configuration.getProperty(JSP_ACTIVATED, ctx.getInitParameter(JSP_ACTIVATED)))) {
+            ctx.addFilter("sirona-jsp-activator", LazyJspMonitoringFilterActivator.class)
+                    .addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "*.jsp");
+        }
     }
 }

Added: incubator/sirona/trunk/agent/performance/web/src/test/java/org/apache/sirona/test/web/Clients.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/performance/web/src/test/java/org/apache/sirona/test/web/Clients.java?rev=1566325&view=auto
==============================================================================
--- incubator/sirona/trunk/agent/performance/web/src/test/java/org/apache/sirona/test/web/Clients.java (added)
+++ incubator/sirona/trunk/agent/performance/web/src/test/java/org/apache/sirona/test/web/Clients.java Sun Feb  9 17:36:28 2014
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sirona.test.web;
+
+import com.gargoylesoftware.htmlunit.WebClient;
+
+public class Clients {
+    public static WebClient newClient() {
+        final WebClient webClient = new WebClient();
+        webClient.getOptions().setJavaScriptEnabled(false);
+        webClient.getOptions().setCssEnabled(false);
+        webClient.getOptions().setAppletEnabled(false);
+        webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
+        return webClient;
+    }
+
+    private Clients() {
+        // no-op
+    }
+}

Added: incubator/sirona/trunk/agent/performance/web/src/test/java/org/apache/sirona/test/web/JspMonitoringTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/performance/web/src/test/java/org/apache/sirona/test/web/JspMonitoringTest.java?rev=1566325&view=auto
==============================================================================
--- incubator/sirona/trunk/agent/performance/web/src/test/java/org/apache/sirona/test/web/JspMonitoringTest.java (added)
+++ incubator/sirona/trunk/agent/performance/web/src/test/java/org/apache/sirona/test/web/JspMonitoringTest.java Sun Feb  9 17:36:28 2014
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sirona.test.web;
+
+import org.apache.catalina.startup.Constants;
+import org.apache.sirona.Role;
+import org.apache.sirona.counters.Counter;
+import org.apache.sirona.repositories.Repository;
+import org.apache.sirona.web.lifecycle.LazyJspMonitoringFilterActivator;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.descriptor.api.Descriptors;
+import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor;
+import org.jboss.shrinkwrap.descriptor.api.webcommon30.WebAppVersionType;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.IOException;
+import java.net.URL;
+
+import static org.apache.sirona.test.web.Clients.newClient;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+@RunWith(Arquillian.class)
+public class JspMonitoringTest {
+    static { // to start faster
+        System.setProperty(Constants.PLUGGABILITY_JARS_TO_SKIP, "a*,c*,d*,e*,g*,h*,i*,j*,l*,m*,n*,p*," +
+                                                                "r*,sa*,se*,sh*,su*,t*,v*,w*,x*,z*");
+        System.setProperty(Constants.TLD_JARS_TO_SKIP, "*");
+    }
+
+    @Deployment(testable = false)
+    public static Archive<?> war() {
+        return ShrinkWrap.create(WebArchive.class, "ajsp.war")
+                .addAsWebResource(new StringAsset("Hello"), "test.jsp")
+                .setWebXML(new StringAsset(
+                    Descriptors.create(WebAppDescriptor.class)
+                        .metadataComplete(true) // don't scan
+                        .version(WebAppVersionType._3_0)
+                        .createFilter()
+                            .filterClass(LazyJspMonitoringFilterActivator.class.getName())
+                            .filterName("jsp-mon-on")
+                        .up()
+                        .createFilterMapping()
+                            .filterName("jsp-mon-on")
+                            .urlPattern("*.jsp")
+                        .up()
+                        .exportAsString()));
+    }
+
+    @ArquillianResource
+    private URL url;
+
+    @Before
+    @After
+    public void resetCounters() {
+        Repository.INSTANCE.clearCounters();
+    }
+
+    @Test
+    public void jsp() throws IOException {
+        final String testUrl = url.toExternalForm() + "test.jsp";
+        for (int i = 0; i < 2; i++) {
+            assertEquals("Hello", newClient().getPage(testUrl).getWebResponse().getContentAsString());
+        }
+        assertEquals("Hello", newClient().getPage(testUrl + "?ignoredQuery=yes&ofcourse=itis").getWebResponse().getContentAsString());
+
+        assertFalse(Repository.INSTANCE.counters().isEmpty());
+        final Counter counter = Repository.INSTANCE.counters().iterator().next();
+        assertEquals(Role.JSP, counter.getKey().getRole());
+        assertEquals(url.getPath() + "test.jsp", counter.getKey().getName());
+        assertEquals(3, counter.getHits());
+    }
+}

Modified: incubator/sirona/trunk/agent/performance/web/src/test/java/org/apache/sirona/test/web/RequestPerformanceTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/performance/web/src/test/java/org/apache/sirona/test/web/RequestPerformanceTest.java?rev=1566325&r1=1566324&r2=1566325&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/performance/web/src/test/java/org/apache/sirona/test/web/RequestPerformanceTest.java (original)
+++ incubator/sirona/trunk/agent/performance/web/src/test/java/org/apache/sirona/test/web/RequestPerformanceTest.java Sun Feb  9 17:36:28 2014
@@ -41,6 +41,7 @@ import java.net.HttpURLConnection;
 import java.net.URL;
 import java.util.Map;
 
+import static org.apache.sirona.test.web.Clients.newClient;
 import static org.junit.Assert.assertEquals;
 
 @RunWith(Arquillian.class)
@@ -94,15 +95,6 @@ public class RequestPerformanceTest {
         assertEquals(0, statusGaugeSum(new Role("/sirona-test-HTTP-4567", Unit.UNARY)));
     }
 
-    private static WebClient newClient() {
-        final WebClient webClient = new WebClient();
-        webClient.getOptions().setJavaScriptEnabled(false);
-        webClient.getOptions().setCssEnabled(false);
-        webClient.getOptions().setAppletEnabled(false);
-        webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
-        return webClient;
-    }
-
     private static int statusGaugeSum(final Role role) {
         return sum(Repository.INSTANCE.getGaugeValues(0, System.currentTimeMillis() + 1000, role));
     }