Java tutorial
/* * Copyright (c) 2007 NTT DATA Corporation * * 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 jp.terasoluna.fw.beans.jxpath; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertSame; import java.util.Locale; import org.apache.commons.jxpath.JXPathBasicBeanInfo; import org.apache.commons.jxpath.JXPathBeanInfo; import org.apache.commons.jxpath.ri.QName; import org.apache.commons.jxpath.ri.model.NodePointer; import org.apache.commons.jxpath.ri.model.beans.PropertyPointer; import org.junit.Test; import org.springframework.test.util.ReflectionTestUtils; /** * {@link jp.terasoluna.fw.beans.jxpath.BeanPointerEx} ? * <p> * <h4>???</h4> Bean??<br> * ???? * <p> * @see jp.terasoluna.fw.beans.jxpath.BeanPointerEx */ public class BeanPointerExTest { /** * testBeanPointerExQname01() <br> * <br> * () <br> * A <br> * <br> * () name:not null<br> * () bean:new Object()<br> * () beanInfo:not null<br> * () locale:Locale("ja")<br> * () this.beanInfo:null<br> * <br> * () this.beanInfo:???<br> * <br> * ?? <br> * @throws Exception ????? */ @Test public void testBeanPointerExQname01() throws Exception { // ?? QName qName = new QName("name"); Object bean = new Object(); JXPathBeanInfo beanInfo = new JXPathBasicBeanInfo(bean.getClass()); Locale locale = new Locale("ja"); // BeanPointerEx result = new BeanPointerEx(qName, bean, beanInfo, locale); // assertEquals(beanInfo, ReflectionTestUtils.getField(result, "beanInfo")); } /** * testBeanPointerExNodePointer01() <br> * <br> * () <br> * A <br> * <br> * () parent:not null<br> * () name:not null<br> * () bean:new Object()<br> * () beanInfo:not null<br> * () this.beanInfo:null<br> * <br> * () this.beanInfo:???<br> * <br> * ?? <br> * @throws Exception ????? */ @Test public void testBeanPointerExNodePointer01() throws Exception { // ?? QName qName = new QName("name"); Object bean = new Object(); JXPathBeanInfo beanInfo = new JXPathBasicBeanInfo(bean.getClass()); Locale locale = new Locale("ja"); NodePointer nodePointer = NodePointer.newNodePointer(qName, bean, locale); // BeanPointerEx result = new BeanPointerEx(nodePointer, qName, bean, beanInfo); // assertEquals(beanInfo, ReflectionTestUtils.getField(result, "beanInfo")); } /** * testGetPropertyPointer01() <br> * <br> * () <br> * A <br> * <br> * () this.beanInfo:not null<br> * <br> * () PropertyPointer:new BeanPropertyPointerEx{<br> * parent=this<br> * beanInfo=?????beanInfo<br> * }<br> * <br> * ???? <br> * @throws Exception ????? */ @Test public void testGetPropertyPointer01() throws Exception { // ?? QName qName = new QName("name"); Object bean = new Object(); JXPathBeanInfo beanInfo = new JXPathBasicBeanInfo(bean.getClass()); Locale locale = new Locale("ja"); BeanPointerEx beanPointer = new BeanPointerEx(qName, bean, beanInfo, locale); // PropertyPointer result = beanPointer.getPropertyPointer(); // assertSame(BeanPropertyPointerEx.class, result.getClass()); assertSame(beanPointer, result.getParent()); assertSame(beanInfo, ReflectionTestUtils.getField(result, "beanInfo")); } }