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  
18  package org.apache.commons.imaging.formats.bmp;
19  
20  import static org.junit.Assert.assertNotNull;
21  
22  import java.awt.image.BufferedImage;
23  import java.io.File;
24  import java.io.IOException;
25  import java.util.Collection;
26  import java.util.Collections;
27  import java.util.Map;
28  
29  import org.apache.commons.imaging.ImageInfo;
30  import org.apache.commons.imaging.ImageReadException;
31  import org.apache.commons.imaging.Imaging;
32  import org.junit.Ignore;
33  import org.junit.Test;
34  import org.junit.runner.RunWith;
35  import org.junit.runners.Parameterized;
36  
37  @RunWith(Parameterized.class)
38  public class BmpReadTest extends BmpBaseTest {
39  
40      private final File imageFile;
41  
42      @Parameterized.Parameters
43      public static Collection<File> data() throws Exception {
44          return getBmpImages();
45      }
46  
47      public BmpReadTest(final File imageFile) {
48          this.imageFile = imageFile;
49      }
50  
51      @Test
52      public void testImageInfo() throws ImageReadException, IOException {
53          final Map<String, Object> params = Collections.emptyMap();
54          final ImageInfo imageInfo = Imaging.getImageInfo(imageFile, params);
55          assertNotNull(imageInfo);
56          // TODO assert more
57      }
58  
59      @Ignore(value = "RoundtripTest has to be fixed befor implementation can throw UnsupportedOperationException")
60      @Test(expected = UnsupportedOperationException.class)
61      public void testMetaData() throws ImageReadException, IOException {
62          Imaging.getMetadata(imageFile);
63      }
64  
65      @Test
66      public void testBufferedImage() throws Exception {
67          final BufferedImage image = Imaging.getBufferedImage(imageFile);
68          assertNotNull(image);
69          // TODO assert more
70      }
71  
72  }