You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jo...@apache.org on 2007/03/09 02:28:44 UTC
svn commit: r516253 - in /ofbiz/trunk/framework:
base/src/base/org/ofbiz/base/util/ entity/src/org/ofbiz/entity/test/
example/script/org/ofbiz/example/example/ example/servicedef/
example/testdef/ testtools/dtd/ testtools/servicedef/ testtools/src/org/...
Author: jonesde
Date: Thu Mar 8 17:28:43 2007
New Revision: 516253
URL: http://svn.apache.org/viewvc?view=rev&rev=516253
Log:
Added simple-method-test to call a simple-method as a service, without a service definition; also includes some various fixes including one from Joe in Jira OFBIZ-791
Added:
ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/SimpleMethodTest.java (with props)
Modified:
ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java
ofbiz/trunk/framework/example/script/org/ofbiz/example/example/ExampleServices.xml
ofbiz/trunk/framework/example/servicedef/services.xml
ofbiz/trunk/framework/example/testdef/tests.xml
ofbiz/trunk/framework/testtools/dtd/test-suite.xsd
ofbiz/trunk/framework/testtools/servicedef/services.xml
ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ModelTestSuite.java
ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ServiceTest.java
Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java?view=diff&rev=516253&r1=516252&r2=516253
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java Thu Mar 8 17:28:43 2007
@@ -288,7 +288,7 @@
* @return
*/
public static boolean isOrSubOf(Class objectClass, Class parentClass) {
-
+ //Debug.logInfo("Checking isOrSubOf for [" + objectClass.getName() + "] and [" + objectClass.getName() + "]", module);
while (objectClass != null) {
if (objectClass == parentClass) return true;
objectClass = objectClass.getSuperclass();
@@ -366,8 +366,9 @@
public static boolean instanceOf(Object obj, String typeName, ClassLoader loader) {
Class infoClass = loadInfoClass(typeName, loader);
- if (infoClass == null)
+ if (infoClass == null) {
throw new IllegalArgumentException("Illegal type found in info map (could not load class for specified type)");
+ }
return instanceOf(obj, infoClass);
}
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java?view=diff&rev=516253&r1=516252&r2=516253
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java Thu Mar 8 17:28:43 2007
@@ -53,8 +53,10 @@
/*
* This sets how many values to insert when trying to create a large number of values. 10,000 causes HSQL to crash but is ok
* with Derby. Going up to 100,000 causes problems all around because Java List seems to be capped at about 65,000 values.
+ *
+ * NOTE: setting this lower so that the general tests don't take so long to run; to really push it can increase this number.
*/
- public static final long TEST_COUNT = 10000;
+ public static final long TEST_COUNT = 1000;
public EntityTestSuite(String name) {
super(name);
Modified: ofbiz/trunk/framework/example/script/org/ofbiz/example/example/ExampleServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/script/org/ofbiz/example/example/ExampleServices.xml?view=diff&rev=516253&r1=516252&r2=516253
==============================================================================
--- ofbiz/trunk/framework/example/script/org/ofbiz/example/example/ExampleServices.xml (original)
+++ ofbiz/trunk/framework/example/script/org/ofbiz/example/example/ExampleServices.xml Thu Mar 8 17:28:43 2007
@@ -106,9 +106,7 @@
</call-service>
<check-errors/>
- <entity-one entity-name="Example" value-name="example" auto-field-map="false">
- <field-map field-name="exampleId" value="lookupMap.exampleId"/>
- </entity-one>
+ <find-by-primary-key entity-name="Example" map-name="lookupMap" value-name="example"/>
<assert>
<not><if-empty field-name="example"/></not>
@@ -116,11 +114,20 @@
<check-errors/>
<assert>
- <if-compare field-name="example.exampleTypeId" value="createExampleMap.exampleTypeId" operator="equals"/>
- <if-compare field-name="example.exampleName" value="createExampleMap.exampleName" operator="equals"/>
- <if-compare field-name="example.statusId" value="createExampleMap.statusId" operator="equals"/>
+ <if-compare-field field-name="example.exampleTypeId" to-field-name="createExampleMap.exampleTypeId" operator="equals"/>
</assert>
<check-errors/>
+
+ <assert>
+ <if-compare-field field-name="example.exampleName" to-field-name="createExampleMap.exampleName" operator="equals"/>
+ </assert>
+ <check-errors/>
+
+ <assert>
+ <if-compare-field field-name="example.statusId" to-field-name="createExampleMap.statusId" operator="equals"/>
+ </assert>
+ <check-errors/>
+
</simple-method>
</simple-methods>
Modified: ofbiz/trunk/framework/example/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/servicedef/services.xml?view=diff&rev=516253&r1=516252&r2=516253
==============================================================================
--- ofbiz/trunk/framework/example/servicedef/services.xml (original)
+++ ofbiz/trunk/framework/example/servicedef/services.xml Thu Mar 8 17:28:43 2007
@@ -137,5 +137,4 @@
location="org/ofbiz/example/example/ExampleServices.xml" invoke="testCreateExampleService">
<implements service="testServiceInterface"/>
</service>
-
</services>
Modified: ofbiz/trunk/framework/example/testdef/tests.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/testdef/tests.xml?view=diff&rev=516253&r1=516252&r2=516253
==============================================================================
--- ofbiz/trunk/framework/example/testdef/tests.xml (original)
+++ ofbiz/trunk/framework/example/testdef/tests.xml Thu Mar 8 17:28:43 2007
@@ -25,9 +25,10 @@
<test-case case-name="userLoginEntityXmlAssert">
<entity-xml-assert entity-xml-url="component://example/testdef/assertdata/TestUserLoginData.xml"/>
</test-case>
-
- <test-case case-name="testCreateExampleService">
+ <test-case case-name="testCreateExampleService Through Service Engine">
<service-test service-name="testCreateExampleService"/>
</test-case>
-
+ <test-case case-name="testCreateExampleService Direct Simple Method">
+ <simple-method-test location="org/ofbiz/example/example/ExampleServices.xml" name="testCreateExampleService"/>
+ </test-case>
</test-suite>
Modified: ofbiz/trunk/framework/testtools/dtd/test-suite.xsd
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/dtd/test-suite.xsd?view=diff&rev=516253&r1=516252&r2=516253
==============================================================================
--- ofbiz/trunk/framework/testtools/dtd/test-suite.xsd (original)
+++ ofbiz/trunk/framework/testtools/dtd/test-suite.xsd Thu Mar 8 17:28:43 2007
@@ -79,6 +79,16 @@
<xs:attribute type="xs:string" name="service-name" use="required"/>
</xs:attributeGroup>
+ <xs:element name="simple-method-test" substitutionGroup="TestCaseTypes">
+ <xs:complexType>
+ <xs:attributeGroup ref="attlist.simple-method-test"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.simple-method-test">
+ <xs:attribute type="xs:string" name="location" use="required"/>
+ <xs:attribute type="xs:string" name="name" use="required"/>
+ </xs:attributeGroup>
+
<xs:element name="entity-xml-assert" substitutionGroup="TestCaseTypes">
<xs:complexType>
<xs:attributeGroup ref="attlist.entity-xml-assert"/>
Modified: ofbiz/trunk/framework/testtools/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/servicedef/services.xml?view=diff&rev=516253&r1=516252&r2=516253
==============================================================================
--- ofbiz/trunk/framework/testtools/servicedef/services.xml (original)
+++ ofbiz/trunk/framework/testtools/servicedef/services.xml Thu Mar 8 17:28:43 2007
@@ -31,6 +31,7 @@
- errorMessage, errorMessageList, errorMessageMap: where messages will comes from for error or fail responses
- successMessage, successMessagesList: where messages will comes from for success responses
</description>
- <attribute name="testCase" type="junit.framework.TestCase" mode="IN" optional="false"/>
+ <attribute name="test" type="junit.framework.Test" mode="IN" optional="false"/>
+ <attribute name="testResult" type="junit.framework.TestResult" mode="IN" optional="false"/>
</service>
</services>
Modified: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ModelTestSuite.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ModelTestSuite.java?view=diff&rev=516253&r1=516252&r2=516253
==============================================================================
--- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ModelTestSuite.java (original)
+++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ModelTestSuite.java Thu Mar 8 17:28:43 2007
@@ -92,6 +92,8 @@
}
} else if ("service-test".equals(nodeName)) {
this.testList.add(new ServiceTest(caseName, this, childElement));
+ } else if ("simple-method-test".equals(nodeName)) {
+ this.testList.add(new SimpleMethodTest(caseName, this, childElement));
} else if ("entity-xml-assert".equals(nodeName)) {
this.testList.add(new EntityXmlAssertTest(caseName, this, childElement));
} else if ("jython-test".equals(nodeName)) {
Modified: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ServiceTest.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ServiceTest.java?view=diff&rev=516253&r1=516252&r2=516253
==============================================================================
--- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ServiceTest.java (original)
+++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ServiceTest.java Thu Mar 8 17:28:43 2007
@@ -58,7 +58,7 @@
try {
- Map serviceResult = dispatcher.runSync(serviceName, UtilMisc.toMap("testCase", this));
+ Map serviceResult = dispatcher.runSync(serviceName, UtilMisc.toMap("test", this, "testResult", result));
// do something with the errorMessage
String errorMessage = (String) serviceResult.get(ModelService.ERROR_MESSAGE);
Added: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/SimpleMethodTest.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/SimpleMethodTest.java?view=auto&rev=516253
==============================================================================
--- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/SimpleMethodTest.java (added)
+++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/SimpleMethodTest.java Thu Mar 8 17:28:43 2007
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * 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 java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestResult;
+
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.minilang.MiniLangException;
+import org.ofbiz.minilang.SimpleMethod;
+import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.service.ModelService;
+import org.w3c.dom.Element;
+
+public class SimpleMethodTest extends TestCaseBase {
+
+ public static final String module = ServiceTest.class.getName();
+
+ protected String methodLocation;
+ protected String methodName;
+
+ /**
+ * @param modelTestSuite
+ */
+ public SimpleMethodTest(String caseName, ModelTestSuite modelTestSuite, Element mainElement) {
+ super(caseName, modelTestSuite);
+ this.methodLocation = mainElement.getAttribute("location");
+ this.methodName = mainElement.getAttribute("name");
+ }
+
+ public int countTestCases() {
+ return 1;
+ }
+
+ public void run(TestResult result) {
+ result.startTest(this);
+
+ LocalDispatcher dispatcher = modelTestSuite.getDispatcher();
+
+ try {
+
+ Map serviceResult = SimpleMethod.runSimpleService(methodLocation, methodName, dispatcher.getDispatchContext(),
+ UtilMisc.toMap("test", this, "testResult", result));
+
+ // do something with the errorMessage
+ String errorMessage = (String) serviceResult.get(ModelService.ERROR_MESSAGE);
+ if (UtilValidate.isNotEmpty(errorMessage)) {
+ result.addFailure(this, new AssertionFailedError(errorMessage));
+ }
+
+ // do something with the errorMessageList
+ List errorMessageList = (List) serviceResult.get(ModelService.ERROR_MESSAGE_LIST);
+ if (UtilValidate.isNotEmpty(errorMessageList)) {
+ Iterator i = errorMessageList.iterator();
+ while (i.hasNext()) {
+ result.addFailure(this, new AssertionFailedError((String) i.next()));
+ }
+ }
+
+ // do something with the errorMessageMap
+ Map errorMessageMap = (Map) serviceResult.get(ModelService.ERROR_MESSAGE_MAP);
+ if (!UtilValidate.isEmpty(errorMessageMap)) {
+ Iterator i = errorMessageMap.entrySet().iterator();
+ while (i.hasNext()) {
+ Map.Entry entry = (Map.Entry) i.next();
+ result.addFailure(this, new AssertionFailedError(entry.getKey() + ": " + entry.getValue()));
+ }
+ }
+
+ } catch (MiniLangException e) {
+ result.addError(this, e);
+ }
+
+ result.endTest(this);
+ }
+}
Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/SimpleMethodTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/SimpleMethodTest.java
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author URL Id"
Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/SimpleMethodTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain