Currently I have test class for testing internal class using Pax-Exam 5.
#ProbeBuilder
public TestProbeBuilder probeConfiguration(TestProbeBuilder probe) {
probe.setHeader("Fragment-Host", "com.mycompany.abc");
return probe;
}
The reason I use Fragment-Host is to avoid exporting internal package for bundle com.mycompany.abc.
But I get this error
org.ops4j.pax.exam.TestContainerException: org.osgi.framework.BundleException: Invalid operation on a fragment.
at org.ops4j.pax.exam.nat.internal.NativeTestContainer.install(NativeTestContainer.java:135)
at org.ops4j.pax.exam.nat.internal.NativeTestContainer.install(NativeTestContainer.java:140)
at org.ops4j.pax.exam.nat.internal.NativeTestContainer.installProbe(NativeTestContainer.java:428)
at org.ops4j.pax.exam.spi.reactors.EagerSingleStagedReactor.setUp(EagerSingleStagedReactor.java:68)
at org.ops4j.pax.exam.spi.reactors.EagerSingleStagedReactor.beforeClass(EagerSingleStagedReactor.java:106)
at org.ops4j.pax.exam.spi.reactors.ReactorManager.beforeClass(ReactorManager.java:400)
at org.ops4j.pax.exam.junit.DriverExtension.beforeClassBlock(DriverExtension.java:130)
at org.ops4j.pax.exam.junit.ExtensibleRunner$1.evaluate(ExtensibleRunner.java:53)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.ops4j.pax.exam.junit.PaxExam.run(PaxExam.java:78)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: org.osgi.framework.BundleException: Invalid operation on a fragment.
at org.eclipse.osgi.container.Module.checkFragment(Module.java:520)
at org.eclipse.osgi.container.Module.start(Module.java:408)
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:428)
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:447)
at org.ops4j.pax.exam.nat.internal.NativeTestContainer.install(NativeTestContainer.java:131)
... 15 more
Is there any other solution?
Thanks
Pax Exam supports provisioning of fragments because you can call .noStart() on the provisioning Option to tell Pax Exam that the bundle/fragment must not be started:
CoreOptions.mavenBundle("gid", "aid", "version").noStart();
But what you are trying to achieve is different, you are trying to make your probe bundle into a fragment of the tested bundle.
You may still achieve your goal without having to make the probe a fragment as follows:
Use TinyBundles to create a fragment that exports the internal package(s) of the test bundle
Pass the fragment to Pax Exam as an url() option with .noStart()
see the following class for an example:
https://github.com/ops4j/org.ops4j.pax.exam2/blob/exam-reactor-3.2.0/itest/osgi/src/it/regression-multi/src/test/java/org/ops4j/pax/exam/regression/multi/fragment/FragmentTest.java#L61
In other words, rather than making the probe a fragment of the host, create on the fly an empty fragment just to export the packages of the host for the benefit of the probe.
Disclaimer: I did not try this, it's just an hypothesis.
Related
We run a set of tests in a CI pipeline and call our test classes like this:
java -classpath junit-jupiter-api-5.0.1.jar:junit-platform-console-standalone-1.0.1.jar org.junit.platform.console.ConsoleLauncher --select-class xy.Test
If class xy.Test cannot be found on the classpath an error message appears but ConsoleLauncher's return value is 0! Since our CI system runs unattended the return value is the only important return value!
As I have seen this behaviour got updated in JUnit 5.0.0 M2 but I regard this as I mistake: If I define a class by --select-class and the class cannot be found then something has gone wrong!
As I countermeasure I hacked (by means of introspection) org.junit.platform.commons.util.BlacklistedExceptions by overwriting blacklist's field with OutOfMemoryError (=default) and PreconditionViolationException (=case where class could not be found).
(If the standard behaviour shall not be changed...) I think there should be a better way to get this behaviour!
I have a screen with a form contaning invoices I want to notify the user with. The screen is used as bodyScreenLocation for the EmailTemplate. Up to here, it works. I wanted to add a link for each invoice so that the user can open the document right from withing the message. How to construct the path? This way it does not work:
This field is created in a form, that is included in a screen. This screen is used in a template called using
<service-call name="org.moqui.impl.EmailServices.send#EmailTemplate" async="true">
Added 18.10.2016
I attempted to use your advice.
<actions>
<entity-find entity-name="mantle.account.invoice.Invoice" list="invoiceList"/>
<script>
import org.moqui.impl.context.WebFacadeImpl
def httpUrl = WebFacadeImpl.getWebappRootUrl('webroot',null,false,false,ec)
</script>
</actions>
This is the log:
21:47:18.996 WARN oquiWorker-2 o.moqui.i.c.TransactionFacadeImpl Transaction set rollback only. The rollback was originally caused by: Error rendering screen [component://HS-data/screen/Notification/PayablesDue.xml]
java.lang.NullPointerException: null
at org.moqui.impl.context.WebFacadeImpl.makeWebappHost(WebFacadeImpl.groovy:477) ~[moqui-framework-2.0.0.jar:2.0.0]
at org.moqui.impl.context.WebFacadeImpl.makeWebappRootUrl(WebFacadeImpl.groovy:520) ~[moqui-framework-2.0.0.jar:2.0.0]
at org.moqui.impl.context.WebFacadeImpl.getWebappRootUrl(WebFacadeImpl.groovy:467) ~[moqui-framework-2.0.0.jar:2.0.0]
at org.moqui.impl.context.WebFacadeImpl$getWebappRootUrl.call(Unknown Source) ~[?:?]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) ~[groovy-2.4.7.jar:2.4.7]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) ~[groovy-2.4.7.jar:2.4.7]
at PayablesDue_xml_screen_actions.run(PayablesDue_xml_screen_actions:11) ~[script:?]
What you're looking for is the WebFacade.getWebappRootUrl() method. Use a call that is something like this in your template to get the base URL:
ec.web.getWebappRootUrl(true, null)
When there is no WebFacade in place, such as when running in an async service, you'll have to drop a level lower and there is a static method in WebFacadeImpl for this (it's not so convenient when you don't have the standard interfaces to go through), here is the method signature:
String getWebappRootUrl(String webappName, String servletContextPath, boolean requireFullUrl, Boolean useEncryption, ExecutionContextImpl eci)
The standard webappName is 'webroot' and unless you're doing something fancy in your Moqui Conf XML file this can be a static String. The servletContextPath can be null or an empty String if your Moqui webapp is mounted on the root (commonly the case; without a request where we can get to the ServletContext to see where it is mounted this can't be determined automatically).
I have an app build with jodd 3.6.6 and when I try to run it on jetty9 it cannot initialize Madvoc :
1377 [ERROR] j.m.Madvoc.startNewWebApplication:161 - Madvoc startup failure.
jodd.madvoc.MadvocException: Scan classpath error; <--- java.lang.ClassNotFoundException: Class not found: org.eclipse.jetty.client.api.Result
at jodd.madvoc.config.AutomagicMadvocConfigurator.configure(AutomagicMadvocConfigurator.java:85)
at jodd.madvoc.config.AutomagicMadvocConfigurator.configure(AutomagicMadvocConfigurator.java:65)
at jodd.madvoc.WebApplication.configure(WebApplication.java:255)
at jodd.madvoc.Madvoc.start(Madvoc.java:238)
at jodd.madvoc.Madvoc.startNewWebApplication(Madvoc.java:157)
at jodd.madvoc.MadvocServletFilter.init(MadvocServletFilter.java:45)
at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:138)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:852)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:298)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1349)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1342)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:505)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.server.Server.start(Server.java:387)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at org.eclipse.jetty.server.Server.doStart(Server.java:354)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at net.sourceforge.eclipsejetty.starter.jetty9.Jetty9Adapter.start(Jetty9Adapter.java:68)
at net.sourceforge.eclipsejetty.starter.common.AbstractJettyLauncherMain.launch(AbstractJettyLauncherMain.java:85)
at net.sourceforge.eclipsejetty.starter.jetty9.Jetty9LauncherMain.main(Jetty9LauncherMain.java:42)
Caused by: jodd.io.findfile.FindFileException: Scan entry error: EntryData{org.eclipse.jetty.client.api.Result'}; <--- java.lang.ClassNotFoundException: Class not found: org.eclipse.jetty.client.api.Result
at jodd.io.findfile.ClassFinder.scanEntry(ClassFinder.java:391)
at jodd.io.findfile.ClassFinder.scanJarFile(ClassFinder.java:292)
at jodd.io.findfile.ClassFinder.scanPath(ClassFinder.java:261)
at jodd.io.findfile.ClassFinder.scanPaths(ClassFinder.java:226)
at jodd.madvoc.config.AutomagicMadvocConfigurator.configure(AutomagicMadvocConfigurator.java:83)
... 22 more
Caused by: jodd.madvoc.MadvocException: Invalid Madvoc result class: org.eclipse.jetty.client.api.Result; <--- java.lang.ClassNotFoundException: Class not found: org.eclipse.jetty.client.api.Result
at jodd.madvoc.config.AutomagicMadvocConfigurator.onEntry(AutomagicMadvocConfigurator.java:108)
at jodd.io.findfile.ClassFinder.scanEntry(ClassFinder.java:389)
... 26 more
The same app runs without a problem on tomcat. Any idea ?
Ok, it should be simple: just skip the scanning of netty classes.
Here is the explanation: In Madvoc you can optionally use the Result class (source) to work with the results (documentation). In short, if you have a field with Result type, Madvoc will use it for this feature.
So it looks like Netty has the same class name, hence the error. To prevent this (until we make a better recognition), just skip scanning the full class path, and make the scanner scan only your classes - that will improve the startup performances too. Here is how to do that:
By default, the AutomagicMadvocConfigurator is used for configuring the actions (by scanning the path). Get this instance (in WebApplication for example) and configure it (since it is a ClassFinder subclass). So what I do is:
classFinder.setExcludeAllEntries(true);
classFinder.setIncludedEntries(myapp.getClass().getPackage().getName() + ".*");
classFinder.setIncludedJars("somejar.jar", "myapp*.jar");
This will narrow down the classpath that is being searched.
Let me know if you need more help with this. Meanwhile, we will definitely make changes so this never happens again!
I've got a executable target called Foobar, a static library holding some common code called FoobarCommon, and a test target specifically for the common code called FoobarCommonSpecs.
Unsurprisingly, I have made both Foobar and FoobarCommonSpecs depend on the FoobarCommon library.
The Podfile looks something like the below:
target 'FoobarCommon' do
pod 'ReactiveCocoa'
...
end
target 'Foobar' do # links against to FoobarCommon in Xcode
...
end
target 'FoobarCommonSpecs' do # links against to FoobarCommon in Xcode
pod 'LLReactiveMatchers', :git => 'https://github.com/lawrencelomax/LLReactiveMatchers.git'
end
LLReactiveMatchers is a Pod that depends on ReactiveCocoa.
Note that in this situation, ReactiveCocoa is prsent in both FoobarCommon and also in FoobarCommonSpecs
The Problem
Whenever I run FoobarCommonSpecs, I get many duplicate symbol errors for ReactiveCocoa.
I want to say to Cocoapods that it should just IGNORE LLReactiveMatcher's dependency on ReactiveCocoa. It should just let Xcode do its job and it should link with the copy of ReactiveCocoa found in FoobarCommon. How do I do that?
Does the link_with directive have anything to do with anything?
FIREBREATH 1.6 -- VC2010 --
No logging with FBLOG_TRACE("StaticInitialize()", "INIT-trace");
settings
outMethods.push_back(std::make_pair(FB::Log::LogMethod_File, "U:/logs/PT.log"));
...
FB::Log::LogLevel getLogLevel(){
return FB::Log::LogLevel_Trace;
...
changing "FBLOG_TRACE" to "FBLOG_INFO" logging to Logfile works. I don´t understand the reason.
function not inserted in its respective area
FB::Log::LogLevel getLogLevel(){
return FB::Log::LogLevel_Trace; // Now Trace and above is logged.
}
Discription Logging here.
Enabling logging
...
regenerate your project using the prep* scripts
open up Factory.cpp in your project. You need to define the following function inside the class definition for PluginFactory:
...
About log levels
...
If you want to change the log level, you need to define the following in your Factory.cpp:
Referring to the above that means somewhere in "Factory.cpp". that´s incorrect. The description should say -->
If you want to change the log level, you need to define the following function inside the class definition for PluginFactory:
I drag it from bottom of "Factory.cpp" to inside Class PluginFactory.
Now it works as expected !!!
The entire purpose of having different log levels (FBLOG_FATAL, FBLOG_ERROR, FBLOG_WARN, FBLOG_INFO, FBLOG_DEBUG, FBLOG_TRACE) is so that you can configure which level to use and anything below that level is hidden. The default log level in FireBreath is FB::Log::LogLevel_Info, which means that nothing below INFO (such as DEBUG or TRACE) will be visible.
You can change this by overriding FB::FactoryBase::getLogLevel() in your Factory class to return FB::Log::LogLevel_Trace.
The method you'd be overriding is: https://github.com/firebreath/FireBreath/blob/master/src/PluginCore/FactoryBase.cpp#L78
The definition of the LogLevel enum:
https://github.com/firebreath/FireBreath/blob/master/src/ScriptingCore/logging.h#L69
There was a version of FireBreath in which this didn't work; I think it was fixed by 1.6.0, but I don't remember for certain. If that doesn't work try updating to the latest on the 1.6 branch (which is currently 1.6.1 as of the time of this writing but I haven't found time to release yet)