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.examples.rest;
18  
19  import static org.apache.juneau.commons.utils.CollectionUtils.*;
20  
21  import java.util.*;
22  
23  import org.apache.juneau.*;
24  import org.junit.runner.*;
25  import org.junit.runners.*;
26  
27  @RunWith(Parameterized.class)
28  public class RootContentTest extends ContentComboTestBase {
29  
30  	@Parameterized.Parameters
31  	public static Collection<Object[]> getParameters() {
32  		// @formatter:off
33  		return l(new Object[][] {
34  			{ 	/* 0 */
35  				new ComboInput("HTML-stylesheet", "/", MediaType.HTML,
36  					"@import '/htdocs/themes/dark.css';",
37  					".menu-item {"
38  				)
39  			},
40  			{ 	/* 1 */
41  				new ComboInput("HTML-stylesheet-contnt", "/htdocs/themes/devops.css", MediaType.PLAIN,
42  					"/** DevOps look-and-feel */"
43  				)
44  			},
45  			{ 	/* 2 */
46  				new ComboInput("HTML-header", "/", MediaType.HTML,
47  					"<head>",
48  					"<h1>Root resources</h1>",
49  					"<h2>Navigation page</h2>",
50  					"<img src='/htdocs/images/juneau.png' style='position:absolute;top:5;right:5;background-color:transparent;height:30px'/>"
51  				)
52  			},
53  			{ 	/* 3 */
54  				new ComboInput("HTML-nav", "/", MediaType.HTML,
55  					"<nav>",
56  					"<a href='/api'>api</a>",
57  					"<a onclick='menuClick(this);'>content-type</a>",
58  					"<a href='https://github.com/apache/juneau/blob/master/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java'>source</a>"
59  				)
60  			},
61  			{ 	/* 4 */
62  				new ComboInput("HTML-nav-popup-contentType", "/", MediaType.HTML,
63  					"<div class='popup-content'>",
64  					"/?plainText=true&Accept=application%2Fjson"
65  				)
66  			},
67  			{ 	/* 5 */
68  				new ComboInput("HTML-aside", "/", MediaType.HTML,
69  					"<aside>",
70  					"<p>This is an example of a 'router' page that serves as a jumping-off point to child resources.</p>",
71  					"<p>Other features (such as this aside) are added through annotations.</p>"
72  				)
73  			},
74  			{ 	/* 6 */
75  				new ComboInput("HTML-footer", "/", MediaType.HTML,
76  					"<footer>",
77  					"<img style='float:right;padding-right:20px;height:32px' src='/htdocs/images/asf.png'>"
78  				)
79  			},
80  			{ 	/* 7 */
81  				new ComboInput("HTML-content-text/html", "/", MediaType.HTML,
82  					"<a href='/helloWorld'>helloWorld</a>",
83  					"<td>Hello World</td>"
84  				)
85  			},
86  			{ 	/* 8 */
87  				new ComboInput("HTML-content-application/json", "/", MediaType.JSON,
88  					"'name':'helloWorld',",
89  					"'description':'Hello World'"
90  				)
91  			},
92  			{ 	/* 9 */
93  				new ComboInput("HTML-content-octal/msgpack", "/", MediaType.MSGPACK,
94  					"82 A4 6E"
95  				)
96  			},
97  			{ 	/* 10 */
98  				new ComboInput("HTML-content-text/plain", "/", MediaType.PLAIN,
99  					"Hello World"
100 				)
101 			},
102 			{ 	/* 11 */
103 				new ComboInput("HTML-content-text/uon", "/", MediaType.UON,
104 					"(name=helloWorld,description='Hello World')"
105 				)
106 			},
107 			{ 	/* 12 */
108 				new ComboInput("HTML-content-application/x-www-form-urlencoded", "/", MediaType.URLENCODING,
109 					"0=(name=helloWorld,description='Hello+World')"
110 				)
111 			},
112 			{ 	/* 13 */
113 				new ComboInput("HTML-content-text/xml", "/", MediaType.XML,
114 					"<name>helloWorld</name><description>Hello World</description>"
115 				)
116 			}
117 		});
118 		// @formatter:on
119 	}
120 
121 	public RootContentTest(ComboInput comboInput) {
122 		super(comboInput);
123 	}
124 }