Here are the examples of the java api class java.io.PrintStream taken from open source projects.
1. TestPruneColumn#setUp()
Project: pig
File: TestPruneColumn.java
File: TestPruneColumn.java
@Before public void setUp() throws Exception { Logger logger = Logger.getLogger(ColumnPruneVisitor.class); logger.removeAllAppenders(); logger.setLevel(Level.INFO); SimpleLayout layout = new SimpleLayout(); logFile = File.createTempFile("log", ""); FileAppender appender = new FileAppender(layout, logFile.toString(), false, false, 0); logger.addAppender(appender); pigServer = new PigServer(Util.getLocalTestMode()); tmpFile1 = File.createTempFile("prune", "txt"); PrintStream ps = new PrintStream(new FileOutputStream(tmpFile1)); ps.println("1\t2\t3"); ps.println("2\t5\t2"); ps.close(); tmpFile2 = File.createTempFile("prune", "txt"); ps = new PrintStream(new FileOutputStream(tmpFile2)); ps.println("1\t1"); ps.println("2\t2"); ps.close(); tmpFile3 = File.createTempFile("prune", "txt"); ps = new PrintStream(new FileOutputStream(tmpFile3)); ps.println("1\t[key1#1,key2#2]"); ps.println("2\t[key1#2,key2#4]"); ps.close(); tmpFile4 = File.createTempFile("prune", "txt"); ps = new PrintStream(new FileOutputStream(tmpFile4)); ps.println("1\t2\t3"); ps.println("1\t2\t3"); ps.close(); tmpFile5 = File.createTempFile("prune", "txt"); ps = new PrintStream(new FileOutputStream(tmpFile5)); ps.println("1\t2\t3\t4"); ps.println("2\t3\t4\t5"); ps.close(); tmpFile6 = File.createTempFile("prune", "txt"); ps = new PrintStream(new FileOutputStream(tmpFile6)); ps.println("\t2\t3"); ps.println("2\t3\t4"); ps.close(); tmpFile7 = File.createTempFile("prune", "txt"); ps = new PrintStream(new FileOutputStream(tmpFile7)); ps.println("1\t1\t1"); ps.println("2\t2\t2"); ps.close(); tmpFile8 = File.createTempFile("prune", "txt"); ps = new PrintStream(new FileOutputStream(tmpFile8)); ps.println("1\t2\t3\t4"); ps.println("2\t5\t2\t3"); ps.close(); tmpFile9 = File.createTempFile("prune", "txt"); ps = new PrintStream(new FileOutputStream(tmpFile9)); ps.println("1\t[key1#1,key2#2]\t[key3#8,key4#9]"); ps.println("2\t[key1#2,key2#4]\t[key3#8,key4#9]"); ps.close(); tmpFile10 = File.createTempFile("prune", "txt"); ps = new PrintStream(new FileOutputStream(tmpFile10)); ps.println("1\t[1#1,2#1]\t2"); ps.close(); tmpFile11 = File.createTempFile("prune", "txt"); ps = new PrintStream(new FileOutputStream(tmpFile11)); ps.println("1\t2\t3"); ps.println("1\t3\t2"); ps.println("2\t5\t2"); ps.close(); tmpFile12 = File.createTempFile("prune", "txt"); ps = new PrintStream(new FileOutputStream(tmpFile12)); ps.println("[key1#1,key2#2,cond#1]"); ps.println("[key1#2,key2#3,cond#1]"); ps.close(); tmpFile13 = File.createTempFile("prune", "txt"); ps = new PrintStream(new FileOutputStream(tmpFile13)); ps.println("3\ti"); ps.println("3\ti"); ps.println("1\ti"); ps.println("2\ti"); ps.println("2\ti"); ps.println("3\ti"); ps.close(); }
2. Compiler#save()
Project: cocoon
File: Compiler.java
File: Compiler.java
/** * Save this <code>Charset</code> as a Java source file to the specified * <code>OutputStream</code>. */ public void save(OutputStream stream) throws IOException { PrintStream out = new PrintStream(new BufferedOutputStream(stream)); out.println("/*"); out.println(" * Copyright 1999-2004 The Apache Software Foundation."); out.println(" *"); out.println(" * Licensed under the Apache License, Version 2.0 (the \"License\");"); out.println(" * you may not use this file except in compliance with the License."); out.println(" * You may obtain a copy of the License at"); out.println(" *"); out.println(" * http://www.apache.org/licenses/LICENSE-2.0"); out.println(" *"); out.println(" * Unless required by applicable law or agreed to in writing, software"); out.println(" * distributed under the License is distributed on an \"AS IS\" BASIS,"); out.println(" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied."); out.println(" * See the License for the specific language governing permissions and"); out.println(" * limitations under the License."); out.println(" */"); out.println("/* Generated by " + this.getClass().getName() + " */"); out.println(); out.println("package org.apache.cocoon.components.serializers.encoding;"); out.println(); out.println("/**"); out.println(" * The <b>" + this.getName() + "</b> character set encoding representation."); out.println(" *"); out.println(" * @author Generated by <code>" + this.getClass().getName() + "</code>"); out.println(" */"); out.println("class " + this.clazz + " extends CompiledCharset {"); out.println(); out.println(" /** The name of this charset (<b>" + this.getName() + "</b>). */"); out.println(" public static final String CS_NAME = \"" + this.getName() + "\";"); out.println(); out.println(" /** The array of alias names of this charset. */"); out.println(" public static final String CS_ALIASES[] = {"); String aliases[] = this.getAliases(); for (int x = 0; x < aliases.length; x++) out.println(" \"" + aliases[x] + "\","); out.println(" };"); out.println(); out.println(" /** The array all characters encoded by this encoding. */"); out.print(" public static final byte CS_ENCODING[] = {"); for (int x = 0; x < this.encoding.length; x++) { if ((x & 0x0F) == 0) { out.println(); out.print(" "); } String value = Integer.toString(this.encoding[x]); value = " ".substring(value.length()) + value; out.print(value); if ((x + 1) != this.encoding.length) out.print(","); } out.println(); out.println(" };"); out.println(); out.println(" /**"); out.println(" * Create a new instance of the <b>" + this.getName() + "</b> caracter"); out.println(" * encoding as a <code>Charset</code>."); out.println(" */"); out.println(" public " + this.clazz + "() {"); out.println(" super(CS_NAME, CS_ALIASES, CS_ENCODING);"); out.println(" }"); out.println(); out.println(" /**"); out.println(" * Operation not supported."); out.println(" */"); out.println(" public boolean compile(char c) {"); out.println(" throw new UnsupportedOperationException();"); out.println(" }"); out.println(); out.println("}"); out.flush(); }
3. GenSort#usage()
Project: incubator-tez
File: GenSort.java
File: GenSort.java
private static void usage() { PrintStream out = System.out; out.println("usage: gensort [-a] [-c] [-bSTARTING_REC_NUM] NUM_RECS FILE_NAME"); out.println("-a Generate ascii records required for PennySort or JouleSort."); out.println(" These records are also an alternative input for the other"); out.println(" sort benchmarks. Without this flag, binary records will be"); out.println(" generated that contain the highest density of randomness in"); out.println(" the 10-byte key."); out.println("-c Calculate the sum of the crc32 checksums of each of the"); out.println(" generated records and send it to standard error."); out.println("-bN Set the beginning record generated to N. By default the"); out.println(" first record generated is record 0."); out.println("NUM_RECS The number of sequential records to generate."); out.println("FILE_NAME The name of the file to write the records to.\n"); out.println("Example 1 - to generate 1000000 ascii records starting at record 0 to"); out.println("the file named \"pennyinput\":"); out.println(" gensort -a 1000000 pennyinput\n"); out.println("Example 2 - to generate 1000 binary records beginning with record 2000"); out.println("to the file named \"partition2\":"); out.println(" gensort -b2000 1000 partition2"); System.exit(1); }
4. GenSort#usage()
Project: hadoop-mapreduce
File: GenSort.java
File: GenSort.java
private static void usage() { PrintStream out = System.out; out.println("usage: gensort [-a] [-c] [-bSTARTING_REC_NUM] NUM_RECS FILE_NAME"); out.println("-a Generate ascii records required for PennySort or JouleSort."); out.println(" These records are also an alternative input for the other"); out.println(" sort benchmarks. Without this flag, binary records will be"); out.println(" generated that contain the highest density of randomness in"); out.println(" the 10-byte key."); out.println("-c Calculate the sum of the crc32 checksums of each of the"); out.println(" generated records and send it to standard error."); out.println("-bN Set the beginning record generated to N. By default the"); out.println(" first record generated is record 0."); out.println("NUM_RECS The number of sequential records to generate."); out.println("FILE_NAME The name of the file to write the records to.\n"); out.println("Example 1 - to generate 1000000 ascii records starting at record 0 to"); out.println("the file named \"pennyinput\":"); out.println(" gensort -a 1000000 pennyinput\n"); out.println("Example 2 - to generate 1000 binary records beginning with record 2000"); out.println("to the file named \"partition2\":"); out.println(" gensort -b2000 1000 partition2"); System.exit(1); }
5. Main#usage()
Project: jdk7u-jdk
File: Main.java
File: Main.java
/** * Prints help message. */ static void usage() { PrintStream p = System.err; p.println("\nUsage: java -jar rmibench.jar [-options]"); p.println("\nwhere options are:"); p.println(" -h print this message"); p.println(" -v verbose mode"); p.println(" -l list configuration file"); p.println(" -t <num hours> repeat benchmarks for specified number of hours"); p.println(" -o <file> specify output file"); p.println(" -c <file> specify (non-default) " + "configuration file"); p.println(" -html format output as html " + "(default is text)"); p.println(" -xml format output as xml"); p.println(" -client <host:port> run benchmark client using server " + "on specified host/port"); p.println(" -server <port> run benchmark server on given port"); }
6. Main#usage()
Project: openjdk
File: Main.java
File: Main.java
/** * Prints help message. */ static void usage() { PrintStream p = System.err; p.println("\nUsage: java -jar rmibench.jar [-options]"); p.println("\nwhere options are:"); p.println(" -h print this message"); p.println(" -v verbose mode"); p.println(" -l list configuration file"); p.println(" -t <num hours> repeat benchmarks for specified number of hours"); p.println(" -o <file> specify output file"); p.println(" -c <file> specify (non-default) " + "configuration file"); p.println(" -html format output as html " + "(default is text)"); p.println(" -xml format output as xml"); p.println(" -server run benchmark server "); p.println(" -client <host:port> run benchmark client using server " + "on specified host/port"); }
7. TestOrderBy#genDataSetFileForOrderByDateTimeColumn()
Project: pig
File: TestOrderBy.java
File: TestOrderBy.java
private File genDataSetFileForOrderByDateTimeColumn() throws IOException { File fp1 = File.createTempFile("order_by_datetime", "txt"); PrintStream ps = new PrintStream(new FileOutputStream(fp1)); ps.println("value1\t1970-01-01T00:01:00.000Z"); ps.println("value2\t1970-01-01T00:00:00.000Z"); ps.println("value3\t"); ps.println("value4\t"); ps.println("value5\t1970-01-01T01:00:00.000Z"); ps.println("value6\t1970-01-01T00:00:01.000Z"); ps.println("value7\t1970-01-01T00:00:01.000Z"); ps.println("value8\t1970-01-02T00:00:00.000Z"); ps.println("value9\t1970-02-01T00:00:00.000Z"); ps.println("value10\t"); ps.close(); return fp1; }
8. TestOrderBy#genDataSetFileForOrderByBooleanColumn()
Project: pig
File: TestOrderBy.java
File: TestOrderBy.java
private File genDataSetFileForOrderByBooleanColumn() throws IOException { File fp1 = File.createTempFile("order_by_boolean", "txt"); PrintStream ps = new PrintStream(new FileOutputStream(fp1)); ps.println("value1\ttrue"); ps.println("value2\tfalse"); ps.println("value3\t"); ps.println("value4\t"); ps.println("value5\ttrue"); ps.println("value6\tfalse"); ps.println("value7\tfalse"); ps.println("value8\ttrue"); ps.println("value9\ttrue"); ps.println("value10\t"); ps.close(); return fp1; }
9. Main#usage()
Project: openjdk
File: Main.java
File: Main.java
/** * Print help message. */ static void usage() { PrintStream p = System.err; p.println("\nUsage: java -jar serialbench.jar [-options]"); p.println("\nwhere options are:"); p.println(" -h print this message"); p.println(" -v verbose mode"); p.println(" -l list configuration file"); p.println(" -t <num hours> repeat benchmarks for specified number of hours"); p.println(" -o <file> specify output file"); p.println(" -c <file> specify (non-default) configuration file"); p.println(" -html format output as html (default is text)"); p.println(" -xml format output as xml"); }
10. Main#usage()
Project: jdk7u-jdk
File: Main.java
File: Main.java
/** * Print help message. */ static void usage() { PrintStream p = System.err; p.println("\nUsage: java -jar serialbench.jar [-options]"); p.println("\nwhere options are:"); p.println(" -h print this message"); p.println(" -v verbose mode"); p.println(" -l list configuration file"); p.println(" -t <num hours> repeat benchmarks for specified number of hours"); p.println(" -o <file> specify output file"); p.println(" -c <file> specify (non-default) configuration file"); p.println(" -html format output as html (default is text)"); p.println(" -xml format output as xml"); }
11. ExtractResourceWithChangesSCM#saveToChangeLog()
Project: hudson-2.x
File: ExtractResourceWithChangesSCM.java
File: ExtractResourceWithChangesSCM.java
public void saveToChangeLog(File changeLogFile, ExtractChangeLogParser.ExtractChangeLogEntry changeLog) throws IOException { FileOutputStream outputStream = new FileOutputStream(changeLogFile); PrintStream stream = new PrintStream(outputStream, false, "UTF-8"); stream.println("<?xml version='1.0' encoding='UTF-8'?>"); stream.println("<extractChanges>"); stream.println("<entry>"); stream.println("<zipFile>" + escapeForXml(changeLog.getZipFile()) + "</zipFile>"); stream.println("<file>"); for (String fileName : changeLog.getAffectedPaths()) { stream.println("<fileName>" + escapeForXml(fileName) + "</fileName>"); } stream.println("</file>"); stream.println("</entry>"); stream.println("</extractChanges>"); stream.close(); }
12. FirstLastCustomerResource#outputCustomer()
Project: Resteasy
File: FirstLastCustomerResource.java
File: FirstLastCustomerResource.java
protected void outputCustomer(OutputStream os, Customer cust) throws IOException { PrintStream writer = new PrintStream(os); writer.println("<customer>"); writer.println(" <first-name>" + cust.getFirstName() + "</first-name>"); writer.println(" <last-name>" + cust.getLastName() + "</last-name>"); writer.println(" <street>" + cust.getStreet() + "</street>"); writer.println(" <city>" + cust.getCity() + "</city>"); writer.println(" <state>" + cust.getState() + "</state>"); writer.println(" <zip>" + cust.getZip() + "</zip>"); writer.println(" <country>" + cust.getCountry() + "</country>"); writer.println("</customer>"); }
13. CustomerResource#outputCustomer()
Project: Resteasy
File: CustomerResource.java
File: CustomerResource.java
protected void outputCustomer(OutputStream os, Customer cust) throws IOException { PrintStream writer = new PrintStream(os); writer.println("<customer id=\"" + cust.getId() + "\">"); writer.println(" <first-name>" + cust.getFirstName() + "</first-name>"); writer.println(" <last-name>" + cust.getLastName() + "</last-name>"); writer.println(" <street>" + cust.getStreet() + "</street>"); writer.println(" <city>" + cust.getCity() + "</city>"); writer.println(" <state>" + cust.getState() + "</state>"); writer.println(" <zip>" + cust.getZip() + "</zip>"); writer.println(" <country>" + cust.getCountry() + "</country>"); writer.println("</customer>"); }
14. CustomerResource#outputCustomer()
Project: Resteasy
File: CustomerResource.java
File: CustomerResource.java
protected void outputCustomer(OutputStream os, Customer cust) throws IOException { PrintStream writer = new PrintStream(os); writer.println("<customer id=\"" + cust.getId() + "\">"); writer.println(" <first-name>" + cust.getFirstName() + "</first-name>"); writer.println(" <last-name>" + cust.getLastName() + "</last-name>"); writer.println(" <street>" + cust.getStreet() + "</street>"); writer.println(" <city>" + cust.getCity() + "</city>"); writer.println(" <state>" + cust.getState() + "</state>"); writer.println(" <zip>" + cust.getZip() + "</zip>"); writer.println(" <country>" + cust.getCountry() + "</country>"); writer.println("</customer>"); }
15. CustomerResource#outputCustomer()
Project: Resteasy
File: CustomerResource.java
File: CustomerResource.java
protected void outputCustomer(OutputStream os, Customer cust) throws IOException { PrintStream writer = new PrintStream(os); writer.println("<customer id=\"" + cust.getId() + "\">"); writer.println(" <first-name>" + cust.getFirstName() + "</first-name>"); writer.println(" <last-name>" + cust.getLastName() + "</last-name>"); writer.println(" <street>" + cust.getStreet() + "</street>"); writer.println(" <city>" + cust.getCity() + "</city>"); writer.println(" <state>" + cust.getState() + "</state>"); writer.println(" <zip>" + cust.getZip() + "</zip>"); writer.println(" <country>" + cust.getCountry() + "</country>"); writer.println("</customer>"); }
16. CustomerResource#outputCustomer()
Project: Resteasy
File: CustomerResource.java
File: CustomerResource.java
protected void outputCustomer(OutputStream os, Customer cust) throws IOException { PrintStream writer = new PrintStream(os); writer.println("<customer id=\"" + cust.getId() + "\">"); writer.println(" <first-name>" + cust.getFirstName() + "</first-name>"); writer.println(" <last-name>" + cust.getLastName() + "</last-name>"); writer.println(" <street>" + cust.getStreet() + "</street>"); writer.println(" <city>" + cust.getCity() + "</city>"); writer.println(" <state>" + cust.getState() + "</state>"); writer.println(" <zip>" + cust.getZip() + "</zip>"); writer.println(" <country>" + cust.getCountry() + "</country>"); writer.println("</customer>"); }
17. MutationCoverage#printStats()
Project: pitest
File: MutationCoverage.java
File: MutationCoverage.java
private void printStats(final MutationStatisticsListener stats) { final PrintStream ps = System.out; ps.println(StringUtil.separatorLine('=')); ps.println("- Timings"); ps.println(StringUtil.separatorLine('=')); this.timings.report(ps); ps.println(StringUtil.separatorLine('=')); ps.println("- Statistics"); ps.println(StringUtil.separatorLine('=')); stats.getStatistics().report(ps); ps.println(StringUtil.separatorLine('=')); ps.println("- Mutators"); ps.println(StringUtil.separatorLine('=')); for (final Score each : stats.getStatistics().getScores()) { each.report(ps); ps.println(StringUtil.separatorLine()); } }
18. TestDefaultDateTimeZone#setUp()
Project: pig
File: TestDefaultDateTimeZone.java
File: TestDefaultDateTimeZone.java
@Override @Before public void setUp() throws Exception { currentDTZ = DateTimeZone.getDefault(); tmpFile = File.createTempFile("test", "txt"); PrintStream ps = new PrintStream(new FileOutputStream(tmpFile)); ps.println("1970-01-01T00:00:00.000"); ps.println("1970-01-01T00:00:00.000Z"); ps.println("1970-01-03T00:00:00.000"); ps.println("1970-01-03T00:00:00.000Z"); ps.println("1970-01-05T00:00:00.000"); ps.println("1970-01-05T00:00:00.000Z"); // for testing DST // EST ps.println("2014-02-01T00:00:00.000"); // EDT ps.println("2014-06-01T00:00:00.000"); ps.close(); }
19. GoodsStorageManageHandlerImpl#chnageStorageLua()
Project: Mycat-openEP
File: GoodsStorageManageHandlerImpl.java
File: GoodsStorageManageHandlerImpl.java
public static String chnageStorageLua() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); ps.println("local c=redis.call('hincrby',KEYS[1],ARGV[1])"); ps.println("if (c<0) then"); ps.println(" redis.call('hincrby',KEYS[1],-ARGV[1])"); ps.println(" return -1"); ps.println("else"); ps.println(" return 1"); ps.println("end"); ps.flush(); ps.close(); baos.flush(); return baos.toString(); }
20. GoodsStorageManageHandlerImpl#chnageStorageLua()
Project: Mycat-openEP
File: GoodsStorageManageHandlerImpl.java
File: GoodsStorageManageHandlerImpl.java
public static String chnageStorageLua() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); ps.println("local c=redis.call('hincrby',KEYS[1],ARGV[1])"); ps.println("if (c<0) then"); ps.println(" redis.call('hincrby',KEYS[1],-ARGV[1])"); ps.println(" return -1"); ps.println("else"); ps.println(" return 1"); ps.println("end"); ps.flush(); ps.close(); baos.flush(); return baos.toString(); }
21. ExtractResourceWithChangesSCM#saveToChangeLog()
Project: hudson
File: ExtractResourceWithChangesSCM.java
File: ExtractResourceWithChangesSCM.java
public void saveToChangeLog(File changeLogFile, ExtractChangeLogParser.ExtractChangeLogEntry changeLog) throws IOException { FileOutputStream outputStream = new FileOutputStream(changeLogFile); PrintStream stream = new PrintStream(outputStream, false, "UTF-8"); stream.println("<?xml version='1.0' encoding='UTF-8'?>"); stream.println("<extractChanges>"); stream.println("<entry>"); stream.println("<zipFile>" + escapeForXml(changeLog.getZipFile()) + "</zipFile>"); for (String fileName : changeLog.getAffectedPaths()) { stream.println("<file>"); stream.println("<fileName>" + escapeForXml(fileName) + "</fileName>"); stream.println("</file>"); } stream.println("</entry>"); stream.println("</extractChanges>"); stream.close(); }
22. MapUtilsTest#testVerbosePrintNullKeyToMap2()
Project: commons-collections
File: MapUtilsTest.java
File: MapUtilsTest.java
@Test public void testVerbosePrintNullKeyToMap2() { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final PrintStream outPrint = new PrintStream(out); final String INDENT = " "; final Map<Object, Object> map = new HashMap<Object, Object>(); final Map<Object, Object> map2 = new HashMap<Object, Object>(); map.put(null, map2); map2.put("2", "B"); outPrint.println("{"); outPrint.println(INDENT + "null = "); outPrint.println(INDENT + "{"); outPrint.println(INDENT + INDENT + "2 = B"); outPrint.println(INDENT + "}"); outPrint.println("}"); final String EXPECTED_OUT = out.toString(); out.reset(); MapUtils.verbosePrint(outPrint, null, map); assertEquals(EXPECTED_OUT, out.toString()); }
23. MapUtilsTest#testDebugPrintNullKeyToMap2()
Project: commons-collections
File: MapUtilsTest.java
File: MapUtilsTest.java
@Test public void testDebugPrintNullKeyToMap2() { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final PrintStream outPrint = new PrintStream(out); final String INDENT = " "; final Map<Object, Object> map = new HashMap<Object, Object>(); final Map<Object, Object> map2 = new HashMap<Object, Object>(); map.put(null, map2); map2.put("2", "B"); outPrint.println("{"); outPrint.println(INDENT + "null = "); outPrint.println(INDENT + "{"); outPrint.println(INDENT + INDENT + "2 = B " + String.class.getName()); outPrint.println(INDENT + "} " + HashMap.class.getName()); outPrint.println("} " + HashMap.class.getName()); final String EXPECTED_OUT = out.toString(); out.reset(); MapUtils.debugPrint(outPrint, null, map); assertEquals(EXPECTED_OUT, out.toString()); }
24. PrintStreamOutput#formatTable()
Project: jbehave-core
File: PrintStreamOutput.java
File: PrintStreamOutput.java
protected String formatTable(ExamplesTable table) { OutputStream formatted = new ByteArrayOutputStream(); PrintStream out = new PrintStream(formatted); out.print(format("examplesTableStart", "\n")); List<Map<String, String>> rows = table.getRows(); List<String> headers = table.getHeaders(); out.print(format("examplesTableHeadStart", "|")); for (String header : headers) { out.print(format("examplesTableHeadCell", "{0}|", header)); } out.print(format("examplesTableHeadEnd", "\n")); out.print(format("examplesTableBodyStart", EMPTY)); for (Map<String, String> row : rows) { out.print(format("examplesTableRowStart", "|")); for (String header : headers) { out.print(format("examplesTableCell", "{0}|", row.get(header))); } out.print(format("examplesTableRowEnd", "\n")); } out.print(format("examplesTableBodyEnd", "")); out.print(format("examplesTableEnd", "")); return formatted.toString(); }
25. TestBootNativeLibraryPath#createTestClass()
Project: openjdk
File: TestBootNativeLibraryPath.java
File: TestBootNativeLibraryPath.java
static void createTestClass() throws IOException { FileOutputStream fos = new FileOutputStream(TESTFILE + ".java"); PrintStream ps = new PrintStream(fos); ps.println("public class " + TESTFILE + "{"); ps.println("public static void main(String[] args) {\n"); ps.println("System.out.println(System.getProperty(\"sun.boot.library.path\"));\n"); ps.println("}}\n"); ps.close(); fos.close(); JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); String javacOpts[] = { TESTFILE + ".java" }; if (javac.run(null, null, null, javacOpts) != 0) { throw new RuntimeException("compilation of " + TESTFILE + ".java Failed"); } }
26. TestShell#test()
Project: ThriftyPaxos
File: TestShell.java
File: TestShell.java
private void test(final boolean commandLineArgs) throws IOException { PipedInputStream testIn = new PipedInputStream(); PipedOutputStream out = new PipedOutputStream(testIn); toolOut = new PrintStream(out, true); out = new PipedOutputStream(); PrintStream testOut = new PrintStream(out, true); toolIn = new PipedInputStream(out); Task task = new Task() { @Override public void call() throws Exception { try { Shell shell = new Shell(); shell.setIn(toolIn); shell.setOut(toolOut); shell.setErr(toolOut); if (commandLineArgs) { shell.runTool("-url", "jdbc:h2:mem:", "-user", "sa", "-password", "sa"); } else { shell.runTool(); } } finally { toolOut.close(); } } }; task.execute(); InputStreamReader reader = new InputStreamReader(testIn); lineReader = new LineNumberReader(reader); read(""); read("Welcome to H2 Shell"); read("Exit with"); if (!commandLineArgs) { read("[Enter]"); testOut.println("jdbc:h2:mem:"); read("URL"); testOut.println(""); read("Driver"); testOut.println("sa"); read("User"); testOut.println("sa"); read("Password"); } read("Commands are case insensitive"); read("help or ?"); read("list"); read("maxwidth"); read("autocommit"); read("history"); read("quit or exit"); read(""); testOut.println("history"); read("sql> No history"); testOut.println("1"); read("sql> Not found"); testOut.println("select 1 a;"); read("sql> A"); read("1"); read("(1 row,"); testOut.println("history"); read("sql> #1: select 1 a"); read("To re-run a statement, type the number and press and enter"); testOut.println("1"); read("sql> select 1 a"); read("A"); read("1"); read("(1 row,"); testOut.println("select 'x' || space(1000) large, 'y' small;"); read("sql> LARGE"); read("x"); read("(data is partially truncated)"); read("(1 row,"); testOut.println("select x, 's' s from system_range(0, 10001);"); read("sql> X | S"); for (int i = 0; i < 10000; i++) { read((i + " ").substring(0, 4) + " | s"); } for (int i = 10000; i <= 10001; i++) { read((i + " ").substring(0, 5) + " | s"); } read("(10002 rows,"); testOut.println("select error;"); read("sql> Error:"); if (read("").startsWith("Column \"ERROR\" not found")) { read(""); } testOut.println("create table test(id int primary key, name varchar)\n;"); read("sql> ...>"); testOut.println("insert into test values(1, 'Hello');"); read("sql>"); testOut.println("select null n, * from test;"); read("sql> N | ID | NAME"); read("null | 1 | Hello"); read("(1 row,"); // test history for (int i = 0; i < 30; i++) { testOut.println("select " + i + " ID from test;"); read("sql> ID"); read("" + i); read("(1 row,"); } testOut.println("20"); read("sql> select 10 ID from test"); read("ID"); read("10"); read("(1 row,"); testOut.println("maxwidth"); read("sql> Usage: maxwidth <integer value>"); read("Maximum column width is now 100"); testOut.println("maxwidth 80"); read("sql> Maximum column width is now 80"); testOut.println("autocommit"); read("sql> Usage: autocommit [true|false]"); read("Autocommit is now true"); testOut.println("autocommit false"); read("sql> Autocommit is now false"); testOut.println("autocommit true"); read("sql> Autocommit is now true"); testOut.println("list"); read("sql> Result list mode is now on"); testOut.println("select 1 first, 2 second;"); read("sql> FIRST : 1"); read("SECOND: 2"); read("(1 row, "); testOut.println("select x from system_range(1, 3);"); read("sql> X: 1"); read(""); read("X: 2"); read(""); read("X: 3"); read("(3 rows, "); testOut.println("select x, 2 as y from system_range(1, 3) where 1 = 0;"); read("sql> X"); read("Y"); read("(0 rows, "); testOut.println("list"); read("sql> Result list mode is now off"); testOut.println("help"); read("sql> Commands are case insensitive"); read("help or ?"); read("list"); read("maxwidth"); read("autocommit"); read("history"); read("quit or exit"); read(""); testOut.println("exit"); read("sql>"); task.get(); }
27. MapUtilsTest#testDebugPrintNullLabel()
Project: commons-collections
File: MapUtilsTest.java
File: MapUtilsTest.java
@Test public void testDebugPrintNullLabel() { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final PrintStream outPrint = new PrintStream(out); final String INDENT = " "; // treeMap guarantees order across JDKs for test final Map<Integer, String> map = new TreeMap<Integer, String>(); map.put(2, "B"); map.put(3, "C"); map.put(4, null); outPrint.println("{"); outPrint.println(INDENT + "2 = B " + String.class.getName()); outPrint.println(INDENT + "3 = C " + String.class.getName()); outPrint.println(INDENT + "4 = null"); outPrint.println("} " + TreeMap.class.getName()); final String EXPECTED_OUT = out.toString(); out.reset(); MapUtils.debugPrint(outPrint, null, map); assertEquals(EXPECTED_OUT, out.toString()); }
28. MapUtilsTest#testVerbosePrintNullLabel()
Project: commons-collections
File: MapUtilsTest.java
File: MapUtilsTest.java
@Test public void testVerbosePrintNullLabel() { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final PrintStream outPrint = new PrintStream(out); final String INDENT = " "; // treeMap guarantees order across JDKs for test final Map<Integer, String> map = new TreeMap<Integer, String>(); map.put(2, "B"); map.put(3, "C"); map.put(4, null); outPrint.println("{"); outPrint.println(INDENT + "2 = B"); outPrint.println(INDENT + "3 = C"); outPrint.println(INDENT + "4 = null"); outPrint.println("}"); final String EXPECTED_OUT = out.toString(); out.reset(); MapUtils.verbosePrint(outPrint, null, map); assertEquals(EXPECTED_OUT, out.toString()); }
29. ZipMeUp#getManifestAsBytes()
Project: openjdk
File: ZipMeUp.java
File: ZipMeUp.java
static byte[] getManifestAsBytes(int nchars) throws IOException { crc.reset(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); CheckedOutputStream cos = new CheckedOutputStream(baos, crc); PrintStream ps = new PrintStream(cos); ps.println("Manifest-Version: 1.0"); ps.print("Main-Class: "); for (int i = 0; i < nchars - SOME_KLASS.length(); i++) { ps.print(i % 10); } ps.println(SOME_KLASS); cos.flush(); cos.close(); ps.close(); return baos.toByteArray(); }
30. ZipMeUp#getManifestAsBytes()
Project: jdk7u-jdk
File: ZipMeUp.java
File: ZipMeUp.java
static byte[] getManifestAsBytes(int nchars) throws IOException { crc.reset(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); CheckedOutputStream cos = new CheckedOutputStream(baos, crc); PrintStream ps = new PrintStream(cos); ps.println("Manifest-Version: 1.0"); ps.print("Main-Class: "); for (int i = 0; i < nchars - SOME_KLASS.length(); i++) { ps.print(i % 10); } ps.println(SOME_KLASS); cos.flush(); cos.close(); ps.close(); return baos.toByteArray(); }
31. PagToDotDumper#dumpPAGForMethod()
Project: JAADAS
File: PagToDotDumper.java
File: PagToDotDumper.java
/** * Dump the PAG for some method in the program in * dot format * @param fName The filename for the output * @param cName The name of the declaring class for the method * @param mName The name of the method * @throws FileNotFoundException if output file cannot be written */ public void dumpPAGForMethod(String fName, String cName, String mName) throws FileNotFoundException { FileOutputStream fos = new FileOutputStream(new File(fName)); PrintStream ps = new PrintStream(fos); ps.println("digraph G {"); ps.println("\trankdir=LR;"); dumpLocalPAG(cName, mName, ps); ps.print("}"); try { fos.close(); } catch (IOException e) { } ps.close(); }
32. FileURLConnection#getDirectoryListing()
Project: j2objc
File: FileURLConnection.java
File: FileURLConnection.java
/** * Returns the directory listing of the file component as an input stream. * * @return the input stream of the directory listing */ private InputStream getDirectoryListing(File f) { String fileList[] = f.list(); ByteArrayOutputStream bytes = new java.io.ByteArrayOutputStream(); PrintStream out = new PrintStream(bytes); out.print("<title>Directory Listing</title>\n"); out.print("<base href=\"file:"); out.print(f.getPath().replace('\\', '/') + "/\"><h1>" + f.getPath() + "</h1>\n<hr>\n"); int i; for (i = 0; i < fileList.length; i++) { out.print(fileList[i] + "<br>\n"); } out.close(); return new ByteArrayInputStream(bytes.toByteArray()); }
33. TestCommand#printMatchingTestRules()
Project: buck
File: TestCommand.java
File: TestCommand.java
private void printMatchingTestRules(Console console, Iterable<TestRule> testRules) { PrintStream out = console.getStdOut(); ImmutableList<TestRule> list = ImmutableList.copyOf(testRules); out.println(String.format("MATCHING TEST RULES (%d):", list.size())); out.println(""); if (list.isEmpty()) { out.println(" (none)"); } else { for (TestRule testRule : testRules) { out.println(" " + testRule.getBuildTarget()); } } out.println(""); }
34. XplainStatisticsTest#invokePlanExporterTool()
Project: derby
File: XplainStatisticsTest.java
File: XplainStatisticsTest.java
/** * Invoke the PlanExporter tool. * * @param args the command line arguments to pass to the tool * @return the output printed by the tool (typically an empty string * on successful execution) */ private static String invokePlanExporterTool(String... args) { PrintStream out = System.out; PrintStream err = System.err; ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); PrintStream testOutput = new PrintStream(byteOut); // Redirect System.out and System.err so that the output // can be captured. setSystemOut(testOutput); setSystemErr(testOutput); try { PlanExporter.main(args); } finally { // Restore System.out and System.err. setSystemOut(out); setSystemErr(err); } testOutput.flush(); return byteOut.toString(); }
35. RunTest#addToListFile()
Project: derby
File: RunTest.java
File: RunTest.java
static void addToListFile(String fileName, String testName) throws IOException { File f; if (isSuiteRun) f = new File(rsuiteDir, fileName); else f = new File(outDir, fileName); PrintStream ps = null; // a bug in the EPOC jvm. try { ps = new PrintStream(new FileOutputStream(f.getCanonicalPath(), true)); } catch (IOException e) { FileWriter fw = new FileWriter(f); fw.close(); ps = new PrintStream(new FileOutputStream(f.getCanonicalPath(), true)); } ps.println(testName); ps.flush(); ps.close(); }
36. MapUtilsTest#testVerbosePrintNullKeyToMap1()
Project: commons-collections
File: MapUtilsTest.java
File: MapUtilsTest.java
@Test public void testVerbosePrintNullKeyToMap1() { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final PrintStream outPrint = new PrintStream(out); final String INDENT = " "; final Map<Object, Map<?, ?>> map = new HashMap<Object, Map<?, ?>>(); map.put(null, map); outPrint.println("{"); outPrint.println(INDENT + "null = (this Map)"); outPrint.println("}"); final String EXPECTED_OUT = out.toString(); out.reset(); MapUtils.verbosePrint(outPrint, null, map); assertEquals(EXPECTED_OUT, out.toString()); }
37. MapUtilsTest#testDebugPrintNullKeyToMap1()
Project: commons-collections
File: MapUtilsTest.java
File: MapUtilsTest.java
@Test public void testDebugPrintNullKeyToMap1() { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final PrintStream outPrint = new PrintStream(out); final String INDENT = " "; final Map<Object, Map<?, ?>> map = new HashMap<Object, Map<?, ?>>(); map.put(null, map); outPrint.println("{"); outPrint.println(INDENT + "null = (this Map) " + HashMap.class.getName()); outPrint.println("} " + HashMap.class.getName()); final String EXPECTED_OUT = out.toString(); out.reset(); MapUtils.debugPrint(outPrint, null, map); assertEquals(EXPECTED_OUT, out.toString()); }
38. MapUtilsTest#testVerbosePrintNullKey()
Project: commons-collections
File: MapUtilsTest.java
File: MapUtilsTest.java
@Test public void testVerbosePrintNullKey() { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final PrintStream outPrint = new PrintStream(out); final String INDENT = " "; final Map<Object, String> map = new HashMap<Object, String>(); map.put(null, "A"); outPrint.println("{"); outPrint.println(INDENT + "null = A"); outPrint.println("}"); final String EXPECTED_OUT = out.toString(); out.reset(); MapUtils.verbosePrint(outPrint, null, map); assertEquals(EXPECTED_OUT, out.toString()); }
39. MapUtilsTest#testDebugPrintNullKey()
Project: commons-collections
File: MapUtilsTest.java
File: MapUtilsTest.java
@Test public void testDebugPrintNullKey() { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final PrintStream outPrint = new PrintStream(out); final String INDENT = " "; final Map<Object, String> map = new HashMap<Object, String>(); map.put(null, "A"); outPrint.println("{"); outPrint.println(INDENT + "null = A " + String.class.getName()); outPrint.println("} " + HashMap.class.getName()); final String EXPECTED_OUT = out.toString(); out.reset(); MapUtils.debugPrint(outPrint, null, map); assertEquals(EXPECTED_OUT, out.toString()); }
40. GetJobCommandTest#withFolders()
Project: Jenkins2
File: GetJobCommandTest.java
File: GetJobCommandTest.java
@Issue("JENKINS-20236") @Test public void withFolders() throws Exception { MockFolder d = j.createFolder("d"); FreeStyleProject p = d.createProject(FreeStyleProject.class, "p"); ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream outS = new PrintStream(out); int result = new GetJobCommand().main(Collections.singletonList("d/p"), Locale.ENGLISH, new NullInputStream(0), outS, outS); outS.flush(); String output = out.toString(); assertEquals(output, 0, result); assertEquals(p.getConfigFile().asString(), output); out = new ByteArrayOutputStream(); outS = new PrintStream(out); result = new GetJobCommand().main(Collections.singletonList("d"), Locale.ENGLISH, new NullInputStream(0), outS, outS); outS.flush(); output = out.toString(); assertEquals(output, 0, result); assertEquals(d.getConfigFile().asString(), output); }
41. TaintingTests#runTest()
Project: jena
File: TaintingTests.java
File: TaintingTests.java
@Override public void runTest() throws IOException { ByteArrayOutputStream goodBytes = new ByteArrayOutputStream(); ByteArrayOutputStream badBytes = new ByteArrayOutputStream(); PrintStream oldOut = System.out; PrintStream oldErr = System.err; try (PrintStream out = new PrintStream(goodBytes); PrintStream err = new PrintStream(badBytes)) { System.setOut(out); System.setErr(err); NTriple.mainEh(new String[] { "-e", "102,136,105,103,108,107,116,106,004,131", "-E", "-b", base, fileName }, this, null); } finally { System.setErr(oldErr); System.setOut(oldOut); } InputStream good = new ByteArrayInputStream(goodBytes.toByteArray()); InputStream bad = new ByteArrayInputStream(badBytes.toByteArray()); compare(good, goodTriples); compare(bad, badTriples); }
42. ConsoleFormatter#printSpecification()
Project: java-8-lambdas-exercises
File: ConsoleFormatter.java
File: ConsoleFormatter.java
private void printSpecification(SpecificationReport specification) { boolean isSuccess = specification.getResult() == Result.SUCCESS; PrintStream out = isSuccess ? System.out : System.err; out.print("\tshould "); out.print(specification.getDescription()); if (!isSuccess) { out.print("["); out.print(specification.getMessage()); out.print("]"); } out.println(); }
43. Info#run()
Project: jackrabbit-filevault
File: Info.java
File: Info.java
public void run(VltDirectory dir, VltFile file, VaultFile remoteFile) throws VltException { if (file == null) { return; } PrintStream out = dir.getContext().getStdout(); VltEntry e = file.getEntry(); out.printf(" Path: %s%n", dir.getContext().getCwdRelativePath(file.getPath())); out.printf("Status: %s%n", file.getStatus().name().toLowerCase()); if (e != null) { RepositoryAddress root = dir.getContext().getMountpoint(); RepositoryAddress addr = root.resolve(e.getAggregatePath()); addr = addr.resolve(e.getRepoRelPath()); out.printf(" URL: %s%n", addr.toString()); print(out, " Work", e.work()); print(out, " Base", e.base()); print(out, " Mine", e.mine()); print(out, "Theirs", e.theirs()); } out.println(); }
44. GetJobCommandTest#withFolders()
Project: hudson
File: GetJobCommandTest.java
File: GetJobCommandTest.java
@Issue("JENKINS-20236") @Test public void withFolders() throws Exception { MockFolder d = j.createFolder("d"); FreeStyleProject p = d.createProject(FreeStyleProject.class, "p"); ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream outS = new PrintStream(out); int result = new GetJobCommand().main(Collections.singletonList("d/p"), Locale.ENGLISH, new NullInputStream(0), outS, outS); outS.flush(); String output = out.toString(); assertEquals(output, 0, result); assertEquals(p.getConfigFile().asString(), output); out = new ByteArrayOutputStream(); outS = new PrintStream(out); result = new GetJobCommand().main(Collections.singletonList("d"), Locale.ENGLISH, new NullInputStream(0), outS, outS); outS.flush(); output = out.toString(); assertEquals(output, 0, result); assertEquals(d.getConfigFile().asString(), output); }
45. TestClassFinder#compileTestClass()
Project: hindex
File: TestClassFinder.java
File: TestClassFinder.java
/** * Compiles the test class with bogus code into a .class file. * Unfortunately it's very tedious. * @param counter Unique test counter. * @param packageNameSuffix Package name suffix (e.g. ".suffix") for nesting, or "". * @return The resulting .class file and the location in jar it is supposed to go to. */ private static FileAndPath compileTestClass(long counter, String packageNameSuffix, String classNamePrefix) throws Exception { classNamePrefix = classNamePrefix + counter; String packageName = makePackageName(packageNameSuffix, counter); String javaPath = basePath + classNamePrefix + ".java"; String classPath = basePath + classNamePrefix + ".class"; PrintStream source = new PrintStream(javaPath); source.println("package " + packageName + ";"); source.println("public class " + classNamePrefix + " { public static void main(String[] args) { } };"); source.close(); JavaCompiler jc = ToolProvider.getSystemJavaCompiler(); int result = jc.run(null, null, null, javaPath); assertEquals(0, result); File classFile = new File(classPath); assertTrue(classFile.exists()); return new FileAndPath(packageName.replace('.', '/') + '/', classFile); }
46. HieroSettings#save()
Project: libgdx
File: HieroSettings.java
File: HieroSettings.java
/** Saves the settings to a file. * @throws IOException if the file could not be saved. */ public void save(File file) throws IOException { PrintStream out = new PrintStream(file, "UTF-8"); out.println("font.name=" + fontName); out.println("font.size=" + fontSize); out.println("font.bold=" + bold); out.println("font.italic=" + italic); out.println("font.gamma=" + gamma); out.println("font.mono=" + mono); out.println(); out.println("font2.file=" + font2File); out.println("font2.use=" + font2Active); out.println(); out.println("pad.top=" + paddingTop); out.println("pad.right=" + paddingRight); out.println("pad.bottom=" + paddingBottom); out.println("pad.left=" + paddingLeft); out.println("pad.advance.x=" + paddingAdvanceX); out.println("pad.advance.y=" + paddingAdvanceY); out.println(); out.println("glyph.native.rendering=" + nativeRendering); out.println("glyph.page.width=" + glyphPageWidth); out.println("glyph.page.height=" + glyphPageHeight); out.println("glyph.text=" + glyphText); out.println(); for (Iterator iter = effects.iterator(); iter.hasNext(); ) { ConfigurableEffect effect = (ConfigurableEffect) iter.next(); out.println("effect.class=" + effect.getClass().getName()); for (Iterator iter2 = effect.getValues().iterator(); iter2.hasNext(); ) { Value value = (Value) iter2.next(); out.println("effect." + value.getName() + "=" + value.getString()); } out.println(); } out.close(); }
47. ConsoleFormatter#printSpecification()
Project: lambda-behave
File: ConsoleFormatter.java
File: ConsoleFormatter.java
private void printSpecification(final SpecificationReport specification) { boolean isSuccess = specification.getResult() == Result.SUCCESS; PrintStream out = isSuccess ? System.out : System.err; out.print("\tshould "); out.print(specification.getDescription()); if (!isSuccess) { out.print("["); out.print(specification.getMessage()); out.print("]"); } out.println(); }
48. MessageDigest#toString()
Project: jdk7u-jdk
File: MessageDigest.java
File: MessageDigest.java
/** * Returns a string representation of this message digest object. */ public String toString() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream p = new PrintStream(baos); p.print(algorithm + " Message Digest from " + provider.getName() + ", "); switch(state) { case INITIAL: p.print("<initialized>"); break; case IN_PROGRESS: p.print("<in progress>"); break; } p.println(); return (baos.toString()); }
49. ClassesGenerator#generate()
Project: ignite
File: ClassesGenerator.java
File: ClassesGenerator.java
/** * @throws Exception In case of error. */ private void generate() throws Exception { System.out.println("Generating classnames.properties..."); for (URL url : ldr.getURLs()) processUrl(url); if (!errs.isEmpty()) { StringBuilder sb = new StringBuilder("Failed to generate classnames.properties due to errors:\n"); for (String err : errs) sb.append(" ").append(err).append('\n'); throw new Exception(sb.toString().trim()); } PrintStream out = new PrintStream(new File(basePath, (fileName == null || fileName.isEmpty()) ? DEFAULT_FILE_PATH : META_INF + fileName)); out.println(hdr); out.println(); for (Class cls : classes) out.println(cls.getName()); }
50. CliManagerImpl#main()
Project: hudson-2.x
File: CliManagerImpl.java
File: CliManagerImpl.java
public int main(List<String> args, Locale locale, InputStream stdin, OutputStream stdout, OutputStream stderr) { // remoting sets the context classloader to the RemoteClassLoader, // which slows down the classloading. we don't load anything from CLI, // so counter that effect. Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); PrintStream out = new PrintStream(stdout); PrintStream err = new PrintStream(stderr); String subCmd = args.get(0); CLICommand cmd = CLICommand.clone(subCmd); if (cmd != null) { final CLICommand old = CLICommand.setCurrent(cmd); try { return cmd.main(args.subList(1, args.size()), locale, stdin, out, err); } finally { CLICommand.setCurrent(old); } } err.println("No such command: " + subCmd); new HelpCommand().main(Collections.<String>emptyList(), locale, stdin, out, err); return -1; }
51. CommitCheckServlet#doGet()
Project: HiTune
File: CommitCheckServlet.java
File: CommitCheckServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { PrintStream out = new PrintStream(resp.getOutputStream()); resp.setStatus(200); out.println("<html><body><h2>Commit status</h2><ul>"); for (String s : commitCheck.getLengthList()) out.println("<li>" + s + "</li>"); out.println("</ul></body></html>"); }
52. TestDistCh#runLsr()
Project: hadoop-mapreduce
File: TestDistCh.java
File: TestDistCh.java
private static String runLsr(final FsShell shell, String root, int returnvalue) throws Exception { System.out.println("root=" + root + ", returnvalue=" + returnvalue); final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); final PrintStream out = new PrintStream(bytes); final PrintStream oldOut = System.out; final PrintStream oldErr = System.err; System.setOut(out); System.setErr(out); final String results; try { assertEquals(returnvalue, shell.run(new String[] { "-lsr", root })); results = bytes.toString(); } finally { IOUtils.closeStream(out); System.setOut(oldOut); System.setErr(oldErr); } System.out.println("results:\n" + results); return results; }
53. TestDFSShell#runLsr()
Project: hadoop-hdfs
File: TestDFSShell.java
File: TestDFSShell.java
private static String runLsr(final FsShell shell, String root, int returnvalue) throws Exception { System.out.println("root=" + root + ", returnvalue=" + returnvalue); final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); final PrintStream out = new PrintStream(bytes); final PrintStream oldOut = System.out; final PrintStream oldErr = System.err; System.setOut(out); System.setErr(out); final String results; try { assertEquals(returnvalue, shell.run(new String[] { "-lsr", root })); results = bytes.toString(); } finally { IOUtils.closeStream(out); System.setOut(oldOut); System.setErr(oldErr); } System.out.println("results:\n" + results); return results; }
54. YamlCompareOutputsTest#main()
Project: protostuff
File: YamlCompareOutputsTest.java
File: YamlCompareOutputsTest.java
public static void main(String[] args) throws Exception { String dir = System.getProperty("benchmark.output_dir"); PrintStream out = dir == null ? System.out : new PrintStream(new FileOutputStream(new File(new File(dir), "protostuff-yaml-" + System.currentTimeMillis() + ".txt"), true)); int warmups = Integer.getInteger("benchmark.warmups", 100000); int loops = Integer.getInteger("benchmark.loops", 1000000); String title = "protostuff-yaml serialization benchmark for " + loops + " runs"; out.println(title); out.println(); start(foo, SERIALIZERS, out, warmups, loops); if (System.out != out) out.close(); }
55. YamlCompareOutputsTest#testBenchmark()
Project: protostuff
File: YamlCompareOutputsTest.java
File: YamlCompareOutputsTest.java
public void testBenchmark() throws Exception { if (!"false".equals(System.getProperty("benchmark.skip"))) return; String dir = System.getProperty("benchmark.output_dir"); PrintStream out = dir == null ? System.out : new PrintStream(new FileOutputStream(new File(new File(dir), "protostuff-yaml-" + System.currentTimeMillis() + ".txt"), true)); int warmups = Integer.getInteger("benchmark.warmups", 200000); int loops = Integer.getInteger("benchmark.loops", 2000000); String title = "protostuff-yaml serialization benchmark for " + loops + " runs"; out.println(title); out.println(); start(foo, SERIALIZERS, out, warmups, loops); if (System.out != out) out.close(); }
56. JsonCompareOutputsTest#main()
Project: protostuff
File: JsonCompareOutputsTest.java
File: JsonCompareOutputsTest.java
public static void main(String[] args) throws Exception { String dir = System.getProperty("benchmark.output_dir"); PrintStream out = dir == null ? System.out : new PrintStream(new FileOutputStream(new File(new File(dir), "protostuff-json-" + System.currentTimeMillis() + ".txt"), true)); int warmups = Integer.getInteger("benchmark.warmups", 100000); int loops = Integer.getInteger("benchmark.loops", 1000000); String title = "protostuff-json serialization benchmark for " + loops + " runs"; out.println(title); out.println(); start(foo, JSON_SERIALIZERS, out, warmups, loops); if (System.out != out) out.close(); }
57. JsonCompareOutputsTest#testBenchmark()
Project: protostuff
File: JsonCompareOutputsTest.java
File: JsonCompareOutputsTest.java
public void testBenchmark() throws Exception { if (!"false".equals(System.getProperty("benchmark.skip"))) return; String dir = System.getProperty("benchmark.output_dir"); PrintStream out = dir == null ? System.out : new PrintStream(new FileOutputStream(new File(new File(dir), "protostuff-json-" + System.currentTimeMillis() + ".txt"), true)); int warmups = Integer.getInteger("benchmark.warmups", 200000); int loops = Integer.getInteger("benchmark.loops", 2000000); String title = "protostuff-json serialization benchmark for " + loops + " runs"; out.println(title); out.println(); start(foo, JSON_SERIALIZERS, out, warmups, loops); if (System.out != out) out.close(); }
58. CompareOutputsTest#main()
Project: protostuff
File: CompareOutputsTest.java
File: CompareOutputsTest.java
public static void main(String[] args) throws Exception { String dir = System.getProperty("benchmark.output_dir"); PrintStream out = dir == null ? System.out : new PrintStream(new FileOutputStream(new File(new File(dir), "protostuff-core-" + System.currentTimeMillis() + ".txt"), true)); int warmups = Integer.getInteger("benchmark.warmups", 200000); int loops = Integer.getInteger("benchmark.loops", 2000000); String title = "protostuff-core serialization benchmark for " + loops + " runs"; out.println(title); out.println(); start(foo, SERIALIZERS, out, warmups, loops); if (System.out != out) out.close(); }
59. CompareOutputsTest#testBenchmark()
Project: protostuff
File: CompareOutputsTest.java
File: CompareOutputsTest.java
public void testBenchmark() throws Exception { if (!"false".equals(System.getProperty("benchmark.skip"))) return; String dir = System.getProperty("benchmark.output_dir"); PrintStream out = dir == null ? System.out : new PrintStream(new FileOutputStream(new File(new File(dir), "protostuff-core-" + System.currentTimeMillis() + ".txt"), true)); int warmups = Integer.getInteger("benchmark.warmups", 200000); int loops = Integer.getInteger("benchmark.loops", 2000000); String title = "protostuff-core serialization benchmark for " + loops + " runs"; out.println(title); out.println(); start(foo, SERIALIZERS, out, warmups, loops); if (System.out != out) out.close(); }
60. CompareInputsTest#main()
Project: protostuff
File: CompareInputsTest.java
File: CompareInputsTest.java
public static void main(String[] args) throws Exception { String dir = System.getProperty("benchmark.output_dir"); PrintStream out = dir == null ? System.out : new PrintStream(new FileOutputStream(new File(new File(dir), "protostuff-core-" + System.currentTimeMillis() + ".txt"), true)); int warmups = Integer.getInteger("benchmark.warmups", 200000); int loops = Integer.getInteger("benchmark.loops", 2000000); String title = "protostuff-core deserialization benchmark for " + loops + " runs"; out.println(title); out.println(); start(out, warmups, loops); if (System.out != out) out.close(); }
61. CompareInputsTest#testBenchmark()
Project: protostuff
File: CompareInputsTest.java
File: CompareInputsTest.java
public void testBenchmark() throws Exception { if (!"false".equals(System.getProperty("benchmark.skip"))) return; String dir = System.getProperty("benchmark.output_dir"); PrintStream out = dir == null ? System.out : new PrintStream(new FileOutputStream(new File(new File(dir), "protostuff-core-" + System.currentTimeMillis() + ".txt"), true)); int warmups = Integer.getInteger("benchmark.warmups", 200000); int loops = Integer.getInteger("benchmark.loops", 2000000); String title = "protostuff-core deserialization benchmark for " + loops + " runs"; out.println(title); out.println(); start(out, warmups, loops); if (System.out != out) out.close(); }
62. TestLocal2#testPig800Sort()
Project: pig
File: TestLocal2.java
File: TestLocal2.java
@Test public void testPig800Sort() throws Exception { // Regression test for Pig-800 File fp1 = File.createTempFile("test", "txt"); PrintStream ps = new PrintStream(new FileOutputStream(fp1)); ps.println("1\t1}"); ps.close(); pig.registerQuery("A = load '" + Util.generateURI(fp1.toString(), pig.getPigContext()) + "'; "); pig.registerQuery("B = foreach A generate flatten(" + Pig800Udf.class.getName() + "($0));"); pig.registerQuery("C = order B by $0;"); Iterator<Tuple> iter = pig.openIterator("C"); // Before PIG-800 was fixed this went into an infinite loop, so just // managing to open the iterator is sufficient. fp1.delete(); }
63. TestLocal2#testPig800Distinct()
Project: pig
File: TestLocal2.java
File: TestLocal2.java
@Test public void testPig800Distinct() throws Exception { // Regression test for Pig-800 File fp1 = File.createTempFile("test", "txt"); PrintStream ps = new PrintStream(new FileOutputStream(fp1)); ps.println("1\t1}"); ps.close(); pig.registerQuery("A = load '" + Util.generateURI(fp1.toString(), pig.getPigContext()) + "'; "); pig.registerQuery("B = foreach A generate flatten(" + Pig800Udf.class.getName() + "($0));"); pig.registerQuery("C = distinct B;"); Iterator<Tuple> iter = pig.openIterator("C"); // Before PIG-800 was fixed this went into an infinite loop, so just // managing to open the iterator is sufficient. fp1.delete(); }
64. MessageDigest#toString()
Project: openjdk
File: MessageDigest.java
File: MessageDigest.java
/** * Returns a string representation of this message digest object. */ public String toString() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream p = new PrintStream(baos); p.print(algorithm + " Message Digest from " + provider.getName() + ", "); switch(state) { case INITIAL: p.print("<initialized>"); break; case IN_PROGRESS: p.print("<in progress>"); break; } p.println(); return (baos.toString()); }
65. PreconditionInfoHandler#handleOption()
Project: oodt
File: PreconditionInfoHandler.java
File: PreconditionInfoHandler.java
@Override public void handleOption(CmdLineAction selectedAction, CmdLineOptionInstance optionInstance) { String[] preCondIds = this.getApplicationContext().getBeanNamesForType(PreConditionComparator.class); PrintStream ps = new PrintStream(this.getOutStream()); ps.println("PreConditionComparators:"); for (String preCondId : preCondIds) { PreConditionComparator<?> preCond = (PreConditionComparator<?>) this.getApplicationContext().getBean(preCondId); ps.println(" PreCondComparator:"); ps.println(" Id: " + preCondId); ps.println(" Description: " + preCond.getDescription()); ps.println(); } ps.close(); }
66. CrawlerActionInfoHandler#handleOption()
Project: oodt
File: CrawlerActionInfoHandler.java
File: CrawlerActionInfoHandler.java
@Override public void handleOption(CmdLineAction selectedAction, CmdLineOptionInstance optionInstance) { String[] actionIds = this.getApplicationContext().getBeanNamesForType(CrawlerAction.class); PrintStream ps = new PrintStream(this.getOutStream()); ps.println("Actions:"); for (String actionId : actionIds) { CrawlerAction ca = (CrawlerAction) this.getApplicationContext().getBean(actionId); ps.println(" Action:"); ps.println(" Id: " + ca.getId()); ps.println(" Description: " + ca.getDescription()); ps.println(" Phases: " + ca.getPhases()); if (ca instanceof MimeTypeCrawlerAction) { ps.println(" MimeTypes: " + ((MimeTypeCrawlerAction) ca).getMimeTypes()); } ps.println(); } ps.close(); }
67. DocMakerTest#testDocMakerLeak()
Project: lucene-solr
File: DocMakerTest.java
File: DocMakerTest.java
public void testDocMakerLeak() throws Exception { // DocMaker did not close its ContentSource if resetInputs was called twice, // leading to a file handle leak. Path f = getWorkDir().resolve("docMakerLeak.txt"); PrintStream ps = new PrintStream(Files.newOutputStream(f), true, IOUtils.UTF_8); ps.println("one title\t" + System.currentTimeMillis() + "\tsome content"); ps.close(); Properties props = new Properties(); props.setProperty("docs.file", f.toAbsolutePath().toString()); props.setProperty("content.source.forever", "false"); Config config = new Config(props); ContentSource source = new LineDocSource(); source.setConfig(config); DocMaker dm = new DocMaker(); dm.setConfig(config, source); dm.resetInputs(); dm.resetInputs(); dm.close(); }
68. BdbNativeBackup#recordBackupSet()
Project: voldemort
File: BdbNativeBackup.java
File: BdbNativeBackup.java
/** * Records the list of backedup files into a text file * * @param filesInEnv * @param backupDir */ private void recordBackupSet(File backupDir) throws IOException { String[] filesInEnv = env.getHome().list(); SimpleDateFormat format = new SimpleDateFormat("yyyy_MM_dd_kk_mm_ss"); String recordFileName = "backupset-" + format.format(new Date()); File recordFile = new File(backupDir, recordFileName); if (recordFile.exists()) { recordFile.renameTo(new File(backupDir, recordFileName + ".old")); } PrintStream backupRecord = new PrintStream(new FileOutputStream(recordFile)); backupRecord.println("Lastfile:" + Long.toHexString(backupHelper.getLastFileInBackupSet())); if (filesInEnv != null) { for (String file : filesInEnv) { if (file.endsWith(BDB_EXT)) backupRecord.println(file); } } backupRecord.close(); }
69. ConfigurationPrinter#main()
Project: titan
File: ConfigurationPrinter.java
File: ConfigurationPrinter.java
public static void main(String args[]) throws FileNotFoundException, IllegalAccessException, NoSuchFieldException, ClassNotFoundException { ReflectiveConfigOptionLoader.INSTANCE.loadStandard(ConfigurationPrinter.class); // Write to filename argument if (3 != args.length) { System.err.println("Usage: " + ConfigurationPrinter.class.getName() + " <package.class.fieldname of a ConfigNamespace root> <output filename> <display mutabilities>"); System.exit(-1); } final ConfigNamespace root = stringToNamespace(args[0]); final PrintStream stream = new PrintStream(new FileOutputStream(args[1])); final boolean mutability = Boolean.valueOf(args[2]); new ConfigurationPrinter(stream, mutability).write(root); stream.flush(); stream.close(); }
70. MessageDigest#toString()
Project: checker-framework
File: MessageDigest.java
File: MessageDigest.java
/** * Returns a string representation of this message digest object. */ public String toString() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream p = new PrintStream(baos); p.print(algorithm + " Message Digest from " + provider.getName() + ", "); switch(state) { case INITIAL: p.print("<initialized>"); break; case IN_PROGRESS: p.print("<in progress>"); break; } p.println(); return (baos.toString()); }
71. SqlLineTest#checkScriptFile()
Project: calcite
File: SqlLineTest.java
File: SqlLineTest.java
/** * Attempts to execute a simple script file with the -f option to SqlLine. * Tests for presence of an expected pattern in the output (stdout or stderr). * * @param scriptText Script text * @param flag Command flag (--run or -f) * @param statusMatcher Checks whether status is as expected * @param outputMatcher Checks whether output is as expected * @throws Exception on command execution error */ private void checkScriptFile(String scriptText, boolean flag, Matcher<SqlLine.Status> statusMatcher, Matcher<String> outputMatcher) throws Throwable { // Put the script content in a temp file File scriptFile = File.createTempFile("foo", "temp"); scriptFile.deleteOnExit(); PrintStream os = new PrintStream(new FileOutputStream(scriptFile)); os.print(scriptText); os.close(); Pair<SqlLine.Status, String> pair = runScript(scriptFile, flag); // Check output before status. It gives a better clue what went wrong. assertThat(pair.right, outputMatcher); assertThat(pair.left, statusMatcher); final boolean delete = scriptFile.delete(); assertThat(delete, is(true)); }
72. DirtyPrintStreamDecoratorTest#testPrintlnObject()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testPrintlnObject() { PrintStream delegate = createMock(PrintStream.class); Object value = new Object(); delegate.println(value); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.println(value); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
73. DirtyPrintStreamDecoratorTest#testPrintlnString()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testPrintlnString() { PrintStream delegate = createMock(PrintStream.class); String value = "buck"; delegate.println(value); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.println(value); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
74. DirtyPrintStreamDecoratorTest#testPrintlnCharArray()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testPrintlnCharArray() { PrintStream delegate = createMock(PrintStream.class); char[] value = new char[] { 'a', 'p', 'p', 'l', 'e' }; delegate.println(value); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.println(value); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
75. DirtyPrintStreamDecoratorTest#testPrintlnDouble()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testPrintlnDouble() { PrintStream delegate = createMock(PrintStream.class); double value = Math.E; delegate.println(value); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.println(value); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
76. DirtyPrintStreamDecoratorTest#testPrintlnFloat()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testPrintlnFloat() { PrintStream delegate = createMock(PrintStream.class); float value = 2.718f; delegate.println(value); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.println(value); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
77. DirtyPrintStreamDecoratorTest#testPrintlnLong()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testPrintlnLong() { PrintStream delegate = createMock(PrintStream.class); long value = Long.MIN_VALUE; delegate.println(value); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.println(value); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
78. DirtyPrintStreamDecoratorTest#testPrintlnInt()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testPrintlnInt() { PrintStream delegate = createMock(PrintStream.class); int value = 144; delegate.println(value); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.println(value); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
79. DirtyPrintStreamDecoratorTest#testPrintlnChar()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testPrintlnChar() { PrintStream delegate = createMock(PrintStream.class); char value = 'z'; delegate.println(value); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.println(value); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
80. DirtyPrintStreamDecoratorTest#testPrintlnBoolean()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testPrintlnBoolean() { PrintStream delegate = createMock(PrintStream.class); boolean value = false; delegate.println(value); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.println(value); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
81. DirtyPrintStreamDecoratorTest#testPrintlnWithNoArguments()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testPrintlnWithNoArguments() { PrintStream delegate = createMock(PrintStream.class); delegate.println(); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.println(); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
82. DirtyPrintStreamDecoratorTest#testPrintObject()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testPrintObject() { PrintStream delegate = createMock(PrintStream.class); Object value = new Object(); delegate.print(value); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.print(value); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
83. DirtyPrintStreamDecoratorTest#testPrintString()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testPrintString() { PrintStream delegate = createMock(PrintStream.class); String value = "hello"; delegate.print(value); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.print(value); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
84. DirtyPrintStreamDecoratorTest#testPrintCharArray()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testPrintCharArray() { PrintStream delegate = createMock(PrintStream.class); char[] value = new char[] { 'h', 'e', 'l', 'l', 'o' }; delegate.print(value); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.print(value); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
85. DirtyPrintStreamDecoratorTest#testPrintDouble()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testPrintDouble() { PrintStream delegate = createMock(PrintStream.class); double value = Math.PI; delegate.print(value); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.print(value); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
86. DirtyPrintStreamDecoratorTest#testPrintFloat()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testPrintFloat() { PrintStream delegate = createMock(PrintStream.class); float value = 3.14f; delegate.print(value); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.print(value); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
87. DirtyPrintStreamDecoratorTest#testPrintLong()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testPrintLong() { PrintStream delegate = createMock(PrintStream.class); long value = Long.MAX_VALUE; delegate.print(value); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.print(value); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
88. DirtyPrintStreamDecoratorTest#testPrintInt()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testPrintInt() { PrintStream delegate = createMock(PrintStream.class); int value = 42; delegate.print(value); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.print(value); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
89. DirtyPrintStreamDecoratorTest#testPrintChar()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testPrintChar() { PrintStream delegate = createMock(PrintStream.class); char value = 'a'; delegate.print(value); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.print(value); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
90. DirtyPrintStreamDecoratorTest#testPrintBoolean()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testPrintBoolean() { PrintStream delegate = createMock(PrintStream.class); boolean value = true; delegate.print(value); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.print(value); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
91. DirtyPrintStreamDecoratorTest#testWriteBytesAndOffset()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testWriteBytesAndOffset() { PrintStream delegate = createMock(PrintStream.class); byte[] bytes = new byte[] { 65, 66, 67 }; delegate.write(bytes, 0, 3); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.write(bytes, 0, 3); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
92. DirtyPrintStreamDecoratorTest#testWriteBytes()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testWriteBytes() throws IOException { PrintStream delegate = createMock(PrintStream.class); byte[] bytes = new byte[] { 65, 66, 67 }; delegate.write(bytes); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.write(bytes); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
93. DirtyPrintStreamDecoratorTest#testWriteInt()
Project: buck
File: DirtyPrintStreamDecoratorTest.java
File: DirtyPrintStreamDecoratorTest.java
@Test public void testWriteInt() { PrintStream delegate = createMock(PrintStream.class); int n = 42; delegate.write(n); delegate.close(); EasyMock.expectLastCall().anyTimes(); replay(delegate); try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) { dirtyPrintStream.write(n); verify(delegate); assertTrue(dirtyPrintStream.isDirty()); } }
94. NetCDFServiceImpl#init()
Project: bioformats
File: NetCDFServiceImpl.java
File: NetCDFServiceImpl.java
private void init() throws IOException { String currentId = Location.getMappedId(currentFile); PrintStream outStream = System.out; PrintStream throwaway = new PrintStream(new ByteArrayOutputStream(), false, /*auto-flush*/ Constants.ENCODING) { @Override public void print(String s) { } }; System.setOut(throwaway); throwaway.close(); netCDFFile = NetcdfFile.open(currentId); System.setOut(outStream); root = netCDFFile.getRootGroup(); }
95. FunctionProjectUtil#addFileToProject()
Project: aws-toolkit-eclipse
File: FunctionProjectUtil.java
File: FunctionProjectUtil.java
private static File addFileToProject(IPath targetPath, String fileName, String fileContent) throws CoreException, FileNotFoundException { IFileStore targetFileStore = EFS.getLocalFileSystem().fromLocalFile(targetPath.append(fileName).toFile()); File targetFile = targetFileStore.toLocalFile(EFS.NONE, null); targetFile.getParentFile().mkdirs(); PrintStream ps = new PrintStream(new FileOutputStream(targetFile)); ps.print(fileContent); ps.close(); return targetFile; }
96. TestDistCh#runLsr()
Project: hadoop-common
File: TestDistCh.java
File: TestDistCh.java
private static String runLsr(final FsShell shell, String root, int returnvalue) throws Exception { System.out.println("root=" + root + ", returnvalue=" + returnvalue); final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); final PrintStream out = new PrintStream(bytes); final PrintStream oldOut = System.out; final PrintStream oldErr = System.err; System.setOut(out); System.setErr(out); final String results; try { assertEquals(returnvalue, shell.run(new String[] { "-lsr", root })); results = bytes.toString(); } finally { IOUtils.closeStream(out); System.setOut(oldOut); System.setErr(oldErr); } System.out.println("results:\n" + results); return results; }
97. TestDFSShell#runLsr()
Project: hadoop-common
File: TestDFSShell.java
File: TestDFSShell.java
private static String runLsr(final FsShell shell, String root, int returnvalue) throws Exception { System.out.println("root=" + root + ", returnvalue=" + returnvalue); final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); final PrintStream out = new PrintStream(bytes); final PrintStream oldOut = System.out; final PrintStream oldErr = System.err; System.setOut(out); System.setErr(out); final String results; try { assertEquals(returnvalue, shell.run(new String[] { "-lsr", root })); results = bytes.toString(); } finally { IOUtils.closeStream(out); System.setOut(oldOut); System.setErr(oldErr); } System.out.println("results:\n" + results); return results; }
98. TestDistCh#runLsr()
Project: hadoop-20
File: TestDistCh.java
File: TestDistCh.java
private static String runLsr(final FsShell shell, String root, int returnvalue) throws Exception { System.out.println("root=" + root + ", returnvalue=" + returnvalue); final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); final PrintStream out = new PrintStream(bytes); final PrintStream oldOut = System.out; final PrintStream oldErr = System.err; System.setOut(out); System.setErr(out); final String results; try { assertEquals(returnvalue, shell.run(new String[] { "-lsr", root })); results = bytes.toString(); } finally { IOUtils.closeStream(out); System.setOut(oldOut); System.setErr(oldErr); } System.out.println("results:\n" + results); return results; }
99. TestDFSShell#runLsCmd()
Project: hadoop-20
File: TestDFSShell.java
File: TestDFSShell.java
private static String runLsCmd(final FsShell shell, String root, int returnvalue, String cmd, String argument) throws Exception { System.out.println("root=" + root + ", returnvalue=" + returnvalue); final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); final PrintStream out = new PrintStream(bytes); final PrintStream oldOut = System.out; final PrintStream oldErr = System.err; System.setOut(out); System.setErr(out); final String results; try { if (argument != null) { assertEquals(returnvalue, shell.run(new String[] { cmd, argument, root })); } else { assertEquals(returnvalue, shell.run(new String[] { cmd, root })); } results = bytes.toString(); } finally { IOUtils.closeStream(out); System.setOut(oldOut); System.setErr(oldErr); } System.out.println("results:\n" + results); return results; }
100. DDLCompiler#compileToCatalog()
Project: h-store
File: DDLCompiler.java
File: DDLCompiler.java
public void compileToCatalog(Catalog catalog, Database db) throws VoltCompilerException { String hexDDL = Encoder.hexEncode(m_fullDDL); catalog.execute("set " + db.getPath() + " schema \"" + hexDDL + "\""); String xmlCatalog; try { xmlCatalog = m_hsql.getXMLFromCatalog(); } catch (HSQLParseException e) { String msg = "DDL Error: " + e.getMessage(); throw m_compiler.new VoltCompilerException(msg); } // output the xml catalog to disk PrintStream ddlXmlOutput = BuildDirectoryUtils.getDebugOutputPrintStream("schema-xml", "hsql-catalog-output.xml"); ddlXmlOutput.println(xmlCatalog); ddlXmlOutput.close(); // build the local catalog from the xml catalog fillCatalogFromXML(catalog, db, xmlCatalog); }