Author: hansbak Date: Fri Aug 2 02:56:59 2013 New Revision: 1509516 URL: http://svn.apache.org/r1509516 Log: work in progress: made the componentlist paged, ordered and more readable, clicking on the component name provides a junit test list from which a test can be run. even in production because all database changes are rolled back
Added: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/RunTestEvents.java (with props) ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/ComponentList.groovy (with props) ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/TestSuiteInfo.groovy (with props) ofbiz/trunk/framework/webtools/widget/ArtifactInfoForms.xml (with props) Removed: ofbiz/trunk/framework/webtools/webapp/webtools/component/viewComponents.ftl Modified: ofbiz/trunk/framework/webtools/build.xml ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml ofbiz/trunk/framework/webtools/widget/ArtifactInfoScreens.xml ofbiz/trunk/framework/webtools/widget/MiscScreens.xml Modified: ofbiz/trunk/framework/webtools/build.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/build.xml?rev=1509516&r1=1509515&r2=1509516&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/build.xml (original) +++ ofbiz/trunk/framework/webtools/build.xml Fri Aug 2 02:56:59 2013 @@ -45,5 +45,6 @@ under the License. <fileset dir="../webapp/lib" includes="*.jar"/> <fileset dir="../webapp/build/lib" includes="*.jar"/> <fileset dir="../widget/build/lib" includes="*.jar"/> + <fileset dir="../testtools/build/lib" includes="*.jar"/> </path> </project> Added: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/RunTestEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/RunTestEvents.java?rev=1509516&view=auto ============================================================================== --- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/RunTestEvents.java (added) +++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/RunTestEvents.java Fri Aug 2 02:56:59 2013 @@ -0,0 +1,59 @@ +/******************************************************************************* + * 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.ofbiz.webtools.artifactinfo; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.ofbiz.base.container.ContainerException; + +import org.ofbiz.testtools.*; + +/** + * Event used to run a Junit test + */ +public class RunTestEvents { + + public static final String module = RunTestEvents.class.getName(); + + public static String runTest(HttpServletRequest request, HttpServletResponse response) throws ContainerException { + + String componentName = request.getParameter("compName"); + String suiteName = request.getParameter("suiteName"); + String caseName = request.getParameter("caseName"); + String result = null; + + String[] args = null; + if (caseName == null) { + args = new String[]{"-componentname=" + componentName, "-suitename=" + suiteName + "-loglevel=info"}; + } else { + args = new String[]{"-componentname=" + componentName, "-suitename=" + suiteName, "-case=" + caseName, "-loglevel=info"}; + } + + TestRunContainer testRunContainer = new TestRunContainer(); + testRunContainer.init(args, "frontend test run", " "); + if (testRunContainer.start() == false) { + result = "error"; + } else { + result = "success"; + } + + return result; + } +} + Propchange: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/RunTestEvents.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/RunTestEvents.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/RunTestEvents.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/ComponentList.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/ComponentList.groovy?rev=1509516&view=auto ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/ComponentList.groovy (added) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/ComponentList.groovy Fri Aug 2 02:56:59 2013 @@ -0,0 +1,65 @@ +/* + * 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. + */ + +import java.util.Collection; +import java.util.List; + +import org.ofbiz.base.component.ComponentConfig; +import org.ofbiz.base.component.ComponentConfig.WebappInfo; + +import javolution.util.FastMap; +import javolution.util.FastList; +import org.ofbiz.base.util.* + +Collection <ComponentConfig> components = ComponentConfig.getAllComponents(); + +List componentList = FastList.newInstance(); + +components.each { component -> + List<WebappInfo> webApps = component.getWebappInfos(); + webApps.each { webApp -> + componentMap = FastMap.newInstance(); + componentMap.compName = component.getComponentName(); + componentMap.rootLocation = component.getRootLocation(); + componentMap.enabled = (component.enabled() == true? "Y" : "N"); + componentMap.webAppName = webApp.getName(); + componentMap.contextRoot = webApp.getContextRoot(); + componentMap.location = webApp.getLocation(); + componentMap.webAppName = webApp.getName(); + componentMap.contextRoot = webApp.getContextRoot(); + componentMap.location = webApp.getLocation(); + componentList.add(componentMap); + } +} + +// sort the entries +componentList = UtilMisc.sortMaps(componentList, UtilMisc.toList("+compName")); + +// make the list more readable +lastComp = null; +for (int entry = 0; entry < componentList.size(); entry++) { + compSave = componentList[entry].compName; + if (lastComp != null && compSave.equals(lastComp)) { + componentList[entry].compName = ""; + componentList[entry].rootLocation = ""; + componentList[entry].enabled = ""; + } + lastComp = compSave; +} +context.componentList = componentList; Propchange: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/ComponentList.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/ComponentList.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/ComponentList.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/TestSuiteInfo.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/TestSuiteInfo.groovy?rev=1509516&view=auto ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/TestSuiteInfo.groovy (added) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/TestSuiteInfo.groovy Fri Aug 2 02:56:59 2013 @@ -0,0 +1,65 @@ +/* + * 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. + */ + +import org.ofbiz.base.util.*; +import org.ofbiz.base.component.ComponentConfig; +import org.ofbiz.base.config.GenericConfigException; +import org.ofbiz.base.config.ResourceHandler; +import org.ofbiz.testtools.TestListContainer.FoundTest; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import java.util.Collection; +import java.util.List; + +import javolution.util.FastMap; +import javolution.util.FastList; + +List testList = FastList.newInstance(); +for (ComponentConfig.TestSuiteInfo testSuiteInfo: ComponentConfig.getAllTestSuiteInfos(parameters.compName)) { + String componentName = testSuiteInfo.componentConfig.getComponentName(); + ResourceHandler testSuiteResource = testSuiteInfo.createResourceHandler(); + + try { + Document testSuiteDocument = testSuiteResource.getDocument(); + Element documentElement = testSuiteDocument.getDocumentElement(); + suiteName = documentElement.getAttribute("suite-name") + firstLine = true; + for (Element testCaseElement : UtilXml.childElementList(documentElement, UtilMisc.toSet("test-case", "test-group"))) { + testMap = FastMap.newInstance(); + String caseName = testCaseElement.getAttribute("case-name"); + if (firstLine == true) { + testMap = UtilMisc.toMap("suiteName", suiteName, "caseName", caseName); + firstLine = false; + } else { + testMap = UtilMisc.toMap("caseName", caseName); + } + testList.add(testMap); + } + } catch (GenericConfigException e) { + String errMsg = "Error reading XML document from ResourceHandler for loader [" + testSuiteResource.getLoaderName() + "] and location [" + testSuiteResource.getLocation() + "]"; + Debug.logError(e, errMsg, module); + throw new IllegalArgumentException(errMsg); + } + + + +} + +context.suits = testList; Propchange: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/TestSuiteInfo.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/TestSuiteInfo.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/artifactinfo/TestSuiteInfo.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml?rev=1509516&r1=1509515&r2=1509516&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml Fri Aug 2 02:56:59 2013 @@ -363,6 +363,16 @@ under the License. <response name="success" type="view" value="ViewComponents"/> </request-map> + <request-map uri="TestSuiteInfo"> + <security https="true" auth="true"/> + <response name="success" type="view" value="TestSuiteInfo"/> + </request-map> + + <request-map uri="RunTest"> + <security https="true" auth="true"/> + <event type="java" path="org.ofbiz.webtools.artifactinfo.RunTestEvents" invoke="runTest"/> + <response name="success" type="request-redirect" value="TestSuiteInfo"/> + </request-map> <!-- EntitySQL requests --> <request-map uri="EntitySQLProcessor"> <security https="true" auth="true"/> @@ -680,12 +690,12 @@ under the License. <view-map name="EntityImport" page="component://webtools/widget/EntityScreens.xml#EntityImport" type="screen"/> <view-map name="EntityImportReaders" page="component://webtools/widget/EntityScreens.xml#EntityImportReaders" type="screen"/> - <view-map name="ViewComponents" page="component://webtools/widget/MiscScreens.xml#ViewComponents" type="screen"/> - <!-- cert views --> <view-map name="viewbrowsercerts" type="screen" page="component://webtools/widget/CommonScreens.xml#browsercerts"/> <!-- Artifact Info Views --> + <view-map name="ViewComponents" page="component://webtools/widget/ArtifactInfoScreens.xml#ViewComponents" type="screen"/> + <view-map name="TestSuiteInfo" page="component://webtools/widget/ArtifactInfoScreens.xml#TestSuiteInfo" type="screen"/> <view-map name="ArtifactInfo" type="screen" page="component://webtools/widget/ArtifactInfoScreens.xml#ArtifactInfo"/> <!-- Label Manager Views --> Added: ofbiz/trunk/framework/webtools/widget/ArtifactInfoForms.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/widget/ArtifactInfoForms.xml?rev=1509516&view=auto ============================================================================== --- ofbiz/trunk/framework/webtools/widget/ArtifactInfoForms.xml (added) +++ ofbiz/trunk/framework/webtools/widget/ArtifactInfoForms.xml Fri Aug 2 02:56:59 2013 @@ -0,0 +1,47 @@ +<?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. +--> + +<forms xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-form.xsd"> + <form name="ComponentList" type="list" separate-columns="true" title="Component List" list-name="componentList" target="" + odd-row-style="alternate-row" header-row-style="header-row-2" default-table-style="basic-table hover-bar"> + <field name="compName"> + <hyperlink target="TestSuiteInfo?compName=${compName}" description="${compName}" ></hyperlink> + </field> + <field name="rootLocation"><display/></field> + <field name="enabled"><display/></field> + <field name="webAppName"><display/></field> + <field name="contextRoot"><display/></field> + <field name="location"><display/></field> + </form> + + <form name="TestSuiteInfo" type="list" separate-columns="true" title="Component List" list-name="suits" target="" + odd-row-style="alternate-row" header-row-style="header-row-2" default-table-style="basic-table hover-bar"> + <field name="compName"><hidden value="${parameters.compName}"/></field> + <field name="suiteName"><display/></field> + <!-- field name="runSuite" use-when="suiteName!=void"> + <hyperlink target="RunTest?compName=${parameters.compName}&suiteName=${suiteName}" description="run suite"/> + </field--> + <field name="caseName"><display/></field> + <field name="runCase"> + <hyperlink target="RunTest?compName=${parameters.compName}&suiteName=${suiteName}&caseName=${caseName}" description="run case"/> + </field> + </form> +</forms> Propchange: ofbiz/trunk/framework/webtools/widget/ArtifactInfoForms.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/webtools/widget/ArtifactInfoForms.xml ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/framework/webtools/widget/ArtifactInfoForms.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Modified: ofbiz/trunk/framework/webtools/widget/ArtifactInfoScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/widget/ArtifactInfoScreens.xml?rev=1509516&r1=1509515&r2=1509516&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/widget/ArtifactInfoScreens.xml (original) +++ ofbiz/trunk/framework/webtools/widget/ArtifactInfoScreens.xml Fri Aug 2 02:56:59 2013 @@ -42,4 +42,42 @@ under the License. </fail-widgets> </section> </screen> + <screen name="ViewComponents"> + <section> + <actions> + <set field="headerItem" value="main"/> + <set field="titleProperty" value="WebtoolsViewComponents"/> + <set field="tabButtonItem" value="viewents"/> + <script location="component://webtools/webapp/webtools/WEB-INF/actions/artifactinfo/ComponentList.groovy"/> + </actions> + <widgets> + <decorator-screen name="CommonArtifactDecorator" location="${parameters.mainDecoratorLocation}"> + <decorator-section name="body"> + <screenlet> + <include-form name="ComponentList" location="component://webtools/widget/ArtifactInfoForms.xml"/> + </screenlet> + </decorator-section> + </decorator-screen> + </widgets> + </section> + </screen> + <screen name="TestSuiteInfo"> + <section> + <actions> + <set field="headerItem" value="main"/> + <set field="titleProperty" value="WebtoolsViewComponents"/> + <set field="tabButtonItem" value="viewents"/> + <script location="component://webtools/webapp/webtools/WEB-INF/actions/artifactinfo/TestSuiteInfo.groovy"/> + </actions> + <widgets> + <decorator-screen name="CommonArtifactDecorator" location="${parameters.mainDecoratorLocation}"> + <decorator-section name="body"> + <screenlet title="Component: ${parameters.compName}"> + <include-form name="TestSuiteInfo" location="component://webtools/widget/ArtifactInfoForms.xml"/> + </screenlet> + </decorator-section> + </decorator-screen> + </widgets> + </section> + </screen> </screens> Modified: ofbiz/trunk/framework/webtools/widget/MiscScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/widget/MiscScreens.xml?rev=1509516&r1=1509515&r2=1509516&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/widget/MiscScreens.xml (original) +++ ofbiz/trunk/framework/webtools/widget/MiscScreens.xml Fri Aug 2 02:56:59 2013 @@ -20,22 +20,6 @@ under the License. <screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-screen.xsd"> - <screen name="ViewComponents"> - <section> - <actions> - <set field="headerItem" value="main"/> - <set field="titleProperty" value="WebtoolsViewComponents"/> - <set field="tabButtonItem" value="viewents"/> - </actions> - <widgets> - <decorator-screen name="CommonArtifactDecorator" location="${parameters.mainDecoratorLocation}"> - <decorator-section name="body"> - <platform-specific><html><html-template location="component://webtools/webapp/webtools/component/viewComponents.ftl"/></html></platform-specific> - </decorator-section> - </decorator-screen> - </widgets> - </section> - </screen> <screen name="viewdatafile"> <section>