EN · DE · RU · FR · ES

#342: ProjectForgeApplicationTest.java

projectforge-application/src/test/java/org/projectforge/start/ProjectForgeApplicationTest.java Typ: Java · Rolle: Test · Quelle: projectforge-application/src/test/java/org/projectforge/start/ProjectForgeApplicationTest.java 55 Zeilen · 26 Code · 22 Kommentare · 7 leer
Unit-/Integrationstest für ProjectForgeApplication. Validiert die Korrektheit des entsprechenden Produktionsklassenverhaltens.

Codestruktur

Paket: org.projectforge.start

Klassen: ProjectForgeApplicationTest

Methoden (1): checkArray

Importe: 2 Pakete

Quellcode (gekürzt)

package org.projectforge.start;


import org.junit.jupiter.api.Test;

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

public class ProjectForgeApplicationTest {
  static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(ProjectForgeApplicationTest.class);

  @Test
  void addDefaultAdditionalLocation() {
    String loc = ProjectForgeApplication.getAddtionalLocationArg(null);
    if (ProjectForgeApplication.addDefaultAdditionalLocation(null, null) == null) {
      log.warn("Found application{-default}.properties in current working directory (you should move it to ~/ProjectForge/projectforge.properties). Can't process with this text (OK).");
      return;
    }
    checkArray(new String[]{loc}, null);
    checkArray(new String[]{loc}, new String[]{});
    checkArray(new String[]{"spring.datasource.driver-class-name=org.postgresql.Driver", loc}, new String[]{"spring.datasource.driver-class-name=org.postgresql.Driver"});
    checkArray(new String[]{"--spring.config.additional-location=file:/opt/projectforge/test.properties"}, new String[]{"--spring.config.additional-location=file:/opt/projectforge/test.properties"});
    checkArray(new String[]{"hurzel", "--spring.config.additional-location=file:/opt/projectforge/test.properties"}, new String[]{"hurzel", "--spring.config.additional-location=file:/opt/projectforge/test.properties"});
  }

  private void checkArray(String[] expected, String[] array) {
    String[] args = ProjectForgeApplication.addDefaultAdditionalLocation(null, array);
    assertEquals(expected.length, args.length);
    for (int i = 0; i < expected.length; i++) {
      assertEquals(expected[i], args[i]);
    }
  }
}

Git-Verlauf

868d6abb7 2025 -> 2026
63081666f Quellcode-Dateiköpfe: 2024->2025.
b6092df09 Copyright 2023 -> 2024
ab45d51fa Copyright 2001-2022 -> 2001-2023.
5f7ef41b8 Copyright 2021 -> 2022