From ebb89430400c2cb1d1c74ca18927375ff41601cc Mon Sep 17 00:00:00 2001 From: antelder Date: Thu, 5 Feb 2009 07:55:03 +0000 Subject: Move the contrib folder out of the sca trunk build as discussed on the ML git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@741038 13f79535-47bb-0310-9956-ffa450edef68 --- java/sca-contrib/samples/quote-xquery/README | 450 +++++++++++++++++++++ java/sca-contrib/samples/quote-xquery/build.xml | 120 ++++++ java/sca-contrib/samples/quote-xquery/pom.xml | 184 +++++++++ .../java/xquery/quote/AvailQuoteProviderImpl.java | 30 ++ .../xquery/quote/AvailQuoteProviderNodeInfo.java | 28 ++ .../xquery/quote/AvailQuoteProviderService.java | 27 ++ .../xquery/quote/ExternalReferencesQuoteJoin.java | 27 ++ .../main/java/xquery/quote/PriceQuoteProvider.java | 28 ++ .../java/xquery/quote/PriceQuoteProviderImpl.java | 27 ++ .../xquery/quote/PriceQuoteProviderNodeInfo.java | 28 ++ .../java/xquery/quote/PropertiesQuoteJoin.java | 32 ++ .../main/java/xquery/quote/QuoteCalculator.java | 26 ++ .../java/xquery/quote/QuoteCalculatorImpl.java | 38 ++ .../src/main/java/xquery/quote/QuoteDataUtil.java | 107 +++++ .../src/main/java/xquery/quote/QuoteJoin.java | 34 ++ .../src/main/java/xquery/quote/QuoteJoinLocal.java | 34 ++ .../main/java/xquery/quote/QuoteJoinLocalImpl.java | 67 +++ .../main/java/xquery/quote/XQueryQuoteClient.java | 145 +++++++ .../main/java/xquery/quote/XQueryQuoteServer.java | 39 ++ .../src/main/resources/META-INF/sca/quote_join.xq | 61 +++ .../META-INF/sca/quote_join_external_references.xq | 69 ++++ .../META-INF/sca/quote_join_properties.xq | 74 ++++ .../src/main/resources/wsdl/AvailQuote.xsd | 39 ++ .../src/main/resources/wsdl/PriceQuote.xsd | 49 +++ .../quote-xquery/src/main/resources/wsdl/Quote.xsd | 40 ++ .../src/main/resources/wsdl/quotejoin.wsdl | 137 +++++++ .../src/main/resources/xqueryquotews.composite | 55 +++ .../main/resources/xqueryquotewsclient.composite | 113 ++++++ .../xquery/quote/XQueryQuoteClientTestCase.java | 192 +++++++++ .../java/xquery/quote/XQueryQuoteTestServer.java | 50 +++ 30 files changed, 2350 insertions(+) create mode 100644 java/sca-contrib/samples/quote-xquery/README create mode 100644 java/sca-contrib/samples/quote-xquery/build.xml create mode 100644 java/sca-contrib/samples/quote-xquery/pom.xml create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderImpl.java create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderNodeInfo.java create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderService.java create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/ExternalReferencesQuoteJoin.java create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProvider.java create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderImpl.java create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderNodeInfo.java create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/PropertiesQuoteJoin.java create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculator.java create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculatorImpl.java create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteDataUtil.java create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoin.java create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocal.java create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocalImpl.java create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteClient.java create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteServer.java create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join.xq create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_external_references.xq create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_properties.xq create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/resources/wsdl/AvailQuote.xsd create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/resources/wsdl/PriceQuote.xsd create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/resources/wsdl/Quote.xsd create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/resources/wsdl/quotejoin.wsdl create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/resources/xqueryquotews.composite create mode 100644 java/sca-contrib/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite create mode 100644 java/sca-contrib/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteClientTestCase.java create mode 100644 java/sca-contrib/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteTestServer.java (limited to 'java/sca-contrib/samples/quote-xquery') diff --git a/java/sca-contrib/samples/quote-xquery/README b/java/sca-contrib/samples/quote-xquery/README new file mode 100644 index 0000000000..cf8a4609a6 --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/README @@ -0,0 +1,450 @@ +Quote Xquery Sample +=================== + + This sample covers the most important integration scenarios for the xquery + implementation type and its corresponding saxon data bindings. + +If you just want to run it to see what happens open two command prompts (one for the server +and the other for the client), navigate to this sample directory and do: + +Command Prompt 1: +ant +ant run-server + +Command Prompt 2: +ant run + +OR if you don't have ant, on Windows do + +In the directory samples\quote-xquery use the JDK 1.5 java command to run the class xquery.quote.XQueryQuoteClient + +Linux: java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-quote-xquery.jar xquery.quote.XQueryQuoteServer +Linux: java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-quote-xquery.jar xquery.quote.XQueryQuoteClient + +Windows: java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-quote-xquery.jar xquery.quote.XQueryQuoteServer +Windows: java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-quote-xquery.jar xquery.quote.XQueryQuoteClient + +Results +---------- +The sample when run should simply display on the standard output some startup messages followed by: + +The compilation: + +Buildfile: build.xml + +init: + +generate-sdo: + [java] >> Generating code + [java] >> Generating packages + [java] >> Generating package QuotePackageImpl + [java] >> Generating Java interface org.example.quote.QuoteFactory + [java] >> Generating /TargetProject/org/example/quote/QuoteFactory.java + [java] >> Examining old /TargetProject/org/example/quote/QuoteFactory.java + [java] >> Generating Java class org.example.quote.impl.QuoteFactoryImpl + [java] >> Generating /TargetProject/org/example/quote/impl/QuoteFactoryImpl.java + [java] >> Examining old /TargetProject/org/example/quote/impl/QuoteFactoryImpl.java + [java] >> Generating Quote + [java] >> Generating Java interface org.example.quote.Quote + [java] >> Generating /TargetProject/org/example/quote/Quote.java + [java] >> Examining old /TargetProject/org/example/quote/Quote.java + [java] >> Generating Java class org.example.quote.impl.QuoteImpl + [java] >> Generating /TargetProject/org/example/quote/impl/QuoteImpl.java + [java] >> Examining old /TargetProject/org/example/quote/impl/QuoteImpl.java + [java] >> Generating Response + [java] >> Generating Java interface org.example.quote.QuoteResponse + [java] >> Generating /TargetProject/org/example/quote/QuoteResponse.java + [java] >> Examining old /TargetProject/org/example/quote/QuoteResponse.java + [java] >> Generating Java class org.example.quote.impl.QuoteResponseImpl + [java] >> Generating /TargetProject/org/example/quote/impl/QuoteResponseImpl.java + [java] >> Examining old /TargetProject/org/example/quote/impl/QuoteResponseImpl.java + [java] >> Generating code + [java] >> Generating packages + [java] >> Generating package AvailPackageImpl + [java] >> Generating Java interface org.example.avail.AvailFactory + [java] >> Generating /TargetProject/org/example/avail/AvailFactory.java + [java] >> Examining old /TargetProject/org/example/avail/AvailFactory.java + [java] >> Generating Java class org.example.avail.impl.AvailFactoryImpl + [java] >> Generating /TargetProject/org/example/avail/impl/AvailFactoryImpl.java + [java] >> Examining old /TargetProject/org/example/avail/impl/AvailFactoryImpl.java + [java] >> Generating Quote + [java] >> Generating Java interface org.example.avail.AvailQuote + [java] >> Generating /TargetProject/org/example/avail/AvailQuote.java + [java] >> Examining old /TargetProject/org/example/avail/AvailQuote.java + [java] >> Generating Java class org.example.avail.impl.AvailQuoteImpl + [java] >> Generating /TargetProject/org/example/avail/impl/AvailQuoteImpl.java + [java] >> Examining old /TargetProject/org/example/avail/impl/AvailQuoteImpl.java + [java] >> Generating Request + [java] >> Generating Java interface org.example.avail.AvailRequest + [java] >> Generating /TargetProject/org/example/avail/AvailRequest.java + [java] >> Examining old /TargetProject/org/example/avail/AvailRequest.java + [java] >> Generating Java class org.example.avail.impl.AvailRequestImpl + [java] >> Generating /TargetProject/org/example/avail/impl/AvailRequestImpl.java + [java] >> Examining old /TargetProject/org/example/avail/impl/AvailRequestImpl.java + [java] >> Generating code + [java] >> Generating packages + [java] >> Generating package PricePackageImpl + [java] >> Generating Java interface org.example.price.PriceFactory + [java] >> Generating /TargetProject/org/example/price/PriceFactory.java + [java] >> Examining old /TargetProject/org/example/price/PriceFactory.java + [java] >> Generating Java class org.example.price.impl.PriceFactoryImpl + [java] >> Generating /TargetProject/org/example/price/impl/PriceFactoryImpl.java + [java] >> Examining old /TargetProject/org/example/price/impl/PriceFactoryImpl.java + [java] >> Generating Quote + [java] >> Generating Java interface org.example.price.PriceQuote + [java] >> Generating /TargetProject/org/example/price/PriceQuote.java + [java] >> Examining old /TargetProject/org/example/price/PriceQuote.java + [java] >> Generating Java class org.example.price.impl.PriceQuoteImpl + [java] >> Generating /TargetProject/org/example/price/impl/PriceQuoteImpl.java + [java] >> Examining old /TargetProject/org/example/price/impl/PriceQuoteImpl.java + [java] >> Generating Request + [java] >> Generating Java interface org.example.price.PriceRequest + [java] >> Generating /TargetProject/org/example/price/PriceRequest.java + [java] >> Examining old /TargetProject/org/example/price/PriceRequest.java + [java] >> Generating Java class org.example.price.impl.PriceRequestImpl + [java] >> Generating /TargetProject/org/example/price/impl/PriceRequestImpl.java + [java] >> Examining old /TargetProject/org/example/price/impl/PriceRequestImpl.java + [java] >> Generating Requests + [java] >> Generating Java interface org.example.price.PriceRequests + [java] >> Generating /TargetProject/org/example/price/PriceRequests.java + [java] >> Examining old /TargetProject/org/example/price/PriceRequests.java + [java] >> Generating Java class org.example.price.impl.PriceRequestsImpl + [java] >> Generating /TargetProject/org/example/price/impl/PriceRequestsImpl.java + [java] >> Examining old /TargetProject/org/example/price/impl/PriceRequestsImpl.java + [java] >> Generating Ship Address + [java] >> Generating Java interface org.example.price.ShipAddress + [java] >> Generating /TargetProject/org/example/price/ShipAddress.java + [java] >> Examining old /TargetProject/org/example/price/ShipAddress.java + [java] >> Generating Java class org.example.price.impl.ShipAddressImpl + [java] >> Generating /TargetProject/org/example/price/impl/ShipAddressImpl.java + [java] >> Examining old /TargetProject/org/example/price/impl/ShipAddressImpl.java + +compile: + [jar] Building jar: C:\Apache\tuscany-sca-1.0-incubating-SNAPSHOT\samples\quote-xquery\target\sample-quote-xquery.jar +BUILD SUCCESSFUL + + +The service side: + +run-server: + [java] Sep 18, 2007 1:14:16 PM org.apache.catalina.core.StandardEngine start + [java] INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 + [java] Sep 18, 2007 1:14:16 PM org.apache.catalina.startup.ContextConfig defaultWebConfig + [java] INFO: No default web.xml + [java] Sep 18, 2007 1:14:16 PM org.apache.catalina.startup.DigesterFactory register + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd + [java] Sep 18, 2007 1:14:16 PM org.apache.catalina.startup.DigesterFactory register + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_1.dtd + [java] Sep 18, 2007 1:14:16 PM org.apache.catalina.startup.DigesterFactory register + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd + [java] Sep 18, 2007 1:14:16 PM org.apache.catalina.startup.DigesterFactory register + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_0.xsd + [java] Sep 18, 2007 1:14:16 PM org.apache.catalina.startup.DigesterFactory register + [java] WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xsd + [java] Sep 18, 2007 1:14:17 PM org.apache.coyote.http11.Http11Protocol init + [java] INFO: Initializing Coyote HTTP/1.1 on http-8085 + [java] Sep 18, 2007 1:14:17 PM org.apache.coyote.http11.Http11Protocol start + [java] INFO: Starting Coyote HTTP/1.1 on http-8085 + [java] Sep 18, 2007 1:14:17 PM org.apache.tuscany.sca.http.tomcat.TomcatServer addServletMapping + [java] INFO: Added Servlet mapping: http://localhost:8085/QuoteJoinService + [java] Sep 18, 2007 1:14:17 PM org.apache.tuscany.sca.http.tomcat.TomcatServer addServletMapping + [java] INFO: Added Servlet mapping: http://localhost:8085/AvailQuoteProviderService + [java] XQuery Quote server started (press enter to shutdown) + [java] Sep 18, 2007 1:16:54 PM org.apache.coyote.http11.Http11Protocol destroy + [java] INFO: Stopping Coyote HTTP/1.1 on http-8085 + +BUILD SUCCESSFUL +Total time: 2 minutes 51 seconds + +The client side: +Buildfile: build.xml + +run: + [java] Input quote for the price list: + [java] + [java] + [java] Acme Inc + [java] + [java] + [java] + [java] 12 + [java] 1.0 + [java] + [java] + [java] 134 + [java] 34.1 + [java] + [java] + [java] 211 + [java] 10.0 + [java] + [java] + [java] + [java] + [java] Input quote for the availability: + [java] + [java] + [java] + [java] 12 + [java] 10 + [java] true + [java] 2003-03-22 + [java] + [java] + [java] 134 + [java] 345 + [java] false + [java] BackOrder + [java] + [java] + [java] 211 + [java] 100 + [java] true + [java] 2003-04-21 + [java] + [java] + [java] + [java] + [java] Output quote from local join: + [java] + [java] + [java] Acme Inc + [java]
12 Springs Rd,Morris Plains,NJ,07960
+ [java] + [java] 12 + [java] 1.0 + [java] 10 + [java] true + [java] 2003-03-22 + [java] 0.1 + [java] 11.0 + [java] + [java] + [java] 134 + [java] 34.1 + [java] 345 + [java] false + [java] BackOrder + [java] 0.1 + [java] 0.0 + [java] + [java] + [java] 211 + [java] 10.0 + [java] 100 + [java] true + [java] 2003-04-21 + [java] 0.1 + [java] 1100.0 + [java] + [java]
+ [java] + [java] + [java] Output quote from local join (second invokation): + [java] + [java] + [java] Acme Inc + [java]
12 Springs Rd,Morris Plains,NJ,07960
+ [java] + [java] 12 + [java] 1.0 + [java] 10 + [java] true + [java] 2003-03-22 + [java] 0.2 + [java] 12.0 + [java] + [java] + [java] 134 + [java] 34.1 + [java] 345 + [java] false + [java] BackOrder + [java] 0.2 + [java] 0.0 + [java] + [java] + [java] 211 + [java] 10.0 + [java] 100 + [java] true + [java] 2003-04-21 + [java] 0.2 + [java] 1200.0 + [java] + [java]
+ [java] + [java] + [java] Output quote from web service join: + [java] + [java] + [java] Acme Inc + [java]
12 Springs Rd,Morris Plains,NJ,07960
+ [java] + [java] 12 + [java] 1.0 + [java] 10 + [java] true + [java] 2003-03-22 + [java] 0.1 + [java] 11.0 + [java] + [java] + [java] 134 + [java] 34.1 + [java] 345 + [java] false + [java] BackOrder + [java] 0.1 + [java] 0.0 + [java] + [java] + [java] 211 + [java] 10.0 + [java] 100 + [java] true + [java] 2003-04-21 + [java] 0.1 + [java] 1100.0 + [java] + [java]
+ [java] + [java] + [java] Output quote from properties join: + [java] + [java] + [java] Acme Inc + [java]
12 Springs Rd,Morris Plains,NJ,07960
+ [java] + [java] 12 + [java] 1.0 + [java] 10 + [java] true + [java] 2003-03-22 + [java] 0.1 + [java] 11.0 + [java] + [java] + [java] 134 + [java] 34.1 + [java] 345 + [java] false + [java] BackOrder + [java] 0.1 + [java] 0.0 + [java] + [java] + [java] 211 + [java] 10.0 + [java] 100 + [java] true + [java] 2003-04-21 + [java] 0.1 + [java] 1100.0 + [java] + [java]
+ [java] + [java] + [java] Output quote from external references join: + [java] + [java] + [java] Acme Inc + [java]
12 Springs Rd,Morris Plains,NJ,07960
+ [java] + [java] 12 + [java] 1.0 + [java] 10 + [java] true + [java] 2003-03-22 + [java] 0.1 + [java] 11.0 + [java] + [java] + [java] 134 + [java] 34.1 + [java] 345 + [java] false + [java] BackOrder + [java] 0.1 + [java] 0.0 + [java] + [java] + [java] 211 + [java] 10.0 + [java] 100 + [java] true + [java] 2003-04-21 + [java] 0.1 + [java] 1100.0 + [java] + [java]
+ [java] + +BUILD SUCCESSFUL +Total time: 16 seconds + + + +Sample Overview +--------------- + + 1. There is a central component for invoking the different + scenarios: QuoteJoinLocalComponent + 2. It provides the following cases: + - invoke XQuery component in the current assembly, by providing all needed + information as input parameters + - invoke XQuery component in external assembly, which is exposed as a web + service + - invoke XQuery component in the current assembly, which retrieves the needed + information from the component properties + - invoke XQuery component in the current assembly, which retrieves the needed + information from its references to other components: + - one of the components is in the current assembly + - the other component is in anther assembly and it is exposed (and accessed) + as web service + + 3. All of the XQuery components have reference to a component for calculation of the + total price + 4. SDO is used for data interchange + +src/main/resources + wsdl + AvailQuote.xsd + PriceQuote.xsd + Quote.xsd + quotejoin.wsdl + META-INF + sca + quote_join_external_references.xq --- the external references xquery script + quote_join_properties.xq --- the property-based join xquery script + quote_join.xq --- the join xquery script + xqueryquotews.composite --- composite file for the client side + xqueryquotewsclient.composite --- composite file for the service side + + build.xml - the Ant build file + pom.xml - the Maven build file + + +Building And Running The Sample Using Ant +----------------------------------------- +cd quote-xquery +ant compile +ant run-server + +you should see: +Buildfile: build.xml + +run: + + + +Building And Running The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built and run +using Maven as follows. + +cd quote-xquery +mvn + + +This shows that the Junit test cases have run successfully. diff --git a/java/sca-contrib/samples/quote-xquery/build.xml b/java/sca-contrib/samples/quote-xquery/build.xml new file mode 100644 index 0000000000..a3a5acf102 --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/build.xml @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca-contrib/samples/quote-xquery/pom.xml b/java/sca-contrib/samples/quote-xquery/pom.xml new file mode 100644 index 0000000000..2fa134132c --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/pom.xml @@ -0,0 +1,184 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-SNAPSHOT + ../../pom.xml + + sample-quote-xquery + Apache Tuscany SCA XQuery Quote Implementation Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-xquery + 2.0-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 2.0-SNAPSHOT + runtime + + + + org.apache.tuscany.sdo + tuscany-sdo-lib + 1.1.1 + + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.1.1 + + + + + + net.sf.saxon + saxon + 8.7 + + + + org.apache.tuscany.sca + tuscany-databinding-sdo + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-jetty + 2.0-SNAPSHOT + runtime + + + + junit + junit + 4.5 + compile + + + + + + ${artifactId} + + + org.codehaus.mojo + build-helper-maven-plugin + 1.0 + + + add-source + generate-sources + + add-test-source + + + + target/sdo-source + + + + + + + org.apache.tuscany.sdo + tuscany-sdo-plugin + 1.1.1 + + + generate-quotejoin-sdo + generate-sources + + ${basedir}/src/main/resources/wsdl/quotejoin.wsdl + + + generate + + + + generate-quote-sdo + generate-sources + + ${basedir}/src/main/resources/wsdl/Quote.xsd + + + generate + + + + generate-avail-quote-sdo + generate-sources + + ${basedir}/src/main/resources/wsdl/AvailQuote.xsd + + + generate + + + + generate-price-quote-sdo + generate-sources + + ${basedir}/src/main/resources/wsdl/PriceQuote.xsd + + + generate + + + + + + + + diff --git a/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderImpl.java b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderImpl.java new file mode 100644 index 0000000000..81396b056a --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderImpl.java @@ -0,0 +1,30 @@ +/* + * 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 xquery.quote; + +import org.example.avail.AvailQuote; +import org.oasisopen.sca.annotation.Service; + +@Service(AvailQuoteProviderService.class) +public class AvailQuoteProviderImpl implements AvailQuoteProviderService { + + public AvailQuote provideAvailQuote(String dummyString) { + return QuoteDataUtil.buildAvailQuoteData(); + } +} diff --git a/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderNodeInfo.java b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderNodeInfo.java new file mode 100644 index 0000000000..fb097c46f8 --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderNodeInfo.java @@ -0,0 +1,28 @@ +/* + * 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 xquery.quote; + +import net.sf.saxon.om.NodeInfo; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface AvailQuoteProviderNodeInfo { + NodeInfo provideAvailQuote(String dummyString); +} diff --git a/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderService.java b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderService.java new file mode 100644 index 0000000000..c54febcd14 --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderService.java @@ -0,0 +1,27 @@ +/* + * 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 xquery.quote; + +import org.example.avail.AvailQuote; +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface AvailQuoteProviderService { + AvailQuote provideAvailQuote(String dummyString); +} diff --git a/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/ExternalReferencesQuoteJoin.java b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/ExternalReferencesQuoteJoin.java new file mode 100644 index 0000000000..ebe0cd51ae --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/ExternalReferencesQuoteJoin.java @@ -0,0 +1,27 @@ +/* + * 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 xquery.quote; + +import org.example.quote.Quote; +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface ExternalReferencesQuoteJoin { + public Quote joinPriceAndAvailQuotes(float taxRate); +} diff --git a/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProvider.java b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProvider.java new file mode 100644 index 0000000000..92341ea26f --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProvider.java @@ -0,0 +1,28 @@ +/* + * 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 xquery.quote; + +import org.example.price.PriceQuote; +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface PriceQuoteProvider { + + public PriceQuote providePriceQuote(); +} diff --git a/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderImpl.java b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderImpl.java new file mode 100644 index 0000000000..d2d175430b --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderImpl.java @@ -0,0 +1,27 @@ +/* + * 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 xquery.quote; + +import org.example.price.PriceQuote; + +public class PriceQuoteProviderImpl implements PriceQuoteProvider { + public PriceQuote providePriceQuote() { + return QuoteDataUtil.buildPriceQuoteData(); + } +} diff --git a/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderNodeInfo.java b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderNodeInfo.java new file mode 100644 index 0000000000..5669738c98 --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderNodeInfo.java @@ -0,0 +1,28 @@ +/* + * 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 xquery.quote; + +import net.sf.saxon.om.NodeInfo; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface PriceQuoteProviderNodeInfo { + public NodeInfo providePriceQuote(); +} diff --git a/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/PropertiesQuoteJoin.java b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/PropertiesQuoteJoin.java new file mode 100644 index 0000000000..1a71abab81 --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/PropertiesQuoteJoin.java @@ -0,0 +1,32 @@ +/* + * 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 xquery.quote; + +import javax.xml.ws.RequestWrapper; +import javax.xml.ws.ResponseWrapper; + +import org.example.quote.Quote; +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface PropertiesQuoteJoin { + @RequestWrapper(className="xquery.quote.joinPriceAndAvailQuotes") + @ResponseWrapper(className="xquery.quote.joinPriceAndAvailQuotesResponse") + public Quote joinPriceAndAvailQuotes(); +} diff --git a/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculator.java b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculator.java new file mode 100644 index 0000000000..5aea04bfb1 --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculator.java @@ -0,0 +1,26 @@ +/* + * 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 xquery.quote; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface QuoteCalculator { + public float calculateTotalPrice(float taxRate, int quantity, float price, boolean fillOrder); +} diff --git a/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculatorImpl.java b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculatorImpl.java new file mode 100644 index 0000000000..26331381a8 --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculatorImpl.java @@ -0,0 +1,38 @@ +/* + * 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 xquery.quote; + +public class QuoteCalculatorImpl implements QuoteCalculator { + + public float calculateTotalPrice(float taxRate, int quantity, float price, boolean fillOrder) { + float totalTax, costNoTax, totalCost; + if (fillOrder) { + // Calculate the total tax + totalTax = taxRate * quantity * price; + // Calculate the total cost without tax + costNoTax = quantity * price; + // Add the tax and the cost to get the total cost + totalCost = totalTax + costNoTax; + } else { + totalCost = 0; + } + return totalCost; + } + +} diff --git a/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteDataUtil.java b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteDataUtil.java new file mode 100644 index 0000000000..8ed02dc1ef --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteDataUtil.java @@ -0,0 +1,107 @@ +/* + * 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 xquery.quote; + +import java.io.IOException; +import java.math.BigInteger; + + +import org.example.avail.AvailFactory; +import org.example.avail.AvailQuote; +import org.example.avail.AvailRequest; +import org.example.price.PriceFactory; +import org.example.price.PriceQuote; +import org.example.price.PriceRequest; +import org.example.price.PriceRequests; +import org.example.price.ShipAddress; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.XMLHelper; + +public class QuoteDataUtil { + + public static AvailQuote buildAvailQuoteData() { + AvailQuote availQuote = AvailFactory.INSTANCE.createAvailQuote(); + AvailRequest availRequest = AvailFactory.INSTANCE.createAvailRequest(); + availRequest.setWidgetId(BigInteger.valueOf(12)); + availRequest.setRequestedQuantity(10); + availRequest.setQuantityAvail(true); + availRequest.setShipDate("2003-03-22"); + availQuote.getAvailRequest().add(availRequest); + + availRequest = AvailFactory.INSTANCE.createAvailRequest(); + availRequest.setWidgetId(BigInteger.valueOf(134)); + availRequest.setRequestedQuantity(345); + availRequest.setQuantityAvail(false); + availRequest.setShipDate("BackOrder"); + availQuote.getAvailRequest().add(availRequest); + + availRequest = AvailFactory.INSTANCE.createAvailRequest(); + availRequest.setWidgetId(BigInteger.valueOf(211)); + availRequest.setRequestedQuantity(100); + availRequest.setQuantityAvail(true); + availRequest.setShipDate("2003-04-21"); + availQuote.getAvailRequest().add(availRequest); + + return availQuote; + } + + public static PriceQuote buildPriceQuoteData() { + PriceQuote priceQuote = PriceFactory.INSTANCE.createPriceQuote(); + priceQuote.setCustomerName("Acme Inc"); + + ShipAddress shipAddress = PriceFactory.INSTANCE.createShipAddress(); + shipAddress.setStreet("12 Springs Rd"); + shipAddress.setCity("Morris Plains"); + shipAddress.setState("nj"); + shipAddress.setZip("07960"); + priceQuote.setShipAddress(shipAddress); + + PriceRequests priceRequests = PriceFactory.INSTANCE.createPriceRequests(); + PriceRequest priceRequest = PriceFactory.INSTANCE.createPriceRequest(); + priceRequest.setWidgetId(BigInteger.valueOf(12)); + priceRequest.setPrice(1.00f); + priceRequests.getPriceRequest().add(priceRequest); + + priceRequest = PriceFactory.INSTANCE.createPriceRequest(); + priceRequest.setWidgetId(BigInteger.valueOf(134)); + priceRequest.setPrice(34.10f); + priceRequests.getPriceRequest().add(priceRequest); + + priceRequest = PriceFactory.INSTANCE.createPriceRequest(); + priceRequest.setWidgetId(BigInteger.valueOf(211)); + priceRequest.setPrice(10.00f); + priceRequests.getPriceRequest().add(priceRequest); + + priceQuote.setPriceRequests(priceRequests); + + return priceQuote; + } + + public static void serializeToSystemOut(DataObject object, String name) { + XMLHelper helper = XMLHelper.INSTANCE; + + try { + helper.save(object, null, name, System.out); + System.out.println(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoin.java b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoin.java new file mode 100644 index 0000000000..103d19e59d --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoin.java @@ -0,0 +1,34 @@ +/* + * 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 xquery.quote; + +import javax.xml.ws.RequestWrapper; +import javax.xml.ws.ResponseWrapper; + +import org.example.avail.AvailQuote; +import org.example.price.PriceQuote; +import org.example.quote.Quote; +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface QuoteJoin { + @RequestWrapper(className="xquery.quote.joinPriceAndAvailQuotes") + @ResponseWrapper(className="xquery.quote.joinPriceAndAvailQuotesResponse") + public Quote joinPriceAndAvailQuotes(PriceQuote priceQuote, AvailQuote availQuote, float taxRate); +} diff --git a/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocal.java b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocal.java new file mode 100644 index 0000000000..cfd201f883 --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocal.java @@ -0,0 +1,34 @@ +/* + * 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 xquery.quote; + +import org.example.avail.AvailQuote; +import org.example.price.PriceQuote; +import org.example.quote.Quote; + +public interface QuoteJoinLocal { + public Quote joinPriceAndAvailQuotes(PriceQuote priceQuote, AvailQuote availQuote, float taxRate); + + public Quote joinPriceAndAvailQuotesWs(PriceQuote priceQuote, AvailQuote availQuote, float taxRate); + + public Quote joinPriceAndAvailQuotes(); + + public Quote joinPriceAndAvailQuotes(float taxRate); + +} diff --git a/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocalImpl.java b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocalImpl.java new file mode 100644 index 0000000000..26bcfe9707 --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocalImpl.java @@ -0,0 +1,67 @@ +/* + * 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 xquery.quote; + +import org.example.avail.AvailQuote; +import org.example.price.PriceQuote; +import org.example.quote.Quote; +import org.oasisopen.sca.annotation.Reference; + +public class QuoteJoinLocalImpl implements QuoteJoinLocal { + private QuoteJoin quoteJoin; + private QuoteJoin quoteJoinWs; + private PropertiesQuoteJoin propertiesQuoteJoin; + private ExternalReferencesQuoteJoin externalServicesQuoteJoin; + + @Reference + public void setQuoteJoin(QuoteJoin quoteJoin) { + this.quoteJoin = quoteJoin; + } + + @Reference + public void setQuoteJoinWs(QuoteJoin quoteJoinWs) { + this.quoteJoinWs = quoteJoinWs; + } + + @Reference + public void setPropertiesQuoteJoin(PropertiesQuoteJoin propertiesQuoteJoin) { + this.propertiesQuoteJoin = propertiesQuoteJoin; + } + + @Reference + public void setExternalServicesQuoteJoin(ExternalReferencesQuoteJoin externalServicesQuoteJoin) { + this.externalServicesQuoteJoin = externalServicesQuoteJoin; + } + + public Quote joinPriceAndAvailQuotes(PriceQuote priceQuote, AvailQuote availQuote, float taxRate) { + return quoteJoin.joinPriceAndAvailQuotes(priceQuote, availQuote, taxRate); + } + + public Quote joinPriceAndAvailQuotesWs(PriceQuote priceQuote, AvailQuote availQuote, float taxRate) { + return quoteJoinWs.joinPriceAndAvailQuotes(priceQuote, availQuote, taxRate); + } + + public Quote joinPriceAndAvailQuotes(float taxRate) { + return externalServicesQuoteJoin.joinPriceAndAvailQuotes(taxRate); + } + + public Quote joinPriceAndAvailQuotes() { + return propertiesQuoteJoin.joinPriceAndAvailQuotes(); + } +} diff --git a/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteClient.java b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteClient.java new file mode 100644 index 0000000000..adc852acd4 --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteClient.java @@ -0,0 +1,145 @@ +/* + * 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 xquery.quote; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.example.avail.AvailQuote; +import org.example.price.PriceQuote; +import org.example.quote.Quote; + +import commonj.sdo.DataObject; + +/** + * Integration test for the XQuery implementation type + * @version $Rev: 577067 $ $Date: 2007-09-18 22:10:03 +0100 (Tue, 18 Sep 2007) $ + * This test covers the most important integration scenarios for the xquery + * implementation type and its corresponding saxon data bindings: + * + * 1. There is a central component for invoking the different + * scenarios: QuoteJoinLocalComponent + * 2. It provides the following tests: + * - invoke XQuery component in the current assembly, by providing all needed + * information as input parameters + * - invoke XQuery component in external assembly, which is exposed as a web + * service + * - invoke XQuery component in the current assembly, which retrieves the needed + * information from the component properties + * - invoke XQuery component in the current assembly, which retrieves the needed + * information from its references to other components: + * - one of the components is in the current assembly + * - the other component is in anther assembly and it is exposed (and accessed) + * as web service + * + * 3. All of the XQuery components have reference to a component for calculation of the + * total price + * 4. SDO is used for data interchange + */ +public class XQueryQuoteClient { + + public static boolean SHOW_DEBUG_MSG = false; + + private SCADomain scaDomain; + + private QuoteJoinLocal quoteJoinLocal; + + public void startClient() throws Exception { + try { + scaDomain = SCADomain.newInstance("xqueryquotewsclient.composite"); + quoteJoinLocal = scaDomain.getService(QuoteJoinLocal.class, "QuoteJoinLocalComponent"); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + public void testQuoteJoin() { + AvailQuote availQuote = QuoteDataUtil.buildAvailQuoteData(); + PriceQuote priceQuote = QuoteDataUtil.buildPriceQuoteData(); + + if (SHOW_DEBUG_MSG) { + System.out.println("Input quote for the price list:"); + QuoteDataUtil.serializeToSystemOut((DataObject)priceQuote, "priceQuote"); + System.out.println(); + System.out.println("Input quote for the availability:"); + QuoteDataUtil.serializeToSystemOut((DataObject)availQuote, "availQuote"); + System.out.println(); + } + + Quote quote = quoteJoinLocal.joinPriceAndAvailQuotes(priceQuote, availQuote, 0.1f); + if (SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from local join:"); + QuoteDataUtil.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + // TestHelper.assertQuote(availQuote, priceQuote, quote, 0.1f); + + quote = quoteJoinLocal.joinPriceAndAvailQuotes(priceQuote, availQuote, 0.2f); + if (SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from local join (second invokation):"); + QuoteDataUtil.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + // TestHelper.assertQuote(availQuote, priceQuote, quote, 0.2f); + + quote = quoteJoinLocal.joinPriceAndAvailQuotesWs(priceQuote, availQuote, 0.1f); + if (SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from web service join:"); + QuoteDataUtil.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + // TestHelper.assertQuote(availQuote, priceQuote, quote, 0.1f); + + quote = quoteJoinLocal.joinPriceAndAvailQuotes(); + if (SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from properties join:"); + QuoteDataUtil.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + // TestHelper.assertQuote(availQuote, priceQuote, quote, 0.1f); + + quote = quoteJoinLocal.joinPriceAndAvailQuotes(0.1f); + if (SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from external references join:"); + QuoteDataUtil.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + // TestHelper.assertQuote(availQuote, priceQuote, quote, 0.1f); + } + + public void stopClient() throws Exception { + if (scaDomain != null) { + scaDomain.close(); + } + } + + public static void main(String[] args) throws Exception { + SHOW_DEBUG_MSG = true; + XQueryQuoteClient client = new XQueryQuoteClient(); + client.startClient(); + try { + client.testQuoteJoin(); + } finally { + client.stopClient(); + } + } +} diff --git a/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteServer.java b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteServer.java new file mode 100644 index 0000000000..3fa3cdb637 --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteServer.java @@ -0,0 +1,39 @@ +/* + * 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 xquery.quote; + +import java.io.IOException; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class XQueryQuoteServer { + + public static void main(String[] args) { + SCADomain scaDomain = SCADomain.newInstance("xqueryquotews.composite"); + try { + System.out.println("XQuery Quote server is started (press enter to shutdown)."); + System.in.read(); + System.out.println("XQuery Quote server is stopping..."); + } catch (IOException e) { + e.printStackTrace(); + } + scaDomain.close(); + System.out.println("XQuery Quote server is now stopped."); + } +} diff --git a/java/sca-contrib/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join.xq b/java/sca-contrib/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join.xq new file mode 100644 index 0000000000..d504f40f04 --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join.xq @@ -0,0 +1,61 @@ +(: + * 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. +:) + +declare namespace quoteJoin="scaservice:java/xquery.quote.QuoteJoin"; + +declare namespace quoteCalculator="scareference:java/xquery.quote.QuoteCalculator"; + +declare namespace quo="http://www.example.org/quote"; + +declare variable $quoteCalculator external; + +declare function quoteJoin:joinPriceAndAvailQuotes($priceQuoteDoc, $availQuoteDoc, $taxRate) { + + { data($priceQuoteDoc/*/customerName) } + { concat($priceQuoteDoc/*/shipAddress/@street , ",", $priceQuoteDoc/*/shipAddress/@city ,",", fn:upper-case($priceQuoteDoc/*/shipAddress/@state) , ",", $priceQuoteDoc/*/shipAddress/@zip) } + { + for $priceRequest in $priceQuoteDoc/*/priceRequests/priceRequest, + $availRequest in $availQuoteDoc/*/availRequest + where data($priceRequest/widgetId) = data($availRequest/widgetId) + return + + { data($priceRequest/widgetId) } + { data($priceRequest/price) } + { data($availRequest/requestedQuantity) } + { data($availRequest/quantityAvail) } + { + for $shipDate in $availRequest/shipDate + return + { data($shipDate) } + } + { $taxRate } + { quoteCalculator:calculateTotalPrice( + $quoteCalculator, + + xs:float($taxRate), + + $availRequest/requestedQuantity, + + $priceRequest/price, + + $availRequest/quantityAvail) } + + } + +}; diff --git a/java/sca-contrib/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_external_references.xq b/java/sca-contrib/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_external_references.xq new file mode 100644 index 0000000000..cc50da164a --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_external_references.xq @@ -0,0 +1,69 @@ +(: + * 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. +:) +declare namespace quoteJoin="scaservice:java/xquery.quote.ExternalReferencesQuoteJoin"; + +declare namespace quoteCalculator="scareference:java/xquery.quote.QuoteCalculator"; + +declare namespace priceQuoteProvider="scareference:java/xquery.quote.PriceQuoteProviderNodeInfo"; +declare namespace availQuoteProvider="scareference:java/xquery.quote.AvailQuoteProviderNodeInfo"; + +declare namespace quo="http://www.example.org/quote"; + +declare variable $quoteCalculator external; + +declare variable $priceQuoteProvider external; +declare variable $availQuoteProvider external; + +declare function quoteJoin:joinPriceAndAvailQuotes($taxRate) { +let $priceQuoteDoc := priceQuoteProvider:providePriceQuote($priceQuoteProvider) +let $availQuoteDoc := availQuoteProvider:provideAvailQuote($availQuoteProvider, 'dummy') +return + + { data($priceQuoteDoc/priceQuote/customerName) } + { concat($priceQuoteDoc/priceQuote/shipAddress/@street , ",", $priceQuoteDoc/priceQuote/shipAddress/@city ,",", fn:upper-case($priceQuoteDoc/priceQuote/shipAddress/@state) , ",", $priceQuoteDoc/priceQuote/shipAddress/@zip) } + { + for $priceRequest in $priceQuoteDoc/priceQuote/priceRequests/priceRequest, + $availRequest in $availQuoteDoc/availQuote/availRequest + where data($priceRequest/widgetId) = data($availRequest/widgetId) + return + + { data($priceRequest/widgetId) } + { data($priceRequest/price) } + { data($availRequest/requestedQuantity) } + { data($availRequest/quantityAvail) } + { + for $shipDate in $availRequest/shipDate + return + { data($shipDate) } + } + { $taxRate } + { quoteCalculator:calculateTotalPrice( + $quoteCalculator, + + $taxRate, + + $availRequest/requestedQuantity, + + $priceRequest/price, + + $availRequest/quantityAvail) } + + } + +}; diff --git a/java/sca-contrib/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_properties.xq b/java/sca-contrib/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_properties.xq new file mode 100644 index 0000000000..cf41ab528d --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_properties.xq @@ -0,0 +1,74 @@ +(: + * 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. +:) + +declare namespace quoteJoin="scaservice:java/xquery.quote.PropertiesQuoteJoin"; + +declare namespace quoteCalculator="scareference:java/xquery.quote.QuoteCalculator"; + +declare namespace priceQuoteDoc="scaproperty:xml/http://www.example.org/price:priceQuote"; +declare namespace availQuoteDoc="scaproperty:xml/http://www.example.org/avail:availQuote"; +declare namespace taxRate="scaproperty:java/java.lang.Float"; + +declare namespace pri="http://www.example.org/price"; +declare namespace ava="http://www.example.org/avail"; +declare namespace quo="http://www.example.org/quote"; + +declare variable $quoteCalculator external; + +declare variable $priceQuoteDoc external; +declare variable $availQuoteDoc external; +declare variable $taxRate external; + +declare function quoteJoin:joinPriceAndAvailQuotes() { + + { data($priceQuoteDoc/pri:priceQuote/customerName) } + { concat($priceQuoteDoc/pri:priceQuote/shipAddress/@street , ",", + $priceQuoteDoc/pri:priceQuote/shipAddress/@city ,",", + fn:upper-case($priceQuoteDoc/pri:priceQuote/shipAddress/@state) , ",", + $priceQuoteDoc/pri:priceQuote/shipAddress/@zip) } + { + for $priceRequest in $priceQuoteDoc/pri:priceQuote/priceRequests/priceRequest, + $availRequest in $availQuoteDoc/ava:availQuote/availRequest + where data($priceRequest/widgetId) = data($availRequest/widgetId) + return + + { data($priceRequest/widgetId) } + { data($priceRequest/price) } + { data($availRequest/requestedQuantity) } + { data($availRequest/quantityAvail) } + { + for $shipDate in $availRequest/shipDate + return + { data($shipDate) } + } + { $taxRate } + { quoteCalculator:calculateTotalPrice( + $quoteCalculator, + + $taxRate, + + $availRequest/requestedQuantity, + + $priceRequest/price, + + $availRequest/quantityAvail) } + + } + +}; diff --git a/java/sca-contrib/samples/quote-xquery/src/main/resources/wsdl/AvailQuote.xsd b/java/sca-contrib/samples/quote-xquery/src/main/resources/wsdl/AvailQuote.xsd new file mode 100644 index 0000000000..e7f3e67068 --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/resources/wsdl/AvailQuote.xsd @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca-contrib/samples/quote-xquery/src/main/resources/wsdl/PriceQuote.xsd b/java/sca-contrib/samples/quote-xquery/src/main/resources/wsdl/PriceQuote.xsd new file mode 100644 index 0000000000..4c437586ef --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/resources/wsdl/PriceQuote.xsd @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca-contrib/samples/quote-xquery/src/main/resources/wsdl/Quote.xsd b/java/sca-contrib/samples/quote-xquery/src/main/resources/wsdl/Quote.xsd new file mode 100644 index 0000000000..4f64850056 --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/resources/wsdl/Quote.xsd @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca-contrib/samples/quote-xquery/src/main/resources/wsdl/quotejoin.wsdl b/java/sca-contrib/samples/quote-xquery/src/main/resources/wsdl/quotejoin.wsdl new file mode 100644 index 0000000000..96c2af138a --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/resources/wsdl/quotejoin.wsdl @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca-contrib/samples/quote-xquery/src/main/resources/xqueryquotews.composite b/java/sca-contrib/samples/quote-xquery/src/main/resources/xqueryquotews.composite new file mode 100644 index 0000000000..9e35e2ecb2 --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/resources/xqueryquotews.composite @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca-contrib/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite b/java/sca-contrib/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite new file mode 100644 index 0000000000..35306b9f89 --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + Acme Inc + + + + 12 + 1.0 + + + 134 + 34.1 + + + 211 + 10.0 + + + + + + + + + + 12 + 10 + true + 2003-03-22 + + + 134 + 345 + false + BackOrder + + + 211 + 100 + true + 2003-04-21 + + + + 0.1 + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca-contrib/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteClientTestCase.java b/java/sca-contrib/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteClientTestCase.java new file mode 100644 index 0000000000..9555532b3e --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteClientTestCase.java @@ -0,0 +1,192 @@ +/* + * 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 xquery.quote; + +import java.util.List; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.host.embedded.SCATestCaseRunner; +import org.example.avail.AvailQuote; +import org.example.avail.AvailRequest; +import org.example.price.PriceQuote; +import org.example.price.PriceRequest; +import org.example.price.ShipAddress; +import org.example.quote.Quote; +import org.example.quote.QuoteResponse; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import commonj.sdo.DataObject; + +/** + * Integration test for the XQuery implementation type + * @version $Rev$ $Date$ + * This test covers the most important integration scenarios for the xquery + * implementation type and its corresponding saxon data bindings: + * + * 1. There is a central component for invoking the different + * scenarios: QuoteJoinLocalComponent + * 2. It provides the following tests: + * - invoke XQuery component in the current assembly, by providing all needed + * information as input parameters + * - invoke XQuery component in external assembly, which is exposed as a web + * service + * - invoke XQuery component in the current assembly, which retrieves the needed + * information from the component properties + * - invoke XQuery component in the current assembly, which retrieves the needed + * information from its references to other components: + * - one of the components is in the current assembly + * - the other component is in anther assembly and it is exposed (and accessed) + * as web service + * + * 3. All of the XQuery components have reference to a component for calculation of the + * total price + * 4. SDO is used for data interchange + */ +public class XQueryQuoteClientTestCase { + + public static boolean SHOW_DEBUG_MSG = false; + + private SCADomain scaDomain; + private SCATestCaseRunner server; + + private QuoteJoinLocal quoteJoinLocal; + + @Before + public void startClient() throws Exception { + try { + scaDomain = SCADomain.newInstance("xqueryquotewsclient.composite"); + + quoteJoinLocal = scaDomain.getService(QuoteJoinLocal.class, "QuoteJoinLocalComponent"); + + server = new SCATestCaseRunner(XQueryQuoteTestServer.class); + server.before(); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @Test + public void testQuoteJoin() { + AvailQuote availQuote = QuoteDataUtil.buildAvailQuoteData(); + PriceQuote priceQuote = QuoteDataUtil.buildPriceQuoteData(); + + if (SHOW_DEBUG_MSG) { + System.out.println("Input quote for the price list:"); + QuoteDataUtil.serializeToSystemOut((DataObject)priceQuote, "priceQuote"); + System.out.println(); + System.out.println("Input quote for the availability:"); + QuoteDataUtil.serializeToSystemOut((DataObject)availQuote, "availQuote"); + System.out.println(); + } + + Quote quote = quoteJoinLocal.joinPriceAndAvailQuotes(priceQuote, availQuote, 0.1f); + if (SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from local join:"); + QuoteDataUtil.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + XQueryQuoteClientTestCase.assertQuote(availQuote, priceQuote, quote, 0.1f); + + quote = quoteJoinLocal.joinPriceAndAvailQuotes(priceQuote, availQuote, 0.2f); + if (SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from local join (second invokation):"); + QuoteDataUtil.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + XQueryQuoteClientTestCase.assertQuote(availQuote, priceQuote, quote, 0.2f); + + quote = quoteJoinLocal.joinPriceAndAvailQuotesWs(priceQuote, availQuote, 0.1f); + if (SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from web service join:"); + QuoteDataUtil.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + XQueryQuoteClientTestCase.assertQuote(availQuote, priceQuote, quote, 0.1f); + + quote = quoteJoinLocal.joinPriceAndAvailQuotes(); + if (SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from properties join:"); + QuoteDataUtil.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + XQueryQuoteClientTestCase.assertQuote(availQuote, priceQuote, quote, 0.1f); + + quote = quoteJoinLocal.joinPriceAndAvailQuotes(0.1f); + if (SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from external references join:"); + QuoteDataUtil.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + XQueryQuoteClientTestCase.assertQuote(availQuote, priceQuote, quote, 0.1f); + } + + @After + public void stopClient() throws Exception { + server.after(); + scaDomain.close(); + } + + public static void assertQuote(AvailQuote availQuote, PriceQuote priceQuote, Quote quote, float taxRate) { + QuoteCalculatorImpl quoteCalculatorImpl = new QuoteCalculatorImpl(); + + TestCase.assertEquals(priceQuote.getCustomerName(), quote.getName()); + ShipAddress shipAddress = priceQuote.getShipAddress(); + TestCase.assertEquals(shipAddress.getStreet() + "," + + shipAddress.getCity() + + "," + + shipAddress.getState().toUpperCase() + + "," + + shipAddress.getZip(), quote.getAddress()); + List availRequests = availQuote.getAvailRequest(); + List priceRequests = priceQuote.getPriceRequests().getPriceRequest(); + List quoteResponses = quote.getQuoteResponse(); + TestCase.assertEquals(availRequests.size(), priceRequests.size()); + TestCase.assertEquals(availRequests.size(), quoteResponses.size()); + + for (int i = 0; i < availRequests.size(); i++) { + AvailRequest availRequest = (AvailRequest)availRequests.get(i); + PriceRequest priceRequest = (PriceRequest)priceRequests.get(i); + QuoteResponse quoteResponse = (QuoteResponse)quoteResponses.get(i); + TestCase.assertEquals(availRequest.getWidgetId(), quoteResponse.getWidgetId()); + TestCase.assertEquals(priceRequest.getPrice(), quoteResponse.getUnitPrice()); + TestCase.assertEquals(availRequest.getRequestedQuantity(), quoteResponse.getRequestedQuantity()); + TestCase.assertEquals(availRequest.isQuantityAvail(), quoteResponse.isFillOrder()); + if (availRequest.getShipDate() == null) { + TestCase.assertNull(quoteResponse.getShipDate()); + } else { + TestCase.assertEquals(availRequest.getShipDate(), quoteResponse.getShipDate()); + } + TestCase.assertEquals(taxRate, quoteResponse.getTaxRate()); + TestCase.assertEquals(quoteCalculatorImpl.calculateTotalPrice(taxRate, + availRequest.getRequestedQuantity(), + priceRequest.getPrice(), + availRequest.isQuantityAvail()), + quoteResponse.getTotalCost()); + } + } +} diff --git a/java/sca-contrib/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteTestServer.java b/java/sca-contrib/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteTestServer.java new file mode 100644 index 0000000000..9a4be5bda6 --- /dev/null +++ b/java/sca-contrib/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteTestServer.java @@ -0,0 +1,50 @@ +/* + * 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 xquery.quote; + +import java.io.IOException; +import java.net.Socket; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class XQueryQuoteTestServer { + private SCADomain scaDomain; + + @Before + public void startServer() throws Exception { + try { + scaDomain = SCADomain.newInstance("xqueryquotews.composite"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Test + public void testPing() throws IOException { + new Socket("127.0.0.1", 8085); + } + + @After + public void stopServer() throws Exception { + scaDomain.close(); + } +} -- cgit v1.2.3