3

我正在尝试在我的 PaxExam 测试类中启用 Felix GoGo Shell。这只是为了开发包时与 OSGi 容器进行简单交互的原因。这是我的 PaxExam 测试课程:

import java.io.IOException;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;


@RunWith(PaxExam.class)
public class RunOSGiWithConsoleIT {

     @Configuration
public Option[] configureTest() throws IOException {

    return CoreOptions.options(
        CoreOptions.cleanCaches(),
        CoreOptions.mavenBundle("org.osgi", "org.osgi.enterprise").startLevel(1),
        CoreOptions.mavenBundle("org.ops4j.pax.swissbox", "pax-swissbox-tracker"),
        CoreOptions.mavenBundle("org.ops4j.pax.swissbox", "pax-swissbox-lifecycle"),
        CoreOptions.mavenBundle("org.ops4j.base", "ops4j-base-lang", "1.5.0"),
        CoreOptions.mavenBundle("org.apache.felix", "org.apache.felix.gogo.runtime"),
        CoreOptions.mavenBundle("org.apache.felix", "org.apache.felix.gogo.shell"),
        CoreOptions.mavenBundle("org.apache.felix", "org.apache.felix.gogo.command"),
        CoreOptions.junitBundles());
    }

    @Test
    public void shouldEnableUsToInspectTheOSGiFrameworkUsingTheGoGoShell() throws Exception {
        Assert.assertTrue(true);
        Object object = new Object();
        synchronized (object) {
            object.wait();
        }
    }

}

object.wait() 用于保持,因此我可以通过 shell 与容器交互。但这是我得到的例外:

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.mycompany.osgi.paxexam.it.RunOSGiWithConsoleIT
[main] INFO org.ops4j.pax.exam.spi.DefaultExamSystem - Pax Exam System (Version: 4.2.0) created.
[main] INFO org.ops4j.pax.exam.junit.impl.ProbeRunner - creating PaxExam runner for class com.mycompany.osgi.paxexam.it.RunOSGiWithConsoleIT
[main] INFO org.ops4j.pax.exam.junit.impl.ProbeRunner - running test class com.mycompany.osgi.paxexam.it.RunOSGiWithConsoleIT
[org.ops4j.pax.swissbox.extender.BundleWatcher] : Creating bundle watcher with scanner [org.ops4j.pax.swissbox.extender.BundleManifestScanner@63848ddf]...
[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.apache.felix.framework]
[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.pax.exam]
[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.pax.exam.inject]
[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [osgi.enterprise]
[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.pax.exam.extender.service]
[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [osgi.cmpn]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator] : Enabling SLF4J API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator] : Enabling Jakarta Commons Logging API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator] : Enabling Log4J API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator] : Enabling Avalon Logger API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator] : Enabling JULI Logger API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.pax.logging.pax-logging-api]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.base]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.pax.swissbox.core]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.pax.swissbox.extender]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.pax.swissbox.framework]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.pax.swissbox.lifecycle]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.pax.swissbox.tracker]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.apache.geronimo.specs.geronimo-atinject_1.0_spec]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.pax.tipi.junit]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.pax.swissbox.tracker]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.pax.swissbox.lifecycle]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.base.lang]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.apache.felix.gogo.runtime]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.apache.felix.gogo.shell]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.apache.felix.gogo.command]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.pax.tipi.hamcrest.core]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [org.ops4j.pax.exam.invoker.junit]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher] : Scanning bundle [PAXEXAM-PROBE-2b227abe-d51d-4cd2-844d-73d4a97e8806]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher] : Found resources [ManifestEntry{ key=PaxExam-39e3e588-ff96-4c9e-ac6a-05ef1c1088c4, value=com.mycompany.osgi.paxexam.it.RunOSGiWithConsoleIT;shouldEnableUsToInspectTheOSGiFrameworkUsingTheGoGoShell }, ManifestEntry{ key=PaxExam-Executable, value=PaxExam-39e3e588-ff96-4c9e-ac6a-05ef1c1088c4, }]
org.ops4j.pax.exam.extender.service[org.ops4j.pax.exam.raw.extender.intern.Probe] : Test PaxExam-39e3e588-ff96-4c9e-ac6a-05ef1c1088c4 to be in PaxExam-39e3e588-ff96-4c9e-ac6a-05ef1c1088c4,
org.ops4j.pax.exam.extender.service[org.ops4j.pax.exam.raw.extender.intern.Probe] : Registering Service: org.ops4j.pax.exam.ProbeInvoker with Probe-Signature="PaxExam-39e3e588-ff96-4c9e-ac6a-05ef1c1088c4" and expression="com.mycompany.osgi.paxexam.it.RunOSGiWithConsoleIT;shouldEnableUsToInspectTheOSGiFrameworkUsingTheGoGoShell"
org.ops4j.pax.exam.extender.service[org.ops4j.pax.exam.raw.extender.intern.Probe] : Test PaxExam-Executable to be in PaxExam-39e3e588-ff96-4c9e-ac6a-05ef1c1088c4,
bundle://18.0:1/gosh_profile:17.22: EOFException: unexpected EOT looking for matching ')'
java.io.EOFException: unexpected EOT looking for matching ')'
    at org.apache.felix.gogo.runtime.Closure.setLocation(Closure.java:101)
    at org.apache.felix.gogo.runtime.Closure.<init>(Closure.java:61)
    at org.apache.felix.gogo.runtime.Closure.eval(Closure.java:277)
    at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:339)
    at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
    at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:179)
    at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:116)
    at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:92)
    at org.apache.felix.gogo.shell.Shell.source(Shell.java:192)
    at org.apache.felix.gogo.shell.Shell.gosh(Shell.java:109)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:137)
    at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
    at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)
    at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)
    at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
    at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:179)
    at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:116)
    at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:92)
    at org.apache.felix.gogo.shell.Activator.run(Activator.java:75)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.felix.gogo.runtime.EOFError: unexpected EOT looking for matching ')'
    at org.apache.felix.gogo.runtime.Tokenizer.group(Tokenizer.java:328)
    at org.apache.felix.gogo.runtime.Tokenizer.next(Tokenizer.java:179)
    at org.apache.felix.gogo.runtime.Parser.command(Parser.java:109)
    at org.apache.felix.gogo.runtime.Parser.pipeline(Parser.java:68)
    at org.apache.felix.gogo.runtime.Parser.program(Parser.java:44)
    at org.apache.felix.gogo.runtime.Closure.<init>(Closure.java:57)
    ... 22 more

我将 jdk1.8_u20 与 Apache Felix 4.4.1 一起使用。

我真的很感激任何帮助,因为通过调试我没有运气找到这个问题的根源。

非常感谢

4

0 回答 0