BeanPropertyPointerEx extends BeanPropertyPointer { @Override public int getLength() { int length = super.getLength(); if (length == 0 && getBaseValue() == null) { return 1; } return length; } BeanPropertyPointerEx(NodePointer parent, JXPathBeanInfo beanInfo); @Override int getLength(); @Override boolean isCollection();  }
@Test public void testGetLength01() throws Exception { QName qName = new QName("property"); BeanPropertyPointerEx_JavaBeanStub01 bean = new BeanPropertyPointerEx_JavaBeanStub01(); Locale locale = new Locale("ja"); NodePointer nodePointer = NodePointer.newNodePointer(qName, bean, locale); JXPathBasicBeanInfo beanInfo = new JXPathBasicBeanInfo(bean.getClass()); BeanPropertyPointerEx pointer = new BeanPropertyPointerEx(nodePointer, beanInfo); pointer.setPropertyName("property"); assertEquals(1, pointer.getLength()); }
@Test public void testGetLength02() throws Exception { QName qName = new QName("property"); BeanPropertyPointerEx_JavaBeanStub01 bean = new BeanPropertyPointerEx_JavaBeanStub01(); bean.setListProperty(null); Locale locale = new Locale("ja"); NodePointer nodePointer = NodePointer.newNodePointer(qName, bean, locale); JXPathBasicBeanInfo beanInfo = new JXPathBasicBeanInfo(bean.getClass()); BeanPropertyPointerEx pointer = new BeanPropertyPointerEx(nodePointer, beanInfo); pointer.setPropertyName("listProperty"); assertEquals(1, pointer.getLength()); }
@Test public void testGetLength03() throws Exception { QName qName = new QName("property"); BeanPropertyPointerEx_JavaBeanStub01 bean = new BeanPropertyPointerEx_JavaBeanStub01(); Locale locale = new Locale("ja"); NodePointer nodePointer = NodePointer.newNodePointer(qName, bean, locale); JXPathBasicBeanInfo beanInfo = new JXPathBasicBeanInfo(bean.getClass()); BeanPropertyPointerEx pointer = new BeanPropertyPointerEx(nodePointer, beanInfo); pointer.setPropertyName("listProperty"); assertEquals(0, pointer.getLength()); }