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 org.apache.harmony.logging.tests.java.util.logging; 19 20import dalvik.annotation.TestTargets; 21import dalvik.annotation.TestLevel; 22import dalvik.annotation.TestTargetNew; 23import dalvik.annotation.TestTargetClass; 24 25import java.util.logging.LoggingPermission; 26 27import junit.framework.TestCase; 28 29import org.apache.harmony.testframework.serialization.SerializationTest; 30 31@TestTargetClass(LoggingPermission.class) 32public class LoggingPermissionTest extends TestCase { 33 34 /** 35 * @tests serialization/deserialization compatibility. 36 */ 37 @TestTargetNew( 38 level = TestLevel.COMPLETE, 39 notes = "", 40 method = "!SerializationSelf", 41 args = {} 42 ) 43 public void testSerializationSelf() throws Exception { 44 SerializationTest.verifySelf(new LoggingPermission("control", "")); 45 } 46 47 /** 48 * @tests serialization/deserialization compatibility with RI. 49 */ 50 @TestTargetNew( 51 level = TestLevel.COMPLETE, 52 notes = "", 53 method = "!SerializationGolden", 54 args = {} 55 ) 56 public void testSerializationCompatibility() throws Exception { 57 58 SerializationTest.verifyGolden(this, new LoggingPermission("control", 59 "")); 60 } 61 62 @TestTargetNew( 63 level = TestLevel.COMPLETE, 64 notes = "", 65 method = "LoggingPermission", 66 args = {java.lang.String.class, java.lang.String.class} 67 ) 68 public void testLoggingPermission() { 69 try { 70 new LoggingPermission(null, null); 71 fail("should throw IllegalArgumentException"); 72 } catch (NullPointerException e) { 73 } 74 try { 75 new LoggingPermission("", null); 76 fail("should throw IllegalArgumentException"); 77 } catch (IllegalArgumentException e) { 78 } 79 try { 80 new LoggingPermission("bad name", null); 81 fail("should throw IllegalArgumentException"); 82 } catch (IllegalArgumentException e) { 83 } 84 try { 85 new LoggingPermission("Control", null); 86 fail("should throw IllegalArgumentException"); 87 } catch (IllegalArgumentException e) { 88 } 89 try { 90 new LoggingPermission("control", 91 "bad action"); 92 fail("should throw IllegalArgumentException"); 93 } catch (IllegalArgumentException e) { 94 } 95 96 new LoggingPermission("control", ""); 97 98 new LoggingPermission("control", null); 99 } 100 101} 102