How to fix: "Status: GracePeriod Blueprint Missing dependencies: (&(objectClass=org.apache.aries.blueprint.NamespaceHandler)" - apache-karaf

I built a bundle using camel-archetype-blueprint.
But after deploy to ServiceMix, it has not run and stayed in GracePeriod state.
There is no errors in log:display.
Calling bundle:diag results in:
"Status: GracePeriod Blueprint Missing dependencies:
(&(objectClass=org.apache.aries.blueprint.NamespaceHandler)(osgi.service.blueprint.namespace=http://camel.apache.org/schema/blueprint))".
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint
http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0
http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd">
<cm:property-placeholder
persistent-id="HelloBean" update-strategy="reload">
<cm:default-properties>
<cm:property name="greeting" value="Hi from Camel" />
</cm:default-properties>
</cm:property-placeholder>
<bean id="MyRouteBuilder" class="com.bpjava.tfsredmine.MyRouteBuilder" />
<camelContext id="blueprint-bean-context"
xmlns="http://camel.apache.org/schema/blueprint">
<routeBuilder ref="MyRouteBuilder" />
</camelContext>

You need to install camel-blueprint feature on your container

Related

WSO2 : Transforming response xml

I would like to turn this xml response into something more easily readable.
<?xml version="1.0" encoding="ISO-8859-1"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"/>
<soap:Body>
<executeResponse xmlns="urn:GCE">
<BusinessViewServiceexecuteOut xmlns="http://www.generix.fr/technicalframework/businesscomponent/applicationmodule/common" xmlns:ns2="http://www.generixgroup.com/processus/configuration/scheduler" xmlns:ns3="http://www.generix.fr/technicalframework/business/service/common">
<xmlpres><?xml version = '1.0' encoding = 'UTF-8'?> <VueTable type="View" name="Table" habctr="true" total_business_row="2" nbline="400" confNbline="400" numpage="1" nbpage="1">
<JTblView name="JTblView" type="ViewObject" maxfetchsize="999" maxfetchsizeexceeded="false">
<JTblViewRow current="true" type="ViewRow" index="1" business_row_index="1">
<Cletbl precision="6" type="VARCHAR" pk="true">
<business_data>N</business_data>
</Cletbl>
<Codtbl precision="6" type="VARCHAR" pk="true">
<business_data>001</business_data>
</Codtbl>
<Lib1 precision="30" type="VARCHAR">
<business_data>Non</business_data>
</Lib1>
<Lib2 precision="30" type="VARCHAR">
<business_data/>
</Lib2>
<Lir precision="10" type="VARCHAR">
<business_data>Non</business_data>
</Lir>
</JTblViewRow>
<JTblViewRow type="ViewRow" index="2" business_row_index="2">
<Cletbl precision="6" type="VARCHAR" pk="true">
<business_data>O</business_data>
</Cletbl>
<Codtbl precision="6" type="VARCHAR" pk="true">
<business_data>001</business_data>
</Codtbl>
<Lib1 precision="30" type="VARCHAR">
<business_data>Oui</business_data>
</Lib1>
<Lib2 precision="30" type="VARCHAR">
<business_data/>
</Lib2>
<Lir precision="10" type="VARCHAR">
<business_data>Oui</business_data>
</Lir>
</JTblViewRow>
</JTblView>
</VueTable></xmlpres>
</BusinessViewServiceexecuteOut>
</executeResponse>
</soap:Body></soap:Envelope>
At least if I could extract what's in the value of "xmlpres", the better I could do:
<table><row><code></code><libelle></libelle/></row></table>
To then turn it into a json response but I can't see ... I just get all the output or in json stream but with everything , which is not usable.
Create an out-mediation sequence with the following content and attach it to the respective API and try out the scenario. This is to extract the xmlpres content and send that as the response to the client
<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="out-sequence">
<!-- extract the xmlpres content and store as OM element -->
<property name="XMLBody"
expression="$body//soap:Body//generic:xmlpres"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:gce="urn:GCE"
xmlns:generic="http://www.generix.fr/technicalframework/businesscomponent/applicationmodule/common" type="OM" />
<!-- pass the extracted property as response body -->
<enrich>
<source type="property" property="XMLBody" />
<target type="body" />
</enrich>
</sequence>
Hope this helps you to extract and send the response accordingly.

How to run PHPUnit tests in a Drupal 8 environment for custom modules

I am trying to create and run PHPUnit tests for Drupal 8. Here are the details:
My top-level directory, where composer.json is located.
Dockerfile bootstrap.php composer.lock phpunit-examples phpunit.xml.org web
Jenkinsfile checkstyle.xml config phpunit.xml scripts
LICENSE components drush phpunit.xml.dist sonar-project.properties
README.md composer.json patches phpunit.xml.dist.org vendor
./vendor/bin/phpunit --version
PHPUnit 6.5.14 by Sebastian Bergmann and contributors.
phpunit.xml.dist
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
verbose="true"
>
<testsuites>
<testsuite name="unit">
<file>./tests/TestSuites/UnitTestSuite.php</file>
</testsuite>
<testsuite name="kernel">
<file>./tests/TestSuites/KernelTestSuite.php</file>
</testsuite>
<testsuite name="functional">
<file>./tests/TestSuites/FunctionalTestSuite.php</file>
</testsuite>
<testsuite name="functional-javascript">
<file>./tests/TestSuites/FunctionalJavascriptTestSuite.php</file>
</testsuite>
</testsuites>
</phpunit>
phpunit.xml
<phpunit
bootstrap="bootstrap.php"
colors="true"
strict="true"
verbose="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true"
checkForUnintentionallyCoveredCode="false">
<testsuites>
<testsuit name="Simple Example Test Suite">
<directory>phpunit-examples/tests</directory>
</testsuit>
</testsuites>
<php>
<ini name="error_reporting" value="32767"/>
<ini name="memory_limit" value="-1"/>
<env name="SIMPLETEST_BASE_URL" value="http://drupal-8.localhost"/>
<env name="SIMPLETEST_DB" value="mysql://drupal-8:drupal-8#localhost/drupal-8"/>
<env name="BROWSERTEST_OUTPUT_DIRECTORY" value="/var/www/sites/default/simpletest"/>
<includePath>phpunit-examples/src/</includePath>
</php>
</phpunit>
custom code to be tested:
web/modules/custom/benefit/src/BenefitListBuilder.php
test located at:
web/modules/custom/benefit/tests/src/BenefitListBuilderTest.php
<?php declare(strict_types = 1);
namespace Drupal\Tests\benefit;
use Mockery;
use Mockery\MockInterface;
use PHPUnit\Framework\TestCase;
use Drupal\benefit\BenefitListBuilder;
/**
* Test basic functionality of My Module.
*
* #group benefit
*/
class BenefitListBuilderTest extends UnitTestCase
{
/** #var BenefitListBuilder */
private $benefitListBuilder;
protected function setUp()
{
$a = "var_a";
$b = "var_b";
$this->benefitListBuilder = new BenefitListBuilder($a,$b);
}
public function testMissing()
{
$this->fail('Test not yet implemented');
}
}
Now, i try to run just this test:
$./vendor/bin/phpunit web/modules/custom/benefit/tests/src/BenefitListBuilderTest.php
PHP Fatal error: Class 'Drupal\Tests\benefit\UnitTestCase' not found in /Users/syedahmed/BG-REPOS/PHPUNITTEST-BenefitsAPI/BenefitsAPI/web/modules/custom/benefit/tests/src/BenefitListBuilderTest.php on line 15
Fatal error: Class 'Drupal\Tests\benefit\UnitTestCase' not found in /Users/syedahmed/BG-REPOS/PHPUNITTEST-BenefitsAPI/BenefitsAPI/web/modules/custom/benefit/tests/src/BenefitListBuilderTest.php on line 15
i tried moving the test under web/modules/custom/benefit/tests/src/Unit/BenefitListBuilderTest.php , but got same error.
How do i get the test to recognize the Path for UnitTestCase?
Update:
I have setup the repository in PHPStorm, so now i am getting error:
Error : Class 'Drupal\Tests\BenefitListBuilder' not found
As I see it, #kamal, the problem is you're instantiating the tests as this: use PHPUnit\Framework\TestCase; but you're using Drupal, so it should be as follows: use Drupal\Tests\UnitTestCase;
I hope this helps.

Why symfony container is build in test environment when I run phpunit whereas .env defines APP_ENV as dev?

I face a problem with env variables and running tests with phpunit on symfony 4.2 framework.
According to the documentation, .env and services.yaml are loaded first but if the APP_ENV is defined and set to a value like test, the container will be configured to load .env.test and services_test.yaml.
What I want to understand is : my .env files contains a key APP_ENV set to dev, but when I run phpunit to execute some tests, the environment is automatically (?) set to test...
To see that, I've dump $this->environment in the class Kernel.php.
bootstrap.php
<?php
use Symfony\Component\Dotenv\Dotenv;
require dirname(__DIR__).'/vendor/autoload.php';
// Load cached env vars if the .env.local.php file exists
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
if (is_array($env = #include dirname(__DIR__).'/.env.local.php')) {
$_SERVER += $env;
$_ENV += $env;
} elseif (!class_exists(Dotenv::class)) {
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
} else {
// load all the .env files
(new Dotenv())->loadEnv(dirname(__DIR__).'/.env');
}
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
.env
###> symfony/framework-bundle ###
APP_ENV=dev
...
Kernel.php
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader)
{
$container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php'));
// Feel free to remove the "container.autowiring.strict_mode" parameter
// if you are using symfony/dependency-injection 4.0+ as it's the default behavior
$container->setParameter('container.autowiring.strict_mode', true);
$container->setParameter('container.dumper.inline_class_loader', true);
$confDir = $this->getProjectDir().'/config';
$loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob');
$loader->load($confDir.'/{packages}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob');
$loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob');
$loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob');
dump($this->environment); //print "test"
}
phpunit.xml.dist
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="config/bootstrap.php"
>
<php>
<ini name="error_reporting" value="-1" />
<server name="KERNEL_CLASS" value="AppBundle\Kernel" />
<!-- ###+ symfony/framework-bundle ### -->
<env name="APP_ENV" value="dev" force="true"/> <!-- doesn't work with or without force="true" -->
<!-- env name="TRUSTED_PROXIES" value="127.0.0.1,127.0.0.2" -->
<!-- env name="TRUSTED_HOSTS" value="'^localhost|example\.com$'" -->
<!-- ###- symfony/framework-bundle ### -->
<!-- ###+ doctrine/doctrine-bundle ### -->
<!-- Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url -->
<!-- For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db" -->
<!-- Configure your db driver and server_version in config/packages/doctrine.yaml -->
<env name="DATABASE_URL" value="sqlite:///%kernel.project_dir%/app/test.db"/>
<!-- ###- doctrine/doctrine-bundle ### -->
</php>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>src</directory>
<exclude>
<directory>src/*Bundle/Resources</directory>
<directory>src/*/*Bundle/Resources</directory>
<directory>src/*/Bundle/*Bundle/Resources</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
Could you give me a clue about what happens, why my container is configure in test environment instead of the value of the APP_ENV?

Dynamically populate version from version.sbt

I'm trying to take the version from version.sbt and and populate it to logback.xml's log appender's applicationVersion field.
version.sbt
version in ThisBuild := "0.4.63"
logback.xml
<configuration debug="true" scan="true" scanPeriod="60 seconds">
<appender name="ADP-MESSAGING" class="com.agoda.adp.messaging.logging.appenders.LogbackAppender">
<applicationName>MyApp</applicationName>
<applicationAssemblyName>myapp</applicationAssemblyName>
<applicationVersion>0.4.61</applicationVersion>
<!-- <applicationVersion>${application.version}</applicationVersion> -->
<apiKey>s234W##$WFW$#$#</apiKey>
<getCallerData>false</getCallerData>
</appender>
....
<root level="WARN">
<appender-ref ref="ADP-MESSAGING" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
I tried by adding ${application.version}, ${version} but no success.
How can I do this?
Please share your thoughts.
Thanks
The values interpolated in a logback.xml file are simply Java system properties. All you have to do is add a value to your Java commandline defining the value you want:
// NOTE: This will only work when running through sbt. You'll have to
// append the same value to your startup scripts when running elsewhere.
javaOptions += "-Dapplication.version=" + version.value
With this flag, you should be able to interpolate the version in your XML file:
<applicationVersion>${application.version}</applicationVersion>
You can add logback PropertyDefiner implementation:
package org.mypackage
import ch.qos.logback.core.PropertyDefinerBase
class VersionPropertyDefiner extends PropertyDefinerBase {
override def getPropertyValue: String = BuildInfo.version
}
You will get autogenerated (managed) scala code BuildInfo.version if you use BuildInfoPlugin in your project build settings.
Then you can define and use variable in your logback.xml configuration:
<configuration debug="true" scan="true" scanPeriod="60 seconds">
<define name="appVersion" class="org.mypackage.VersionPropertyDefiner"/>
<appender name="ADP-MESSAGING" class="com.agoda.adp.messaging.logging.appenders.LogbackAppender">
<applicationName>MyApp</applicationName>
<applicationAssemblyName>myapp</applicationAssemblyName>
<applicationVersion>${appVersion}</applicationVersion>
<apiKey>s234W##$WFW$#$#</apiKey>
<getCallerData>false</getCallerData>
</appender>
....
<root level="WARN">
<appender-ref ref="ADP-MESSAGING" />
<appender-ref ref="STDOUT" />
</root>
</configuration>

Javascript Bundle Definition in Plone 5

I have define my Resource Directory in configure.zcml:
<plone:static
type="plone"
name="stuff.dropdownmenu"
directory="static" />
I have define my JS Resource in registry.xml:
<records
prefix="plone.resources/stuff"
interface='Products.CMFPlone.interfaces.IResourceRegistry'>
<value key="js">++plone++stuff.dropdownmenu/stuff.js</value>
</records>
My Question: What is the right value of the Element-Tag in the Bundle Definition:
<records
prefix="plone.bundles/stuffdropdown"
interface='Products.CMFPlone.interfaces.IBundleRegistry'>
<value key="resources" purge="false">
<element>???<element>
</value>
<value key="enabled">True</value>
</records>
Is it the stuff part of prefix-Attribute or ++plone++stuff.dropdownmenu/stuff.js ?
best regards
I found in CMFPlone registry.xml that the part of prefix is the right option. The Resource Definition is here in the same file: CMFPlone registry.xml

Resources