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 2013/11/05 18:25:24 UTC
svn commit: r1539076 [17/17] - in /incubator/sirona/trunk: ./ agent/
agent/performance/ agent/performance/aop/ agent/performance/aop/src/
agent/performance/aop/src/main/ agent/performance/aop/src/main/java/
agent/performance/aop/src/main/java/org/ agen...
Added: incubator/sirona/trunk/server/reporting/src/main/resources/templates/report/report.vm
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/main/resources/templates/report/report.vm?rev=1539076&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/main/resources/templates/report/report.vm (added)
+++ incubator/sirona/trunk/server/reporting/src/main/resources/templates/report/report.vm Tue Nov 5 17:25:15 2013
@@ -0,0 +1,101 @@
+#*
+ 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.
+*#
+<h1>Report</h1>
+
+<ul class="nav nav-pills">
+ <li class="dropdown">
+ <a id="actions" role="button" data-toggle="dropdown" href="#">Actions <b class="caret"></b></a>
+ <ul id="actions-list" class="dropdown-menu" role="menu" aria-labelledby="actions">
+ <li role="presentation"><a role="menuitem" href="$mapping/report/clear">Clear</a></li>
+ </ul>
+ </li>
+ <li class="dropdown">
+ <a id="formats" role="button" data-toggle="dropdown" href="#">Formats <b class="caret"></b></a>
+ <ul id="formats-list" class="dropdown-menu" role="menu" aria-labelledby="formats">
+ <li role="presentation"><a role="menuitem" href="$mapping/report.xml">xml</a></li>
+ <li role="presentation"><a role="menuitem" href="$mapping/report.csv">csv</a></li>
+ <li role="presentation"><a role="menuitem" href="$mapping/report.json">json</a></li>
+ </ul>
+ </li>
+ <li class="dropdown">
+ <a id="units" role="button" data-toggle="dropdown" href="#">Units <b class="caret"></b></a>
+ <ul id="units-list" class="dropdown-menu" role="menu" aria-labelledby="units">
+ <li role="presentation"><a role="menuitem" href="$mapping/report?unit=s">s</a></li>
+ <li role="presentation"><a role="menuitem" href="$mapping/report?unit=ms">ms</a></li>
+ <li role="presentation"><a role="menuitem" href="$mapping/report?unit=ns">ns</a></li>
+ </ul>
+ </li>
+</ul>
+
+<table id="report-table" class="table table-bordered table-hover table-striped tablesorter">
+ <thead>
+ <tr>
+ #foreach( $header in $headers )
+ <th>$header <i class="icon-sort"></i></th>
+ #end
+ </tr>
+ </thead>
+ <tbody>
+ #foreach( $line in $data.entrySet() )
+ <tr>
+ #foreach( $item in $line.getValue() )
+ <td>
+ #if ($foreach.isFirst())
+ <a href="$mapping/report/counter/$line.getKey()">$item</a>
+ #else
+ $item
+ #end
+ </td>
+ #end
+ </tr>
+ #end
+ </tbody>
+</table>
+
+<script type="text/javascript" src="$mapping/resources/js/jquery.tablesorter.js"></script>
+<script type="text/javascript" src="$mapping/resources/js/jquery.tablesorter.widgets.js"></script>
+<script type="text/javascript">
+ $(function() {
+ $("table#report-table").tablesorter({
+ widthFixed : false,
+ widgets: [ "filter" ],
+ widgetOptions : {
+ filter_childRows : false,
+ filter_columnFilters : true,
+ filter_cssFilter : 'tablesorter-filter',
+ filter_filteredRow : 'filtered',
+ filter_formatter : null,
+ filter_functions : null,
+ filter_hideFilters : false,
+ filter_ignoreCase : true,
+ filter_liveSearch : true,
+ filter_reset : 'button.reset',
+ filter_searchDelay : 300,
+ filter_serversideFiltering: false,
+ filter_startsWith : false,
+ filter_useParsedData : false,
+ cssAsc: 'headerSortUp',
+ cssDesc: 'headerSortDown',
+ sortList: [[4, 1]] // sort by mean in descending order
+ }
+ });
+
+ // input search box shouldn't force the width of columns
+ $('input[type="search"].tablesorter-filter').addClass('col-lg-12')
+ $('input[type="search"].tablesorter-filter').addClass('smooth-box')
+ });
+</script>
Added: incubator/sirona/trunk/server/reporting/src/main/resources/templates/status/detail.vm
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/main/resources/templates/status/detail.vm?rev=1539076&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/main/resources/templates/status/detail.vm (added)
+++ incubator/sirona/trunk/server/reporting/src/main/resources/templates/status/detail.vm Tue Nov 5 17:25:15 2013
@@ -0,0 +1,39 @@
+#*
+ 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.
+*#
+<h1>Node $name</h1>
+
+<div>
+ <div class="alert alert-$helper.map($node.status)">Global status: $node.status</div>
+ <table class="table table-bordered table-striped">
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>Description</th>
+ <th>Status</th>
+ </tr>
+ </thead>
+ <tbody>
+ #foreach ($result in $node.results)
+ <tr class="$helper.map($result.status)">
+ <td>$result.name</td>
+ <td>$result.message</td>
+ <td>$result.status</td>
+ </tr>
+ #end
+ </tbody>
+ </table>
+</div>
Added: incubator/sirona/trunk/server/reporting/src/main/resources/templates/status/home.vm
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/main/resources/templates/status/home.vm?rev=1539076&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/main/resources/templates/status/home.vm (added)
+++ incubator/sirona/trunk/server/reporting/src/main/resources/templates/status/home.vm Tue Nov 5 17:25:15 2013
@@ -0,0 +1,32 @@
+#*
+ 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.
+*#
+<h1>Nodes</h1>
+
+<div>
+ Here is the list of available nodes with their status:
+ <ul>
+ #foreach ($node in $nodes.entrySet())
+ #set($status = $node.value.status)
+ #set($statusClass = $helper.map($status))
+ <li>
+ <div class="alert alert-$statusClass">
+ <a class="alert-$statusClass" href="$mapping/status/$node.key">$node.key</a>: $status
+ </div>
+ </li>
+ #end
+ </ul>
+</div>
Added: incubator/sirona/trunk/server/reporting/src/main/resources/templates/threads/thread.vm
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/main/resources/templates/threads/thread.vm?rev=1539076&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/main/resources/templates/threads/thread.vm (added)
+++ incubator/sirona/trunk/server/reporting/src/main/resources/templates/threads/thread.vm Tue Nov 5 17:25:15 2013
@@ -0,0 +1,24 @@
+#*
+ 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.
+*#
+<p>
+ State: $state
+</p>
+<p>
+ #if ($dump)
+$dump
+ #end
+</p>
\ No newline at end of file
Added: incubator/sirona/trunk/server/reporting/src/main/resources/templates/threads/threads.vm
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/main/resources/templates/threads/threads.vm?rev=1539076&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/main/resources/templates/threads/threads.vm (added)
+++ incubator/sirona/trunk/server/reporting/src/main/resources/templates/threads/threads.vm Tue Nov 5 17:25:15 2013
@@ -0,0 +1,49 @@
+#*
+ 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.
+*#
+<div class="page-header">
+ <h2>Threads</h2>
+</div>
+
+<div class="container-fluid">
+ <div class="row-fluid">
+ <div class="col-lg-2" style="word-break: break-all; word-wrap: break-word;">
+ #foreach ($thread in $threads.entrySet())
+ <ul>
+ <li><a id="$thread.value" class="thread" href="#">$thread.key</a></li>
+ </ul>
+ #end
+ </div>
+ <div class="col-lg-6 space">
+ <div id="thread-info" class="col-lg-10">
+ Click on the left list to select a thread to show.
+ </div>
+ </div>
+ </div>
+</div>
+
+<script type="text/javascript">
+ $(function() {
+ $('.thread').click(function (evt) {
+ evt.preventDefault();
+
+ var url = '$mapping/threads/' + $(this).attr("id");
+ $.get(url, function(data) {
+ $("#thread-info").html(data);
+ });
+ });
+ });
+</script>
Added: incubator/sirona/trunk/server/reporting/src/main/resources/templates/web/web.vm
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/main/resources/templates/web/web.vm?rev=1539076&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/main/resources/templates/web/web.vm (added)
+++ incubator/sirona/trunk/server/reporting/src/main/resources/templates/web/web.vm Tue Nov 5 17:25:15 2013
@@ -0,0 +1,41 @@
+#*
+ 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.
+*#
+#set ( $parts = ["Commits", "Rollbacks", "Actives"])
+
+<div class="container-fluid">
+ <div class="row-fluid">
+ #graphBlock("Sessions", "sessions")
+ </div>
+</div>
+
+<script type="text/javascript" src="$mapping/resources/js/bootstrap-datetimepicker.min.js"></script>
+<script type="text/javascript" src="$mapping/resources/js/jquery.flot.min.js"></script>
+<script type="text/javascript" src="$mapping/resources/js/jquery.flot.time.min.js"></script>
+<script type="text/javascript">
+ $(function() {
+ var options = {
+ canvas: true,
+ series: { lines: { show: true }, points: { show: true } },
+ grid: { hoverable: true, clickable: true },
+ xaxes: [ { mode: "time", timezone: "browser" } ],
+ yaxes: [ { min: 0 } ]
+ };
+
+ // update diagram when clicking on update buttons
+ Sirona.initGraph("$mapping", 'web', 'sessions', options);
+ });
+</script>
Added: incubator/sirona/trunk/server/reporting/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/main/webapp/WEB-INF/web.xml?rev=1539076&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/main/webapp/WEB-INF/web.xml (added)
+++ incubator/sirona/trunk/server/reporting/src/main/webapp/WEB-INF/web.xml Tue Nov 5 17:25:15 2013
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<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_2_5.xsd"
+ version="2.5">
+
+ <context-param> <!-- only register this webapp gauges -->
+ <param-name>monitoring.discovery.packages</param-name>
+ <param-value>org.apache.sirona.reporting.web.plugin</param-value>
+ </context-param>
+
+ <listener>
+ <listener-class>org.apache.sirona.web.discovery.GaugeDiscoveryListener</listener-class>
+ </listener>
+
+ <filter>
+ <filter-name>Monitoring</filter-name>
+ <filter-class>org.apache.sirona.reporting.web.MonitoringController</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>Monitoring</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+</web-app>
Added: incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/FormatsTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/FormatsTest.java?rev=1539076&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/FormatsTest.java (added)
+++ incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/FormatsTest.java Tue Nov 5 17:25:15 2013
@@ -0,0 +1,94 @@
+/*
+ * 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.reporting;
+
+import org.apache.sirona.Role;
+import org.apache.sirona.counters.Counter;
+import org.apache.sirona.reporting.web.handler.api.Template;
+import org.apache.sirona.reporting.web.handler.api.TemplateHelper;
+import org.apache.sirona.reporting.web.plugin.report.format.CSVFormat;
+import org.apache.sirona.reporting.web.plugin.report.format.Format;
+import org.apache.sirona.reporting.web.template.Templates;
+import org.apache.sirona.repositories.Repository;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Collections;
+
+import static org.junit.Assert.assertEquals;
+
+public class FormatsTest {
+ @BeforeClass
+ public static void setup() {
+ Repository.INSTANCE.clear();
+ Templates.init("", "");
+
+ final Counter counter = Repository.INSTANCE.getCounter(new Counter.Key(Role.FAILURES, "RendererTest"));
+ counter.updateConcurrency(1);
+ counter.add(1.);
+ }
+
+ @AfterClass
+ public static void clear() {
+ Repository.INSTANCE.clear();
+ }
+
+ @Test
+ public void renderToXML() throws Exception {
+ final StringWriter out = new StringWriter();
+ final TemplateHelper helper = new TemplateHelper(new PrintWriter(out), Collections.<String, Object>emptyMap());
+ final Template template = Format.Defaults.XML.render(Collections.<String, Object>emptyMap());
+ helper.renderPlain(template.getTemplate(), template.getUserParams());
+
+ assertEquals("<?xml version=\"1.0\"?> <repository> " +
+ "<counter name=\"RendererTest\" role=\"failures\" unit=\"u\" Hits=\"1.0\" Max=\"1.0\" Mean=\"1.0\" Min=\"1.0\" " +
+ "StandardDeviation=\"0.0\" Sum=\"1.0\" Variance=\"0.0\" Value=\"1.0\" Concurrency=\"0.0\" MaxConcurrency=\"1.0\" />" +
+ " </repository>", inline(out));
+ }
+
+ @Test
+ public void renderToJSON() throws Exception {
+ final StringWriter out = new StringWriter();
+ final TemplateHelper helper = new TemplateHelper(new PrintWriter(out), Collections.<String, Object>emptyMap());
+ final Template template = Format.Defaults.JSON.render(Collections.<String, Object>emptyMap());
+ helper.renderPlain(template.getTemplate(), template.getUserParams());
+
+ assertEquals("{\"counters\":[" +
+ " {\"name\":\"RendererTest\", \"role\":\"failures\",\"unit\":\"u\",\"Hits\":\"1.0\",\"Max\":\"1.0\",\"Mean\":\"1.0\",\"Min\":\"1.0\"," +
+ "\"StandardDeviation\":\"0.0\",\"Sum\":\"1.0\",\"Variance\":\"0.0\"," +
+ "\"Value\":\"1.0\",\"Concurrency\":\"0.0\",\"MaxConcurrency\":\"1.0\"} ]}", inline(out));
+ }
+
+ @Test
+ public void renderToCSV() throws Exception {
+ final StringWriter out = new StringWriter();
+ final TemplateHelper helper = new TemplateHelper(new PrintWriter(out), Collections.<String, Object>emptyMap());
+ final Template template = Format.Defaults.CSV.render(Collections.<String, Object>emptyMap());
+ helper.renderPlain(template.getTemplate(), template.getUserParams());
+
+ assertEquals(CSVFormat.HEADER +
+ "RendererTest;failures (u);1.0;1.0;1.0;1.0;0.0;1.0;0.0;1.0;0.0;1.0\n",
+ out.toString());
+ }
+
+ private static String inline(StringWriter out) {
+ return out.toString().replace("\r\n", " ").replace("\n", " ").replaceAll(" +", " ").replace("\t", "").trim();
+ }
+}
Added: incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/GaugesTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/GaugesTest.java?rev=1539076&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/GaugesTest.java (added)
+++ incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/GaugesTest.java Tue Nov 5 17:25:15 2013
@@ -0,0 +1,52 @@
+/*
+ * 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.reporting.template;
+
+import com.gargoylesoftware.htmlunit.TextPage;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertThat;
+
+public class GaugesTest extends SironaReportingTestBase {
+ private static final String CPU_GAUGE_ENCODED = "Q1BV";
+
+ @Test
+ public void checkGaugesAreListed() throws IOException {
+ final HtmlPage page = page("gauges");
+ final String content = page.getWebResponse().getContentAsString();
+ assertThat(content, containsString("<a href=\"/sirona-test/monitoring/gauges/" + CPU_GAUGE_ENCODED + "\">"));
+ assertThat(content, containsString("CPU"));
+ }
+
+ @Test
+ public void checkDetail() throws IOException {
+ final HtmlPage page = page("gauges/" + CPU_GAUGE_ENCODED);
+ assertThat(page.getWebResponse().getContentAsString(), containsString("id=\"" + CPU_GAUGE_ENCODED + "-graph\""));
+ }
+
+ @Test
+ public void checkJsonDetail() throws IOException {
+ final TextPage page = page("gauges/" + CPU_GAUGE_ENCODED + "/0/" + (System.currentTimeMillis() + 1000));
+ final String json = page.getWebResponse().getContentAsString();
+ assertThat(json, containsString("[{\"label\":\"CPU\",\"color\":"));
+ assertThat(json, containsString("\"data\":"));
+ }
+}
Added: incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/HomeTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/HomeTest.java?rev=1539076&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/HomeTest.java (added)
+++ incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/HomeTest.java Tue Nov 5 17:25:15 2013
@@ -0,0 +1,40 @@
+/*
+ * 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.reporting.template;
+
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertThat;
+import org.junit.Test;
+
+import java.io.IOException;
+
+public class HomeTest extends SironaReportingTestBase {
+ @Test
+ public void checkHomeShowsPlugins() throws IOException {
+ final HtmlPage page = page("");
+ final String plugins = page.getElementById("plugins").asText();
+ assertThat(plugins, containsString("Home"));
+ assertThat(plugins, containsString("Report"));
+ assertThat(plugins, containsString("JMX"));
+ assertThat(plugins, containsString("JVM"));
+ assertThat(plugins, containsString("JTA"));
+ assertThat(plugins, containsString("Threads"));
+ assertThat(plugins, containsString("Web"));
+ }
+}
Added: incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/JMXTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/JMXTest.java?rev=1539076&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/JMXTest.java (added)
+++ incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/JMXTest.java Tue Nov 5 17:25:15 2013
@@ -0,0 +1,44 @@
+/*
+ * 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.reporting.template;
+
+import com.gargoylesoftware.htmlunit.TextPage;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static com.gargoylesoftware.htmlunit.WebAssert.assertElementPresent;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertThat;
+
+public class JMXTest extends SironaReportingTestBase {
+ @Test
+ public void checkSomeMBeanIsAvailable() throws IOException {
+ final String classLoadingMBeanId = "amF2YS5sYW5nOnR5cGU9Q2xhc3NMb2FkaW5n"; // java.lang:ClassLoading
+
+ final HtmlPage page = page("jmx");
+ assertElementPresent(page, classLoadingMBeanId);
+
+ // we could click on the link but it would mandates to activate js in the WebClient (see parent)
+ // this is not as easy as setting the boolean because of dev environment (proxy, etc...)
+ final TextPage detail = page("jmx/" + classLoadingMBeanId);
+ final String detailAsStr = detail.getWebResponse().getContentAsString();
+ assertThat(detailAsStr, containsString("LoadedClassCount"));
+ assertThat(detailAsStr, containsString("sun.management.ClassLoadingImpl"));
+ }
+}
Added: incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/JTATest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/JTATest.java?rev=1539076&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/JTATest.java (added)
+++ incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/JTATest.java Tue Nov 5 17:25:15 2013
@@ -0,0 +1,42 @@
+/*
+ * 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.reporting.template;
+
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static com.gargoylesoftware.htmlunit.WebAssert.assertElementPresent;
+import static org.junit.Assert.assertTrue;
+
+public class JTATest extends SironaReportingTestBase {
+ @Test
+ public void checkGraphArePresent() throws IOException {
+ final HtmlPage page = page("jta");
+ assertElementPresent(page, "Commits-graph");
+ assertElementPresent(page, "Rollbacks-graph");
+ assertElementPresent(page, "Actives-graph");
+ }
+
+ @Test
+ public void checkJsonEndpoint() throws IOException {
+ final String page = page("jta/Actives/0/" + System.currentTimeMillis()).getWebResponse().getContentAsString().replace(" ", "");
+ assertTrue(page.contains("\"data\":["));
+ assertTrue(page.startsWith("[{\"label\":\"Actives\",\"color\":\"#"));
+ }
+}
Added: incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/JVMTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/JVMTest.java?rev=1539076&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/JVMTest.java (added)
+++ incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/JVMTest.java Tue Nov 5 17:25:15 2013
@@ -0,0 +1,41 @@
+/*
+ * 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.reporting.template;
+
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static com.gargoylesoftware.htmlunit.WebAssert.assertElementPresent;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertThat;
+
+public class JVMTest extends SironaReportingTestBase {
+ @Test
+ public void checkGraphArePresent() throws IOException {
+ final HtmlPage page = page("jvm");
+ assertElementPresent(page, "cpu-graph");
+ assertElementPresent(page, "memory-graph");
+
+ final String detailAsStr = page.getWebResponse().getContentAsString();
+ assertThat(detailAsStr, containsString("CPU"));
+ assertThat(detailAsStr, containsString("Memory"));
+ assertThat(detailAsStr, containsString("OS Name"));
+ assertThat(detailAsStr, containsString(System.getProperty("os.name")));
+ }
+}
Added: incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/ReportTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/ReportTest.java?rev=1539076&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/ReportTest.java (added)
+++ incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/ReportTest.java Tue Nov 5 17:25:15 2013
@@ -0,0 +1,88 @@
+/*
+ * 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.reporting.template;
+
+import com.gargoylesoftware.htmlunit.WebAssert;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import org.apache.sirona.Role;
+import org.apache.sirona.counters.Counter;
+import org.apache.sirona.counters.Unit;
+import org.apache.sirona.reporting.web.plugin.report.format.MapFormat;
+import org.apache.sirona.repositories.Repository;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.Locale;
+
+import static org.junit.Assert.assertEquals;
+
+public class ReportTest extends SironaReportingTestBase {
+ private Counter.Key key;
+
+ private static Locale oldLocale;
+ private static final String lineSeparator = System.getProperty("line.separator");
+
+ @Before
+ public void init() {
+ Repository.INSTANCE.clear();
+ key = new Counter.Key(new Role("role", Unit.UNARY), "counter");
+ Repository.INSTANCE.getCounter(key).add(55);
+ }
+
+ @After
+ public void reset() {
+ Repository.INSTANCE.clear();
+ }
+
+ @BeforeClass
+ public static void setDefaultLocale() {
+ oldLocale = Locale.getDefault();
+ Locale.setDefault(Locale.ENGLISH);
+ }
+
+ @AfterClass
+ public static void restoreLocale() {
+ Locale.setDefault(oldLocale);
+ }
+
+ @Test
+ public void generalList() throws IOException {
+ final WebClient client = newClient();
+ final HtmlPage page = client.getPage(base.toExternalForm() + "monitoring/report");
+ WebAssert.assertElementPresent(page, "report-table");
+
+ final String text = page.getElementById("report-table").asText();
+ assertEquals("Counter\tRole\tHits\tMax\tMean\tMin\tStandardDeviation\tSum\tVariance\tValue\tConcurrency\tMaxConcurrency" + lineSeparator +
+ "counter\trole(u)\t1.00\t55.00\t55.00\t55.00\t0.00\t55.00\t0.00\t55.00\t0.00\t0.00", text.replace(" ", ""));
+ }
+
+ @Test
+ public void detail() throws IOException {
+ final WebClient client = newClient();
+ final HtmlPage page = client.getPage(base.toExternalForm() + "monitoring/report/counter/" + MapFormat.generateCounterKeyString(key));
+ WebAssert.assertElementPresent(page, "counter");
+
+ final String text = page.getElementById("counter").asText();
+ assertEquals("Counter\tRole\tHits\tMax\tMean\tMin\tStandardDeviation\tSum\tVariance\tValue\tConcurrency\tMaxConcurrency" + lineSeparator +
+ "counter\trole (u)\t1.00\t55.00\t55.00\t55.00\t0.00\t55.00\t0.00\t55.00\t0.00\t0.00", text);
+ }
+}
Added: incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/SironaReportingTestBase.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/SironaReportingTestBase.java?rev=1539076&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/SironaReportingTestBase.java (added)
+++ incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/SironaReportingTestBase.java Tue Nov 5 17:25:15 2013
@@ -0,0 +1,75 @@
+/*
+ * 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.reporting.template;
+
+import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.WebClient;
+import org.apache.catalina.startup.Constants;
+import org.apache.sirona.reporting.web.registration.MonitoringReportingInitializer;
+import org.apache.sirona.web.lifecycle.SironaLifecycle;
+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.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.runner.RunWith;
+
+import javax.servlet.ServletContainerInitializer;
+import java.io.IOException;
+import java.net.URL;
+
+// NOTE: we depend implicitely on tomcat embedded adapter since
+// 1) we don't add dependencies
+// 2) we use the fact Repository.INSTANCE is in the same JVM
+@RunWith(Arquillian.class)
+public abstract class SironaReportingTestBase {
+ static {
+ // we use this hack to init jars to skip since this method is triggered before any deployment
+ // so ContextConfig is not yet loaded
+ System.setProperty(Constants.DEFAULT_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*");
+ }
+
+ @Deployment(testable = false)
+ public static Archive<?> war() {
+ // bug hack: we don't create an Archive<?> representing our webapp since all will be at classpath
+ // this makes test faster and easier to maintain (if we add stuff) but dependent on our current tomcat embedded adapter
+ return ShrinkWrap.create(WebArchive.class, "sirona-test.war")
+ .addAsLibraries(
+ ShrinkWrap.create(JavaArchive.class, "sci.jar") // bug in tomcat?
+ .addAsServiceProvider(ServletContainerInitializer.class, MonitoringReportingInitializer.class)
+ .addClass(SironaLifecycle.class));
+ }
+
+ @ArquillianResource
+ protected URL base;
+
+ protected <P extends Page> P page(final String path) throws IOException {
+ return newClient().getPage(base.toExternalForm() + "monitoring/" + path);
+ }
+
+ protected static WebClient newClient() {
+ final WebClient webClient = new WebClient();
+ webClient.getOptions().setJavaScriptEnabled(false);
+ webClient.getOptions().setCssEnabled(false);
+ webClient.getOptions().setAppletEnabled(false);
+ webClient.setAjaxController(new NicelyResynchronizingAjaxController());
+ return webClient;
+ }
+}
Added: incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/StatusTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/StatusTest.java?rev=1539076&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/StatusTest.java (added)
+++ incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/StatusTest.java Tue Nov 5 17:25:15 2013
@@ -0,0 +1,54 @@
+/*
+ * 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.reporting.template;
+
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import org.apache.sirona.configuration.Configuration;
+import org.apache.sirona.repositories.Repository;
+import org.apache.sirona.status.NodeStatus;
+import org.apache.sirona.status.Status;
+import org.apache.sirona.status.ValidationResult;
+import org.apache.sirona.store.status.NodeStatusDataStore;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertThat;
+
+public class StatusTest extends SironaReportingTestBase {
+ @BeforeClass
+ public static void addStatus() {
+ Configuration.findOrCreateInstance(Repository.class);
+ Configuration.getInstance(NodeStatusDataStore.class).statuses().put("node1", new NodeStatus(new ValidationResult[] { new ValidationResult("validation #1", Status.OK, "all is fine") }));
+ }
+
+ @Test
+ public void checkNodesAreListed() throws IOException {
+ final HtmlPage page = page("status");
+ assertThat(page.getWebResponse().getContentAsString(), containsString("/status/node1"));
+ }
+
+ @Test
+ public void checkDetail() throws IOException {
+ final HtmlPage page = page("status/node1");
+ assertThat(page.getWebResponse().getContentAsString(), containsString("Global status: OK"));
+ assertThat(page.getWebResponse().getContentAsString(), containsString("validation #1"));
+ assertThat(page.getWebResponse().getContentAsString(), containsString("all is fine"));
+ }
+}
Added: incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/ThreadsTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/ThreadsTest.java?rev=1539076&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/ThreadsTest.java (added)
+++ incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/ThreadsTest.java Tue Nov 5 17:25:15 2013
@@ -0,0 +1,44 @@
+/*
+ * 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.reporting.template;
+
+import com.gargoylesoftware.htmlunit.TextPage;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static com.gargoylesoftware.htmlunit.WebAssert.assertElementPresent;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+public class ThreadsTest extends SironaReportingTestBase {
+ private static final String CONTAINER_BACKGROUND_THREAD = "Q29udGFpbmVyQmFja2dyb3VuZFByb2Nlc3NvcltTdGFuZGFyZEVuZ2luZVthcnF1aWxsaWFuLXRvbWNhdC1lbWJlZGRlZC03XV0="; // always exists
+
+ @Test
+ public void checkThreadsAreListed() throws IOException {
+ final HtmlPage page = page("threads");
+ assertElementPresent(page, CONTAINER_BACKGROUND_THREAD);
+ }
+
+ @Test
+ public void checkDetail() throws IOException {
+ final TextPage page = page("threads/" + CONTAINER_BACKGROUND_THREAD);
+ assertThat(page.getWebResponse().getContentAsString(), containsString("org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run"));
+ }
+}
Added: incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/WebTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/WebTest.java?rev=1539076&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/WebTest.java (added)
+++ incubator/sirona/trunk/server/reporting/src/test/java/org/apache/sirona/reporting/template/WebTest.java Tue Nov 5 17:25:15 2013
@@ -0,0 +1,45 @@
+/*
+ * 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.reporting.template;
+
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static com.gargoylesoftware.htmlunit.WebAssert.assertElementPresent;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+public class WebTest extends SironaReportingTestBase {
+ @Test
+ public void checkSessionsGraphIsPresent() throws IOException {
+ final HtmlPage page = page("web");
+ assertElementPresent(page, "sessions-graph");
+
+ final String detailAsStr = page.getWebResponse().getContentAsString();
+ assertThat(detailAsStr, containsString("Sessions"));
+ }
+
+ @Test
+ public void checkJsonEndpoint() throws IOException {
+ final String page = page("web/sessions/0/" + System.currentTimeMillis()).getWebResponse().getContentAsString().replace(" ", "");
+ assertEquals("[]", page); // we don't deploy in this tests sessions gauges so we have nothing
+ }
+}
Added: incubator/sirona/trunk/server/reporting/src/test/resources/arquillian.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/test/resources/arquillian.xml?rev=1539076&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/test/resources/arquillian.xml (added)
+++ incubator/sirona/trunk/server/reporting/src/test/resources/arquillian.xml Tue Nov 5 17:25:15 2013
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+ 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.
+-->
+<arquillian xmlns="http://jboss.org/schema/arquillian"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://jboss.org/schema/arquillian
+ http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
+ <container qualifier="tomcat7" default="true">
+ <configuration>
+ <property name="tomcatHome">target/tomcat7</property>
+ <property name="workDir">target/arquillian-work</property>
+ <property name="unpackArchive">true</property>
+ <property name="bindHttpPort">1234</property>
+ </configuration>
+ </container>
+</arquillian>
Added: incubator/sirona/trunk/server/reporting/src/test/resources/sirona.properties
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/test/resources/sirona.properties?rev=1539076&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/test/resources/sirona.properties (added)
+++ incubator/sirona/trunk/server/reporting/src/test/resources/sirona.properties Tue Nov 5 17:25:15 2013
@@ -0,0 +1,17 @@
+# 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.
+org.apache.sirona.store.status.NodeStatusDataStore = org.apache.sirona.store.status.EmptyStatuses