01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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.java.lang.instrument;
19:
20: import java.lang.instrument.ClassDefinition;
21:
22: import junit.framework.TestCase;
23:
24: public class ClassDefinitionTest extends TestCase {
25:
26: /**
27: * @tests java.lang.instrument.ClassDefinition#ClassDefinition(Class<?>, byte[])
28: */
29: public void test_ConstructorLClass$B() {
30: try {
31: new ClassDefinition(null, null);
32: fail("Should throw NullPointerException");
33: } catch (NullPointerException e) {
34: // expected
35: }
36: try {
37: new ClassDefinition(null, new byte[0]);
38: fail("Should throw NullPointerException");
39: } catch (NullPointerException e) {
40: // expected
41: }
42: try {
43: new ClassDefinition(this .getClass(), null);
44: fail("Should throw NullPointerException");
45: } catch (NullPointerException e) {
46: // expected
47: }
48: }
49:
50: /**
51: * @tests java.lang.instrument.ClassDefinition#getDefinitionClass()
52: */
53: public void test_getDefinitionClass() {
54: ClassDefinition cd = new ClassDefinition(this .getClass(),
55: new byte[0]);
56: assertSame(this .getClass(), cd.getDefinitionClass());
57: }
58:
59: /**
60: * @tests java.lang.instrument.ClassDefinition#getDefinitionClassFile()
61: */
62: public void test_getDefinitionClassFile() {
63: byte[] emptyByteArray = new byte[0];
64: byte[] someByteArray = new byte[1024];
65: ClassDefinition cd = new ClassDefinition(this .getClass(),
66: emptyByteArray);
67: assertSame(emptyByteArray, cd.getDefinitionClassFile());
68: cd = new ClassDefinition(this.getClass(), someByteArray);
69: assertSame(someByteArray, cd.getDefinitionClassFile());
70: }
71: }
|