Package ca.odell.glazedlists.event

Examples of ca.odell.glazedlists.event.ListEventPublisher


     * to be preserved after deserialization.
     */
    public void testSerializableLocksAndPublisher() throws IOException, ClassNotFoundException {
        // 1. create the Lock and Publisher that will be shared by all BasicEventLists
        final ReadWriteLock sharedLock = LockFactory.DEFAULT.createReadWriteLock();
        final ListEventPublisher sharedPublisher = ListEventAssembler.createListEventPublisher();

        // 2. add 4 BasicEventLists to a container, each of which shares a common Publisher and ReadWriteLocks
        final List<EventList<String>> serializationContainer = new ArrayList<EventList<String>>();
        for (int i = 0; i < 4; i++) {
            final EventList<String> eventList = new BasicEventList<String>(sharedPublisher, sharedLock);
            eventList.add("Test " + i);
            serializationContainer.add(eventList);
        }

        // 3. serialize/deserialize the container
        final List<EventList<String>> serializedCopy = GlazedListsTests.serialize(serializationContainer);
        assertEquals(serializationContainer, serializedCopy);

        // 4. ensure deserialized lists still share the lock and publisher
        final ListEventPublisher publisher = serializedCopy.get(0).getPublisher();
        final ReadWriteLock lock = serializedCopy.get(0).getReadWriteLock();       
        final CompositeList<String> compositeList = new CompositeList<String>(publisher, lock);
        for (int i = 0; i < 4; i++) {
            // explicitly check the identity of the publisher and lock
            final EventList<String> eventList = serializedCopy.get(i);
View Full Code Here


            ReadWriteLock emailLock = u.getEmailAddresses().getReadWriteLock();
            assertEquals(nickNamesLock, emailLock);
            assertEquals(TestEventListType2.LOCK, u.getRoles().getReadWriteLock());
           
            // test publisher equality
            ListEventPublisher nickNamesPublisher = u.getNickNames().getPublisher();
            ListEventPublisher emailPublisher = u.getEmailAddresses().getPublisher();
            assertEquals(nickNamesPublisher, emailPublisher);
            assertEquals(TestEventListType2.PUBLISHER, u.getRoles().getPublisher());
           
            // lazy collection should still be uninitialized
            assertFalse(Hibernate.isInitialized(u.getNickNames()));
            assertFalse(Hibernate.isInitialized(u.getEmailAddresses()));
            assertFalse(Hibernate.isInitialized(u.getRoles()));

            // trigger initialization       
            assertEquals(2, u.getNickNames().size());
            assertTrue(Hibernate.isInitialized(u.getNickNames()));
            assertEquals(2, u.getEmailAddresses().size());
            assertTrue(Hibernate.isInitialized(u.getEmailAddresses()));
                       
            // test ReadWriteLock equality again
            nickNamesLock = u.getNickNames().getReadWriteLock();
            emailLock = u.getEmailAddresses().getReadWriteLock();
            assertEquals(nickNamesLock, emailLock);
            assertEquals(TestEventListType2.LOCK, u.getRoles().getReadWriteLock());
           
            // test publisher equality again
            nickNamesPublisher = u.getNickNames().getPublisher();
            emailPublisher = u.getEmailAddresses().getPublisher();
            assertEquals(nickNamesPublisher, emailPublisher);
            assertEquals(TestEventListType2.PUBLISHER, u.getRoles().getPublisher());
        } else {
            // collection should be initialized
            assertTrue(Hibernate.isInitialized(u.getNickNames()));
            assertTrue(Hibernate.isInitialized(u.getEmailAddresses()));
            assertTrue(Hibernate.isInitialized(u.getRoles()));
            // test ReadWriteLock equality
            final ReadWriteLock nickNamesLock = u.getNickNames().getReadWriteLock();
            final ReadWriteLock emailLock = u.getEmailAddresses().getReadWriteLock();
            assertEquals(nickNamesLock, emailLock);
            assertEquals(TestEventListType2.LOCK, u.getRoles().getReadWriteLock());
           
            // test publisher equality
            final ListEventPublisher nickNamesPublisher = u.getNickNames().getPublisher();
            final ListEventPublisher emailPublisher = u.getEmailAddresses().getPublisher();
            assertEquals(nickNamesPublisher, emailPublisher);
            assertEquals(TestEventListType2.PUBLISHER, u.getRoles().getPublisher());
           
        }
        assertEquals(PersistentEventList.class, u.getNickNames().getClass());
View Full Code Here

        final ReadWriteLock nickNamesLock = nickNamesCopy.getReadWriteLock();
        final ReadWriteLock emailLock = emailsCopy.getReadWriteLock();
        assertEquals(nickNamesLock, emailLock);

        final ListEventPublisher nickNamesPublisher = nickNamesCopy.getPublisher();
        final ListEventPublisher emailPublisher = emailsCopy.getPublisher();
        assertEquals(nickNamesPublisher, emailPublisher);

        // delete user
        s.delete(u);
        t.commit();
View Full Code Here

    private static void verifyTestData(Object rootObj) {
        // ensure deserialzed lists still share the lock and publisher
        final List<ListHolder> serializedCopy = (List<ListHolder>) rootObj;
        assert (serializedCopy != null && serializedCopy.size() > 0);
       
        final ListEventPublisher publisher = serializedCopy.get(0).names.getPublisher();
        final ReadWriteLock lock = serializedCopy.get(0).names.getReadWriteLock();       
       
        final CompositeList<String> compositeList = new CompositeList<String>(publisher, lock);
       
        for (Iterator<ListHolder> iter = serializedCopy.iterator(); iter.hasNext();) {
View Full Code Here

    }
   
    /** creates some test data to serialize. */
    private static Object createTestData() {
        final ReadWriteLock sharedLock = LockFactory.DEFAULT.createReadWriteLock();
        final ListEventPublisher sharedPublisher = ListEventAssembler.createListEventPublisher();
        final List<ListHolder> rootList = new ArrayList<ListHolder>();
        for (int i = 0; i < 4; i++) {
            final BasicEventList<String> eventList = new BasicEventList<String>(sharedPublisher, sharedLock);
            eventList.add("Test " + i);
            final ListHolder elem = new ListHolder(eventList);
View Full Code Here

     * Test that when {@link CompositeList} is constructed with a publisher and read/write
     * lock, it uses them and produces member lists which also use them.
     */
    public void testPublisherAndLockConstructor() {
        final ReadWriteLock sharedLock = LockFactory.DEFAULT.createReadWriteLock();
        final ListEventPublisher sharedPublisher = ListEventAssembler.createListEventPublisher();

        final EventList<Object> alpha = new BasicEventList<Object>(sharedPublisher, sharedLock);
        final EventList<Object> beta = new BasicEventList<Object>(sharedPublisher, sharedLock);

        final CompositeList<Object> uber = new CompositeList<Object>(sharedPublisher, sharedLock);
View Full Code Here

     * Tests that when EventLists are added as members, an IllegalArgumentException should be thrown
     * if they don'to share the same lock and publisher with the CompositeList.
     */
    public void testAddMemberList() {
        final ReadWriteLock sharedLock = LockFactory.DEFAULT.createReadWriteLock();
        final ListEventPublisher sharedPublisher = ListEventAssembler.createListEventPublisher();

        final CompositeList<Object> uber = new CompositeList<Object>(sharedPublisher, sharedLock);
        final EventList<Object> alpha = new BasicEventList<Object>();
        final EventList<Object> beta = new BasicEventList<Object>(sharedLock);
        final EventList<Object> gamma = new BasicEventList<Object>(sharedPublisher, sharedLock);
View Full Code Here

     * Tests disposing of CollectionList, where the model produces EventLists
     * containing the children.
     */
    public void testDisposeWithEventListChildren() {
        final EventList<List<String>> parentEventList = new BasicEventList<List<String>>();
        final ListEventPublisher sharedpublisher = parentEventList.getPublisher();
        final ReadWriteLock sharedLocks = parentEventList.getReadWriteLock();

        // make sure all of the child lists are built using the shared ListEventPublisher and ReadWriteLocks
        final List<String> abcList = GlazedListsTests.stringToList("ABC");
        final EventList<String> abcEventList = new BasicEventList<String>(sharedpublisher, sharedLocks);
View Full Code Here

TOP

Related Classes of ca.odell.glazedlists.event.ListEventPublisher

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.