Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSTL TCK Refactoring using Arquillian and JUnit #1203

Merged
merged 13 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 17 additions & 0 deletions glassfish-runner/jstl-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/jstl-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
478 changes: 478 additions & 0 deletions glassfish-runner/jstl-tck/pom.xml

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions glassfish-runner/jstl-tck/sql/derby/derby.ddl.jstl.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
drop table jstl_tab1 ;
create table jstl_tab1(idNum INT NOT NULL, firstName VARCHAR(20) NOT NULL, lastName VARCHAR(20) NOT NULL, primary key(idNum)) ;

drop table jstl_tab2 ;
create table jstl_tab2(idNum INT NOT NULL, dob DATE NOT NULL, firstName VARCHAR(20) NOT NULL, lastName VARCHAR(20) NOT NULL, rank INT NOT NULL, rating NUMERIC(10,2)) ;

drop table jstl_tab3 ;
create table jstl_tab3(idNum INTEGER NOT NULL, aDate DATE, aTime TIME, aTimestamp TIMESTAMP) ;


INSERT INTO jstl_tab1 VALUES(1, 'Lance', 'Andersen') ;
INSERT INTO jstl_tab1 VALUES(2, 'Ryan', 'Lubke') ;
INSERT INTO jstl_tab1 VALUES(3, 'Sandra', 'Roberts') ;
INSERT INTO jstl_tab1 VALUES(4, 'Hong', 'Zhang') ;
INSERT INTO jstl_tab1 VALUES(5, 'Raja', 'Perumal') ;
INSERT INTO jstl_tab1 VALUES(6, 'Shelly', 'McGowan') ;
INSERT INTO jstl_tab1 VALUES(7, 'Ryan', 'O''Connell') ;
INSERT INTO jstl_tab1 VALUES(8, 'Tonya', 'Andersen') ;
INSERT INTO jstl_tab1 VALUES(9, 'Eric', 'Jendrock') ;
INSERT INTO jstl_tab1 VALUES(10, 'Carla', 'Mott') ;
INSERT INTO jstl_tab2(idNum, dob, firstName, lastName, rank, rating) VALUES (1, {d '1999-05-05'}, 'Lance', 'Andersen', 1, 4.25) ;
INSERT INTO jstl_tab2(idNum, dob, firstName, lastName, rank, rating) VALUES (99, {d '1999-05-05'}, 'Courtney', 'Andersen', 1, NULL) ;
INSERT INTO jstl_tab3(idNum, aDate, aTime, aTimestamp) VALUES(1, {d '2001-08-30'}, {t '20:20:20'}, {ts '2001-08-30 20:20:20'}) ;
INSERT INTO jstl_tab3(idNum, aDate, aTime, aTimestamp) VALUES(2, NULL, NULL, NULL) ;
35 changes: 35 additions & 0 deletions glassfish-runner/jstl-tck/sql/derby/derby.dml.jstl.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Simple_Select_Query= SELECT * FROM jstl_tab1
Select_NoRows_Query= SELECT * FROM jstl_tab1 WHERE idNum = -9999
Select_Jstl_Tab1_OneRow_Query= SELECT * FROM jstl_tab1 where idNum = 1
Select_Jstl_Tab1_By_Id_Query= SELECT * FROM jstl_tab1 ORDER BY idNum
Select_Jstl_Tab1_Using_Param_Query= SELECT * FROM jstl_tab1 WHERE idNum = ?
Select_Jstl_Tab2_Using_Param_Query= SELECT idNum, lastName FROM jstl_tab2 WHERE idNum = ?

Update_Jstl_Tab2_Using_Param_Query= UPDATE jstl_tab2 SET lastName= ? WHERE idNum = ?

Delete_NoRows_Query= DELETE FROM jstl_tab2 WHERE idNum = -9999
Delete_AllRows_Query= DELETE FROM jstl_tab2

