View Javadoc
1   /*
2    *  Licensed under the Apache License, Version 2.0 (the "License");
3    *  you may not use this file except in compliance with the License.
4    *  You may obtain a copy of the License at
5    * 
6    *       http://www.apache.org/licenses/LICENSE-2.0
7    * 
8    *  Unless required by applicable law or agreed to in writing, software
9    *  distributed under the License is distributed on an "AS IS" BASIS,
10   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11   *  See the License for the specific language governing permissions and
12   *  limitations under the License.
13   *  under the License.
14   */
15  
16  package org.apache.commons.imaging.formats.xbm;
17  
18  import static org.junit.Assert.assertNotNull;
19  
20  import java.awt.image.BufferedImage;
21  import java.io.File;
22  import java.util.HashMap;
23  import java.util.List;
24  import java.util.Map;
25  
26  import org.apache.commons.imaging.ImageInfo;
27  import org.apache.commons.imaging.Imaging;
28  import org.apache.commons.imaging.common.ImageMetadata;
29  import org.apache.commons.imaging.util.Debug;
30  import org.junit.Assert;
31  import org.junit.Test;
32  
33  public class XbmReadTest extends XbmBaseTest {
34  
35      @Test
36      public void test() throws Exception {
37          Debug.debug("start");
38  
39          final List<File> images = getXbmImages();
40          for (final File imageFile : images) {
41  
42              Debug.debug("imageFile", imageFile);
43  
44              final ImageMetadata metadata = Imaging.getMetadata(imageFile);
45              Assert.assertFalse(metadata instanceof File); // Dummy check to avoid unused warning (it may be null)
46  
47              final Map<String, Object> params = new HashMap<>();
48              final ImageInfo imageInfo = Imaging.getImageInfo(imageFile, params);
49              assertNotNull(imageInfo);
50  
51              final BufferedImage image = Imaging.getBufferedImage(imageFile);
52              assertNotNull(image);
53          }
54      }
55  
56  }