/home/mario/oci/jnb/dataaccess/source/test/java/com/ociweb/service/MockQueryFactory.java
|
1 /**
2 * This software program, Simple Data Access Layer (SDAL), is copyrighted by Object
3 * Computing inc of St. Louis MO USA. It is provided under the open-source model
4 * and is free of license fees. You are free to modify this code for your own use
5 * but you may not claim copyright.
6 *
7 * Since SDAL is open source and free of licensing fees, you are free to use,
8 * modify, and distribute the source code, as long as you include this copyright
9 * statement.
10 *
11 * In particular, you can use SDAL to build proprietary software and are under no
12 * obligation to redistribute any of your source code that is built using SDAL.
13 * Note, however, that you may not do anything to the SDAL code, such as
14 * copyrighting it yourself or claiming authorship of the SDAL code, that will
15 * prevent SDAL from being distributed freely using an open source development
16 * model.
17 *
18 * Warranty
19 * LICENSED PRODUCT, SDAL, IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
20 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE,
21 * NONINFRINGEMENT, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
22 *
23 * Support
24 * LICENSED PRODUCT, SDAL, IS PROVIDED WITH NO SUPPORT AND WITHOUT ANY OBLIGATION ON THE
25 * PART OF OCI OR ANY OF ITS SUBSIDIARIES OR AFFILIATES TO ASSIST IN ITS USE,
26 * CORRECTION, MODIFICATION OR ENHANCEMENT.
27 *
28 * Support may be available from OCI to users who have agreed to a support
29 * contract.
30 *
31 * Liability
32 * OCI OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH
33 * RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY
34 * LICENSED PRODUCT OR ANY PART THEREOF.
35 *
36 * IN NO EVENT WILL OCI OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR ANY
37 * LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL DAMAGES,
38 * EVEN IF OCI HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
39 *
40 * Copyright OCI. St. Louis MO USA, 2004
41 *
42 */
43 package com.ociweb.service;
44
45 public class MockQueryFactory implements QueryFactory {
46
47 public boolean newQueryCalled;
48 public com.ociweb.service.Query newQueryReturn;
49 public Throwable newQueryException;
50 public java.lang.String newQueryQuery;
51 public com.ociweb.service.Query newQuery(java.lang.String query) throws com.ociweb.service.LookupException {
52 newQueryCalled = true;
53 this.newQueryQuery = query;
54 if (newQueryException != null) {
55 if (newQueryException instanceof com.ociweb.service.LookupException)
56 throw (com.ociweb.service.LookupException) newQueryException;
57 if (newQueryException instanceof java.lang.RuntimeException)
58 throw (java.lang.RuntimeException) newQueryException;
59 if (newQueryException instanceof java.lang.Error)
60 throw (java.lang.Error) newQueryException;
61 throw new RuntimeException();
62 }
63 return this.newQueryReturn;
64 }
65
66 public boolean getNamedQueryCalled;
67 public com.ociweb.service.Query getNamedQueryReturn;
68 public Throwable getNamedQueryException;
69 public java.lang.String getNamedQueryName;
70 public com.ociweb.service.Query getNamedQuery(java.lang.String name) throws com.ociweb.service.LookupException {
71 getNamedQueryCalled = true;
72 this.getNamedQueryName = name;
73 if (getNamedQueryException != null) {
74 if (getNamedQueryException instanceof com.ociweb.service.LookupException)
75 throw (com.ociweb.service.LookupException) getNamedQueryException;
76 if (getNamedQueryException instanceof java.lang.RuntimeException)
77 throw (java.lang.RuntimeException) getNamedQueryException;
78 if (getNamedQueryException instanceof java.lang.Error)
79 throw (java.lang.Error) getNamedQueryException;
80 throw new RuntimeException();
81 }
82 return this.getNamedQueryReturn;
83 }
84
85 public boolean newCriteriaQueryCalled;
86 public com.ociweb.service.CriteriaQuery newCriteriaQueryReturn;
87 public Throwable newCriteriaQueryException;
88 public java.lang.Class newCriteriaQueryDomainClass;
89 public com.ociweb.service.CriteriaQuery newCriteriaQuery(java.lang.Class domainClass) {
90 newCriteriaQueryCalled = true;
91 this.newCriteriaQueryDomainClass = domainClass;
92 if (newCriteriaQueryException != null) {
93 if (newCriteriaQueryException instanceof java.lang.RuntimeException)
94 throw (java.lang.RuntimeException) newCriteriaQueryException;
95 if (newCriteriaQueryException instanceof java.lang.Error)
96 throw (java.lang.Error) newCriteriaQueryException;
97 throw new RuntimeException();
98 }
99 return this.newCriteriaQueryReturn;
100 }
101
102 }