本文整理汇总了Java中java.beans.Statement.execute方法的典型用法代码示例。如果您正苦于以下问题:Java Statement.execute方法的具体用法?Java Statement.execute怎么用?Java Statement.execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.beans.Statement
的用法示例。
在下文中一共展示了Statement.execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setMethodValue
import java.beans.Statement; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static <E> void setMethodValue(E obj, Method method, Object... args) {
try {
method.setAccessible(true);
method.invoke(obj, args);
} catch (InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
// e.printStackTrace();
try {
if (obj != null) {
Statement stmt = new Statement(obj, method.getName(), args);
stmt.execute();
}
} catch (Exception e1) {
// e1.printStackTrace();
}
}
}
示例2: itemStateChanged
import java.beans.Statement; //导入方法依赖的package包/类
@Override
public void itemStateChanged(ItemEvent evt) {
Statement statement = (evt.getStateChange() == ItemEvent.DESELECTED) ? falseStatement
: trueStatement;
try {
statement.execute();
} catch (Exception ex) {
LOG.log(Level.FINE,
"Couldn't execute boolean method via Statement "
+ statement, ex);
}
}
示例3: itemStateChanged
import java.beans.Statement; //导入方法依赖的package包/类
public void itemStateChanged(ItemEvent evt) {
Statement statement = (evt.getStateChange() == ItemEvent.DESELECTED) ? falseStatement
: trueStatement;
try {
statement.execute();
} catch (Exception ex) {
LOG.log(Level.FINE,
"Couldn't execute boolean method via Statement "
+ statement, ex);
}
}
示例4: testSetter
import java.beans.Statement; //导入方法依赖的package包/类
/**
* The test checks the method execute() for setter
*/
public void testSetter() throws Exception {
Bean bean = new Bean();
Statement s = new Statement(bean, "setText", new Object[] { "hello" });
s.execute();
assertEquals("hello", bean.getText());
}
示例5: testExecute_ProtectedMethodWithPackage
import java.beans.Statement; //导入方法依赖的package包/类
public void testExecute_ProtectedMethodWithPackage() throws Exception {
DefaultPersistenceDelegate dpd = new DefaultPersistenceDelegate();
Object[] arguments = new Object[] { "test", "test" };
Statement t = new Statement(dpd, "mutatesTo", arguments);
try {
t.execute();
fail("Should throw NoSuchMethodException!");
} catch (NoSuchMethodException e) {
// expected
}
}
示例6: testArraySetter
import java.beans.Statement; //导入方法依赖的package包/类
/**
* The test checks the method execute() for array setter
*/
public void testArraySetter() throws Exception {
int[] a = { 1, 2, 3 };
Statement s = new Statement(a, "set", new Object[] { new Integer(1),
new Integer(7) });
s.execute();
assertEquals(7, a[1]);
}
示例7: testStatic
import java.beans.Statement; //导入方法依赖的package包/类
/**
* 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());
}
示例8: testExecute_ArrayInvalidName
import java.beans.Statement; //导入方法依赖的package包/类
public void testExecute_ArrayInvalidName() throws Exception {
Object[] array = new Object[] { "test" };
Statement t = new Statement(array, "gets", new Object[] {
new Integer(0), new Object() });
try {
t.execute();
fail("Should throw NoSuchMethodException!");
} catch (NoSuchMethodException ex) {
// expected
}
}
示例9: testExceptionThrownOnStaticMethodCall
import java.beans.Statement; //导入方法依赖的package包/类
/**
* 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
}
}
示例10: testExecute_ApplicableViaTypeConversion
import java.beans.Statement; //导入方法依赖的package包/类
public void testExecute_ApplicableViaTypeConversion() throws Exception {
MockObject mo = new MockObject(false);
// mo.methodB('c');
Object[] arguments = new Object[] { new Character((char) 1) };
Statement t = new Statement(mo, "methodB", arguments);
try {
t.execute();
fail("Should throw NoSuchMethodException!");
} catch (NoSuchMethodException e) {
// expected
}
}
示例11: testExecute_ExceptionalMethod
import java.beans.Statement; //导入方法依赖的package包/类
public void testExecute_ExceptionalMethod() throws Exception {
MockObject mo = new MockObject(false);
Statement t = new Statement(mo, "method", new Object[] { null, null });
try {
t.execute();
fail("Should throw NullPointerException!");
} catch (NullPointerException ex) {
// expected
}
MockObject.assertCalled("method4", new Object[] { null, null });
}
示例12: testExecute_NonExistingMethod
import java.beans.Statement; //导入方法依赖的package包/类
public void testExecute_NonExistingMethod() throws Exception {
MockObject mo = new MockObject(false);
Statement t = new Statement(mo, "method_not_existing", new Object[] {
null, null });
try {
t.execute();
fail("Should throw NoSuchMethodException!");
} catch (NoSuchMethodException ex) {
// expected
}
}
示例13: testExecute_NullTarget
import java.beans.Statement; //导入方法依赖的package包/类
public void testExecute_NullTarget() throws Exception {
Statement t = new Statement(null, "method_not_existing", new Object[] {
null, null });
try {
t.execute();
fail("Should throw NullPointerException!");
} catch (NullPointerException ex) {
// expected
}
}
示例14: testExecute_InvalidArguments
import java.beans.Statement; //导入方法依赖的package包/类
public void testExecute_InvalidArguments() throws Exception {
MockObject mo = new MockObject(false);
Statement t = new Statement(mo, "method", new Object[] { new Object(),
new Object(), new Object() });
try {
t.execute();
fail("Should throw NoSuchMethodException!");
} catch (NoSuchMethodException ex) {
// expected
}
}
示例15: testExecute_NormalConstructorNull
import java.beans.Statement; //导入方法依赖的package包/类
public void testExecute_NormalConstructorNull() throws Exception {
Object[] arguments = new Object[] { null, null };
Statement t = new Statement(MockObject.class, "new", arguments);
try {
t.execute();
fail("Should throw NullPointerException!");
} catch (NullPointerException ex) {
// expected
}
MockObject.assertCalled("new4", arguments);
}