mirror of
https://github.com/OtusTeam/Spring.git
synced 2026-06-20 11:14:34 +00:00
examples added
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.6.1</version>
|
||||
<version>2.7.0</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
<java.version>11</java.version>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<lombok.version>1.18.22</lombok.version>
|
||||
<spring.version>5.3.13</spring.version>
|
||||
<lombok.version>1.18.24</lombok.version>
|
||||
<spring.version>5.3.20</spring.version>
|
||||
<junit.jupiter.version>5.8.2</junit.jupiter.version>
|
||||
<mockito.version>4.1.0</mockito.version>
|
||||
<assertj.version>3.21.0</assertj.version>
|
||||
<mockito.version>4.6.1</mockito.version>
|
||||
<assertj.version>3.22.0</assertj.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.otus.testing.example.services.ClosedConsoleIOService;
|
||||
import ru.otus.testing.example.services.IOService;
|
||||
import ru.otus.testing.example.services.OpenedConsoleIOService;
|
||||
import ru.otus.testing.example.services.OpenedStreamsIOService;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
@@ -16,7 +16,7 @@ public class TestingExampleSpringApplication {
|
||||
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(TestingExampleSpringApplication.class);
|
||||
|
||||
IOService closedConsoleIOService = context.getBean(ClosedConsoleIOService.class);
|
||||
IOService openedConsoleIOService = context.getBean(OpenedConsoleIOService.class);
|
||||
IOService openedConsoleIOService = context.getBean(OpenedStreamsIOService.class);
|
||||
|
||||
closedConsoleIOService.out("Hello World");
|
||||
openedConsoleIOService.out("Hello World 2");
|
||||
|
||||
+2
-2
@@ -8,12 +8,12 @@ import java.io.PrintStream;
|
||||
import java.util.Scanner;
|
||||
|
||||
@Service
|
||||
public class OpenedConsoleIOService implements IOService {
|
||||
public class OpenedStreamsIOService implements IOService {
|
||||
private final PrintStream out;
|
||||
private final Scanner sc;
|
||||
|
||||
|
||||
public OpenedConsoleIOService(@Value("#{ T(java.lang.System).in}") InputStream in,
|
||||
public OpenedStreamsIOService(@Value("#{ T(java.lang.System).in}") InputStream in,
|
||||
@Value("#{ T(java.lang.System).out}") PrintStream out) {
|
||||
this.out = out;
|
||||
this.sc = new Scanner(in);
|
||||
+1
-1
@@ -27,7 +27,7 @@ class OpenedIOServiceTest {
|
||||
System.out.println(Thread.currentThread().getName());
|
||||
|
||||
bos = new ByteArrayOutputStream();
|
||||
ioService = new OpenedConsoleIOService(System.in, new PrintStream(bos));
|
||||
ioService = new OpenedStreamsIOService(System.in, new PrintStream(bos));
|
||||
}
|
||||
|
||||
@DisplayName("должно печатать \"" + TEXT_TO_PRINT1 + "\"")
|
||||
|
||||
Reference in New Issue
Block a user