Insert_Row_Query= INSERT INTO jstl_tab2(idNum, dob, firstName, lastName, rank, rating) VALUES (1, {d '1961-08-30'}, 'Clark', 'Kent', 1, 4.5)
Insert2_Row_Query= INSERT INTO jstl_tab2(idNum, dob, firstName, lastName, rank, rating) VALUES (2, {d '1980-12-30'}, 'Fred', 'Flinstone', 2, 4.5)
Insert3_Row_Query= INSERT INTO jstl_tab2(idNum, dob, firstName, lastName, rank, rating) VALUES (3, {d '1961-01-01'}, 'Scooby', 'Doo', 4, 4.5)
Insert4_Row_Query= INSERT INTO jstl_tab2(idNum, dob, firstName, lastName, rank, rating) VALUES (4, {d '1990-03-15'}, 'Bruce', 'Wayne', 3, 4.5)
Delete_Jstl_Tab2_Using_Param_Query=DELETE FROM jstl_tab2 where idNum = ?
Failed_Insert_Query=INSERT INTO jstl_tab2(idNum, dob, firstName, lastName, rank, rating) VALUES (2, '1992-02-03'}, NULL,NULL, 2, 4.5)
Select_Jstl_Tab2_AllRows_Query=SELECT * from jstl_tab2
Invalid_SQL_Query=This Will Fail on Any RDBMS I Hope!
Select_Jstl_Tab1_MultiParam_Query=SELECT idNum, firstName, lastName from jstl_tab1 where idNum= ? and lastName = ?
Delete_Jstl_Tab2_MultiParam_Query=DELETE FROM jstl_tab2 where idNum = ? and lastName = ?
Select_Jstl_Tab3_Date_Query=SELECT * from jstl_tab3 where aDate= ?
Select_Jstl_Tab3_Time_Query=SELECT * from jstl_tab3 where aTime= ?
Select_Jstl_Tab3_Timestamp_Query=SELECT * from jstl_tab3 where aTimestamp= ?
Insert_Jstl_Tab3_Query=INSERT INTO jstl_tab3(idNum, aDate, aTime, aTimestamp) VALUES(1, {d '2001-08-30'}, {t '20:20:20'}, {ts '2001-08-30 20:20:20'})
Insert_Jstl_Tab3_Date_Query=INSERT INTO jstl_tab3(idNum, aDate, aTime, aTimestamp) VALUES(1, ?, {t '20:20:20'}, {ts '2001-08-30 20:20:20'})
Insert_Jstl_Tab3_Time_Query=INSERT INTO jstl_tab3(idNum, aDate, aTime, aTimestamp) VALUES(1, {d '2001-08-30'}, ?, {ts '2001-08-30 20:20:20'})
Insert_Jstl_Tab3_Timestamp_Query=INSERT INTO jstl_tab3(idNum, aDate, aTime, aTimestamp) VALUES(1, {d '2001-08-30'}, {t '20:20:20'}, ?)
Delete_Jstl_Tab3_AllRows_Query= DELETE FROM jstl_tab3

Insert_Jstl_Tab3_Null_Query=INSERT INTO jstl_tab3(idNum, aDate, aTime, aTimestamp) VALUES(99, null, null, null)
Select_Jstl_Tab2_NullParam_Query= SELECT * FROM jstl_tab2 WHERE rank = ?
Insert_Jstl_Tab2_Null_Query=INSERT INTO jstl_tab2(idNum, dob, firstName, lastName, rank, rating) VALUES (5, {d '1970-07-04'}, 'Peter', 'Parker', 5, null)
Insert_Jstl_Tab2_NullParam_Query=INSERT INTO jstl_tab2(idNum, dob, firstName, lastName, rank, rating) VALUES (5, {d '1970-07-04'}, 'Peter', 'Parker', 5, ?)
18 changes: 18 additions & 0 deletions glassfish-runner/jstl-tck/src/test/resources/arquillian.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://jboss.org/schema/arquillian"
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

<engine>
<!-- property name="deploymentExportPath">target/</property -->
</engine>

<group qualifier="glassfish-servers" default="true">
<container qualifier="http" default="true">
<configuration>
<property name="glassFishHome">target/glassfish8</property>
</configuration>
</container>
</group>

</arquillian>
84 changes: 77 additions & 7 deletions jstl/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2021 Contributors to the Eclipse Foundation
Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
All rights reserved.

