public void testAttributeSetters() throws BuildException { Project p = new Project(); p.setBasedir("/tmp"); IntrospectionHelper ih = IntrospectionHelper.getHelper(getClass()); try { ih.setAttribute(p, this, "one", "test"); fail("setOne doesn't exist"); } catch (BuildException be) { } try { ih.setAttribute(p, this, "two", "test"); fail("setTwo returns non void"); } catch (BuildException be) { } try { ih.setAttribute(p, this, "three", "test"); fail("setThree takes no args"); } catch (BuildException be) { } try { ih.setAttribute(p, this, "four", "test"); fail("setFour takes two args"); } catch (BuildException be) { } try { ih.setAttribute(p, this, "five", "test"); fail("setFive takes array arg"); } catch (BuildException be) { } try { ih.setAttribute(p, this, "six", "test"); fail("Project doesn't have a String constructor"); } catch (BuildException be) { } ih.setAttribute(p, this, "seven", "2"); try { ih.setAttribute(p, this, "seven", "3"); fail("2 shouldn't be equals to three"); } catch (BuildException be) { assertTrue(be.getException() instanceof AssertionFailedError); } ih.setAttribute(p, this, "eight", "2"); try { ih.setAttribute(p, this, "eight", "3"); fail("2 shouldn't be equals to three - as int"); } catch (BuildException be) { assertTrue(be.getException() instanceof AssertionFailedError); } ih.setAttribute(p, this, "nine", "2"); try { ih.setAttribute(p, this, "nine", "3"); fail("2 shouldn't be equals to three - as Integer"); } catch (BuildException be) { assertTrue(be.getException() instanceof AssertionFailedError); } ih.setAttribute(p, this, "ten", "2"); try { ih.setAttribute(p, this, "ten", "3"); fail("/tmp/2 shouldn't be equals to /tmp/3"); } catch (BuildException be) { assertTrue(be.getException() instanceof AssertionFailedError); } ih.setAttribute(p, this, "eleven", "2"); try { ih.setAttribute(p, this, "eleven", "on"); fail("on shouldn't be false"); } catch (BuildException be) { assertTrue(be.getException() instanceof AssertionFailedError); } ih.setAttribute(p, this, "twelve", "2"); try { ih.setAttribute(p, this, "twelve", "on"); fail("on shouldn't be false"); } catch (BuildException be) { assertTrue(be.getException() instanceof AssertionFailedError); } ih.setAttribute(p, this, "thirteen", "org.apache.tools.ant.Project"); try { ih.setAttribute(p, this, "thirteen", "org.apache.tools.ant.ProjectHelper"); fail("org.apache.tools.ant.Project shouldn't be equal to org.apache.tools.ant.ProjectHelper"); } catch (BuildException be) { assertTrue(be.getException() instanceof AssertionFailedError); } try { ih.setAttribute(p, this, "thirteen", "org.apache.tools.ant.Project2"); fail("org.apache.tools.ant.Project2 doesn't exist"); } catch (BuildException be) { assertTrue(be.getException() instanceof ClassNotFoundException); } ih.setAttribute(p, this, "fourteen", "2"); try { ih.setAttribute(p, this, "fourteen", "on"); fail("2 shouldn't be equals to three - as StringBuffer"); } catch (BuildException be) { assertTrue(be.getException() instanceof AssertionFailedError); } ih.setAttribute(p, this, "fifteen", "abcd"); try { ih.setAttribute(p, this, "fifteen", "on"); fail("o shouldn't be equal to a"); } catch (BuildException be) { assertTrue(be.getException() instanceof AssertionFailedError); } ih.setAttribute(p, this, "sixteen", "abcd"); try { ih.setAttribute(p, this, "sixteen", "on"); fail("o shouldn't be equal to a"); } catch (BuildException be) { assertTrue(be.getException() instanceof AssertionFailedError); } }