DestroyableTest.java revision ab762bb740405d0fefcccf4a0899a234f995be13
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 18package tests.api.javax.security.auth; 19 20import junit.framework.TestCase; 21 22import javax.security.auth.Destroyable; 23import javax.security.auth.DestroyFailedException; 24 25 26/** 27 * Tests for <code>Destroyable</code> class constructors and methods. 28 * 29 */ 30public class DestroyableTest extends TestCase { 31 32 /** 33 * javax.security.auth.Destroyable#destroy() 34 * javax.security.auth.Destroyable#isDestroyed() 35 */ 36 public void test_destroy() { 37 myDestroyable md = new myDestroyable(); 38 try { 39 assertFalse(md.isDestroyed()); 40 md.destroy(); 41 assertTrue(md.isDestroyed()); 42 } catch (Exception e) { 43 fail("Unexpected exception " + e); 44 } 45 } 46 47 private class myDestroyable implements Destroyable { 48 49 boolean destroyDone = false; 50 51 myDestroyable() { 52 } 53 54 public void destroy() throws DestroyFailedException { 55 destroyDone = true; 56 } 57 58 public boolean isDestroyed() { 59 return destroyDone; 60 } 61 } 62} 63 64 65