Skip to main content
summaryrefslogtreecommitdiffstats
blob: ae113dbd2b45d320a05366ad6767c080fe1e354e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*******************************************************************************
 * Copyright (c) 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     
 *******************************************************************************/

package org.eclipse.jst.jsp.tests.encoding.jsp;

import java.io.IOException;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.content.IContentDescription;
import org.eclipse.jst.jsp.core.internal.provisional.contenttype.IContentDescriptionForJSP;
import org.eclipse.wst.xml.tests.encoding.read.TestContentTypeDetection;

public class TestContentTypeDetectionForJSP extends TestContentTypeDetection {

	protected void doTest(String expectedContentType, String filePath, Class expectedException, String expectedJSPContentType) throws CoreException, IOException {
		super.doTest(expectedContentType, filePath, expectedException);
		
		IFile file = (IFile) getTestProject().findMember(filePath);
		assertNotNull("Error in test case: file not found: " + filePath, file);


		IContentDescription streamContentDescription = doGetContentTypeBasedOnStream(file);
		IContentDescription fileContentDescription = doGetContentTypeBasedOnFile(file);

		String streamJSPContentType = (String) streamContentDescription.getProperty(IContentDescriptionForJSP.CONTENT_TYPE_ATTRIBUTE);

		checkResults(expectedJSPContentType, streamJSPContentType);
		
		
		String fileJSPContentType = (String) fileContentDescription.getProperty(IContentDescriptionForJSP.CONTENT_TYPE_ATTRIBUTE);
		checkResults(expectedJSPContentType, fileJSPContentType);


	}

	private void checkResults(String expectedJSPContentType, String foundJSPContentType) {
		if (expectedJSPContentType == null) {
			assertTrue("expected no contentType, but found: " + foundJSPContentType, foundJSPContentType == null);
		}
		else {
			assertTrue("expected " + expectedJSPContentType + " but found " + foundJSPContentType, expectedJSPContentType.equals(foundJSPContentType));
		}
	}
	
	public void testFile100() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/regressionTestFiles/defect223365/SelColBeanRow12ResultsFormB.jsp", null, "text/html");
	}

	public void testFile101() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/regressionTestFiles/defect224293/testshiftjisXmlSyntax.jsp", null, "text/html");
	}

	public void testFile102() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/regressionTestFiles/defect229667/audi.jsp", null, "text/html");
	}

	public void testFile65() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/EmptyFile.jsp", null, null);
	}

	public void testFile66() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/IllformedNormalNonDefault.jsp", null, "text/html");
	}

	public void testFile67() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/inValidEncodingValue.jsp", org.eclipse.wst.sse.core.internal.exceptions.UnsupportedCharsetExceptionWithDetail.class);
	}

	public void testFile68() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/javaEncodingValue.jsp", null, "text/html");
	}

	public void testFile69() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/MalformedNoEncoding.jsp", null, null);
	}

	public void testFile70() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/MalformedNoEncodingXSL.jsp", null, null);
	}

	public void testFile71() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/noEncoding.jsp", null, "text/html");
	}

	public void testFile72() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/NoEncodinginXMLDecl.jsp", null, null);
	}

	public void testFile73() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/nomalDirectiveCase.jsp", null, "text/html");
	}

	public void testFile74() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/nomalDirectiveCaseNoEncoding.jsp", null, null);
	}

	public void testFile75() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/nomalDirectiveCaseUsingCharset.jsp", null, "text/html");
	}

	public void testFile76() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/nomalDirectiveCaseUsingXMLSyntax.jsp", null, "text/html");
	}

	public void testFile77() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/NormalNonDefault.jsp", null, null);
	}

	public void testFile78() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/NormalNonDefaultWithXMLDecl.jsp", null, "text/html");
	}
	public void nomalDirectiveCasewithXMLDecl() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/nomalDirectiveCasewithXMLDecl.jsp", null, "text/html");
	}
	public void testFile79() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/NormalPageCaseNonDefault.jsp", null, "text/html");
	}

	public void testFile80() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/SelColBeanRow12ResultsForm.jsp", null, "text/html");
	}

	public void testFile81() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/testBrokenLine.jsp", null, null);
	}

	public void testFile82() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/testDefaultEncoding.jsp", org.eclipse.wst.sse.core.internal.exceptions.UnsupportedCharsetExceptionWithDetail.class, "text/html");
	}

	public void testFile83() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/testDefaultEncodingWithJunk.jsp", org.eclipse.wst.sse.core.internal.exceptions.UnsupportedCharsetExceptionWithDetail.class, "text/html");
	}

	public void testFile84() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/testExtraJunk.jsp", null, null);
	}

	public void testFile85() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/testExtraValidStuff.jsp", null, null);
	}

	public void testFile86() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/testIllFormed.jsp", null, null);
	}

	public void testFile87() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/testIllFormed2.jsp", null, null);
	}

	public void testFile88() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/testNoEncodingValue.jsp", null, null);
	}

	public void testFile89() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/testNoPageDirective.jsp", null, null);
	}


	public void testFile90() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/testNoPageDirectiveAtFirst.jsp", null, "text/html");
	}

	public void testFile91() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/testNoPageDirectiveInLargeFile.jsp", null, null);
	}

	public void testFile92() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/testNormalCase.jsp", null, null);
	}

	public void testFile93() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/testUTF16.jsp", null, null);
	}

	public void testFile94() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/utf16UnicodeStreamWithNoEncodingInHeader2.jsp", null, null);
	}

	public void testFile95() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/utf16UnicodeStreamWithNoEncodingInHeaderBE.jsp", null, null);
	}

	public void testFile96() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/utf16WithJapaneseChars.jsp", null, null);
	}

	public void testFile97() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/UTF8With3ByteBOM.jsp", null, null);
	}

	public void testFile98() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/jsp/WellFormedNormalNonDefault.jsp", null, "text/html");
	}

	public void testFile99() throws CoreException, IOException {
		doTest("org.eclipse.jst.jsp.core.jspsource", "testfiles/regressionTestFiles/defect223365/SelColBeanRow12ResultsForm.jsp", null, "text/html");
	}


}

Back to the top