KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > attributes > test > SealableTestCase


1 /*
2  * Copyright 2003-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * 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.commons.attributes.test;
17
18 import java.lang.reflect.Field JavaDoc;
19 import java.lang.reflect.Method JavaDoc;
20 import java.lang.reflect.Constructor JavaDoc;
21 import java.io.File JavaDoc;
22 import java.net.URL JavaDoc;
23 import java.net.URLClassLoader JavaDoc;
24 import java.util.Collection JavaDoc;
25 import java.util.Iterator JavaDoc;
26 import org.apache.commons.attributes.Attributes;
27 import org.apache.commons.attributes.AttributeIndex;
28 import junit.framework.TestCase;
29
30 public class SealableTestCase extends TestCase {
31     
32     public void testSealable () throws Exception JavaDoc {
33         Method JavaDoc m = Sample.class.getMethod ("methodWithNamedParameters", new Class JavaDoc[]{ });
34         BeanAttribute attribute = (BeanAttribute) Attributes.getAttributes (m, BeanAttribute.class).iterator ().next ();
35         
36         try {
37             attribute.setName ("Joe Doe");
38             fail ("Attribute should be sealed!");
39         } catch (IllegalStateException JavaDoc ise) {
40             // -- OK, attribute should be sealed.
41
}
42     }
43 }
Popular Tags