Author: psrna
Date: 2010-10-27 04:43:44 -0400 (Wed, 27 Oct 2010)
New Revision: 26082
Added:
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/TeiidFilesPublishing.java
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/Utils.java
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/ModeshapeAllTests.java
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/Properties.java
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/Publishing.java
Log:
* New publishing test for Teiid Project Example
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/ModeshapeAllTests.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/ModeshapeAllTests.java 2010-10-27
08:06:05 UTC (rev 26081)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/ModeshapeAllTests.java 2010-10-27
08:43:44 UTC (rev 26082)
@@ -11,7 +11,8 @@
*
*/
@SuiteClasses({
- Publishing.class
+ Publishing.class,
+ TeiidFilesPublishing.class
})
@RunWith(RequirementAwareSuite.class)
public class ModeshapeAllTests {
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/Properties.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/Properties.java 2010-10-27
08:06:05 UTC (rev 26081)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/Properties.java 2010-10-27
08:43:44 UTC (rev 26082)
@@ -7,16 +7,30 @@
*/
public class Properties {
- public static final String PROJECT_NAME = "testproject";
- public static final String FILE_NAME = "testfile";
- public static final String FILE_CONTENT = "testcontent";
+ public static final String PROJECT_NAME = "testproject";
+ public static final String FILE_NAME = "testfile";
+ public static final String FILE_CONTENT = "testcontent";
- public static final String URL = "http://localhost:8080/modeshape-rest";
- public static final String WEBDAV_URL =
"http://localhost:8080/modeshape-webdav";
+ public static final String URL =
"http://localhost:8080/modeshape-rest";
+ public static final String WEBDAV_URL =
"http://localhost:8080/modeshape-webdav";
- public static final String REPOSITORY = "repository";
- public static final String WORKSPACE = "default";
+ public static final String REPOSITORY = "repository";
+ public static final String WORKSPACE = "default";
- public static final String USER = "admin";
- public static final String PASSWORD = "admin";
+ public static final String USER = "admin";
+ public static final String PASSWORD = "admin";
+
+
+ //~~~~~ Properties for Teiid Project Examples Publishing ~~~~~//
+ public static final String TEIID_PROJECT_NAME = "PartsProject";
+
+ public static final String TEIID_PROJECT_DESC = ".project";
+
+ public static final String ORACLE_SQL =
"data/CreateDB_PartsSupplier_Oracle.sql";
+ public static final String SQLSERVER_SQL =
"data/CreateDB_PartsSupplier_SQLServer.sql";
+
+ public static final String PARTS_SOURCE_A = "PartsSourceA.xmi";
+ public static final String PARTS_SOURCE_B = "PartsSourceB.xmi";
+ public static final String PARTS_VIRTUAL = "PartsVirtual.xmi";
+
}
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 2010-10-27
08:06:05 UTC (rev 26081)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/Publishing.java 2010-10-27
08:43:44 UTC (rev 26082)
@@ -24,6 +24,7 @@
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.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -32,7 +33,7 @@
* @author psrna
*
*/
-@SWTBotTestRequires(server=(a)Server(type=ServerType.EAP,version="5.0"),perspective="Java
EE")
+@SWTBotTestRequires(server=(a)Server(type=ServerType.SOA,version="5.1"),perspective="Java
EE")
public class Publishing extends SWTTestExt{
private static final String CONNERR_MSG = "Unable to connect using the specified
server properties." +
@@ -75,6 +76,7 @@
public void createModeShapeServer(){
openModeshapeView();
+
SWTBotView view = bot.viewByTitle("ModeShape");
assertTrue("ModeShape View must be active", view.isActive());
@@ -99,9 +101,10 @@
open.finish(shell.bot());
- assertTrue("Created server not visible in ModeShape view.",
view.bot().tree().getTreeItem(Properties.URL).isVisible());
+ assertTrue("Created server not visible in ModeShape view.",
view.bot().tree().getTreeItem(Properties.URL).isVisible());
+
}
-
+
private void openModeshapeView(){
bot.menu(IDELabel.Menu.WINDOW)
@@ -203,7 +206,20 @@
}
+ @AfterClass
+ public static void afterClass(){
+ bot.viewByTitle("ModeShape").show();
+ SWTBot mbot = bot.viewByTitle("ModeShape").bot();
+ mbot.tree().select(Properties.URL);
+ bot.toolbarButtonWithTooltip("Delete server from the server
registry").click();
+ SWTBotShell shell = bot.shell("Confirm Delete Server");
+
+ open.finish(shell.bot(),IDELabel.Button.OK);
+ }
+
+
+
/**
*
* @return response code
@@ -212,7 +228,11 @@
try {
- URL url = new URL(Properties.WEBDAV_URL + "/" + Properties.PROJECT_NAME +
"/" + Properties.FILE_NAME);
+ URL url = new URL(Properties.WEBDAV_URL + "/" +
+ Properties.REPOSITORY + "/" +
+ Properties.WORKSPACE + "/" +
+ Properties.PROJECT_NAME + "/" +
+ Properties.FILE_NAME);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
Added:
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/TeiidFilesPublishing.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/TeiidFilesPublishing.java
(rev 0)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/TeiidFilesPublishing.java 2010-10-27
08:43:44 UTC (rev 26082)
@@ -0,0 +1,235 @@
+package org.jboss.tools.modeshape.rest.ui.bot.tests;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.Arrays;
+
+import org.eclipse.core.internal.preferences.Base64;
+import org.eclipse.core.runtime.Platform;
+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.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
+import org.jboss.tools.ui.bot.ext.config.Annotations.ServerType;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ *
+ * @author psrna
+ *
+ */
+@SWTBotTestRequires(server=(a)Server(type=ServerType.SOA,version="5.1"),
perspective="Teiid Designer")
+public class TeiidFilesPublishing 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 importTeiidPartsModelExample(){
+
+ bot.menu(IDELabel.Menu.HELP)
+ .menu("Project Examples...").click();
+
+ SWTBotShell shell = bot.shell("New Project Example");
+ shell.activate();
+ shell.bot().tree(0).expandNode("Teiid Designer")
+ .select("Parts Model Project Set Example");
+
+ open.finish(shell.bot(), IDELabel.Button.FINISH);
+
+ }
+
+ @BeforeClass
+ public static void beforeClass(){
+ importTeiidPartsModelExample();
+
+ }
+
+ @Test
+ public void createModeShapeServer(){
+
+ openModeshapeView();
+
+ SWTBotView view = bot.viewByTitle("ModeShape");
+ assertTrue("ModeShape View must be active", view.isActive());
+
+ view.toolbarButton("Create a new server").click();
+ SWTBotShell shell = bot.shell("New Server");
+ shell.activate();
+
+ shell.bot().textWithLabel("URL:").typeText(Properties.URL);
+ shell.bot().textWithLabel("User:").typeText(Properties.USER);
+ shell.bot().textWithLabel("Password:").typeText(Properties.PASSWORD);
+
+ shell.bot().button("Test").click();
+ shell = bot.shell("Test Server Connection");
+ shell.activate();
+
+ 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");
+ shell.activate();
+
+ open.finish(shell.bot());
+
+ 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();
+
+ 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 publishFiles(){
+
+ bot.viewByTitle("Model Explorer").show();
+ SWTBotView view = bot.viewByTitle("Model Explorer");
+ SWTBot viewBot = view.bot();
+ SWTBotTreeItem node = eclipse.selectTreeLocation(viewBot,
Properties.TEIID_PROJECT_NAME);
+
+ ContextMenuHelper.prepareTreeItemForContextMenu(projectExplorer.tree(),node);
+ ContextMenuHelper.clickContextMenu(projectExplorer.tree(), "ModeShape",
"Publish");
+
+ SWTBotShell shell = bot.shell("Publish");
+ shell.activate();
+
+ SWTBotCombo serverCombo = shell.bot().comboBoxWithLabel("Server:");
+ SWTBotCombo repoCombo = shell.bot().comboBoxWithLabel("Repository:");
+ SWTBotCombo workspaceCombo = shell.bot().comboBoxWithLabel("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(Properties.TEIID_PROJECT_DESC));
+ assertTrue("HTTP Response code must be 200 after publishing.",
HttpURLConnection.HTTP_OK == testPublishedFile(Properties.PARTS_SOURCE_A));
+ assertTrue("HTTP Response code must be 200 after publishing.",
HttpURLConnection.HTTP_OK == testPublishedFile(Properties.PARTS_SOURCE_B));
+ assertTrue("HTTP Response code must be 200 after publishing.",
HttpURLConnection.HTTP_OK == testPublishedFile(Properties.PARTS_VIRTUAL));
+ assertTrue("HTTP Response code must be 200 after publishing.",
HttpURLConnection.HTTP_OK == testPublishedFile(Properties.ORACLE_SQL));
+ assertTrue("HTTP Response code must be 200 after publishing.",
HttpURLConnection.HTTP_OK == testPublishedFile(Properties.SQLSERVER_SQL));
+ }
+
+ @Test
+ public void unpublishFiles(){
+
+ SWTBotView view = bot.viewByTitle("Model Explorer");
+ SWTBot viewBot = view.bot();
+ SWTBotTreeItem node = eclipse.selectTreeLocation(viewBot,
Properties.TEIID_PROJECT_NAME);
+
+ ContextMenuHelper.prepareTreeItemForContextMenu(projectExplorer.tree(),node);
+ ContextMenuHelper.clickContextMenu(projectExplorer.tree(), "ModeShape",
"Unpublish");
+
+ SWTBotShell shell = bot.shell("Unpublish");
+ shell.activate();
+
+ SWTBotCombo serverCombo = shell.bot().comboBoxWithLabel("Server:");
+ SWTBotCombo repoCombo = shell.bot().comboBoxWithLabel("Repository:");
+ SWTBotCombo workspaceCombo = shell.bot().comboBoxWithLabel("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(Properties.TEIID_PROJECT_DESC));
+ assertTrue("HTTP Response code must be 404 after unpublishing.",
HttpURLConnection.HTTP_NOT_FOUND == testPublishedFile(Properties.PARTS_SOURCE_A));
+ assertTrue("HTTP Response code must be 404 after unpublishing.",
HttpURLConnection.HTTP_NOT_FOUND == testPublishedFile(Properties.PARTS_SOURCE_B));
+ assertTrue("HTTP Response code must be 404 after unpublishing.",
HttpURLConnection.HTTP_NOT_FOUND == testPublishedFile(Properties.PARTS_VIRTUAL));
+ assertTrue("HTTP Response code must be 404 after unpublishing.",
HttpURLConnection.HTTP_NOT_FOUND == testPublishedFile(Properties.ORACLE_SQL));
+ assertTrue("HTTP Response code must be 404 after unpublishing.",
HttpURLConnection.HTTP_NOT_FOUND == testPublishedFile(Properties.SQLSERVER_SQL));
+ }
+
+ /**
+ *
+ * @return response code
+ */
+ private int testPublishedFile(String filename){
+
+ try {
+
+ URL url = new URL(Properties.WEBDAV_URL + "/" +
+ Properties.REPOSITORY + "/" +
+ Properties.WORKSPACE + "/" +
+ Properties.TEIID_PROJECT_NAME + "/" + filename);
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+
+ conn.setRequestMethod("GET");
+ conn.setAllowUserInteraction(false);
+ 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()));
+ conn.setRequestProperty("Authorization", "Basic " +
encodedAuthorization);
+
+ conn.connect();
+
+ if(conn.getResponseCode() == HttpURLConnection.HTTP_OK){
+ //if HTTP_OK, test content
+
+ File file = new File(Platform.getLocation() + "/" +
Properties.TEIID_PROJECT_NAME + "/" + filename);
+ byte[] file_input;
+ byte[] server_input;
+ InputStream is = conn.getInputStream();
+
+ file_input = Utils.read(file);
+ server_input = Utils.read(is,(int) file.length());
+
+ assertTrue("File content mismatch.", Arrays.equals(file_input,
server_input));
+ }
+
+ //return response code
+ return conn.getResponseCode();
+
+ } catch (IOException e) {
+ fail("Unable to test the published file.");
+ log.error(e.getMessage());
+ }
+ return -1;
+ }
+
+
+ @AfterClass
+ public static void afterClass(){
+
+ bot.viewByTitle("ModeShape").show();
+ SWTBot mbot = bot.viewByTitle("ModeShape").bot();
+ mbot.tree().select(Properties.URL);
+ bot.toolbarButtonWithTooltip("Delete server from the server
registry").click();
+ SWTBotShell shell = bot.shell("Confirm Delete Server");
+
+ open.finish(shell.bot(),IDELabel.Button.OK);
+ }
+
+}
Property changes on:
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/TeiidFilesPublishing.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/Utils.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/Utils.java
(rev 0)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/Utils.java 2010-10-27
08:43:44 UTC (rev 26082)
@@ -0,0 +1,40 @@
+package org.jboss.tools.modeshape.rest.ui.bot.tests;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class Utils {
+
+ public static byte[] read(File file) throws IOException {
+
+ InputStream is = new FileInputStream(file);
+ if (file.length() > Integer.MAX_VALUE) {
+ // File is too large
+ throw new IOException("File " + file.toString() + " is too
large!");
+ }
+
+ byte[] bytes = read(is, (int) file.length());
+
+ is.close();
+ return bytes;
+ }
+
+ public static byte[] read(InputStream is, int len) throws IOException{
+
+ byte[] bytes = new byte[len];
+ int bytesRead = 0;
+ int result = 0;
+
+ while (bytesRead < len) {
+
+ result = is.read(bytes, bytesRead, len - bytesRead);
+ if (result == -1) break;
+ bytesRead += result;
+ }
+
+ is.close();
+ return bytes;
+ }
+}
Property changes on:
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.ui.bot.test/src/org/jboss/tools/modeshape/rest/ui/bot/tests/Utils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain