001 package org.picocontainer.script; 002 003 import static java.util.Arrays.asList; 004 import static org.junit.Assert.assertEquals; 005 import static org.junit.Assert.assertNotNull; 006 import static org.junit.Assert.assertTrue; 007 008 import org.junit.After; 009 import org.junit.Before; 010 import org.junit.Test; 011 012 /** 013 * Exception Tests. 014 * @author Michael Rimov 015 */ 016 public class UnsupportedScriptTypeExceptionTestCase { 017 private UnsupportedScriptTypeException unsupportedScriptTypeException = null; 018 019 private final String[] supportedParams = new String[]{".groovy",".py",".xml"}; 020 021 @Before public void setUp() throws Exception { 022 unsupportedScriptTypeException = new UnsupportedScriptTypeException("test.txt", supportedParams); 023 } 024 025 @After public void tearDown() throws Exception { 026 unsupportedScriptTypeException = null; 027 } 028 029 @Test public void testGetMessage() { 030 String actualReturn = unsupportedScriptTypeException.getMessage(); 031 assertNotNull(actualReturn); 032 assertTrue(actualReturn.indexOf(".groovy") > -1); 033 assertTrue(actualReturn.indexOf(".py") > -1) ; 034 assertTrue(actualReturn.indexOf(".xml") > -1); 035 assertTrue(actualReturn.indexOf("test.txt") > -1); 036 } 037 038 @Test public void testGetRequestedExtension() { 039 String expectedReturn = "test.txt"; 040 String actualReturn = unsupportedScriptTypeException.getRequestedExtension(); 041 assertEquals("return value", expectedReturn, actualReturn); 042 } 043 044 @Test public void testGetSystemSupportedExtensions() { 045 String[] expectedReturn = supportedParams; 046 String[] actualReturn = unsupportedScriptTypeException.getSystemSupportedExtensions(); 047 assertEquals("return value", asList(expectedReturn), asList(actualReturn)); 048 } 049 050 051 }