You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2008/09/25 11:27:14 UTC
svn commit: r698888 - in /servicemix/smx4/kernel/trunk/gshell/gshell-admin:
./ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/
src/test/java/org/apache/servicemix/ src/test/java/org/apache/servicemix/jpm/
Author: gnodet
Date: Thu Sep 25 02:27:14 2008
New Revision: 698888
URL: http://svn.apache.org/viewvc?rev=698888&view=rev
Log:
Add a simple test for process management library
Added:
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/test/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/test/java/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/test/java/org/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/test/java/org/apache/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/test/java/org/apache/servicemix/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/test/java/org/apache/servicemix/jpm/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/test/java/org/apache/servicemix/jpm/MainTest.java
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/test/java/org/apache/servicemix/jpm/ProcessTest.java
Modified:
servicemix/smx4/kernel/trunk/gshell/gshell-admin/pom.xml
Modified: servicemix/smx4/kernel/trunk/gshell/gshell-admin/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/pom.xml?rev=698888&r1=698887&r2=698888&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/pom.xml (original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/pom.xml Thu Sep 25 02:27:14 2008
@@ -76,6 +76,13 @@
<artifactId>spring-osgi-core</artifactId>
<version>${spring.osgi.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
Added: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/test/java/org/apache/servicemix/jpm/MainTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/test/java/org/apache/servicemix/jpm/MainTest.java?rev=698888&view=auto
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/test/java/org/apache/servicemix/jpm/MainTest.java (added)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/test/java/org/apache/servicemix/jpm/MainTest.java Thu Sep 25 02:27:14 2008
@@ -0,0 +1,24 @@
+/*
+ * 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.servicemix.jpm;
+
+public class MainTest {
+
+ public static void main(String[] args) throws Exception {
+ Thread.sleep(Long.parseLong(args[0]));
+ }
+}
Added: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/test/java/org/apache/servicemix/jpm/ProcessTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/test/java/org/apache/servicemix/jpm/ProcessTest.java?rev=698888&view=auto
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/test/java/org/apache/servicemix/jpm/ProcessTest.java (added)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/test/java/org/apache/servicemix/jpm/ProcessTest.java Thu Sep 25 02:27:14 2008
@@ -0,0 +1,64 @@
+/*
+ * 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.servicemix.jpm;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class ProcessTest {
+
+ @Test
+ public void testCreate() throws Exception {
+ StringBuilder command = new StringBuilder();
+ command.append("java -classpath ");
+ String clRes = getClass().getName().replace('.', '/') + ".class";
+ String str = getClass().getClassLoader().getResource(clRes).toString();
+ str = str.substring("file:".length(), str.indexOf(clRes));
+ command.append(str);
+ command.append(" ");
+ command.append(MainTest.class.getName());
+ command.append(" ");
+ command.append(60000);
+ System.err.println("Executing: " + command.toString());
+
+ ProcessBuilder builder = ProcessBuilderFactory.newInstance().newBuilder();
+ Process p = builder.command(command.toString()).start();
+ assertNotNull(p);
+ System.err.println("Process: " + p.getPid());
+ assertNotNull(p.getPid());
+ Thread.currentThread().sleep(1000);
+ System.err.println("Running: " + p.isRunning());
+ assertTrue(p.isRunning());
+ System.err.println("Destroying");
+ p.destroy();
+ System.err.println("Running: " + p.isRunning());
+ assertFalse(p.isRunning());
+ }
+
+ /*
+ @Test
+ @Ignore("When the process creation fails, no error is reported by the script")
+ public void testFailure() throws Exception {
+ ProcessBuilder builder = ProcessBuilderFactory.newInstance().newBuilder();
+ Process p = builder.command("ec").start();
+ fail("An exception should have been thrown");
+ }
+ */
+}