This program and the accompanying materials are made available under the
Expand All @@ -26,28 +26,35 @@
<version>11.0.0-SNAPSHOT</version>
</parent>

<artifactId>jstl</artifactId>
<artifactId>jstl-tck</artifactId>
<packaging>jar</packaging>

<name>JSTL</name>
<description>JSTL</description>
<description>JSTL TCK</description>

<properties>
<arquillian.junit>1.7.0.Alpha14</arquillian.junit>
<jakarta.servlet.api.version>6.1.0-M2</jakarta.servlet.api.version>
<jakarta.servlet.jsp-api.version>4.0.0-M2</jakarta.servlet.jsp-api.version>
<junit.jupiter.version>5.9.1</junit.jupiter.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>common</artifactId>
</dependency>
<dependency>
<groupId>javatest</groupId>
<artifactId>javatest</artifactId>
</dependency>
<dependency>
<groupId>jakarta.servlet.jsp</groupId>
<artifactId>jakarta.servlet.jsp-api</artifactId>
<version>${jakarta.servlet.jsp-api.version}</version>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>${jakarta.servlet.api.version}</version>
</dependency>
<dependency>
<groupId>jakarta.servlet.jsp.jstl</groupId>
Expand All @@ -57,7 +64,70 @@
<groupId>jakarta.transaction</groupId>
<artifactId>jakarta.transaction-api</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit5</groupId>
<artifactId>arquillian-junit5-container</artifactId>
<version>${arquillian.junit}</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit5</groupId>
<artifactId>arquillian-junit5-core</artifactId>
<version>${arquillian.junit}</version>
</dependency>
</dependencies>

<profiles>
<profile>
<id>tck-build</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<!-- do not publish this artifact to Maven repositories -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 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
Expand All @@ -20,14 +20,113 @@

package com.sun.ts.tests.jstl.common.client;

import static org.junit.jupiter.api.Assertions.assertFalse;

import java.io.InputStream;
import java.lang.System.Logger;
import java.net.URL;

import com.sun.ts.tests.jstl.common.tags.TestTag;
import com.sun.ts.tests.jstl.common.resources.Resources_en;

import org.jboss.arquillian.container.test.api.OperateOnDeployment;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.UrlAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInfo;

import com.sun.ts.tests.common.webclient.BaseUrlClient;
import com.sun.ts.tests.common.webclient.WebTestCase;
import com.sun.ts.tests.common.webclient.http.HttpRequest;

