Author: doogie
Date: Wed Mar 4 18:02:07 2009 New Revision: 750089 URL: http://svn.apache.org/viewvc?rev=750089&view=rev Log: Container that prints out the test cases that are available. Added: ofbiz/trunk/framework/base/config/testlist-containers.xml ofbiz/trunk/framework/base/src/org/ofbiz/base/container/JustLoadComponentsContainer.java ofbiz/trunk/framework/start/src/org/ofbiz/base/start/testlist.properties ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/TestListContainer.java Added: ofbiz/trunk/framework/base/config/testlist-containers.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/config/testlist-containers.xml?rev=750089&view=auto ============================================================================== --- ofbiz/trunk/framework/base/config/testlist-containers.xml (added) +++ ofbiz/trunk/framework/base/config/testlist-containers.xml Wed Mar 4 18:02:07 2009 @@ -0,0 +1,32 @@ +<?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. +--> + +<ofbiz-containers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-containers.xsd"> + <!-- load the ofbiz component container (always first) --> + <!-- + <container name="component-container" class="org.ofbiz.base.container.ComponentContainer"/> + --> + <container name="component-container" class="org.ofbiz.base.container.JustLoadComponentsContainer"/> + + <!-- + --> + <container name="testtools-container" class="org.ofbiz.testtools.TestListContainer"/> +</ofbiz-containers> Added: ofbiz/trunk/framework/base/src/org/ofbiz/base/container/JustLoadComponentsContainer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/container/JustLoadComponentsContainer.java?rev=750089&view=auto ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/container/JustLoadComponentsContainer.java (added) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/container/JustLoadComponentsContainer.java Wed Mar 4 18:02:07 2009 @@ -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.ofbiz.base.container; + +import org.ofbiz.base.component.AlreadyLoadedException; +import org.ofbiz.base.component.ComponentException; +import org.ofbiz.base.util.Debug; + +/** + * A Container implementation to run the tests configured through this testtools stuff. + */ +public class JustLoadComponentsContainer implements Container { + + public static final String module = JustLoadComponentsContainer.class.getName(); + + /** + * @see org.ofbiz.base.container.Container#init(java.lang.String[], java.lang.String) + */ + public void init(String[] args, String configFile) { + try { + ComponentContainer.loadComponents(true); + } catch (AlreadyLoadedException e) { + Debug.logError(e, module); + } catch (ComponentException e) { + Debug.logError(e, module); + //throw (ContainerException) new ContainerException(e.getMessage()).initCause(e); + } + } + + public boolean start() throws ContainerException { + return true; + } + + public void stop() throws ContainerException { + } +} Added: ofbiz/trunk/framework/start/src/org/ofbiz/base/start/testlist.properties URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/start/src/org/ofbiz/base/start/testlist.properties?rev=750089&view=auto ============================================================================== --- ofbiz/trunk/framework/start/src/org/ofbiz/base/start/testlist.properties (added) +++ ofbiz/trunk/framework/start/src/org/ofbiz/base/start/testlist.properties Wed Mar 4 18:02:07 2009 @@ -0,0 +1,60 @@ +############################################################################### +# 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. +############################################################################### +#### +# OFBiz Startup Application Settings +#### + +# --- Java LIB tools.jar is not required +#java.tools.jar.required=false + +# --- External Base configuration files (relative to ofbiz.home) +#ofbiz.base.config=framework/base/config + +# --- External Base schema files (relative to ofbiz.home) +#ofbiz.base.schema=framework/base/dtd + +# --- External Base libraries (relative to ofbiz.home) +#ofbiz.base.lib=framework/base/lib + +# --- Base Jar [ofbiz-base.jar] (relative to ofbiz.home) +#ofbiz.base.jar=framework/base/build/lib/ofbiz-base.jar + +# --- Default logs directory (relative to ofbiz.home) +#ofbiz.log.dir=runtime/logs + +# --- Location (relative to ofbiz.home) for (normal) container configuration +ofbiz.container.config=framework/base/config/testlist-containers.xml + +# --- StartupLoader implementations to load (in order) +ofbiz.start.loader1=org.ofbiz.base.container.ContainerLoader + +# -- Enable the shutdown hook +#ofbiz.enable.hook=true + +# -- Auto-Shutdown after load +ofbiz.auto.shutdown=true + +# --- Default Derby system home directory +#derby.system.home=runtime/data/derby + +# --- By default we will find base/config/debug.properties and point to there +#log4j.configuration=log4j.xml + +# --- Tells AWT (i.e. JasperReports/FOP/etc) to not require a head (X11) +java.awt.headless=true Added: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/TestListContainer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/TestListContainer.java?rev=750089&view=auto ============================================================================== --- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/TestListContainer.java (added) +++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/TestListContainer.java Wed Mar 4 18:02:07 2009 @@ -0,0 +1,96 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + *******************************************************************************/ +package org.ofbiz.testtools; + +import org.ofbiz.base.component.AlreadyLoadedException; +import org.ofbiz.base.component.ComponentConfig; +import org.ofbiz.base.component.ComponentException; +import org.ofbiz.base.config.GenericConfigException; +import org.ofbiz.base.config.ResourceHandler; +import org.ofbiz.base.container.ComponentContainer; +import org.ofbiz.base.container.Container; +import org.ofbiz.base.container.ContainerException; +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilXml; + +import java.io.File; +import java.io.IOException; +import java.io.FileOutputStream; +import java.io.PrintStream; +import java.util.List; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +/** + * A Container implementation to run the tests configured through this testtools stuff. + */ +public class TestListContainer implements Container { + + public static final String module = TestListContainer.class.getName(); + + private String outputLocation; + + /** + * @see org.ofbiz.base.container.Container#init(java.lang.String[], java.lang.String) + */ + public void init(String[] args, String configFile) { + this.outputLocation = args[0]; + } + + public boolean start() throws ContainerException { + FileOutputStream fout; + try { + fout = new FileOutputStream(outputLocation + ".tmp"); + } catch (IOException e) { + Debug.logError(e, module); + throw (IllegalArgumentException) new IllegalArgumentException(e.getMessage()).initCause(e); + } + PrintStream pout = new PrintStream(fout); + for (ComponentConfig.TestSuiteInfo testSuiteInfo: ComponentConfig.getAllTestSuiteInfos(null)) { + String componentName = testSuiteInfo.componentConfig.getComponentName(); + ResourceHandler testSuiteResource = testSuiteInfo.createResourceHandler(); + + try { + Document testSuiteDocument = testSuiteResource.getDocument(); + Element documentElement = testSuiteDocument.getDocumentElement(); + for (Element testCaseElement : UtilXml.childElementList(documentElement, "test-case")) { + String caseName = testCaseElement.getAttribute("case-name"); + pout.println(componentName + ":" + caseName); + } + } 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); + } + } + try { + pout.close(); + fout.close(); + new File(outputLocation + ".tmp").renameTo(new File(outputLocation)); + } catch (IOException e) { + Debug.logError(e, module); + throw (IllegalArgumentException) new IllegalArgumentException(e.getMessage()).initCause(e); + } + + return true; + } + + public void stop() throws ContainerException { + } +} |
Free forum by Nabble | Edit this page |