View Javadoc

1   /*
2    * Copyright 2007-2011 smartics, Kronseder & Reiner GmbH
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 de.smartics.exceptions.i18n;
17  
18  import static org.junit.Assert.assertEquals;
19  import static org.junit.Assert.assertTrue;
20  
21  import org.junit.Test;
22  
23  import de.smartics.exceptions.i18n.app.ConfigurationExceptionCode;
24  import de.smartics.exceptions.i18n.message.MessageType;
25  import de.smartics.util.test.io.SerialTestUtils;
26  
27  /**
28   * Checks that the messages are correctly rendered for the exception
29   * {@link ConfigurationException}.
30   *
31   * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a>
32   * @version $Revision:591 $
33   */
34  public class ConfigurationExceptionTest
35  {
36    // ********************************* Fields *********************************
37  
38    // --- constants ------------------------------------------------------------
39  
40    // --- members --------------------------------------------------------------
41  
42    // ****************************** Inner Classes *****************************
43  
44    // ********************************* Methods ********************************
45  
46    // --- prepare --------------------------------------------------------------
47  
48    // --- helper ---------------------------------------------------------------
49  
50    // --- tests ----------------------------------------------------------------
51  
52    /**
53     * Creates exception with code <code>1000</code>.
54     */
55    @Test
56    public void create1000()
57    {
58      final ConfigurationException e =
59          new MethodAccessConfigurationException(null,
60              ConfigurationExceptionCode.GENERIC, "propertyName", Object.class,
61              "methodName");
62      final String header = e.getMessage(MessageType.TITLE);
63      assertEquals("Configuration Error", header); // NOPMD
64      final String summary = e.getMessage(MessageType.SUMMARY);
65      assertEquals("The configuration of the exception library is inconsistent.", // NOPMD
66          summary);
67      final String details = e.getMessage(MessageType.DETAILS);
68      assertEquals("The system is unable to report more detailed information.", // NOPMD
69          details);
70    }
71  
72    /**
73     * Tests that the exception is serializable.
74     */
75    @Test
76    public void testSerial()
77    {
78      final ConfigurationException uut =
79          new MethodAccessConfigurationException(null,
80              ConfigurationExceptionCode.GENERIC, "propertyName", Object.class,
81              "methodName");
82      SerialTestUtils.runSerializationQuietly(uut);
83      assertTrue("Serialization successful.", true);
84    }
85  }