HibernateMappingTests.java ( File view )

  • By 2016-05-17
  • View(s):0
  • Download(s):0
  • Point(s): 1
			/*
 * Copyright (c) 2005 Chris Richardson
 * 
 * Licensed 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 net.chrisrichardson.ormunit.hibernate;

import java.util.Collections;
import java.util.Set;

import net.chrisrichardson.ormunit.PropertyNameSet;

import org.hibernate.MappingException;
import org.hibernate.PropertyNotFoundException;

/**
 * Base class for writing tests that make assertions about a Hibernate O/R
 * mapping document.
 * 
 * Note: This class been replaced by HibernateORMappingTests, which uses the term 'property' rather than field 
 * and by default, checks for property mappings rather than field mappings
 * 
 * @author cer
 * @see net.chrisrichardson.ormunit.HibernateORMappingTests
 * 
 */
public abstract class HibernateMappingTests extends AbstractORMappingTests {


	protected void onSetUp() throws Exception {

		super.onSetUp();
		mappingChecker.setAccessStrategy(AccessStrategy.FIELD);
	
}


	protected ComponentPropertyMapping getComponentFieldMapping(String propertyName)
			throws MappingException {

		return classChecker.getComponentPropertyMapping(propertyName);
	
}

	protected void assertAllFieldsMapped() throws MappingException {

		classChecker.assertAllPropertiesMappedExcept(Collections.EMPTY_SET);
	
}

	protected void assertAllFieldsMappedExcept(Set propertyNames)
			throws MappingException {

		classChecker.assertAllPropertiesMappedExcept(propertyNames);
	
}

	protected void assertCompositeListField(String propertyName)
			throws MappingException {

		classChecker.assertCompositeListProperty(propertyName);
	
}

	protected ListPropertyMapping assertListField(String propertyName)
			throws MappingException {

		return classChecker.assertListProperty(propertyName);
	
}

	protected CompositeListPropertyMapping getCompositeListFieldMapping(
			String propertyName) throws MappingException {

		return classChecker.getCompositeListPropertyMapping(propertyName);
	
}

	protected ListPropertyMapping getListFieldMapping(String propertyName)
			throws MappingException {

		return classChecker.getListPropertyMapping(propertyName);
	
}

	protected void assertComponentField(String propertyName)
			throws MappingException {

		classChecker.assertComponentProperty(propertyName);
	
}

	protected void assertSetField(String propertyName) throws MappingException {

		classChecker.assertSetProperty(propertyName);
	
}

	protected ToOnePropertyMapping assertManyToOneField(String propertyName,
			String foreignKeyColumnName) throws MappingException {

		return classChecker.assertManyToOneProperty(propertyName,
		foreignKeyColumnName);
	
}

	protected void assertVersionField(String propertyName, String columnName) {

		classChecker.assertVersionProperty(propertyName, columnName);
	
}

	protected void assertIdField(String idProperty, String idColumn)
			throws PropertyNotFoundException, MappingException {

		classChecker.assertIdProperty(idProperty, idColumn);
	
}

	protected void assertField(String propertyName, String columnName)
			throws MappingException {

		classChecker.assertProperty(propertyName, columnName);
	
}

	protected void assertField(String propertyName, String columnName,
			Class fieldType) {

		classChecker.assertProperty(propertyName, columnName, fieldType);
	
}

	protected void assertOneToManyListField(String propertyName,
			String foreignKeyColumn, String indexColumn)
			throws MappingException {

		classChecker.assertOneToManyListProperty(propertyName, foreignKeyColumn,
		indexColumn);
	
}

	protected void assertAllFieldsMappedExcept(String field1, String field2,
			String field3) throws MappingException {

		classChecker.assertAllPropertiesMappedExcept(field1, field2, field3);
	
}

	protected void assertAllFieldsMappedExcept(String field1, String field2)
			throws MappingException {

		classChecker.assertAllPropertiesMappedExcept(field1, field2);
	
}

	protected void assertAllFieldsMappedExcept(String field1)
			throws MappingException {

		classChecker.assertAllPropertiesMappedExcept(field1);
	
}

	protected CompositeSetPropertyMapping getCompositeSetFieldMapping(String propertyName) {

		return classChecker.getCompositeSetPropertyMapping(propertyName);
	
}

