test/testlibrary_tests/OutputAnalyzerTest.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 187,193 **** --- 187,212 ---- String result = output.firstMatch(aa_grouped_aa, 1); if (!aa.equals(result)) { throw new Exception("firstMatch(String, int) failed to match. Expected: " + aa + " got: " + result); } } + + { + output = new OutputAnalyzer(stdout); + String actual = output.getStdout(); + if (!stdout.equals(actual)) { + throw new RuntimeException(String.format( + "The expected stdout '%s' doesn't equal to '%s'", + stdout, actual)); + } + if (!output.getStderr().isEmpty()) { + throw new RuntimeException(String.format( + "The expected stderr should be empty, '%s'", actual)); + } + if (!stdout.equals(output.getOutput())) { + throw new RuntimeException(String.format( + "The expected output '%s' doesn't equal to '%s'", + stdout, actual)); + } + } } }