|
From: <cr...@us...> - 2009-01-25 01:04:40
|
Revision: 4908
http://jnode.svn.sourceforge.net/jnode/?rev=4908&view=rev
Author: crawley
Date: 2009-01-25 01:04:36 +0000 (Sun, 25 Jan 2009)
Log Message:
-----------
Another checkpoint of command test harness, etc
Modified Paths:
--------------
trunk/shell/src/emu/org/jnode/emu/Emu.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/BjornePseudoPlugin.java
trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
trunk/shell/src/test/org/jnode/test/shell/command/posix/posix-command-tests.xml
trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java
trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java
trunk/shell/src/test/org/jnode/test/shell/harness/JNodeTestRunnerBase.java
trunk/shell/src/test/org/jnode/test/shell/harness/PseudoPlugin.java
trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestCommandShell.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestEmu.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnable.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecification.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationException.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationParser.java
Added Paths:
-----------
trunk/shell/src/test/org/jnode/test/shell/harness/DummyPseudoPlugin.java
trunk/shell/src/test/org/jnode/test/shell/harness/PluginSpecification.java
trunk/shell/src/test/org/jnode/test/shell/harness/TestSetSpecification.java
Removed Paths:
-------------
trunk/shell/src/test/org/jnode/test/shell/harness/Test.java
Modified: trunk/shell/src/emu/org/jnode/emu/Emu.java
===================================================================
--- trunk/shell/src/emu/org/jnode/emu/Emu.java 2009-01-24 05:34:47 UTC (rev 4907)
+++ trunk/shell/src/emu/org/jnode/emu/Emu.java 2009-01-25 01:04:36 UTC (rev 4908)
@@ -59,14 +59,21 @@
};
// FIXME configuring a hard-coded list of command plugins is a bad idea.
- private static final String[] PLUGIN_NAMES = new String[] {
+ private static final String[] DEFAULT_PLUGIN_NAMES = new String[] {
"org.jnode.shell.command",
- "org.jnode.shell.command.posix",
"org.jnode.shell.command.driver.console",
"org.jnode.apps.editor",
"org.jnode.apps.edit",
"org.jnode.apps.console",
};
+
+ private final File root;
+ private final AliasManager aliasMgr;
+ private final SyntaxManager syntaxMgr;
+
+ public Emu(File root) throws EmuException {
+ this(root, DEFAULT_PLUGIN_NAMES);
+ }
/**
* The constructor initializes a minimal subset of JNode services to allow us to run JNode commands.
@@ -74,21 +81,20 @@
* @param root the notional JNode sandbox root directory or <code>null</code>.
* @throws EmuException
*/
- public Emu(File root) throws EmuException {
+ public Emu(File root, String[] pluginNames) throws EmuException {
if (root == null) {
root = new File("").getAbsoluteFile();
System.err.println("Assuming that the JNode root is '" + root + "'");
}
+ this.root = root;
InitialNaming.setNameSpace(new BasicNameSpace());
try {
InitialNaming.bind(DeviceManager.NAME, DeviceManager.INSTANCE);
- AliasManager aliasMgr =
- new DefaultAliasManager(new DummyExtensionPoint()).createAliasManager();
- SyntaxManager syntaxMgr =
- new DefaultSyntaxManager(new DummyExtensionPoint()).createSyntaxManager();
- for (String pluginName : PLUGIN_NAMES) {
- configurePluginCommands(root, pluginName, aliasMgr, syntaxMgr);
+ aliasMgr = new DefaultAliasManager(new DummyExtensionPoint()).createAliasManager();
+ syntaxMgr = new DefaultSyntaxManager(new DummyExtensionPoint()).createSyntaxManager();
+ for (String pluginName : pluginNames) {
+ configurePluginCommands(pluginName);
}
System.setProperty("jnode.invoker", "thread");
System.setProperty("jnode.interpreter", "redirecting");
@@ -105,27 +111,22 @@
/**
* Configure any command classes specified by a given plugin's descriptor
*
- * @param root the root directory for the JNode sandbox.
* @param pluginName the plugin to be processed
- * @param aliasMgr the alias manager to be populated
- * @param syntaxMgr the syntax manager to be populated
* @throws EmuException
*/
- private void configurePluginCommands(File root, String pluginName, AliasManager aliasMgr,
- SyntaxManager syntaxMgr) throws EmuException {
- XMLElement pluginDescriptor = loadPluginDescriptor(root, pluginName);
- extractAliases(pluginDescriptor, aliasMgr);
- extractSyntaxBundles(pluginDescriptor, syntaxMgr);
+ public void configurePluginCommands(String pluginName) throws EmuException {
+ XMLElement pluginDescriptor = loadPluginDescriptor(pluginName);
+ extractAliases(pluginDescriptor);
+ extractSyntaxBundles(pluginDescriptor);
}
/**
* Populate the supplied syntax manager with syntax entries from a plugin descriptor.
*
* @param pluginDescriptor the plugin descriptor's root XML element
- * @param syntaxMgr the syntax manager to be populated.
* @throws EmuException
*/
- private void extractSyntaxBundles(XMLElement pluginDescriptor, SyntaxManager syntaxMgr)
+ private void extractSyntaxBundles(XMLElement pluginDescriptor)
throws EmuException {
XMLElement syntaxesDescriptor = findExtension(pluginDescriptor, SyntaxManager.SYNTAXES_EP_NAME);
if (syntaxesDescriptor == null) {
@@ -152,10 +153,9 @@
* Populate the supplied alias manager with aliases from a plugin descriptor.
*
* @param pluginDescriptor the plugin descriptor's root XML element
- * @param aliasMgr the alias manager to be populated.
* @throws EmuException
*/
- private void extractAliases(XMLElement pluginDescriptor, AliasManager aliasMgr) {
+ private void extractAliases(XMLElement pluginDescriptor) {
XMLElement aliasesDescriptor = findExtension(pluginDescriptor, AliasManager.ALIASES_EP_NAME);
if (aliasesDescriptor == null) {
return;
@@ -190,12 +190,11 @@
* Locate and load a plugin descriptor. We search the "descriptors" directory of
* each of the projects listed in ALL_PROJECTS
*
- * @param root the notional root directory for the user's JNode sandbox.
* @param pluginName the name of the plugin we're trying to locate
* @return the loaded plugin descriptor or <code>null</code>
* @throws EmuException
*/
- private XMLElement loadPluginDescriptor(File root, String pluginName)
+ private XMLElement loadPluginDescriptor(String pluginName)
throws EmuException {
File file = null;
for (String projectName : ALL_PROJECTS) {
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjornePseudoPlugin.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjornePseudoPlugin.java 2009-01-24 05:34:47 UTC (rev 4907)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjornePseudoPlugin.java 2009-01-25 01:04:36 UTC (rev 4908)
@@ -1,3 +1,23 @@
+/*
+ * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $
+ *
+ * JNode.org
+ * Copyright (C) 2003-2006 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
package org.jnode.test.shell.bjorne;
import javax.naming.NamingException;
Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-01-24 05:34:47 UTC (rev 4907)
+++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-01-25 01:04:36 UTC (rev 4908)
@@ -1,14 +1,16 @@
<testSpecs>
+<title>Bjorne interpreter tests</title>
+<plugin>
+<id>org.jnode.shell.bjorne</id>
+<class>org.jnode.test.shell.bjorne.BjornePseudoPlugin</class>
+</plugin>
+<plugin>
+<id>org.jnode.shell.command.posix</id>
+</plugin>
<testSpec>
<title>simple</title>
<command>test</command>
<runMode>AS_SCRIPT</runMode>
-<plugins>
-<plugin>
-<id>org.jnode.shell.bjorne</id>
-<class>org.jnode.test.shell.bjorne.BjornePseudoPlugin</class>
-</plugin>
-</plugins>
<script>#!bjorne
echo HI
</script>
Modified: trunk/shell/src/test/org/jnode/test/shell/command/posix/posix-command-tests.xml
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/command/posix/posix-command-tests.xml 2009-01-24 05:34:47 UTC (rev 4907)
+++ trunk/shell/src/test/org/jnode/test/shell/command/posix/posix-command-tests.xml 2009-01-25 01:04:36 UTC (rev 4908)
@@ -1,4 +1,8 @@
<testSpecs>
+<title>POSIX command tests</title>
+<plugin>
+<id>org.jnode.shell.command.posix</id>
+</plugin>
<testSpec>
<title>true command</title>
<command>org.jnode.shell.command.posix.TrueCommand</command>
Modified: trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java 2009-01-24 05:34:47 UTC (rev 4907)
+++ trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java 2009-01-25 01:04:36 UTC (rev 4908)
@@ -1,5 +1,22 @@
-/**
- *
+/*
+ * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $
+ *
+ * JNode.org
+ * Copyright (C) 2003-2006 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.jnode.test.shell.harness;
Modified: trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java 2009-01-24 05:34:47 UTC (rev 4907)
+++ trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java 2009-01-25 01:04:36 UTC (rev 4908)
@@ -1,5 +1,22 @@
-/**
- *
+/*
+ * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $
+ *
+ * JNode.org
+ * Copyright (C) 2003-2006 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.jnode.test.shell.harness;
Added: trunk/shell/src/test/org/jnode/test/shell/harness/DummyPseudoPlugin.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/harness/DummyPseudoPlugin.java (rev 0)
+++ trunk/shell/src/test/org/jnode/test/shell/harness/DummyPseudoPlugin.java 2009-01-25 01:04:36 UTC (rev 4908)
@@ -0,0 +1,25 @@
+/*
+ * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $
+ *
+ * JNode.org
+ * Copyright (C) 2003-2006 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+package org.jnode.test.shell.harness;
+
+public class DummyPseudoPlugin implements PseudoPlugin {
+ // Nothing required.
+}
Modified: trunk/shell/src/test/org/jnode/test/shell/harness/JNodeTestRunnerBase.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/harness/JNodeTestRunnerBase.java 2009-01-24 05:34:47 UTC (rev 4907)
+++ trunk/shell/src/test/org/jnode/test/shell/harness/JNodeTestRunnerBase.java 2009-01-25 01:04:36 UTC (rev 4908)
@@ -1,3 +1,23 @@
+/*
+ * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $
+ *
+ * JNode.org
+ * Copyright (C) 2003-2006 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
package org.jnode.test.shell.harness;
import java.io.ByteArrayInputStream;
@@ -8,7 +28,6 @@
import org.jnode.plugin.PluginManager;
import org.jnode.shell.CommandShell;
import org.jnode.shell.ShellException;
-import org.jnode.test.shell.harness.TestSpecification.PluginSpec;
public abstract class JNodeTestRunnerBase implements TestRunnable {
protected ByteArrayOutputStream outBucket;
@@ -41,7 +60,12 @@
@Override
public void setup() {
- for (PluginSpec plugin : spec.getRequiredPlugins()) {
+ if (spec.getTestSet() != null) {
+ for (PluginSpecification plugin : spec.getTestSet().getPlugins()) {
+ ensurePluginLoaded(plugin);
+ }
+ }
+ for (PluginSpecification plugin : spec.getPlugins()) {
ensurePluginLoaded(plugin);
}
System.setIn(new ByteArrayInputStream(spec.getInputContent().getBytes()));
@@ -51,17 +75,18 @@
System.setErr(new PrintStream(errBucket));
}
- protected void ensurePluginLoaded(PluginSpec pluginSpec) {
+ protected void ensurePluginLoaded(PluginSpecification plugin) {
if (usingEmu) {
- TestEmu.loadPseudoPlugin(pluginSpec.pseudoPluginClassName);
+ TestEmu.loadPseudoPlugin(plugin.getPluginId(), plugin.getClassName());
} else {
- String ver = (pluginSpec.pluginVersion.length() == 0) ?
- System.getProperty("os.version") : pluginSpec.pluginVersion;
+ String ver = (plugin.getPluginVersion().length() == 0) ?
+ System.getProperty("os.version") : plugin.getPluginVersion();
try {
PluginManager mgr = InitialNaming.lookup(PluginManager.NAME);
- mgr.getRegistry().loadPlugin(mgr.getLoaderManager(), pluginSpec.pluginId, ver);
+ mgr.getRegistry().loadPlugin(mgr.getLoaderManager(), plugin.getPluginId(), ver);
} catch (Exception ex) {
- throw new RuntimeException("Cannot load plugin '" + pluginSpec.pluginId + "/" + ver + "'");
+ throw new RuntimeException(
+ "Cannot load plugin '" + plugin.getPluginId() + "/" + ver + "'");
}
}
}
Added: trunk/shell/src/test/org/jnode/test/shell/harness/PluginSpecification.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/harness/PluginSpecification.java (rev 0)
+++ trunk/shell/src/test/org/jnode/test/shell/harness/PluginSpecification.java 2009-01-25 01:04:36 UTC (rev 4908)
@@ -0,0 +1,47 @@
+/*
+ * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $
+ *
+ * JNode.org
+ * Copyright (C) 2003-2006 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+package org.jnode.test.shell.harness;
+
+public class PluginSpecification {
+ private final String pluginId;
+ private final String pluginVersion;
+ private final String pseudoPluginClassName;
+
+ public PluginSpecification(String pluginId, String pluginVersion,
+ String pseudoPluginClassName) {
+ super();
+ this.pluginId = pluginId;
+ this.pluginVersion = pluginVersion;
+ this.pseudoPluginClassName = pseudoPluginClassName;
+ }
+
+ public String getPluginId() {
+ return pluginId;
+ }
+
+ public String getPluginVersion() {
+ return pluginVersion;
+ }
+
+ public String getClassName() {
+ return pseudoPluginClassName;
+ }
+}
\ No newline at end of file
Modified: trunk/shell/src/test/org/jnode/test/shell/harness/PseudoPlugin.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/harness/PseudoPlugin.java 2009-01-24 05:34:47 UTC (rev 4907)
+++ trunk/shell/src/test/org/jnode/test/shell/harness/PseudoPlugin.java 2009-01-25 01:04:36 UTC (rev 4908)
@@ -1,3 +1,23 @@
+/*
+ * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $
+ *
+ * JNode.org
+ * Copyright (C) 2003-2006 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
package org.jnode.test.shell.harness;
public interface PseudoPlugin {
Modified: trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java 2009-01-24 05:34:47 UTC (rev 4907)
+++ trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java 2009-01-25 01:04:36 UTC (rev 4908)
@@ -1,5 +1,22 @@
-/**
- *
+/*
+ * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $
+ *
+ * JNode.org
+ * Copyright (C) 2003-2006 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.jnode.test.shell.harness;
Deleted: trunk/shell/src/test/org/jnode/test/shell/harness/Test.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/harness/Test.java 2009-01-24 05:34:47 UTC (rev 4907)
+++ trunk/shell/src/test/org/jnode/test/shell/harness/Test.java 2009-01-25 01:04:36 UTC (rev 4908)
@@ -1,16 +0,0 @@
-package org.jnode.test.shell.harness;
-
-public class Test {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- if (args.length == 0) {
- System.out.println("Hi mum");
- } else if (args[0].equals("System.exit")) {
- System.exit(1);
- }
- }
-
-}
Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestCommandShell.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/harness/TestCommandShell.java 2009-01-24 05:34:47 UTC (rev 4907)
+++ trunk/shell/src/test/org/jnode/test/shell/harness/TestCommandShell.java 2009-01-25 01:04:36 UTC (rev 4908)
@@ -1,3 +1,23 @@
+/*
+ * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $
+ *
+ * JNode.org
+ * Copyright (C) 2003-2006 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
package org.jnode.test.shell.harness;
import java.io.InputStream;
Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestEmu.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/harness/TestEmu.java 2009-01-24 05:34:47 UTC (rev 4907)
+++ trunk/shell/src/test/org/jnode/test/shell/harness/TestEmu.java 2009-01-25 01:04:36 UTC (rev 4908)
@@ -1,3 +1,23 @@
+/*
+ * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $
+ *
+ * JNode.org
+ * Copyright (C) 2003-2006 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
package org.jnode.test.shell.harness;
import java.io.File;
@@ -2,2 +22,3 @@
import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
import java.util.HashSet;
@@ -19,6 +40,7 @@
private static boolean emuInitialized;
private static boolean emuAvailable;
private static CommandShell shell;
+ private static Class<?> emuClass;
@SuppressWarnings("unused")
private static Object emuObject;
@@ -33,8 +55,8 @@
// The following infers that we are running on the dev't platform if
// the 'Emu' class is not loadable.
try {
- Class<?> cls = Class.forName("org.jnode.emu.Emu");
- Constructor<?> constructor = cls.getConstructor(File.class);
+ emuClass = Class.forName("org.jnode.emu.Emu");
+ Constructor<?> constructor = emuClass.getConstructor(File.class);
emuObject = constructor.newInstance(root);
emuAvailable = true;
} catch (Throwable ex) {
@@ -65,18 +87,20 @@
return shell;
}
- public static synchronized void loadPseudoPlugin(String pseudoPluginClassName) {
+ public static synchronized void loadPseudoPlugin(String pluginId, String className) {
if (!emuInitialized) {
throw new IllegalStateException("Emu not initialized");
}
- if (!loadedPseudoPlugins.contains(pseudoPluginClassName)) {
+ if (!loadedPseudoPlugins.contains(className)) {
try {
- Class<?> clazz = Class.forName(pseudoPluginClassName);
+ Class<?> clazz = Class.forName(className);
clazz.newInstance();
+ Method method = emuClass.getMethod("configurePluginCommands", String.class);
+ method.invoke(emuObject, pluginId);
} catch (Exception ex) {
- throw new RuntimeException("Cannot load '" + pseudoPluginClassName + "'", ex);
+ throw new RuntimeException("Cannot configure plugin '" + pluginId + "'", ex);
}
- loadedPseudoPlugins.add(pseudoPluginClassName);
+ loadedPseudoPlugins.add(className);
}
}
Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java 2009-01-24 05:34:47 UTC (rev 4907)
+++ trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java 2009-01-25 01:04:36 UTC (rev 4908)
@@ -1,3 +1,23 @@
+/*
+ * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $
+ *
+ * JNode.org
+ * Copyright (C) 2003-2006 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
package org.jnode.test.shell.harness;
import java.io.File;
@@ -6,7 +26,6 @@
import java.io.InputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
-import java.util.List;
import net.n3.nanoxml.XMLException;
@@ -50,7 +69,7 @@
boolean useResources = false;
int firstArg = 0;
TestSpecificationParser parser = new TestSpecificationParser();
- List<TestSpecification> specs;
+ TestSetSpecification specs;
if (args.length == 0) {
usage();
return;
@@ -105,8 +124,8 @@
System.err.println(commandName + " <spec-file> ... // run tests from specs read from file system");
}
- private void execute(List<TestSpecification> specs) {
- for (TestSpecification spec : specs) {
+ private void execute(TestSetSpecification specs) {
+ for (TestSpecification spec : specs.getSpecs()) {
execute(spec);
}
}
Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnable.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnable.java 2009-01-24 05:34:47 UTC (rev 4907)
+++ trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnable.java 2009-01-25 01:04:36 UTC (rev 4908)
@@ -1,3 +1,23 @@
+/*
+ * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $
+ *
+ * JNode.org
+ * Copyright (C) 2003-2006 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
package org.jnode.test.shell.harness;
/**
Added: trunk/shell/src/test/org/jnode/test/shell/harness/TestSetSpecification.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/harness/TestSetSpecification.java (rev 0)
+++ trunk/shell/src/test/org/jnode/test/shell/harness/TestSetSpecification.java 2009-01-25 01:04:36 UTC (rev 4908)
@@ -0,0 +1,41 @@
+package org.jnode.test.shell.harness;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestSetSpecification {
+
+ private final List<TestSpecification> specs =
+ new ArrayList<TestSpecification>();
+
+ private final List<PluginSpecification> plugins =
+ new ArrayList<PluginSpecification>();
+
+ private final String title;
+
+ public TestSetSpecification(String title) {
+ super();
+ this.title = title;
+ }
+
+ public List<TestSpecification> getSpecs() {
+ return specs;
+ }
+
+ public List<PluginSpecification> getPlugins() {
+ return plugins;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void addPluginSpec(PluginSpecification plugin) {
+ plugins.add(plugin);
+ }
+
+ public void addTestSpec(TestSpecification spec) {
+ specs.add(spec);
+ spec.setTestSet(this);
+ }
+}
Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecification.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecification.java 2009-01-24 05:34:47 UTC (rev 4907)
+++ trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecification.java 2009-01-25 01:04:36 UTC (rev 4908)
@@ -1,6 +1,28 @@
+/*
+ * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $
+ *
+ * JNode.org
+ * Copyright (C) 2003-2006 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
package org.jnode.test.shell.harness;
import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -11,20 +33,6 @@
*/
public class TestSpecification {
- public static class PluginSpec {
- public final String pluginId;
- public final String pluginVersion;
- public final String pseudoPluginClassName;
-
- public PluginSpec(String pluginId, String pluginVersion,
- String pseudoPluginClassName) {
- super();
- this.pluginId = pluginId;
- this.pluginVersion = pluginVersion;
- this.pseudoPluginClassName = pseudoPluginClassName;
- }
- }
-
public static enum RunMode {
AS_SCRIPT,
AS_CLASS,
@@ -33,20 +41,20 @@
private final RunMode runMode;
private final String command;
- private final List<String> args;
+ private final List<String> args = new ArrayList<String>();
private final String scriptContent;
private final String inputContent;
private final String outputContent;
private final String errorContent;
private final String title;
- private final List<PluginSpec> requiredPlugins;
+ private final List<PluginSpecification> plugins = new ArrayList<PluginSpecification>();
private final int rc;
- private final Map<File, String> fileMap;
+ private final Map<File, String> fileMap = new HashMap<File, String>();
+ private TestSetSpecification testSet;
public TestSpecification(RunMode runMode, String command, String scriptContent,
String inputContent, String outputContent, String errorContent,
- String title, int rc, List<String> args, Map<File, String> fileMap,
- List<PluginSpec> requiredPlugins) {
+ String title, int rc) {
super();
this.runMode = runMode;
this.command = command;
@@ -56,9 +64,6 @@
this.errorContent = errorContent;
this.title = title;
this.rc = rc;
- this.args = args;
- this.fileMap = fileMap;
- this.requiredPlugins = requiredPlugins;
}
public String getOutputContent() {
@@ -73,6 +78,14 @@
return rc;
}
+ public void addArg(String arg) {
+ args.add(arg);
+ }
+
+ public void addPlugin(PluginSpecification plugin) {
+ plugins.add(plugin);
+ }
+
public void addFile(File file, String content) {
fileMap.put(file, content);
}
@@ -105,7 +118,15 @@
return title;
}
- public List<PluginSpec> getRequiredPlugins() {
- return requiredPlugins;
+ public List<PluginSpecification> getPlugins() {
+ return plugins;
}
+
+ public TestSetSpecification getTestSet() {
+ return testSet;
+ }
+
+ public void setTestSet(TestSetSpecification testSet) {
+ this.testSet = testSet;
+ }
}
Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationException.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationException.java 2009-01-24 05:34:47 UTC (rev 4907)
+++ trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationException.java 2009-01-25 01:04:36 UTC (rev 4908)
@@ -1,3 +1,23 @@
+/*
+ * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $
+ *
+ * JNode.org
+ * Copyright (C) 2003-2006 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
package org.jnode.test.shell.harness;
public class TestSpecificationException extends Exception {
Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationParser.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationParser.java 2009-01-24 05:34:47 UTC (rev 4907)
+++ trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationParser.java 2009-01-25 01:04:36 UTC (rev 4908)
@@ -1,3 +1,23 @@
+/*
+ * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $
+ *
+ * JNode.org
+ * Copyright (C) 2003-2006 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
package org.jnode.test.shell.harness;
import java.io.File;
@@ -2,6 +22,2 @@
import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
@@ -12,29 +28,31 @@
import net.n3.nanoxml.StdXMLReader;
import net.n3.nanoxml.XMLParserFactory;
-import org.jnode.test.shell.harness.TestSpecification.PluginSpec;
import org.jnode.test.shell.harness.TestSpecification.RunMode;
public class TestSpecificationParser {
- public List<TestSpecification> parse(InputStream in) throws Exception {
+ public TestSetSpecification parse(InputStream in) throws Exception {
StdXMLReader xr = new StdXMLReader(in);
IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
parser.setReader(xr);
- List<TestSpecification> res = new ArrayList<TestSpecification>();
+ TestSetSpecification res;
IXMLElement root = (IXMLElement) parser.parse();
if (root.getName().equals("testSpec")) {
- res.add(parseTestSpecification(root));
+ res = new TestSetSpecification("");
+ res.addTestSpec(parseTestSpecification(root));
} else if (root.getName().equals("testSpecs")) {
+ String title = extractElementValue(root, "title");
+ res = new TestSetSpecification(title);
for (Object obj : root.getChildren()) {
if (obj instanceof IXMLElement) {
IXMLElement argChild = (IXMLElement) obj;
- if (!argChild.getName().equals("testSpec")) {
- throw new TestSpecificationException(
- "Child elements of 'testSpecs' should be 'testSpec' not '" +
- argChild.getName() + "'");
- }
- res.add(parseTestSpecification(argChild));
+ String name = argChild.getName();
+ if (name.equals("testSpec")) {
+ res.addTestSpec(parseTestSpecification(argChild));
+ } else if (name.equals("plugin")) {
+ res.addPluginSpec(parsePluginSpecification(argChild));
+ }
}
}
} else {
@@ -45,7 +63,6 @@
}
private TestSpecification parseTestSpecification(IXMLElement elem) throws TestSpecificationException {
-
RunMode runMode = RunMode.valueOf(extractElementValue(elem, "runMode", "AS_CLASS"));
String title = extractElementValue(elem, "title");
String command = extractElementValue(elem, "command");
@@ -59,70 +76,41 @@
} catch (NumberFormatException ex) {
throw new TestSpecificationException("'rc' is not an integer");
}
- List<String> args = parseArgs(elem.getFirstChildNamed("args"));
- Map<File, String> fileMap = parseFiles(elem.getFirstChildNamed("files"));
- List<PluginSpec> plugins = parsePlugins(elem.getFirstChildNamed("plugins"));
- return new TestSpecification(
+ TestSpecification res = new TestSpecification(
runMode, command, scriptContent, inputContent, outputContent, errorContent,
- title, rc, args, fileMap, plugins);
- }
-
- private List<PluginSpec> parsePlugins(IXMLElement pluginsElem) throws TestSpecificationException {
- List<PluginSpec> plugins = new ArrayList<PluginSpec>();
- if (pluginsElem != null) {
- for (Object obj : pluginsElem.getChildren()) {
- if (obj instanceof IXMLElement) {
- IXMLElement child = (IXMLElement) obj;
- if (!child.getName().equals("plugin")) {
- throw new TestSpecificationException(
- "Child elements of 'plugins' should be 'plugin' not '" + child.getName() + "'");
- }
- String pluginId = extractElementValue(child, "id");
- String pluginVersion = extractElementValue(child, "version", "");
- String pseudoPluginClassName = extractElementValue(child, "class");
- plugins.add(new PluginSpec(pluginId, pluginVersion, pseudoPluginClassName));
+ title, rc);
+ for (Object obj : elem.getChildren()) {
+ if (obj instanceof IXMLElement) {
+ IXMLElement child = (IXMLElement) obj;
+ String name = child.getName();
+ if (name.equals("arg")) {
+ res.addArg(child.getContent());
+ } else if (name.equals("plugin")) {
+ res.addPlugin(parsePluginSpecification(child));
+ } else if (name.equals("file")) {
+ parseFile(child, res);
}
}
}
- return plugins;
+ return res;
}
- private Map<File, String> parseFiles(IXMLElement filesElem) throws TestSpecificationException {
- Map<File, String> fileMap = new HashMap<File, String>();
- if (filesElem != null) {
- for (Object obj : filesElem.getChildren()) {
- if (obj instanceof IXMLElement) {
- IXMLElement fileChild = (IXMLElement) obj;
- if (!fileChild.getName().equals("file")) {
- throw new TestSpecificationException(
- "Child elements of 'files' should be 'file' not '" + fileChild.getName() + "'");
- }
- String fileName = extractElementValue(fileChild, "name");
- String content = extractElementValue(fileChild, "content", "");
- fileMap.put(new File(fileName), content);
- }
- }
- }
- return fileMap;
+ private PluginSpecification parsePluginSpecification(IXMLElement elem)
+ throws TestSpecificationException {
+ String pluginId = extractElementValue(elem, "id");
+ String pluginVersion = extractElementValue(elem, "version", "");
+ String pseudoPluginClassName = extractElementValue(elem, "class",
+ "org.jnode.test.shell.harness.DummyPseudoPlugin");
+ return new PluginSpecification(pluginId, pluginVersion, pseudoPluginClassName);
}
- private List<String> parseArgs(IXMLElement argsElem) throws TestSpecificationException {
- List<String> args = new ArrayList<String>();
- if (argsElem != null) {
- for (Object obj : argsElem.getChildren()) {
- if (obj instanceof IXMLElement) {
- IXMLElement argChild = (IXMLElement) obj;
- if (!argChild.getName().equals("arg")) {
- throw new TestSpecificationException(
- "Child elements of 'args' should be 'arg' not '" + argChild.getName() + "'");
- }
- args.add(argChild.getContent());
- }
- }
- }
- return args;
+ private void parseFile(IXMLElement elem, TestSpecification res)
+ throws TestSpecificationException {
+ String fileName = extractElementValue(elem, "name");
+ String content = extractElementValue(elem, "content", "");
+ res.addFile(new File(fileName), content);
}
-
+
private String extractElementValue(IXMLElement parent, String name) throws TestSpecificationException {
IXMLElement elem = parent.getFirstChildNamed(name);
if (elem == null) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|