001    /*
002     *   Copyright (C) Christian Schulte, 2005-206
003     *   All rights reserved.
004     *
005     *   Redistribution and use in source and binary forms, with or without
006     *   modification, are permitted provided that the following conditions
007     *   are met:
008     *
009     *     o Redistributions of source code must retain the above copyright
010     *       notice, this list of conditions and the following disclaimer.
011     *
012     *     o Redistributions in binary form must reproduce the above copyright
013     *       notice, this list of conditions and the following disclaimer in
014     *       the documentation and/or other materials provided with the
015     *       distribution.
016     *
017     *   THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
018     *   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
019     *   AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
020     *   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
021     *   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
022     *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
023     *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
024     *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025     *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
026     *   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027     *
028     *   $JOMC: WriteModelTaskTest.java 3879 2011-10-24 00:59:27Z schulte2005 $
029     *
030     */
031    package org.jomc.ant.test;
032    
033    import org.apache.tools.ant.BuildException;
034    import org.apache.tools.ant.Project;
035    import org.jomc.ant.WriteModelTask;
036    import org.jomc.ant.test.support.AntExecutionResult;
037    import static org.jomc.ant.test.support.Assert.assertException;
038    import static org.jomc.ant.test.support.Assert.assertExceptionMessage;
039    import static org.jomc.ant.test.support.Assert.assertMessageLogged;
040    import static org.jomc.ant.test.support.Assert.assertMessageLoggedContaining;
041    import static org.jomc.ant.test.support.Assert.assertNoException;
042    import org.junit.Test;
043    
044    /**
045     * Test cases for class {@code org.jomc.ant.WriteModelTask}.
046     *
047     * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a>
048     * @version $JOMC: WriteModelTaskTest.java 3879 2011-10-24 00:59:27Z schulte2005 $
049     */
050    public class WriteModelTaskTest extends JomcModelTaskTest
051    {
052    
053        /** Creates a new {@code WriteModelTaskTest} instance. */
054        public WriteModelTaskTest()
055        {
056            super();
057        }
058    
059        /** {@inheritDoc} */
060        @Override
061        public WriteModelTask getJomcTask()
062        {
063            return (WriteModelTask) super.getJomcTask();
064        }
065    
066        /** {@inheritDoc} */
067        @Override
068        protected WriteModelTask newJomcTask()
069        {
070            return new WriteModelTask();
071        }
072    
073        /** {@inheritDoc} */
074        @Override
075        protected String getBuildFileName()
076        {
077            return "write-model-task-test.xml";
078        }
079    
080        @Test
081        public final void testSpecificationNotFound() throws Exception
082        {
083            final AntExecutionResult r = this.executeTarget( "test-specification-not-found" );
084            assertNoException( r );
085            assertMessageLogged( r, "Specification 'DOES NOT EXIST' not found.", Project.MSG_WARN );
086        }
087    
088        @Test
089        public final void testImplementationNotFound() throws Exception
090        {
091            final AntExecutionResult r = this.executeTarget( "test-implementation-not-found" );
092            assertNoException( r );
093            assertMessageLogged( r, "Implementation 'DOES NOT EXIST' not found.", Project.MSG_WARN );
094        }
095    
096        @Test
097        public final void testModuleNotFound() throws Exception
098        {
099            final AntExecutionResult r = this.executeTarget( "test-module-not-found" );
100            assertNoException( r );
101            assertMessageLogged( r, "Module 'DOES NOT EXIST' not found.", Project.MSG_WARN );
102        }
103    
104        @Test
105        public final void testWriteModelAllAttributes() throws Exception
106        {
107            final AntExecutionResult r = this.executeTarget( "test-write-model-all-attributes" );
108            assertNoException( r );
109            assertMessageLoggedContaining( r, "Writing", Project.MSG_INFO );
110        }
111    
112    }