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