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

TCK Refactor of JSP & EL Standalone Signature tests #1209

Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions el/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
<artifactId>common</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>signaturetest</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>jakarta.el</groupId>
<artifactId>jakarta.el-api</artifactId>
Expand All @@ -63,6 +68,12 @@
<artifactId>junit-jupiter</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.netbeans.tools</groupId>
<artifactId>sigtest-maven-plugin</artifactId>
<version>1.7</version>
</dependency>

</dependencies>

<build>
Expand All @@ -72,6 +83,7 @@
<directory>src/main/resources</directory>
<includes>
<include>LICENSE_${license}.md</include>
<include>com/</include>
</includes>
</resource>
</resources>
Expand Down Expand Up @@ -143,6 +155,37 @@
<license>EPL</license>
</properties>
</profile>
<profile>
<id>record-signature</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<bundle-name>jakarta-expression-language-tck</bundle-name>
<license>EFTL</license>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.netbeans.tools</groupId>
<artifactId>sigtest-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<FileName>${project.build.directory}/jakarta.el.sig_${project.parent.version}</FileName>
<packages>jakarta.el</packages>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

</profiles>

</project>
151 changes: 151 additions & 0 deletions el/src/main/java/com/sun/ts/tests/el/signaturetest/el/ELSigTestIT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/*
* Copyright (c) 2007, 2023 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
* 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
*/

package com.sun.ts.tests.signaturetest.el;

import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.File;

import org.junit.jupiter.api.Test;

import com.sun.javatest.Status;
import com.sun.ts.tests.signaturetest.SigTest;
import com.sun.ts.tests.signaturetest.SignatureTestDriver;
import com.sun.ts.tests.signaturetest.SignatureTestDriverFactory;

import java.util.Properties;
import com.sun.ts.lib.util.TestUtil;
import java.lang.System.Logger;

/*
* This class is a simple example of a signature test that extends the
* SigTest framework class. This signature test is run outside of the
* Java EE containers. This class also contains the boilerplate
* code necessary to create a signature test using the test framework.
* To see a complete TCK example see the javaee directory for the Java EE
* TCK signature test class.
*/
public class ELSigTestIT extends SigTest {

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

public ELSigTestIT(){
setup();
}

/***** Abstract Method Implementation *****/

/**
* Returns a list of strings where each string represents a package name. Each
* package name will have it's signature tested by the signature test
* framework.
*
* @return String[] The names of the packages whose signatures should be
* verified.
*/
protected String[] getPackages() {
return new String[] { "jakarta.el" };
}


/*
* The following comments are specified in the base class that defines the
* signature tests. This is done so the test finders will find the right class
* to run. The implementation of these methods is inherited from the super
* class which is part of the signature test framework.
*/

// NOTE: If the API under test is not part of your testing runtime
// environment, you may use the property sigTestClasspath to specify
// where the API under test lives. This should almost never be used.
// Normally the API under test should be specified in the classpath
// of the VM running the signature tests. Use either the first
// comment or the one below it depending on which properties your
// signature tests need. Please do not use both comments.

/*
* @class.setup_props: ts_home, The base path of this TCK; sigTestClasspath;
*/

/*
* @testName: signatureTest
*
* @assertion: An EL container must implement the required classes and APIs
* specified in the EL Specification.
*
* @test_Strategy: Using reflection, gather the implementation specific
* classes and APIs. Compare these results with the expected (required)
* classes and APIs.
*
*/
@Test
public void signatureTest() throws Exception {

logger.log(Logger.Level.INFO, "$$$ SigTestIT.signatureTest() called");
String mapFile = null;
String packageFile = null;
String repositoryDir = null;
Properties mapFileAsProps = null;
String[] packages = getPackages();
String apiPackage = "jakarta.el";

try {

InputStream inStreamMapfile = ELSigTestIT.class.getClassLoader().getResourceAsStream("com/sun/ts/tests/signaturetest/el/sig-test.map");
File mFile = writeStreamToTempFile(inStreamMapfile, "sig-test", ".map");
mapFile = mFile.getCanonicalPath();
logger.log(Logger.Level.INFO, "mapFile location is :"+mapFile);

InputStream inStreamPackageFile = ELSigTestIT.class.getClassLoader().getResourceAsStream("com/sun/ts/tests/signaturetest/el/sig-test-pkg-list.txt");
File pFile = writeStreamToTempFile(inStreamPackageFile, "sig-test-pkg-list", ".txt");
packageFile = pFile.getCanonicalPath();
logger.log(Logger.Level.INFO, "packageFile location is :"+packageFile);

mapFileAsProps = getSigTestDriver().loadMapFile(mapFile);
String packageVersion = mapFileAsProps.getProperty(apiPackage);
logger.log(Logger.Level.INFO, "Package version from mapfile :"+packageVersion);

InputStream inStreamSigFile = ELSigTestIT.class.getClassLoader().getResourceAsStream("com/sun/ts/tests/signaturetest/el/jakarta.el.sig_"+packageVersion);
File sigFile = writeStreamToSigFile(inStreamSigFile, apiPackage, packageVersion);
logger.log(Logger.Level.INFO, "signature File location is :"+sigFile.getCanonicalPath());

} catch(IOException ex) {
logger.log(Logger.Level.ERROR, "Exception while creating temp files :"+ex);
}

super.signatureTest(mapFile, packageFile, mapFileAsProps, packages);
}


/*
* Call the parent class's cleanup method.
*/

/*
* define which sig driver we will use
*/
@Override
protected SignatureTestDriver getSigTestDriver() {
driver = SignatureTestDriverFactory
.getInstance(SignatureTestDriverFactory.SIG_TEST);

return driver;

} // END getSigTestDriver
}
Loading
Loading