Author: hansbak
Date: Tue Aug 30 04:25:28 2011 New Revision: 1163084 URL: http://svn.apache.org/viewvc?rev=1163084&view=rev Log: junit tests to test the change in r1163083 to have invoicing per order/or shipment. Also added spring jar files to be able to test ofbiz events. Added: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/InvoicePerShipmentTests.xml (with props) ofbiz/trunk/framework/testtools/lib/org.springframework.core-3.1.0.M2.jar (with props) ofbiz/trunk/framework/testtools/lib/org.springframework.test-3.1.0.M2.jar (with props) ofbiz/trunk/framework/testtools/lib/org.springframework.web-3.1.0.M2.jar (with props) Modified: ofbiz/trunk/.classpath ofbiz/trunk/applications/accounting/testdef/invoicetests.xml ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/SimpleMethodTest.java ofbiz/trunk/specialpurpose/ecommerce/data/DemoOrderTestData.xml Modified: ofbiz/trunk/.classpath URL: http://svn.apache.org/viewvc/ofbiz/trunk/.classpath?rev=1163084&r1=1163083&r2=1163084&view=diff ============================================================================== --- ofbiz/trunk/.classpath (original) +++ ofbiz/trunk/.classpath Tue Aug 30 04:25:28 2011 @@ -158,6 +158,9 @@ <classpathentry kind="lib" path="framework/service/lib/neethi-2.0.4.jar"/> <classpathentry kind="lib" path="framework/service/lib/XmlSchema-1.4.3.jar"/> <classpathentry kind="lib" path="framework/testtools/lib/selenium-java-client-driver.jar"/> + <classpathentry kind="lib" path="framework/testtools/lib/org.springframework.test-3.1.0.M2.jar"/> + <classpathentry kind="lib" path="framework/testtools/lib/org.springframework.web-3.1.0.M2.jar"/> + <classpathentry kind="lib" path="framework/testtools/lib/org.springframework.core-3.1.0.M2.jar"/> <classpathentry kind="lib" path="framework/webapp/lib/DataVision-1.0.0.jar"/> <classpathentry kind="lib" path="framework/webapp/lib/ezmorph-0.9.1.jar"/> <classpathentry kind="lib" path="framework/webapp/lib/iText-2.1.7.jar"/> Added: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/InvoicePerShipmentTests.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/InvoicePerShipmentTests.xml?rev=1163084&view=auto ============================================================================== --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/InvoicePerShipmentTests.xml (added) +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/InvoicePerShipmentTests.xml Tue Aug 30 04:25:28 2011 @@ -0,0 +1,529 @@ +<?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. +--> + +<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd"> + + <simple-method method-name="testInvoicePerShipmentSetFalse" short-description="Test Invoice Per Shipment Set False" login-required="false"> + <!-- Test Invoice Per Shipment + Step 1) Set create.invoice.per.shipment=N in AccountingConfig.properties file. + Step 2) Create order and approve order. + Step 3) Pack Shipment For Ship Group. + Step 4) Check invoice should not created. + --> + <!-- Step 1 --> + <call-bsh><![CDATA[ + import org.ofbiz.base.util.UtilProperties; + UtilProperties.setPropertyValue("AccountingConfig.properties", "create.invoice.per.shipment", "N"); + ]]></call-bsh> + <log level="info" message="===== >>> Set Accounting.properties / create.invoice.per.shipment = N"/> + <!-- Step 2 --> + <field-to-session field="nullField" session-name="orderMode"/> + <set field="request" from-field="parameters.request"/> + <set field="response" from-field="parameters.response"/> + <call-class-method method-name="routeOrderEntry" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : routeOrderEntry, Response : ${result}"/> + <entity-one value-field="userLogin" entity-name="UserLogin"> + <field-map field-name="userLoginId" value="admin"/> + </entity-one> + <call-bsh><![CDATA[ + request.setParameter("orderMode", "SALES_ORDER"); + request.setParameter("productStoreId", "9000"); + request.setParameter("partyId", "DemoCustomer"); + request.setParameter("currencyUom", "USD"); + session = request.getSession(); + session.setAttribute("userLogin", userLogin); + ]]></call-bsh> + <call-class-method method-name="initializeOrderEntry" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : initializeOrderEntry, Response : ${result}"/> + <call-class-method method-name="setOrderCurrencyAgreementShipDates" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : setOrderCurrencyAgreementShipDates, Response : ${result}"/> + <call-bsh><![CDATA[ + request.setParameter("add_product_id", "GZ-1000"); + ]]></call-bsh> + <call-class-method method-name="addToCart" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : addToCart, Response : ${result}"/> + <call-bsh><![CDATA[ + request.setParameter("checkoutpage", "quick"); + request.setParameter("shipping_contact_mech_id", "9015"); + request.setParameter("shipping_method", "GROUND@UPS"); + request.setParameter("checkOutPaymentId", "EXT_COD"); + request.setParameter("is_gift", "false"); + request.setParameter("may_split", "false"); + ]]></call-bsh> + <field-to-request field="nullField" request-name="shoppingCart"/> + <call-class-method method-name="setQuickCheckOutOptions" class-name="org.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : setQuickCheckOutOptions, Response : ${result}"/> + <call-class-method method-name="createOrder" class-name="org.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : createOrder, Response : ${result}"/> + <call-class-method method-name="processPayment" class-name="org.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : processPayment, Response : ${result}"/> + <call-service-asynch service-name="sendOrderConfirmation"/> + <call-class-method method-name="destroyCart" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : destroyCart, Response = ${result}"/> + <!-- Step 3 --> + <entity-condition list="orderHeaders" entity-name="OrderHeader"> + <condition-expr field-name="orderTypeId" value="SALES_ORDER"/> + <order-by field-name="-entryDate"/> + </entity-condition> + <first-from-list entry="orderHeader" list="orderHeaders"/> + <log level="info" message="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx : ${orderHeader}"/> + <call-bsh><![CDATA[ + import org.ofbiz.shipment.packing.PackingSession; + packingSession = new PackingSession(dispatcher, userLogin); + packingSession.setPrimaryOrderId(orderHeader.get("orderId")); + packingSession.setPrimaryShipGroupSeqId("00001"); + parameters.put("packingSession", packingSession); + ]]></call-bsh> + <set field="packInput.orderId" from-field="orderHeader.orderId"/> + <set field="packInput.shipGroupSeqId" value="00001"/> + <set field="packInput.packingSession" from-field="parameters.packingSession"/> + <set field="packInput.nextPackageSeq" value="1" type="Integer"/> + <set field="packInput.userLogin" from-field="userLogin"/> + <!-- Items --> + <set field="packInput.selInfo._1" value="Y"/> + <set field="packInput.pkgInfo._1" value="1"/> + <set field="packInput.qtyInfo._1" value="1"/> + <set field="packInput.prdInfo._1" value="GZ-1000"/> + <set field="packInput.iteInfo._1" value="00001"/> + <set field="packInput.wgtInfo._1" value="0"/> + <set field="packInput.boxTypeInfo._1" value="FX10KGBOX"/> + <set field="packInput.numPackagesInfo._1" value="1"/> + <call-service service-name="packBulkItems" in-map-name="packInput"> + <result-to-field result-name="responseMessage"/> + </call-service> + <log level="info" message="===== >>> Service: packBulkItems, Response = ${responseMessage}"/> + <set-service-fields service-name="completePack" to-map="completePackInput" map="packInput"/> + <call-service service-name="completePack" in-map-name="completePackInput"> + <result-to-field result-name="shipmentId"/> + </call-service> + <log level="info" message="===== >>> Service: completePack, shipmentId = ${shipmentId}"/> + <!-- Step 4 --> + <entity-and list="invoices" entity-name="OrderItemBillingAndInvoiceAndItem"> + <field-map field-name="orderId" from-field="orderHeader.orderId"/> + </entity-and> + <assert> + <if-empty field="invoices"/> + </assert> + <check-errors/> + </simple-method> + <simple-method method-name="testInvoicePerShipmentSetTrue" short-description="Test Invoice Per Shipment Set True" login-required="false"> + <!-- Test Invoice Per Shipment + Step 1) Set create.invoice.per.shipment=N in AccountingConfig.properties file. + Step 2) Create order and approve order. + Step 3) Pack Shipment For Ship Group. + Step 4) Check invoice should created. + --> + <!-- Step 1 --> + <call-bsh><![CDATA[ + import org.ofbiz.base.util.UtilProperties; + UtilProperties.setPropertyValue("AccountingConfig.properties", "create.invoice.per.shipment", "Y"); + ]]></call-bsh> + <log level="info" message="===== >>> Set Accounting.properties / create.invoice.per.shipment = Y"/> + <!-- Step 2 --> + <field-to-session field="nullField" session-name="orderMode"/> + <set field="request" from-field="parameters.request"/> + <set field="response" from-field="parameters.response"/> + <call-class-method method-name="routeOrderEntry" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : routeOrderEntry, Response = ${result}"/> + <entity-one value-field="userLogin" entity-name="UserLogin"> + <field-map field-name="userLoginId" value="admin"/> + </entity-one> + <call-bsh><![CDATA[ + request.setParameter("orderMode", "SALES_ORDER"); + request.setParameter("productStoreId", "9000"); + request.setParameter("partyId", "DemoCustomer"); + request.setParameter("currencyUom", "USD"); + session = request.getSession(); + session.setAttribute("userLogin", userLogin); + ]]></call-bsh> + <call-class-method method-name="initializeOrderEntry" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : initializeOrderEntry, Response = ${result}"/> + <call-class-method method-name="setOrderCurrencyAgreementShipDates" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : setOrderCurrencyAgreementShipDates, Response = ${result}"/> + <call-bsh><![CDATA[ + request.setParameter("add_product_id", "GZ-1000"); + ]]></call-bsh> + <call-class-method method-name="addToCart" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : addToCart, Response = ${result}"/> + <call-bsh><![CDATA[ + request.setParameter("checkoutpage", "quick"); + request.setParameter("shipping_contact_mech_id", "9015"); + request.setParameter("shipping_method", "GROUND@UPS"); + request.setParameter("checkOutPaymentId", "EXT_COD"); + request.setParameter("is_gift", "false"); + request.setParameter("may_split", "false"); + ]]></call-bsh> + <field-to-request field="nullField" request-name="shoppingCart"/> + <call-class-method method-name="setQuickCheckOutOptions" class-name="org.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : setQuickCheckOutOptions, Response = ${result}"/> + <call-class-method method-name="createOrder" class-name="org.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : createOrder, Response = ${result}"/> + <call-class-method method-name="processPayment" class-name="org.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : processPayment, Response = ${result}"/> + <call-service-asynch service-name="sendOrderConfirmation"/> + <call-class-method method-name="destroyCart" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : destroyCart, Response = ${result}"/> + <!-- Step 3 --> + <entity-condition list="orderHeaders" entity-name="OrderHeader"> + <condition-expr field-name="orderTypeId" value="SALES_ORDER"/> + <order-by field-name="-entryDate"/> + </entity-condition> + <first-from-list entry="orderHeader" list="orderHeaders"/> + <call-bsh><![CDATA[ + import org.ofbiz.shipment.packing.PackingSession; + packingSession = new PackingSession(dispatcher, userLogin); + packingSession.setPrimaryOrderId(orderHeader.get("orderId")); + packingSession.setPrimaryShipGroupSeqId("00001"); + parameters.put("packingSession", packingSession); + ]]></call-bsh> + <set field="packInput.orderId" from-field="orderHeader.orderId"/> + <set field="packInput.shipGroupSeqId" value="00001"/> + <set field="packInput.packingSession" from-field="parameters.packingSession"/> + <set field="packInput.nextPackageSeq" value="1" type="Integer"/> + <set field="packInput.userLogin" from-field="userLogin"/> + <!-- Items --> + <set field="packInput.selInfo._1" value="Y"/> + <set field="packInput.pkgInfo._1" value="1"/> + <set field="packInput.qtyInfo._1" value="1"/> + <set field="packInput.prdInfo._1" value="GZ-1000"/> + <set field="packInput.iteInfo._1" value="00001"/> + <set field="packInput.wgtInfo._1" value="0"/> + <set field="packInput.boxTypeInfo._1" value="FX10KGBOX"/> + <set field="packInput.numPackagesInfo._1" value="1"/> + <call-service service-name="packBulkItems" in-map-name="packInput"> + <result-to-field result-name="responseMessage"/> + </call-service> + <log level="info" message="===== >>> Service: packBulkItems, Response = ${responseMessage}"/> + <set-service-fields service-name="completePack" to-map="completePackInput" map="packInput"/> + <call-service service-name="completePack" in-map-name="completePackInput"> + <result-to-field result-name="shipmentId"/> + </call-service> + <log level="info" message="===== >>> Service: completePack, shipmentId = ${shipmentId}"/> + <!-- Step 4 --> + <entity-and list="invoices" entity-name="OrderItemBillingAndInvoiceAndItem"> + <field-map field-name="orderId" from-field="orderHeader.orderId"/> + </entity-and> + <assert> + <not><if-empty field="invoices"/></not> + </assert> + <check-errors/> + </simple-method> + <simple-method method-name="testInvoicePerShipmentSetOrderFalse" short-description="Test Invoice Per Shipment Set Order False" login-required="false"> + <!-- Test Invoice Per Shipment + Step 1) Create order and set invoicePerShipment=N. + Step 2) Pack Shipment For Ship Group. + Step 3) Check invoice should not created. + --> + <!-- Step 1 --> + <field-to-session field="nullField" session-name="orderMode"/> + <set field="request" from-field="parameters.request"/> + <set field="response" from-field="parameters.response"/> + <call-class-method method-name="routeOrderEntry" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : routeOrderEntry, Response = ${result}"/> + <entity-one value-field="userLogin" entity-name="UserLogin"> + <field-map field-name="userLoginId" value="admin"/> + </entity-one> + <call-bsh><![CDATA[ + request.setParameter("orderMode", "SALES_ORDER"); + request.setParameter("productStoreId", "9000"); + request.setParameter("partyId", "DemoCustomer"); + request.setParameter("currencyUom", "USD"); + session = request.getSession(); + session.setAttribute("userLogin", userLogin); + ]]></call-bsh> + <call-class-method method-name="initializeOrderEntry" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : initializeOrderEntry, Response = ${result}"/> + <call-class-method method-name="setOrderCurrencyAgreementShipDates" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : setOrderCurrencyAgreementShipDates, Response = ${result}"/> + <call-bsh><![CDATA[ + request.setParameter("add_product_id", "GZ-2644"); + ]]></call-bsh> + <call-class-method method-name="addToCart" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : addToCart, Response = ${result}"/> + <call-bsh><![CDATA[ + request.setParameter("checkoutpage", "quick"); + request.setParameter("shipping_contact_mech_id", "9015"); + request.setParameter("shipping_method", "GROUND@UPS"); + request.setParameter("checkOutPaymentId", "EXT_COD"); + request.setParameter("is_gift", "false"); + request.setParameter("may_split", "false"); + ]]></call-bsh> + <field-to-request field="nullField" request-name="shoppingCart"/> + <call-class-method method-name="setQuickCheckOutOptions" class-name="org.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : setQuickCheckOutOptions, Response = ${result}"/> + <call-class-method method-name="createOrder" class-name="org.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : createOrder, Response = ${result}"/> + <call-class-method method-name="processPayment" class-name="org.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : processPayment, Response = ${result}"/> + <call-service-asynch service-name="sendOrderConfirmation"/> + <call-class-method method-name="destroyCart" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : destroyCart, Response = ${result}"/> + <entity-condition list="orderHeaders" entity-name="OrderHeader"> + <condition-expr field-name="orderTypeId" value="SALES_ORDER"/> + <order-by field-name="-entryDate"/> + </entity-condition> + <first-from-list entry="orderHeader" list="orderHeaders"/> + <set field="orderInput.orderId" from-field="orderHeader.orderId"/> + <set field="orderInput.invoicePerShipment" value="N"/> + <set field="orderInput.userLogin" from-field="userLogin"/> + <call-service service-name="updateOrderHeader" in-map-name="orderInput"> + <result-to-field result-name="responseMessage"/> + </call-service> + <log level="info" message="===== >>> Service : updateOrderHeader / invoicePerShipment = N, Response = ${responseMessage}"/> + <!-- Step 2 --> + <call-bsh><![CDATA[ + import org.ofbiz.shipment.packing.PackingSession; + packingSession = new PackingSession(dispatcher, userLogin); + packingSession.setPrimaryOrderId(orderHeader.get("orderId")); + packingSession.setPrimaryShipGroupSeqId("00001"); + parameters.put("packingSession", packingSession); + ]]></call-bsh> + <set field="packInput.orderId" from-field="orderHeader.orderId"/> + <set field="packInput.shipGroupSeqId" value="00001"/> + <set field="packInput.packingSession" from-field="parameters.packingSession"/> + <set field="packInput.nextPackageSeq" value="1" type="Integer"/> + <set field="packInput.userLogin" from-field="userLogin"/> + <!-- Items --> + <set field="packInput.selInfo._1" value="Y"/> + <set field="packInput.pkgInfo._1" value="1"/> + <set field="packInput.qtyInfo._1" value="1"/> + <set field="packInput.prdInfo._1" value="GZ-2644"/> + <set field="packInput.iteInfo._1" value="00001"/> + <set field="packInput.wgtInfo._1" value="0"/> + <set field="packInput.boxTypeInfo._1" value="FX10KGBOX"/> + <set field="packInput.numPackagesInfo._1" value="1"/> + <call-service service-name="packBulkItems" in-map-name="packInput"> + <result-to-field result-name="responseMessage"/> + </call-service> + <log level="info" message="===== >>> Service: packBulkItems, Response = ${responseMessage}"/> + <set-service-fields service-name="completePack" to-map="completePackInput" map="packInput"/> + <call-service service-name="completePack" in-map-name="completePackInput"> + <result-to-field result-name="shipmentId"/> + </call-service> + <log level="info" message="===== >>> Service: completePack, shipmentId = ${shipmentId}"/> + <!-- Step 3 --> + <entity-and list="invoices" entity-name="OrderItemBillingAndInvoiceAndItem"> + <field-map field-name="orderId" from-field="orderHeader.orderId"/> + </entity-and> + <assert> + <if-empty field="invoices"/> + </assert> + <check-errors/> + </simple-method> + <simple-method method-name="testInvoicePerShipmentSetOrderTrue" short-description="Test Invoice Per Shipment Set Order True" login-required="false"> + <!-- Test Invoice Per Shipment + Step 1) Create order and set invoicePerShipment=Y. + Step 2) Pack Shipment For Ship Group. + Step 3) Check invoice should created. + --> + <!-- Step 1 --> + <field-to-session field="nullField" session-name="orderMode"/> + <set field="request" from-field="parameters.request"/> + <set field="response" from-field="parameters.response"/> + <call-class-method method-name="routeOrderEntry" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : routeOrderEntry, Response = ${result}"/> + <entity-one value-field="userLogin" entity-name="UserLogin"> + <field-map field-name="userLoginId" value="admin"/> + </entity-one> + <call-bsh><![CDATA[ + request.setParameter("orderMode", "SALES_ORDER"); + request.setParameter("productStoreId", "9000"); + request.setParameter("partyId", "DemoCustomer"); + request.setParameter("currencyUom", "USD"); + session = request.getSession(); + session.setAttribute("userLogin", userLogin); + ]]></call-bsh> + <call-class-method method-name="initializeOrderEntry" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : initializeOrderEntry, Response = ${result}"/> + <call-class-method method-name="setOrderCurrencyAgreementShipDates" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : setOrderCurrencyAgreementShipDates, Response = ${result}"/> + <call-bsh><![CDATA[ + request.setParameter("add_product_id", "GZ-2644"); + ]]></call-bsh> + <call-class-method method-name="addToCart" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : addToCart, Response = ${result}"/> + <call-bsh><![CDATA[ + request.setParameter("checkoutpage", "quick"); + request.setParameter("shipping_contact_mech_id", "9015"); + request.setParameter("shipping_method", "GROUND@UPS"); + request.setParameter("checkOutPaymentId", "EXT_COD"); + request.setParameter("is_gift", "false"); + request.setParameter("may_split", "false"); + ]]></call-bsh> + <field-to-request field="nullField" request-name="shoppingCart"/> + <call-class-method method-name="setQuickCheckOutOptions" class-name="org.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : setQuickCheckOutOptions, Response = ${result}"/> + <call-class-method method-name="createOrder" class-name="org.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : createOrder, Response = ${result}"/> + <call-class-method method-name="processPayment" class-name="org.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : processPayment, Response = ${result}"/> + <call-service-asynch service-name="sendOrderConfirmation"/> + <call-class-method method-name="destroyCart" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : destroyCart, Response = ${result}"/> + <entity-condition list="orderHeaders" entity-name="OrderHeader"> + <condition-expr field-name="orderTypeId" value="SALES_ORDER"/> + <order-by field-name="-entryDate"/> + </entity-condition> + <first-from-list entry="orderHeader" list="orderHeaders"/> + <set field="orderInput.orderId" from-field="orderHeader.orderId"/> + <set field="orderInput.invoicePerShipment" value="Y"/> + <set field="orderInput.userLogin" from-field="userLogin"/> + <call-service service-name="updateOrderHeader" in-map-name="orderInput"> + <result-to-field result-name="responseMessage"/> + </call-service> + <log level="info" message="===== >>> Service : updateOrderHeader / invoicePerShipment = Y, Response = ${responseMessage}"/> + <!-- Step 2 --> + <call-bsh><![CDATA[ + import org.ofbiz.shipment.packing.PackingSession; + packingSession = new PackingSession(dispatcher, userLogin); + packingSession.setPrimaryOrderId(orderHeader.get("orderId")); + packingSession.setPrimaryShipGroupSeqId("00001"); + parameters.put("packingSession", packingSession); + ]]></call-bsh> + <set field="packInput.orderId" from-field="orderHeader.orderId"/> + <set field="packInput.shipGroupSeqId" value="00001"/> + <set field="packInput.packingSession" from-field="parameters.packingSession"/> + <set field="packInput.nextPackageSeq" value="1" type="Integer"/> + <set field="packInput.userLogin" from-field="userLogin"/> + <!-- Items --> + <set field="packInput.selInfo._1" value="Y"/> + <set field="packInput.pkgInfo._1" value="1"/> + <set field="packInput.qtyInfo._1" value="1"/> + <set field="packInput.prdInfo._1" value="GZ-2644"/> + <set field="packInput.iteInfo._1" value="00001"/> + <set field="packInput.wgtInfo._1" value="0"/> + <set field="packInput.boxTypeInfo._1" value="FX10KGBOX"/> + <set field="packInput.numPackagesInfo._1" value="1"/> + <call-service service-name="packBulkItems" in-map-name="packInput"> + <result-to-field result-name="responseMessage"/> + </call-service> + <log level="info" message="===== >>> Service: packBulkItems, Response = ${responseMessage}"/> + <set-service-fields service-name="completePack" to-map="completePackInput" map="packInput"/> + <call-service service-name="completePack" in-map-name="completePackInput"> + <result-to-field result-name="shipmentId"/> + </call-service> + <log level="info" message="===== >>> Service: completePack, shipmentId = ${shipmentId}"/> + <!-- Step 3 --> + <entity-and list="invoices" entity-name="OrderItemBillingAndInvoiceAndItem"> + <field-map field-name="orderId" from-field="orderHeader.orderId"/> + </entity-and> + <assert> + <not><if-empty field="invoices"/></not> + </assert> + <check-errors/> + </simple-method> +</simple-methods> Propchange: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/InvoicePerShipmentTests.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/InvoicePerShipmentTests.xml ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/InvoicePerShipmentTests.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Modified: ofbiz/trunk/applications/accounting/testdef/invoicetests.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/testdef/invoicetests.xml?rev=1163084&r1=1163083&r2=1163084&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/testdef/invoicetests.xml (original) +++ ofbiz/trunk/applications/accounting/testdef/invoicetests.xml Tue Aug 30 04:25:28 2011 @@ -25,5 +25,7 @@ <test-case case-name="auto-invoice-tests"> <simple-method-test location="component://accounting/script/org/ofbiz/accounting/test/AutoInvoiceTests.xml"/> </test-case> - + <test-case case-name="invoice-per-shipment-tests"> + <simple-method-test location="component://accounting/script/org/ofbiz/accounting/test/InvoicePerShipmentTests.xml"/> + </test-case> </test-suite> Added: ofbiz/trunk/framework/testtools/lib/org.springframework.core-3.1.0.M2.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/lib/org.springframework.core-3.1.0.M2.jar?rev=1163084&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/trunk/framework/testtools/lib/org.springframework.core-3.1.0.M2.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: ofbiz/trunk/framework/testtools/lib/org.springframework.test-3.1.0.M2.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/lib/org.springframework.test-3.1.0.M2.jar?rev=1163084&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/trunk/framework/testtools/lib/org.springframework.test-3.1.0.M2.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: ofbiz/trunk/framework/testtools/lib/org.springframework.web-3.1.0.M2.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/lib/org.springframework.web-3.1.0.M2.jar?rev=1163084&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/trunk/framework/testtools/lib/org.springframework.web-3.1.0.M2.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Modified: 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?rev=1163084&r1=1163083&r2=1163084&view=diff ============================================================================== --- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/SimpleMethodTest.java (original) +++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/SimpleMethodTest.java Tue Aug 30 04:25:28 2011 @@ -30,8 +30,16 @@ 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.security.Security; +import org.ofbiz.security.SecurityConfigurationException; +import org.ofbiz.security.SecurityFactory; import org.ofbiz.service.ModelService; import org.ofbiz.service.testtools.OFBizTestCase; + +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; +import org.springframework.mock.web.MockServletContext; + import org.w3c.dom.Element; public class SimpleMethodTest extends OFBizTestCase { @@ -40,6 +48,9 @@ public class SimpleMethodTest extends OF protected String methodLocation; protected String methodName; + + public static MockHttpServletRequest request = new MockHttpServletRequest(); + public static MockHttpServletResponse response = new MockHttpServletResponse(); /** * Tests of Simple Method @@ -64,11 +75,17 @@ public class SimpleMethodTest extends OF @Override public void run(TestResult result) { result.startTest(this); - + try { - + // define request + Security security = SecurityFactory.getInstance(delegator); + MockServletContext servletContext = new MockServletContext(); + request.setAttribute("security", security); + request.setAttribute("servletContext", servletContext); + request.setAttribute("delegator", delegator); + request.setAttribute("dispatcher", dispatcher); Map<String, Object> serviceResult = SimpleMethod.runSimpleService(methodLocation, methodName, dispatcher.getDispatchContext(), - UtilMisc.toMap("test", this, "testResult", result, "locale", Locale.getDefault())); + UtilMisc.toMap("test", this, "testResult", result, "locale", Locale.getDefault(), "request", request, "response", response)); // do something with the errorMessage String errorMessage = (String) serviceResult.get(ModelService.ERROR_MESSAGE); @@ -94,6 +111,8 @@ public class SimpleMethodTest extends OF } catch (MiniLangException e) { result.addError(this, e); + } catch (SecurityConfigurationException e) { + result.addError(this, e); } result.endTest(this); Modified: ofbiz/trunk/specialpurpose/ecommerce/data/DemoOrderTestData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/data/DemoOrderTestData.xml?rev=1163084&r1=1163083&r2=1163084&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/data/DemoOrderTestData.xml (original) +++ ofbiz/trunk/specialpurpose/ecommerce/data/DemoOrderTestData.xml Tue Aug 30 04:25:28 2011 @@ -20,7 +20,7 @@ under the License. <entity-engine-xml> <!--Demo data for a sales order --> - <OrderHeader orderId="DEMO10090" orderTypeId="SALES_ORDER" orderName="" salesChannelEnumId="WEB_SALES_CHANNEL" orderDate="2008-04-23 16:49:27.392" entryDate="2008-04-23 16:49:27.392" priority="2" visitId="10002" statusId="ORDER_APPROVED" createdBy="admin" currencyUom="USD" webSiteId="OrderEntry" productStoreId="9000" remainingSubTotal="38.40" grandTotal="50.85" lastUpdatedStamp="2008-04-23 16:49:33.196" lastUpdatedTxStamp="2008-04-23 16:49:33.118" createdStamp="2008-04-23 16:49:27.716" createdTxStamp="2008-04-23 16:49:27.349"/> + <OrderHeader orderId="DEMO10090" orderTypeId="SALES_ORDER" orderName="" salesChannelEnumId="WEB_SALES_CHANNEL" orderDate="2008-04-23 16:49:27.392" entryDate="2008-04-23 16:49:27.392" priority="2" visitId="10002" statusId="ORDER_APPROVED" createdBy="admin" currencyUom="USD" webSiteId="OrderEntry" productStoreId="9000" remainingSubTotal="38.40" grandTotal="50.85" invoicePerShipment="Y" lastUpdatedStamp="2008-04-23 16:49:33.196" lastUpdatedTxStamp="2008-04-23 16:49:33.118" createdStamp="2008-04-23 16:49:27.716" createdTxStamp="2008-04-23 16:49:27.349"/> <OrderItem orderId="DEMO10090" orderItemSeqId="00001" orderItemTypeId="PRODUCT_ORDER_ITEM" productId="GZ-2644" prodCatalogId="DemoCatalog" isPromo="N" quantity="2.0" selectedAmount="0.0" unitPrice="38.4" unitListPrice="48.0" isModifiedPrice="N" itemDescription="Round Gizmo" correspondingPoId="" statusId="ITEM_APPROVED" lastUpdatedStamp="2008-04-23 16:49:33.514" lastUpdatedTxStamp="2008-04-23 16:49:33.484" createdStamp="2008-04-23 16:49:28.128" createdTxStamp="2008-04-23 16:49:27.349"/> <OrderItemPriceInfo orderItemPriceInfoId="9000" orderId="DEMO10090" orderItemSeqId="00001" productPriceRuleId="9000" productPriceActionSeqId="01" modifyAmount="-9.600" description="[PRODUCT_CATEGORY_IDIsPROMOTIONS] [list:48.0;avgCost:48.0;margin:0.0] [type:PRICE_POL]" lastUpdatedStamp="2008-04-23 16:49:28.682" lastUpdatedTxStamp="2008-04-23 16:49:27.349" createdStamp="2008-04-23 16:49:28.682" createdTxStamp="2008-04-23 16:49:27.349"/> |
Free forum by Nabble | Edit this page |