1 23 24 package org.objectweb.clif.console.lib; 25 26 27 import java.io.OutputStream ; 28 import java.io.IOException ; 29 import java.util.Map ; 30 import java.util.Iterator ; 31 import java.util.Properties ; 32 33 34 38 public class TestPlanWriter 39 { 40 static public void write2prop(OutputStream out, Map testPlan) 41 throws IOException 42 { 43 TestPlanWriter writer = new TestPlanWriter(out); 44 writer.write2prop(testPlan); 45 writer.close(); 46 } 47 48 49 OutputStream out; 50 51 52 public TestPlanWriter(OutputStream out) 53 { 54 this.out = out; 55 } 56 57 58 public void close() 59 throws IOException 60 { 61 out.close(); 62 } 63 64 65 public void flush() 66 throws IOException 67 { 68 out.flush(); 69 } 70 71 72 public void write2prop(Map testPlan) 73 throws IOException 74 { 75 Iterator entries = testPlan.entrySet().iterator(); 76 int n = 0; 77 Properties props = new Properties (); 78 while (entries.hasNext()) 79 { 80 Map.Entry entry = (Map.Entry )entries.next(); 81 String prefix = TestPlanReader.BLADE_PROP + "." + n++ + "."; 82 props.setProperty(prefix + TestPlanReader.ID_PROP, (String )entry.getKey()); 83 ClifDeployDefinition def = (ClifDeployDefinition)entry.getValue(); 84 if (def.isProbe()) 85 { 86 props.setProperty( 87 prefix + TestPlanReader.PROBE_PROP, 88 (String )def.getContext().get("insert")); 89 } 90 else 91 { 92 props.setProperty( 93 prefix + TestPlanReader.INJECTOR_PROP, 94 (String )def.getContext().get("insert")); 95 } 96 props.setProperty(prefix + TestPlanReader.SERVER_PROP, def.getServerName()); 97 props.setProperty(prefix + TestPlanReader.ARGUMENT_PROP, def.getArgument()); 98 props.setProperty(prefix + TestPlanReader.COMMENT_PROP, def.getComment()); 99 } 100 props.store(out, "CLIF test plan"); 101 } 102 } 103 | Popular Tags |