Skip to content

Commit

Permalink
chore(merge): release-10.2.0 into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
bonita-ci committed Sep 17, 2024
2 parents bf6f24b + 1aae95b commit 7b9a195
Show file tree
Hide file tree
Showing 13 changed files with 165 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
Expand All @@ -42,9 +41,9 @@ public class ClassloaderRefresher {
*/
public ClassLoader loadClientModelInClassloader(final byte[] clientZipContent, final ClassLoader contextClassLoader,
final String modelClass,
final File fsFolderToPutJars) throws IOException, MalformedURLException {
final File fsFolderToPutJars) throws IOException {
final Map<String, byte[]> ressources = IOUtils.unzip(clientZipContent);
final List<URL> urls = new ArrayList<URL>();
final List<URL> urls = new ArrayList<>();
for (final Entry<String, byte[]> e : ressources.entrySet()) {
final File file = new File(fsFolderToPutJars, e.getKey());
if (file.getName().endsWith(".jar")) {
Expand All @@ -58,7 +57,7 @@ public ClassLoader loadClientModelInClassloader(final byte[] clientZipContent, f
}
if (file.getName().contains("dao")) {
try {
contextClassLoader.loadClass(modelClass + "DAO");
contextClassLoader.loadClass(modelClass + "DAOImpl");
} catch (final ClassNotFoundException e1) {
FileUtils.writeByteArrayToFile(file, e.getValue());
urls.add(file.toURI().toURL());
Expand All @@ -76,7 +75,7 @@ public ClassLoader loadClientModelInClassloader(final byte[] clientZipContent, f
}
ClassLoader classLoaderWithBDM = contextClassLoader;
if (!urls.isEmpty()) {
classLoaderWithBDM = new URLClassLoader(urls.toArray(new URL[urls.size()]), contextClassLoader);
classLoaderWithBDM = new URLClassLoader(urls.toArray(new URL[0]), contextClassLoader);
}
return classLoaderWithBDM;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@
import org.bonitasoft.engine.tenant.TenantResource;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.xml.sax.SAXException;

/**
* Those tests fail because after installing the second BDM version, Hibernate is not aware of
* Those tests fail on MySQL and SQLServer because after installing the second BDM version, Hibernate is not aware of
* previous FK_ that stay in database, so it does not drop them, and then the 'drop table' fails on test cleanup.
* Those cases should be handled when we support more "BDM update" scenarios, leveraging Hibernate poor level of
* support on HBM2DDL.
*/
@Ignore("FIXME: Not working on mysql and sql server")
public class BDMUpdateIT extends CommonAPIIT {

public static final String DOT = ".";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,7 @@
import org.bonitasoft.engine.api.impl.application.installer.ApplicationArchive;
import org.bonitasoft.engine.api.impl.application.installer.ApplicationArchiveReader;
import org.bonitasoft.engine.api.impl.application.installer.ApplicationInstaller;
import org.bonitasoft.engine.api.impl.application.installer.detector.ArtifactTypeDetector;
import org.bonitasoft.engine.api.impl.application.installer.detector.BdmDetector;
import org.bonitasoft.engine.api.impl.application.installer.detector.CustomPageDetector;
import org.bonitasoft.engine.api.impl.application.installer.detector.IconDetector;
import org.bonitasoft.engine.api.impl.application.installer.detector.LayoutDetector;
import org.bonitasoft.engine.api.impl.application.installer.detector.LivingApplicationDetector;
import org.bonitasoft.engine.api.impl.application.installer.detector.OrganizationDetector;
import org.bonitasoft.engine.api.impl.application.installer.detector.PageAndFormDetector;
import org.bonitasoft.engine.api.impl.application.installer.detector.ProcessDetector;
import org.bonitasoft.engine.api.impl.application.installer.detector.ThemeDetector;
import org.bonitasoft.engine.api.impl.application.installer.detector.*;
import org.bonitasoft.engine.bpm.process.ActivationState;
import org.bonitasoft.engine.bpm.process.ConfigurationState;
import org.bonitasoft.engine.bpm.process.ProcessDeploymentInfo;
Expand All @@ -55,6 +46,11 @@ public void before() throws Exception {

@After
public void after() throws Exception {
if (!getTenantAdministrationAPI().isPaused()) {
getTenantAdministrationAPI().pause();
getTenantAdministrationAPI().cleanAndUninstallBusinessDataModel();
getTenantAdministrationAPI().resume();
}
logoutOnTenant();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,16 @@ public void before() throws Exception {
new LivingApplicationDetector(), new OrganizationDetector(), new CustomPageDetector(),
new ProcessDetector(), new ThemeDetector(), new PageAndFormDetector(), new LayoutDetector(),
new IconDetector()));

initFirstInstall();
}

@After
public void after() throws Exception {
if (!getTenantAdministrationAPI().isPaused()) {
getTenantAdministrationAPI().pause();
getTenantAdministrationAPI().cleanAndUninstallBusinessDataModel();
getTenantAdministrationAPI().resume();
}
logoutOnTenant();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,7 @@ public void timerBoundaryEvent_should_not_trigger_and_be_deleted_at_flownode_abo
waitForUserTask(processInstance.getId(), "step1");
waitForUserTaskAssignAndExecuteIt(processInstance, "step2", user, Map.of());
waitForProcessToFinish(processInstance);
List<String> allJobs = schedulerService.getAllJobs();
assertThat(allJobs).isEmpty();
assertThat(schedulerService.getAllJobs()).isEmpty();
disableAndDeleteProcess(processDefinition);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.bonitasoft.engine.business.application.model.SApplicationState;
import org.bonitasoft.engine.page.PageService;
import org.bonitasoft.engine.page.SPage;
import org.bonitasoft.engine.profile.ProfileService;
import org.bonitasoft.engine.profile.model.SProfile;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -34,6 +36,7 @@ public class ApplicationImporterIT extends CommonBPMServicesTest {
private ApplicationImporter applicationImporter;
private ApplicationService applicationService;
private PageService pageService;
private ProfileService profileService;

private static final String APP_1_TOKEN = "app1";
private static final String APP_2_TOKEN = "app2";
Expand All @@ -45,6 +48,7 @@ public void setUp() {
applicationImporter = getServiceAccessor().getApplicationImporter();
applicationService = getServiceAccessor().getApplicationService();
pageService = getServiceAccessor().getPageService();
profileService = getServiceAccessor().getProfileService();
}

@After
Expand Down Expand Up @@ -222,7 +226,7 @@ private void assertAppLink1() throws Exception {
assertThat(app.getIconPath()).isEqualTo("/app1.jpg");
assertThat(app.getCreatedBy()).isEqualTo(-1L);
assertThat(app.getState()).isEqualTo(SApplicationState.ACTIVATED.name());
assertThat(app.getProfileId()).isEqualTo(1L);
assertThat(getProfile(app.getProfileId()).getName()).isEqualTo("User");
assertThat(app.getInternalProfile()).isNull();
assertThat(app.getHomePageId()).isNull();
assertThat(app.getLayoutId()).isNull();
Expand All @@ -231,6 +235,10 @@ private void assertAppLink1() throws Exception {
assertThat(app.isLink()).isTrue();
}

private SProfile getProfile(Long profileId) throws Exception {
return getTransactionService().executeInTransaction(() -> profileService.getProfile(profileId));
}

private void assertAppLink2() throws Exception {
SApplication app = getTransactionService()
.executeInTransaction(() -> applicationService.getApplicationByToken(APP_2_TOKEN));
Expand Down Expand Up @@ -261,7 +269,7 @@ private void assertAppLink3() throws Exception {
assertThat(app.getCreatedBy()).isEqualTo(-1L);
assertThat(app.getState()).isEqualTo(SApplicationState.ACTIVATED.name());
assertThat(app.getHomePageId()).isNotNull();
assertThat(app.getProfileId()).isEqualTo(1L);
assertThat(getProfile(app.getProfileId()).getName()).isEqualTo("User");
assertThat(app.getInternalProfile()).isNull();
assertThat(app.getLayoutId()).isNotNull();
assertThat(app.getThemeId()).isNotNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
**/
package org.bonitasoft.engine.test.junit;

import java.lang.reflect.InvocationTargetException;

import org.bonitasoft.engine.test.TestEngine;
import org.bonitasoft.engine.test.TestEngineImpl;
import org.junit.rules.MethodRule;
Expand All @@ -32,6 +34,16 @@ protected BonitaEngineRule(TestEngine testEngine) {
}

public static BonitaEngineRule create() {
try {
var testEngineSpClazz = BonitaEngineRule.class.getClassLoader()
.loadClass("com.bonitasoft.engine.test.TestEngineSP");
TestEngine testEngineSpInstance = (TestEngine) testEngineSpClazz.getMethod("getInstance").invoke(null);
return new BonitaEngineRule(testEngineSpInstance);
} catch (ClassNotFoundException e) {
// Use Community TestEngine
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
throw new RuntimeException(e);
}
return new BonitaEngineRule(TestEngineImpl.getInstance());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,21 @@ public Object invokeMethod(final Map<String, Serializable> options, final String
}
} catch (final BonitaRuntimeException | BonitaException bre) {
fillGlobalContextForException(session, bre);
// reset class loader
Thread.currentThread().setContextClassLoader(baseClassLoader);
throw createServerWrappedException(bre);
} catch (final UndeclaredThrowableException ute) {
// reset class loader
Thread.currentThread().setContextClassLoader(baseClassLoader);
throw createServerWrappedException(ute);
} catch (final Throwable cause) {
final BonitaRuntimeException throwableToWrap = wrapThrowable(cause);
fillGlobalContextForException(session, throwableToWrap);
// reset class loader
Thread.currentThread().setContextClassLoader(baseClassLoader);
throw createServerWrappedException(throwableToWrap);
} finally {
cleanSessionIfNeeded(sessionAccessor);
// reset class loader
Thread.currentThread().setContextClassLoader(baseClassLoader);
logger.trace("End Server API call {} {}", apiInterfaceName, methodName);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.bonitasoft.engine.gradle.docker

import groovy.transform.Canonical
import org.gradle.api.Project

@Canonical
class DatabaseExtraConfiguration {
/**
* Include an additional module in the test classpath
*/
Project includeTestModule
/**
* Excludes test class patterns
*/
List<String> excludes
/**
* Enable or disable the execution of the test task for this database configuration
*/
boolean enabled = false

def excludes(String... excludes) {
this.excludes = []
this.excludes.addAll(excludes)
}

def exclude(String excludes) {
if (this.excludes == null) {
this.excludes = []
}
this.excludes.add(excludes)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,28 @@
**/
package org.bonitasoft.engine.gradle.docker

/**
* @author Baptiste Mesta
*/
class DatabasePluginExtension {

/**
* Include test class patterns
*/
List<String> includes
/**
* Extra configuration for the postgres database
*/
DatabaseExtraConfiguration postgres = new DatabaseExtraConfiguration(enabled: true)
/**
* Extra configuration for the mysql database
*/
DatabaseExtraConfiguration mysql = new DatabaseExtraConfiguration()
/**
* Extra configuration for the oracle database
*/
DatabaseExtraConfiguration oracle = new DatabaseExtraConfiguration()
/**
* Extra configuration for the sqlserver database
*/
DatabaseExtraConfiguration sqlserver = new DatabaseExtraConfiguration()

def includes(String... includes) {
this.includes = []
Expand All @@ -32,4 +48,28 @@ class DatabasePluginExtension {
this.includes.add(include)
}

def postgres(Closure closure) {
closure.delegate = postgres
closure.resolveStrategy = Closure.DELEGATE_FIRST
closure()
}

def mysql(Closure closure) {
closure.delegate = mysql
closure.resolveStrategy = Closure.DELEGATE_FIRST
closure()
}

def oracle(Closure closure) {
closure.delegate = oracle
closure.resolveStrategy = Closure.DELEGATE_FIRST
closure()
}

def sqlserver(Closure closure) {
closure.delegate = sqlserver
closure.resolveStrategy = Closure.DELEGATE_FIRST
closure()
}

}
Loading

0 comments on commit 7b9a195

Please sign in to comment.