Skip to content

Commit

Permalink
fix test (#7078)
Browse files Browse the repository at this point in the history
  • Loading branch information
pethers authored Jan 23, 2025
1 parent d1732d4 commit 2eeb00f
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 53 deletions.
11 changes: 2 additions & 9 deletions citizen-intelligence-agency/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1694,15 +1694,8 @@
<excludes>
<exclude>**/*$*</exclude>
</excludes>
<systemPropertyVariables>
<java.util.logging.config.file>src/test/resources/logging.properties</java.util.logging.config.file>
</systemPropertyVariables>
<argLine>
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang.reflect=ALL-UNNAMED
-Xmx2048m
</argLine>
<argLine>${surefireArgLine} ${testAdditionalRuntimeArgLine}</argLine>
<useModulePath>false</useModulePath>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package com.hack23.cia.systemintegrationtest;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.openqa.selenium.WebDriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.hack23.cia.systemintegrationtest.ui.TestConstants;
import com.hack23.cia.systemintegrationtest.ui.UserPageVisit;
Expand All @@ -16,16 +13,11 @@
*/
public abstract class AbstractUITest extends AbstractRoleSystemITest {

/** The Constant LOG. */
private static final Logger LOG = LoggerFactory.getLogger(AbstractUITest.class);

/** The Constant DEFAULT_TIMEOUT. */
protected static final long DEFAULT_TIMEOUT = TestConstants.DEFAULT_TIMEOUT;

/** The Constant BASE_URL. */
protected static final String BASE_URL = System.getProperty("system.test.target.url",
CitizenIntelligenceAgencyServer.ACCESS_URL);


/** The driver. */
protected static WebDriver driver;

Expand All @@ -37,21 +29,10 @@ public abstract class AbstractUITest extends AbstractRoleSystemITest {
*/
@BeforeClass
public static void globalSetup() {
LOG.info("Setting up test with browser");
driver = WebDriverFactory.createDriver();
pageVisit = new UserPageVisit(driver);
}

/**
* Global teardown.
*/
@AfterClass
public static void globalTeardown() {
LOG.info("Tearing down WebDriver after all tests have run");
if (driver != null) {
driver.quit();
}
}

@After
public void cleanBrowser() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package com.hack23.cia.systemintegrationtest.suites;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.openqa.selenium.WebDriver;

import com.hack23.cia.systemintegrationtest.CitizenIntelligenceAgencyServer;
import com.hack23.cia.systemintegrationtest.admin.configuration.AdminConfigurationTest;
import com.hack23.cia.systemintegrationtest.admin.data.AdminDataTest;
import com.hack23.cia.systemintegrationtest.admin.operations.AdminOperationsTest;
import com.hack23.cia.systemintegrationtest.admin.security.AdminSecurityTest;
import com.hack23.cia.systemintegrationtest.ui.UserPageVisit;
import com.hack23.cia.systemintegrationtest.ui.WebDriverFactory;
import com.hack23.cia.systemintegrationtest.user.home.UserHomeTest;

import io.github.bonigarcia.wdm.WebDriverManager;
import io.github.bonigarcia.wdm.config.DriverManagerType;

/**
* The Class IntegrationTestSuite.
*/
Expand All @@ -27,11 +28,19 @@
UserHomeTest.class
})
public class IntegrationTestSuite {

protected static final boolean usingExternalServer;

/** The webdriver setup. */
private static boolean webdriverSetup = false;
/** The Constant BASE_URL. */
protected static final String BASE_URL = System.getProperty("system.test.target.url",
CitizenIntelligenceAgencyServer.ACCESS_URL);

/** The driver. */
protected static WebDriver driver;


/** The page visit. */
protected static UserPageVisit pageVisit;

protected static final boolean usingExternalServer;

/** The Constant webDriverMap. */
static {
Expand All @@ -47,6 +56,25 @@ public class IntegrationTestSuite {
CitizenIntelligenceAgencyServer.setEnv("CIA_APP_ENCRYPTION_PASSWORD", "allhaildiscordia");
}

/**
* Global setup.
*/
@BeforeClass
public static void globalSetup() {
driver = WebDriverFactory.createDriver();
pageVisit = new UserPageVisit(driver);
}

/**
* Global teardown.
*/
@AfterClass
public static void globalTeardown() {
if (driver != null) {
driver.quit();
}
}

/**
* Start server.
*
Expand All @@ -58,10 +86,6 @@ public static final synchronized void startServer() throws Exception {
if (!usingExternalServer) {
CitizenIntelligenceAgencyServer.startTestServer();
}
if(!webdriverSetup) {
WebDriverManager.getInstance(DriverManagerType.CHROME).setup();
webdriverSetup=true;
}
}

/**
Expand All @@ -77,6 +101,10 @@ public static final synchronized void stopServer() throws Exception {
}
}



@After
public void cleanBrowser() {
pageVisit.cleanBrowser();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@
ListPropertyConverterTest.class,
UserContextUtilTest.class})
public class UnitTestSuite {

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import io.github.bonigarcia.wdm.WebDriverManager;
import io.github.bonigarcia.wdm.config.DriverManagerType;

/**
* A factory for creating WebDriver objects.
*/
public class WebDriverFactory {

private static WebDriver driver;

/**
* Instantiates a new web driver factory.
Expand All @@ -22,8 +26,11 @@ private WebDriverFactory() {
* @return the web driver
*/
public static WebDriver createDriver() {
final WebDriver driver = createChromeDriver();
configureDriver(driver);
if (driver == null ) {
WebDriverManager.getInstance(DriverManagerType.CHROME).setup();
driver = createChromeDriver();
configureDriver(driver);
}
return driver;
}

Expand Down
14 changes: 6 additions & 8 deletions citizen-intelligence-agency/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,21 @@

<logger name="org.eclipse" level="warn" />

<logger name="org.springframework" level="info" />
<logger name="org.springframework.web" level="info" />
<logger name="org.springframework" level="error" />
<logger name="org.springframework.web" level="error" />
<logger name="org.springframework.oxm.jaxb" level="error" />

<logger name="org.springframework.security" level="warn" />
<logger name="org.springframework.security" level="error" />

<logger name="org.apache.activemq.artemis" level="warn" />
<logger name="org.apache.activemq.artemis" level="error" />

<logger name="ch.qos.logback.core" level="warn" />


<logger name="com.hack23.cia" level="info" />
<logger name="com.hack23.cia.systemintegrationtest" level="info" />
<logger name="com.hack23.cia" level="error" />


<root level="error">
<appender-ref ref="console" />
</root>

</configuration>
</configuration>

0 comments on commit 2eeb00f

Please sign in to comment.