List of usage examples for org.apache.commons.lang3.mutable MutableBoolean setValue
@Override public void setValue(final Boolean value)
From source file:org.pircbotx.ConfigurationTest.java
@Test(dataProvider = "fieldNamesDataProvider", dependsOnMethods = "containSameFieldsTest", description = "Make sure every getter in builder gets called when creating Configuration") @SuppressWarnings("unchecked") public void copyConstructorTest(Class containerClass, Class copiedClass, Object copiedOpject, String getterName) throws Exception { //Get the method that is going to be called final Method methodToCall = copiedClass.getDeclaredMethod(getterName); //Trip if method gets called final MutableBoolean isMethodCalled = new MutableBoolean(false); Object copiedObjectSpied = mock(copiedClass, withSettings().spiedInstance(copiedOpject).defaultAnswer(new Answer() { public Object answer(InvocationOnMock invocation) throws Throwable { if (invocation.getMethod().equals(methodToCall)) isMethodCalled.setValue(true); return invocation.callRealMethod(); }//from ww w .ja v a2s . c o m })); //Call and test containerClass.getDeclaredConstructor(copiedClass).newInstance(copiedObjectSpied); assertTrue(isMethodCalled.getValue(), "Getter " + getterName + " on Builder not called in constructor in class " + containerClass.getCanonicalName()); }
From source file:org.pircbotx.hooks.ListenerAdapterTest.java
@Test(description = "Do an actual test with a sample ListenerAdapter") public void usabilityTest() throws Exception { final MutableBoolean onMessageCalled = new MutableBoolean(false); final MutableBoolean onGenericMessageCalled = new MutableBoolean(false); ListenerAdapter testListener = new ListenerAdapter() { @Override//from w w w . j a v a 2 s. c om public void onMessage(MessageEvent event) throws Exception { onMessageCalled.setValue(true); } @Override public void onGenericMessage(GenericMessageEvent event) throws Exception { onGenericMessageCalled.setValue(true); } }; testListener.onEvent(mock(MessageEvent.class)); assertTrue(onMessageCalled.isTrue(), "onMessage wasn't called on MessageEvent"); assertTrue(onGenericMessageCalled.isTrue(), "onGenericMessage wasn't called on MessageEvent"); }
From source file:org.sejda.cli.CommandLineTestBuilder.java
public void assertTaskCompletes(String commandLine) { final MutableBoolean taskCompleted = new MutableBoolean(false); GlobalNotificationContext.getContext().addListener(new EventListener<TaskExecutionCompletedEvent>() { @Override//from ww w. ja v a2 s. co m public void onEvent(TaskExecutionCompletedEvent event) { taskCompleted.setValue(true); } }); String consoleOutput = invokeConsoleAndReturnSystemOut(commandLine); assertThat("Task did not complete. Console output was:\n" + consoleOutput, taskCompleted.toBoolean(), is(true)); }