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  package org.apache.commons.imaging.formats.xbm;
16  
17  import static org.junit.jupiter.api.Assertions.assertFalse;
18  import static org.junit.jupiter.api.Assertions.assertNotNull;
19  
20  import java.awt.image.BufferedImage;
21  import java.io.File;
22  import java.util.List;
23  
24  import org.apache.commons.imaging.ImageInfo;
25  import org.apache.commons.imaging.Imaging;
26  import org.apache.commons.imaging.common.ImageMetadata;
27  import org.apache.commons.imaging.internal.Debug;
28  import org.junit.jupiter.api.Test;
29  
30  public class XbmReadTest extends XbmBaseTest {
31  
32      @Test
33      public void test() throws Exception {
34          Debug.debug("start");
35  
36          final List<File> images = getXbmImages();
37          for (final File imageFile : images) {
38  
39              Debug.debug("imageFile", imageFile);
40  
41              final ImageMetadata metadata = Imaging.getMetadata(imageFile);
42              assertFalse(metadata instanceof File); // Dummy check to avoid unused warning (it may be null)
43  
44              final ImageInfo imageInfo = Imaging.getImageInfo(imageFile);
45              assertNotNull(imageInfo);
46  
47              final BufferedImage image = Imaging.getBufferedImage(imageFile);
48              assertNotNull(image);
49          }
50      }
51  
52  }