Skip to content

Commit 8503291

Browse files
authored
Merge pull request #35 from ktor/master
fix: multi company configuration execution, add tests, upgrade testing harness libraries
2 parents f4188d5 + ca35da3 commit 8503291

File tree

12 files changed

+336
-132
lines changed

12 files changed

+336
-132
lines changed

.github/workflows/build.yml

Lines changed: 63 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,65 @@
1-
name: Build
1+
name: Build and analyze
22
on:
3-
push:
4-
branches:
5-
- master
6-
pull_request:
7-
types: [opened, synchronize, reopened]
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
types: [ opened, synchronize, reopened ]
88
jobs:
9-
build:
10-
name: Build
11-
runs-on: ubuntu-latest
12-
steps:
13-
- uses: actions/checkout@v2
14-
with:
15-
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
16-
- name: Set up JDK 11
17-
uses: actions/setup-java@v1
18-
with:
19-
java-version: 11
20-
- name: Cache SonarCloud packages
21-
uses: actions/cache@v1
22-
with:
23-
path: ~/.sonar/cache
24-
key: ${{ runner.os }}-sonar
25-
restore-keys: ${{ runner.os }}-sonar
26-
- name: Cache Maven packages
27-
uses: actions/cache@v1
28-
with:
29-
path: ~/.m2
30-
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
31-
restore-keys: ${{ runner.os }}-m2
32-
- name: Build and analyze
33-
env:
34-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
35-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
36-
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=liferay-db-setup-core-2_x
9+
build:
10+
name: Build and test
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
16+
- name: Set up JDK 1.8
17+
uses: actions/setup-java@v1
18+
with:
19+
java-version: 8
20+
- name: Cache SonarCloud packages
21+
uses: actions/cache@v1
22+
with:
23+
path: ~/.sonar/cache
24+
key: ${{ runner.os }}-sonar
25+
restore-keys: ${{ runner.os }}-sonar
26+
- name: Cache Maven packages
27+
uses: actions/cache@v1
28+
with:
29+
path: ~/.m2
30+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
31+
restore-keys: ${{ runner.os }}-m2
32+
- name: Build and test
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
35+
run: mvn -B clean package
36+
scan:
37+
name: Analyze
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v2
41+
with:
42+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
43+
- name: Set up JDK 11
44+
uses: actions/setup-java@v1
45+
with:
46+
java-version: 11
47+
- name: Cache Maven packages
48+
uses: actions/cache@v1
49+
with:
50+
path: ~/.m2
51+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
52+
restore-keys: ${{ runner.os }}-m2
53+
- name: Cache SonarCloud packages
54+
uses: actions/cache@v1
55+
with:
56+
path: ~/.sonar/cache
57+
key: ${{ runner.os }}-sonar
58+
restore-keys: ${{ runner.os }}-sonar
59+
- name: Sonar Scan
60+
env:
61+
# Needed to get some information about the pull request, if any
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
# SonarCloud access token should be generated from https://sonarcloud.io/account/security/
64+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
65+
run: mvn -B verify -DskipTests org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Pcoverage

.travis.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

README.adoc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
= Liferay Portal DB setup core
22
:liferay-version: 7.3.6
3-
:current-db-setup-core-version: 7.3.602
3+
:current-db-setup-core-version: 7.3.603
44
:TOC:
55

66
image:https://maven-badges.herokuapp.com/maven-central/com.ableneo.liferay/com.ableneo.liferay.db.setup.core/badge.svg?color=blue[Maven Central,link=https://search.maven.org/search?q=g:com.ableneo.liferay%20AND%20a:com.ableneo.liferay.db.setup.core]
@@ -256,6 +256,13 @@ They are probably not perfect, please let me know if anything feels wrong or inc
256256

257257
== Changelog
258258

259+
=== Version 7.3.603
260+
==== Features & bug fixes
261+
* fixed setup for multiple companies/groups
262+
263+
==== Refactorings & project changes
264+
* upgraded test harness to latest mockito, added basic tests for multiple company/groups setup execution
265+
259266
=== Version 7.3.602
260267
==== Features & bug fixes
261268
* fixed configuration related resource reading, library can read e.g. article files from caller bundle, credit goes to Milan Kuljovsky- thank you!

