Definition at line 49 of file CodecTest.java.
Static Public Member Functions | |
| static void | main (String[] args) |
Static Package Functions | |
| static byte[] | readData (String filename) |
| static boolean | writeData (String filename, byte[] data) |
Static Private Attributes | |
| static final Logger | LOGGER = Logger.getLogger(CodecTest.class) |
| The logger. | |
| static byte [] de.fhg.fokus.diameter.DiameterPeer.data.CodecTest.readData | ( | String | filename | ) | [static, package] |
Definition at line 54 of file CodecTest.java.
Referenced by de.fhg.fokus.diameter.DiameterPeer.data.CodecTest.main().
00055 { 00056 FileInputStream fin; 00057 byte[] b = null; 00058 int count = 0; 00059 int len; 00060 try { 00061 fin = new FileInputStream(filename); 00062 len = fin.available(); 00063 b = new byte[len]; 00064 count = fin.read(b); 00065 if (count == -1) b = null; 00066 } catch (FileNotFoundException e) { 00067 // TODO Auto-generated catch block 00068 e.printStackTrace(); 00069 } catch (IOException e) { 00070 // TODO Auto-generated catch block 00071 e.printStackTrace(); 00072 } 00073 return b; 00074 }
| static boolean de.fhg.fokus.diameter.DiameterPeer.data.CodecTest.writeData | ( | String | filename, | |
| byte[] | data | |||
| ) | [static, package] |
Definition at line 75 of file CodecTest.java.
Referenced by de.fhg.fokus.diameter.DiameterPeer.data.CodecTest.main().
00076 { 00077 FileOutputStream fout; 00078 try { 00079 File f = new File(filename); 00080 if (!f.exists()) f.createNewFile(); 00081 fout = new FileOutputStream(f); 00082 fout.write(data); 00083 fout.close(); 00084 return true; 00085 } catch (FileNotFoundException e) { 00086 // TODO Auto-generated catch block 00087 e.printStackTrace(); 00088 } catch (IOException e) { 00089 // TODO Auto-generated catch block 00090 e.printStackTrace(); 00091 } 00092 return false; 00093 }
| static void de.fhg.fokus.diameter.DiameterPeer.data.CodecTest.main | ( | String[] | args | ) | [static] |
Definition at line 95 of file CodecTest.java.
References de.fhg.fokus.diameter.DiameterPeer.data.CodecTest.LOGGER, de.fhg.fokus.diameter.DiameterPeer.data.CodecTest.readData(), and de.fhg.fokus.diameter.DiameterPeer.data.CodecTest.writeData().
00095 { 00096 DiameterMessage msg = null; 00097 byte[] original={},bootstrapped={}; 00098 long duration; 00099 int repeat = 1000000; 00100 if (args.length<1) { 00101 LOGGER.debug("No input file specified. Please specify it as first parameter!"); 00102 System.exit(-1); 00103 } 00104 if (args.length<2) { 00105 LOGGER.debug("No output file specified. Please specify it as second parameter!"); 00106 System.exit(-1); 00107 } 00108 original = readData(args[0]); 00109 if (original==null){ 00110 LOGGER.debug("Error reading data from file. Aborting!"); 00111 System.exit(-1); 00112 } 00113 duration = System.currentTimeMillis(); 00114 try { 00115 for(int i=0;i<repeat;i++) 00116 msg = Codec.decodeDiameterMessage(original,0); 00117 } catch (DiameterMessageDecodeException e) { 00118 // TODO Auto-generated catch block 00119 e.printStackTrace(); 00120 LOGGER.debug("Error decoding AVP. Aborting!"); 00121 System.exit(-1); 00122 } 00123 // try { 00124 // for(int i=0;i<repeat;i++) 00125 // avp.ungroup(); 00126 // } catch (AVPDecodeException e1) { 00127 // // TODO Auto-generated catch block 00128 // e1.printStackTrace(); 00129 // LOGGER.debug("Error Ungrouping AVP. Aborting!"); 00130 // System.exit(-1); 00131 // } 00132 for(int i=0;i<repeat;i++) 00133 bootstrapped = Codec.encodeDiameterMessage(msg); 00134 00135 duration = System.currentTimeMillis() - duration; 00136 00137 LOGGER.debug("Speed: "+repeat/duration*1000+" ops/sec"); 00138 LOGGER.debug(msg); 00139 00140 bootstrapped = Codec.encodeDiameterMessage(msg); 00141 if (!writeData(args[1],bootstrapped)){ 00142 LOGGER.debug("Error writing data to file. Aborting!"); 00143 System.exit(-1); 00144 } 00145 if (Arrays.equals(original,bootstrapped)){ 00146 LOGGER.debug("Bootstrapping Succesfull..."); 00147 } 00148 else{ 00149 LOGGER.debug("Bootstrapping failed!"); 00150 System.exit(-1); 00151 } 00152 00153 /* Test of AVP creation */ 00154 // avp = new AVP(123,false,16777216); 00155 // avp.setData("Bubu was here"); 00156 // bootstrapped = AVP.encode(avp); 00157 // if (!writeData(args[1],bootstrapped)){ 00158 // LOGGER.debug("Error writing data to file. Aborting!"); 00159 // System.exit(-1); 00160 // } 00161 00162 00163 }
final Logger de.fhg.fokus.diameter.DiameterPeer.data.CodecTest.LOGGER = Logger.getLogger(CodecTest.class) [static, private] |
The logger.
Definition at line 52 of file CodecTest.java.
Referenced by de.fhg.fokus.diameter.DiameterPeer.data.CodecTest.main().
1.5.2