Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libTools / src-test / org / gvsig / tools / exception / BaseRuntimeExceptionTest.java @ 23150

History | View | Annotate | Download (1.46 KB)

1
package org.gvsig.tools.exception;
2

    
3
import java.util.Map;
4

    
5
public class BaseRuntimeExceptionTest extends BaseExceptionTest {
6
    
7
    public void testRuntimeExceptionNature() {
8
        Object test = new Object() {
9

    
10
            public String toString() {
11
                throw new BaseRuntimeException("ERROR", "ERROR", 1) {
12
                    protected Map values() {
13
                        return null;
14
                    }
15
                };
16
            }
17
            
18
        };
19
        
20
        try {
21
            test.toString();
22
            fail("RuntimeException not generated");
23
        } catch (RuntimeException rex) {
24
            // success
25
        }
26
    }
27

    
28
    protected IBaseException createBadDateException(String driver,
29
            Throwable throwable) {
30
        return new BadDateException(driver, throwable);
31
    }
32

    
33
    protected IBaseException createDriverException(String driver,
34
            Throwable throwable) {
35
        return new DriverRuntimeException(driver, throwable);
36
    }
37

    
38
    class BadDateException extends DriverRuntimeException {
39
        private static final long serialVersionUID = -8985920349210629998L;
40
        private static final String KEY = "Driver_%(driverName)s_Formato_de_fecha_incorrecto";
41

    
42
        private static final String MESSAGE = "Driver %(driverName)s: Formato de fecha incorrecto";
43

    
44
        public BadDateException(String driverName, Throwable cause) {
45
            super(driverName, MESSAGE, cause, KEY, serialVersionUID);
46
        }
47
    }
48

    
49
}