[jbosstools-commits] JBoss Tools SVN: r43800 - in trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot: ext and 3 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue Sep 18 11:21:45 EDT 2012


Author: apodhrad
Date: 2012-09-18 11:21:45 -0400 (Tue, 18 Sep 2012)
New Revision: 43800

Added:
   trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/ext/
   trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/ext/dialog/
   trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/ext/dialog/ModeshapePublishDialog.java
   trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/ext/dialog/ModeshapeServerDialog.java
   trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/ext/view/
   trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/ext/view/ModeshapeProjectExplorer.java
   trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/ext/view/ModeshapeView.java
Modified:
   trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/Publishing.java
Log:
JBQA-6489 fix

Added: trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/ext/dialog/ModeshapePublishDialog.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/ext/dialog/ModeshapePublishDialog.java	                        (rev 0)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/ext/dialog/ModeshapePublishDialog.java	2012-09-18 15:21:45 UTC (rev 43800)
@@ -0,0 +1,68 @@
+package org.jboss.tools.modeshape.rest.ui.bot.ext.dialog;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.jboss.tools.ui.bot.ext.wizards.SWTBotWizard;
+
+/**
+ * 
+ * This class represents dialog for publishing/unpublishing files to/from the
+ * server.
+ * 
+ * @author apodhrad
+ * 
+ */
+public class ModeshapePublishDialog extends SWTBotWizard {
+
+	public static final String LABEL_SERVER = "Server:";
+	public static final String LABEL_JCR_REPOSITORY = "JCR Repository:";
+	public static final String LABEL_JCR_WORKSPACE = "JCR Workspace:";
+	public static final String LABEL_PUBLISH_AREA = "Publish Area:";
+
+	public ModeshapePublishDialog(SWTBotShell dialog) {
+		super(dialog.activate().widget);
+	}
+
+	public void setServer(String server) {
+		getComboBox(LABEL_SERVER).setSelection(server);
+	}
+
+	public String getServer() {
+		return getComboBox(LABEL_SERVER).getText();
+	}
+
+	public void setJcrRepository(String repository) {
+		getComboBox(LABEL_JCR_REPOSITORY).setSelection(repository);
+	}
+
+	public String getJcrRepository() {
+		return getComboBox(LABEL_JCR_REPOSITORY).getText();
+	}
+
+	public void setJcrWorkspace(String workspace) {
+		getComboBox(LABEL_JCR_WORKSPACE).setSelection(workspace);
+	}
+
+	public String getJcrWorkspace() {
+		return getComboBox(LABEL_JCR_WORKSPACE).getText();
+	}
+
+	public void setPublishArea(String publishArea) {
+		getComboBox(LABEL_PUBLISH_AREA).setText(publishArea);
+	}
+
+	public String getPublishArea() {
+		return getComboBox(LABEL_PUBLISH_AREA).getText();
+	}
+
+	private SWTBotCombo getComboBox(String label) {
+		return bot().comboBoxWithLabel(label);
+	}
+
+	public List<String> getComboBoxList(String label) {
+		return Arrays.asList(getComboBox(label).items());
+	}
+}

Added: trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/ext/dialog/ModeshapeServerDialog.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/ext/dialog/ModeshapeServerDialog.java	                        (rev 0)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/ext/dialog/ModeshapeServerDialog.java	2012-09-18 15:21:45 UTC (rev 43800)
@@ -0,0 +1,64 @@
+package org.jboss.tools.modeshape.rest.ui.bot.ext.dialog;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.jboss.tools.ui.bot.ext.wizards.SWTBotWizard;
+
+/**
+ * 
+ * This class represents dialog for setting the modeshape server.
+ * 
+ * @author apodhrad
+ * 
+ */
+public class ModeshapeServerDialog extends SWTBotWizard {
+
+	public static final String LABEL_URL = "URL:";
+	public static final String LABEL_USER = "User:";
+	public static final String LABEL_PASSWORD = "Password:";
+
+	public ModeshapeServerDialog(SWTBotShell dialog) {
+		super(dialog.activate().widget);
+	}
+
+	public String getUrl() {
+		return getTextField(LABEL_URL).getText();
+	}
+
+	public void setUrl(String url) {
+		getTextField(LABEL_URL).setText(url);
+	}
+
+	public String getUser() {
+		return getTextField(LABEL_USER).getText();
+	}
+
+	public void setUser(String user) {
+		getTextField(LABEL_USER).setText(user);
+	}
+
+	public String getPassword() {
+		return getTextField(LABEL_PASSWORD).getText();
+	}
+
+	public void setPassword(String password) {
+		getTextField(LABEL_PASSWORD).setText(password);
+	}
+
+	public boolean testServerConnection() {
+		clickButton("Test");
+
+		SWTBotShell shell = bot().shell("Test Server Connection");
+		shell.activate();
+		String message = shell.bot().label(1).getText();
+		shell.bot().button("OK").click();
+
+		activate();
+		return message.equals("Successfully connected using the specified server properties.");
+	}
+
+	private SWTBotText getTextField(String label) {
+		return bot().textWithLabel(label);
+	}
+
+}

