1   /*
2    *  soapUI, copyright (C) 2004-2008 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.impl;
14  
15  import java.io.File;
16  
17  import junit.framework.TestCase;
18  
19  import com.eviware.soapui.impl.wsdl.WsdlProject;
20  
21  public class WorkspaceImplTestCase extends TestCase
22  {
23  	@Override
24  	protected void setUp() throws Exception
25  	{
26  		File file = new File( "test-workspace.xml");
27  		if( file.exists() )
28  			file.delete();
29  		
30  		file = new File( "test-project.xml");
31  		if( file.exists() )
32  			file.delete();
33  	}
34  
35  	public void testProjectRoot() throws Exception
36  	{
37  		File wsFile = new File( "test-workspace.xml");
38  		WorkspaceImpl ws = new WorkspaceImpl( wsFile.getAbsolutePath(), null );
39  		
40  		WsdlProject project = ws.createProject( "Test Project", null );
41  		project.saveAs(new File("test-project.xml").getAbsolutePath() );
42  		
43  		ws.save(false);
44  		ws.switchWorkspace(wsFile);
45  		assertEquals(1, ws.getProjectCount());
46  		assertEquals("Test Project", ws.getProjectAt( 0 ).getName());
47  		
48  		ws.setProjectRoot("${workspaceDir}");
49  
50  		ws.save(false);
51  
52  		ws.switchWorkspace(wsFile);
53  		assertEquals("${workspaceDir}",ws.getProjectRoot() );
54  		assertEquals(1, ws.getProjectCount());
55  		assertEquals("Test Project", ws.getProjectAt( 0 ).getName());
56  	}
57  }