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.jpeg.exif;
19  
20  import static org.junit.Assert.assertNotNull;
21  
22  import java.io.File;
23  import java.util.Collection;
24  import java.util.HashMap;
25  import java.util.Map;
26  
27  import org.apache.commons.imaging.Imaging;
28  import org.apache.commons.imaging.ImagingConstants;
29  import org.apache.commons.imaging.common.bytesource.ByteSource;
30  import org.apache.commons.imaging.common.bytesource.ByteSourceFile;
31  import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata;
32  import org.apache.commons.imaging.formats.jpeg.JpegUtils;
33  import org.apache.commons.imaging.util.Debug;
34  import org.junit.Test;
35  import org.junit.runner.RunWith;
36  import org.junit.runners.Parameterized;
37  
38  @RunWith(Parameterized.class)
39  public class ExifDumpTest extends ExifBaseTest {
40  
41      private final File imageFile;
42  
43      @Parameterized.Parameters
44      public static Collection<File> data() throws Exception {
45          return getImagesWithExifData();
46      }
47  
48      public ExifDumpTest(final File imageFile) {
49          this.imageFile = imageFile;
50      }
51  
52      @Test
53      public void testDumpJFIF() throws Exception {
54          final ByteSource byteSource = new ByteSourceFile(imageFile);
55          Debug.debug("Segments:");
56          new JpegUtils().dumpJFIF(byteSource);
57          // TODO assert someting
58      }
59  
60      @Test
61      public void testMetadata() throws Exception {
62          final Map<String, Object> params = new HashMap<>();
63          final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
64          params.put(ImagingConstants.PARAM_KEY_READ_THUMBNAILS, Boolean.valueOf(!ignoreImageData));
65  
66          final JpegImageMetadata metadata = (JpegImageMetadata) Imaging.getMetadata(imageFile, params);
67          assertNotNull(metadata);
68          // TODO assert more
69      }
70  }