public void testSendPage_spacekey()

in src/main/java/com/atlassian/uwc/ui/ConverterEngineTest.java [1091:1187]


	public void testSendPage_spacekey() {
		//create a space test
		Page page = new Page(null);
		String parentid = "0"; //XXX I don't think this settings currently matters?
		ConfluenceServerSettings confsettings = new ConfluenceServerSettings();
		String testpropslocation = "test.basic.properties";
		loadSettingsFromFile(confsettings, testpropslocation);
		UWCUserSettings settings = new UWCUserSettings();
		settings.setLogin(confsettings.login);
		settings.setUrl(confsettings.url);
		settings.setPassword(confsettings.password);
		settings.setSpace("uwctest"); //wrong space - this will be overridden by the page settings
		String title = "Test In New Space"; //Might as well use "Home". There's always a home.
		String spacekey = "testspace";
		page.setName(title);
		String spacename = "New Test Space";
		String spacedesc = "This is a test space tada!";
		page.setSpace(spacekey, spacename, spacedesc);
		
		RemoteWikiBroker broker = RemoteWikiBroker.getInstance();
		PageForXmlRpc startPage = null;
		//check that space does not exists
		try {
			SpaceForXmlRpc space = broker.getSpace(confsettings, spacekey);
			assertNull(space); //this will fail if the space is not deleted before the test
		} catch (Exception e) {
			e.printStackTrace();
			fail();
		}
		//change content
		//send page with changed content 
		String testcontent = "Testing adding page to new space";
		page.setConvertedText(testcontent);
		tester.sendPage(page, parentid, settings);
		
		//get page
		PageForXmlRpc endPage = null;
		String id = null;
		try {
			//test space was created
			SpaceForXmlRpc space = broker.getSpace(confsettings, spacekey);
			assertNotNull(space);
			assertNotNull(space.getSpaceName());
			assertEquals(spacename, space.getSpaceName());
			assertNotNull(space.getDescription());
			assertEquals(spacedesc, space.getDescription());
			
			//test page was created
			id = broker.getPageIdFromConfluence(confsettings, spacekey, title);
			endPage = broker.getPage(confsettings, id);
			assertNotNull(endPage);
			assertEquals(title, endPage.getTitle());
			//test that content is the new content
			String newcontent = endPage.getContent();
			assertNotNull(newcontent);
			assertEquals(testcontent, newcontent);
			
		} catch (Exception e) {
			e.printStackTrace();
			fail();
		} finally {
			deletePage(id, confsettings);
		}
		
		//use the created space
		page.setName(title);
		String spacename2 = "New Test Space 2"; //shouldn't be changed. space will already exist at this point.
		page.setSpace(spacekey, spacename2, spacedesc);
		tester.sendPage(page, parentid, settings);
		//get page
		endPage = null;
		id = null;
		try {
			//test space was created
			SpaceForXmlRpc space = broker.getSpace(confsettings, spacekey);
			assertNotNull(space);
			assertNotNull(space.getSpaceName());
			assertEquals(spacename, space.getSpaceName()); //compare against original space name, not new one.
			
			//test page was created
			id = broker.getPageIdFromConfluence(confsettings, spacekey, title);
			endPage = broker.getPage(confsettings, id);
			assertNotNull(endPage);
			assertEquals(title, endPage.getTitle());
			//test that content is the new content
			String newcontent = endPage.getContent();
			assertNotNull(newcontent);
			assertEquals(testcontent, newcontent);
			
		} catch (Exception e) {
			e.printStackTrace();
			fail();
		} finally {
			deletePage(id, confsettings);
		}
		
	}