Search in sources :

Example 1 with LogCollector

use of ch.ivyteam.ivy.maven.log.LogCollector in project project-build-plugin by axonivy.

the class TestFileLogForwarder method fileToMavenLog.

@Test
public void fileToMavenLog() throws Exception {
    File fakeEngineLog = Files.createTempFile("myProject.iar", ".deploymentLog").toFile();
    LogCollector mavenLog = new LogCollector();
    FileLogForwarder logForwarder = new FileLogForwarder(fakeEngineLog, mavenLog, new EngineLogLineHandler(mavenLog));
    try {
        logForwarder.activate();
        logAndWait(fakeEngineLog, "WARNING: starting");
        assertThat(mavenLog.getWarnings()).hasSize(1);
        LogEntry firstEntry = mavenLog.getWarnings().get(mavenLog.getWarnings().size() - 1);
        assertThat(firstEntry.toString()).isEqualTo(" ENGINE: starting");
        logAndWait(fakeEngineLog, "WARNING: finished");
        assertThat(mavenLog.getWarnings()).hasSize(2);
        LogEntry lastEntry = mavenLog.getWarnings().get(mavenLog.getWarnings().size() - 1);
        assertThat(lastEntry.toString()).isEqualTo(" ENGINE: finished");
        logAndWait(fakeEngineLog, "INFO: hi");
        assertThat(mavenLog.getDebug()).hasSize(1);
        LogEntry debugEntry = mavenLog.getDebug().get(mavenLog.getDebug().size() - 1);
        assertThat(debugEntry.toString()).isEqualTo(" ENGINE: hi");
    } finally {
        logForwarder.deactivate();
    }
    logAndWait(fakeEngineLog, "WARNING: illegal");
    assertThat(mavenLog.getWarnings()).hasSize(2);
}
Also used : LogCollector(ch.ivyteam.ivy.maven.log.LogCollector) File(java.io.File) LogEntry(ch.ivyteam.ivy.maven.log.LogCollector.LogEntry) Test(org.junit.Test)

Example 2 with LogCollector

use of ch.ivyteam.ivy.maven.log.LogCollector in project project-build-plugin by axonivy.

the class TestCompileProjectMojo method compilerSettingsFile_notFoundWarnings.

@Test
public void compilerSettingsFile_notFoundWarnings() throws Exception {
    LogCollector log = new LogCollector();
    CompileProjectMojo mojo = compile.getMojo();
    mojo.setLog(log);
    mojo.compilerWarnings = false;
    mojo.compilerSettings = new File("path/to/oblivion");
    mojo.execute();
    assertThat(log.getWarnings().toString()).doesNotContain("Could not locate compiler settings file");
    mojo.compilerWarnings = true;
    mojo.execute();
    assertThat(log.getWarnings().toString()).contains("Could not locate compiler settings file");
}
Also used : LogCollector(ch.ivyteam.ivy.maven.log.LogCollector) File(java.io.File) BaseEngineProjectMojoTest(ch.ivyteam.ivy.maven.BaseEngineProjectMojoTest) Test(org.junit.Test)

Example 3 with LogCollector

use of ch.ivyteam.ivy.maven.log.LogCollector in project project-build-plugin by axonivy.

the class TestFileLogForwarder method fileToMavenLog.

