1 /* Licensed to the Apache Software Foundation (ASF) under one or more 2 * contributor license agreements. See the NOTICE file distributed with 3 * this work for additional information regarding copyright ownership. 4 * The ASF licenses this file to You under the Apache License, Version 2.0 5 * (the "License"); you may not use this file except in compliance with 6 * the License. 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.apache.harmony.luni.tests.java.util; 17 18 import java.io.Serializable; 19 import java.util.InputMismatchException; 20 import java.util.NoSuchElementException; 21 22 import junit.framework.TestCase; 23 24 import org.apache.harmony.testframework.serialization.SerializationTest; 25 26 public class InputMismatchExceptionTest extends TestCase { 27 28 private static final String ERROR_MESSAGE = "for serialization test"; //$NON-NLS-1$ 29 30 /** 31 * @tests java.util.InputMismatchException#InputMismatchException() 32 */ 33 @SuppressWarnings("cast") 34 public void test_Constructor() { 35 InputMismatchException exception = new InputMismatchException(); 36 assertNotNull(exception); 37 assertTrue(exception instanceof NoSuchElementException); 38 assertTrue(exception instanceof Serializable); 39 } 40 41 /** 42 * @tests java.util.InputMismatchException#InputMismatchException(String) 43 */ 44 public void test_ConstructorLjava_lang_String() { 45 InputMismatchException exception = new InputMismatchException( 46 ERROR_MESSAGE); 47 assertNotNull(exception); 48 assertEquals(ERROR_MESSAGE, exception.getMessage()); 49 } 50 51 /** 52 * @tests serialization/deserialization. 53 */ 54 public void testSerializationSelf() throws Exception { 55 56 SerializationTest.verifySelf(new InputMismatchException(ERROR_MESSAGE)); 57 } 58 59 /** 60 * @tests serialization/deserialization compatibility with RI. 61 */ 62 public void testSerializationCompatibility() throws Exception { 63 64 SerializationTest.verifyGolden(this, new InputMismatchException( 65 ERROR_MESSAGE)); 66 } 67 } 68