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.ri.QName; import org.apache.commons.jxpath.ri.model.NodePointer; import org.apache.commons.jxpath.ri.model.beans.NullPointer; import org.junit.Test; import org.springframework.test.util.ReflectionTestUtils; /** * {@link jp.terasoluna.fw.beans.jxpath.BeanPointerFactoryEx} ? * <p> * <h4>???</h4> Bean??<br> * ???? * <p> * @see jp.terasoluna.fw.beans.jxpath.BeanPointerFactoryEx */ public class BeanPointerFactoryExTest { /** * testGetOrder01() <br> * <br> * () <br> * A <br> * <br> * <br> * () -:850<br> * <br> * ??? <br> * @throws Exception ????? */ @Test public void testGetOrder01() throws Exception { // ?? BeanPointerFactoryEx factory = new BeanPointerFactoryEx(); // assertEquals(850, factory.getOrder()); } /** * testCreateNodePointerQname01() <br> * <br> * () <br> * A <br> * <br> * () name:not null<br> * () bean:new Object()<br> * () locale:Locale("ja")<br> * <br> * () NodePointer:new BeanPointerEX {<br> * locale=?locale<br> * name=?name<br> * bean=?bean<br> * }<br> * <br> * ??? <br> * @throws Exception ????? */ @Test public void testCreateNodePointerQname01() throws Exception { // ?? BeanPointerFactoryEx factory = new BeanPointerFactoryEx(); QName qName = new QName("name"); Object bean = new Object(); Locale locale = new Locale("ja"); // NodePointer result = factory.createNodePointer(qName, bean, locale); // assertSame(BeanPointerEx.class, result.getClass()); assertSame(locale, result.getLocale()); assertSame(qName, result.getName()); assertSame(bean, ReflectionTestUtils.getField(result, "bean")); } /** * testCreateNodePointerNodePointer01() <br> * <br> * () <br> * C <br> * <br> * () parent:not null<br> * () name:not null<br> * () bean:null<br> * <br> * () NodePointer:new NullPointer {<br> * parent=?parent<br> * name=?name<br> * }<br> * <br> * ?null??? <br> * @throws Exception ????? */ @Test public void testCreateNodePointerNodePointer01() throws Exception { // ?? BeanPointerFactoryEx factory = new BeanPointerFactoryEx(); QName qName = new QName("name"); Locale locale = new Locale("ja"); NodePointer nodePointer = NodePointer.newNodePointer(qName, null, locale); // NodePointer result = factory.createNodePointer(nodePointer, qName, null); // assertSame(NullPointer.class, result.getClass()); assertSame(nodePointer, result.getParent()); assertSame(qName, result.getName()); } /** * testCreateNodePointerNodePointer02() <br> * <br> * () <br> * A <br> * <br> * () parent:not null<br> * () name:not null<br> * () bean:new Object()<br> * <br> * () NodePointer:new BeanPointerEX {<br> * parent=?parent<br> * name=?name<br> * bean=?bean<br> * }<br> * <br> * ?null?????? <br> * @throws Exception ????? */ @Test public void testCreateNodePointerNodePointer02() throws Exception { // ?? BeanPointerFactoryEx factory = new BeanPointerFactoryEx(); QName qName = new QName("name"); Object bean = new Object(); Locale locale = new Locale("ja"); NodePointer nodePointer = NodePointer.newNodePointer(qName, bean, locale); // NodePointer result = factory.createNodePointer(nodePointer, qName, bean); // assertSame(BeanPointerEx.class, result.getClass()); assertSame(nodePointer, result.getParent()); assertSame(qName, result.getName()); assertSame(bean, ReflectionTestUtils.getField(result, "bean")); } }