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.juneau.plaintext;
18  
19  import static org.junit.jupiter.api.Assertions.*;
20  
21  import org.apache.juneau.*;
22  import org.apache.juneau.plaintext.annotation.*;
23  import org.apache.juneau.reflect.*;
24  import org.apache.juneau.svl.*;
25  import org.junit.jupiter.api.*;
26  
27  /**
28   * Tests the @PlainTextConfig annotation.
29   */
30  class PlainTextConfigAnnotation_Test extends TestBase {
31  
32  	static VarResolverSession sr = VarResolver.create().vars(XVar.class).build().createSession();
33  
34  	//-----------------------------------------------------------------------------------------------------------------
35  	// Annotation with no values.
36  	//-----------------------------------------------------------------------------------------------------------------
37  
38  	@PlainTextConfig()
39  	static class B {}
40  	static ClassInfo b = ClassInfo.of(B.class);
41  
42  	@Test void noValuesSerializer() {
43  		var al = AnnotationWorkList.of(sr, b.getAnnotationList());
44  		assertDoesNotThrow(()->PlainTextSerializer.create().apply(al).build().createSession());
45  	}
46  
47  	@Test void noValuesParser() {
48  		var al = AnnotationWorkList.of(sr, b.getAnnotationList());
49  		assertDoesNotThrow(()->PlainTextParser.create().apply(al).build().createSession());
50  	}
51  
52  	//-----------------------------------------------------------------------------------------------------------------
53  	// No annotation.
54  	//-----------------------------------------------------------------------------------------------------------------
55  
56  	static class C {}
57  	static ClassInfo c = ClassInfo.of(C.class);
58  
59  	@Test void noAnnotationSerializer() {
60  		var al = AnnotationWorkList.of(sr, c.getAnnotationList());
61  		assertDoesNotThrow(()->PlainTextSerializer.create().apply(al).build().createSession());
62  	}
63  
64  	@Test void noAnnotationParser() {
65  		var al = AnnotationWorkList.of(sr, c.getAnnotationList());
66  		assertDoesNotThrow(()->PlainTextParser.create().apply(al).build().createSession());
67  	}
68  }