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; 025 026import java.io.File; 027 028import org.x4o.xml.eld.xsd.X4OLanguageEldXsdWriter; 029import org.x4o.xml.test.swixml.SwiXmlParserSupport2; 030 031import junit.framework.TestCase; 032 033/** 034 * Tests some code for eld schema generating 035 * 036 * @author Willem Cazander 037 * @version 1.0 Auh 16, 2012 038 */ 039public class EldSchemaTest extends TestCase { 040 041 private File getTempPath(String dir) throws Exception { 042 File tempFile = File.createTempFile("test-path", ".tmp"); 043 String absolutePath = tempFile.getAbsolutePath(); 044 String tempPath = absolutePath.substring(0,absolutePath.lastIndexOf(File.separator)+1); 045 tempFile.delete(); 046 File result = new File(tempPath+File.separator+dir); 047 if (result.exists()==false) { 048 result.mkdir(); 049 } 050 return result; 051 } 052 053 public void testEldSchema() throws Exception { 054 X4OLanguageEldXsdWriter writer = new X4OLanguageEldXsdWriter(); 055 writer.setBasePath(getTempPath("junit-xsd-eld")); 056 writer.setLanguageParserSupport(EldParserSupport.class); 057 writer.execute(); 058 } 059 060 public void testEldCoreSchema() throws Exception { 061 X4OLanguageEldXsdWriter writer = new X4OLanguageEldXsdWriter(); 062 writer.setBasePath(getTempPath("junit-xsd-cel")); 063 writer.setLanguageParserSupport(EldParserSupportCore.class); 064 writer.execute(); 065 } 066 067 public void testSwiXmlSchema() throws Exception { 068 X4OLanguageEldXsdWriter writer = new X4OLanguageEldXsdWriter(); 069 writer.setBasePath(getTempPath("junit-xsd-swixml2")); 070 writer.setLanguageParserSupport(SwiXmlParserSupport2.class); 071 writer.execute(); 072 } 073 074 public void testEldDocMain() throws Exception { 075 X4OLanguageEldXsdWriter.main(new String[] {"-path",getTempPath("junit-xsd-main").getAbsolutePath(),"-class",EldParserSupport.class.getName()}); 076 } 077}