1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package net.sf.bluecove.se;
26
27 import java.io.IOException;
28
29 import org.bluecove.tester.log.Logger;
30
31 import net.sf.bluecove.Configuration;
32 import net.sf.bluecove.Switcher;
33
34
35
36
37 public class Console {
38
39 public static void main(String[] args) {
40 JavaSECommon.initOnce();
41 Configuration.storage = new FileStorage();
42 help();
43
44 while (true) {
45 try {
46 String cmd = readCommand();
47 if (cmd == null) {
48 quit();
49 return;
50 }
51 if (cmd.length() == 0) {
52 help();
53 continue;
54 }
55 cmd = cmd.toUpperCase();
56 char user_input = cmd.charAt(0);
57 switch (user_input) {
58 case 'Q':
59 quit();
60 break;
61 case '\n':
62 case '?':
63 case 'H':
64 help();
65 break;
66 case '4':
67 UIHelper.printFailureLog();
68 break;
69 case '*':
70 Switcher.startDiscovery();
71 break;
72 case '7':
73 Switcher.startServicesSearch();
74 break;
75 case '2':
76 Switcher.startClient();
77 break;
78 case '3':
79 Switcher.clientShutdown();
80 break;
81 case '5':
82 Switcher.startServer();
83 break;
84 case '6':
85 Switcher.serverShutdown();
86 break;
87 case 'D':
88 boolean dbg = BlueCoveSpecific.changeDebug();
89 if (dbg) {
90 System.out.println("BlueCove Debug ON");
91 } else {
92 System.out.println("BlueCove Debug OFF");
93 }
94 break;
95 case 'T':
96 Switcher.startTCKAgent();
97 break;
98 }
99 } catch (IOException e) {
100 return;
101 }
102 }
103 }
104
105 private static String readCommand() throws IOException {
106 int b = System.in.read();
107 if (b == -1) {
108 return null;
109 }
110 return new String("" + (char) b);
111 }
112
113 private static void help() {
114 System.out.println("BlueCove tester Console application (keyboard codes the same as in MIDP application)");
115 System.out.println("\t2 - Start Client");
116 System.out.println("\t3 - Stop Client");
117 System.out.println("\t5 - Start Server");
118 System.out.println("\t6 - Stop Server");
119 System.out.println("\t* - Run Discovery");
120 System.out.println("\t7 - Services Search");
121 System.out.println("\td - toggle BlueCove Debug");
122 System.out.println("\tT - Start TCK Agent");
123 System.out.println("\tq - Quit");
124 System.out.flush();
125 }
126
127 private static void quit() {
128 Logger.debug("quit");
129 Switcher.clientShutdown();
130 Switcher.serverShutdownOnExit();
131 System.exit(0);
132 }
133 }