Author: arminw
Date: Mon Oct 29 18:21:49 2007
New Revision: 589925
URL: http://svn.apache.org/viewvc?rev=589925&view=rev
Log:
add tests
Modified:
db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/metadata/MetadataTest.java
db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/metadata/PersistentFieldTest.java
Modified:
db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/metadata/MetadataTest.java
URL:
http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/metadata/MetadataTest.java?rev=589925&r1=589924&r2=589925&view=diff
==============================================================================
---
db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/metadata/MetadataTest.java
(original)
+++
db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/metadata/MetadataTest.java
Mon Oct 29 18:21:49 2007
@@ -71,6 +71,31 @@
super.tearDown();
}
+ public void testToString() throws Exception
+ {
+ MetadataManager mm = MetadataManager.getInstance();
+ DescriptorRepository dr = mm.getRepository();
+ dr.toString();
+ Iterator it = dr.iterator();
+ while(it.hasNext())
+ {
+ ClassDescriptor cld = (ClassDescriptor) it.next();
+ cld.toString();
+ FieldDescriptor[] fields = cld.getFieldDescriptor(true);
+ if(fields != null)
+ {
+ for(int i = 0; i < fields.length; i++)
+ {
+ FieldDescriptor field = fields[i];
+ //System.out.println(field.toString());
+ field.toString();
+
//System.out.println(field.getPersistentField().toString());
+ field.getPersistentField().toString();
+ }
+ }
+ }
+ }
+
public void testReadRepository_1() throws Exception
{
MetadataManager mm = MetadataManager.getInstance();
Modified:
db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/metadata/PersistentFieldTest.java
URL:
http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/metadata/PersistentFieldTest.java?rev=589925&r1=589924&r2=589925&view=diff
==============================================================================
---
db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/metadata/PersistentFieldTest.java
(original)
+++
db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/metadata/PersistentFieldTest.java
Mon Oct 29 18:21:49 2007
@@ -1,5 +1,24 @@
package org.apache.ojb.broker.metadata;
+/*
+ * 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.
+ */
+
import java.util.Collection;
import org.apache.commons.beanutils.BasicDynaClass;
@@ -21,31 +40,10 @@
import org.apache.ojb.broker.util.configuration.impl.OjbConfigurator;
import org.apache.ojb.junit.OJBTestCase;
-/*
- * 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.
- */
-
-
/**
* Test to check the capability of the [EMAIL PROTECTED]
org.apache.ojb.broker.metadata.fieldaccess.PersistentField}
* implementations.
*
- * @author <a href="mailto:[EMAIL PROTECTED]">Armin Waibel</a>
* @version $Id$
*/
public class PersistentFieldTest extends OJBTestCase
@@ -78,6 +76,72 @@
super.tearDown();
((OjbConfiguration) OjbConfigurator.getInstance()
.getConfigurationFor(null)).setPersistentFieldClass(oldPFClass);
+ }
+
+ public void testProvokeError()
+ {
+ TestObj obj = new TestObj(new Integer(17), "name", 33, "value");
+ // test for exception
+ try
+ {
+ PersistentField pf_NotExist = new
PersistentFieldDirectImpl(TestObj.class, "not_exist");
+ pf_NotExist.getType();
+ pf_NotExist.get(obj);
+ fail("Expect error for invalid field");
+ }
+ catch(Exception expected)
+ {
+ //expected.printStackTrace();
+ // is expected
+ }
+
+ try
+ {
+ PersistentField pf_NotExist = new
PersistentFieldCGLibImpl(TestObj.class, "not_exist");
+ pf_NotExist.get(obj);
+ fail("Expect error for invalid field");
+ }
+ catch(Exception expected)
+ {
+ //expected.printStackTrace();
+ // is expected
+ }
+
+ try
+ {
+ PersistentField pf_NotExist = new
PersistentFieldIntrospectorImpl(TestObj.class, "not_exist");
+ pf_NotExist.get(obj);
+ fail("Expect error for invalid field");
+ }
+ catch(Exception expected)
+ {
+ //expected.printStackTrace();
+ // is expected
+ }
+
+ try
+ {
+ PersistentField pf_NotExist = new
PersistentFieldPrivilegedImpl(TestObj.class, "not_exist");
+ pf_NotExist.get(obj);
+ fail("Expect error for invalid field");
+ }
+ catch(Exception expected)
+ {
+ //expected.printStackTrace();
+ // is expected
+ }
+
+ try
+ {
+ PersistentField pf_NotExist = new
PersistentFieldAutoProxyImpl(TestObj.class, "not_exist");
+ pf_NotExist.get(obj);
+ fail("Expect error for invalid field");
+ }
+ catch(Exception expected)
+ {
+ //expected.printStackTrace();
+ // is expected
+ }
}
private void runFieldTestsFor(Class targetClass, boolean
supportJavaBeanNames) throws Exception
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]