Skip to content

Commit

Permalink
Modify the jsp:plugin tests to reflect that the action should be a NO-OP
Browse files Browse the repository at this point in the history
  • Loading branch information
markt-asf committed Apr 21, 2022
1 parent 1541a65 commit e1daad3
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 47 deletions.
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022 Oracle and/or its affiliates and others.
* All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -31,8 +32,8 @@
import com.sun.ts.tests.common.webclient.validation.ValidationStrategy;

/**
* This validator will, loosely, validate the generated output of a jsp:plugin
* action.
* This validator will, loosely, validate that a jsp:plugin action does not
* generate any output.
*/
public class JspPluginValidator implements ValidationStrategy {
private static final String NL = System.getProperty("line.separartor", "\n");
Expand Down Expand Up @@ -67,8 +68,7 @@ public JspPluginValidator() {
public boolean validate(WebTestCase testCase) {

List<String> searchStrings = testCase.getSearchStrings();
List<String> unexpectedSearchStrings = testCase
.getUnexpectedSearchStrings();
List<String> unexpectedSearchStrings = testCase.getUnexpectedSearchStrings();
boolean passed = true;
String response = null;

Expand All @@ -83,8 +83,7 @@ public boolean validate(WebTestCase testCase) {

// get response body
try {
response = testCase.getResponse().getResponseBodyAsRawString()
.toLowerCase();
response = testCase.getResponse().getResponseBodyAsRawString().toLowerCase();

String[] htmlTokens = prepareTokens(
new StringTokenizer(response, "<>='\";\n\t "));
Expand All @@ -104,16 +103,19 @@ public boolean validate(WebTestCase testCase) {
+ sb.toString());
}

// check the response for either an object or embed tag in the
// response
if (response.indexOf("<embed") < 0 && response.indexOf("<object") < 0) {
TestUtil.logErr("[JspPluginValidator] Unable to locate either an"
+ "OBJECT or EMBED tag in the server's response.");
// Check the response for object tag in the response
if (response.indexOf("<embed") > -1) {
TestUtil.logErr("[JspPluginValidator] Found EMBED tag in the server's response.");
return false;
}

List<String> itemsNotFound = scanForExpectedValues(response, htmlTokens,
searchStrings);
// Check the response for embed tag in the response
if (response.indexOf("<object") > -1) {
TestUtil.logErr("[JspPluginValidator] Found OBJECT tag in the server's response.");
return false;
}

List<String> itemsNotFound = scanForExpectedValues(response, htmlTokens, searchStrings);

// check to see if we had any misses
if (itemsNotFound.size() > 0) {
Expand Down
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022 Oracle and/or its affiliates and others.
* All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -76,25 +77,27 @@ public void jspPluginTest() throws Fault {
"com.sun.ts.tests.jsp.spec.core_syntax.actions.plugin.JspPluginValidator");
TEST_PROPS.setProperty(REQUEST,
"GET /jsp_core_act_plugin_web/JspPluginAppletTest.jsp HTTP/1.1");
TEST_PROPS.setProperty(SEARCH_STRING,
"http://www.nowaythiswebsitecouldpossiblyexist.com|"
+ "fallback_text|vspace=1|hspace=1|"
+ "width=10|height=10|test=testvalue|applet|"
+ "code=foo.class|archive=test.jar|name=test|"
+ "align=middle|codebase=/");
TEST_PROPS.setProperty(SEARCH_STRING, "expected_text");
TEST_PROPS.setProperty(UNEXPECTED_RESPONSE_MATCH,
"http://www.nowaythiswebsitecouldpossiblyexist.com|" +
"fallback_text|vspace=1|hspace=1|" +
"width=10|height=10|test=testvalue|applet|" +
"code=foo.class|archive=test.jar|name=test|" +
"align=middle|codebase=/");
TEST_PROPS.setProperty(REQUEST_HEADERS,
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)");
invoke();
TEST_PROPS.setProperty(STRATEGY,
"com.sun.ts.tests.jsp.spec.core_syntax.actions.plugin.JspPluginValidator");
TEST_PROPS.setProperty(REQUEST,
"GET /jsp_core_act_plugin_web/JspPluginBeanTest.jsp HTTP/1.1");
TEST_PROPS.setProperty(SEARCH_STRING,
"http://www.nowaythiswebsitecouldpossiblyexist.com|"
+ "fallback_text|vspace=1|hspace=1|"
+ "width=10|height=10|test=testvalue|bean|"
+ "code=foo.class|archive=test.jar|name=test|"
+ "align=middle|codebase=/");
TEST_PROPS.setProperty(SEARCH_STRING, "expected_text");
TEST_PROPS.setProperty(UNEXPECTED_RESPONSE_MATCH,
"http://www.nowaythiswebsitecouldpossiblyexist.com|" +
"fallback_text|vspace=1|hspace=1|" +
"width=10|height=10|test=testvalue|bean|" +
"code=foo.class|archive=test.jar|name=test|" +
"align=middle|codebase=/");
TEST_PROPS.setProperty(REQUEST_HEADERS,
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)");
invoke();
Expand All @@ -113,31 +116,31 @@ public void jspPluginDynamicAttributesTest() throws Fault {
"com.sun.ts.tests.jsp.spec.core_syntax.actions.plugin.JspPluginValidator");
TEST_PROPS.setProperty(REQUEST,
"GET /jsp_core_act_plugin_web/JspPluginHeightElAttributeValueTest.jsp HTTP/1.1");
TEST_PROPS.setProperty(SEARCH_STRING, "height=10");
TEST_PROPS.setProperty(UNEXPECTED_RESPONSE_MATCH, "height=10");
TEST_PROPS.setProperty(REQUEST_HEADERS,
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)");
invoke();
TEST_PROPS.setProperty(STRATEGY,
"com.sun.ts.tests.jsp.spec.core_syntax.actions.plugin.JspPluginValidator");
TEST_PROPS.setProperty(REQUEST,
"GET /jsp_core_act_plugin_web/JspPluginHeightRtAttributeValueTest.jsp HTTP/1.1");
TEST_PROPS.setProperty(SEARCH_STRING, "height=10");
TEST_PROPS.setProperty(UNEXPECTED_RESPONSE_MATCH, "height=10");
TEST_PROPS.setProperty(REQUEST_HEADERS,
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)");
invoke();
TEST_PROPS.setProperty(STRATEGY,
"com.sun.ts.tests.jsp.spec.core_syntax.actions.plugin.JspPluginValidator");
TEST_PROPS.setProperty(REQUEST,
"GET /jsp_core_act_plugin_web/JspPluginWidthElAttributeValueTest.jsp HTTP/1.1");
TEST_PROPS.setProperty(SEARCH_STRING, "width=10");
TEST_PROPS.setProperty(UNEXPECTED_RESPONSE_MATCH, "width=10");
TEST_PROPS.setProperty(REQUEST_HEADERS,
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)");
invoke();
TEST_PROPS.setProperty(STRATEGY,
"com.sun.ts.tests.jsp.spec.core_syntax.actions.plugin.JspPluginValidator");
TEST_PROPS.setProperty(REQUEST,
"GET /jsp_core_act_plugin_web/JspPluginWidthRtAttributeValueTest.jsp HTTP/1.1");
TEST_PROPS.setProperty(SEARCH_STRING, "width=10");
TEST_PROPS.setProperty(UNEXPECTED_RESPONSE_MATCH, "width=10");
TEST_PROPS.setProperty(REQUEST_HEADERS,
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)");
invoke();
Expand Down Expand Up @@ -323,8 +326,8 @@ public void jspFallbackBodyTest() throws Fault {
"com.sun.ts.tests.jsp.spec.core_syntax.actions.plugin.JspPluginValidator");
TEST_PROPS.setProperty(REQUEST,
"GET /jsp_core_act_plugin_web/JspFallbackBodyTest.jsp HTTP/1.1");
TEST_PROPS.setProperty(SEARCH_STRING, "fallback_text");
TEST_PROPS.setProperty(UNEXPECTED_RESPONSE_MATCH, "<jsp:body>|</jsp:body>");
TEST_PROPS.setProperty(SEARCH_STRING, "expected_text");
TEST_PROPS.setProperty(UNEXPECTED_RESPONSE_MATCH, "<jsp:body>|fallback_text|</jsp:body>");
TEST_PROPS.setProperty(REQUEST_HEADERS,
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)");
invoke();
Expand All @@ -343,8 +346,8 @@ public void jspParamsBodyTest() throws Fault {
"com.sun.ts.tests.jsp.spec.core_syntax.actions.plugin.JspPluginValidator");
TEST_PROPS.setProperty(REQUEST,
"GET /jsp_core_act_plugin_web/JspParamsBodyTest.jsp HTTP/1.1");
TEST_PROPS.setProperty(SEARCH_STRING, "param1=value1");
TEST_PROPS.setProperty(UNEXPECTED_RESPONSE_MATCH, "<jsp:body>|</jsp:body>");
TEST_PROPS.setProperty(SEARCH_STRING, "expected_text");
TEST_PROPS.setProperty(UNEXPECTED_RESPONSE_MATCH, "<jsp:body>|param1=value1|</jsp:body>");
TEST_PROPS.setProperty(REQUEST_HEADERS,
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)");
invoke();
Expand Down Expand Up @@ -380,14 +383,14 @@ public void jspPluginJspAttributeTest() throws Fault {
"com.sun.ts.tests.jsp.spec.core_syntax.actions.plugin.JspPluginValidator");
TEST_PROPS.setProperty(REQUEST,
"GET /jsp_core_act_plugin_web/JspPluginJspAttributeTest.jsp HTTP/1.1");
TEST_PROPS.setProperty(SEARCH_STRING,
"http://www.nowaythiswebsitecouldpossiblyexist.com|"
+ "fallback_text|vspace=1|hspace=1|"
+ "width=10|height=10|test=testvalue|bean|"
+ "code=foo.class|archive=test.jar|name=test|"
+ "align=middle|codebase=/");
TEST_PROPS.setProperty(SEARCH_STRING, "expected_text");
TEST_PROPS.setProperty(UNEXPECTED_RESPONSE_MATCH,
"<jsp:attribute>|</jsp:attribute>");
"<jsp:attribute>|</jsp:attribute>|" +
"http://www.nowaythiswebsitecouldpossiblyexist.com|" +
"fallback_text|vspace=1|hspace=1|" +
"width=10|height=10|test=testvalue|bean|" +
"code=foo.class|archive=test.jar|name=test|" +
"align=middle|codebase=/");
TEST_PROPS.setProperty(REQUEST_HEADERS,
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)");
invoke();
Expand Down
@@ -1,6 +1,7 @@
<%--
Copyright (c) 2003, 2018 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2003, 2022 Oracle and/or its affiliates and others.
All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -23,3 +24,4 @@
<jsp:body>fallback_text</jsp:body>
</jsp:fallback>
</jsp:plugin>
expected_text
@@ -1,6 +1,7 @@
<%--
Copyright (c) 2003, 2018 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2003, 2022 Oracle and/or its affiliates and others.
All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -29,3 +30,4 @@
</jsp:body>
</jsp:params>
</jsp:plugin>
expected_text
@@ -1,6 +1,7 @@
<%--
Copyright (c) 2003, 2018 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2003, 2022 Oracle and/or its affiliates and others.
All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -28,3 +29,4 @@
</jsp:params>
<jsp:fallback>fallback_text</jsp:fallback>
</jsp:plugin>
expected_text
@@ -1,6 +1,7 @@
<%--
Copyright (c) 2003, 2018 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2003, 2022 Oracle and/or its affiliates and others.
All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -28,3 +29,4 @@
</jsp:params>
<jsp:fallback>fallback_text</jsp:fallback>
</jsp:plugin>
expected_text
@@ -1,6 +1,7 @@
<%--
Copyright (c) 2003, 2018 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2003, 2022 Oracle and/or its affiliates and others.
All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -42,3 +43,4 @@
<jsp:fallback>fallback_text</jsp:fallback>
</jsp:body>
</jsp:plugin>
expected_text

0 comments on commit e1daad3

Please sign in to comment.