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  import java.util.Arrays;
19  
20  import com.eviware.soapui.impl.wsdl.MutableTestPropertyHolder;
21  import com.eviware.soapui.model.TestPropertyHolder;
22  import com.eviware.soapui.model.testsuite.TestProperty;
23  
24  public class TestPropertyUtils
25  {
26  	public static int saveTo( TestPropertyHolder propertyHolder, String fileName ) throws IOException
27  	{
28  		PrintWriter writer = new PrintWriter( new FileWriter( fileName ) );
29  
30  		for( TestProperty prop : propertyHolder.getPropertyList() )
31  		{
32  			writer.print( prop.getName() );
33  			writer.print( '=' );
34  			String value = prop.getValue();
35  			if( value == null )
36  				value = "";
37  
38  			String[] lines = value.split( "\n" );
39  			for( int c = 0; c < lines.length; c++ )
40  			{
41  				if( c > 0 )
42  					writer.println( "//" );
43  				writer.print( lines[c] );
44  			}
45  
46  			writer.println();
47  		}
48  
49  		writer.close();
50  		return propertyHolder.getPropertyCount();
51  	}
52  
53  	public synchronized static void sortProperties( MutableTestPropertyHolder holder )
54  	{
55  	}
56  }