本文整理汇总了Java中com.sandwich.koan.cmdline.CommandLineArgumentBuilder类的典型用法代码示例。如果您正苦于以下问题:Java CommandLineArgumentBuilder类的具体用法?Java CommandLineArgumentBuilder怎么用?Java CommandLineArgumentBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CommandLineArgumentBuilder类属于com.sandwich.koan.cmdline包,在下文中一共展示了CommandLineArgumentBuilder类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testWarningFromPlacingExpecationOnWrongSide
import com.sandwich.koan.cmdline.CommandLineArgumentBuilder; //导入依赖的package包/类
@Test
public void testWarningFromPlacingExpecationOnWrongSide() throws Throwable {
final String[] message = new String[1];
stubAllKoans(Arrays.asList(new WrongExpectationOrderKoan()));
Logger.getLogger(CommandLineArgumentRunner.class.getSimpleName()).addHandler(
new Handler() {
@Override
public void close() throws SecurityException {
}
@Override
public void flush() {
}
@Override
public void publish(LogRecord arg0) {
message[0] = arg0.getMessage();
}
});
new CommandLineArgumentRunner(new CommandLineArgumentBuilder()).run();
assertEquals(
new StringBuilder(
WrongExpectationOrderKoan.class.getSimpleName())
.append(".expectationOnLeft ")
.append(EXPECTATION_LEFT_ARG).toString(), message[0]);
}
示例2: testWarningFromPlacingExpectationOnWrongSide
import com.sandwich.koan.cmdline.CommandLineArgumentBuilder; //导入依赖的package包/类
@Test
public void testWarningFromPlacingExpectationOnWrongSide() throws Throwable {
final String[] message = new String[1];
stubAllKoans(Arrays.asList(new WrongExpectationOrderKoan()));
Logger.getLogger(CommandLineArgumentRunner.class.getSimpleName()).addHandler(
new Handler() {
@Override
public void close() throws SecurityException {
}
@Override
public void flush() {
}
@Override
public void publish(LogRecord arg0) {
message[0] = arg0.getMessage();
}
});
new CommandLineArgumentRunner(new CommandLineArgumentBuilder()).run();
assertEquals(
new StringBuilder(
WrongExpectationOrderKoan.class.getSimpleName())
.append(".expectationOnLeft ")
.append(EXPECTATION_LEFT_ARG).toString(), message[0]);
}
示例3: hintPresentation
import com.sandwich.koan.cmdline.CommandLineArgumentBuilder; //导入依赖的package包/类
@Test
public void hintPresentation() throws Throwable {
stubAllKoans(Arrays.asList(new OneFailingKoanDifferentName()));
new CommandLineArgumentRunner(new CommandLineArgumentBuilder()).run();
assertSystemOutContains(new StringBuilder(
INVESTIGATE_IN_THE).append(
" ").append(
OneFailingKoanDifferentName.class.getSimpleName()).append(
" class's ").append(
OneFailingKoanDifferentName.class.getDeclaredMethod("koanMethod").getName()).append(
" method.").toString());
assertSystemOutContains("Line 11 may offer a clue as to how you may progress, now make haste!");
}
示例4: testNecessityOfAddingRunKoansCommandLineArgument_doesntIfClassArgIsntPresent
import com.sandwich.koan.cmdline.CommandLineArgumentBuilder; //导入依赖的package包/类
@Test
public void testNecessityOfAddingRunKoansCommandLineArgument_doesntIfClassArgIsntPresent(){
List<ArgumentType> types = new ArrayList<ArgumentType>(Arrays.asList(ArgumentType.values()));
assertTrue(types.remove(ArgumentType.CLASS_ARG));
assertTrue(types.remove(ArgumentType.DEBUG));
assertTrue(types.remove(ArgumentType.RUN_KOANS));
for(ArgumentType type : types){
Map<ArgumentType, CommandLineArgument> args = new CommandLineArgumentBuilder(type.args().iterator().next());
assertArgsContains(false, args, ArgumentType.RUN_KOANS);
assertArgsContains(true, args, type);
}
}
示例5: hintPresentation
import com.sandwich.koan.cmdline.CommandLineArgumentBuilder; //导入依赖的package包/类
@Test
public void hintPresentation() throws Throwable {
stubAllKoans(Arrays.asList(new OneFailingKoanDifferentName()));
new CommandLineArgumentRunner(new CommandLineArgumentBuilder()).run();
assertSystemOutContains(new StringBuilder(
Strings.getMessage("investigate")).append(
": ").append(
OneFailingKoanDifferentName.class.getSimpleName()).append(
" class's ").append(
OneFailingKoanDifferentName.class.getDeclaredMethod("koanMethod").getName()).append(
" method.").toString());
assertSystemOutContains("Line 11 may offer a clue as to how you may progress, now make haste!");
}
示例6: main
import com.sandwich.koan.cmdline.CommandLineArgumentBuilder; //导入依赖的package包/类
public static void main(final String... args) throws Throwable {
Map<ArgumentType, CommandLineArgument> argsMap = new CommandLineArgumentBuilder(args);
if(argsMap.containsKey(ArgumentType.RUN_KOANS)){
new Thread(new Runnable(){
public void run() {
do{
try {
char c = (char)System.in.read();
if(Character.toUpperCase(c) ==
Character.toUpperCase(ApplicationSettings.getExitChar())){
FileMonitorFactory.closeAll();
System.exit(0);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}while(true);
}
}).start();
FileMonitor monitor = FileMonitorFactory.getInstance(
new File(DirectoryManager.getProdMainDir()),
new File(DirectoryManager.getDataFile()));
if(ApplicationUtils.isFirstTimeAppHasBeenRun()){
monitor.writeChanges();
}
monitor.addFileSavedListener(new KoanFileCompileAndRunListener(argsMap));
}
new CommandLineArgumentRunner(argsMap).run();
if(ApplicationSettings.isDebug()){
StringBuilder argsBuilder = new StringBuilder();
int argNumber = 0;
for(String arg : args){
argsBuilder.append("Argument number "+String.valueOf(++argNumber)+": '"+arg+"'");
}
ApplicationUtils.getPresenter().displayMessage(argsBuilder.toString());
}
}
示例7: testNecessityOfAddingRunKoansCommandLineArgument_addsIfNoArgsPresent
import com.sandwich.koan.cmdline.CommandLineArgumentBuilder; //导入依赖的package包/类
@Test
public void testNecessityOfAddingRunKoansCommandLineArgument_addsIfNoArgsPresent(){ //default target
Map<ArgumentType, CommandLineArgument> args = new CommandLineArgumentBuilder();
assertArgsContains(true, args, ArgumentType.RUN_KOANS);
}
示例8: testNecessityOfAddingRunKoansCommandLineArgument_ifClassArgIsPresent
import com.sandwich.koan.cmdline.CommandLineArgumentBuilder; //导入依赖的package包/类
@Test
public void testNecessityOfAddingRunKoansCommandLineArgument_ifClassArgIsPresent(){
Map<ArgumentType, CommandLineArgument> args = new CommandLineArgumentBuilder(Object.class.getName());
assertArgsContains(true, args, ArgumentType.RUN_KOANS, ArgumentType.CLASS_ARG);
}
示例9: main
import com.sandwich.koan.cmdline.CommandLineArgumentBuilder; //导入依赖的package包/类
public static void main(final String... args) throws Throwable {
Map<ArgumentType, CommandLineArgument> argsMap = new CommandLineArgumentBuilder(
args);
if (argsMap.containsKey(ArgumentType.RUN_KOANS)) {
if (ApplicationSettings.isInteractive()) {
new Thread(new Runnable() {
public void run() {
do {
try {
char c = (char) System.in.read();
char exitChar = ApplicationSettings.getExitChar();
if (Character.toUpperCase(c) == Character.toUpperCase(exitChar)) {
exit(0);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
} while (true);
}
}).start();
FileMonitor monitor = FileMonitorFactory.getInstance(new File(
DirectoryManager.getProdMainDir()), new File(
DirectoryManager.getDataFile()));
if (ApplicationUtils.isFirstTimeAppHasBeenRun()) {
monitor.writeChanges();
}
monitor.addFileSavedListener(new KoanFileCompileAndRunListener(argsMap));
}
}
new CommandLineArgumentRunner(argsMap).run();
if (ApplicationSettings.isDebug()) {
StringBuilder argsBuilder = new StringBuilder();
int argNumber = 0;
for (String arg : args) {
argsBuilder.append("Argument number "
+ String.valueOf(++argNumber) + ": '" + arg + "'");
}
ApplicationUtils.getPresenter().displayMessage(
argsBuilder.toString());
}
}