View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2009 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
11   */
12  
13  package com.eviware.soapui.model.support;
14  
15  import java.io.FileWriter;
16  import java.io.IOException;
17  import java.io.PrintWriter;
18  
19  import com.eviware.soapui.model.TestPropertyHolder;
20  import com.eviware.soapui.model.testsuite.TestProperty;
21  
22  public class TestPropertyUtils
23  {
24  	public static int saveTo( TestPropertyHolder propertyHolder, String fileName ) throws IOException
25  	{
26  		PrintWriter writer = new PrintWriter( new FileWriter( fileName ));
27  		
28  		for( TestProperty prop : propertyHolder.getPropertyList() )
29  		{
30  			writer.print( prop.getName() );
31  			writer.print('=');
32  			String[] lines = prop.getValue().split( "\n" );
33  			for( int c = 0; c < lines.length; c++ )
34  			{
35  				if( c > 0 )
36  					writer.println( "//" );
37  				writer.print( lines[c] );
38  			}
39  			
40  			writer.println();
41  		}
42  		
43  		writer.close();
44  		return propertyHolder.getPropertyCount();
45  	}
46  }