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

All active tests transformed from JUnit1-4 to Junit5 #23598

Merged
merged 69 commits into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
2e6af89
Issue #23507 Junit4 removed from poms in reactor
dmatej Aug 23, 2021
09e455f
Issue #23507 tiger-types use junit5 instead of junit4
dmatej Aug 23, 2021
e5672dd
Issue #23507 hk2-config use junit5 instead of junit4
dmatej Aug 23, 2021
1169004
Issue #23507 Removed unused profile from hk2-config
dmatej Aug 23, 2021
2b74fb0
Issue #23507 config-types use junit5 instead of junit4
dmatej Aug 23, 2021
c01dee3
Issue #23507 grizzly-config uses junit5 instead of junit4
dmatej Aug 23, 2021
9cdd9ee
Issue #23507 glassfish-api uses junit5 instead of junit4
dmatej Aug 23, 2021
11b4df6
Issue #23507 Added missing license headers
dmatej Aug 23, 2021
5c03648
Issue #23507 common-util uses junit5 instead of junit4 + crazy stuff
dmatej Aug 23, 2021
e23bfc8
Issue #23507 glassfish(bootstrap) uses junit5 instead of junit4
dmatej Aug 23, 2021
60833e0
Issue #23507 test-utils use junit5 instead of junit4
dmatej Aug 23, 2021
b608adf
Issue #23507 config-api uses junit5 instead of junit4
dmatej Aug 24, 2021
5a793d2
Issue #23507 deployment-common uses junit5 instead of junit4
dmatej Aug 25, 2021
6eeccf7
Issue #23507 Implemented HK2Extension
dmatej Aug 25, 2021
0e13ee8
Issue #23507 security-services use junit5 instead of junit4
dmatej Aug 25, 2021
f4ccc6a
Issue #23507 admin-util uses junit5 instead of junit4
dmatej Aug 25, 2021
29ea5e9
Issue #23507 cluster-common uses junit5 instead of junit4
dmatej Aug 25, 2021
9754f8c
Issue #23507 libpam4j now uses junit5 instead of junit4/3
dmatej Aug 27, 2021
ac22ab9
Issue #23507 jta now uses junit5 instead of junit3 and asserts
dmatej Aug 27, 2021
54d29ca
Issue #23507 jaspic-provider-framework now uses junit5 instead of junit4
dmatej Aug 27, 2021
06d48db
Issue #23507 security-ee now uses junit5 instead of junit4
dmatej Aug 27, 2021
a4eab40
Issue #23507 logging now uses junit5 instead of junit4
dmatej Aug 27, 2021
0ffcfa6
Issue #23507 admin-core now uses junit5 instead of junit4
dmatej Aug 29, 2021
9323810
Issue #23507 launcher now uses junit5 instead of junit4
dmatej Aug 29, 2021
88c599f
Issue #23507 admin-cli now uses junit5 instead of junit4 + deleted zo…
dmatej Aug 29, 2021
8e086c3
Issue #23507 Removed unused AIX profile
dmatej Aug 29, 2021
403dc78
Issue #23507 flashligh-framework now uses junit5 instead of junit4 + …
dmatej Aug 29, 2021
b1c3d18
Issue #23507 HK2Extension for JUnit5 extended after kernel experience
dmatej Sep 1, 2021
22d287d
Issue #23507 Disabled trimming stacktraces from tests
dmatej Sep 1, 2021
25a81c4
Issue #23507 kernel now uses JUnit5 instead Junit4 + enabled and fixe…
dmatej Sep 1, 2021
14bcf90
Issue #23507 Refactoring to be independent on the old hk2-junitrunner
dmatej Sep 1, 2021
c2fdcd6
Issue #23507 cluster-cli now uses junit5 instead of junit4
dmatej Sep 2, 2021
e4d8afc
Issue #23507 amx-core now uses junit5 instead of junit4
dmatej Sep 2, 2021
bbe6b7e
Issue #23507 context-propagation now uses junit5 instead of junit4
dmatej Sep 2, 2021
329552b
Issue #23507 context-propagation tests enabled
dmatej Sep 3, 2021
c51842f
Issue #23507 monitoring-core now uses junit5 instead of junit4 + enab…
dmatej Sep 3, 2021
2265c42
Issue #23507 Fixed ProgressStatusEventTest's imports
dmatej Sep 3, 2021
13a2393
Issue #23507 deployment-admin now uses junit5 instead of junit4
dmatej Sep 3, 2021
8319ee0
Issue #23507 diagnostics-context now uses junit5 instead of junit4
dmatej Sep 3, 2021
f8fd5dc
Issue #23507 annotation-framework now uses junit5 instead of junit4
dmatej Sep 3, 2021
846865e
Issue #23507 EasyMock moved to Jmockit and upgraded
dmatej Sep 3, 2021
f44cd35
Issue #23507 dol now uses junit5 instead of junit4
dmatej Sep 3, 2021
58c6a5f
Issue #23507 glassfish-naming now uses junit5 instead of junit4
dmatej Sep 3, 2021
79fa42f
Issue #23507 resources-connector now uses junit5 instead of junit4
dmatej Sep 3, 2021
fdd76e9
Issue #23507 connectors-internal-api now uses junit5 instead of junit4
dmatej Sep 4, 2021
8c8252e
Issue #23507 orb-connector now uses junit5 instead of junit4
dmatej Sep 4, 2021
4a9123d
Issue #23507 mail-connector now uses junit5 instead of junit4
dmatej Sep 4, 2021
039e0f9
Issue #23507 jts now uses junit5 instead of junit1/2
dmatej Sep 6, 2021
ad515d3
Issue #23507 web-core now uses junit5 instead of junit4
dmatej Sep 6, 2021
e1fd722
Issue #23507 ejb-container now uses junit5 instead of junit4
dmatej Sep 6, 2021
71208c8
Issue #23507 weld-integration now uses junit5 instead of junit4
dmatej Sep 6, 2021
25688ee
Issue #23507 connectors-admin now uses junit5 instead of junit4
dmatej Sep 6, 2021
f45f442
Issue #23507 jdbc-runtime now uses junit5 instead of junit4
dmatej Sep 6, 2021
8d59f2b
Issue #23507 jdbc-admin now uses junit5 instead of junit4 + enabled s…
dmatej Sep 6, 2021
0179a06
Issue #23507 Reflection helper methods moved to Utils class
dmatej Sep 6, 2021
e21acf2
Issue #23507 concurrent-impl now uses junit5 instead of junit4 + enab…
dmatej Sep 6, 2021
c8fe011
Issue #23507 jsr109-impl now uses junit5 instead of junit4
dmatej Sep 6, 2021
f97043a
Issue #23507 acc-config now uses junit5 instead of junit4
dmatej Sep 6, 2021
d520f0f
Issue #23507 gf-client-module now uses junit5 instead of junit4
dmatej Sep 6, 2021
72d1671
Issue #23507 RestResponseTest deleted - it tested just if 10 is equal…
dmatej Sep 7, 2021
388f9c0
Issue #23507 TCK runner now uses junit5 instead of junit4
dmatej Sep 7, 2021
63b1d3a
Issue #23507 Allow to set null as the installRoot (in tests)
dmatej Sep 7, 2021
6006b91
Issue #23507 UpgradeTest doesn't depend on ConfigApiTest
dmatej Sep 7, 2021
078edbc
Issue #23507 Enabled some context-propagation tests
dmatej Sep 7, 2021
6e3c8ca
Issue #23507 ConfigApiTest and related methods are gone.
dmatej Sep 9, 2021
4dad2a5
Issue #23507 Refactored test-utils
dmatej Sep 9, 2021
671195f
Issue #23507 New test updated to keep standards
dmatej Sep 9, 2021
9177204
Issue #23507 test-utils and utils merged to a single project
dmatej Sep 9, 2021
b5b5dbb
Issue #23507 Fixed mistakes spotted in my own review
dmatej Sep 9, 2021
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
  •  
  •  
  •  