Added: trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/ext/view/ModeshapeProjectExplorer.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/ext/view/ModeshapeProjectExplorer.java	                        (rev 0)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/ext/view/ModeshapeProjectExplorer.java	2012-09-18 15:21:45 UTC (rev 43800)
@@ -0,0 +1,32 @@
+package org.jboss.tools.modeshape.rest.ui.bot.ext.view;
+
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.view.ProjectExplorer;
+
+/**
+ * 
+ * This class represents an extension of Project Explorer. The extension refers
+ * to modeshape context menu.
+ * 
+ * @author apodhrad
+ * 
+ */
+public class ModeshapeProjectExplorer extends ProjectExplorer {
+
+	public void publish(String file, String... path) {
+		contextMenu(file, "Publish", path);
+	}
+
+	public void unpublish(String file, String... path) {
+		contextMenu(file, "Unpublish", path);
+	}
+
+	public void showPublishedLocations(String file, String... path) {
+		contextMenu(file, "Show Published Locations", path);
+	}
+
+	private void contextMenu(String file, String selection, String... path) {
+		selectTreeItem(file, path);
+		ContextMenuHelper.clickContextMenu(bot().tree(), "ModeShape", selection);
+	}
+}

Added: trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/ext/view/ModeshapeView.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/ext/view/ModeshapeView.java	                        (rev 0)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/ext/view/ModeshapeView.java	2012-09-18 15:21:45 UTC (rev 43800)
@@ -0,0 +1,72 @@
+package org.jboss.tools.modeshape.rest.ui.bot.ext.view;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.modeshape.rest.ui.bot.ext.dialog.ModeshapeServerDialog;
+import org.jboss.tools.ui.bot.ext.gen.IView;
+import org.jboss.tools.ui.bot.ext.view.ViewBase;
+
+/**
+ * 
+ * This class represents the ModeShape view.
+ * 
+ * @author apodhrad
+ * 
+ */
+public class ModeshapeView extends ViewBase {
+
+	public static final String TOOLBAR_ADD_SERVER = "Create a new server";
+	public static final String TOOLBAR_EDIT_SERVER = "Edit server properties";
+	public static final String TOOLBAR_DELETE_SERVER = "Delete server from the server registry";
+	public static final String TOOLBAR_RECONNECT_SERVER = "Reconnect to the selected server";
+
+	public ModeshapeView() {
+		viewObject = new IView() {
+			public String getName() {
+				return "ModeShape";
+			}
+
+			public List<String> getGroupPath() {
+				List<String> list = new Vector<String>();
+				list.add("ModeShape");
+				return list;
+			}
+		};
+	}
+
+	public void toolbarButtonClick(String toolTip) {
+		getToolbarButtonWitTooltip(toolTip).click();
+	}
+
+	public ModeshapeServerDialog addServer() {
+		getToolbarButtonWitTooltip("Create a new server").click();
+		return new ModeshapeServerDialog(bot.shell("New Server"));
+	}
+
+	public List<String> getServers() {
+		List<String> servers = new ArrayList<String>();
+		for (SWTBotTreeItem server : bot().tree().getAllItems()) {
+			if (server.isVisible()) {
+				servers.add(server.getText());
+			}
+		}
+		return servers;
+	}
+
+	public boolean containsServer(String serverName) {
+		return getServers().contains(serverName);
+	}
+
+	public void selectServer(String serverName) {
+		bot().tree().getTreeItem(serverName).select();
+	}
+
+	public void deleteServer(String serverName) {
+		selectServer(serverName);
+		toolbarButtonClick(TOOLBAR_DELETE_SERVER);
+		bot.shell("Confirm Delete Server").bot().button("OK").click();
+	}
+}

Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/Publishing.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/Publishing.java	2012-09-18 15:21:26 UTC (rev 43799)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/Publishing.java	2012-09-18 15:21:45 UTC (rev 43800)
@@ -1,288 +1,189 @@
 package org.jboss.tools.modeshape.rest.ui.bot.tests;
 
