Issue #23507 test-utils use junit5 instead of junit4
- also deleted ProxyModule - wasn't used anywhere
diff --git a/nucleus/test-utils/utils/pom.xml b/nucleus/test-utils/utils/pom.xml
index 7e1513f..9c7e1bc 100644
--- a/nucleus/test-utils/utils/pom.xml
+++ b/nucleus/test-utils/utils/pom.xml
@@ -59,5 +59,10 @@
<artifactId>glassfish</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/nucleus/test-utils/utils/src/main/java/org/glassfish/tests/utils/ConfigApiTest.java b/nucleus/test-utils/utils/src/main/java/org/glassfish/tests/utils/ConfigApiTest.java
index 5ad49bc..2537359 100644
--- a/nucleus/test-utils/utils/src/main/java/org/glassfish/tests/utils/ConfigApiTest.java
+++ b/nucleus/test-utils/utils/src/main/java/org/glassfish/tests/utils/ConfigApiTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -22,26 +23,24 @@
import java.security.PrivilegedAction;
import java.util.List;
import java.util.Set;
+import java.util.logging.Logger;
+
import javax.security.auth.Subject;
import javax.xml.stream.XMLStreamReader;
import org.glassfish.hk2.api.Filter;
+import org.glassfish.hk2.api.ServiceHandle;
import org.glassfish.hk2.api.ServiceLocator;
-import org.junit.Ignore;
import org.jvnet.hk2.config.ConfigBean;
import org.jvnet.hk2.config.ConfigModel;
import org.jvnet.hk2.config.DomDocument;
import org.jvnet.hk2.config.Transactions;
-import static org.junit.Assert.*;
-import java.util.logging.Logger;
-import org.glassfish.hk2.api.Descriptor;
-import org.glassfish.hk2.api.ServiceHandle;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Super class for all config-api related tests, give access to a configured habitat
*/
-@Ignore
public abstract class ConfigApiTest {
public static final Logger logger = Logger.getAnonymousLogger();
@@ -51,44 +50,19 @@
private Subject prepareAdminSubject() {
final ServiceLocator locator = getBaseServiceLocator();
if (locator != null) {
- final List<ServiceHandle<? extends Object>> adminIdentities =
-/*
- (List<ServiceHandle<? extends Object>>) getBaseServiceLocator().getAllServices(
- new Filter() {
-
- @Override
- public boolean matches(Descriptor d) {
- if (d == null) {
- return false;
- }
- final Set<String> contracts = d.getAdvertisedContracts();
- return (contracts == null ? false : contracts.contains("org.glassfish.internal.api.InternalSystemAdmin"));
+ final Filter filter = d -> {
+ if (d == null) {
+ return false;
}
- });
-*/
- AccessController.doPrivileged(new PrivilegedAction<List<ServiceHandle<? extends Object>>>() {
- public List<ServiceHandle<? extends Object>> run() {
-
- List<ServiceHandle<? extends Object>> identities = (List<ServiceHandle<? extends Object>>)getBaseServiceLocator().getAllServices(
- new Filter() {
-
- @Override
- public boolean matches(Descriptor d) {
- if (d == null) {
- return false;
- }
- final Set<String> contracts = d.getAdvertisedContracts();
- return (contracts == null ? false : contracts.contains("org.glassfish.internal.api.InternalSystemAdmin"));
- }
- });
-
- return identities;
-
- }
- });
-
-
- if ( ! adminIdentities.isEmpty()) {
+ final Set<String> contracts = d.getAdvertisedContracts();
+ return (contracts == null ? false
+ : contracts.contains("org.glassfish.internal.api.InternalSystemAdmin"));
+ };
+ final PrivilegedAction<List<ServiceHandle<? extends Object>>> privilegedAction = () -> {
+ return (List<ServiceHandle<? extends Object>>) getBaseServiceLocator().getAllServices(filter);
+ };
+ final List<ServiceHandle<? extends Object>> adminIdentities = AccessController.doPrivileged(privilegedAction);
+ if (!adminIdentities.isEmpty()) {
final Object adminIdentity = adminIdentities.get(0);
try {
final Method getSubjectMethod = adminIdentity.getClass().getDeclaredMethod("getSubject", Subject.class);
@@ -138,8 +112,8 @@
*/
public ServiceLocator getHabitat() {
ServiceLocator habitat = Utils.instance.getHabitat(this);
-
- assertNotNull("Transactions service from Configuration subsystem is null", habitat.getService(Transactions.class));
+ assertNotNull(habitat.getService(Transactions.class),
+ "Transactions service from Configuration subsystem is null");
return habitat;
}
@@ -171,9 +145,11 @@
}
}
- /*
+ /**
* Decorate the habitat after parsing. This is called on the habitat
* just after parsing of the XML file is complete.
*/
- public void decorate(ServiceLocator habitat) {}
+ public void decorate(ServiceLocator locator) {
+ // override it
+ }
}
diff --git a/nucleus/test-utils/utils/src/main/java/org/glassfish/tests/utils/ProxyModule.java b/nucleus/test-utils/utils/src/main/java/org/glassfish/tests/utils/ProxyModule.java
deleted file mode 100644
index b86a061..0000000
--- a/nucleus/test-utils/utils/src/main/java/org/glassfish/tests/utils/ProxyModule.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (c) 2009, 2018 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
- */
-
-package org.glassfish.tests.utils;
-
-import com.sun.enterprise.module.*;
-
-import java.util.List;
-import java.io.PrintStream;
-
-/**
- * Created by IntelliJ IDEA.
- * User: dochez
- * Date: Nov 19, 2008
- * Time: 11:29:13 PM
- * To change this template use File | Settings | File Templates.
- */
-public class ProxyModule implements HK2Module {
-
- final ClassLoader classLoader;
- final ModuleDefinition moduleDef;
- final ModulesRegistry modulesRegistry;
-
- public ProxyModule(ModulesRegistry registry, ModuleDefinition moduleDef, ClassLoader cl) {
- this.classLoader = cl;
- this.moduleDef = moduleDef;
- this.modulesRegistry = registry;
- }
-
- public ModuleDefinition getModuleDefinition() {
- return moduleDef;
- }
-
- public String getName() {
- return moduleDef.getName();
- }
-
- public ModulesRegistry getRegistry() {
- return modulesRegistry;
- }
-
- public ModuleState getState() {
- return ModuleState.READY;
- }
-
- public void resolve() throws ResolveError {
-
- }
-
- public void start() throws ResolveError {
-
- }
-
- public boolean stop() {
- return false;
- }
-
- public void detach() {
- }
-
- public void refresh() {
- }
-
- public ModuleMetadata getMetadata() {
- return moduleDef.getMetadata();
- }
-
- public void addListener(ModuleChangeListener listener) {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void removeListener(ModuleChangeListener listener) {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public ClassLoader getClassLoader() {
- return classLoader;
- }
-
- public List<HK2Module> getImports() {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void addImport(HK2Module module) {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public HK2Module addImport(ModuleDependency dependency) {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public boolean isShared() {
- return false; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public boolean isSticky() {
- return false; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void setSticky(boolean sticky) {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public <T> Iterable<Class<? extends T>> getProvidersClass(Class<T> serviceClass) {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public Iterable<Class> getProvidersClass(String name) {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public boolean hasProvider(Class serviceClass) {
- return false; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void dumpState(PrintStream writer) {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void uninstall() {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-}
diff --git a/nucleus/test-utils/utils/src/main/java/org/glassfish/tests/utils/Utils.java b/nucleus/test-utils/utils/src/main/java/org/glassfish/tests/utils/Utils.java
index f6bbc50..1f1049a 100644
--- a/nucleus/test-utils/utils/src/main/java/org/glassfish/tests/utils/Utils.java
+++ b/nucleus/test-utils/utils/src/main/java/org/glassfish/tests/utils/Utils.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,8 +17,6 @@
package org.glassfish.tests.utils;
-// import com.sun.enterprise.module.bootstrap.Populator;
-
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
@@ -86,13 +85,14 @@
return sl;
}
+
public static ServiceLocator getNewHabitat() {
- final String root = Utils.class.getResource("/").getPath();
+ final String root = Utils.class.getResource("/").getPath();
return getNewHabitat(root);
}
- public static ServiceLocator getNewHabitat(String root) {
+ public static ServiceLocator getNewHabitat(String root) {
Properties p = new Properties();
p.put(com.sun.enterprise.glassfish.bootstrap.Constants.INSTALL_ROOT_PROP_NAME, root);
p.put(com.sun.enterprise.glassfish.bootstrap.Constants.INSTANCE_ROOT_PROP_NAME, root);
@@ -101,8 +101,8 @@
return defaultSL;
}
- public void shutdownServiceLocator(
- final ConfigApiTest test) {
+
+ public void shutdownServiceLocator(final ConfigApiTest test) {
String fileName = test.getFileName();
if (habitats.containsKey(fileName)) {