]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3786 Rewrite the "Tests" tabulation in the source viewer to drop use of GWT
authorJulien Lancelot <julien.lancelot@gmail.com>
Tue, 20 Nov 2012 17:26:31 +0000 (18:26 +0100)
committerJulien Lancelot <julien.lancelot@gmail.com>
Wed, 21 Nov 2012 10:41:24 +0000 (11:41 +0100)
19 files changed:
plugins/sonar-core-gwt/infinitest.args [deleted file]
plugins/sonar-core-gwt/pom.xml [deleted file]
plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/TestsViewerDefinition.java [deleted file]
plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsPanel.java [deleted file]
plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsViewer.java [deleted file]
plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/TestsViewer.gwt.xml [deleted file]
plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/TestsViewerDev.gwt.xml [deleted file]
plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/TestsViewer.css [deleted file]
plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/error.png [deleted file]
plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/failure.png [deleted file]
plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/ok.png [deleted file]
plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/skipped.png [deleted file]
plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/test.html [deleted file]
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/web/TestsViewer.java [new file with mode: 0644]
plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/web/tests_viewer.html.erb [new file with mode: 0644]
pom.xml
sonar-server/src/main/webapp/javascripts/resource.js

diff --git a/plugins/sonar-core-gwt/infinitest.args b/plugins/sonar-core-gwt/infinitest.args
deleted file mode 100644 (file)
index ed9f41d..0000000
+++ /dev/null
@@ -1 +0,0 @@
--Djava.awt.headless=true
\ No newline at end of file
diff --git a/plugins/sonar-core-gwt/pom.xml b/plugins/sonar-core-gwt/pom.xml
deleted file mode 100644 (file)
index 8363454..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>org.codehaus.sonar</groupId>
-    <artifactId>sonar</artifactId>
-    <version>3.4-SNAPSHOT</version>
-    <relativePath>../..</relativePath>
-  </parent>
-  <artifactId>sonar-core-gwt</artifactId>
-  <packaging>jar</packaging>
-  <name>Sonar :: Plugins :: Core GWT</name>
-  
-  <dependencies>
-    <dependency>
-      <groupId>org.codehaus.sonar</groupId>
-      <artifactId>sonar-plugin-api</artifactId>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.sonar</groupId>
-      <artifactId>sonar-gwt-api</artifactId>
-      <version>${sonarGwt.version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.sonar</groupId>
-      <artifactId>sonar-ws-client</artifactId>
-      <version>3.3.1</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>com.google.gwt</groupId>
-      <artifactId>gwt-user</artifactId>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>com.google.gwt</groupId>
-      <artifactId>gwt-incubator</artifactId>
-      <scope>provided</scope>
-    </dependency>
-
-    <!-- unit tests -->
-    <dependency>
-      <groupId>org.codehaus.sonar</groupId>
-      <artifactId>sonar-testing-harness</artifactId>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <testResources>
-      <testResource>
-        <directory>${basedir}/src/main/resources</directory>
-      </testResource>
-      <testResource>
-        <directory>${basedir}/src/test/resources</directory>
-      </testResource>
-    </testResources>
-
-    <plugins>
-      <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>gwt-maven-plugin</artifactId>
-        <executions>
-          <execution>
-            <configuration>
-              <modules>
-                <module>org.sonar.plugins.core.testdetailsviewer.TestsViewer${gwt.permutationSuffix}</module>
-              </modules>
-              <skip>${skipGwt}</skip>
-              <webappDirectory>${project.build.directory}/classes</webappDirectory>
-              <extraJvmArgs>${gwt.extraJvmArgs}</extraJvmArgs>
-            </configuration>
-            <goals>
-              <goal>compile</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-</project>
\ No newline at end of file
diff --git a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/TestsViewerDefinition.java b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/TestsViewerDefinition.java
deleted file mode 100644 (file)
index e9d3271..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.core.testdetailsviewer;
-
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.web.*;
-import org.sonar.plugins.core.testdetailsviewer.client.TestsViewer;
-
-@ResourceQualifier(Qualifiers.UNIT_TEST_FILE)
-@NavigationSection(NavigationSection.RESOURCE_TAB)
-@DefaultTab(metrics = {CoreMetrics.TESTS_KEY, CoreMetrics.TEST_EXECUTION_TIME_KEY, CoreMetrics.TEST_SUCCESS_DENSITY_KEY, CoreMetrics.TEST_FAILURES_KEY, CoreMetrics.TEST_ERRORS_KEY, CoreMetrics.SKIPPED_TESTS_KEY})
-@UserRole(UserRole.CODEVIEWER)
-public class TestsViewerDefinition extends GwtPage {
-
-  public String getTitle() {
-    return "Tests";
-  }
-
-  public String getGwtId() {
-    return TestsViewer.GWT_ID;
-  }
-
-}
diff --git a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsPanel.java b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsPanel.java
deleted file mode 100644 (file)
index df22980..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.core.testdetailsviewer.client;
-
-import com.google.gwt.gen2.table.override.client.FlexTable;
-import com.google.gwt.gen2.table.override.client.FlexTable.FlexCellFormatter;
-import com.google.gwt.i18n.client.Dictionary;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.ui.*;
-import com.google.gwt.xml.client.Document;
-import com.google.gwt.xml.client.Element;
-import com.google.gwt.xml.client.NodeList;
-import com.google.gwt.xml.client.XMLParser;
-import org.sonar.gwt.Metrics;
-import org.sonar.gwt.ui.ExpandCollapseLink;
-import org.sonar.gwt.ui.Loading;
-import org.sonar.wsclient.gwt.AbstractCallback;
-import org.sonar.wsclient.gwt.Sonar;
-import org.sonar.wsclient.services.Measure;
-import org.sonar.wsclient.services.Resource;
-import org.sonar.wsclient.services.ResourceQuery;
-
-public class TestsPanel extends Composite {
-
-  private final Panel panel;
-  private Loading loading;
-
-  public TestsPanel(Resource resource) {
-    panel = new VerticalPanel();
-    loading = new Loading();
-    panel.add(loading);
-    initWidget(panel);
-    setStyleName("gwt-TestDetailsPanel");
-    getElement().setId("gwt-TestDetailsPanel");
-    loadData(resource);
-  }
-
-  private void loadData(Resource resource) {
-    ResourceQuery query = ResourceQuery.createForResource(resource, Metrics.TEST_DATA);
-    Sonar.getInstance().find(query, new TestDetailsMeasureHandler());
-  }
-
-  private class TestDetailsMeasureHandler extends AbstractCallback<Resource> {
-
-    public TestDetailsMeasureHandler() {
-      super(loading);
-    }
-
-    @Override
-    protected void doOnResponse(Resource resource) {
-      loading.removeFromParent();
-      if (resource != null) {
-        Measure measure = resource.getMeasure(Metrics.TEST_DATA);
-        processTestDetails(measure.getData());
-      }
-    }
-
-    private void processTestDetails(String testXMLData) {
-      Document parsed = XMLParser.parse(testXMLData);
-      NodeList testcasesXML = parsed.getElementsByTagName("testcase");
-
-      Dictionary l10n = Dictionary.getDictionary("l10n");
-      FlexTable table = new FlexTable();
-      table.setStylePrimaryName("detailsTable");
-      table.setText(0, 0, "");
-      table.setText(0, 1, "");
-      table.setText(0, 2, l10n.get("unittest.duration"));
-      table.setText(0, 3, l10n.get("unittest.name"));
-      table.getCellFormatter().getElement(0, 1).setId("iCol");
-      table.getCellFormatter().getElement(0, 2).setId("dCol");
-      setRowStyle(0, table, "header", false);
-
-      int rowCounter = 1;
-      for (int i = 0; i < testcasesXML.getLength(); i++) {
-        Element testcaseXML = (Element) testcasesXML.item(i);
-        String time = testcaseXML.getAttribute("time");
-        String name = testcaseXML.getAttribute("name");
-        String status = testcaseXML.getAttribute("status");
-        Element error = getFirstElement("error", testcaseXML);
-        Element failure = getFirstElement("failure", testcaseXML);
-        Element stackTrace = status.equals("error") ? error : failure;
-        renderTestDetails(rowCounter, i, status, stackTrace, name, time, table);
-        rowCounter += 2;
-      }
-      panel.add(table);
-    }
-
-    private Element getFirstElement(String elementName, Element node) {
-      NodeList elements = node.getElementsByTagName(elementName);
-      return elements.getLength() > 0 ? (Element) elements.item(0) : null;
-    }
-
-    private void renderTestDetails(int row, int testCounter, String testCaseStatus, Element stackTrace, String name, String timeMS, FlexTable table) {
-      HTML icon = new HTML("&nbsp;");
-      icon.setStyleName(testCaseStatus);
-      table.setWidget(row, 1, icon);
-      table.setText(row, 2, timeMS + " ms");
-
-      table.setText(row, 3, name);
-      String style = (testCounter % 2 == 0) ? "odd" : "even";
-      setRowStyle(row, table, style, false);
-
-      if (stackTrace != null) {
-        Panel stackPanel = new SimplePanel();
-        stackPanel.setStyleName("stackPanel");
-        stackPanel.getElement().setId("stack-panel" + name);
-        stackPanel.setVisible(false);
-        fillStackPanel(stackPanel, stackTrace);
-
-        FlexCellFormatter frmt = (FlexCellFormatter) table.getCellFormatter();
-        frmt.setColSpan(row + 1, 1, 3);
-        table.setWidget(row + 1, 1, stackPanel);
-        table.setWidget(row, 0, new ExpandCollapseLink(stackPanel));
-        table.getCellFormatter().getElement(row, 0).setId("expandCollapseCol");
-        setRowStyle(row + 1, table, style, true);
-      }
-    }
-
-    private void setRowStyle(int row, FlexTable table, String style, boolean isPanelRow) {
-      table.getCellFormatter().setStyleName(row, 0, style);
-      table.getCellFormatter().setStyleName(row, 1, style);
-      if (!isPanelRow) {
-        table.getCellFormatter().setStyleName(row, 2, style);
-        table.getCellFormatter().setStyleName(row, 3, style);
-      }
-      table.getCellFormatter().getElement(row, 0).setId("noLinkExpandCollapseCol");
-    }
-  }
-
-  private void fillStackPanel(Panel p, Element stackElement) {
-    String message = stackElement.getAttribute("message");
-    if (message.length() > 0) {
-      p.getElement().setInnerHTML(escapeHtml(message) + "<br/>" + stackLineBreaks(stackElement.getFirstChild().getNodeValue()));
-    } else {
-      p.getElement().setInnerHTML(stackLineBreaks(stackElement.getFirstChild().getNodeValue()));
-    }
-  }
-
-  private String escapeHtml(String maybeHtml) {
-    com.google.gwt.dom.client.Element div = DOM.createDiv();
-    div.setInnerText(maybeHtml);
-    return div.getInnerHTML();
-  }
-
-  private String stackLineBreaks(String s) {
-    StringBuilder stack = new StringBuilder(256);
-    for (String el : s.split("\n")) {
-      stack.append(el.trim()).append("<br/>");
-    }
-    return stack.toString();
-  }
-}
\ No newline at end of file
diff --git a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsViewer.java b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsViewer.java
deleted file mode 100644 (file)
index 0ac58dc..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.core.testdetailsviewer.client;
-
-import com.google.gwt.i18n.client.Dictionary;
-import com.google.gwt.user.client.ui.FlowPanel;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Widget;
-import org.sonar.gwt.Metrics;
-import org.sonar.gwt.ui.Page;
-import org.sonar.gwt.ui.ViewerHeader;
-import org.sonar.wsclient.services.Measure;
-import org.sonar.wsclient.services.Resource;
-
-public class TestsViewer extends Page {
-
-  public static final String GWT_ID = "org.sonar.plugins.core.testdetailsviewer.TestsViewer";
-
-  @Override
-  protected Widget doOnResourceLoad(Resource resource) {
-    FlowPanel flowPanel = new FlowPanel();
-    flowPanel.add(new UnitTestsHeader(resource));
-    flowPanel.add(new TestsPanel(resource));
-    return flowPanel;
-  }
-
-  private static class UnitTestsHeader extends ViewerHeader {
-    public UnitTestsHeader(Resource resource) {
-
-      super(resource, new String[]{
-          Metrics.TEST_ERRORS,
-          Metrics.TEST_FAILURES,
-          Metrics.TEST_SUCCESS_DENSITY,
-          Metrics.TESTS,
-          Metrics.SKIPPED_TESTS,
-          Metrics.TEST_EXECUTION_TIME}
-      );
-    }
-
-    @Override
-    protected void display(FlowPanel header, Resource resource) {
-      Dictionary l10n = Dictionary.getDictionary("l10n");
-      HorizontalPanel panel = new HorizontalPanel();
-      header.add(panel);
-
-      Measure measure = resource.getMeasure(Metrics.TEST_SUCCESS_DENSITY);
-      if (measure == null) {
-        addBigCell(panel, "100%"); // best value
-      } else {
-        addBigCell(panel, measure.getFormattedValue());
-      }
-
-      String skippedHtml = "";
-      Measure skipped = resource.getMeasure(Metrics.SKIPPED_TESTS);
-      if (skipped != null && skipped.getValue() > 0.0) {
-        skippedHtml += " (+" + skipped.getFormattedValue() + " " + l10n.get("unittest.skipped") + ")";
-      }
-      addCell(panel,
-          l10n.get("unittest.tests") + ": ",
-          resource.getMeasureFormattedValue(Metrics.TESTS, "-") + skippedHtml);
-
-      addCell(panel,
-          l10n.get("unittest.failures") + ": ",
-          resource.getMeasureFormattedValue(Metrics.TEST_FAILURES, "0") + "/" + resource.getMeasureFormattedValue(Metrics.TEST_ERRORS, "0"));
-
-      addCell(panel,
-          l10n.get("unittest.duration") + ": ",
-          resource.getMeasureFormattedValue(Metrics.TEST_EXECUTION_TIME, "-"));
-    }
-  }
-
-}
diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/TestsViewer.gwt.xml b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/TestsViewer.gwt.xml
deleted file mode 100644 (file)
index c5e1c33..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<module>
-  <inherits name="com.google.gwt.xml.XML"/>
-  <inherits name="com.google.gwt.user.User"/>
-  <inherits name="com.google.gwt.json.JSON"/>
-  <inherits name="com.google.gwt.http.HTTP"/>
-  <inherits name="org.sonar.Sonar"/>
-  <inherits name="com.google.gwt.gen2.table.Table"/>
-
-  <stylesheet src="TestsViewer.css"/>
-
-  <entry-point class="org.sonar.plugins.core.testdetailsviewer.client.TestsViewer"/>
-
-</module>
\ No newline at end of file
diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/TestsViewerDev.gwt.xml b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/TestsViewerDev.gwt.xml
deleted file mode 100644 (file)
index 8f8f3d8..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<module rename-to="org.sonar.plugins.core.testdetailsviewer.TestsViewer">
-  <inherits name="org.sonar.plugins.core.testdetailsviewer.TestsViewer"/>
-  <inherits name="org.sonar.SonarDev"/>
-
-  <entry-point class="org.sonar.plugins.core.testdetailsviewer.client.TestsViewer"/>
-</module>
diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/TestsViewer.css b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/TestsViewer.css
deleted file mode 100644 (file)
index 0ce4284..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-.gwt-TestDetailsPanel {
-  width: 100%;
-}
-
-.gwt-TestDetailsPanel .error {
-  background-image: url("images/error.png");
-  background-position: 4px 2px;
-  background-repeat: no-repeat;
-  background-color: transparent;
-  border: none;
-  margin: 0 0 2px;
-  padding: 2px;
-  vertical-align: top;
-}
-
-.gwt-TestDetailsPanel .failure {
-  background-image: url("images/failure.png");
-  background-position: 4px 2px;
-  background-repeat: no-repeat;
-  margin: 0 0 2px;
-  padding: 2px;
-  vertical-align: top;
-}
-
-.gwt-TestDetailsPanel .skipped {
-  background-image: url("images/skipped.png");
-  background-position: 4px 2px;
-  background-repeat: no-repeat;
-  margin: 0 0 2px;
-  padding: 2px;
-  vertical-align: top;
-}
-
-.gwt-TestDetailsPanel .ok {
-  background-image: url("images/ok.png");
-  background-position: 4px 2px;
-  background-repeat: no-repeat;
-  margin: 0 0 2px;
-  padding: 2px;
-  vertical-align: top;
-}
-
-.detailsTable {
-  border: 1px solid #C0C0C0;
-  width: 100%;
-  vertical-align: top;
-}
-
-.detailsTable td {
-  vertical-align: top;
-  text-align: left;
-  padding: 3px;
-}
-
-.detailsTable .header {
-  background-color: #EFEFEF;
-  font-weight: bold;
-  color: #333;
-  vertical-align: top;
-}
-
-.detailsTable #iCol {
-  width: 25px;
-}
-
-.detailsTable #dCol {
-  width: 70px;
-}
-
-.detailsTable #expandCollapseCol {
-  width: 60px;
-  text-align: right;
-}
-
-.detailsTable #noLinkExpandCollapseCol {
-  width: 0px;
-  padding: 0px;
-}
-
-.stackPanel {
-  padding: 5px;
-  border: 1px solid #C0C0C0;
-}
-
-.expandCollapseLink {
-       text-align: right;
-  margin-right: 5px;
-}
\ No newline at end of file
diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/error.png b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/error.png
deleted file mode 100644 (file)
index 6e195cf..0000000
Binary files a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/error.png and /dev/null differ
diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/failure.png b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/failure.png
deleted file mode 100644 (file)
index f00e426..0000000
Binary files a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/failure.png and /dev/null differ
diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/ok.png b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/ok.png
deleted file mode 100644 (file)
index 1faba7e..0000000
Binary files a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/ok.png and /dev/null differ
diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/skipped.png b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/skipped.png
deleted file mode 100644 (file)
index 34c0de0..0000000
Binary files a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/skipped.png and /dev/null differ
diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/test.html b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/test.html
deleted file mode 100644 (file)
index 6ec71b5..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
-    "http://www.w3.org/TR/html4/loose.dtd">
-
-<html>
-<head>
-  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
-  <title>TestDetails</title>
-  <link href="http://localhost:9000/dev/stylesheets/yui-2.6.0.css" media="all" rel="Stylesheet" type="text/css"/>
-  <link href="http://localhost:9000/dev/stylesheets/style.css" media="all" rel="Stylesheet" type="text/css"/>
-  <script src="http://localhost:9000/dev/javascripts/application.js" type="text/javascript"></script>
-  <script src="http://localhost:9000/dev/javascripts/prototype.js" type="text/javascript"></script>
-  <script src="http://localhost:9000/dev/javascripts/scriptaculous.js" type="text/javascript"></script>
-</head>
-
-<body>
-<script type="text/javascript">
-  var registeredTabs = [];
-  var config = {
-    "sonar_url": "http://localhost:9000/dev",
-    "viewer_resource_key" : "org.sonar.tests.test-failures:moduleA:ch.hortis.sonar.samples.testFailures.moduleA.FailTest"
-  };
-</script>
-<div class="error" id="error" style="display:none"><span id="errormsg"></span> &nbsp;&nbsp;[<a href="#"
-                                                                                               onclick="javascript:$('error').hide();return false;">hide</a>]
-</div>
-<div class="warning" id="warning" style="display:none"><span id="warningmsg"></span> &nbsp;&nbsp;[<a href="#"
-                                                                                                     onclick="javascript:$('warning').hide();return false;">hide</a>]
-</div>
-<div class="notice" id="info" style="display:none"><span id="infomsg"></span> &nbsp;&nbsp;[<a href="#"
-                                                                                              onclick="javascript:$('info').hide();return false;">hide</a>]
-</div>
-
-<div id="resource_viewers">
-  <div id='loading'></div>
-</div>
-<script type="text/javascript" language="javascript"
-        src="org.sonar.plugins.core.testdetailsviewer.TestsViewer.nocache.js"></script>
-
-<a href="#" onclick="load_org_sonar_plugins_core_testdetailsviewer_TestsViewer();">load</a>
-</body>
-</html>
\ No newline at end of file
index b7a2f0f003d900e97678164278b92908b451939e..5a8303e9dba0e2e9ef7877e3123f53b3f9659d99 100644 (file)
@@ -87,6 +87,7 @@ import org.sonar.plugins.core.timemachine.VariationDecorator;
 import org.sonar.plugins.core.timemachine.ViolationPersisterDecorator;
 import org.sonar.plugins.core.timemachine.ViolationTrackingDecorator;
 import org.sonar.plugins.core.web.Lcom4Viewer;
