1 26 27 import com.opensugar.cube.Launcher; 28 import com.opensugar.cube.Util; 29 30 import java.io.File ; 31 import java.io.FileNotFoundException ; 32 import java.io.IOException ; 33 34 public class MainTest extends Main { 35 36 public static void main( String [] args ) throws Exception { 37 new MainTest( args ); 38 } 39 40 protected MainTest( String [] args ) { 41 if ( args.length != 1 ) { 42 usage(); 43 } 44 45 46 IOException exceptionWhileLoadingProperties = null; 47 try { 48 loadProperties(); 49 } 50 catch( IOException e ) { 51 exceptionWhileLoadingProperties = e; 52 } 53 54 FileNotFoundException exceptionWhileSettingSystemStreams = null; 55 try { 56 setSystemStreams(); 57 } 58 catch ( FileNotFoundException e ) { 59 exceptionWhileSettingSystemStreams = e; 60 } 61 62 65 if ( exceptionWhileLoadingProperties != null ) { 66 System.err.println( "Error while loading properties: " + exceptionWhileLoadingProperties.toString() ); 67 } 68 if ( exceptionWhileSettingSystemStreams != null ) { 69 System.err.println( "Error while setting system streams: " + exceptionWhileSettingSystemStreams.toString() ); 70 } 71 72 73 74 int charge = -1; 75 try { 76 charge = Integer.valueOf( args[ 0 ] ).intValue(); 77 } 78 catch ( Exception e ) { 79 usage(); 80 } 81 82 System.getProperties().put( "com.opensugar.cube.systemBundleJarFile", "lib/cube0.jar" ); 83 84 System.setProperty( "com.opensugar.cube.test", "" + true ); 85 if ( System.getProperty( "com.opensugar.cube.test.admin.port" ) == null ) { 86 System.setProperty( "com.opensugar.cube.test.admin.port", "" + 4000 ); 87 } 88 if ( System.getProperty( "com.opensugar.cube.test.telnet.port" ) == null ) { 89 System.setProperty( "com.opensugar.cube.test.telnet.port", "" + 6000 ); 90 } 91 if ( System.getProperty( "com.opensugar.cube.test.http.port" ) == null ) { 92 System.setProperty( "com.opensugar.cube.test.http.port", "" + 10000 ); 93 } 94 File refDir = new File ( "osc" ); 95 String baseDirBase = "osc"; 96 File dir; 97 for ( int i = 0; i < charge; i++ ) { 98 System.out.println( "####### " + i + " #######" ); 99 dir = new File ( baseDirBase + i ); 100 if ( !dir.exists() ) { 101 Util.recursiveFileCopy( refDir, dir ); 102 } 103 new Launcher( new File ( dir, "bs" ), null ); 105 } 106 107 Object obj = new Object (); 108 synchronized( obj ) { 109 try { 110 obj.wait(); 111 } 112 catch ( InterruptedException ignore ) {} 113 } 114 115 } 116 117 private class LauncherThread extends Thread { 118 private File baseDir; 119 public LauncherThread( File baseDir ) { 120 this.baseDir = baseDir; 121 } 122 public void run() { 123 new Launcher( baseDir, null ); 124 } 125 } 126 127 private static void usage() { 128 System.out.println( "Usage:" ); 129 System.out.println( "\tjava MainTest n" ); 130 System.out.println( "\t\t n must be an integer (number of cubes to start)" ); 131 132 System.exit( 1 ); 133 } 134 135 } 136 | Popular Tags |