View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   https://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.commons.compress.harmony.unpack200;
20  
21  import static org.junit.jupiter.api.Assertions.assertEquals;
22  
23  import java.io.ByteArrayInputStream;
24  import java.io.IOException;
25  import java.io.InputStream;
26  
27  import org.apache.commons.compress.harmony.pack200.BHSDCodec;
28  import org.apache.commons.compress.harmony.pack200.Codec;
29  import org.apache.commons.compress.harmony.pack200.Pack200Exception;
30  import org.junit.jupiter.api.Disabled;
31  import org.junit.jupiter.api.Test;
32  
33  class BandSetTest {
34  
35      public class MockSegment extends Segment {
36  
37          @Override
38          public SegmentHeader getSegmentHeader() {
39              return new SegmentHeader(this);
40          }
41      }
42  
43      private final BandSet bandSet = new BandSet(new MockSegment()) {
44  
45          @Override
46          public void read(final InputStream inputStream) throws IOException, Pack200Exception {
47          }
48  
49          @Override
50          public void unpack() throws IOException, Pack200Exception {
51          }
52  
53      };
54  
55      @Test
56      void testDecodeBandInt() throws IOException, Pack200Exception {
57          final BHSDCodec codec = Codec.BYTE1;
58          final byte[] bytes = { (byte) 3, (byte) 56, (byte) 122, (byte) 78 };
59          final InputStream in = new ByteArrayInputStream(bytes);
60          final int[] ints = bandSet.decodeBandInt("Test Band", in, codec, 4);
61          for (int i = 0; i < ints.length; i++) {
62              assertEquals(ints[i], bytes[i], "Wrong value in position " + i);
63          }
64      }
65  
66      @Test
67      @Disabled("TODO: Implement")
68      void testParseFlags1() {
69  
70      }
71  
72      @Test
73      @Disabled("TODO: Implement")
74      void testParseFlags2() {
75  
76      }
77  
78      @Test
79      @Disabled("TODO: Implement")
80      void testParseFlags3() {
81  
82      }
83  
84      @Test
85      @Disabled("TODO: Implement")
86      void testParseReferences1() {
87  
88      }
89  
90      @Test
91      @Disabled("TODO: Implement")
92      void testParseReferences2() {
93  
94      }
95  
96  }