Package java.beans

Examples of java.beans.Statement$MethodComparator


    /**
     * The test checks the method execute() for static method
     */
    public void testStatic() throws Exception {
        int currentId = getTestId();
        Statement s = new Statement(StatementTest.class, "nextTestId",
                new Object[] {});
        s.execute();
        assertEquals(++currentId, getTestId());
    }
View Full Code Here


     * The test checks the method execute() if exception is thrown on method
     * call
     */
    public void testExceptionThrownOnMethodCall() {
        Bean bean = new Bean("hello");
        Statement s = new Statement(bean, "setChar", new Object[] {
                new Integer(5), new Character('a') });

        try {
            s.execute();
            fail("Exception must be thrown while Bean.setChar(5, 'a') "
                    + "invocation.");
        } catch (Exception e) {
            // correct situation
        }
View Full Code Here

    /**
     * The test checks the method execute() if exception is thrown on static
     * method call
     */
    public void testExceptionThrownOnStaticMethodCall() throws Exception {
        Statement s = new Statement(StatementTest.class, "methodWithException",
                new Object[] {});

        try {
            s.execute();
            fail("Exception must be thrown with methodWithException call");
        } catch (SampleException se) {
            // SampleException is thrown as expected
        }
    }
View Full Code Here

    /**
     * The test checks the method execute() with array as parameter
     */
    public void testMethodWithArrayParam() throws Exception {
        Statement s = new Statement(StatementTest.class, "methodWithIntArray",
                new Object[] { new int[] { 3 } });
        s.execute();
    }
View Full Code Here

     */
    public void testConstructor_Normal() {
        Object arg1 = new Object();
        Object arg2 = "string";
        Object[] oa = new Object[] { arg1, arg2 };
        Statement t = new Statement(arg1, "method", oa);
        assertSame(arg1, t.getTarget());
        assertSame("method", t.getMethodName());
        assertSame(oa, t.getArguments());
        assertSame(arg1, t.getArguments()[0]);
        assertSame(arg2, t.getArguments()[1]);
        assertEquals("Object.method(Object, \"string\");", t.toString());
    }
View Full Code Here

     * Test the constructor with null target.
     */
    public void testConstructor_NullTarget() {
        Object arg = new Object();
        Object[] oa = new Object[] { arg };
        Statement t = new Statement(null, "method", oa);
        assertSame(null, t.getTarget());
        assertSame("method", t.getMethodName());
        assertSame(oa, t.getArguments());
        assertSame(arg, t.getArguments()[0]);
        assertEquals("null.method(Object);", t.toString());
    }
View Full Code Here

     * Test the constructor with an array target.
     */
    public void testConstructor_ArrayTarget() {
        Object arg = new Object();
        Object[] oa = new Object[] { arg };
        Statement t = new Statement(oa, "method", oa);
        assertSame(oa, t.getTarget());
        assertSame("method", t.getMethodName());
        assertSame(oa, t.getArguments());
        assertSame(arg, t.getArguments()[0]);
        assertEquals("ObjectArray.method(Object);", t.toString());
    }
View Full Code Here

     * Test the constructor with null method name.
     */
    public void testConstructor_NullMethodName() {
        Object target = new Object();
        Object[] oa = new Object[] { new Object() };
        Statement t = new Statement(target, null, oa);
        assertSame(target, t.getTarget());
        assertSame(null, t.getMethodName());
        assertSame(oa, t.getArguments());
        assertEquals("Object.null(Object);", t.toString());
    }
View Full Code Here

     * Test the constructor with the method name "new".
     */
    public void testConstructor_NewMethodName() {
        Object target = new Object();
        Object[] oa = new Object[] { new Object() };
        Statement t = new Statement(target, "new", oa);
        assertSame(target, t.getTarget());
        assertSame("new", t.getMethodName());
        assertSame(oa, t.getArguments());
        assertEquals("Object.new(Object);", t.toString());
    }
View Full Code Here

    }
  }
 
  private static void injectServices(Object contributor) {
    if (gatewayServices != null) {
      Statement stmt = null;
      for(String serviceName : gatewayServices.getServiceNames()) {
       
        try {
          // TODO: this is just a temporary injection solution
          // TODO: test for the existence of the setter before attempting it
          // TODO: avoid exception throwing when there is no setter
          stmt = new Statement(contributor, "set" + serviceName, new Object[]{gatewayServices.getService(serviceName)});
          stmt.execute();
        } catch (NoSuchMethodException e) {
          // TODO: eliminate the possibility of this being thrown up front
        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
View Full Code Here

TOP

Related Classes of java.beans.Statement$MethodComparator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.