Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.virgo.kernel.smoketest')
-rw-r--r--org.eclipse.virgo.kernel.smoketest/.classpath10
-rw-r--r--org.eclipse.virgo.kernel.smoketest/.project17
-rw-r--r--org.eclipse.virgo.kernel.smoketest/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--org.eclipse.virgo.kernel.smoketest/build.xml9
-rw-r--r--org.eclipse.virgo.kernel.smoketest/ivy.xml25
-rw-r--r--org.eclipse.virgo.kernel.smoketest/src/main/java/.gitignore0
-rw-r--r--org.eclipse.virgo.kernel.smoketest/src/main/resources/.gitignore0
-rw-r--r--org.eclipse.virgo.kernel.smoketest/src/test/.gitignore0
-rw-r--r--org.eclipse.virgo.kernel.smoketest/src/test/java/org/eclipse/virgo/kernel/smoketest/AbstractKernelTests.java300
-rw-r--r--org.eclipse.virgo.kernel.smoketest/src/test/java/org/eclipse/virgo/kernel/smoketest/KernelStartupAndShutdownTests.java32
-rw-r--r--org.eclipse.virgo.kernel.smoketest/src/test/resources/.gitignore0
11 files changed, 405 insertions, 0 deletions
diff --git a/org.eclipse.virgo.kernel.smoketest/.classpath b/org.eclipse.virgo.kernel.smoketest/.classpath
new file mode 100644
index 00000000..4ffe210f
--- /dev/null
+++ b/org.eclipse.virgo.kernel.smoketest/.classpath
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/main/resources"/>
+ <classpathentry kind="src" path="src/test/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.io/2.1.0.D-20100420091708/org.eclipse.virgo.util.io-2.1.0.D-20100420091708.jar" sourcepath="/KERNEL_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.io/2.1.0.D-20100420091708/org.eclipse.virgo.util.io-sources-2.1.0.D-20100420091708.jar"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/org.eclipse.virgo.kernel.smoketest/.project b/org.eclipse.virgo.kernel.smoketest/.project
new file mode 100644
index 00000000..3e467a68
--- /dev/null
+++ b/org.eclipse.virgo.kernel.smoketest/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.virgo.kernel.smoketest</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.virgo.kernel.smoketest/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.virgo.kernel.smoketest/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..4f1c37da
--- /dev/null
+++ b/org.eclipse.virgo.kernel.smoketest/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Mon Aug 17 12:06:29 BST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.eclipse.virgo.kernel.smoketest/build.xml b/org.eclipse.virgo.kernel.smoketest/build.xml
new file mode 100644
index 00000000..d12096d2
--- /dev/null
+++ b/org.eclipse.virgo.kernel.smoketest/build.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="org.eclipse.virgo.kernel.smoketest">
+
+ <property file="${basedir}/../build.properties"/>
+ <property file="${basedir}/../build.versions"/>
+ <import file="${basedir}/../virgo-build/standard/default.xml"/>
+ <import file="${basedir}/../build-kernel/test-package.xml"/>
+
+</project>
diff --git a/org.eclipse.virgo.kernel.smoketest/ivy.xml b/org.eclipse.virgo.kernel.smoketest/ivy.xml
new file mode 100644
index 00000000..70269097
--- /dev/null
+++ b/org.eclipse.virgo.kernel.smoketest/ivy.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" href="http://ivyrep.jayasoft.org/ivy-doc.xsl"?>
+<ivy-module xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://incubator.apache.org/ivy/schemas/ivy.xsd"
+ version="1.3">
+
+ <info organisation="org.eclipse.virgo.kernel" module="${ant.project.name}" />
+
+ <configurations>
+ <include file="${virgo.build.dir}/common/default-ivy-configurations.xml" />
+ </configurations>
+
+ <publications>
+ <artifact name="${ant.project.name}" />
+ <artifact name="${ant.project.name}-sources" type="src" ext="jar" />
+ </publications>
+
+ <dependencies>
+ <dependency org="org.junit" name="com.springsource.org.junit" rev="${org.junit}" conf="test->runtime" />
+ <dependency org="org.eclipse.virgo.util" name="org.eclipse.virgo.util.io" rev="${org.eclipse.virgo.util}" conf="test->runtime"/>
+
+ <override org="org.eclipse.virgo.util" rev="${org.eclipse.virgo.util}"/>
+ </dependencies>
+
+</ivy-module>
diff --git a/org.eclipse.virgo.kernel.smoketest/src/main/java/.gitignore b/org.eclipse.virgo.kernel.smoketest/src/main/java/.gitignore
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.smoketest/src/main/java/.gitignore
diff --git a/org.eclipse.virgo.kernel.smoketest/src/main/resources/.gitignore b/org.eclipse.virgo.kernel.smoketest/src/main/resources/.gitignore
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.smoketest/src/main/resources/.gitignore
diff --git a/org.eclipse.virgo.kernel.smoketest/src/test/.gitignore b/org.eclipse.virgo.kernel.smoketest/src/test/.gitignore
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.smoketest/src/test/.gitignore
diff --git a/org.eclipse.virgo.kernel.smoketest/src/test/java/org/eclipse/virgo/kernel/smoketest/AbstractKernelTests.java b/org.eclipse.virgo.kernel.smoketest/src/test/java/org/eclipse/virgo/kernel/smoketest/AbstractKernelTests.java
new file mode 100644
index 00000000..cec6e230
--- /dev/null
+++ b/org.eclipse.virgo.kernel.smoketest/src/test/java/org/eclipse/virgo/kernel/smoketest/AbstractKernelTests.java
@@ -0,0 +1,300 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.smoketest;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.management.ManagementFactory;
+import java.lang.management.OperatingSystemMXBean;
+import java.rmi.ConnectIOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+
+import org.eclipse.virgo.util.io.FileCopyUtils;
+import org.eclipse.virgo.util.io.NetUtils;
+
+public class AbstractKernelTests {
+
+ private static MBeanServerConnection connection = null;
+ private static String binDir = null;
+ private static String configDir = null;
+ private static String watchRepoDir = null;
+ private static String srcDir = "src/test/resources";
+ private static String srcFileName = "org.eclipse.virgo.repository.properties";
+ private static String bundlesDir = "src/test/resources/bundles";
+ private static String[] bundleNames = new String[] { "org.springframework.dmServer.testtool.incoho.domain-1.0.0.RELEASE.jar" };
+
+ private static Process process = null;
+ private static ProcessBuilder pb = null;
+ private static File startup = null;
+ private static String startupFileName = null;
+ private static File shutdown = null;
+ private static String shutdownFileName = null;
+ private static File startupURI = null;
+ private static File shutdownURI = null;
+ private static OperatingSystemMXBean os = ManagementFactory
+ .getOperatingSystemMXBean();
+ public static final long HALF_SECOND = 500;
+
+ public static final long TWO_MINUTES = 120 * 1000;
+ public static final String STATUS_STARTED = "STARTED";
+ public static final String STATUS_STARTING = "STARTING";
+
+ protected static MBeanServerConnection getMBeanServerConnection()
+ throws Exception {
+ String severDir = null;
+ Map<String, String[]> env = new HashMap<String, String[]>();
+
+ File testExpanded = new File("./target/test-expanded/");
+ for (File mainDir : testExpanded.listFiles()) {
+ if (mainDir.isDirectory()) {
+ severDir = new File(mainDir.toURI()).getCanonicalPath();
+
+ }
+ }
+ String[] creds = { "admin", "springsource" };
+ env.put(JMXConnector.CREDENTIALS, creds);
+
+ System.setProperty("javax.net.ssl.trustStore", severDir
+ + "/config/keystore");
+ System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
+
+ JMXServiceURL url = new JMXServiceURL(
+ "service:jmx:rmi:///jndi/rmi://localhost:9875/jmxrmi");
+ connection = JMXConnectorFactory.connect(url, env)
+ .getMBeanServerConnection();
+ return connection;
+ }
+
+ protected static String getKernelStartUpStatus() throws Exception {
+ String kernelStartupStatus = (String) getMBeanServerConnection()
+ .getAttribute(
+ new ObjectName(
+ "org.eclipse.virgo.kernel:type=KernelStatus"),
+ "Status");
+ return kernelStartupStatus;
+ }
+
+ private static String getKernelBinDir() throws IOException {
+ if (binDir == null) {
+ File testExpanded = new File("./target/test-expanded/");
+ for (File candidate : testExpanded.listFiles()) {
+ if (candidate.isDirectory()) {
+ binDir = new File(candidate, "bin").getCanonicalPath();
+ break;
+ }
+ }
+ }
+ return binDir;
+ }
+
+ protected static String getKernelConfigDir() throws IOException {
+ if (configDir == null) {
+ File testExpanded = new File("./target/test-expanded/");
+ for (File candidate : testExpanded.listFiles()) {
+ if (candidate.isDirectory()) {
+ configDir = new File(candidate, "config")
+ .getCanonicalPath();
+ break;
+ }
+ }
+ }
+ return configDir;
+ }
+
+ protected static void configureWatchRepoWithDefaultConfiguration(
+ String destDir) {
+ try {
+ FileCopyUtils.copy(new File(srcDir, srcFileName), new File(destDir,
+ srcFileName));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ createWatchedRepoDir();
+ }
+
+ protected static void addBundlesToWatchedRepository(String watchRepoDir) {
+ for (String bundleName : bundleNames) {
+ try {
+ FileCopyUtils.copy(new File(bundlesDir, bundleName), new File(
+ watchRepoDir, bundleName));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ protected static String getWatchedRepoDir() throws IOException {
+ if (watchRepoDir == null) {
+ File testExpanded = new File("./target/test-expanded/");
+ for (File mainDir : testExpanded.listFiles()) {
+ if (mainDir.isDirectory()) {
+ File repositoryDir = new File(mainDir, "repository")
+ .getCanonicalFile();
+ if (repositoryDir.isDirectory()) {
+ watchRepoDir = new File(repositoryDir, "watched-repo")
+ .getCanonicalPath();
+ break;
+ }
+
+ }
+ }
+ }
+ return watchRepoDir;
+ }
+
+ protected static void createWatchedRepoDir() {
+ File testExpanded = new File("./target/test-expanded/");
+ for (File candidate : testExpanded.listFiles()) {
+ if (candidate.isDirectory()) {
+ File repoDir = new File(candidate, "repository");
+ if (repoDir.mkdir()) {
+ new File(repoDir, "watched-repo").mkdir();
+ }
+ }
+ }
+ }
+
+ public static void waitForKernelStartFully() throws Exception {
+ waitForKernelStartFully(TWO_MINUTES, HALF_SECOND);
+ }
+
+ public static void waitForKernelShutdownFully() throws Exception {
+ waitForKernelShutdownFully(TWO_MINUTES, HALF_SECOND);
+ }
+
+ private static void waitForKernelStartFully(long duration, long interval) throws Exception {
+ long startTime = System.currentTimeMillis();
+ while (System.currentTimeMillis() - startTime < duration) {
+ try {
+ if (getKernelStartUpStatus().equals(STATUS_STARTED)) {
+ return;
+ } else if (getKernelStartUpStatus().equals(STATUS_STARTING)) {
+ continue;
+ }
+ } catch (InstanceNotFoundException e) {
+ continue;
+ } catch (ConnectIOException e) {
+ continue;
+ } catch (IOException e) {
+ continue;
+ }
+ Thread.sleep(interval);
+ }
+ }
+
+ private static void waitForKernelShutdownFully(long duration, long interval) throws Exception {
+ long startTime = System.currentTimeMillis();
+ while (System.currentTimeMillis() - startTime < duration) {
+ try {
+ if (!getKernelStartUpStatus().equals(STATUS_STARTED)) {
+ if (NetUtils.isPortAvailable(9875)) {
+ return;
+ }
+ }
+ } catch (InstanceNotFoundException e) {
+ return;
+ } catch (ConnectIOException e) {
+ return;
+ } catch (IOException e) {
+ return;
+ }
+ Thread.sleep(interval);
+ }
+ }
+
+ protected static class KernelStartUpThread implements Runnable {
+ public KernelStartUpThread() {
+ }
+
+ public void run() {
+ String[] args = null;
+ try {
+ if (os.getName().contains("Windows")) {
+ startup = new File(getKernelBinDir(), "startup.bat");
+ startupURI = new File(startup.toURI());
+ startupFileName = startupURI.getCanonicalPath();
+
+ } else {
+ startup = new File(getKernelBinDir(), "startup.sh");
+ startupURI = new File(startup.toURI());
+ startupFileName = startupURI.getCanonicalPath();
+ }
+ args = new String[] { startupFileName };
+ pb = new ProcessBuilder(args);
+ pb.redirectErrorStream(true);
+ Map<String, String> env = pb.environment();
+ env.put("JAVA_HOME", System.getProperty("java.home"));
+
+ process = pb.start();
+
+ InputStream is = process.getInputStream();
+ InputStreamReader isr = new InputStreamReader(is);
+ BufferedReader br = new BufferedReader(isr);
+ String line;
+ while ((line = br.readLine()) != null) {
+ System.out.println(line);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ protected static class KernelShutdownThread implements Runnable {
+ public KernelShutdownThread() {
+ }
+
+ public void run() {
+ String[] args = null;
+ try {
+ if (os.getName().contains("Windows")) {
+ shutdown = new File(getKernelBinDir(), "shutdown.bat");
+ shutdownURI = new File(shutdown.toURI());
+ shutdownFileName = shutdownURI.getCanonicalPath();
+ } else {
+ shutdown = new File(getKernelBinDir(), "shutdown.sh");
+ shutdownURI = new File(shutdown.toURI());
+ shutdownFileName = shutdownURI.getCanonicalPath();
+ }
+ args = new String[] { shutdownFileName };
+ pb = new ProcessBuilder(args);
+ pb.redirectErrorStream(true);
+ Map<String, String> env = pb.environment();
+ env.put("JAVA_HOME", System.getProperty("java.home"));
+
+ process = pb.start();
+
+ InputStream is = process.getInputStream();
+ InputStreamReader isr = new InputStreamReader(is);
+ BufferedReader br = new BufferedReader(isr);
+ String line;
+ while ((line = br.readLine()) != null) {
+ System.out.println(line);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/org.eclipse.virgo.kernel.smoketest/src/test/java/org/eclipse/virgo/kernel/smoketest/KernelStartupAndShutdownTests.java b/org.eclipse.virgo.kernel.smoketest/src/test/java/org/eclipse/virgo/kernel/smoketest/KernelStartupAndShutdownTests.java
new file mode 100644
index 00000000..95c515be
--- /dev/null
+++ b/org.eclipse.virgo.kernel.smoketest/src/test/java/org/eclipse/virgo/kernel/smoketest/KernelStartupAndShutdownTests.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.smoketest;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+public class KernelStartupAndShutdownTests extends AbstractKernelTests {
+
+ @Test
+ public void testKernelStartUpStatus() throws Exception {
+ new Thread(new KernelStartUpThread()).start();
+ AbstractKernelTests.waitForKernelStartFully();
+ assertEquals(STATUS_STARTED, getKernelStartUpStatus());
+ }
+
+ @Test
+ public void testKernelShutdownStatus() throws Exception {
+ new Thread(new KernelShutdownThread()).start();
+ AbstractKernelTests.waitForKernelShutdownFully();
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.smoketest/src/test/resources/.gitignore b/org.eclipse.virgo.kernel.smoketest/src/test/resources/.gitignore
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.smoketest/src/test/resources/.gitignore

Back to the top