Source Code Cross Referenced for ReferenceResolverTest.java in  » Database-ORM » jaxor-3.5 » net » sourceforge » jaxor » tests » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database ORM » jaxor 3.5 » net.sourceforge.jaxor.tests 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sourceforge.jaxor.tests;
002:
003:        import junit.framework.TestCase;
004:        import net.sourceforge.jaxor.JaxorContextImpl;
005:        import net.sourceforge.jaxor.MetaRow;
006:        import net.sourceforge.jaxor.QueryParams;
007:        import net.sourceforge.jaxor.ReferenceResolver;
008:        import net.sourceforge.jaxor.EntityRow;
009:        import net.sourceforge.jaxor.MetaField;
010:        import net.sourceforge.jaxor.mappers.FieldAdapterImpl;
011:        import net.sourceforge.jaxor.mappers.StringMapper;
012:        import net.sourceforge.jaxor.api.*;
013:        import net.sourceforge.jaxor.example.db.HyperConnection;
014:        import net.sourceforge.jaxor.example.domain.*;
015:
016:        import java.sql.ResultSet;
017:        import java.util.List;
018:
019:        /*
020:         * User: Mike
021:         * Date: Sep 2, 2003
022:         * Time: 9:15:39 PM
023:         */
024:
025:        public class ReferenceResolverTest extends TestCase {
026:
027:            private static final AddressEntity address = new AddressImpl();
028:            private static final AddressMetaRow meta = new AddressMetaRow();
029:            private static final Long ADDRESS_ID = new Long(1);
030:            private MockCustomer customer;
031:            private static final String BASE_SQL = "where address_ID=?";
032:
033:            protected void setUp() throws Exception {
034:                customer = new MockCustomer("table");
035:            }
036:
037:            public void testGetSql() {
038:                ReferenceResolver resolver = createResolver();
039:                resolver.add(meta.getCity(), meta.getCity());
040:                assertEquals("where address_ID=? AND city=?", resolver
041:                        .createFindSql());
042:            }
043:
044:            public void testResolvingWithNoContext() {
045:                CustomerEntity cust = new CustomerBase();
046:                assertNull(cust.getAddressEntity());
047:            }
048:
049:            private ReferenceResolver createResolver() {
050:                JaxorContextImpl conn = new JaxorContextImpl(
051:                        HyperConnection.INSTANCE);
052:                customer.setJaxorContext(conn);
053:                ReferenceResolver resolver = new ReferenceResolver(
054:                        MockAddressFinder.class, customer, true);
055:                resolver.add(meta.getAddressId(), meta.getAddressId());
056:                assertEquals(BASE_SQL, resolver.createFindSql());
057:                return resolver;
058:            }
059:
060:            public void testGettingBeanValues() {
061:                ReferenceResolver resolver = createResolver();
062:                assertEquals(resolver.getValue("AddressId"), ADDRESS_ID);
063:            }
064:
065:            public void testResolving() {
066:                ReferenceResolver resolver = createResolver();
067:                assertTrue(address == resolver.getObject());
068:            }
069:
070:            private class MockCustomer extends EntityRow {
071:
072:                public MockCustomer(String table) {
073:                    super (table);
074:                    MetaField metaData = new MetaField("AddressId",
075:                            "AddressId", false, true, false, false,
076:                            StringMapper.class);
077:                    FieldAdapter field = new FieldAdapterImpl(metaData, null);
078:                    field.setValue(ADDRESS_ID);
079:                    setFields(new FieldAdapter[] { field });
080:                }
081:            }
082:
083:            public static class MockAddressFinder implements  FinderAdapter,
084:                    Finder {
085:
086:                public MockAddressFinder(JaxorContext conn) {
087:
088:                }
089:
090:                public EntityInterface newInstance() {
091:                    return null;
092:                }
093:
094:                public MetaRow getMetaRow() {
095:                    return null;
096:                }
097:
098:                public Finder getFinder() {
099:                    return this ;
100:                }
101:
102:                public String getBaseQuerySQL() {
103:                    return null;
104:                }
105:
106:                public EntityInterface load(ResultSet rs) {
107:                    return null;
108:                }
109:
110:                public void registerNew(EntityInterface entity) {
111:                }
112:
113:                public boolean entityExists(QueryParams ps) {
114:                    return false;
115:                }
116:
117:                public List selectAll() {
118:                    return null;
119:                }
120:
121:                public QueryResult query(String sql) {
122:                    return null;
123:                }
124:
125:                public QueryResult query(String sql, QueryParams args) {
126:                    return null;
127:                }
128:
129:                public QueryResult find(String whereClause) {
130:                    return null;
131:                }
132:
133:                public QueryResult find(String whereClause, QueryParams p) {
134:                    assertEquals(BASE_SQL, whereClause);
135:                    return new QueryResult() {
136:                        public List list() {
137:                            return null;
138:                        }
139:
140:                        public String getSQL() {
141:                            return "";
142:                        }
143:
144:                        public EntityResultSet resultSet() {
145:                            return null;
146:                        }
147:
148:                        public EntityInterface entity() {
149:                            return address;
150:                        }
151:
152:                        public EntityInterface entityProxy() {
153:                            return null;
154:                        }
155:
156:                        public QueryParams getParams() {
157:                            return new QueryParams();
158:                        }
159:
160:                        public JaxorPreparedStatement preparedStatement() {
161:                            return null;
162:                        }
163:
164:                    };
165:                }
166:
167:                public EntityInterface selectByPrimaryKey(QueryParams key,
168:                        boolean lazy) {
169:                    return null;
170:                }
171:            }
172:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.