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: ValidateModelTaskTest.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.ValidateModelTask; 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.assertNoException; 041 import org.junit.Test; 042 043 /** 044 * Test cases for class {@code org.jomc.ant.ValidateModelTask}. 045 * 046 * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 047 * @version $JOMC: ValidateModelTaskTest.java 3879 2011-10-24 00:59:27Z schulte2005 $ 048 */ 049 public class ValidateModelTaskTest extends JomcModelTaskTest 050 { 051 052 /** Creates a new {@code ValidateModelTaskTest} instance. */ 053 public ValidateModelTaskTest() 054 { 055 super(); 056 } 057 058 /** {@inheritDoc} */ 059 @Override 060 public ValidateModelTask getJomcTask() 061 { 062 return (ValidateModelTask) super.getJomcTask(); 063 } 064 065 /** {@inheritDoc} */ 066 @Override 067 protected ValidateModelTask newJomcTask() 068 { 069 return new ValidateModelTask(); 070 } 071 072 /** {@inheritDoc} */ 073 @Override 074 protected String getBuildFileName() 075 { 076 return "validate-model-test.xml"; 077 } 078 079 @Test 080 public final void testValidateModel() throws Exception 081 { 082 final AntExecutionResult r = this.executeTarget( "test-validate-model" ); 083 assertNoException( r ); 084 assertMessageLogged( r, "Model validation successful.", Project.MSG_INFO ); 085 } 086 087 @Test 088 public final void testValidateModelWithRedundantResources() throws Exception 089 { 090 final AntExecutionResult r = this.executeTarget( "test-validate-model-with-redundant-resources" ); 091 assertNoException( r ); 092 assertMessageLogged( r, "Model validation successful.", Project.MSG_INFO ); 093 } 094 095 @Test 096 public final void testValidateModelWithBrokenModel() throws Exception 097 { 098 final AntExecutionResult r = this.executeTarget( "test-validate-model-with-broken-model" ); 099 assertException( r, BuildException.class ); 100 assertExceptionMessage( r, "Model validation failure." ); 101 } 102 103 }