Package org.springframework.binding.value

Examples of org.springframework.binding.value.CommitTrigger


            }
        }

        private CommitTrigger getResetTrigger() {
            if (resetTrigger == null) {
                resetTrigger = new CommitTrigger();
                registerListeners();
            }
            return resetTrigger;
        }
View Full Code Here


    private ValueModel wrapped;
    private CommitTrigger commitTrigger;
       
    protected void doSetUp() throws Exception {
        wrapped = new ValueHolder(INITIAL_VALUE);
        commitTrigger = new CommitTrigger();
    }
View Full Code Here

    /**
     * Checks that #setCommitTrigger changes the commit trigger.
     */
    public void testCommitTriggerChange() {
        CommitTrigger trigger1 = new CommitTrigger();
        CommitTrigger trigger2 = new CommitTrigger();
       
        BufferedValueModel buffer = new BufferedValueModel(wrapped, trigger1);
        assertSame(
            "Commit trigger has been changed.",
            buffer.getCommitTrigger(),
View Full Code Here

    /**
     * Checks and verifies that commit and flush events are driven
     * by the current commit trigger.
     */
    public void testListensToCurrentCommitTrigger() {
        CommitTrigger trigger1 = new CommitTrigger();
        CommitTrigger trigger2 = new CommitTrigger();
       
        BufferedValueModel buffer = new BufferedValueModel(wrapped, trigger1);
        buffer.setValue("change1");
        Object wrappedValue = wrapped.getValue();
        Object bufferedValue = buffer.getValue();
        trigger2.commit();
        assertEquals(
            "Changing the unrelated trigger2 to commit has no effect on the wrapped.",
            wrapped.getValue(),
            wrappedValue);
        assertSame(
            "Changing the unrelated trigger2 to commit has no effect on the buffer.",
            buffer.getValue(),
            bufferedValue);
       
        trigger2.revert();
        assertEquals(
            "Changing the unrelated trigger2 to revert has no effect on the wrapped.",
            wrapped.getValue(),
            wrappedValue);
        assertSame(
            "Changing the unrelated trigger2 to revert has no effect on the buffer.",
            buffer.getValue(),
            bufferedValue);
       
        // Change the commit trigger to trigger2.
        buffer.setCommitTrigger(trigger2);
        assertSame(
            "Commit trigger has been changed.",
            buffer.getCommitTrigger(),
            trigger2);

        trigger1.commit();
        assertEquals(
            "Changing the unrelated trigger1 to commit has no effect on the wrapped.",
            wrapped.getValue(),
            wrappedValue);
        assertSame(
            "Changing the unrelated trigger1 to commit has no effect on the buffer.",
            buffer.getValue(),
            bufferedValue);
       
        trigger1.revert();
        assertEquals(
            "Changing the unrelated trigger1 to revert has no effect on the wrapped.",
            wrapped.getValue(),
            wrappedValue);
        assertSame(
            "Changing the unrelated trigger1 to revert has no effect on the buffer.",
            buffer.getValue(),
            bufferedValue);
       
        // Commit using trigger2.
        trigger2.commit();
        assertEquals(
            "Changing the current trigger2 to commit commits the buffered value.",
            buffer.getValue(),
            wrapped.getValue());
       
        buffer.setValue("change2");
        wrappedValue = wrapped.getValue();
        trigger2.revert();
        assertEquals(
            "Changing the current trigger2 to revert flushes the buffered value.",
            buffer.getValue(),
            wrapped.getValue());
        assertEquals(
View Full Code Here

    // Test Implementations ***************************************************
   
    private void testSetValueSendsProperEvents(Object oldValue, Object newValue, boolean eventExpected) {
        BufferedValueModel valueModel =
            new BufferedValueModel(new ValueHolder(oldValue), new CommitTrigger());
        testSendsProperEvents(valueModel, oldValue, newValue, eventExpected);
    }
View Full Code Here

        llm.clear();
        assertEquals(1, vl.eventCount());
    }

    public void testRevert() {
        CommitTrigger commitTriger = new CommitTrigger();

        Collection backingCollection = getCollection(HashSet.class, 700);
        BufferedCollectionValueModel vm = getBufferedCollectionValueModel(backingCollection);
        vm.setCommitTrigger(commitTriger);
        ListListModel llm = (ListListModel)vm.getValue();
        llm.clear();
        commitTriger.revert();
        assertHasSameStructure(llm, backingCollection);
    }
View Full Code Here

* @author Oliver Hutchison
*/
public class CommitTriggerTests extends TestCase {

    public void testCommitTrigger() {
        CommitTrigger ct = new CommitTrigger();
        ct.commit();
        ct.revert();

        TestCommitTriggerListener l = new TestCommitTriggerListener();
        ct.addCommitTriggerListener(l);
        assertEquals(0, l.commits);
        assertEquals(0, l.reverts);

        ct.commit();
        assertEquals(1, l.commits);
        ct.commit();
        assertEquals(2, l.commits);
        assertEquals(0, l.reverts);
        ct.revert();
        assertEquals(2, l.commits);
        assertEquals(1, l.reverts);
       
        ct.removeCommitTriggerListener(l);
       
        ct.commit();
        assertEquals(2, l.commits);
        ct.revert();
        assertEquals(1, l.reverts);       
    }
View Full Code Here

TOP

Related Classes of org.springframework.binding.value.CommitTrigger

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.