+import org.sonar.plugins.core.web.TestsViewer;
 import org.sonar.plugins.core.widgets.AlertsWidget;
 import org.sonar.plugins.core.widgets.CommentsDuplicationsWidget;
 import org.sonar.plugins.core.widgets.ComplexityWidget;
@@ -402,8 +403,8 @@ public final class CorePlugin extends SonarPlugin {
       Java.class,
 
       // pages
-      TestsViewerDefinition.class,
       Lcom4Viewer.class,
+      TestsViewer.class,
 
       // filters
       ProjectFilter.class,
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/web/TestsViewer.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/web/TestsViewer.java
new file mode 100644 (file)
index 0000000..b3470ec
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+ */
+package org.sonar.plugins.core.web;
+
+import org.sonar.api.measures.CoreMetrics;
+import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.web.*;
+
+@ResourceQualifier(Qualifiers.UNIT_TEST_FILE)
+@NavigationSection(NavigationSection.RESOURCE_TAB)
+@DefaultTab(metrics = {CoreMetrics.TESTS_KEY, CoreMetrics.TEST_EXECUTION_TIME_KEY, CoreMetrics.TEST_SUCCESS_DENSITY_KEY, CoreMetrics.TEST_FAILURES_KEY, CoreMetrics.TEST_ERRORS_KEY, CoreMetrics.SKIPPED_TESTS_KEY})
+@UserRole(UserRole.CODEVIEWER)
+public class TestsViewer extends AbstractRubyTemplate implements RubyRailsPage {
+
+  public String getId() {
+      return "tests_viewer";
+  }
+
+  public String getTitle() {
+    return "Tests";
+  }
+
+  @Override
+  protected String getTemplatePath() {
+    return "/org/sonar/plugins/core/web/tests_viewer.html.erb";
+  }
+}
index e050a5305f7dae82a5844f560be0879959d6709a..e3e8e475c6b1db1b615a6b7e55482e15135aec2b 100644 (file)
@@ -1023,6 +1023,21 @@ dependencies.ca=Afferent (incoming) couplings
 dependencies.ce=Efferent (outgoing) couplings
 
 
+#------------------------------------------------------------------------------
+#
+# TESTS VIEWER
+#
+#------------------------------------------------------------------------------
+test_viewer.tests=Tests
+test_viewer.failures=Failures
+test_viewer.errors=Errors
+test_viewer.duration=Duration
+test_viewer.unit_test_name=Unit test name
+test_viewer.skipped=skipped
+test_viewer.expand=expand
+test_viewer.collapse=collapse
+
+
 #------------------------------------------------------------------------------
 #
 # MANUAL MEASURES
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/web/tests_viewer.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/web/tests_viewer.html.erb
new file mode 100644 (file)
index 0000000..f9a28a2
--- /dev/null
@@ -0,0 +1,106 @@
+<div class="tab_header tests_viewer" id="tests_header">
+  <table>
+    <tr>
+      <% test_success_density = measure('test_success_density') %>
+      <td id= "test_success_density" class="big"><%= test_success_density ? number_with_precision(test_success_density.value(), :precision => 1) : "100.0" -%>%</td>
+      <td class="sep"> </td>
+      <td class="name"><%= message('test_viewer.tests') -%>:</td>
+      <%
+         tests = measure('tests')
+         tests_display = tests ? format_measure(tests) : "-"
+         skipped_tests = measure('skipped_tests')
+         if !skipped_tests.nil?
+           tests_display = tests_display + " (+" + format_measure(skipped_tests) + " " + message('test_viewer.skipped') + ")"
+         end
+      %>
+      <td id="tests" class="value"><%= tests_display -%></td>
+      <td class="sep"> </td>
+      <td class="name"><%= message('test_viewer.failures') -%>/<%= message('test_viewer.errors') -%>:</td>
+      <%
+         test_failures = measure('test_failures') ? format_measure(measure('test_failures')) : "0"
+         test_errors = measure('test_errors') ? format_measure(measure('test_errors')) : "0"
+      %>
+      <td id="test_failures_errors" class="value"><%= test_failures -%>/<%= test_errors -%></td>
+      <td class="sep"> </td>
+      <td class="name"><%= message('test_viewer.duration') -%>:</td>
+      <% test_execution_time = measure('test_execution_time') %>
+      <td id="test_execution_time" class="value"><%= test_execution_time ? format_measure(test_execution_time) : "-" -%></td>
+    </tr>
+  </table>
+</div>
+
+<% test_data = measure('test_data') %>
+<% if test_data %>
+<table class="data width100 tests_viewer"  id="test_data">
+  <thead>
+    <tr>
+      <th class="thin">&nbsp;</th>
+      <th class="thin">&nbsp;</th>
+      <th class="thin"><%= message('test_viewer.duration') -%></th>
+      <th><%= message('test_viewer.unit_test_name') -%></th>
+    </tr>
+  </thead>
+  <tbody>
+
+  <%
+     index = 0
+     blocks = REXML::Document.new test_data.data
+     blocks.elements.each("tests-details/testcase") do |block|
+  %>
+    <% index = index+1 %>
+    <tr class="<%= cycle("even","odd") -%>" id="testdata_<%= index -%>" display="table-row">
+      <%
+         status = block.attributes['status']
+         case status
+           when 'failure'
+             icon_url = ApplicationController.root_context + "/images/warning.png"
+           when 'skipped'
+             icon_url = ApplicationController.root_context + "/images/levels/none.png"
+           else
+             icon_url = ApplicationController.root_context + "/images/levels/" + status + ".png"
+         end
+
+         error = block.elements['error']
+         block_message = !error.nil? ? error : nil
+         failure = block.elements['failure']
+         block_message = !failure.nil? ? failure : block_message
+      %>
+      <td class="thin" nowrap>
+        <% if !block_message.nil? %>
+          <a id="expandLink_<%= index -%>" href="#" onclick="expandTests(<%= index -%>);"><%= message('test_viewer.expand') -%></a>
+          <a id="collapseLink_<%= index -%>" class="collapse" href="#" onclick="collapseTests(<%= index -%>);" style="display: none;"><%= message('test_viewer.collapse') -%></a>
+        <% else %>
+          &nbsp;
+        <% end %>
+      </td>
+      <td class="thin" nowrap>
+        <img id="test_status_<%= index -%>_<%= status -%>" src="<%= icon_url -%>" />
+      </td>
+      <td id="test_time_<%= index -%>" class="thin" nowrap><%= block.attributes['time'] -%> ms</td>
+      <td>
+        <span><%= block.attributes['name'] -%></span>
+        <% if !block_message.nil? %>
+          <div id="message_<%= index -%>" class="message" style="display: none;">
+            <% message = block_message.attributes['message'] %>
+            <% if !message.nil? %>
+              <span><%= h message -%></span>
+            <% end %>
+            <pre style="border: 1px solid #ddd; padding: 5px; margin: 5px 0"><%= block_message.first.to_s-%></pre>
+          </div>
+        <% end %>
+      </td>
+    </tr>
+
+  <%
+     end
+  %>
+  </tbody>
+</table>
+
+<%
+   else
+%>
+  <p><%= message('no_data') -%></p>
+<%
+   end
+%>
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index be2d5e3375bd77fd24695743f10a60742b849987..ce90818969e28235ce9ddd6a97b0a4eabfe918a9 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -32,7 +32,6 @@
     <module>sonar-squid</module>
     <module>sonar-testing-harness</module>
     <module>sonar-ws-client</module>
-    <module>plugins/sonar-core-gwt</module>
     <module>plugins/sonar-core-plugin</module>
     <module>plugins/sonar-dbcleaner-plugin</module>
     <module>plugins/sonar-findbugs-plugin</module>
index bd2e74042577aca83f18e9389b5f28fede81e972..7b4327dfd47027f6e3fe6ae15cc51275d8ee4d44 100644 (file)
@@ -181,4 +181,19 @@ function hVF(line) {
     row.remove();
   }
   return false;
+}
+
+/*
+ Functions used in tests viewer
+ */
+function expandTests(index){
+  $j(".tests_viewer #collapseLink_"+ index).show();
+  $j(".tests_viewer #expandLink_"+ index).hide();
+  $j(".tests_viewer #message_"+ index).show();
+}
+
+function collapseTests(index){
+  $j(".tests_viewer #collapseLink_"+ index).hide();
+  $j(".tests_viewer #expandLink_"+ index).show();
+  $j(".tests_viewer #message_"+ index).hide();
 }
\ No newline at end of file