You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by de...@apache.org on 2010/10/19 05:09:43 UTC
svn commit: r1024098 -
/geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/
Author: delos
Date: Tue Oct 19 03:09:43 2010
New Revision: 1024098
URL: http://svn.apache.org/viewvc?rev=1024098&view=rev
Log:
GERONIMODEVTOOLS-637 add missing files for aries test cases
Added:
geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/
geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/AriesToolInstallTest.java
geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/DownloadsTest.java
geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ExportBundleTest.java
geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ExportCBATest.java
geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ExportEBATest.java
geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ImportBundleTest.java
geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ImportCBATest.java
geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ImportEBATest.java
geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/NewOSGiBundleTest.java
geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/NewOSGiCompositeBundleTest.java
geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/Tutorial5MinuteTest.java
Added: geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/AriesToolInstallTest.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/AriesToolInstallTest.java?rev=1024098&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/AriesToolInstallTest.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/AriesToolInstallTest.java Tue Oct 19 03:09:43 2010
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.testsuite.v30.ui.aries;
+
+import org.apache.geronimo.testsuite.common.ui.AbbotHelper;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import abbot.swt.eclipse.junit.extensions.WorkbenchTestCase;
+import abbot.swt.eclipse.utils.WorkbenchUtilities;
+
+/*
+ * Aries tool install test
+ * @version $Rev$ $Date$
+ */
+public class AriesToolInstallTest extends WorkbenchTestCase {
+ Shell workbenchShell;
+ AbbotHelper abbotHelper;
+
+ @Before()
+ public void setUp() throws Exception {
+ workbenchShell = WorkbenchUtilities.getWorkbenchWindow().getShell();
+ abbotHelper = new AbbotHelper(workbenchShell);
+ }
+
+ @After()
+ public void tearDown() throws Exception {
+ }
+
+ @Test()
+ public void testAriesToolInstall() {
+ assertTrue(installAriesTool());
+ //TODO check installation
+ }
+
+ private boolean installAriesTool() {
+ boolean success = true;
+ try {
+ Shell newShell = abbotHelper.clickMenuItem(workbenchShell, new String[]{"&Help", "Install New &Software..."}, "Install");
+ Shell nextShell = abbotHelper.clickButton(newShell, "&Add...", "Add Repository");
+ abbotHelper.setTextField(nextShell, "http://", "http://public.dhe.ibm.com/ibmdl/export/pub/software/rational/OSGiAppTools");
+ abbotHelper.clickButton(nextShell, IDialogConstants.OK_LABEL);
+ //Need time to retrieve the tree.
+ abbotHelper.waitTime(30000);
+ abbotHelper.clickButton(newShell, "&Select All");
+ abbotHelper.clickButton(newShell, IDialogConstants.NEXT_LABEL);
+ //Need time to calculate the dependencies of the plugin.
+ abbotHelper.waitTime(30000);
+ abbotHelper.clickButton(newShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(newShell, "I &accept the terms of the license agreement");
+ nextShell = abbotHelper.clickButton(newShell, IDialogConstants.FINISH_LABEL, "Software Update");
+ abbotHelper.clickButton(nextShell, "&Not Now");
+ } catch(Exception e) {
+ e.printStackTrace();
+ success = false;
+ }
+ return success;
+ }
+
+}
Added: geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/DownloadsTest.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/DownloadsTest.java?rev=1024098&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/DownloadsTest.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/DownloadsTest.java Tue Oct 19 03:09:43 2010
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.testsuite.v30.ui.aries;
+
+import org.apache.geronimo.testsuite.common.ui.AbbotHelper;
+import org.eclipse.swt.widgets.Shell;
+import org.junit.Before;
+import org.junit.Test;
+
+import abbot.swt.eclipse.junit.extensions.WorkbenchTestCase;
+import abbot.swt.eclipse.utils.WorkbenchUtilities;
+
+/*
+ * Download menu test.
+ * @version $Rev$ $Date$
+ */
+public class DownloadsTest extends WorkbenchTestCase {
+ Shell workbenchShell;
+ AbbotHelper abbotHelper;
+
+ @Before()
+ public void setUp() {
+ workbenchShell = WorkbenchUtilities.getWorkbenchWindow().getShell();
+ abbotHelper = new AbbotHelper(workbenchShell);
+ }
+
+ @Test()
+ public void testDownloads() {
+ assertTrue(downloadGeronimoServer());
+ assertTrue(downloadOSGiTools());
+ //TODO verify using selenium
+ }
+
+ private boolean downloadGeronimoServer() {
+ boolean success = false;
+ try {
+ abbotHelper.clickMenuItem(workbenchShell,
+ new String[]{"&Downloads", "Download &Geronimo Servers"});
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private boolean downloadOSGiTools() {
+ boolean success = false;
+ try {
+ abbotHelper.clickMenuItem(workbenchShell,
+ new String[]{"&Downloads", "Download &OSGi Application Development Tools"});
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+}
Added: geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ExportBundleTest.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ExportBundleTest.java?rev=1024098&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ExportBundleTest.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ExportBundleTest.java Tue Oct 19 03:09:43 2010
@@ -0,0 +1,238 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.testsuite.v30.ui.aries;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+import org.apache.geronimo.testsuite.common.selenium.EclipseSelenium;
+import org.apache.geronimo.testsuite.common.ui.AbbotHelper;
+import org.apache.geronimo.testsuite.common.ui.Constants;
+import org.apache.geronimo.testsuite.common.ui.ProjectTasks;
+import org.apache.geronimo.testsuite.common.ui.ServerTasks;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.widgets.Shell;
+import org.junit.Before;
+import org.junit.Test;
+
+import abbot.swt.eclipse.junit.extensions.WorkbenchTestCase;
+import abbot.swt.eclipse.utils.WorkbenchUtilities;
+
+/*
+ * Export bundle test
+ * @version $Rev$ $Date$
+ */
+public class ExportBundleTest extends WorkbenchTestCase {
+ Shell workbenchShell;
+ AbbotHelper abbotHelper;
+ ServerTasks serverTasks;
+
+ @Before()
+ public void setUp() throws Exception {
+ workbenchShell = WorkbenchUtilities.getWorkbenchWindow().getShell();
+ abbotHelper = new AbbotHelper(workbenchShell);
+ serverTasks = new ServerTasks(workbenchShell, abbotHelper, Constants.SERVER_V30);
+ }
+
+ @Test()
+ public void testBundleExport() {
+ assertTrue(installServer());
+ assertTrue(createBundle());
+ assertTrue(copyCodeToBundle());
+ assertTrue(exportBundle());
+ assertTrue(validateBundle());
+ assertTrue(runBundle());
+ assertTrue(deleteBundle());
+ assertTrue(uninstallServer());
+ }
+
+ private boolean installServer() {
+ boolean success = serverTasks.createServer();
+ if(success == true) {
+ success = serverTasks.startServer(false);
+ }
+ return success;
+ }
+
+ private boolean uninstallServer() {
+ boolean success = serverTasks.stopServer();
+ if (success == true) {
+ success = serverTasks.removeServer();
+ }
+ return success;
+ }
+
+ private boolean createBundle() {
+ boolean success = false;
+ try {
+ Shell wizardShell = abbotHelper.clickMenuItem(workbenchShell,
+ new String[]{"&File", "&New\tShift+Alt+N", "&Other...\tCtrl+N"}, "New");
+ abbotHelper.clickTreeItem(wizardShell, new String[]{"OSGi", "OSGi Bundle Project"});
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.setCursorText("OSGiBundleSample");
+ //Create a simple web bundle here.
+ abbotHelper.setTextField(wizardShell,
+ "Default Configuration for Apache Geronimo v3.0",
+ "OSGi Web Configuration");
+ //Don't need to add this bundle to any osgi application, so uncheck it.
+ abbotHelper.clickButton(wizardShell, "Add bundle to application");
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.FINISH_LABEL);
+ abbotHelper.waitForDialogDisposal(wizardShell);
+ success = true;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private boolean copyCodeToBundle() {
+ boolean success = false;
+ try {
+ IWorkspaceRoot aWSRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IProject aProject = aWSRoot.getProject("OSGiBundleSample");
+ String fileDir = aWSRoot.getLocation().toOSString() + "/src/main/resources/aries/export/wab";
+ //The web bundle only contains a jsp file.
+ IFile aFile = aProject.getFile("WebContent/index.jsp");
+ aFile.create(new FileInputStream(fileDir + "/index.jsp"), true, null);
+ abbotHelper.waitTime(AbbotHelper.WAIT_STANDARD);
+ success = true;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private boolean exportBundle() {
+ boolean success = false;
+ try {
+ Shell wizardShell = abbotHelper.rightClickItem(workbenchShell, "OSGiBundleSample",
+ new String[]{"E&xport", "Exp&ort..."}, "Export");
+ abbotHelper.clickTreeItem(wizardShell, new String[]{"OSGi", "OSGi Bundle"});
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.setTextField(wizardShell, "", getExportLocation());
+ abbotHelper.clickButton(wizardShell, IDialogConstants.FINISH_LABEL);
+ success = true;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ /*
+ * Validate the bundle through deploying it to server.
+ * If there is no exception during deployment, then the bundle is valid.
+ */
+ private boolean validateBundle() {
+ boolean success = false;
+ try {
+ String serverBinDir = getServerInstallDir() + File.separatorChar + "bin";
+ String fileLocation = getExportLocation();
+ //This is the deploy command.
+ String deployCommand = serverBinDir + File.separatorChar +
+ "deploy --user system --password manager deploy " +
+ fileLocation;
+ //Deploy exported bundle to server to validate it.
+ Process proc = Runtime.getRuntime().exec(deployCommand);
+ //Wait for deployment finished.
+ int exitVal = proc.waitFor();
+ //According to jdk documentation, by convention, the value 0 indicates normal termination.
+ if(exitVal!=0) {
+ return false;
+ }
+ abbotHelper.waitTime(AbbotHelper.WAIT_LONG);
+ success = true;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private boolean runBundle() {
+ boolean success = false;
+ try {
+ EclipseSelenium selenium = new EclipseSelenium();
+ selenium.start();
+ selenium.open("http://localhost:8080/OSGiBundleSample/index.jsp");
+ selenium.waitForPageToLoad("60000");
+ success = (selenium.getHtmlSource().indexOf("Test OSGi bundle!") > 0);
+ abbotHelper.waitTime(AbbotHelper.WAIT_STANDARD);
+ selenium.stop();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private String getExportLocation() {
+ IWorkspace ws = ResourcesPlugin.getWorkspace();
+ String location = ws.getRoot().getLocation().toOSString();
+ String fileName = "OSGiBundleSample.jar";
+ int index = location.lastIndexOf(File.separatorChar);
+ if(index > -1) {
+ location = location.substring(0, index);
+ }
+ index = location.lastIndexOf(File.separatorChar);
+ if(index > -1) {
+ location = location.substring(0, index);
+ }
+ index = location.lastIndexOf(File.separatorChar);
+ if(index > -1) {
+ location = location.substring(0, index);
+ }
+ location = location + File.separatorChar + "results" + File.separatorChar + fileName;
+ return location;
+ }
+
+ private String getServerInstallDir() {
+ IWorkspace ws = ResourcesPlugin.getWorkspace();
+ String location = ws.getRoot().getLocation().toOSString();
+ int index = location.lastIndexOf(File.separatorChar);
+ if (index > -1) {
+ location = location.substring(0,index);
+ }
+ index = location.lastIndexOf(File.separatorChar);
+ if (index > -1) {
+ location = location.substring(0,index);
+ }
+ index = location.lastIndexOf(File.separatorChar);
+ if (index > -1) {
+ location = location.substring(0,index);
+ }
+ location = location + File.separatorChar + Constants.getConstant(Constants.SERVER_V30, Constants.SERVERPATH);
+ return location;
+ }
+
+ private boolean deleteBundle() {
+ boolean success = false;
+ try {
+ ProjectTasks projectTasks = new ProjectTasks(workbenchShell, abbotHelper);
+ success = projectTasks.deleteProject("OSGiBundleSample");
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+}
Added: geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ExportCBATest.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ExportCBATest.java?rev=1024098&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ExportCBATest.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ExportCBATest.java Tue Oct 19 03:09:43 2010
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.testsuite.v30.ui.aries;
+
+import org.apache.geronimo.testsuite.common.ui.AbbotHelper;
+import org.apache.geronimo.testsuite.common.ui.Constants;
+import org.apache.geronimo.testsuite.common.ui.ServerTasks;
+import org.eclipse.swt.widgets.Shell;
+import org.junit.Before;
+import org.junit.Test;
+
+import abbot.swt.eclipse.junit.extensions.WorkbenchTestCase;
+import abbot.swt.eclipse.utils.WorkbenchUtilities;
+
+/*
+ * Export cba test
+ * @version $Rev$ $Date$
+ */
+public class ExportCBATest extends WorkbenchTestCase {
+ Shell workbenchShell;
+ AbbotHelper abbotHelper;
+ ServerTasks serverTasks;
+
+ @Before()
+ public void setUp() throws Exception {
+ workbenchShell = WorkbenchUtilities.getWorkbenchWindow().getShell();
+ abbotHelper = new AbbotHelper(workbenchShell);
+ serverTasks = new ServerTasks(workbenchShell, abbotHelper, Constants.SERVER_V30);
+ }
+
+ @Test()
+ public void testCBAExport() {
+ assertTrue(installServer());
+ //TODO create and export cba
+ assertTrue(uninstallServer());
+ }
+
+ private boolean installServer() {
+ boolean success = serverTasks.createServer();
+ if(success == true) {
+ success = serverTasks.startServer(false);
+ }
+ return success;
+ }
+
+ private boolean uninstallServer() {
+ boolean success = serverTasks.stopServer();
+ if (success == true) {
+ success = serverTasks.removeServer();
+ }
+ return success;
+ }
+
+}
Added: geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ExportEBATest.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ExportEBATest.java?rev=1024098&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ExportEBATest.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ExportEBATest.java Tue Oct 19 03:09:43 2010
@@ -0,0 +1,265 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.testsuite.v30.ui.aries;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+import org.apache.geronimo.testsuite.common.selenium.EclipseSelenium;
+import org.apache.geronimo.testsuite.common.ui.AbbotHelper;
+import org.apache.geronimo.testsuite.common.ui.Constants;
+import org.apache.geronimo.testsuite.common.ui.ProjectTasks;
+import org.apache.geronimo.testsuite.common.ui.ServerTasks;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.widgets.Shell;
+import org.junit.Before;
+import org.junit.Test;
+
+import abbot.swt.eclipse.junit.extensions.WorkbenchTestCase;
+import abbot.swt.eclipse.utils.WorkbenchUtilities;
+
+/*
+ * Export eba test.
+ * @version $Rev$ $Date$
+ */
+public class ExportEBATest extends WorkbenchTestCase {
+ Shell workbenchShell;
+ AbbotHelper abbotHelper;
+ ServerTasks serverTasks;
+
+ @Before()
+ public void setUp() throws Exception {
+ workbenchShell = WorkbenchUtilities.getWorkbenchWindow().getShell();
+ abbotHelper = new AbbotHelper(workbenchShell);
+ serverTasks = new ServerTasks(workbenchShell, abbotHelper, Constants.SERVER_V30);
+ }
+
+ @Test()
+ public void testEBAExport() {
+ assertTrue(installServer());
+ assertTrue(createEBA());
+ assertTrue(createBundle());
+ assertTrue(copyCodeToBundle());
+ assertTrue(exportEBA());
+ assertTrue(validateEBA());
+ assertTrue(runEBA());
+ assertTrue(deleteBundle());
+ assertTrue(deleteEBA());
+ assertTrue(uninstallServer());
+ }
+
+ private boolean installServer() {
+ boolean success = serverTasks.createServer();
+ if(success == true) {
+ success = serverTasks.startServer(false);
+ }
+ return success;
+ }
+
+ private boolean uninstallServer() {
+ boolean success = serverTasks.stopServer();
+ if (success == true) {
+ success = serverTasks.removeServer();
+ }
+ return success;
+ }
+
+ private boolean createEBA() {
+ boolean success = false;
+ try {
+ Shell wizardShell = abbotHelper.clickMenuItem(workbenchShell,
+ new String[]{"&File", "&New\tShift+Alt+N", "&Other...\tCtrl+N"}, "New");
+ abbotHelper.clickTreeItem(wizardShell, new String[]{"OSGi", "OSGi Application Project"});
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.setCursorText("OSGiAppSample");
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.FINISH_LABEL);
+ abbotHelper.waitForDialogDisposal(wizardShell);
+ success = true;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private boolean createBundle() {
+ boolean success = false;
+ try {
+ Shell wizardShell = abbotHelper.clickMenuItem(workbenchShell,
+ new String[]{"&File", "&New\tShift+Alt+N", "&Other...\tCtrl+N"}, "New");
+ abbotHelper.clickTreeItem(wizardShell, new String[]{"OSGi", "OSGi Bundle Project"});
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.setCursorText("OSGiBundleSample");
+ //This is a web bundle.
+ abbotHelper.setTextField(wizardShell, "Default Configuration for Apache Geronimo v3.0",
+ "OSGi Web Configuration");
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.FINISH_LABEL);
+ abbotHelper.waitForDialogDisposal(wizardShell);
+ success = true;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private boolean copyCodeToBundle() {
+ boolean success = false;
+ try {
+ IWorkspaceRoot aWSRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IProject aProject = aWSRoot.getProject("OSGiWebBundleSample");
+ String fileDir = aWSRoot.getLocation().toOSString() + "/src/main/resources/aries/export/eba";
+ IFile aFile = aProject.getFile("WebContent/index.jsp");
+ aFile.create(new FileInputStream(fileDir + "/index.jsp"), true, null);
+ abbotHelper.waitTime(AbbotHelper.WAIT_STANDARD);
+ success = true;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private boolean exportEBA() {
+ boolean success = false;
+ try {
+ Shell wizardShell = abbotHelper.rightClickItem(workbenchShell, "OSGiAppSample",
+ new String[]{"E&xport", "Exp&ort..."}, "Export");
+ abbotHelper.clickTreeItem(wizardShell, new String[]{"OSGi", "OSGi Application(EBA)"});
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.setTextField(wizardShell, "", getExportLocation());
+ abbotHelper.clickButton(wizardShell, IDialogConstants.FINISH_LABEL);
+ success = true;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private String getExportLocation() {
+ IWorkspace ws = ResourcesPlugin.getWorkspace();
+ String location = ws.getRoot().getLocation().toOSString();
+ String fileName = "OSGiAppSample.eba";
+ int index = location.lastIndexOf(File.separatorChar);
+ if(index > -1) {
+ location = location.substring(0, index);
+ }
+ index = location.lastIndexOf(File.separatorChar);
+ if(index > -1) {
+ location = location.substring(0, index);
+ }
+ index = location.lastIndexOf(File.separatorChar);
+ if(index > -1) {
+ location = location.substring(0, index);
+ }
+ location = location + File.separatorChar + "results" + File.separatorChar + fileName;
+ return location;
+ }
+
+ /*
+ * Validate the eba through deploying it to server.
+ * If there is no exception during deployment, then the eba is valid.
+ */
+ private boolean validateEBA() {
+ boolean success = false;
+ try {
+ String serverBinDir = getServerInstallDir() + File.separatorChar + "bin";
+ String fileLocation = getExportLocation();
+ //This is the deploy command.
+ String deployCommand = serverBinDir + File.separatorChar +
+ "deploy --user system --password manager deploy " +
+ fileLocation;
+ //Deploy exported eba to server to validate it.
+ Process proc = Runtime.getRuntime().exec(deployCommand);
+ //Wait for deployment finished.
+ int exitVal = proc.exitValue();
+ //According to jdk documentation, by convention, the value 0 indicates normal termination.
+ if(exitVal!=0) {
+ return false;
+ }
+ abbotHelper.waitTime(AbbotHelper.WAIT_LONG);
+ success = true;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private boolean runEBA() {
+ boolean success = false;
+ try {
+ EclipseSelenium selenium = new EclipseSelenium();
+ selenium.start();
+ selenium.open("http://localhost:8080/OSGiBundleSample/index.jsp");
+ selenium.waitForPageToLoad("60000");
+ success = (selenium.getHtmlSource().indexOf("Test OSGi bundle") > 0);
+ abbotHelper.waitTime(AbbotHelper.WAIT_STANDARD);
+ selenium.stop();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private String getServerInstallDir() {
+ IWorkspace ws = ResourcesPlugin.getWorkspace();
+ String location = ws.getRoot().getLocation().toOSString();
+ int index = location.lastIndexOf(File.separatorChar);
+ if (index > -1) {
+ location = location.substring(0,index);
+ }
+ index = location.lastIndexOf(File.separatorChar);
+ if (index > -1) {
+ location = location.substring(0,index);
+ }
+ index = location.lastIndexOf(File.separatorChar);
+ if (index > -1) {
+ location = location.substring(0,index);
+ }
+ location = location + File.separatorChar + Constants.getConstant(Constants.SERVER_V30, Constants.SERVERPATH);
+ return location;
+ }
+
+ private boolean deleteBundle() {
+ boolean success = false;
+ try {
+ ProjectTasks projectTasks = new ProjectTasks(workbenchShell, abbotHelper);
+ success = projectTasks.deleteProject("OSGiBundleSample");
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private boolean deleteEBA() {
+ boolean success = false;
+ try {
+ ProjectTasks projectTasks = new ProjectTasks(workbenchShell, abbotHelper);
+ success = projectTasks.deleteProject("OSGiAppSample");
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+}
Added: geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ImportBundleTest.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ImportBundleTest.java?rev=1024098&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ImportBundleTest.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ImportBundleTest.java Tue Oct 19 03:09:43 2010
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.testsuite.v30.ui.aries;
+
+import java.io.File;
+
+import org.apache.geronimo.testsuite.common.selenium.EclipseSelenium;
+import org.apache.geronimo.testsuite.common.ui.AbbotHelper;
+import org.apache.geronimo.testsuite.common.ui.Constants;
+import org.apache.geronimo.testsuite.common.ui.ProjectTasks;
+import org.apache.geronimo.testsuite.common.ui.ServerTasks;
+import org.apache.geronimo.testsuite.common.ui.WorkbenchTasks;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.widgets.Shell;
+import org.junit.Before;
+import org.junit.Test;
+
+import abbot.swt.eclipse.junit.extensions.WorkbenchTestCase;
+import abbot.swt.eclipse.utils.WorkbenchUtilities;
+
+/*
+ * Import bundle test
+ * @version $Rev$ $Date$
+ */
+public class ImportBundleTest extends WorkbenchTestCase {
+ Shell workbenchShell;
+ AbbotHelper abbotHelper;
+ ServerTasks serverTasks;
+ WorkbenchTasks workbenchTasks;
+ ProjectTasks projectTasks;
+
+ @Before()
+ public void setUp() {
+ workbenchShell = WorkbenchUtilities.getWorkbenchWindow().getShell();
+ abbotHelper = new AbbotHelper(workbenchShell);
+ serverTasks = new ServerTasks(workbenchShell, abbotHelper, Constants.SERVER_V30);
+ projectTasks = new ProjectTasks(workbenchShell, abbotHelper);
+ }
+
+ @Test()
+ public void testBundleImport() {
+ assertTrue(installServer());
+ assertTrue(importBundle());
+ assertTrue(deployBundle());
+ assertTrue(runBundle());
+ assertTrue(undeployBundle());
+ assertTrue(deleteBundle());
+ assertTrue(uninstallServer());
+ }
+
+ private boolean installServer() {
+ boolean success = serverTasks.createServer();
+ if(success == true) {
+ success = serverTasks.startServer(false);
+ }
+ return success;
+ }
+
+ private boolean uninstallServer() {
+ boolean success = serverTasks.stopServer();
+ if (success == true) {
+ success = serverTasks.removeServer();
+ }
+ return success;
+ }
+
+ private boolean importBundle() {
+ boolean success = false;
+ try {
+ Shell wizardShell = abbotHelper.clickMenuItem(workbenchShell,
+ new String[]{"&File", "&Import..."}, "Import");
+ abbotHelper.clickTreeItem(wizardShell, new String[]{"OSGi", "OSGi Bundle"});
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.setCursorText(getBundleLocation());
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.FINISH_LABEL);
+ abbotHelper.waitForDialogDisposal(wizardShell);
+ success = true;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private String getBundleLocation() {
+ IWorkspace ws = ResourcesPlugin.getWorkspace();
+ String location = ws.getRoot().getLocation().toOSString();
+ String fileName = "com.example.helloworld.web.jar";
+ //The location is a bit complicated.
+ location = location + File.separatorChar +
+ "src" + File.separatorChar +
+ "main" + File.separatorChar +
+ "resources" + File.separatorChar +
+ "aries" + File.separatorChar +
+ "import" + File.separatorChar +
+ "wab" + File.separatorChar + fileName;
+ return location;
+ }
+
+ private boolean deployBundle() {
+ boolean success = false;
+ try {
+ success = serverTasks.publishAllProjects();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private boolean runBundle() {
+ boolean success = false;
+ try {
+ EclipseSelenium selenium = new EclipseSelenium();
+ selenium.start();
+ selenium.open("http://localhost:8080/helloworld/index.jsp");
+ selenium.waitForPageToLoad("60000");
+ success = (selenium.getHtmlSource().indexOf("Hello world test") > 0);
+ abbotHelper.waitTime(AbbotHelper.WAIT_STANDARD);
+ selenium.stop();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private boolean undeployBundle() {
+ boolean success = false;
+ try {
+ success = serverTasks.removeAllProjects();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private boolean deleteBundle() {
+ boolean success = false;
+ try {
+ success = projectTasks.deleteProject("com.example.helloworld");
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+}
Added: geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ImportCBATest.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ImportCBATest.java?rev=1024098&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ImportCBATest.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ImportCBATest.java Tue Oct 19 03:09:43 2010
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.testsuite.v30.ui.aries;
+
+import org.apache.geronimo.testsuite.common.ui.AbbotHelper;
+import org.apache.geronimo.testsuite.common.ui.Constants;
+import org.apache.geronimo.testsuite.common.ui.ProjectTasks;
+import org.apache.geronimo.testsuite.common.ui.ServerTasks;
+import org.apache.geronimo.testsuite.common.ui.WorkbenchTasks;
+import org.eclipse.swt.widgets.Shell;
+import org.junit.Before;
+import org.junit.Test;
+
+import abbot.swt.eclipse.junit.extensions.WorkbenchTestCase;
+import abbot.swt.eclipse.utils.WorkbenchUtilities;
+
+/*
+ * Import cba test.
+ * @version $Rev$ $Date$
+ */
+public class ImportCBATest extends WorkbenchTestCase {
+ Shell workbenchShell;
+ AbbotHelper abbotHelper;
+ ServerTasks serverTasks;
+ WorkbenchTasks workbenchTasks;
+ ProjectTasks projectTasks;
+
+ @Before()
+ public void setUp() {
+ workbenchShell = WorkbenchUtilities.getWorkbenchWindow().getShell();
+ abbotHelper = new AbbotHelper(workbenchShell);
+ serverTasks = new ServerTasks(workbenchShell, abbotHelper, Constants.SERVER_V30);
+ projectTasks = new ProjectTasks(workbenchShell, abbotHelper);
+ }
+
+ @Test()
+ public void testBundleImport() {
+ assertTrue(installServer());
+ //TODO import, deploy, run cba
+ assertTrue(uninstallServer());
+ }
+
+ private boolean installServer() {
+ boolean success = serverTasks.createServer();
+ if(success == true) {
+ success = serverTasks.startServer(false);
+ }
+ return success;
+ }
+
+ private boolean uninstallServer() {
+ boolean success = serverTasks.stopServer();
+ if (success == true) {
+ success = serverTasks.removeServer();
+ }
+ return success;
+ }
+
+}
Added: geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ImportEBATest.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ImportEBATest.java?rev=1024098&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ImportEBATest.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/ImportEBATest.java Tue Oct 19 03:09:43 2010
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.testsuite.v30.ui.aries;
+
+import java.io.File;
+
+import org.apache.geronimo.testsuite.common.selenium.EclipseSelenium;
+import org.apache.geronimo.testsuite.common.ui.AbbotHelper;
+import org.apache.geronimo.testsuite.common.ui.Constants;
+import org.apache.geronimo.testsuite.common.ui.ProjectTasks;
+import org.apache.geronimo.testsuite.common.ui.ServerTasks;
+import org.apache.geronimo.testsuite.common.ui.WorkbenchTasks;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.widgets.Shell;
+import org.junit.Before;
+import org.junit.Test;
+
+import abbot.swt.eclipse.junit.extensions.WorkbenchTestCase;
+import abbot.swt.eclipse.utils.WorkbenchUtilities;
+
+/*
+ * Import eba test
+ * @version $Rev$ $Date$
+ */
+public class ImportEBATest extends WorkbenchTestCase {
+ Shell workbenchShell;
+ AbbotHelper abbotHelper;
+ ServerTasks serverTasks;
+ WorkbenchTasks workbenchTasks;
+ ProjectTasks projectTasks;
+
+ @Before()
+ public void setUp() {
+ workbenchShell = WorkbenchUtilities.getWorkbenchWindow().getShell();
+ abbotHelper = new AbbotHelper(workbenchShell);
+ serverTasks = new ServerTasks(workbenchShell, abbotHelper, Constants.SERVER_V30);
+ projectTasks = new ProjectTasks(workbenchShell, abbotHelper);
+ }
+
+ @Test()
+ public void testEBAImport() {
+ assertTrue(installServer());
+ assertTrue(importEBA());
+ assertTrue(deployEBA());
+ assertTrue(runEBA());
+ assertTrue(undeployEBA());
+ assertTrue(deleteEBA());
+ assertTrue(uninstallServer());
+ }
+
+ private boolean installServer() {
+ boolean success = serverTasks.createServer();
+ if(success == true) {
+ success = serverTasks.startServer(false);
+ }
+ return success;
+ }
+
+ private boolean uninstallServer() {
+ boolean success = serverTasks.stopServer();
+ if (success == true) {
+ success = serverTasks.removeServer();
+ }
+ return success;
+ }
+
+ private boolean importEBA() {
+ boolean success = false;
+ try {
+ Shell wizardShell = abbotHelper.clickMenuItem(workbenchShell,
+ new String[]{"&File", "&Import..."}, "Import");
+ abbotHelper.clickTreeItem(wizardShell, new String[]{"OSGi", "OSGi Application(EBA)"});
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.setCursorText(getEBALocation());
+ //Need some time to calculate the bundles that are included in the eba.
+ abbotHelper.waitTime(5000);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.FINISH_LABEL);
+ abbotHelper.waitForDialogDisposal(wizardShell);
+ success = true;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private String getEBALocation() {
+ IWorkspace ws = ResourcesPlugin.getWorkspace();
+ String location = ws.getRoot().getLocation().toOSString();
+ String fileName = "com.example.helloworld.eba-0.1-incubating.eba";
+ //The location is a bit complicated.
+ location = location + File.separatorChar +
+ "src" + File.separatorChar +
+ "main" + File.separatorChar +
+ "resources" + File.separatorChar +
+ "aries" + File.separatorChar +
+ "import" + File.separatorChar +
+ "eba" + File.separatorChar + fileName;
+ return location;
+ }
+
+ private boolean deployEBA() {
+ boolean success = false;
+ try {
+ success = serverTasks.publishAllProjects();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private boolean runEBA() {
+ boolean success = false;
+ try {
+ EclipseSelenium selenium = new EclipseSelenium();
+ selenium.start();
+ selenium.open("http://localhost:8080/helloworld/sayhello");
+ selenium.waitForPageToLoad("60000");
+ success = (selenium.getHtmlSource().indexOf("Hello Aries World!") > 0);
+ abbotHelper.waitTime(AbbotHelper.WAIT_STANDARD);
+ selenium.stop();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private boolean undeployEBA() {
+ boolean success = false;
+ try {
+ success = serverTasks.removeAllProjects();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private boolean deleteEBA() {
+ boolean success = false;
+ try {
+ //The order of bundles that are deleted is arbitrary.
+ success = projectTasks.deleteProject("com.example.helloworld.web");
+ if(success == true) {
+ success = projectTasks.deleteProject("com.example.helloworld.biz");
+ }
+ if(success == true) {
+ success = projectTasks.deleteProject("com.example.helloworld.api");
+ }
+ if(success == true) {
+ success = projectTasks.deleteProject("com.example.helloworld.eba");
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+}
Added: geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/NewOSGiBundleTest.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/NewOSGiBundleTest.java?rev=1024098&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/NewOSGiBundleTest.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/NewOSGiBundleTest.java Tue Oct 19 03:09:43 2010
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.testsuite.v30.ui.aries;
+
+import java.io.FileInputStream;
+
+import org.apache.geronimo.testsuite.common.selenium.EclipseSelenium;
+import org.apache.geronimo.testsuite.common.ui.AbbotHelper;
+import org.apache.geronimo.testsuite.common.ui.Constants;
+import org.apache.geronimo.testsuite.common.ui.ProjectTasks;
+import org.apache.geronimo.testsuite.common.ui.ServerTasks;
+import org.apache.geronimo.testsuite.common.ui.WorkbenchTasks;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.widgets.Shell;
+import org.junit.Before;
+import org.junit.Test;
+
+import abbot.swt.eclipse.junit.extensions.WorkbenchTestCase;
+import abbot.swt.eclipse.utils.WorkbenchUtilities;
+
+/*
+ * New osgi bundle test
+ * @version $Rev$ $Date$
+ */
+public class NewOSGiBundleTest extends WorkbenchTestCase {
+ Shell workbenchShell;
+ AbbotHelper abbotHelper;
+ ServerTasks serverTasks;
+ WorkbenchTasks workbenchTasks;
+
+ @Before()
+ public void setUp() {
+ workbenchShell = WorkbenchUtilities.getWorkbenchWindow().getShell();
+ abbotHelper = new AbbotHelper(workbenchShell);
+ serverTasks = new ServerTasks(workbenchShell, abbotHelper, Constants.SERVER_V30 );
+ }
+
+ @Test()
+ public void testNewOSGiBundle() {
+ assertTrue(installServer());
+ assertTrue(createBundle());
+ assertTrue(copyCodeToBundle());
+ assertTrue(deployBundle());
+ assertTrue(runBundle());
+ assertTrue(undeployBundle());
+ assertTrue(deleteBundle());
+ assertTrue(uninstallServer());
+ }
+
+ private boolean installServer() {
+ boolean success = serverTasks.createServer();
+ if(success == true) {
+ success = serverTasks.startServer(false);
+ }
+ return success;
+ }
+
+ private boolean uninstallServer() {
+ boolean success = serverTasks.stopServer();
+ if (success == true) {
+ success = serverTasks.removeServer();
+ }
+ return success;
+ }
+
+ private boolean createBundle() {
+ boolean success = false;
+ try {
+ Shell wizardShell = abbotHelper.clickMenuItem(workbenchShell,
+ new String[]{"&File", "&New\tShift+Alt+N", "&Other...\tCtrl+N"}, "New");
+ abbotHelper.clickTreeItem(wizardShell, new String[]{"OSGi", "OSGi Bundle Project"});
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.setCursorText("OSGiBundleSample");
+ //Create a simple web bundle here.
+ abbotHelper.setTextField(wizardShell,
+ "Default Configuration for Apache Geronimo v3.0",
+ "OSGi Web Configuration");
+ //Don't need to add this bundle to any osgi application, so uncheck it.
+ abbotHelper.clickButton(wizardShell, "Add bundle to application");
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.FINISH_LABEL);
+ abbotHelper.waitForDialogDisposal(wizardShell);
+ success = true;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private boolean copyCodeToBundle() {
+ boolean success = false;
+ try {
+ IWorkspaceRoot aWSRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IProject aProject = aWSRoot.getProject("OSGiBundleSample");
+ String fileDir = aWSRoot.getLocation().toOSString() + "/src/main/resources/aries/create/wab";
+ //The web bundle only contains a jsp file.
+ IFile aFile = aProject.getFile("WebContent/index.jsp");
+ aFile.create(new FileInputStream(fileDir + "/index.jsp"), true, null);
+ abbotHelper.waitTime(AbbotHelper.WAIT_STANDARD);
+ success = true;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private boolean deployBundle() {
+ boolean success = false;
+ try {
+ success = serverTasks.publishAllProjects();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private boolean runBundle() {
+ boolean success = false;
+ try {
+ EclipseSelenium selenium = new EclipseSelenium();
+ selenium.start();
+ selenium.open("http://localhost:8080/OSGiBundleSample/index.jsp");
+ selenium.waitForPageToLoad("60000");
+ success = (selenium.getHtmlSource().indexOf("Test OSGi bundle!") > 0);
+ abbotHelper.waitTime(AbbotHelper.WAIT_STANDARD);
+ selenium.stop();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private boolean undeployBundle() {
+ boolean success = false;
+ try {
+ success = serverTasks.removeAllProjects();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ private boolean deleteBundle() {
+ boolean success = false;
+ try {
+ ProjectTasks projectTasks = new ProjectTasks(workbenchShell, abbotHelper);
+ success = projectTasks.deleteProject("OSGiBundleSample");
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+}
Added: geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/NewOSGiCompositeBundleTest.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/NewOSGiCompositeBundleTest.java?rev=1024098&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/NewOSGiCompositeBundleTest.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/NewOSGiCompositeBundleTest.java Tue Oct 19 03:09:43 2010
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.testsuite.v30.ui.aries;
+
+import org.apache.geronimo.testsuite.common.ui.AbbotHelper;
+import org.apache.geronimo.testsuite.common.ui.Constants;
+import org.apache.geronimo.testsuite.common.ui.ServerTasks;
+import org.apache.geronimo.testsuite.common.ui.WorkbenchTasks;
+import org.eclipse.swt.widgets.Shell;
+import org.junit.Before;
+import org.junit.Test;
+
+import abbot.swt.eclipse.junit.extensions.WorkbenchTestCase;
+import abbot.swt.eclipse.utils.WorkbenchUtilities;
+
+/*
+ * New cba test.
+ * @version $Rev$ $Date$
+ */
+public class NewOSGiCompositeBundleTest extends WorkbenchTestCase {
+ Shell workbenchShell;
+ AbbotHelper abbotHelper;
+ ServerTasks serverTasks;
+ WorkbenchTasks workbenchTasks;
+
+ @Before()
+ public void setUp() {
+ workbenchShell = WorkbenchUtilities.getWorkbenchWindow().getShell();
+ abbotHelper = new AbbotHelper(workbenchShell);
+ serverTasks = new ServerTasks(workbenchShell, abbotHelper, Constants.SERVER_V30 );
+ }
+
+ @Test()
+ public void testNewOSGiCompositeBundle() {
+ assertTrue(installServer());
+ //TODO create, deploy, run, undeploy cba
+ assertTrue(uninstallServer());
+ }
+
+ private boolean installServer() {
+ boolean success = serverTasks.createServer();
+ if(success == true) {
+ success = serverTasks.startServer(false);
+ }
+ return success;
+ }
+
+ private boolean uninstallServer() {
+ boolean success = serverTasks.stopServer();
+ if (success == true) {
+ success = serverTasks.removeServer();
+ }
+ return success;
+ }
+
+}
Added: geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/Tutorial5MinuteTest.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/Tutorial5MinuteTest.java?rev=1024098&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/Tutorial5MinuteTest.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/testsuite/plugins/org.apache.geronimo.testsuite.v30/src/main/java/org/apache/geronimo/testsuite/v30/ui/aries/Tutorial5MinuteTest.java Tue Oct 19 03:09:43 2010
@@ -0,0 +1,372 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.testsuite.v30.ui.aries;
+
+import java.io.FileInputStream;
+
+import org.apache.geronimo.testsuite.common.selenium.EclipseSelenium;
+import org.apache.geronimo.testsuite.common.ui.AbbotHelper;
+import org.apache.geronimo.testsuite.common.ui.Constants;
+import org.apache.geronimo.testsuite.common.ui.ProjectTasks;
+import org.apache.geronimo.testsuite.common.ui.ServerTasks;
+import org.apache.geronimo.testsuite.common.ui.WorkbenchTasks;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.widgets.Shell;
+import org.junit.Before;
+import org.junit.Test;
+
+import abbot.swt.eclipse.junit.extensions.WorkbenchTestCase;
+import abbot.swt.eclipse.utils.WorkbenchUtilities;
+
+/*
+ * Tutorial 5 minutes test with a bit complicated osgi application.
+ * @version $Rev$ $Date$
+ */
+public class Tutorial5MinuteTest extends WorkbenchTestCase {
+ Shell workbenchShell;
+ AbbotHelper abbotHelper;
+ ServerTasks serverTasks;
+ WorkbenchTasks workbenchTasks;
+
+ @Before()
+ public void setUp() {
+ workbenchShell = WorkbenchUtilities.getWorkbenchWindow().getShell();
+ abbotHelper = new AbbotHelper(workbenchShell);
+ serverTasks = new ServerTasks(workbenchShell, abbotHelper, Constants.SERVER_V30);
+ }
+
+ @Test()
+ public void test() {
+ assertTrue(installServer());
+ assertTrue(createOSGiApp());
+ assertTrue(createServiceBundle());
+ assertTrue(copyCodeToServiceBundle());
+ assertTrue(createServiceImplBundle());
+ assertTrue(copyCodeToServiceImplBundle());
+ assertTrue(createBlueprintFile());
+ assertTrue(copyCodeToBlueprintFile());
+ assertTrue(createWebBundle());
+ assertTrue(copyCodeToWebBundle());
+ assertTrue(deployOSGiApp());
+ assertTrue(runOSGiApp());
+ assertTrue(undeployOSGiApp());
+ assertTrue(deleteOSGiApp());
+ assertTrue(uninstallServer());
+ }
+
+ /*
+ * Create and install server
+ */
+ private boolean installServer() {
+ boolean success = serverTasks.createServer();
+ if (success == true) {
+ success = serverTasks.startServer(false);
+ }
+ return success;
+ }
+
+ /*
+ * Stop and uninstall server
+ */
+ private boolean uninstallServer() {
+ boolean success = serverTasks.stopServer();
+ if (success == true) {
+ success = serverTasks.removeServer();
+ }
+ return success;
+ }
+
+ /*
+ * Create osgi application that is used to include bundles.
+ */
+ private boolean createOSGiApp() {
+ boolean success = false;
+ try {
+ Shell wizardShell = abbotHelper.clickMenuItem(workbenchShell, new String[] { "&File", "&New\tShift+Alt+N",
+ "&Other...\tCtrl+N" }, "New");
+ abbotHelper.clickTreeItem(wizardShell, new String[] { "OSGi", "OSGi Application Project" });
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.setCursorText("OSGiAppSample");
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.FINISH_LABEL);
+ abbotHelper.waitForDialogDisposal(wizardShell);
+ success = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ /*
+ * Create service bundle.
+ */
+ private boolean createServiceBundle() {
+ boolean success = false;
+ try {
+ Shell wizardShell = abbotHelper.clickMenuItem(workbenchShell, new String[] { "&File", "&New\tShift+Alt+N",
+ "&Other...\tCtrl+N" }, "New");
+ abbotHelper.clickTreeItem(wizardShell, new String[] { "OSGi", "OSGi Bundle Project" });
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.setCursorText("OSGiServiceBundleSample");
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.FINISH_LABEL);
+ abbotHelper.waitForDialogDisposal(wizardShell);
+ success = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ /*
+ * Copy code to service bundle. This bundle provides an interface that contains a simple method.
+ */
+ private boolean copyCodeToServiceBundle() {
+ boolean success = false;
+ try {
+ IWorkspaceRoot aWSRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IProject aProject = aWSRoot.getProject("OSGiServiceBundleSample");
+ IFolder aFolder = aProject.getFolder("src/com.example.helloworld.api");
+ aFolder.create(false, true, null);
+ String fileDir = aWSRoot.getLocation().toOSString() + "/src/main/resources/aries/create/tutorial/api";
+ IFile aFile = aProject.getFile("src/com.example.helloworld.api/HelloworldService.java");
+ aFile.create(new FileInputStream(fileDir + "/HelloworldService.java"), true, null);
+ abbotHelper.waitTime(AbbotHelper.WAIT_STANDARD);
+ aFile = aProject.getFile("BundleContent/META-INF/MANIFEST.MF");
+ aFile.setContents(new FileInputStream(fileDir + "/MANIFEST.MF"), true, true, null);
+ abbotHelper.waitTime(AbbotHelper.WAIT_STANDARD);
+ success = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ /*
+ * Create service implementation bundle.
+ */
+ private boolean createServiceImplBundle() {
+ boolean success = false;
+ try {
+ Shell wizardShell = abbotHelper.clickMenuItem(workbenchShell, new String[] { "&File", "&New\tShift+Alt+N",
+ "&Other...\tCtrl+N" }, "New");
+ abbotHelper.clickTreeItem(wizardShell, new String[] { "OSGi", "OSGi Bundle Project" });
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.setCursorText("OSGiServiceImplBundleSample");
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.FINISH_LABEL);
+ abbotHelper.waitForDialogDisposal(wizardShell);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ /*
+ * Copy code to service implementation bundle. This bundle implements the service interface.
+ */
+ private boolean copyCodeToServiceImplBundle() {
+ boolean success = false;
+ try {
+ IWorkspaceRoot aWSRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IProject aProject = aWSRoot.getProject("OSGiServiceImplBundleSample");
+ IFolder aFolder = aProject.getFolder("src/com.example.helloworld.biz");
+ aFolder.create(false, true, null);
+ abbotHelper.waitTime(AbbotHelper.WAIT_STANDARD);
+ String fileDir = aWSRoot.getLocation().toOSString() + "/src/main/resources/aries/create/tutorial/biz";
+ IFile aFile = aProject.getFile("BundleContent/META-INF/MANIFEST.MF");
+ aFile.setContents(new FileInputStream(fileDir + "/MANIFEST.MF"), true, true, null);
+ abbotHelper.waitTime(AbbotHelper.WAIT_STANDARD);
+ aFile = aProject.getFile("src/com.example.helloworld.biz/HelloworldServiceImpl.java");
+ aFile.create(new FileInputStream(fileDir + "/HelloworldServiceImpl.java"), true, null);
+ abbotHelper.waitTime(AbbotHelper.WAIT_STANDARD);
+ success = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ /*
+ * Create blueprint file for service implementation bundle.
+ */
+ private boolean createBlueprintFile() {
+ boolean success = false;
+ try {
+ Shell wizardShell = abbotHelper.rightClickItem(workbenchShell, "OSGiServiceImplBundleSample", new String[] {
+ "&New", "&Other...\tCtrl+N" }, "New");
+ abbotHelper.clickTreeItem(wizardShell, new String[] { "OSGi", "Blueprint File" });
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.FINISH_LABEL);
+ abbotHelper.waitForDialogDisposal(wizardShell);
+ success = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ /*
+ * Set the content of the blueprint file.
+ */
+ private boolean copyCodeToBlueprintFile() {
+ boolean success = false;
+ try {
+ IWorkspaceRoot aWSRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IProject aProject = aWSRoot.getProject("OSGiServiceImplBundleSample");
+ String fileDir = aWSRoot.getLocation().toOSString() + "/src/main/resources/aries/create/tutorial/biz";
+ IFile aFile = aProject.getFile("BundleContent/OSGI-INF/blueprint/blueprint.xml");
+ aFile.setContents(new FileInputStream(fileDir + "/blueprint.xml"), true, true, null);
+ abbotHelper.waitTime(AbbotHelper.WAIT_STANDARD);
+ success = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ /*
+ * Create web bundle.
+ */
+ private boolean createWebBundle() {
+ boolean success = true;
+ try {
+ Shell wizardShell = abbotHelper.clickMenuItem(workbenchShell, new String[] { "&File", "&New\tShift+Alt+N",
+ "&Other...\tCtrl+N" }, "New");
+ abbotHelper.clickTreeItem(wizardShell, new String[] { "OSGi", "OSGi Bundle Project" });
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.setCursorText("OSGiWebBundleSample");
+ //This is a web bundle.
+ abbotHelper.setTextField(wizardShell, "Default Configuration for Apache Geronimo v3.0",
+ "OSGi Web Configuration");
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.NEXT_LABEL);
+ abbotHelper.clickButton(wizardShell, IDialogConstants.FINISH_LABEL);
+ abbotHelper.waitForDialogDisposal(wizardShell);
+ success = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ /*
+ * Copy code to web bundle. This bundle provides a single servlet and a single jsp file.
+ */
+ private boolean copyCodeToWebBundle() {
+ boolean success = false;
+ try {
+ IWorkspaceRoot aWSRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IProject aProject = aWSRoot.getProject("OSGiWebBundleSample");
+ String fileDir = aWSRoot.getLocation().toOSString() + "/src/main/resources/aries/create/tutorial/web";
+ IFile aFile = aProject.getFile("WebContent/META-INF/MANIFEST.MF");
+ aFile.setContents(new FileInputStream(fileDir + "/MANIFEST.MF"), true, true, null);
+ abbotHelper.waitTime(AbbotHelper.WAIT_STANDARD);
+ aFile = aProject.getFile("WebContent/WEB-INF/web.xml");
+ aFile.setContents(new FileInputStream(fileDir + "/web.xml"), true, true, null);
+ abbotHelper.waitTime(AbbotHelper.WAIT_STANDARD);
+ aFile = aProject.getFile("WebContent/index.jsp");
+ aFile.create(new FileInputStream(fileDir + "/index.jsp"), true, null);
+ abbotHelper.waitTime(AbbotHelper.WAIT_STANDARD);
+ aFile = aProject.getFile("JavaResources:src/com.example.helloworld.web/HelloWorld.java");
+ aFile.create(new FileInputStream(fileDir + "/HelloWorld.java"), true, null);
+ abbotHelper.waitTime(AbbotHelper.WAIT_STANDARD);
+ success = true;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ /*
+ * Deploy the osgi application to server.
+ */
+ private boolean deployOSGiApp() {
+ boolean success = false;
+ try {
+ success = serverTasks.publishAllProjects();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ /*
+ * Run the osgi application on server.
+ */
+ private boolean runOSGiApp() {
+ boolean success = false;
+ try {
+ EclipseSelenium selenium = new EclipseSelenium();
+ selenium.start();
+ selenium.open("http://localhost:8080/OSGiWebBundleSample/sayhello");
+ selenium.waitForPageToLoad("60000");
+ success = (selenium.getHtmlSource().indexOf("Hello Aries World!") > 0);
+ abbotHelper.waitTime(AbbotHelper.WAIT_STANDARD);
+ selenium.stop();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ /*
+ * Undeploy the osgi application.
+ */
+ private boolean undeployOSGiApp() {
+ boolean success = false;
+ try {
+ success = serverTasks.removeAllProjects();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+
+ /*
+ * Delete the osgi application.
+ */
+ private boolean deleteOSGiApp() {
+ boolean success = false;
+ try {
+ ProjectTasks projectTasks = new ProjectTasks(workbenchShell, abbotHelper);
+ //The order of bundles that are deleted is arbitrary.
+ success = projectTasks.deleteProject("OSGiWebBundleSample");
+ if(success == true) {
+ success = projectTasks.deleteProject("OSGiServiceImplBundleSample");
+ }
+ if(success == true) {
+ success = projectTasks.deleteProject("OSGiServiceBundleSample");
+ }
+ if(success == true) {
+ success = projectTasks.deleteProject("OSGiAppSample");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return success;
+ }
+}