View Javadoc
1   package nom.tam.fits;
2   
3   import org.junit.jupiter.api.Assertions;
4   
5   /*-
6    * #%L
7    * nom.tam FITS library
8    * %%
9    * Copyright (C) 1996 - 2024 nom-tam-fits
10   * %%
11   * This is free and unencumbered software released into the public domain.
12   *
13   * Anyone is free to copy, modify, publish, use, compile, sell, or
14   * distribute this software, either in source code form or as a compiled
15   * binary, for any purpose, commercial or non-commercial, and by any
16   * means.
17   *
18   * In jurisdictions that recognize copyright laws, the author or authors
19   * of this software dedicate any and all copyright interest in the
20   * software to the public domain. We make this dedication for the benefit
21   * of the public at large and to the detriment of our heirs and
22   * successors. We intend this dedication to be an overt act of
23   * relinquishment in perpetuity of all present and future rights to this
24   * software under copyright law.
25   *
26   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27   * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28   * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
29   * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
30   * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
31   * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
32   * OTHER DEALINGS IN THE SOFTWARE.
33   * #L%
34   */
35  
36  import org.junit.jupiter.api.Test;
37  
38  import nom.tam.util.ArrayDataInput;
39  import nom.tam.util.ArrayDataOutput;
40  
41  @SuppressWarnings({"javadoc", "deprecation"})
42  public class DeferredTest {
43  
44      @Test
45      public void isDeferredAsciiTableNew() throws Exception {
46          Assertions.assertFalse(new AsciiTable().isDeferred());
47      }
48  
49      @Test
50      public void isDeferredBinaryTableNew() throws Exception {
51          Assertions.assertFalse(new BinaryTable().isDeferred());
52      }
53  
54      @Test
55      public void isDeferredImageDataNew() throws Exception {
56          Assertions.assertFalse(new ImageData().isDeferred());
57      }
58  
59      @Test
60      public void isDeferredRandomGroupsDataNew() throws Exception {
61          Assertions.assertFalse(new RandomGroupsData().isDeferred());
62      }
63  
64      @Test
65      public void isDeferredUndefinedDataNew() throws Exception {
66          Assertions.assertFalse(new UndefinedData(new int[10]).isDeferred());
67      }
68  
69      @Test
70      public void isDeferredDataNew() throws Exception {
71          Assertions.assertFalse(new DefaultData().isDeferred());
72      }
73  
74      @Test
75      public void deferredDataRewrite() throws Exception {
76          new DefaultData() {
77              @Override
78              public boolean isDeferred() {
79                  return true;
80              }
81          }.rewrite(); // No exception is good enough!
82      }
83  
84      class DefaultData extends Data {
85          @Override
86          protected void fillHeader(Header head) throws FitsException {
87          }
88  
89          @Override
90          public Object getData() throws FitsException {
91              return null;
92          }
93  
94          @Override
95          protected long getTrueSize() {
96              return 0;
97          }
98  
99          @Override
100         public void read(ArrayDataInput in) throws FitsException {
101             throw new FitsException("not implemented");
102         }
103 
104         @Override
105         public void write(ArrayDataOutput o) throws FitsException {
106             throw new FitsException("not implemented");
107         }
108 
109         @Override
110         protected Object getCurrentData() {
111             // TODO Auto-generated method stub
112             return null;
113         }
114 
115         @Override
116         protected void loadData(ArrayDataInput in) {
117             // TODO Auto-generated method stub
118         }
119 
120         @Override
121         public BasicHDU<?> toHDU() {
122             // TODO Auto-generated method stub
123             return null;
124         }
125     }
126 }