001/*
002 * Copyright (c) 2004-2012, Willem Cazander
003 * All rights reserved.
004 *
005 * Redistribution and use in source and binary forms, with or without modification, are permitted provided
006 * that the following conditions are met:
007 * 
008 * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
009 *   following disclaimer.
010 * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
011 *   the following disclaimer in the documentation and/or other materials provided with the distribution.
012 * 
013 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
014 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
015 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
016 * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
018 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
019 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
020 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
021 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
022 */
023
024package org.x4o.xml.core;
025
026import java.util.List;
027
028import org.x4o.xml.core.X4OPhase;
029import org.x4o.xml.core.X4OPhaseHandler;
030import org.x4o.xml.core.X4OPhaseManager;
031import org.x4o.xml.test.TestParser;
032
033
034import junit.framework.TestCase;
035
036/**
037 * Tests some code for testing x4o phases. 
038 *  * 
039 * @author Willem Cazander
040 * @version 1.0 Jan 15, 2009
041 */
042public class X4OPhaseManagerTest extends TestCase {
043        
044        boolean phaseRunned = false;
045        
046        public void setUp() throws Exception {
047                phaseRunned = false;
048        }
049
050        public void testPhaseOrder() throws Exception {
051                TestParser parser = new TestParser();
052                X4OPhaseManager manager = parser.getDriver().createX4OPhaseManager();
053                
054                assertEquals(false,manager.getPhases().isEmpty());
055                List<X4OPhaseHandler> phases = manager.getOrderedPhases();
056                
057                int i = 0;
058                for (X4OPhase phase:X4OPhase.PHASE_ORDER) {
059                        //if (X4OPhase.configOptionalPhase.equals(phase)) {
060                        //      continue;
061                        //}
062                        assertEquals(phase, phases.get(i).getX4OPhase());
063                        i++;
064                }
065        }
066        
067        public void testPhaseManager() throws Exception {
068                TestParser parser = new TestParser();
069                X4OPhaseManager manager = parser.getDriver().createX4OPhaseManager();
070                
071                Exception e = null;
072                try {
073                        manager.addX4OPhaseHandler(null);
074                } catch (NullPointerException ee) {
075                        e = ee;
076                }
077                assertEquals(true, e!=null );
078        }
079}