public class AbstractUrlClient extends BaseUrlClient {

private static final Logger logger = System.getLogger(AbstractUrlClient.class.getName());

@BeforeEach
void logStartTest(TestInfo testInfo) {
logger.log(Logger.Level.INFO, "STARTING TEST : "+testInfo.getDisplayName());
}

@AfterEach
void logFinishTest(TestInfo testInfo) {
logger.log(Logger.Level.INFO, "FINISHED TEST : "+testInfo.getDisplayName());
}

@ArquillianResource
@OperateOnDeployment("_DEFAULT_")
public URL url;


protected InputStream goldenFileStream = null;

public InputStream getGoldenFileStream() {
return goldenFileStream;
}

public void setGoldenFileStream(InputStream gfStream) {
goldenFileStream = gfStream;
}

protected static final String STANDARD_COMPAT = "standardCompat";


private void setGoldenFileStreamProperty(WebTestCase testCase, InputStream gfStream) {
testCase.setGoldenFileStream(gfStream);
}

protected boolean isNullOrEmpty(String val) {
if (val == null || val.equals("")) {
return true;
}
return false;
}

protected static JavaArchive getCommonJarArchive() {
String packagePathTags = TestTag.class.getPackageName().replace(".", "/");
String packagePathResources = Resources_en.class.getPackageName().replace(".", "/");

JavaArchive jstlTCKCommonJar = ShrinkWrap.create(JavaArchive.class, "jstltck-common.jar");
jstlTCKCommonJar.addAsResource(new UrlAsset(TestTag.class.getClassLoader().getResource(packagePathTags+"/tlds/jstltck-util.tld")), "META-INF/jstltck-util.tld");
jstlTCKCommonJar.addAsResource(new UrlAsset(TestTag.class.getClassLoader().getResource(packagePathTags+"/tlds/permitted.tld")), "META-INF/permitted.tld");
jstlTCKCommonJar.addAsResource(new UrlAsset(TestTag.class.getClassLoader().getResource(packagePathTags+"/tlds/scrfree_nodecl.tld")), "META-INF/scrfree_nodecl.tld");
jstlTCKCommonJar.addAsResource(new UrlAsset(TestTag.class.getClassLoader().getResource(packagePathTags+"/tlds/scrfree_noexpr.tld")), "META-INF/scrfree_noexpr.tld");
jstlTCKCommonJar.addAsResource(new UrlAsset(TestTag.class.getClassLoader().getResource(packagePathTags+"/tlds/scrfree_nortexpr.tld")), "META-INF/scrfree_nortexpr.tld");
jstlTCKCommonJar.addAsResource(new UrlAsset(TestTag.class.getClassLoader().getResource(packagePathTags+"/tlds/scrfree_noscr.tld")), "META-INF/scrfree_noscr.tld");

jstlTCKCommonJar.addPackages(true,"com.sun.ts.tests.jstl.common");

jstlTCKCommonJar.add(new UrlAsset(Resources_en.class.getClassLoader().getResource(packagePathResources+"/AlgoResources_en_IE_EURO.properties")), packagePathResources+"/AlgoResources_en_IE_EURO.properties");
jstlTCKCommonJar.add(new UrlAsset(Resources_en.class.getClassLoader().getResource(packagePathResources+"/AlgoResources.properties")), packagePathResources+"/AlgoResources.properties");

return jstlTCKCommonJar;
}

@BeforeEach
public void setup() throws Exception {

logger.log(Logger.Level.INFO, "setup method AbstractUrlClient");

if (url == null){
throw new Exception(
"[AbstractUrlClient] The url was not injected");
}

String hostname = url.getHost();
String portnum = Integer.toString(url.getPort());

assertFalse(isNullOrEmpty(hostname), "[AbstractUrlClient] 'webServerHost' was not set in the properties.");
_hostname = hostname.trim();
assertFalse(isNullOrEmpty(portnum), "[AbstractUrlClient] 'webServerPort' was not set in the properties.");
_port = Integer.parseInt(portnum.trim());

logger.log(Logger.Level.INFO, "[AbstractUrlClient] Test setup OK");
}


/**
* Sets the test properties for this testCase.
*
Expand All @@ -47,14 +146,8 @@ protected void setTestProperties(WebTestCase testCase) {
HttpRequest req = new HttpRequest(sb.toString(), _hostname, _port);
testCase.setRequest(req);
}
String gf = TEST_PROPS.getProperty(GOLDENFILE);
if (gf != null) {
StringBuffer sb = new StringBuffer(25);
sb.append(_tsHome).append("/src/web").append(GOLDENFILEDIR);
sb.append(SL).append(gf);
testCase.setGoldenFilePath(sb.toString());
TEST_PROPS.remove(GOLDENFILE);
}

setGoldenFileStreamProperty(testCase, goldenFileStream);
}

super.setTestProperties(testCase);
Expand Down Expand Up @@ -102,12 +195,6 @@ private void setStandardProperties(String testValue, WebTestCase testCase) {
HttpRequest req = new HttpRequest(sb.toString(), _hostname, _port);
testCase.setRequest(req);

// set the goldenfile
sb = new StringBuffer(50);
sb.append(_tsHome).append("/src/web").append(GOLDENFILEDIR);
sb.append(SL);
sb.append(testValue).append(GF_SUFFIX);
testCase.setGoldenFilePath(sb.toString());
}

/**
Expand Down Expand Up @@ -143,11 +230,5 @@ private void setStandardCompatProperties(String testValue,
HttpRequest req = new HttpRequest(sb.toString(), _hostname, _port);
testCase.setRequest(req);

// set the goldenfile
sb = new StringBuffer(50);
sb.append(_tsHome).append(GOLDENFILEDIR);
sb.append(_generalURI).append(SL);
sb.append(testValue).append(GF_SUFFIX);
testCase.setGoldenFilePath(sb.toString());
}
}
Loading
Loading