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.plugin.ant.eld.doc;
025
026import java.io.File;
027
028import org.apache.tools.ant.BuildFileTest;
029
030/**
031 * SchemaTaskTest tests the schema ant task.
032 * 
033 * @author Willem Cazander
034 * @version 1.0 Aug 23, 2012
035 */
036public class EldDocWriterTaskTest extends BuildFileTest {
037
038        public void setUp() {
039                configureProject("src/test/resources/tests/ant-elddoc-task.xml");
040        }
041        
042        public void testEldDocCel() {
043                executeTarget("test-elddoc-cel");
044                File testDir = new File("target/test-elddoc/cel");
045                int files = testDir.listFiles().length;
046                assertEquals("Should created more then two files", true, files>2);
047        }
048        
049        public void testEldDocEld() {
050                executeTarget("test-elddoc-eld");
051                File testDir = new File("target/test-elddoc/eld");
052                int files = testDir.listFiles().length;
053                assertEquals("Should created more then two files", true, files>2);
054                
055                ///assertEquals("Message was logged but should not.", getLog(), "");
056                //expectLog("use.message", "attribute-text");
057                //assertLogContaining("Nested Element 1");
058        }
059        
060        public void testEldDocEldVerbose() {
061                executeTarget("test-elddoc-cel-verbose");
062                assertLogContaining("verbose:");
063        }
064        
065        public void testFailBasePath() {
066                expectBuildException("test-fail-destdir", "Should get exception id destdir is not set.");
067        }
068        public void testFailBasePathError() {
069                expectBuildException("test-fail-destdir-error", "Should get exception id destdir does not exists.");
070        }
071        public void testFailSupportClass() {
072                expectBuildException("test-fail-supportclass", "Should get exception id supportclass is not set.");
073        }
074        public void testFailSupportClassError() {
075                expectBuildException("test-fail-supportclass-error", "Should get exception id supportclass throws error.");
076        }
077        public void testFailAllMissing() {
078                expectBuildException("test-fail-all", "Should get exception with no attributes.");
079        }
080        public void testFailClassError() {
081                expectBuildException("test-fail-class-error", "No build exception while class is missing.");
082        }
083        public void testFailClassErrorNo() {
084                executeTarget("test-fail-class-error-no");
085                assertLogContaining("Could not load class:");
086        }
087}