pom.xml

Lines changed: 73 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45

56
<parent>
@@ -21,10 +22,16 @@
2122
<liferay.version>7.3.6</liferay.version>
2223
<liferay.version.portal.api>${liferay.version}-ga7</liferay.version.portal.api>
2324

24-
<jmockit.version>1.46</jmockit.version>
25+
<junit.version>5.8.2</junit.version>
26+
<mockito.version>4.3.1</mockito.version>
27+
2528
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2629

2730
<bnd.version>5.2.0</bnd.version>
31+
32+
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
33+
<sonar.organization>ableneo</sonar.organization>
34+
<sonar.projectKey>liferay-db-setup-core-2_x</sonar.projectKey>
2835
</properties>
2936

3037
<build>
@@ -147,23 +154,12 @@
147154
<artifactId>maven-surefire-plugin</artifactId>
148155
<version>2.22.1</version>
149156
<dependencies>
150-
<dependency>
151-
<groupId>org.junit.platform</groupId>
152-
<artifactId>junit-platform-surefire-provider</artifactId>
153-
<version>1.2.0</version>
154-
</dependency>
155157
<dependency>
156158
<groupId>org.junit.jupiter</groupId>
157159
<artifactId>junit-jupiter-engine</artifactId>
158-
<version>5.3.1</version>
160+
<version>${junit.version}</version>
159161
</dependency>
160162
</dependencies>
161-
<configuration>
162-
<argLine>
163-
@{argLine}
164-
-javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar
165-
</argLine>
166-
</configuration>
167163
</plugin>
168164

169165
<plugin>
@@ -186,6 +182,12 @@
186182
</execution>
187183
</executions>
188184
</plugin>
185+
<plugin>
186+
<groupId>org.sonarsource.scanner.maven</groupId>
187+
<artifactId>sonar-maven-plugin</artifactId>
188+
<!-- see versions at https://search.maven.org/search?q=g:org.sonarsource.scanner.maven%20AND%20a:sonar-maven-plugin -->
189+
<version>3.9.1.2184</version>
190+
</plugin>
189191
<plugin>
190192
<groupId>biz.aQute.bnd</groupId>
191193
<artifactId>bnd-maven-plugin</artifactId>
@@ -274,10 +276,12 @@
274276
<groupId>com.liferay.portal</groupId>
275277
<artifactId>release.portal.api</artifactId>
276278
<version>${liferay.version.portal.api}</version>
279+
<scope>provided</scope>
277280
</dependency>
278281
<dependency>
279282
<groupId>org.slf4j</groupId>
280283
<artifactId>slf4j-api</artifactId>
284+
<scope>provided</scope>
281285
</dependency>
282286
<!-- debug deps -->
283287
<!--
@@ -304,32 +308,44 @@
304308
-->
305309
<!-- debug deps END -->
306310

307-
<!-- Test -->
311+
<!-- test deps start -->
312+
<dependency>
313+
<groupId>org.junit.jupiter</groupId>
314+
<artifactId>junit-jupiter-api</artifactId>
315+
<version>${junit.version}</version>
316+
<scope>test</scope>
317+
</dependency>
308318
<dependency>
309319
<groupId>org.junit.jupiter</groupId>
310320
<artifactId>junit-jupiter-engine</artifactId>
311-
<version>5.3.1</version>
321+
<version>${junit.version}</version>
322+
<scope>test</scope>
323+
</dependency>
324+
<dependency>
325+
<groupId>org.mockito</groupId>
326+
<artifactId>mockito-junit-jupiter</artifactId>
327+
<version>${mockito.version}</version>
312328
<scope>test</scope>
313329
</dependency>
314330
<dependency>
315331
<groupId>org.mockito</groupId>
316332
<artifactId>mockito-core</artifactId>
317-
<version>2.21.0</version>
333+
<version>${mockito.version}</version>
318334
<scope>test</scope>
319335
</dependency>
320336
<dependency>
321337
<groupId>org.mockito</groupId>
322-
<artifactId>mockito-junit-jupiter</artifactId>
323-
<version>2.23.0</version>
338+
<artifactId>mockito-inline</artifactId>
339+
<version>${mockito.version}</version>
324340
<scope>test</scope>
325341
</dependency>
326-
<!-- static method mocking -->
327342
<dependency>
328-
<groupId>org.jmockit</groupId>
329-
<artifactId>jmockit</artifactId>
330-
<version>${jmockit.version}</version>
343+
<groupId>ch.qos.logback</groupId>
344+
<artifactId>logback-classic</artifactId>
345+
<version>1.2.10</version>
331346
<scope>test</scope>
332347
</dependency>
348+
<!-- test deps stop -->
333349
</dependencies>
334350

