-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
140 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
server: | ||
port: 1010 | ||
port: 8080 | ||
ip: "127.0.0.1" | ||
env: dev | ||
test: only in yaml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
id = "condation" | ||
hostname = [ "condation.com", "localhost" ] | ||
baseurl = "https://condation.com" | ||
|
||
[template] | ||
engine = "pebble" | ||
|
||
[index] | ||
persistent = true | ||
|
||
[modules] | ||
active = [ "pebble-module", "seo-module" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
cms-core/src/test/java/com/condation/cms/core/configuration/SiteConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package com.condation.cms.core.configuration; | ||
|
||
/*- | ||
* #%L | ||
* tests | ||
* %% | ||
* Copyright (C) 2023 - 2024 CondationCMS | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/gpl-3.0.html>. | ||
* #L% | ||
*/ | ||
|
||
import com.condation.cms.core.configuration.configs.SimpleConfiguration; | ||
import com.condation.cms.core.configuration.source.TomlConfigSource; | ||
import com.condation.cms.core.configuration.source.YamlConfigSource; | ||
import com.condation.cms.api.SiteProperties; | ||
import com.condation.cms.api.eventbus.EventBus; | ||
import com.condation.cms.api.scheduler.CronJobContext; | ||
import com.condation.cms.api.scheduler.CronJobScheduler; | ||
import com.condation.cms.api.utils.FileUtils; | ||
import com.condation.cms.core.configuration.reload.CronReload; | ||
import com.condation.cms.api.eventbus.events.ConfigurationReloadEvent; | ||
import com.condation.cms.core.configuration.properties.ExtendedSiteProperties; | ||
import com.condation.cms.core.scheduler.SingleCronJobScheduler; | ||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.time.Duration; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.assertj.core.api.Assertions; | ||
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 org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.quartz.Scheduler; | ||
import org.quartz.SchedulerException; | ||
import org.quartz.impl.StdSchedulerFactory; | ||
|
||
/** | ||
* | ||
* @author t.marx | ||
*/ | ||
@ExtendWith(MockitoExtension.class) | ||
public class SiteConfigurationTest { | ||
|
||
SimpleConfiguration configuration; | ||
|
||
Scheduler scheduler; | ||
CronJobScheduler cronScheduler; | ||
|
||
@Mock | ||
SiteProperties siteProperties; | ||
|
||
@Mock | ||
EventBus eventBus; | ||
|
||
private ExtendedSiteProperties extSiteProperties; | ||
|
||
@BeforeEach | ||
public void setup() throws IOException, SchedulerException { | ||
scheduler = StdSchedulerFactory.getDefaultScheduler(); | ||
scheduler.start(); | ||
cronScheduler = new SingleCronJobScheduler(scheduler, new CronJobContext(), siteProperties); | ||
|
||
configuration = SimpleConfiguration.builder(eventBus) | ||
.id("test-config") | ||
.reloadStrategy(new CronReload("0/10 * * * * ?", cronScheduler)) | ||
.addSource(YamlConfigSource.build(Path.of("configs/site.yaml"))) | ||
.addSource(TomlConfigSource.build(Path.of("configs/site.toml"))) | ||
.build(); | ||
|
||
extSiteProperties = new ExtendedSiteProperties(configuration); | ||
} | ||
|
||
@AfterEach | ||
public void shutdown () throws SchedulerException { | ||
scheduler.clear(); | ||
scheduler.shutdown(); | ||
} | ||
|
||
@Test | ||
public void test_hostname() { | ||
var hostnames = extSiteProperties.hostnames(); | ||
|
||
Assertions.assertThat(hostnames).contains("localhost", "condation.com"); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
id = "demo-site" | ||
hostname = [ "localhost" ] | ||
hostname = [ "localhost", "localhost2" ] | ||
baseurl = "http://localhost:1010" | ||
language = "en" | ||
theme = "demo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters