/**
  * Tests if the merge method fails with an exception if the class
  * name doesn't match when try to merge to descriptor instances.
  *
  * @return void
  * @expectedException AppserverIo\Psr\EnterpriseBeans\EnterpriseBeansException
  */
 public function testMergeWithException()
 {
     // initialize the configuration
     $node = new SessionNode();
     $node->initFromFile(__DIR__ . '/_files/dd-sessionbean.xml');
     // initialize the descriptor from the nodes data
     $this->descriptor->fromConfiguration($node);
     // initialize the descriptor to merge
     $descriptorToMerge = $this->getMockForAbstractClass('AppserverIo\\Description\\BeanDescriptor');
     // initialize the configuration of the descriptor to be merged
     $nodeToMerge = new SessionNode();
     $nodeToMerge->initFromFile(__DIR__ . '/_files/dd-sessionbean-to-merge-with-exception.xml');
     $descriptorToMerge->fromConfiguration($nodeToMerge);
     // merge the descriptors
     $this->descriptor->merge($descriptorToMerge);
 }
 /**
  * Initializes a bean descriptor instance from the passed configuration node.
  *
  * @param \AppserverIo\Description\Configuration\ConfigurationInterface $configuration The configuration node with the bean configuration
  *
  * @return \AppserverIo\Psr\EnterpriseBeans\Description\MessageDrivenBeanDescriptorInterface|null The initialized descriptor instance
  */
 public function fromConfiguration(ConfigurationInterface $configuration)
 {
     // query whether or not we've a message driven bean configuration
     if (!$configuration instanceof MessageDrivenConfigurationInterface) {
         return;
     }
     // initialize the descriptor instance
     parent::fromConfiguration($configuration);
     // return the instance
     return $this;
 }
 /**
  * Merges the passed configuration into this one. Configuration values
  * of the passed configuration will overwrite the this one.
  *
  * @param \AppserverIo\Psr\EnterpriseBeans\Description\BeanDescriptorInterface $beanDescriptor The configuration to merge
  *
  * @return void
  */
 public function merge(BeanDescriptorInterface $beanDescriptor)
 {
     // only merge the more special configuration fields if the desciptor has the right type
     if (!$beanDescriptor instanceof SessionBeanDescriptorInterface) {
         return;
     }
     // merge the default bean members by invoking the parent method
     parent::merge($beanDescriptor);
     // merge the session type
     if ($sessionType = $beanDescriptor->getSessionType()) {
         $this->setSessionType($sessionType);
     }
     // merge the post construct callback method names
     foreach ($beanDescriptor->getPostConstructCallbacks() as $postConstructCallback) {
         if (in_array($postConstructCallback, $this->getPostConstructCallbacks()) === false) {
             $this->addPostConstructCallback($postConstructCallback);
         }
     }
     // merge the pre destroy callback method names
     foreach ($beanDescriptor->getPreDestroyCallbacks() as $preDestroyCallback) {
         if (in_array($preDestroyCallback, $this->getPreDestroyCallbacks()) === false) {
             $this->addPreDestroyCallback($preDestroyCallback);
         }
     }
 }