コード例 #1
0
 public void testGetSql() throws Exception {
   BeanDesc beanDesc = BeanDescFactory.getBeanDesc(getDaoClass("AnnotationTestDaoImpl"));
   DaoAnnotationReader reader = readerFactory.createDaoAnnotationReader(beanDesc);
   Method method1 = beanDesc.getMethods("subclassMethod2")[0];
   String sql = reader.getSQL(method1, "mysql");
   assertEquals("1", "SELECT * FROM emp", sql);
 }
コード例 #2
0
 public void testGetQuery() throws Exception {
   BeanDesc beanDesc = BeanDescFactory.getBeanDesc(getDaoClass("AnnotationTestDaoImpl"));
   DaoAnnotationReader reader = readerFactory.createDaoAnnotationReader(beanDesc);
   Method method1 = beanDesc.getMethods("withQueryAnnotaion")[0];
   String queryq = reader.getQuery(method1);
   assertEquals("1", "arg1 = /*arg1*/'dummy'", queryq);
   // return null if QUERY annotation not found
   Method method2 = beanDesc.getMethods("withNoAnnotaion")[0];
   String query2 = reader.getQuery(method2);
   assertNull("1", query2);
   // annotationReader must read subclass annotation
   Method method3 = beanDesc.getMethods("subclassMethod")[0];
   String[] names3 = reader.getArgNames(method3);
   assertEquals("3", 1, names3.length);
 }
コード例 #3
0
 public void testGetArgNames() throws Exception {
   BeanDesc beanDesc = BeanDescFactory.getBeanDesc(getDaoClass("AnnotationTestDaoImpl"));
   DaoAnnotationReader reader = readerFactory.createDaoAnnotationReader(beanDesc);
   assertEquals("1", Employee.class, reader.getBeanClass());
   Method method = beanDesc.getMethods("withArgumentAnnotaion")[0];
   String[] names = reader.getArgNames(method);
   assertEquals("2", 2, names.length);
   assertEquals("2", "arg1", names[0]);
   assertEquals("2", "arg2", names[1]);
   // getArgNames return 0 length array if args annotation is not
   // specified.
   Method method2 = beanDesc.getMethods("withNoAnnotaion")[0];
   String[] names2 = reader.getArgNames(method2);
   assertEquals("3", 0, names2.length);
   // annotationReader must read subclass annotation
   Method method3 = beanDesc.getMethods("subclassMethod")[0];
   String[] names3 = reader.getArgNames(method3);
   assertEquals("3", 1, names3.length);
 }
コード例 #4
0
 public void testGetNoPersistentProps() throws Exception {
   BeanDesc beanDesc = BeanDescFactory.getBeanDesc(getDaoClass("AnnotationTestDaoImpl"));
   DaoAnnotationReader reader = readerFactory.createDaoAnnotationReader(beanDesc);
   Method method1 = beanDesc.getMethods("withNoPersistentProps")[0];
   String[] props1 = reader.getNoPersistentProps(method1);
   assertEquals("1", 2, props1.length);
   assertEquals("1", "prop1", props1[0]);
   assertEquals("1", "prop2", props1[1]);
   // return null if QUERY annotation not found
   Method method2 = beanDesc.getMethods("withNoAnnotaion")[0];
   String[] props2 = reader.getNoPersistentProps(method2);
   assertNull("2", props2);
   // annotationReader must read subclass annotation
   Method method3 = beanDesc.getMethods("subclassMethod2")[0];
   String[] props3 = reader.getNoPersistentProps(method3);
   assertEquals("1", 2, props3.length);
   assertEquals("1", "prop1", props3[0]);
   assertEquals("1", "prop2", props3[1]);
 }
コード例 #5
0
 public void testGetNullBean() {
   BeanDesc beanDesc = BeanDescFactory.getBeanDesc(getDaoClass("DummyDao"));
   DaoAnnotationReader reader = readerFactory.createDaoAnnotationReader(beanDesc);
   assertEquals(NullBean.class, reader.getBeanClass());
 }
コード例 #6
0
 public void testGetBean() {
   BeanDesc beanDesc1 = BeanDescFactory.getBeanDesc(getDaoClass("AnnotationTestDaoImpl"));
   DaoAnnotationReader reader1 = readerFactory.createDaoAnnotationReader(beanDesc1);
   assertEquals(Employee.class, reader1.getBeanClass());
 }