5 changed files with 12 additions and 110 deletions
@ -1,42 +0,0 @@
@@ -1,42 +0,0 @@
|
||||
/* |
||||
* Copyright 2012-2025 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.boot.buildpack.platform.docker; |
||||
|
||||
import java.io.PrintStream; |
||||
|
||||
import org.springframework.util.Assert; |
||||
|
||||
/** |
||||
* {@link DockerLog} implementation that prints output to a {@link PrintStream}. |
||||
* |
||||
* @author Dmytro Nosan |
||||
*/ |
||||
class PrintStreamDockerLog implements DockerLog { |
||||
|
||||
private final PrintStream stream; |
||||
|
||||
PrintStreamDockerLog(PrintStream stream) { |
||||
Assert.notNull(stream, "'stream' must not be null"); |
||||
this.stream = stream; |
||||
} |
||||
|
||||
@Override |
||||
public void log(String message) { |
||||
this.stream.println(message); |
||||
} |
||||
|
||||
} |
||||
@ -1,55 +0,0 @@
@@ -1,55 +0,0 @@
|
||||
/* |
||||
* Copyright 2012-2025 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.boot.buildpack.platform.docker; |
||||
|
||||
import java.io.ByteArrayOutputStream; |
||||
import java.io.PrintStream; |
||||
|
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
||||
/** |
||||
* Tests for {@link PrintStreamDockerLog}. |
||||
* |
||||
* @author Dmytro Nosan |
||||
*/ |
||||
class PrintStreamDockerLogTests { |
||||
|
||||
@Test |
||||
void printsExpectedOutput() { |
||||
TestPrintStream stream = new TestPrintStream(); |
||||
PrintStreamDockerLog logger = new PrintStreamDockerLog(stream); |
||||
logger.log("Some message"); |
||||
logger.log("Some message1"); |
||||
assertThat(stream.toString()).isEqualTo(String.format("Some message%nSome message1%n")); |
||||
} |
||||
|
||||
static class TestPrintStream extends PrintStream { |
||||
|
||||
TestPrintStream() { |
||||
super(new ByteArrayOutputStream()); |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return this.out.toString(); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue