View Javadoc
1   /*
2    * Copyright 2007 Kasper B. Graversen
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.supercsv.exception;
17  
18  import static org.junit.Assert.assertEquals;
19  import static org.junit.Assert.assertNull;
20  
21  import org.junit.Test;
22  
23  /**
24   * Tests the SuperCsvReflectionException class.
25   * 
26   * @author James Bassett
27   */
28  public class SuperCsvReflectionExceptionTest {
29  	
30  	private static final String MSG = "Reflection failed";
31  	private static final Throwable THROWABLE = new RuntimeException("Mirror is broken");
32  	
33  	/**
34  	 * Tests the first constructor.
35  	 */
36  	@Test
37  	public void testConstructor1() {
38  		SuperCsvReflectionException e = new SuperCsvReflectionException(MSG);
39  		assertEquals(MSG, e.getMessage());
40  		
41  		// test with null msg
42  		e = new SuperCsvReflectionException(null);
43  		assertNull(e.getMessage());
44  	}
45  	
46  	/**
47  	 * Tests the second constructor.
48  	 */
49  	@Test
50  	public void testConstructor2() {
51  		SuperCsvReflectionException e = new SuperCsvReflectionException(MSG, THROWABLE);
52  		assertEquals(MSG, e.getMessage());
53  		assertEquals(THROWABLE, e.getCause());
54  		
55  		// test with null msg
56  		e = new SuperCsvReflectionException(null, null);
57  		assertNull(e.getMessage());
58  		assertNull(e.getCause());
59  	}
60  	
61  }