21 changes: 10 additions & 11 deletions appserver/admin/admin-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,26 @@
<version>${project.version}</version>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>org.glassfish.main.tests</groupId>
<artifactId>utils</artifactId>
<groupId>org.glassfish.main</groupId>
<artifactId>test-utils</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.el</groupId>
<artifactId>jakarta.el-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>jakarta.el</artifactId>
<scope>test</scope>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
</dependency>
<!-- Dependency of Hibernate Validator -->
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>jakarta.el</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2009, 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
Expand All @@ -16,63 +17,106 @@

package com.sun.enterprise.admin.tests;

import java.util.logging.Logger;
import java.util.List;
import java.util.ArrayList;

import com.sun.enterprise.config.serverbeans.Application;
import com.sun.enterprise.config.serverbeans.Applications;
import com.sun.enterprise.config.serverbeans.Config;
import com.sun.enterprise.config.serverbeans.Domain;
import com.sun.enterprise.config.serverbeans.Module;
import com.sun.enterprise.config.serverbeans.Config;
import org.glassfish.grizzly.config.dom.ThreadPool;
import com.sun.enterprise.module.bootstrap.StartupContext;
import com.sun.enterprise.util.SystemPropertyConstants;

import java.util.List;
import java.util.logging.Logger;

import org.glassfish.api.admin.ServerEnvironment;
import org.glassfish.api.admin.config.ConfigurationUpgrade;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import org.glassfish.grizzly.config.dom.ThreadPool;
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.tests.utils.junit.DomainXml;
import org.glassfish.tests.utils.junit.HK2JUnit5Extension;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import jakarta.inject.Inject;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.arrayContaining;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Simple test for the domain.xml upgrade scenario
*
* @author Jerome Dochez
*/
public class UpgradeTest extends ConfigApiTest {
@ExtendWith(HK2JUnit5Extension.class)
@DomainXml(value = "UpgradeTest.xml")
public class UpgradeTest {

@Inject
private ServiceLocator locator;
@Inject
private StartupContext startupContext;

// FIXME: Workaround, because ServerEnvironmentImpl changes global System.properties, but other services
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on this I created this issue: #23593

// are depending on it. The for cycle in setup() in the test will start initializations
// of objects, but the order is not well defined.
// But if the test instance injects the environment instance, it is initialized before the cycle.
@Inject
private ServerEnvironment environment;

@Before
/**
* Does the upgrade. Results will be verified in tests methods.
*/
@BeforeEach
public void setup() {
Domain domain = getHabitat().getService(Domain.class);
assertTrue(domain!=null);
System.clearProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY);
startupContext.getArguments().clear();

// perform upgrade
for (ConfigurationUpgrade upgrade : getHabitat().<ConfigurationUpgrade>getAllServices(ConfigurationUpgrade.class)) {
Logger.getAnonymousLogger().info("running upgrade " + upgrade.getClass());
Domain domain = locator.getService(Domain.class);
assertNotNull(domain);

final List<ConfigurationUpgrade> allServices = locator
.<ConfigurationUpgrade> getAllServices(ConfigurationUpgrade.class);
for (ConfigurationUpgrade upgrade : allServices) {
Logger.getAnonymousLogger().info("Running upgrade " + upgrade.getClass());
}
}

@AfterEach
public void checkStateOfEnvironment() {
// DefaultConfigUpgrade uses this property.
assertNull(System.getProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY), "Install root in system props");
assertNotNull(environment.getInstanceRoot(), "Instance root in ServerEnvironment");
assertNull(startupContext.getArguments().get(SystemPropertyConstants.INSTALL_ROOT_PROPERTY),
"Install root in startup context");
}

@Test
public void threadPools() {
List<String> names = new ArrayList<String>();
for (ThreadPool pool : getHabitat().<Config>getService(Config.class).getThreadPools().getThreadPool()) {
names.add(pool.getName());
}
assertTrue(names.contains("http-thread-pool") && names.contains("thread-pool-1"));
List<ThreadPool> threadPools = locator.<Config>getService(Config.class).getThreadPools().getThreadPool();
assertThat(threadPools, hasSize(3));
String[] threadPoolNames = threadPools.stream().map(ThreadPool::getName).toArray(String[]::new);
assertThat(threadPoolNames, arrayContaining("thread-pool-1", "http-thread-pool", "admin-thread-pool"));
}

private void verify(String name) {
assertTrue("Should find thread pool named " + name, getHabitat().getService(ThreadPool.class, name) != null);
}

@Test
public void applicationUpgrade() {
Applications apps = getHabitat().getService(Applications.class);
assertTrue(apps!=null);
Applications apps = locator.getService(Applications.class);
assertNotNull(apps);
for (Application app : apps.getApplications()) {
assertTrue(app.getEngine().isEmpty());
assertTrue(app.getModule().size()==1);
assertThat(app.getModule(), hasSize(1));
for (Module module : app.getModule()) {
assertTrue(module.getName().equals(app.getName()));
assertTrue(!module.getEngines().isEmpty());
assertEquals(app.getName(), module.getName());
assertFalse(module.getEngines().isEmpty());
}
}
}

}
}
5 changes: 0 additions & 5 deletions appserver/admingui/common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,5 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
</dependency>
</dependencies>
</project>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@

import org.junit.jupiter.api.Test;

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

public class WoodstockHandlerTest {
@Test
public void testMessageForNullName() {
var actual = WoodstockHandler.prepareFileNotDeletedMessage(null);

assert "file Couldn't be found at null, proceeding execution without deletion.".equals(actual) : actual;
}
@Test
public void testMessageForNullName() {
var actual = WoodstockHandler.prepareFileNotDeletedMessage(null);
assertEquals("file Couldn't be found at null, proceeding execution without deletion.", actual);
}

@Test
public void testMessageForNonNullName() {
var actual = WoodstockHandler.prepareFileNotDeletedMessage("abcd");

assert "file Couldn't be found at abcd, proceeding execution without deletion.".equals(actual) : actual;
}
@Test
public void testMessageForNonNullName() {
var actual = WoodstockHandler.prepareFileNotDeletedMessage("abcd");
assertEquals("file Couldn't be found at abcd, proceeding execution without deletion.", actual);
}
}

5 changes: 5 additions & 0 deletions appserver/appclient/client/acc-config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-osgi</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
Expand Down
Loading