-
Notifications
You must be signed in to change notification settings - Fork 729
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4105 from theresa-m/jep334_string
Methods and tests for jep334 String
- Loading branch information
Showing
7 changed files
with
280 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?xml version="1.0"?> | ||
|
||
<!-- | ||
Copyright (c) 2018, 2019 IBM Corp. and others | ||
This program and the accompanying materials are made available under | ||
the terms of the Eclipse Public License 2.0 which accompanies this | ||
distribution and is available at https://www.eclipse.org/legal/epl-2.0/ | ||
or the Apache License, Version 2.0 which accompanies this distribution and | ||
is available at https://www.apache.org/licenses/LICENSE-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 [1] and GNU General Public License, version 2 with the | ||
OpenJDK Assembly Exception [2]. | ||
[1] https://www.gnu.org/software/classpath/license.html | ||
[2] http://openjdk.java.net/legal/assembly-exception.html | ||
SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception | ||
--> | ||
|
||
<project name="Java12AndUp" default="build" basedir="."> | ||
<taskdef resource='net/sf/antcontrib/antlib.xml'/> | ||
<description> | ||
Tests for Java 12 and up | ||
</description> | ||
<import file="${TEST_ROOT}/functional/build.xml"/> | ||
|
||
<!-- set global properties for this build --> | ||
<property name="DEST" value="${BUILD_ROOT}/functional/Java12andUp" /> | ||
|
||
<!--Properties for this particular build--> | ||
<property name="src" location="./src"/> | ||
<property name="build" location="./bin"/> | ||
|
||
<target name="init"> | ||
<mkdir dir="${DEST}" /> | ||
<mkdir dir="${build}"/> | ||
</target> | ||
|
||
<target name="compile" depends="init" description="Using java ${JDK_VERSION} to compile the source" > | ||
<echo>Ant version is ${ant.version}</echo> | ||
<echo>============COMPILER SETTINGS============</echo> | ||
<echo>===fork: yes</echo> | ||
<echo>===executable: ${compiler.javac}</echo> | ||
<echo>===debug: on</echo> | ||
<echo>===destdir: ${DEST}</echo> | ||
|
||
<javac srcdir="${src}" destdir="${build}" debug="true" fork="true" executable="${compiler.javac}" includeAntRuntime="false" encoding="ISO-8859-1"> | ||
<src path="${src}"/> | ||
<classpath> | ||
<pathelement location="${TEST_ROOT}/TestConfig/lib/testng.jar"/> | ||
<pathelement location="${TEST_ROOT}/TestConfig/lib/jcommander.jar"/> | ||
<pathelement location="${build}" /> | ||
</classpath> | ||
</javac> | ||
</target> | ||
|
||
<target name="dist" depends="compile,dist_functional" description="generate the distribution" > | ||
<mkdir dir="${DEST}"/> | ||
<jar jarfile="${DEST}/GeneralTest.jar" filesonly="true"> | ||
<fileset dir="${build}"/> | ||
<fileset dir="${src}/../" includes="*.properties,*.xml"/> | ||
</jar> | ||
<copy todir="${DEST}"> | ||
<fileset dir="${src}/../" includes="*.xml" /> | ||
<fileset dir="${src}/../" includes="*.mk" /> | ||
</copy> | ||
</target> | ||
|
||
<target name="build" > | ||
<if> | ||
<not> | ||
<matches string="${JDK_VERSION}" pattern="^(8|9|10|11)$$" /> | ||
</not> | ||
<then> | ||
<antcall target="clean" inheritall="true" /> | ||
</then> | ||
</if> | ||
</target> | ||
|
||
<target name="clean" depends="dist" description="clean up" > | ||
<delete dir="${build}"/> | ||
</target> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
Copyright (c) 2018, 2019 IBM Corp. and others | ||
This program and the accompanying materials are made available under | ||
the terms of the Eclipse Public License 2.0 which accompanies this | ||
distribution and is available at https://www.eclipse.org/legal/epl-2.0/ | ||
or the Apache License, Version 2.0 which accompanies this distribution and | ||
is available at https://www.apache.org/licenses/LICENSE-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 [1] and GNU General Public License, version 2 with the | ||
OpenJDK Assembly Exception [2]. | ||
[1] https://www.gnu.org/software/classpath/license.html | ||
[2] http://openjdk.java.net/legal/assembly-exception.html | ||
SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception | ||
--> | ||
|
||
<playlist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../TestConfig/playlist.xsd"> | ||
<test> | ||
<testCaseName>Jep334Tests</testCaseName> | ||
<variations> | ||
<variation>NoOptions</variation> | ||
</variations> | ||
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) \ | ||
-cp $(Q)$(RESOURCES_DIR)$(P)$(TESTNG)$(P)$(TEST_RESROOT)$(D)GeneralTest.jar$(Q) \ | ||
org.testng.TestNG -d $(REPORTDIR) $(Q)$(TEST_RESROOT)$(D)testng.xml$(Q) -testnames Jep334Tests \ | ||
-groups $(TEST_GROUP) \ | ||
-excludegroups $(DEFAULT_EXCLUDE); \ | ||
$(TEST_STATUS) | ||
</command> | ||
<levels> | ||
<level>sanity</level> | ||
</levels> | ||
<groups> | ||
<group>functional</group> | ||
</groups> | ||
<subsets> | ||
<subset>12+</subset> | ||
</subsets> | ||
</test> | ||
</playlist> |
86 changes: 86 additions & 0 deletions
86
test/functional/Java12andUp/src/org/openj9/test/java_lang/Test_String.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2018, 2019 IBM Corp. and others | ||
* | ||
* This program and the accompanying materials are made available under | ||
* the terms of the Eclipse Public License 2.0 which accompanies this | ||
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* or the Apache License, Version 2.0 which accompanies this distribution and | ||
* is available at https://www.apache.org/licenses/LICENSE-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 [1] and GNU General Public License, version 2 with the | ||
* OpenJDK Assembly Exception [2]. | ||
* | ||
* [1] https://www.gnu.org/software/classpath/license.html | ||
* [2] http://openjdk.java.net/legal/assembly-exception.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception | ||
*******************************************************************************/ | ||
package org.openj9.test.java_lang; | ||
|
||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
import org.testng.log4testng.Logger; | ||
|
||
import java.lang.invoke.MethodHandles; | ||
import java.lang.invoke.MethodHandles.Lookup; | ||
import java.util.Optional; | ||
|
||
/** | ||
* This test Java.lang.String API added in Java 12 and later version. | ||
* | ||
*/ | ||
public class Test_String { | ||
public static Logger logger = Logger.getLogger(Test_String.class); | ||
|
||
private String empty = ""; | ||
private String latin1 = "abc123"; | ||
private String nonLatin1 = "abc\u0153"; | ||
private String emptyWithTerm = "\n"; | ||
|
||
/* | ||
* Test Java 12 API String.describeConstable() | ||
*/ | ||
@Test(groups = { "level.sanity" }) | ||
public void testStringDescribeConstable() throws Throwable { | ||
testStringDescribeConstable_sub(empty); | ||
testStringDescribeConstable_sub(latin1); | ||
testStringDescribeConstable_sub(nonLatin1); | ||
testStringDescribeConstable_sub(emptyWithTerm); | ||
} | ||
|
||
private void testStringDescribeConstable_sub(String test) throws Throwable { | ||
logger.debug("testStringDescribeConstable: test with string: " + test); | ||
Optional<String> optionalTest = test.describeConstable(); | ||
String describedTestString = optionalTest.orElseThrow(); | ||
Assert.assertTrue(test.equals(describedTestString)); | ||
} | ||
|
||
/* | ||
* Test Java 12 API String.resolveConstantDesc() | ||
*/ | ||
@Test(groups = { "level.sanity" }) | ||
public void testStringResolveConstantDesc() { | ||
testStringResolveConstantDesc_sub(empty); | ||
testStringResolveConstantDesc_sub(latin1); | ||
testStringResolveConstantDesc_sub(nonLatin1); | ||
testStringResolveConstantDesc_sub(emptyWithTerm); | ||
} | ||
|
||
private void testStringResolveConstantDesc_sub(String test) { | ||
logger.debug("testStringDescribeConstable: test with string: " + test); | ||
|
||
/* run test with a valid lookup */ | ||
MethodHandles.Lookup lookup = MethodHandles.publicLookup(); | ||
String resolvedTest = test.resolveConstantDesc(lookup); | ||
Assert.assertTrue(test.equals(resolvedTest)); | ||
|
||
/* run tests with a null lookup (should be ignored) */ | ||
String resolvedTest2 = test.resolveConstantDesc(null); | ||
Assert.assertTrue(test.equals(resolvedTest2)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
Copyright (c) 2018, 2019 IBM Corp. and others | ||
This program and the accompanying materials are made available under | ||
the terms of the Eclipse Public License 2.0 which accompanies this | ||
distribution and is available at https://www.eclipse.org/legal/epl-2.0/ | ||
or the Apache License, Version 2.0 which accompanies this distribution and | ||
is available at https://www.apache.org/licenses/LICENSE-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 [1] and GNU General Public License, version 2 with the | ||
OpenJDK Assembly Exception [2]. | ||
[1] https://www.gnu.org/software/classpath/license.html | ||
[2] http://openjdk.java.net/legal/assembly-exception.html | ||
SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception | ||
--> | ||
|
||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> | ||
<suite name="Java12andUp suite" parallel="none" verbose="2"> | ||
|
||
<test name="Jep334Tests"> | ||
<classes> | ||
<class name="org.openj9.test.java_lang.Test_String" /> | ||
</classes> | ||
</test> | ||
|
||
</suite> |