	protected PropertyNameSet makeFieldNameSet(Class type, String field) {

		return PropertyNameSet.makePropertyNameSet(type, field);
	
}

	protected void assertAllClassesMapped(PropertyNameSet set) {

		mappingChecker.assertAllClassesMapped(set.asSet());
	
}

	protected PropertyNameSet except(Class type, String name) {

		return PropertyNameSet.except(type, name);
	
}

	protected PropertyNameSet except(String propertyName) {

		return PropertyNameSet.except(propertyName);
	
}

	protected void assertAllFieldsMapped(PropertyNameSet set) {

		classChecker.assertAllPropertiesMappedExcept(set.asSet());
	
}


}			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 1

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
01.96 kB
pom.xml5.04 kB2007-04-27 13:43
dep.xml726.00 B2007-04-29 11:25
MANIFEST.MF39.00 B2007-03-25 15:17
ClassMappingException.java1.43 kB2007-03-25 15:17
AbstractORMappingTests.java1.54 kB2007-04-27 17:54
AccessStrategy.java789.00 B2007-04-27 17:54
ClassPropertyUtil.java2.01 kB2007-04-26 16:05
ComponentCollectionFieldMapping.java1.96 kB2007-04-27 13:43
ComponentPropertyMapping.java3.57 kB2007-04-27 13:43
CompositeListPropertyMapping.java1.67 kB2007-04-27 13:43
CompositeSetPropertyMapping.java1.05 kB2007-04-27 13:43
DatabaseInitializer.java134.00 B2007-03-25 15:17
DatabaseResetStrategy.java829.00 B2007-03-25 15:17
FieldMapping.java726.00 B2007-03-25 15:17
HibernateAssertUtil.java1.40 kB2007-04-27 13:43
HibernateMappingChecker.java1.34 kB2007-04-27 17:54
HibernateMappingTests.java5.27 kB2007-04-27 17:54
HibernateORMappingTests.java4.93 kB2007-04-27 17:54
HibernateORMTestCase.java1.80 kB2007-04-27 13:43
HibernatePersistenceTests.java4.28 kB2007-04-27 13:43
HibernatePersistenceTestsStrategy.java1.21 kB2007-04-27 13:43
HibernateSchemaChecker.java2.03 kB2007-04-27 13:43
HibernateSchemaTests.java1.36 kB2007-04-27 13:43
ListPropertyMapping.java2.37 kB2007-04-27 13:43
LocalSessionFactoryBeanUtil.java1.53 kB2007-03-25 15:17
MappedClassChecker.java13.11 kB2007-04-27 17:54
NoopDatabaseResetStrategy.java856.00 B2007-03-25 15:17
PathUtil.java1.49 kB2007-04-27 17:54
ResetDatabaseByRecreatingSchemaStrategy.java3.68 kB2007-03-25 15:17
RollbackTransactionHibernatePersistenceTestsStrategy.java2.42 kB2007-04-27 13:43
SimpleHibernatePersistenceTestsStrategy.java3.04 kB2007-04-27 13:43
ToOnePropertyMapping.java502.00 B2007-04-27 13:43
NonexistentPropertiesException.java1.25 kB2007-04-27 13:43
NonPersistentPropertyException.java1.20 kB2007-04-27 13:43
ORMUnitException.java927.00 B2007-03-25 15:17
ORMUnitMappingException.java962.00 B2007-03-25 15:17
PropertyNameSet.java1.33 kB2007-04-27 17:54
UnmappedPropertiesException.java1.31 kB2007-04-27 13:43
TxnCallback.java743.00 B2007-03-25 15:17
TxnCallbackWithResult.java755.00 B2007-03-25 15:17
Address.java1.47 kB2007-03-25 15:17
AddressWithProperties.java1.60 kB2007-04-26 13:33
BaseClass.java122.00 B2007-04-26 16:05
ClassWithUnmappedField.java785.00 B2007-03-25 15:17
ClassWithUnmappedProperty.java1,017.00 B2007-04-26 13:33
Customer.java1.21 kB2007-03-25 15:17
CustomerPersistenceTests.java1.80 kB2007-04-27 13:43
CustomerWithComponentAddress.java804.00 B2007-03-25 15:17
CustomerWithProperties.java574.00 B2007-04-26 13:33
CustomerWithPropertiesAndComponentAddress.java1.19 kB2007-04-26 13:33
ExampleMappingTests.java3.79 kB2007-04-27 13:43
ExampleWithPropertiesMappingTests.java4.25 kB2007-04-27 13:43
InheritanceTests.java1.94 kB2007-04-27 13:43
PointlessSchemaTests.java398.00 B2007-04-27 13:43
Subclass.java140.00 B2007-04-26 16:05
context.xml2.00 kB2007-03-25 15:17
contextWithProperties.xml2.02 kB2007-04-26 13:33
log4j.properties1.04 kB2007-03-25 15:17
example.hbm.xml1.41 kB2007-04-26 13:33
exampleWithProperties.hbm.xml1.52 kB2007-04-26 13:33
inheritanceOutsideOfHibernate.hbm.xml422.00 B2007-04-26 16:05
inheritanceUsingSubclass.hbm.xml559.00 B2007-04-26 16:05
01.96 kB
ormunit-hibernate-1.0-SNAPSHOT.jar49.43 kB2007-04-29 11:26
allclasses-frame.html7.33 kB2007-04-29 11:26
allclasses-noframe.html6.61 kB2007-04-29 11:26
constant-values.html5.24 kB2007-04-29 11:26
deprecated-list.html5.18 kB2007-04-29 11:26
help-doc.html9.77 kB2007-04-29 11:26
index-all.html105.10 kB2007-04-29 11:26
index.html1.42 kB2007-04-29 11:26
ClassMappingException.html6.04 kB2007-04-29 11:26
NonexistentPropertiesException.html6.13 kB2007-04-29 11:26
NonPersistentPropertyException.html6.13 kB2007-04-29 11:26
ORMUnitException.html9.69 kB2007-04-29 11:26
ORMUnitMappingException.html9.34 kB2007-04-29 11:26
PropertyNameSet.html19.14 kB2007-04-29 11:26
UnmappedPropertiesException.html6.10 kB2007-04-29 11:26
ClassMappingException.html13.09 kB2007-04-29 11:26
AbstractORMappingTests.html24.59 kB2007-04-29 11:26
AccessStrategy.html15.67 kB2007-04-29 11:26
AbstractORMappingTests.html8.78 kB2007-04-29 11:26
AccessStrategy.html14.86 kB2007-04-29 11:26
ClassPropertyUtil.html6.15 kB2007-04-29 11:26
ComponentCollectionFieldMapping.html8.77 kB2007-04-29 11:26
ComponentPropertyMapping.html9.76 kB2007-04-29 11:26
CompositeListPropertyMapping.html9.86 kB2007-04-29 11:26
CompositeSetPropertyMapping.html10.49 kB2007-04-29 11:26
DatabaseInitializer.html6.19 kB2007-04-29 11:26
DatabaseResetStrategy.html10.00 kB2007-04-29 11:26
FieldMapping.html8.46 kB2007-04-29 11:26
HibernateAssertUtil.html6.17 kB2007-04-29 11:26
HibernateMappingChecker.html8.38 kB2007-04-29 11:26
HibernateMappingTests.html6.19 kB2007-04-29 11:26
HibernateORMappingTests.html6.21 kB2007-04-29 11:26
HibernateORMTestCase.html10.33 kB2007-04-29 11:26
HibernatePersistenceTests.html6.23 kB2007-04-29 11:26
HibernatePersistenceTestsStrategy.html10.32 kB2007-04-29 11:26
HibernateSchemaChecker.html6.20 kB2007-04-29 11:26
HibernateSchemaTests.html6.18 kB2007-04-29 11:26
ListPropertyMapping.html14.53 kB2007-04-29 11:26
LocalSessionFactoryBeanUtil.html6.25 kB2007-04-29 11:26
MappedClassChecker.html9.40 kB2007-04-29 11:26
NoopDatabaseResetStrategy.html6.23 kB2007-04-29 11:26
PathUtil.html6.06 kB2007-04-29 11:26
ResetDatabaseByRecreatingSchemaStrategy.html6.37 kB2007-04-29 11:26
RollbackTransactionHibernatePersistenceTestsStrategy.html8.90 kB2007-04-29 11:26
SimpleHibernatePersistenceTestsStrategy.html6.37 kB2007-04-29 11:26
ToOnePropertyMapping.html10.53 kB2007-04-29 11:26
ClassPropertyUtil.html12.22 kB2007-04-29 11:26
ComponentCollectionFieldMapping.html15.50 kB2007-04-29 11:26
ComponentPropertyMapping.html16.16 kB2007-04-29 11:26
CompositeListPropertyMapping.html15.71 kB2007-04-29 11:26
CompositeSetPropertyMapping.html13.57 kB2007-04-29 11:26
DatabaseInitializer.html8.49 kB2007-04-29 11:26
DatabaseResetStrategy.html9.00 kB2007-04-29 11:26
FieldMapping.html12.08 kB2007-04-29 11:26
HibernateAssertUtil.html11.43 kB2007-04-29 11:26
HibernateMappingChecker.html13.26 kB2007-04-29 11:26
HibernateMappingTests.html45.05 kB2007-04-29 11:26
HibernateORMappingTests.html44.47 kB2007-04-29 11:26
HibernateORMTestCase.html19.56 kB2007-04-29 11:26
HibernatePersistenceTests.html31.88 kB2007-04-29 11:26
HibernatePersistenceTestsStrategy.html11.42 kB2007-04-29 11:26
HibernateSchemaChecker.html11.84 kB2007-04-29 11:26
HibernateSchemaTests.html19.65 kB2007-04-29 11:26
ListPropertyMapping.html17.05 kB2007-04-29 11:26
LocalSessionFactoryBeanUtil.html10.82 kB2007-04-29 11:26
MappedClassChecker.html31.44 kB2007-04-29 11:26
NoopDatabaseResetStrategy.html11.22 kB2007-04-29 11:26
package-frame.html5.50 kB2007-04-29 11:26
package-summary.html15.04 kB2007-04-29 11:26
package-tree.html14.34 kB2007-04-29 11:26
package-use.html11.65 kB2007-04-29 11:26
PathUtil.html12.76 kB2007-04-29 11:26
ResetDatabaseByRecreatingSchemaStrategy.html14.10 kB2007-04-29 11:26
RollbackTransactionHibernatePersistenceTestsStrategy.html16.54 kB2007-04-29 11:26
SimpleHibernatePersistenceTestsStrategy.html17.97 kB2007-04-29 11:26
ToOnePropertyMapping.html13.06 kB2007-04-29 11:26
NonexistentPropertiesException.html13.41 kB2007-04-29 11:26
NonPersistentPropertyException.html12.76 kB2007-04-29 11:26
ORMUnitException.html11.04 kB2007-04-29 11:26
ORMUnitMappingException.html12.00 kB2007-04-29 11:26
package-frame.html2.07 kB2007-04-29 11:26
package-summary.html8.28 kB2007-04-29 11:26
package-tree.html7.42 kB2007-04-29 11:26
package-use.html8.50 kB2007-04-29 11:26
PropertyNameSet.html17.07 kB2007-04-29 11:26
UnmappedPropertiesException.html13.12 kB2007-04-29 11:26
TxnCallback.html9.88 kB2007-04-29 11:26
TxnCallbackWithResult.html6.03 kB2007-04-29 11:26
package-frame.html1.18 kB2007-04-29 11:26
package-summary.html6.44 kB2007-04-29 11:26
package-tree.html6.13 kB2007-04-29 11:26
package-use.html6.80 kB2007-04-29 11:26
TxnCallback.html7.96 kB2007-04-29 11:26
TxnCallbackWithResult.html8.09 kB2007-04-29 11:26
options1.21 kB2007-04-29 11:26
overview-frame.html1.45 kB2007-04-29 11:26
overview-summary.html6.01 kB2007-04-29 11:26
overview-tree.html15.30 kB2007-04-29 11:26
package-list94.00 B2007-04-29 11:26
packages92.00 B2007-04-29 11:26
inherit.gif57.00 B2007-04-29 11:26
serialized-form.html11.13 kB2007-04-29 11:26
stylesheet.css1.20 kB2007-04-29 11:26
...
Sponsored links

HibernateMappingTests.java (316.73 kB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D