1 package org.tanukisoftware.wrapper.test;
2 
3 /*
4  * Copyright (c) 1999, 2021 Tanuki Software, Ltd.
5  * http://www.tanukisoftware.com
6  * All rights reserved.
7  *
8  * This software is the proprietary information of Tanuki Software.
9  * You shall use it only in accordance with the terms of the
10  * license agreement you entered into with Tanuki Software.
11  * http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html
12  *
13  *
14  * Portions of the Software have been derived from source code
15  * developed by Silver Egg Technology under the following license:
16  *
17  * Copyright (c) 2001 Silver Egg Technology
18  *
19  * Permission is hereby granted, free of charge, to any person
20  * obtaining a copy of this software and associated documentation
21  * files (the "Software"), to deal in the Software without
22  * restriction, including without limitation the rights to use,
23  * copy, modify, merge, publish, distribute, sub-license, and/or
24  * sell copies of the Software, and to permit persons to whom the
25  * Software is furnished to do so, subject to the following
26  * conditions:
27  *
28  * The above copyright notice and this permission notice shall be
29  * included in all copies or substantial portions of the Software.
30  */
31 
32 /**
33  * Tests Bug #531880 where % characters in the text output were causing
34  *  the wrapper to crash.
35  *
36  * @author Tanuki Software Development Team <support@tanukisoftware.com>
37  */
38 public class PercentOutput {
39     /*---------------------------------------------------------------
40      * Main Method
41      *-------------------------------------------------------------*/
main(String[] args)42     public static void main(String[] args) {
43         System.out.println( Main.getRes().getString( "Starting Test..." ) );
44         System.out.println( "%");
45         System.out.println("%%");
46         System.out.println("%s");
47         System.out.println("%S");
48         System.out.println("%d");
49         System.out.println("\\%s%%");
50         System.out.println("\\%S%%");
51 
52         // This is a case from a user crash
53         System.out.println("         and vg.foobar like '%SEARCHKEY=vendorid%'");
54 
55         // Lots more output mixed with various quotes.
56         //  This will test the code that causes the internal buffer to be expanded.
57         for ( int i = 0; i < 100; i++ )
58         {
59             StringBuffer sb = new StringBuffer();
60             sb.append( i );
61             sb.append( ": " );
62             for ( int j = 0; j < i; j++ )
63             {
64                 sb.append( ":01234567890123456%s90123456789012345%d890123456789012345%S8901234%%789012%S5678901234%p789012345678" );
65             }
66             sb.append( ":END" );
67             System.out.println( sb.toString() );
68         }
69 
70         System.out.println( Main.getRes().getString( "Test Complete..." ) );
71     }
72 }
73 
74