Methods Summary |
---|
private org.hibernate.mapping.Property | generateAccountIdProperty()
SimpleValue value = new SimpleValue();
value.setTypeName( "long" );
Property property = new Property();
property.setName( "number" );
property.setNodeName( "account/@num" );
property.setValue( value );
return property;
|
private org.hibernate.mapping.Property | generateIdProperty()
SimpleValue value = new SimpleValue();
value.setTypeName( "long" );
Property property = new Property();
property.setName( "id" );
property.setNodeName( "@id" );
property.setValue( value );
return property;
|
private org.hibernate.mapping.Property | generateNameProperty()
SimpleValue value = new SimpleValue();
value.setTypeName( "string" );
Property property = new Property();
property.setName( "name" );
property.setNodeName( "name" );
property.setValue( value );
return property;
|
private static org.dom4j.Element | generateRootTestElement()
return DocumentFactory.getInstance().createElement( "company" );
|
private static org.dom4j.Element | generateTestElement()
Element company = generateRootTestElement();
company.addAttribute( "id", "123" );
company.setText( "description..." );
company.addElement( "name" ).setText( "JBoss" );
company.addElement( "account" ).addAttribute( "num", "456" );
return company;
|
private org.hibernate.mapping.Property | generateTextProperty()
SimpleValue value = new SimpleValue();
value.setTypeName( "string" );
Property property = new Property();
property.setName( "text" );
property.setNodeName( "." );
property.setValue( value );
return property;
|
private org.hibernate.engine.SessionFactoryImplementor | getSFI()
return null;
|
public static junit.framework.Test | suite()
return new TestSuite( Dom4jAccessorTest.class );
|
public void | testCompanyElementGeneration()
Setter idSetter = PropertyAccessorFactory.getPropertyAccessor( generateIdProperty(), EntityMode.DOM4J )
.getSetter( null, null );
Setter nameSetter = PropertyAccessorFactory.getPropertyAccessor( generateNameProperty(), EntityMode.DOM4J )
.getSetter( null, null );
Setter textSetter = PropertyAccessorFactory.getPropertyAccessor( generateTextProperty(), EntityMode.DOM4J )
.getSetter( null, null );
Setter accountIdSetter = PropertyAccessorFactory.getPropertyAccessor(
generateAccountIdProperty(), EntityMode.DOM4J
)
.getSetter( null, null );
Element root = generateRootTestElement();
idSetter.set( root, new Long( 123 ), getSFI() );
textSetter.set( root, "description...", getSFI() );
nameSetter.set( root, "JBoss", getSFI() );
accountIdSetter.set( root, new Long( 456 ), getSFI() );
assertTrue( "DOMs not equal", new NodeComparator().compare( DOM, root ) == 0 );
|
public void | testLongAttributeExtraction()
Property property = generateIdProperty();
Getter getter = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.DOM4J )
.getGetter( null, null );
Long id = ( Long ) getter.get( DOM );
assertEquals( "Not equals", new Long( 123 ), id );
|
public void | testLongElementAttributeExtraction()
Property property = generateAccountIdProperty();
Getter getter = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.DOM4J )
.getGetter( null, null );
Long id = ( Long ) getter.get( DOM );
assertEquals( "Not equals", new Long( 456 ), id );
|
public void | testStringElementExtraction()
Property property = generateNameProperty();
Getter getter = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.DOM4J )
.getGetter( null, null );
String name = ( String ) getter.get( DOM );
assertEquals( "Not equals", "JBoss", name );
|
public void | testStringTextExtraction()
Property property = generateTextProperty();
Getter getter = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.DOM4J )
.getGetter( null, null );
String name = ( String ) getter.get( DOM );
assertEquals( "Not equals", "description...", name );
|