335351
<profiles>
@@ -361,6 +377,31 @@
361377
</dependency>
362378
</dependencies>
363379
</profile>
380+
<profile>
381+
<id>coverage</id>
382+
<build>
383+
<plugins>
384+
<plugin>
385+
<groupId>org.jacoco</groupId>
386+
<artifactId>jacoco-maven-plugin</artifactId>
387+
<executions>
388+
<execution>
389+
<id>prepare-agent</id>
390+
<goals>
391+
<goal>prepare-agent</goal>
392+
</goals>
393+
</execution>
394+
<execution>
395+
<id>report</id>
396+
<goals>
397+
<goal>report</goal>
398+
</goals>
399+
</execution>
400+
</executions>
401+
</plugin>
402+
</plugins>
403+
</build>
404+
</profile>
364405
</profiles>
365406

366407
<organization>
@@ -442,6 +483,13 @@
442483
<name>Marcel Fadtke</name>
443484
<url>https://github.com/MarcelFadtke</url>
444485
</developer>
486+
<developer>
487+
<id>milan</id>
488+
<name>Milan Kuljovsky</name>
489+
<email>milan.kuljovsky@o2.sk</email>
490+
<organization>O2</organization>
491+
<organizationUrl>https://www.o2.sk</organizationUrl>
492+
</developer>
445493
<developer>
446494
<id>ntrp</id>
447495
<name>Ivan Greguric Ortolan</name>
@@ -467,12 +515,7 @@
467515
<organizationUrl>https://ronky.net</organizationUrl>
468516
</developer>
469517
<developer>
470-
<name>Milan Kuljovsky</name>
471-
<email>milan.kuljovsky@o2.sk</email>
472-
<organization>O2</organization>
473-
<organizationUrl>https://www.o2.sk</organizationUrl>
474-
</developer>
475-
<developer>
518+
<id>silvio</id>
476519
<name>Silvio Meier</name>
477520
<email>silvio.meier@empa.ch</email>
478521
<organization>Empa</organization>
@@ -485,7 +528,7 @@
485528
<developerConnection>scm:git:git@github.com:ableneo/liferay-db-setup-core.git</developerConnection>
486529
<url>https://github.com/ableneo/liferay-db-setup-core</url>
487530
<tag>7.3.602</tag>
488-
</scm>
531+
</scm>
489532

490533
<licenses>
491534
<license>

src/main/java/com/ableneo/liferay/portal/setup/LiferaySetup.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import com.liferay.portal.kernel.service.CompanyLocalServiceUtil;
2727
import com.liferay.portal.kernel.service.GroupLocalServiceUtil;
2828
import com.liferay.portal.kernel.util.LocaleThreadLocal;
29-
import com.liferay.portal.kernel.util.PortalUtil;
3029
import java.io.File;
3130
import java.io.FileNotFoundException;
3231
import java.io.InputStream;
@@ -153,11 +152,7 @@ public static boolean setup(final Setup setup, Bundle callerBundle) {
153152
private static void setupGroup(Setup setup, String runAsUserEmail, long companyId, String groupName)
154153
throws PortalException {
155154
Group group = GroupLocalServiceUtil.getGroup(companyId, groupName);
156-
SetupConfigurationThreadLocal.configureThreadLocalContent(
157-
runAsUserEmail,
158-
PortalUtil.getDefaultCompanyId(),
159-
group
160-
);
155+
SetupConfigurationThreadLocal.setRunInGroupId(group.getGroupId());
161156
setupPortalGroup(setup);
162157
}
163158

0 commit comments

Comments
 (0)