001/* 002 * Copyright (c) 2004-2012, Willem Cazander 003 * All rights reserved. 004 * 005 * Redistribution and use in source and binary forms, with or without modification, are permitted provided 006 * that the following conditions are met: 007 * 008 * * Redistributions of source code must retain the above copyright notice, this list of conditions and the 009 * following disclaimer. 010 * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 011 * the following disclaimer in the documentation and/or other materials provided with the distribution. 012 * 013 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 014 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 015 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 016 * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 017 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 018 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 019 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 020 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 021 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 022 */ 023 024package org.x4o.xml.core; 025 026import org.x4o.xml.core.config.X4OLanguagePropertyKeys; 027import org.x4o.xml.test.TestParser; 028import org.x4o.xml.test.models.TestBean; 029 030import junit.framework.TestCase; 031 032/** 033 * Tests a simple x4o xml language. 034 * 035 * @author Willem Cazander 036 * @version 1.0 Jul 24, 2006 037 */ 038public class AttributeBeanTest extends TestCase { 039 040 public void testBeanProperties() throws Exception { 041 TestParser parser = new TestParser(); 042 parser.setProperty(X4OLanguagePropertyKeys.PHASE_SKIP_RELEASE, true); 043 try { 044 parser.parseResource("tests/attributes/test-bean.xml"); 045 TestBean b = (TestBean)parser.getElementLanguage().getRootElement().getChilderen().get(1).getElementObject(); 046 047 assertEquals(123 ,0+ b.getPrivateIntegerTypeField()); 048 assertEquals(123 ,0+ b.getPrivateIntegerObjectField()); 049 050 assertEquals(123l ,0+ b.getPrivateLongTypeField()); 051 assertEquals(123l ,0+ b.getPrivateLongObjectField()); 052 053 assertEquals(123.45d ,0+ b.getPrivateDoubleTypeField()); 054 assertEquals(123.45d ,0+ b.getPrivateDoubleObjectField()); 055 056 assertEquals(123.45f ,0+ b.getPrivateFloatTypeField()); 057 assertEquals(123.45f ,0+ b.getPrivateFloatObjectField()); 058 059 assertEquals(67 ,0+ b.getPrivateByteTypeField()); 060 assertEquals(67 ,0+ b.getPrivateByteObjectField()); 061 062 assertEquals(true, b.isPrivateBooleanTypeField()); 063 assertEquals(new Boolean(true), b.getPrivateBooleanObjectField()); 064 065 assertEquals('W' ,0+ b.getPrivateCharTypeField()); 066 assertEquals('C' ,0+ b.getPrivateCharObjectField()); 067 068 assertEquals("x4o" ,b.getPrivateStringObjectField()); 069 //TODO: add again: assertEquals(true ,null!=b.getPrivateDateObjectField()); 070 } finally { 071 parser.doReleasePhaseManual(); 072 } 073 } 074}