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 java.util.HashMap; import java.util.Locale; import java.util.Map; import org.apache.commons.jxpath.DynamicPropertyHandler; import org.apache.commons.jxpath.MapDynamicPropertyHandler; import org.apache.commons.jxpath.ri.QName; import org.apache.commons.jxpath.ri.model.NodePointer; import org.junit.Test; /** * {@link jp.terasoluna.fw.beans.jxpath.DynamicPropertyPointerEx} ? * * <p> * <h4>???</h4> * null????Map?<br> * ???? * <p> * * @see jp.terasoluna.fw.beans.jxpath.DynamicPropertyPointerEx */ public class DynamicPropertyPointerExTest { /** * testGetLength01() * <br><br> * * () * <br> * A * <br><br> * () getBaseValue():null<br> * * <br> * () -:1<br> * * <br> * ???null???? * <br> * * @throws Exception ????? */ @Test @SuppressWarnings("unchecked") public void testGetLength01() throws Exception { // ?? QName qName = new QName("name"); @SuppressWarnings("rawtypes") Map map = new HashMap(); map.put("key", null); DynamicPropertyHandler handler = new MapDynamicPropertyHandler(); Locale locale = new Locale("ja"); NodePointer nodePointer = NodePointer.newNodePointer(qName, map, locale); DynamicPropertyPointerEx pointer = new DynamicPropertyPointerEx(nodePointer, handler); pointer.setPropertyName("key"); // assertEquals(1, pointer.getLength()); } /** * testGetLength02() * <br><br> * * () * <br> * A * <br><br> * () getBaseValue():not null<br> * () ValueUtils.getLength(value):?????<br> * * <br> * () -:ValueUtils.getLength(value)??<br> * * <br> * ??null??????ValueUtils.getLength()? * <br> * * @throws Exception ????? */ @Test @SuppressWarnings("unchecked") public void testGetLength02() throws Exception { // ?? QName qName = new QName("name"); @SuppressWarnings("rawtypes") Map map = new HashMap(); map.put("key", new String[] { "a", "b", "c" }); DynamicPropertyHandler handler = new MapDynamicPropertyHandler(); Locale locale = new Locale("ja"); NodePointer nodePointer = NodePointer.newNodePointer(qName, map, locale); DynamicPropertyPointerEx pointer = new DynamicPropertyPointerEx(nodePointer, handler); pointer.setPropertyName("key"); // assertEquals(3, pointer.getLength()); } }