@Test
public void fileToMavenLog() throws Exception {
    File fakeEngineLog = Files.createTempFile("myProject.iar", ".deploymentLog").toFile();
    LogCollector mavenLog = new LogCollector();
    FileLogForwarder logForwarder = new FileLogForwarder(fakeEngineLog, mavenLog, new EngineLogLineHandler(mavenLog));
    try {
        logForwarder.activate();
        logAndWait(fakeEngineLog, "WARNING: starting");
        assertThat(mavenLog.getWarnings()).hasSize(1);
        LogEntry firstEntry = mavenLog.getWarnings().get(mavenLog.getWarnings().size() - 1);
        assertThat(firstEntry.toString()).isEqualTo(" ENGINE: starting");
        logAndWait(fakeEngineLog, "WARNING: finished");
        assertThat(mavenLog.getWarnings()).hasSize(2);
        LogEntry lastEntry = mavenLog.getWarnings().get(mavenLog.getWarnings().size() - 1);
        assertThat(lastEntry.toString()).isEqualTo(" ENGINE: finished");
        logAndWait(fakeEngineLog, "INFO: hi");
        assertThat(mavenLog.getDebug()).hasSize(1);
        LogEntry debugEntry = mavenLog.getDebug().get(mavenLog.getDebug().size() - 1);
        assertThat(debugEntry.toString()).isEqualTo(" ENGINE: hi");
    } finally {
        logForwarder.deactivate();
    }
    logAndWait(fakeEngineLog, "WARNING: illegal");
    assertThat(mavenLog.getWarnings()).hasSize(2);
}
Also used : LogCollector(ch.ivyteam.ivy.maven.log.LogCollector) File(java.io.File) LogEntry(ch.ivyteam.ivy.maven.log.LogCollector.LogEntry) Test(org.junit.Test)

Example 4 with LogCollector

use of ch.ivyteam.ivy.maven.log.LogCollector in project project-build-plugin by axonivy.

the class TestStartEngine method startEngine_targetDirectoryNotClean.

@Test
public void startEngine_targetDirectoryNotClean() throws Exception {
    LogCollector log = new LogCollector();
    StartTestEngineMojo mojo = rule.getMojo();
    mojo.setLog(log);
    Executor startedProcess = null;
    try {
        File engineDirTarget = mojo.getEngineDir(mojo.project);
        assertThat(engineDirTarget.toString()).contains("/target/ivyEngine");
        assertThat(engineDirTarget).doesNotExist();
        assertThat(log.getWarnings().toString()).doesNotContain("Skipping copy");
        startedProcess = mojo.startEngine();
        assertThat(engineDirTarget).exists();
        assertThat(log.getWarnings().toString()).doesNotContain("Skipping copy");
        kill(startedProcess);
        startedProcess = mojo.startEngine();
        assertThat(engineDirTarget).exists();
        assertThat(log.getWarnings().toString()).contains("Skipping copy");
    } finally {
        kill(startedProcess);
    }
}
Also used : LogCollector(ch.ivyteam.ivy.maven.log.LogCollector) Executor(org.apache.commons.exec.Executor) File(java.io.File) BaseEngineProjectMojoTest(ch.ivyteam.ivy.maven.BaseEngineProjectMojoTest) Test(org.junit.Test)

Example 5 with LogCollector

use of ch.ivyteam.ivy.maven.log.LogCollector in project project-build-plugin by axonivy.

the class TestEngineControl method startAndStop.

@Test
public void startAndStop() throws Exception {
    LogCollector log = new LogCollector();
    rule.getMojo().setLog(log);
    EngineControl controller = rule.getMojo().createEngineController();
    assertThat(controller.state()).isEqualTo(EngineState.STOPPED);
    controller.start();
    assertThat(controller.state()).isEqualTo(EngineState.RUNNING);
    controller.stop();
    assertThat(controller.state()).isEqualTo(EngineState.STOPPED);
    assertThat(log.getErrors()).isEmpty();
}
Also used : LogCollector(ch.ivyteam.ivy.maven.log.LogCollector) BaseEngineProjectMojoTest(ch.ivyteam.ivy.maven.BaseEngineProjectMojoTest) Test(org.junit.Test)

Aggregations

LogCollector (ch.ivyteam.ivy.maven.log.LogCollector)6 Test (org.junit.Test)6 BaseEngineProjectMojoTest (ch.ivyteam.ivy.maven.BaseEngineProjectMojoTest)4 File (java.io.File)4 LogEntry (ch.ivyteam.ivy.maven.log.LogCollector.LogEntry)2 EngineControl (ch.ivyteam.ivy.maven.engine.EngineControl)1 Executor (org.apache.commons.exec.Executor)1