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: package org.apache.harmony.pack200.tests;
18:
19: import junit.framework.TestCase;
20:
21: import org.apache.harmony.pack200.AttrDefinitionBands;
22: import org.apache.harmony.pack200.AttributeLayoutMap;
23: import org.apache.harmony.pack200.Pack200Exception;
24: import org.apache.harmony.pack200.Segment;
25: import org.apache.harmony.pack200.SegmentHeader;
26: import org.apache.harmony.pack200.SegmentOptions;
27:
28: /**
29: *
30: */
31: public abstract class AbstractBandsTestCase extends TestCase {
32:
33: protected int numClasses = 1;
34: protected int[] numMethods = { 1 };
35:
36: public class MockSegmentHeader extends SegmentHeader {
37: public int getClassCount() {
38: return numClasses;
39: }
40:
41: public SegmentOptions getOptions() {
42: try {
43: return new SegmentOptions(0);
44: } catch (Pack200Exception e) {
45: return null;
46: }
47: }
48: }
49:
50: public class MockAttributeDefinitionBands extends
51: AttrDefinitionBands {
52:
53: public MockAttributeDefinitionBands(Segment segment) {
54: super (segment);
55: }
56:
57: public AttributeLayoutMap getAttributeDefinitionMap() {
58: try {
59: return new AttributeLayoutMap();
60: } catch (Pack200Exception e) {
61: fail(e.getLocalizedMessage());
62: }
63: return null;
64: }
65:
66: }
67:
68: public class MockSegment extends Segment {
69:
70: protected AttrDefinitionBands getAttrDefinitionBands() {
71: return new MockAttributeDefinitionBands(this );
72: }
73:
74: public SegmentHeader getSegmentHeader() {
75: return new MockSegmentHeader();
76: }
77: }
78:
79: }
|