奥马珠单抗国内哪有买的质量咋样,买过的网友冒个泡

跪求帮忙_java吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:594,108贴子:
跪求帮忙收藏
import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.event.AncestorL//2、定义类public class 计算器界面 extends JFrame implements ActionListener { //3、定义成员变量 private final String[] KEYS = { &7&, &8&, &9&, &÷&, &sqrt&, &4&, &5&, &6&, &×&, &%&, &1&, &2&, &3&, &-&, &1/x&, &0&, &+/-&, &.&, &+&, &=& };
private final String[] COMMAND = { &Backspace&, &CE&, &C& };
private JButton keys[] = new JButton[KEYS.length];
private JButton commands[] = new JButton[COMMAND.length]; private JTextField resultText = new JTextField();
private boolean firstDigit =
private double resultNum = 0.0;
private String operator = &=&;
private boolean operateValidFlag =
JPanel panel[]=new JPanel[4]; //4、定义构造函数
public 计算器界面(){
//构造函数
//super(&计算器&);
init(); //调用初始函数
setBackground(Color.LIGHT_GRAY);
setResizable(false);
setLocation(588, 250);
setSize(300,214);
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
//窗口不能直接关闭
setVisible(true);
addWindowListener( new WindowAdapter() {
public void windowClosing(WindowEvent e){
if (JOptionPane.showConfirmDialog(null,&要退出吗 &, &提示&,1)==0){
System.exit(0);
}}}); } //5、完成初始化函数
private void init() {
setLayout(null);
for (int i = 0; i & 3; i++) {
panel[i]=new JPanel();
add(panel[i]);//将面板加入到窗体
//以下设定3个面板的布局方式
panel[0].setLayout(new GridLayout(1,1,3,3));
panel[1].setLayout(new GridLayout(1,3,3,3));
panel[2].setLayout(new GridLayout(4,5,3,3));
resultText.setHorizontalAlignment(JTextField.RIGHT);
resultText.setAlignmentX(50);
resultText.setEditable(true);
resultText.setFont(new Font(&宋体&,Font.PLAIN,19));//设置字体
resultText.setBackground(Color.white);
panel[0].add(resultText);
for (int i = 0; i & KEYS. i++) {
//此循环为设置jbutton
keys[i] = new JButton(KEYS[i]);
panel[2].add(keys[i]);
if (i%5-3==0){ keys[i].setForeground(Color.red); }
else{keys[i].setForeground(Color.black);}
keys[i].setVisible(true);
keys[i].setFont(new Font(null,Font.PLAIN,17));//设置字体
keys[i].addAncestorListener(null);
//添加监听器
keys[i].setHorizontalAlignment(keys[i].CENTER); //文本居中
keys[i].setBackground(new Color(255,236,233));
//keys[4].setFont(new Font(null,Font.PLAIN,13));//设置字体
//keys[15].setForeground(Color.blue);
for (int i = 0; i & COMMAND. i++) {
commands[i] = new JButton(COMMAND[i]);
panel[1].add(commands[i]); // 将COMMAND[i]按钮加入到panel[1]
commands[i].setForeground(Color.red);
//添加监听器
commands[0].setFont(new Font(null,Font.PLAIN,12));//设置字体
//利用panel[0].setBounds设定面板的大小位置
panel[0].setBounds(2, 0, 300, 30);
panel[1].setBounds(2, 30, 290, 30);
panel[2].setBounds(2,62, 295, 120);
validate(); }
//6、完成public void actionPerformed(ActionEvent e)函数 public void actionPerformed(ActionEvent e) {
String label = e.getActionCommand();
if (label.equals(COMMAND[0])){ //用户按了&Backspace&键
handleBackspace();
} else if (label.equals(COMMAND[1])) { //用户按了&CE&键
resultText.setText(&0&);
} else if (label.equals(COMMAND[2])){ //用户按了&C&键
handleC();
} else if (label.equals(&sqrt&)) {
//平方根运算
resultNum = Math.sqrt(Double.valueOf(resultText.getText()).doubleValue());
resultText.setText(String.valueOf(resultNum));
} else if (label.equals(&%&)){
//百分号运算,除以100
resultNum = Double.valueOf(resultText.getText()).doubleValue() / 100;
resultText.setText(String.valueOf(resultNum));
} else if (label.equals(&+/-&)){
//正数负数运算
resultNum = Double.valueOf(resultText.getText()).doubleValue() * (-1);
resultText.setText(String.valueOf(resultNum));
} else if (label.equals(&1/x&)) {
//倒数运算
resultNum=Double.valueOf(resultText.getText()).doubleValue();
if (resultNum == 0.0){
//操作不合法
operateValidFlag =
resultText.setText(&零没有倒数&);
resultNum = 1 / resultN
resultText.setText(String.valueOf(resultNum));
} else if (&.&.indexOf(label) &= 0) { //用户按了数字键或者小数点键
handleNumber(label);
resultText.setText(label);
//用户按了运算符键
handleOperator(label);
// 7、完成各功能private void handleBackspace() {
// 处理Backspace键被按下的事件
String text = resultText.getText();
int i = text.length();
if (i & 0) {
//退格,将文本最后一个字符去掉
text = text.substring(0, i - 1);
if (text.length() == 0) {
resultText.setText(&0&);
firstDigit =
operator = &=&;
//显示新的文本
resultText.setText(text);
} } private void handleNumber(String key) { // 处理数字键被按下的事件
if (firstDigit) {
//输入的第一个数字
resultText.setText(key);
} else if ((key.equals(&.&)) && (resultText.getText().indexOf(&.&) & 0)){
resultText.setText(resultText.getText() + &.&);
} else if (!key.equals(&.&)) {
resultText.setText(resultText.getText() + key);
firstDigit = //以后输入的肯定不是第一个数字了
} private void handleC() {
//处理C键被按下的事件, 初始化计算器的各种值
resultText.setText(&0&);
firstDigit =
operator = &=&;
private void handleOperator(String key) { //处理运算符键被按下的事件
if (operator.equals(&÷&)) {
if (getNumberFromText() == 0.0){
//操作不合法
operateValidFlag =
resultText.setText(&除数不能为零&);
resultNum /= getNumberFromText();
} else if (operator.equals(&+&)){
//加法运算
resultNum += getNumberFromText();
} else if (operator.equals(&-&)){
//减法运算
resultNum -= getNumberFromText();
} else if (operator.equals(&×&)){
//乘法运算
resultNum *= getNumberFromText();
} else if (operator.equals(&=&)){
//赋值运算
resultNum = getNumberFromText();
if (operateValidFlag) {
double t2;
t1 = (long) resultN
t2 = resultNum - t1;
if (t2 == 0) {
resultText.setText(String.valueOf(t1));
resultText.setText(String.valueOf(resultNum));
operator =
//运算符等于用户按的按钮
firstDigit =
operateValidFlag =
} private double getNumberFromText() {
// 从结果文本框中获取数字
double result = 0;
result = Double.valueOf(resultText.getText()).doubleValue();
catch (NumberFormatException e){ }
public static void main (String [] args
计算器界面 a =new 计算器界面(); }}
上海java培训,选达内,美国上市教育机构,「java培训之父」Sun认证,先就业后付款!达内java培训,名师授课,0基础120天速成java工程师,0元试学!学习+认证+就业=薪前景!
要加tan功能怎么加上去
登录百度帐号推荐应用
为兴趣而生,贴吧更懂你。或Java Code Example junit.textui.ResultPrinter
Java Code Examples for junit.textui.ResultPrinter
The following are top voted examples for showing how to use
junit.textui.ResultPrinter. These examples are extracted from open source projects.
You can vote up the examples you like and your votes will be used in our system to product
more good examples.
+ Save this class to your library
public void testError() {
ByteArrayOutputStream output = new ByteArrayOutputStream();
TestRunner runner = new TestRunner(new TestResultPrinter(
new PrintStream(output)));
String expected = expected(new String[]{&.E&, &Time: 0&,
&Errors here&, &&, &FAILURES!!!&,
&Tests run: 1,
Failures: 0,
Errors: 1&, &&});
ResultPrinter printer = new TestResultPrinter(new PrintStream(output)) {
public void printErrors(TestResult result) {
getWriter().println(&Errors here&);
runner.setPrinter(printer);
TestSuite suite = new TestSuite();
suite.addTest(new TestCase() {
public void runTest() throws Exception {
throw new Exception();
runner.doRun(suite);
assertEquals(expected, output.toString());
public void testErrorAdapted() {
ByteArrayOutputStream output = new ByteArrayOutputStream();
TestRunner runner = new TestRunner(new TestResultPrinter(
new PrintStream(output)));
String expected = expected(new String[]{&.E&, &Time: 0&,
&Errors here&, &&, &FAILURES!!!&,
&Tests run: 1,
Failures: 0,
Errors: 1&, &&});
ResultPrinter printer = new TestResultPrinter(new PrintStream(output)) {
public void printErrors(TestResult result) {
getWriter().println(&Errors here&);
runner.setPrinter(printer);
runner.doRun(new JUnit4TestAdapter(ATest.class));
assertEquals(expected, output.toString());
public static void main(String[] args) {
junit.textui.TestRunner runner = new junit.textui.TestRunner();
runner.setPrinter(new ResultPrinter(System.out) {
public void startTest(Test test) {
getWriter().println(&About to run & + test);
super.startTest(test);
public void endTest(Test test) {
super.endTest(test);
System.gc();
System.gc();
System.gc();
Runtime.getRuntime().runFinalization();
getWriter().println(&Test ended: & + test);
getWriter().println();
runner.doRun(new TestSuite(VersionedOperationsOnlineTest.class));
* Overrides parent to explicitly print out failures. The ResultPrinter relies on the runner
* calling &print& at end of test run to do this.
public void testFailed(TestFailure status, TestIdentifier testId, String trace) {
ResultPrinter printer = (ResultPrinter)getJUnitListener();
printer.getWriter().format(&\nTest %s: %s \n stack: %s &, status, testId, trace);
* Overrides parent to explicitly print out test metrics.
public void testEnded(TestIdentifier testId, Map&String, String& metrics) {
super.testEnded(testId, metrics);
if (!metrics.isEmpty()) {
ResultPrinter printer = (ResultPrinter)getJUnitListener();
printer.getWriter().format(&\n%s metrics: %s\n&, testId, metrics);
public void testError() {
ByteArrayOutputStream output= new ByteArrayOutputStream();
TestRunner runner= new TestRunner(new TestResultPrinter(
new PrintStream(output)));
String expected= expected(new String[] { &.E&, &Time: 0&,
&Errors here&, &&, &FAILURES!!!&,
&Tests run: 1,
Failures: 0,
Errors: 1&, && });
ResultPrinter printer= new TestResultPrinter(new PrintStream(output)) {
public void printErrors(TestResult result) {
getWriter().println(&Errors here&);
runner.setPrinter(printer);
TestSuite suite= new TestSuite();
suite.addTest(new TestCase() {
public void runTest() throws Exception {
throw new Exception();
runner.doRun(suite);
assertEquals(expected, output.toString());
public void testErrorAdapted() {
ByteArrayOutputStream output= new ByteArrayOutputStream();
TestRunner runner= new TestRunner(new TestResultPrinter(
new PrintStream(output)));
String expected= expected(new String[] { &.E&, &Time: 0&,
&Errors here&, &&, &FAILURES!!!&,
&Tests run: 1,
Failures: 0,
Errors: 1&, && });
ResultPrinter printer= new TestResultPrinter(new PrintStream(output)) {
public void printErrors(TestResult result) {
getWriter().println(&Errors here&);
runner.setPrinter(printer);
runner.doRun(new JUnit4TestAdapter(ATest.class));
assertEquals(expected, output.toString());
public void testFailure() {
String expected= expected(new String[]{&.F&, &Time: 0&, &Failures here&, &&, &FAILURES!!!&, &Tests run: 1,
Failures: 1,
Errors: 0&, &&});
ResultPrinter printer= new TestResultPrinter(new PrintStream(output)) {
public void printFailures(TestResult result) {
getWriter().println(&Failures here&);
runner.setPrinter(printer);
TestSuite suite = new TestSuite();
suite.addTest(new TestCase() { public void runTest() {throw new AssertionFailedError();}});
runner.doRun(suite);
assertEquals(expected, output.toString());
public void testError() {
String expected= expected(new String[]{&.E&, &Time: 0&, &Errors here&, &&, &FAILURES!!!&, &Tests run: 1,
Failures: 0,
Errors: 1&, &&});
ResultPrinter printer= new TestResultPrinter(new PrintStream(output)) {
public void printErrors(TestResult result) {
getWriter().println(&Errors here&);
runner.setPrinter(printer);
TestSuite suite = new TestSuite();
suite.addTest(new TestCase() { public void runTest() throws Exception {throw new Exception();}});
runner.doRun(suite);
assertEquals(expected, output.toString());
Example 10
* @throws Exception
public void testFromRootPackage_JarFile() throws Exception {
Resources[] resourcesArray = ResourcesUtil.getResourcesTypes(&junit.textui&);
assertNotNull(resourcesArray);
assertEquals(1, resourcesArray.length);
Resources resources = resourcesArray[0];
assertTrue(resources instanceof JarFileResources);
assertTrue(resources.isExistClass(&TestRunner&));
assertFalse(resources.isExistClass(&DummyTest&));
final Set set = new HashSet();
resources.forEach(new ClassHandler() {
public void processClass(String packageName, String shortClassName) {
set.add(ClassUtil.concatName(packageName, shortClassName));
assertEquals(2, set.size());
assertTrue(set.contains(ResultPrinter.class.getName()));
assertTrue(set.contains(TestRunner.class.getName()));
assertFalse(set
.contains(junit.extensions.TestDecorator.class.getName()));
Example 11
public void testError() {
ByteArrayOutputStream output = new ByteArrayOutputStream();
TestRunner runner = new TestRunner(new TestResultPrinter(
new PrintStream(output)));
String expected = expected(new String[]{&.E&, &Time: 0&,
&Errors here&, &&, &FAILURES!!!&,
&Tests run: 1,
Failures: 0,
Errors: 1&, &&});
ResultPrinter printer = new TestResultPrinter(new PrintStream(output)) {
public void printErrors(TestResult result) {
getWriter().println(&Errors here&);
runner.setPrinter(printer);
TestSuite suite = new TestSuite();
suite.addTest(new TestCase() {
public void runTest() throws Exception {
throw new Exception();
runner.doRun(suite);
assertEquals(expected, output.toString());
Example 12
public void testErrorAdapted() {
ByteArrayOutputStream output = new ByteArrayOutputStream();
TestRunner runner = new TestRunner(new TestResultPrinter(
new PrintStream(output)));
String expected = expected(new String[]{&.E&, &Time: 0&,
&Errors here&, &&, &FAILURES!!!&,
&Tests run: 1,
Failures: 0,
Errors: 1&, &&});
ResultPrinter printer = new TestResultPrinter(new PrintStream(output)) {
public void printErrors(TestResult result) {
getWriter().println(&Errors here&);
runner.setPrinter(printer);
runner.doRun(new JUnit4TestAdapter(ATest.class));
assertEquals(expected, output.toString());
Example 13
public static void main(String[] args) {
junit.textui.TestRunner runner = new junit.textui.TestRunner();
runner.setPrinter(new ResultPrinter(System.out) {
public void startTest(Test test) {
getWriter().println(&About to run & + test);
super.startTest(test);
public void endTest(Test test) {
super.endTest(test);
System.gc();
System.gc();
System.gc();
Runtime.getRuntime().runFinalization();
getWriter().println(&Test ended: & + test);
getWriter().println();
runner.doRun(new TestSuite(VersionedOperationsOnlineTest.class));
Example 14
public static void main(String[] args) {
junit.textui.TestRunner runner = new junit.textui.TestRunner();
runner.setPrinter(new ResultPrinter(System.out) {
public void startTest(Test test) {
getWriter().println(&About to run & + test);
super.startTest(test);
public void endTest(Test test) {
super.endTest(test);
System.gc();
System.gc();
System.gc();
Runtime.getRuntime().runFinalization();
getWriter().println(&Test ended: & + test);
getWriter().println();
runner.doRun(new TestSuite(VersionedOperationsOnlineTest.class));
Example 15
public static void main(String[] args) {
junit.textui.TestRunner runner = new junit.textui.TestRunner();
runner.setPrinter(new ResultPrinter(System.out) {
public void startTest(Test test) {
getWriter().println(&About to run & + test);
super.startTest(test);
public void endTest(Test test) {
super.endTest(test);
System.gc();
System.gc();
System.gc();
Runtime.getRuntime().runFinalization();
getWriter().println(&Test ended: & + test);
getWriter().println();
runner.doRun(new TestSuite(VersionedOperationsOnlineTest.class));
Example 16
public void testError() {
ByteArrayOutputStream output= new ByteArrayOutputStream();
TestRunner runner= new TestRunner(new TestResultPrinter(
new PrintStream(output)));
String expected= expected(new String[] { &.E&, &Time: 0&,
&Errors here&, &&, &FAILURES!!!&,
&Tests run: 1,
Failures: 0,
Errors: 1&, && });
ResultPrinter printer= new TestResultPrinter(new PrintStream(output)) {
public void printErrors(TestResult result) {
getWriter().println(&Errors here&);
runner.setPrinter(printer);
TestSuite suite= new TestSuite();
suite.addTest(new TestCase() {
public void runTest() throws Exception {
throw new Exception();
runner.doRun(suite);
assertEquals(expected, output.toString());
Example 17
public void testErrorAdapted() {
ByteArrayOutputStream output= new ByteArrayOutputStream();
TestRunner runner= new TestRunner(new TestResultPrinter(
new PrintStream(output)));
String expected= expected(new String[] { &.E&, &Time: 0&,
&Errors here&, &&, &FAILURES!!!&,
&Tests run: 1,
Failures: 0,
Errors: 1&, && });
ResultPrinter printer= new TestResultPrinter(new PrintStream(output)) {
public void printErrors(TestResult result) {
getWriter().println(&Errors here&);
runner.setPrinter(printer);
runner.doRun(new JUnit4TestAdapter(ATest.class));
assertEquals(expected, output.toString());
Example 18
* @throws Exception
public void testFromRootPackage_JarFile() throws Exception {
Traverser[] traversers = TraversalUtil.getTraversers(&junit.textui&);
assertThat(traversers, is(notNullValue()));
assertThat(traversers.length, is(1));
Traverser traverser = traversers[0];
assertThat(traverser instanceof JarFileTraverser, is(true));
assertThat(traverser.isExistClass(&TestRunner&), is(true));
assertThat(traverser.isExistClass(&DummyTest&), is(not(true)));
final Set&String& set = new HashSet&String&();
traverser.forEach(new ClassHandler() {
public void processClass(String packageName, String shortClassName) {
set.add(ClassUtil.concatName(packageName, shortClassName));
assertThat(set.size(), is(2));
assertThat(set.contains(ResultPrinter.class.getName()), is(true));
assertThat(set.contains(TestRunner.class.getName()), is(true));
assertThat(
set.contains(junit.extensions.TestDecorator.class.getName()),
is(not(true)));
Example 19
protected TestResult start(String args[]) throws Exception {
String test_bundle =
List junit_args = new ArrayList() ;
boolean wait = // junit.textui.TestRunner option
TestContext context = TestContext.getInstance() ;
for (int i= 0; i & args. i++) {
if ( args[i].startsWith(&--&) ) {
if ( &--h&.equals(args[i]) ||
&--help&.equals(args[i])) {
System.exit(SUCCESS_EXIT);
if ( &--cc&.equals(args[i]) ||
&--containerclass&.equals(args[i])) {
context.setValue(TestContext.TEST_CONTAINER_CLASS,
args[++i]);
if ( &--pc&.equals(args[i]) ||
&--printerclass&.equals(args[i])) {
context.setValue(TestContext.RESULT_PRINTER_CLASS,
args[++i]);
if ( &--ta&.equals(args[i]) ||
&--testargs&.equals(args[i])) {
String arg = args[++i] ;
if ( new File(arg).exists() ) {
context.setValue(TestContext.TEST_ARGS_FILENAME,
System.out.println(arg+& file does not exist&) ;
System.exit(EXCEPTION_EXIT);
if ( &--tb&.equals(args[i]) ||
&--testbundle&.equals(args[i])) {
test_bundle = args[++i] ;
if ( !(new File(test_bundle).exists()) ){
System.out.println(test_bundle+
& file does not exist&) ;
System.exit(EXCEPTION_EXIT);
if ( &--rp&.equals(args[i]) ||
&--refimagepath&.equals(args[i])) {
context.setValue(TestContext.REF_IMAGE_PATH,
args[++i]);
junit_args.add(args[i]) ;
if ( &-wait&.equals(args[i]) )
catch ( ArrayIndexOutOfBoundsException bex ) {
System.exit(EXCEPTION_EXIT);
// the last junit argument is the &testcase-class& or
// &testcase-method& (supported only by gunit), we examine the
// last argument and if it is a &testcase-method&, create a
// test filter with the method name and pass the class to
// if test_bundle is present then the &testcase-class& or
// &testcase-method& is ignored.
if ( test_bundle == null && junit_args.size() & 0 ) {
String arg = (String)junit_args.get(junit_args.size()-1) ;
// check if the &arg& is a class
Class.forName(arg) ;
catch ( Exception ex ) {
// arg is probably &classname&.&methodname&
int index = arg.lastIndexOf('.') ;
if ( index & 0 ) {
String class_name = arg.substring(0,index);
String method_name = arg.substring(index+1) ;
context.setValue(TestContext.TEST_FILTER,
new SingleMethodTestFilter(class_name,
method_name)) ;
// replace the last argument with the class name
junit_args.set(junit_args.size()-1, class_name) ;
ResultPrinter printer = (ResultPrinter)
context.getObjectValue(TestContext.RESULT_PRINTER_CLASS);
if ( printer != null )
setPrinter(printer) ;
if ( test_bundle != null ) {
Test suite = TestFactory.createTest(test_bundle) ;
return super.doRun(suite, wait);
return super.start((String[])junit_args.toArray(new String[0]));
Example 20
* Runs the test suite against an
IBigdataFederation} or a
Journal}. The federation must already be up and running. An
* embedded
NanoSparqlServer} instance will be created for each test
* run. Each test will run against a distinct KB instance within a unique
* bigdata namespace on the same backing
IIndexManager}.
* When run for CI, this can be executed as:
* ... -Djava.security.policy=policy.all TestNanoSparqlServerWithProxyIndexManager triples /nas/bigdata/benchmark/config/bigdataStandalone.config
* @param args
* (testMode) (propertyFile|configFile)
where propertyFile is the configuration file for a
Journal}. &br/&
where configFile is the configuration file for an
IBigdataFederation}.&br/&
where &i&triples&/i& or &i&sids&/i& or &i&quads&/i& is the
database mode.&/br& where &i&tm&/i& indicates that truth
maintenance should be enabled (only valid with triples or
public static void main(final String[] args) throws Exception {
if (args.length & 2) {
System.err
.println(&(triples|sids|quads) (propertyFile|configFile) (tm)?&);
System.exit(1);
final TestMode testMode = TestMode.valueOf(args[0]);
if (testMode != TestMode.triples)
fail(&Unsupported test mode: & + testMode);
final File propertyFile = new File(args[1]);
if (!propertyFile.exists())
fail(&No such file: & + propertyFile);
// Setup test result.
final TestResult result = new TestResult();
// Setup listener, which will write the result on System.out
result.addListener(new ResultPrinter(System.out));
result.addListener(new TestListener() {
public void startTest(Test arg0) {
public void endTest(Test arg0) {
public void addFailure(Test arg0, AssertionFailedError arg1) {
log.error(arg0,arg1);
public void addError(Test arg0, Throwable arg1) {
log.error(arg0,arg1);
// Open Journal / Connect to the configured federation.
final IIndexManager indexManager = openIndexManager(propertyFile
.getAbsolutePath());
// Setup test suite
final Test test = TestNanoSparqlServerWithProxyIndexManager.suite(
indexManager, testMode);
// Run the test suite.
test.run(result);
} finally {
if (indexManager instanceof JiniFederation&?&) {
// disconnect
((JiniFederation&?&) indexManager).shutdownNow();
// destroy journal.
((Journal) indexManager).destroy();
final String msg = &nerrors=& + result.errorCount() + &, nfailures=&
+ result.failureCount() + &, nrun=& + result.runCount();
if (result.errorCount() & 0 || result.failureCount() & 0) {
// At least one test failed.
fail(msg);
// All green.
System.out.println(msg);
Example 21
* Connect to the NSS end point and run a test suite designed to verify the
* health of that instance.
* @param args
* @throws MalformedURLException
TODO Support HA health checks as well.
public static void main(final String[] args) throws MalformedURLException {
if (args.length & 1) {
System.err.println(&usage: &cmd& Request-URI&);
System.exit(1);
final String requestURI = args[0];
// Setup test result.
final TestResult result = new TestResult();
// Setup listener, which will write the result on System.out
result.addListener(new ResultPrinter(System.out));
result.addListener(new TestListener() {
public void startTest(Test arg0) {
public void endTest(Test arg0) {
public void addFailure(Test arg0, AssertionFailedError arg1) {
log.error(arg0, arg1);
public void addError(Test arg0, Throwable arg1) {
log.error(arg0, arg1);
// Setup test suite
final Test test = createTestSuite(null/* name */, requestURI);
System.out.println(&Running health check: Request-URI=&
+ requestURI);
// Run the test suite.
test.run(result);
} finally {
final String msg = &nerrors=& + result.errorCount() + &, nfailures=&
+ result.failureCount() + &, nrun=& + result.runCount()
+ & : Request-URI=& + requestURI;
System.out.println(msg);
if (result.errorCount() & 0 || result.failureCount() & 0) {
// At least one test failed.
System.exit(1);
// All green.
System.exit(0);

我要回帖

更多关于 什么人买奥马冰箱 的文章

 

随机推荐