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.eld.doc; 025 026import java.io.File; 027 028import org.x4o.xml.eld.EldParserSupport; 029import org.x4o.xml.eld.EldParserSupportCore; 030import org.x4o.xml.test.TestParserSupport; 031import org.x4o.xml.test.swixml.SwiXmlParserSupport2; 032import org.x4o.xml.test.swixml.SwiXmlParserSupport3; 033 034import junit.framework.TestCase; 035 036/** 037 * Test for eld doc generation 038 * 039 * @author Willem Cazander 040 * @version 1.0 Aug 26, 2010 041 */ 042public class EldDocTest extends TestCase { 043 044 private File getTempPath(String dir) throws Exception { 045 File tempFile = File.createTempFile("test-path", ".tmp"); 046 String absolutePath = tempFile.getAbsolutePath(); 047 String tempPath = absolutePath.substring(0,absolutePath.lastIndexOf(File.separator)+1); 048 tempFile.delete(); 049 File result = new File(tempPath+File.separator+dir); 050 if (result.exists()==false) { 051 result.mkdir(); 052 } 053 return result; 054 } 055 056 public void testCelDoc() throws Exception { 057 X4OLanguageEldDocWriter writer = new X4OLanguageEldDocWriter(); 058 writer.setBasePath(getTempPath("junit-cel")); 059 writer.setLanguageParserSupport(EldParserSupportCore.class); 060 writer.execute(); 061 } 062 063 public void testEldDoc() throws Exception { 064 X4OLanguageEldDocWriter writer = new X4OLanguageEldDocWriter(); 065 writer.setBasePath(getTempPath("junit-eld")); 066 writer.setLanguageParserSupport(EldParserSupport.class); 067 writer.execute(); 068 } 069 070 public void testUnitDoc() throws Exception { 071 X4OLanguageEldDocWriter writer = new X4OLanguageEldDocWriter(); 072 writer.setBasePath(getTempPath("junit-test")); 073 writer.setLanguageParserSupport(TestParserSupport.class); 074 writer.execute(); 075 } 076 077 public void testSwiXml2Doc() throws Exception { 078 X4OLanguageEldDocWriter writer = new X4OLanguageEldDocWriter(); 079 writer.setBasePath(getTempPath("junit-swixml2")); 080 writer.setLanguageParserSupport(SwiXmlParserSupport2.class); 081 writer.execute(); 082 } 083 084 public void testSwiXml3Doc() throws Exception { 085 X4OLanguageEldDocWriter writer = new X4OLanguageEldDocWriter(); 086 writer.setBasePath(getTempPath("junit-swixml3")); 087 writer.setLanguageParserSupport(SwiXmlParserSupport3.class); 088 writer.execute(); 089 } 090 091 092 public void testEldDocMain() throws Exception { 093 X4OLanguageEldDocWriter.main(new String[] {"-path",getTempPath("junit-test-main").getAbsolutePath(),"-class",EldParserSupport.class.getName()}); 094 } 095}