Home | History | Annotate | Download | only in auth
      1 /*
      2  *  Licensed to the Apache Software Foundation (ASF) under one or more
      3  *  contributor license agreements.  See the NOTICE file distributed with
      4  *  this work for additional information regarding copyright ownership.
      5  *  The ASF licenses this file to You under the Apache License, Version 2.0
      6  *  (the "License"); you may not use this file except in compliance with
      7  *  the License.  You may obtain a copy of the License at
      8  *
      9  *     http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *  See the License for the specific language governing permissions and
     15  *  limitations under the License.
     16  */
     17 
     18 package org.apache.harmony.tests.javax.security.auth;
     19 
     20 import junit.framework.TestCase;
     21 import javax.security.auth.DestroyFailedException;
     22 import org.apache.harmony.testframework.serialization.SerializationTest;
     23 
     24 /**
     25  * Tests for <code>DestroyFailedException</code> class constructors and methods.
     26  *
     27  */
     28 public class DestroyFailedExceptionTest extends TestCase {
     29 
     30     private static String[] msgs = {
     31             "",
     32             "Check new message",
     33             "Check new message Check new message Check new message Check new message Check new message" };
     34 
     35 
     36     /**
     37      * javax.security.auth.DestroyFailedException#DestroyFailedException()
     38      * Assertion: constructs DestroyFailedException with no detail message
     39      */
     40     public void testDestroyFailedException01() {
     41         DestroyFailedException dfE = new DestroyFailedException();
     42         assertNull("getMessage() must return null.", dfE.getMessage());
     43         assertNull("getCause() must return null", dfE.getCause());
     44     }
     45 
     46     /**
     47      * javax.security.auth.DestroyFailedException#DestroyFailedException(String msg)
     48      * Assertion: constructs with not null parameter.
     49      */
     50     public void testDestroyFailedException02() {
     51         DestroyFailedException dfE;
     52         for (int i = 0; i < msgs.length; i++) {
     53             dfE = new DestroyFailedException(msgs[i]);
     54             assertEquals("getMessage() must return: ".concat(msgs[i]), dfE.getMessage(), msgs[i]);
     55             assertNull("getCause() must return null", dfE.getCause());
     56         }
     57     }
     58 
     59     /**
     60      * javax.security.auth.DestroyFailedException#DestroyFailedException(String msg)
     61      * Assertion: constructs with null parameter.
     62      */
     63     public void testDestroyFailedException03() {
     64         String msg = null;
     65         DestroyFailedException dfE = new DestroyFailedException(msg);
     66         assertNull("getMessage() must return null.", dfE.getMessage());
     67         assertNull("getCause() must return null", dfE.getCause());
     68     }
     69 
     70     public void testSerializationSelf() throws Exception {
     71         SerializationTest.verifySelf(getSerializationData());
     72     }
     73 
     74     public void testSerializationGolden() throws Exception {
     75         SerializationTest.verifyGolden(this, getSerializationData());
     76     }
     77 
     78     private Object[] getSerializationData() {
     79         return new Object[] { new DestroyFailedException("message") };
     80     }
     81 }
     82