-
 import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.net.HttpURLConnection;
 import java.net.URL;
+
 import org.eclipse.core.internal.preferences.Base64;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
+import org.jboss.tools.modeshape.rest.ui.bot.ext.dialog.ModeshapePublishDialog;
+import org.jboss.tools.modeshape.rest.ui.bot.ext.dialog.ModeshapeServerDialog;
+import org.jboss.tools.modeshape.rest.ui.bot.ext.view.ModeshapeProjectExplorer;
+import org.jboss.tools.modeshape.rest.ui.bot.ext.view.ModeshapeView;
 import org.jboss.tools.ui.bot.ext.SWTTestExt;
-import org.jboss.tools.ui.bot.ext.SWTUtilExt;
 import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
 import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
 import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
 import org.jboss.tools.ui.bot.ext.config.Annotations.ServerType;
-import org.jboss.tools.ui.bot.ext.gen.ActionItem;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.GeneralFile;
 import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.GeneralProject;
 import org.jboss.tools.ui.bot.ext.types.IDELabel;
-import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.wizards.SWTBotNewObjectWizard;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-
 /**
  * 
  * @author psrna
- *
+ * @author apodhrad
+ * 
  */
- at Require(server=@Server(type=ServerType.ALL, state=ServerState.Running),perspective="Java EE")
-public class Publishing extends SWTTestExt{
-	
-	private static final String CONNERR_MSG = "Unable to connect using the specified server properties." +
-    										  "The server properties could be invalid or the server may be offline.";
-	
-	
-	public static void createResource(){
-		
-		SWTBot wiz = open.newObject(ActionItem.NewObject.GeneralProject.LABEL);
-		wiz.textWithLabel(GeneralProject.TEXT_PROJECT_NAME).setText(Properties.PROJECT_NAME);
-		open.finish(wiz);
-		assertTrue(projectExplorer.existsResource(Properties.PROJECT_NAME));
-		
-		wiz = open.newObject(ActionItem.NewObject.GeneralFile.LABEL);
-		wiz.tree().select(Properties.PROJECT_NAME);
-		wiz.textWithLabel(ActionItem.NewObject.GeneralFile.TEXT_FILE_NAME).setText(Properties.FILE_NAME);
-		open.finish(wiz);
-		assertTrue(projectExplorer.isFilePresent(Properties.PROJECT_NAME, Properties.FILE_NAME));	
-		
-		bot.editorByTitle(Properties.FILE_NAME).close();
-		
-		String projectLocation = SWTUtilExt.getPathToProject(Properties.PROJECT_NAME);
-		try {
-			FileWriter fstream = new FileWriter(projectLocation + "/" + Properties.FILE_NAME);
-			BufferedWriter out = new BufferedWriter(fstream);
-			out.write(Properties.FILE_CONTENT);
-			out.close();
-		} catch (IOException e) {
-			fail("Unable to write to file.");
-			log.error(e.getMessage());
-		}
-		
-		bot.viewByTitle("Project Explorer").show();
-		bot.viewByTitle("Project Explorer").setFocus();
-		SWTBot viewBot = bot.viewByTitle("Project Explorer").bot();
-		
-		SWTBotTreeItem node = SWTEclipseExt.selectTreeLocation(viewBot, Properties.PROJECT_NAME);
+ at Require(server = @Server(type = ServerType.ALL, state = ServerState.Running), perspective = "Java EE")
+public class Publishing extends SWTTestExt {
 
-		ContextMenuHelper.prepareTreeItemForContextMenu(viewBot.tree(), node);
-		ContextMenuHelper.clickContextMenu(viewBot.tree(), "Refresh");
+	public static final String SERVER_REST_URL = "http://localhost:8080/modeshape-rest";
+	public static final String SERVER_WEBDAV_URL = "http://localhost:8080/modeshape-webdav";
+	public static final String PROJECT_NAME = "testproject";
+	public static final String FILE_NAME = "testfile.txt";
+	public static final String FILE_CONTENT = "testcontent";
+	public static final String PUBLISH_URL = SERVER_REST_URL + "/repository/default/items/files/"
+			+ PROJECT_NAME + "/" + FILE_NAME;
+	public static final String PUBLISH_WEB_URL = SERVER_WEBDAV_URL
+			+ "/repository/default/files/" + PROJECT_NAME + "/" + FILE_NAME;
 
-	}
-	
+	private static final ModeshapeProjectExplorer modeshapeExplorer = new ModeshapeProjectExplorer();
+
 	@BeforeClass
-	public static void beforeClass(){
-		createResource();
+	public static void createTestFile() {
+		// Create a general project
+		SWTBotNewObjectWizard projectWizard = new SWTBotNewObjectWizard();
+		projectWizard.open(GeneralProject.LABEL);
+		projectWizard.bot().textWithLabel(GeneralProject.TEXT_PROJECT_NAME).setText(PROJECT_NAME);
+		projectWizard.finishWithWait();
+		// Create a file
+		SWTBotNewObjectWizard fileWizard = new SWTBotNewObjectWizard();
+		fileWizard.open(GeneralFile.LABEL);
+		fileWizard.bot().textWithLabel(GeneralFile.TEXT_FILE_NAME).setText(FILE_NAME);
+		fileWizard.finishWithWait();
+		// Edit the file
+		SWTBotEclipseEditor fileEditor = projectExplorer.openFile(PROJECT_NAME, FILE_NAME)
+				.toTextEditor();
+		fileEditor.setText(FILE_CONTENT);
+		fileEditor.saveAndClose();
+
+		assertTrue("The test file wasn't created!",
+				projectExplorer.isFilePresent(PROJECT_NAME, FILE_NAME));
 	}
-	
-	
+
 	@Test
-	public void createModeShapeServer(){
+	public void createModeShapeServer() {
+		ModeshapeView modeshapeView = new ModeshapeView();
+		modeshapeView.show();
+		ModeshapeServerDialog dialog = modeshapeView.addServer();
+		dialog.setUrl(SERVER_REST_URL);
+		dialog.setUser("admin");
+		dialog.setPassword("admin");
+		assertTrue("Couldn't connect to the server", dialog.testServerConnection());
+		dialog.finishWithWait();
+		assertTrue("Created server not visible in ModeShape view.",
+				modeshapeView.containsServer(SERVER_REST_URL));
+	}
 
-		openModeshapeView();
+	@Test
+	public void publishFile() {
+		modeshapeExplorer.publish(FILE_NAME, PROJECT_NAME);
 
-		SWTBotView view = bot.viewByTitle("ModeShape");
-		assertTrue("ModeShape View must be active", view.isActive());
+		ModeshapePublishDialog publishDialog = new ModeshapePublishDialog(
+				bot.shell("Publish to ModeShape"));
 
-		view.toolbarButton("Create a new server").click();
-		SWTBotShell shell = bot.shell("New Server");
-		shell.activate();
+		assertEquals(SERVER_REST_URL, publishDialog.getServer());
+		assertTrue(publishDialog.canFinish());
+		publishDialog.finishWithWait();
 
-		shell.bot().textWithLabel("URL:").setText(Properties.URL);
-		shell.bot().textWithLabel("User:").setText(Properties.USER);
-		shell.bot().textWithLabel("Password:").setText(Properties.PASSWORD);
+		assertTrue("HTTP Response code must be 200 after publishing.",
+				HttpURLConnection.HTTP_OK == testPublishedFile());
+	}
 
-		shell.bot().button("Test").click();
-		shell = bot.shell("Test Server Connection");
-		shell.activate();
+	@Test
+	public void publishedLocations() {
+		modeshapeExplorer.showPublishedLocations(FILE_NAME, PROJECT_NAME);
 
-		String msg = shell.bot().label(1).getText();
-		assertTrue(CONNERR_MSG, msg.equals("Successfully connected using the specified server properties."));
-
-		open.finish(bot.activeShell().bot(), IDELabel.Button.OK);
-		shell = bot.shell("New Server");
+		SWTBotShell shell = bot.shell("Published Locations");
 		shell.activate();
 
-		open.finish(shell.bot()); 
+		SWTBotTable table = shell.bot().table();
+		assertEquals(SERVER_REST_URL, table.cell(0, 0));
+		assertEquals("admin", table.cell(0, 1));
+		assertEquals("repository", table.cell(0, 2));
+		assertEquals("default", table.cell(0, 3));
+		assertEquals(PUBLISH_URL, table.cell(0, 4));
 
-		assertTrue("Created server not visible in ModeShape view.", view.bot().tree().getTreeItem(Properties.URL).isVisible());	
-			
-	}
-		
-	private void openModeshapeView(){
-		
-		bot.menu(IDELabel.Menu.WINDOW)
-		   .menu(IDELabel.Menu.SHOW_VIEW)
-		   .menu(IDELabel.Menu.OTHER).click();		
+		open.finish(shell.bot(), IDELabel.Button.OK);
 
-		SWTBotShell shell = bot.shell("Show View");
-		shell.activate();
-		shell.bot().tree().expandNode("ModeShape", false).select("ModeShape");
-
-		open.finish(bot.activeShell().bot(), IDELabel.Button.OK);
 	}
-	
 
 	@Test
-	public void publishFile(){
+	public void unpublishFile() {
+		modeshapeExplorer.unpublish(FILE_NAME, PROJECT_NAME);
 
-		SWTBotView view = bot.viewByTitle("Project Explorer");
-		SWTBot viewBot = view.bot();
-		SWTBotTreeItem node = eclipse.selectTreeLocation(viewBot, Properties.PROJECT_NAME, Properties.FILE_NAME);
+		ModeshapePublishDialog dialog = new ModeshapePublishDialog(
+				bot.shell("Unpublish from ModeShape"));
 
-		ContextMenuHelper.prepareTreeItemForContextMenu(projectExplorer.bot().tree(),node);
-		ContextMenuHelper.clickContextMenu(projectExplorer.bot().tree(), "ModeShape", "Publish");
-		
-		SWTBotShell shell = bot.shell("Publish to ModeShape");
-		shell.activate();
-		
-		SWTBotCombo serverCombo = shell.bot().comboBoxWithLabel("Server:");
-		SWTBotCombo repoCombo = shell.bot().comboBoxWithLabel("JCR Repository:");
-		SWTBotCombo workspaceCombo = shell.bot().comboBoxWithLabel("JCR Workspace:");
-		workspaceCombo.setSelection(Properties.WORKSPACE);
-		
-		assertTrue("URL mismatch.", serverCombo.getText().equals(Properties.URL));
-		assertTrue("Repository mismatch.", repoCombo.getText().equals(Properties.REPOSITORY));
-		assertTrue("Workspace mismatch.", workspaceCombo.getText().equals(Properties.WORKSPACE));
-		
-		open.finish(shell.bot());
-		
-		assertTrue("HTTP Response code must be 200 after publishing.", HttpURLConnection.HTTP_OK == testPublishedFile());
-	}
-	
-	
-	@Test
-	public void publishedLocations(){
-		
-		SWTBotView view = bot.viewByTitle("Project Explorer");
-		SWTBot viewBot = view.bot();
-		SWTBotTreeItem node = eclipse.selectTreeLocation(viewBot, Properties.PROJECT_NAME, Properties.FILE_NAME);
-		
-		ContextMenuHelper.prepareTreeItemForContextMenu(projectExplorer.bot().tree(),node);
-		ContextMenuHelper.clickContextMenu(projectExplorer.bot().tree(), "ModeShape", "Show Published Locations");
-		
-		SWTBotShell shell = bot.shell("Published Locations");
-		shell.activate();
-		
-		SWTBotTable table = shell.bot().table();
-		assertTrue("Url mismatch.", table.cell(0, 0).equals(Properties.URL));
-		assertTrue("User mismatch.", table.cell(0, 1).equals(Properties.USER));
-		assertTrue("Repository mismatch.", table.cell(0, 2).equals(Properties.REPOSITORY));
-		assertTrue("Workspace mismatch.", table.cell(0, 3).equals(Properties.WORKSPACE));
-		
-		String expectedPublishedUrl = Properties.URL          + "/"             + 
-		                              Properties.REPOSITORY   + "/"             + 
-		                              Properties.WORKSPACE    + "/items/files/" + 
-		                              Properties.PROJECT_NAME + "/"             + 
-		                              Properties.FILE_NAME;
-		
-		assertTrue("Published Url mismatch.", table.cell(0, 4).equals(expectedPublishedUrl));
-		
-		open.finish(shell.bot(), IDELabel.Button.OK);
-		
-	}
+		assertEquals(SERVER_REST_URL, dialog.getServer());
+		assertEquals("repository", dialog.getJcrRepository());
+		assertEquals("default", dialog.getJcrWorkspace());
 
-	
-	
-	@Test
-	public void unpublishFile(){
-		
-		SWTBotView view = bot.viewByTitle("Project Explorer");
-		SWTBot viewBot = view.bot();
-		SWTBotTreeItem node = eclipse.selectTreeLocation(viewBot, Properties.PROJECT_NAME, Properties.FILE_NAME);
-		
-		ContextMenuHelper.prepareTreeItemForContextMenu(projectExplorer.bot().tree(),node);
-		ContextMenuHelper.clickContextMenu(projectExplorer.bot().tree(), "ModeShape", "Unpublish");
-		
-		SWTBotShell shell = bot.shell("Unpublish from ModeShape");
-		shell.activate();
-		
-		SWTBotCombo serverCombo = shell.bot().comboBoxWithLabel("Server:");
-		SWTBotCombo repoCombo = shell.bot().comboBoxWithLabel("JCR Repository:");
-		SWTBotCombo workspaceCombo = shell.bot().comboBoxWithLabel("JCR Workspace:");
-		workspaceCombo.setSelection(Properties.WORKSPACE);
-		
-		assertTrue("URL mismatch.", serverCombo.getText().equals(Properties.URL));
-		assertTrue("Repository mismatch.", repoCombo.getText().equals(Properties.REPOSITORY));
-		assertTrue("Workspace mismatch.", workspaceCombo.getText().equals(Properties.WORKSPACE));
-		
-		open.finish(shell.bot());
-		
-		assertTrue("HTTP Response code must be 404 after unpublishing.", HttpURLConnection.HTTP_NOT_FOUND == testPublishedFile());
-		
+		dialog.finishWithWait();
+
+		assertTrue("HTTP Response code must be 404 after unpublishing.",
+				HttpURLConnection.HTTP_NOT_FOUND == testPublishedFile());
+
 	}
-		
+
 	@AfterClass
-	public static void afterClass(){
-		
-		bot.viewByTitle("ModeShape").show();
-		SWTBotView botView = bot.viewByTitle("ModeShape");
-		botView.bot().tree().select(Properties.URL);
-		botView.toolbarButton("Delete server from the server registry").click();
-		SWTBotShell shell = bot.shell("Confirm Delete Server");
-		
-		open.finish(shell.bot(),IDELabel.Button.OK);
+	public static void afterClass() {
+		ModeshapeView view = new ModeshapeView();
+		view.deleteServer(SERVER_REST_URL);
 	}
-	
-	
-		
+
 	/**
 	 * 
 	 * @return response code
 	 */
-	private int testPublishedFile(){
-		
+	private int testPublishedFile() {
+
 		try {
-			
-			URL url = new URL(Properties.WEBDAV_URL   + "/"       + 
-							  Properties.REPOSITORY   + "/"       + 
-							  Properties.WORKSPACE    + "/files/" + 
-							  Properties.PROJECT_NAME + "/"       + 
-							  Properties.FILE_NAME);
-			
+
+			URL url = new URL(PUBLISH_WEB_URL);
+
 			HttpURLConnection conn = (HttpURLConnection) url.openConnection();
-			
+
 			conn.setRequestMethod("GET");
 			conn.setAllowUserInteraction(false);
-		    conn.setUseCaches(false);
-		    conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
-						
+			conn.setUseCaches(false);
+			conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+
 			String authorization = Properties.USER + ":" + Properties.PASSWORD;
-			String encodedAuthorization= new String(Base64.encode(authorization.getBytes()));
+			String encodedAuthorization = new String(Base64.encode(authorization.getBytes()));
 			conn.setRequestProperty("Authorization", "Basic " + encodedAuthorization);
 
 			conn.connect();
-			
-			if(conn.getResponseCode() == HttpURLConnection.HTTP_OK){
-				//if HTTP_OK, test content
+
+			if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
+				// if HTTP_OK, test content
 				BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
 				StringBuilder sb = new StringBuilder();
 				String line = null;
-			
-				while ((line = rd.readLine()) != null){
+
+				while ((line = rd.readLine()) != null) {
 					sb.append(line);
 				}
-				assertTrue("File content mismatch.", sb.toString().equals(Properties.FILE_CONTENT));
+				assertEquals(FILE_CONTENT, sb.toString());
 			}
 
-			//return response code
+			// return response code
 			return conn.getResponseCode();
-			
+
 		} catch (IOException e) {
 			fail("Unable to test the published file.");
 			log.error(e.getMessage());
-		} 
+		}
 		return -1;
 	}
-		
+
 }



More information about the jbosstools-commits mailing list