package test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Scanner;
@Component
public class Main {
@Autowired
private StringValidator stringValidator;
@Autowired
private StringService stringService;
@Autowired
private ValidationService validationService;
public void main() {
scanKeyboardCreateLists();
stringValidator.validate();
final List<String> validatedList = stringValidator.getValidatedList();
for (String currentValid : validatedList) {
System.out.println(currentValid);
}
}
private void scanKeyboardCreateLists() {
//Let's presume the user interacts with the GUI, dynamically changing the object graph...
//Needless to say, this is past container …Run Code Online (Sandbox Code Playgroud) 关于Guice的问题.我还在学习它,但我能理解基础知识.
这个问题已经在网上问了几次,但从来没有一个具体的答案(没有我能找到).
说我的情况就像在图片上(类似的例子是在网上).

public class Dog {}
public class Walk implements Walkable {
private final Dog dog;
private final boolean leash;
@Inject
public Walk(Dog dog, @Assisted boolean leash) {
this.dog = dog;
this.leash = leash;
}
public void go() {
}
}
public interface Walkable {
void go();
}
public interface WalkFactory {
Walk create(boolean leash);
}
public class AssistedMain {
public static void main(String[] args) {
Injector i = Guice.createInjector(new AbstractModule() {
protected void configure() {
install(new FactoryModuleBuilder().
implement(Walkable.class, …Run Code Online (Sandbox Code Playgroud) 关于Ruby的第一个问题.我正在尝试在Reactor循环中测试EventMachine交互 - 我猜它可以被归类为"功能"测试.
假设我有两个类 - 服务器和客户端.我想测试双方 - 我需要确定他们的互动.
服务器:
require 'singleton'
class EchoServer < EM::Connection
include EM::Protocols::LineProtocol
def post_init
puts "-- someone connected to the echo server!"
end
def receive_data data
send_data ">>>you sent: #{data}"
close_connection if data =~ /quit/i
end
def unbind
puts "-- someone disconnected from the echo server!"
end
end
Run Code Online (Sandbox Code Playgroud)
客户:
class EchoClient < EM::Connection
include EM::Protocols::LineProtocol
def post_init
send_data "Hello"
end
def receive_data(data)
@message = data
p data
end
def unbind
puts "-- someone disconnected from …Run Code Online (Sandbox Code Playgroud)