<?xml version="1.0" encoding="utf-8"?><!-- generator="wordpress/2.0.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Utility class for simple getter/setter JUnit testing</title>
	<link>http://www.plaintivemewling.com/articles/gettersetter</link>
	<description>Incessant chatterings of a young fart</description>
	<pubDate>Thu, 11 Mar 2010 01:08:24 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.2</generator>

	<item>
		<title>by: August Dwight</title>
		<link>http://www.plaintivemewling.com/articles/gettersetter#comment-569</link>
		<pubDate>Thu, 03 Sep 2009 18:13:04 +0000</pubDate>
		<guid>http://www.plaintivemewling.com/articles/gettersetter#comment-569</guid>
					<description>I added a couple of lines to the makeProxy method, beneath the primitives, to handle the creation of other objects.  Many of my beans have instance variables which are other beans, so this allowed me to test those as well.

Object o = type.newInstance();
return o;</description>
		<content:encoded><![CDATA[<p>I added a couple of lines to the makeProxy method, beneath the primitives, to handle the creation of other objects.  Many of my beans have instance variables which are other beans, so this allowed me to test those as well.</p>
<p>Object o = type.newInstance();<br />
return o;
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Steven</title>
		<link>http://www.plaintivemewling.com/articles/gettersetter#comment-508</link>
		<pubDate>Fri, 05 Dec 2008 05:15:09 +0000</pubDate>
		<guid>http://www.plaintivemewling.com/articles/gettersetter#comment-508</guid>
					<description>I needed to exclude certain object casts, not just the name of the variable.

private Set excludeCasts = new TreeSet();

public GetterSetterTester exclude(String field)
{
	excludes.add(field.toLowerCase());
	return this;
}

// added this check in public void test()
if (excludeCasts.contains(args[0].getName())){
	continue;
}</description>
		<content:encoded><![CDATA[<p>I needed to exclude certain object casts, not just the name of the variable.</p>
<p>private Set excludeCasts = new TreeSet();</p>
<p>public GetterSetterTester exclude(String field)<br />
{<br />
	excludes.add(field.toLowerCase());<br />
	return this;<br />
}</p>
<p>// added this check in public void test()<br />
if (excludeCasts.contains(args[0].getName())){<br />
	continue;<br />
}
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David</title>
		<link>http://www.plaintivemewling.com/articles/gettersetter#comment-435</link>
		<pubDate>Tue, 28 Aug 2007 13:53:20 +0000</pubDate>
		<guid>http://www.plaintivemewling.com/articles/gettersetter#comment-435</guid>
					<description>Thanks for this. Very useful class.

I added a few more types I needed to be handled that were not in makeProxy:

                if (type == Byte.class &amp;#124;&amp;#124; type == byte.class)
                    return new Byte((byte) 0);
                if (type == Short.class &amp;#124;&amp;#124; type == short.class)
                        return new Short((short) 0);
                if (type == ByteBuffer.class)
                    return ByteBuffer.allocate(1);</description>
		<content:encoded><![CDATA[<p>Thanks for this. Very useful class.</p>
<p>I added a few more types I needed to be handled that were not in makeProxy:</p>
<p>                if (type == Byte.class || type == byte.class)<br />
                    return new Byte((byte) 0);<br />
                if (type == Short.class || type == short.class)<br />
                        return new Short((short) 0);<br />
                if (type == ByteBuffer.class)<br />
                    return ByteBuffer.allocate(1);
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Lynorics</title>
		<link>http://www.plaintivemewling.com/articles/gettersetter#comment-359</link>
		<pubDate>Thu, 27 Apr 2006 13:21:03 +0000</pubDate>
		<guid>http://www.plaintivemewling.com/articles/gettersetter#comment-359</guid>
					<description>In the case of the tuple setArray(IMyInterface[] array) / IMyInterface[] getArray() the mehtod makeProxy(Class) must be extended by reacting on an array:

...
if (type == BigInteger.class)
  return new BigInteger(&quot;0&quot;);
// in the case of an array just return an empty array of same type
if (type.isArray())
{
  return java.lang.reflect.Array.newInstance(type.getComponentType(), 0);
}</description>
		<content:encoded><![CDATA[<p>In the case of the tuple setArray(IMyInterface[] array) / IMyInterface[] getArray() the mehtod makeProxy(Class) must be extended by reacting on an array:</p>
<p>&#8230;<br />
if (type == BigInteger.class)<br />
  return new BigInteger(&#8221;0&#8243;);<br />
// in the case of an array just return an empty array of same type<br />
if (type.isArray())<br />
{<br />
  return java.lang.reflect.Array.newInstance(type.getComponentType(), 0);<br />
}
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Ken</title>
		<link>http://www.plaintivemewling.com/articles/gettersetter#comment-307</link>
		<pubDate>Fri, 10 Feb 2006 02:16:09 +0000</pubDate>
		<guid>http://www.plaintivemewling.com/articles/gettersetter#comment-307</guid>
					<description>Helpful class. Thanks. It doesn't seem to support boolean properties, which by JavaBean definition should have an isPropertyName() rather than getPropertyName() getter. Should be a simple extension to support.

Ken</description>
		<content:encoded><![CDATA[<p>Helpful class. Thanks. It doesn&#8217;t seem to support boolean properties, which by JavaBean definition should have an isPropertyName() rather than getPropertyName() getter. Should be a simple extension to support.</p>
<p>Ken
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: W. Craig Trader</title>
		<link>http://www.plaintivemewling.com/articles/gettersetter#comment-304</link>
		<pubDate>Sat, 28 Jan 2006 01:50:55 +0000</pubDate>
		<guid>http://www.plaintivemewling.com/articles/gettersetter#comment-304</guid>
					<description>If you're using Java 1.1 or later, you can simplify the test() method by using the facilities of the java.beans.Introspector, as follows:

    public test() {
        BeanInfo info = null;
        try {
            info = Introspector.getBeanInfo(clazz);
        } catch (IntrospectionException e) {
            throw new RuntimeException(e);
        }

        PropertyDescriptor[] properties = info.getPropertyDescriptors();
        for (int i = 0; i </description>
		<content:encoded><![CDATA[<p>If you&#8217;re using Java 1.1 or later, you can simplify the test() method by using the facilities of the java.beans.Introspector, as follows:</p>
<p>    public test() {<br />
        BeanInfo info = null;<br />
        try {<br />
            info = Introspector.getBeanInfo(clazz);<br />
        } catch (IntrospectionException e) {<br />
            throw new RuntimeException(e);<br />
        }</p>
<p>        PropertyDescriptor[] properties = info.getPropertyDescriptors();<br />
        for (int i = 0; i
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
