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  package org.apache.commons.io.build;
18  
19  import static org.junit.jupiter.api.Assertions.assertThrows;
20  
21  import java.io.StringWriter;
22  import java.io.Writer;
23  
24  import org.apache.commons.io.build.AbstractOrigin.WriterOrigin;
25  import org.junit.jupiter.api.BeforeEach;
26  import org.junit.jupiter.api.Test;
27  
28  /**
29   * Tests {@link WriterOrigin}.
30   *
31   * A WriterOrigin can convert into some of the other aspects.
32   */
33  public class WriterStreamOriginTest extends AbstractOriginTest<Writer, WriterOrigin> {
34  
35      @BeforeEach
36      public void beforeEach() {
37          setOriginRo(new WriterOrigin(new StringWriter()));
38          setOriginRw(new WriterOrigin(new StringWriter()));
39      }
40  
41      @Override
42      @Test
43      public void testGetByteArray() {
44          // Cannot convert a Writer to a byte[].
45          assertThrows(UnsupportedOperationException.class, super::testGetByteArray);
46      }
47  
48      @Override
49      @Test
50      public void testGetByteArrayAt_0_0() {
51          // Cannot convert a OutputStream to a byte[].
52          assertThrows(UnsupportedOperationException.class, super::testGetByteArrayAt_0_0);
53      }
54  
55      @Override
56      @Test
57      public void testGetByteArrayAt_0_1() {
58          // Cannot convert a OutputStream to a byte[].
59          assertThrows(UnsupportedOperationException.class, super::testGetByteArrayAt_0_1);
60      }
61  
62      @Override
63      @Test
64      public void testGetByteArrayAt_1_1() {
65          // Cannot convert a OutputStream to a byte[].
66          assertThrows(UnsupportedOperationException.class, super::testGetByteArrayAt_1_1);
67      }
68  
69      @Override
70      @Test
71      public void testGetCharSequence() {
72          // Cannot convert a Writer to a CharSequence.
73          assertThrows(UnsupportedOperationException.class, super::testGetCharSequence);
74      }
75  
76      @Override
77      @Test
78      public void testGetFile() {
79          // Cannot convert a Writer to a File.
80          assertThrows(UnsupportedOperationException.class, super::testGetFile);
81      }
82  
83      @Override
84      @Test
85      public void testGetInputStream() {
86          // Cannot convert a Writer to an InputStream.
87          assertThrows(UnsupportedOperationException.class, super::testGetInputStream);
88      }
89  
90      @Override
91      @Test
92      public void testGetPath() {
93          // Cannot convert a Writer to a Path.
94          assertThrows(UnsupportedOperationException.class, super::testGetPath);
95      }
96  
97      @Override
98      @Test
99      public void testGetReader() {
100         // Cannot convert a Writer to a Reader.
101         assertThrows(UnsupportedOperationException.class, super::testGetReader);
102     }
103 
104     @Override
105     @Test
106     public void testSize() {
107         // Cannot convert a Writer to a size.
108         assertThrows(UnsupportedOperationException.class, super::testSize);
109     }
110 
111 }