@Configuration
public class MyApplicationContext {
@Bean
public DirectoryScanner scanner() {
return new WatchServiceDirectoryScanner("/tmp/myDir");
}
}
@Component
public class MyApplicationContext {
@Bean
public DirectoryScanner scanner() {
return new WatchServiceDirectoryScanner("/tmp/myDir");
}
}
@SpringBootApplication
public class HelloServerApplication {
public static void main(String[] args) {
SpringApplication.run(HelloServerApplication.class, args);
}
@Bean
public ServerService getServerService() {
return new ServerService();
}
}
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) // Run the server for testing.
public class mockTest {
@Autowired
// Should work now
}