1 /* 2 * Copyright (C) The Spice Group. All rights reserved. 3 * 4 * This software is published under the terms of the Spice 5 * Software License version 1.1, a copy of which has been included 6 * with this distribution in the LICENSE.txt file. 7 */ 8 package org.codehaus.spice.xmlpolicy.metadata; 9 10 import junit.framework.TestCase; 11 12 /*** 13 * TestCase for {@link org.codehaus.spice.xmlpolicy.reader.PolicyReader}. 14 * 15 * @author Peter Donald 16 */ 17 public class MetaDataTestCase 18 extends TestCase 19 { 20 public MetaDataTestCase( final String name ) 21 { 22 super( name ); 23 } 24 25 public void testNullClassNameInPermissionCtor() 26 throws Exception 27 { 28 try 29 { 30 new PermissionMetaData( null, null, null, null, null ); 31 fail( "Expected to fail due to null pointer in ctor" ); 32 } 33 catch( final NullPointerException npe ) 34 { 35 assertEquals( "NPE message", 36 "classname", 37 npe.getMessage() ); 38 } 39 } 40 41 public void testNullPermissionsInGrantCtor() 42 throws Exception 43 { 44 try 45 { 46 new GrantMetaData( null, null, null, null ); 47 fail( "Expected to fail due to null pointer in ctor" ); 48 } 49 catch( final NullPointerException npe ) 50 { 51 assertEquals( "NPE message", 52 "permissions", 53 npe.getMessage() ); 54 } 55 } 56 57 public void testNullPermissionsElementInGrantCtor() 58 throws Exception 59 { 60 try 61 { 62 new GrantMetaData( null, null, null, new PermissionMetaData[]{null} ); 63 fail( "Expected to fail due to null pointer in ctor" ); 64 } 65 catch( final NullPointerException npe ) 66 { 67 assertEquals( "NPE message", 68 "permissions[0]", 69 npe.getMessage() ); 70 } 71 } 72 73 74 public void testNullSignedByNonNullKeyStoreInGrantCtor() 75 throws Exception 76 { 77 try 78 { 79 new GrantMetaData( null, null, "default", new PermissionMetaData[0] ); 80 fail( "Expected to fail due to null pointer in ctor" ); 81 } 82 catch( final NullPointerException npe ) 83 { 84 assertEquals( "NPE message", 85 "signedBy", 86 npe.getMessage() ); 87 } 88 } 89 90 public void testNullKeyStoreNonNullSignedByInGrantCtor() 91 throws Exception 92 { 93 try 94 { 95 new GrantMetaData( null, "default", null, new PermissionMetaData[ 0 ] ); 96 fail( "Expected to fail due to null pointer in ctor" ); 97 } 98 catch( final NullPointerException npe ) 99 { 100 assertEquals( "NPE message", 101 "keyStore", 102 npe.getMessage() ); 103 } 104 } 105 106 public void testNullNameInKeyStoreCtor() 107 throws Exception 108 { 109 try 110 { 111 new KeyStoreMetaData( null, "", "" ); 112 fail( "Expected to fail due to null pointer in ctor" ); 113 } 114 catch( final NullPointerException npe ) 115 { 116 assertEquals( "NPE message", 117 "name", 118 npe.getMessage() ); 119 } 120 } 121 122 public void testNullLocationInKeyStoreCtor() 123 throws Exception 124 { 125 try 126 { 127 new KeyStoreMetaData( "", null, "" ); 128 fail( "Expected to fail due to null pointer in ctor" ); 129 } 130 catch( final NullPointerException npe ) 131 { 132 assertEquals( "NPE message", 133 "location", 134 npe.getMessage() ); 135 } 136 } 137 138 public void testNullTypeInKeyStoreCtor() 139 throws Exception 140 { 141 try 142 { 143 new KeyStoreMetaData( "", "", null ); 144 fail( "Expected to fail due to null pointer in ctor" ); 145 } 146 catch( final NullPointerException npe ) 147 { 148 assertEquals( "NPE message", 149 "type", 150 npe.getMessage() ); 151 } 152 } 153 154 public void testNullKeyStoreNonNullSignedByInPermissionCtor() 155 throws Exception 156 { 157 try 158 { 159 new PermissionMetaData( "", "", "", "", null ); 160 fail( "Expected to fail due to null pointer in ctor" ); 161 } 162 catch( final NullPointerException npe ) 163 { 164 assertEquals( "NPE message", 165 "keyStore", 166 npe.getMessage() ); 167 } 168 } 169 170 public void testNullSignedByNonNullKeyStoreInPermissionCtor() 171 throws Exception 172 { 173 try 174 { 175 new PermissionMetaData( "", "","", null, "default" ); 176 fail( "Expected to fail due to null pointer in ctor" ); 177 } 178 catch( final NullPointerException npe ) 179 { 180 assertEquals( "NPE message", 181 "signedBy", 182 npe.getMessage() ); 183 } 184 } 185 186 }

This page was automatically generated by Maven