Skip to content

Commit

Permalink
8320712: Rewrite BadFactoryTest in pure Java
Browse files Browse the repository at this point in the history
Reviewed-by: jpai, sundar
  • Loading branch information
Eirik Bjørsnøs committed Jan 31, 2024
1 parent 725314f commit 6697160
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 62 deletions.
28 changes: 26 additions & 2 deletions test/jdk/javax/script/JDK_8196959/BadFactoryTest.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -21,10 +21,34 @@
* questions.
*/

import org.junit.jupiter.api.Test;

import javax.script.ScriptEngineFactory;
import javax.script.ScriptEngineManager;
import java.util.Optional;

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

/*
* @test
* @bug 8196959 8320712
* @summary Verify that ScriptEngineManager can load BadFactory without throwing NPE
* @build BadFactory BadFactoryTest
* @run junit/othervm BadFactoryTest
* @run junit/othervm -Djava.security.manager=allow BadFactoryTest
*/
public class BadFactoryTest {
public static void main(String[] args) {

@Test
public void scriptEngineManagerShouldLoadBadFactory() {
// Check that ScriptEngineManager initializes even in the
// presence of a ScriptEngineFactory returning nulls
ScriptEngineManager m = new ScriptEngineManager();

// Sanity check that ScriptEngineManager actually found the BadFactory
Optional<ScriptEngineFactory> badFactory = m.getEngineFactories().stream()
.filter(fac -> fac.getClass() == BadFactory.class)
.findAny();
assertTrue(badFactory.isPresent(), "BadFactory not found");
}
}
60 changes: 0 additions & 60 deletions test/jdk/javax/script/JDK_8196959/BadFactoryTest.sh

This file was deleted.

7 comments on commit 6697160

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 6697160 Mar 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 6697160 Mar 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin the backport was successfully created on the branch backport-GoeLin-66971600 in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 66971600 from the openjdk/jdk repository.

The commit being backported was authored by Eirik Bjørsnøs on 31 Jan 2024 and was reviewed by Jaikiran Pai and Athijegannathan Sundararajan.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-GoeLin-66971600:backport-GoeLin-66971600
$ git checkout backport-GoeLin-66971600
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-GoeLin-66971600

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 6697160 Mar 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 6697160 Mar 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin the backport was successfully created on the branch backport-GoeLin-66971600 in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 66971600 from the openjdk/jdk repository.

The commit being backported was authored by Eirik Bjørsnøs on 31 Jan 2024 and was reviewed by Jaikiran Pai and Athijegannathan Sundararajan.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-GoeLin-66971600:backport-GoeLin-66971600
$ git checkout backport-GoeLin-66971600
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-GoeLin-66971600

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 6697160 Mar 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 6697160 Mar 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin the backport was successfully created on the branch backport-GoeLin-66971600 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 66971600 from the openjdk/jdk repository.

The commit being backported was authored by Eirik Bjørsnøs on 31 Jan 2024 and was reviewed by Jaikiran Pai and Athijegannathan Sundararajan.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git backport-GoeLin-66971600:backport-GoeLin-66971600
$ git checkout backport-GoeLin-66971600
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git backport-GoeLin-66971600

Please sign in to comment.