Skip to content

Commit

Permalink
JSP TCK Refactoring using Arquillian and JUnit (#1182)
Browse files Browse the repository at this point in the history
* Convert JSP arrayelresolver test to use Arquillian/JUnit

- duplicated SunRIURL class to jsp module
- copied ArrayELResolverTest.jsp, WEB-INF/arrayelresolver.tld from webartifacts module

* add jsp tck runner, passing test arrayelresolver

* simplify arrayelresolver test deployment code

* prepare resources folder for jsp/api/jakarta_el & jakarta_servlet

* URLClient changes in jsp/api/jakarta_el & jakarta_servlet to use Arquillian & Junit

* rename URLClient to URLClientIT in jsp/api/jakarta_el & jakarta_servlet

* remove build.xml and duplicate resource files from src

* prepare resources folder for pending tests in jsp/spec

: copied the web.xml from src, copied other web resources(tld, tag, tagx, gf, jsp, jspx, html files) from webartifacts/jsp module

* set goldenfile stream as new property for tests depending on goldenfiles(.gf)

* modify tests in jsp/spec to use Junit/Arquillian

- pending 37 tests after this change to be run
- URLClient classes renamed to URLClientIT

* missed out file in previous commit

* more tests included in spec - tagfiles/packaging, elevaluation, tldres,

* use host/port from Arquillian if system property not set

* add logging and address review comments

* move test logging code to parent class

* remove package name of classes while creating archive

* use URL injected by Arquillian
  • Loading branch information
alwin-joseph authored Nov 28, 2023
1 parent f7ff710 commit 094e93a
Show file tree
Hide file tree
Showing 1,507 changed files with 60,683 additions and 20,166 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

package com.sun.ts.tests.common.webclient;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -94,6 +95,8 @@ public class WebTestCase implements TestCase {
*/
private String _goldenfilePath = null;

private InputStream _goldenfileStream = null;

/**
* A List of strings that will be searched for in the response in the order
* they appear in the list.
Expand Down Expand Up @@ -227,6 +230,17 @@ public void setGoldenFilePath(String gfPath) {
_goldenfilePath = gfPath;
}


/**
* Sets the InputStream of the goldenfile the test case should use.
*
* @param in
* an InputStream value of the goldenfile.
*/
public void setGoldenFileStream(InputStream in) {
_goldenfileStream = in;
}

/**
* Sets the request that should be dispatched by this test case.
*
Expand Down Expand Up @@ -458,6 +472,15 @@ public String getGoldenfilePath() {
return _goldenfilePath;
}

/**
* Returns the InputStream of the goldenfile.
*
* @return InputStream of the goldenfile
*/
public InputStream getGoldenfileStream() {
return _goldenfileStream;
}

/**
* Returns the state for this particular test case.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@

package com.sun.ts.tests.common.webclient.validation;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;

import com.sun.ts.lib.util.TestUtil;
import com.sun.ts.tests.common.webclient.Goldenfile;
import com.sun.ts.tests.common.webclient.Util;

/**
* <pre>
Expand Down Expand Up @@ -63,7 +65,7 @@ public TokenizedValidator() {
* if an error occurs will processing the Goldenfile
*/
protected boolean checkGoldenfile() throws IOException {
String gf;
String gf = null;
String path = _case.getGoldenfilePath();
String enc = _res.getResponseEncoding();

Expand All @@ -74,7 +76,13 @@ protected boolean checkGoldenfile() throws IOException {
Goldenfile file = new Goldenfile(_case.getGoldenfilePath(), enc);

try {
gf = file.getGoldenFileAsString();
File goldenFile = new File(_case.getGoldenfilePath());
if(goldenFile.exists()){
gf = file.getGoldenFileAsString();
}
else if(_case.getGoldenfileStream()!=null){
gf = Util.getEncodedStringFromStream(_case.getGoldenfileStream(), enc);
}
} catch (IOException ioe) {
TestUtil
.logErr("[TokenizedValidator] Unexpected exception while accessing "
Expand Down
17 changes: 17 additions & 0 deletions glassfish-runner/jsp-tck/j2ee.pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

#
# Copyright (c) 2023 Oracle and/or its affiliates. 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
# http://www.eclipse.org/legal/epl-2.0.
#
# This Source Code may also be made available under the following Secondary
# Licenses when the conditions for such availability set forth in the
# Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
# version 2 with the GNU Classpath Exception, which is available at
# https://www.gnu.org/software/classpath/license.html.
#
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
#
AS_ADMIN_USERPASSWORD=j2ee
16 changes: 16 additions & 0 deletions glassfish-runner/jsp-tck/javajoe.pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Copyright (c) 2023 Oracle and/or its affiliates. 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
# http://www.eclipse.org/legal/epl-2.0.
#
# This Source Code may also be made available under the following Secondary
# Licenses when the conditions for such availability set forth in the
# Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
# version 2 with the GNU Classpath Exception, which is available at
# https://www.gnu.org/software/classpath/license.html.
#
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
#
AS_ADMIN_USERPASSWORD=javajoe
Loading

0 comments on commit 094e93a

Please sign in to comment.