/** * Tests that initialization from an invalid deployment descriptor won't work. * * @return void */ public function testFromInvalidConfiguration() { // initialize the configuration $node = new SessionNode(); $node->initFromFile(__DIR__ . '/_files/dd-statefulsessionbean.xml'); // check that the descriptor has not been initialized $this->assertNull($this->descriptor->fromConfiguration($node)); }
/** * Tests if the merge method works successfully. * * @return void */ public function testMergeSuccessful() { // initialize the configuration $node = new SessionNode(); $node->initFromFile(__DIR__ . '/_files/dd-singletonsessionbean.xml'); // initialize the descriptor from the nodes data $this->descriptor->fromConfiguration($node); // initialize the descriptor to merge $descriptorToMerge = $this->getMockForAbstractClass('AppserverIo\\Description\\SingletonSessionBeanDescriptor'); // initialize the configuration of the descriptor to be merged $nodeToMerge = new SessionNode(); $nodeToMerge->initFromFile(__DIR__ . '/_files/dd-singletonsessionbean-to-merge.xml'); $descriptorToMerge->fromConfiguration($nodeToMerge); // merge the descriptors $this->descriptor->merge($descriptorToMerge); // check if all values have been merged $this->assertSame('ASingletonProcessor', $this->descriptor->getName()); $this->assertSame('AppserverIo\\Apps\\Example\\Services\\ASingletonProcessor', $this->descriptor->getClassName()); $this->assertFalse($this->descriptor->isInitOnStartup()); $this->assertContains('newDetach', $this->descriptor->getPostDetachCallbacks()); $this->assertContains('newAttach', $this->descriptor->getPreAttachCallbacks()); $this->assertCount(0, $this->descriptor->getEpbReferences()); $this->assertCount(0, $this->descriptor->getResReferences()); $this->assertCount(0, $this->descriptor->getReferences()); $this->assertCount(1, $this->descriptor->getPostConstructCallbacks()); $this->assertCount(2, $this->descriptor->getPostDetachCallbacks()); $this->assertCount(2, $this->descriptor->getPreAttachCallbacks()); }
/** * Tests if the merge method works successfully. * * @return void */ public function testMergeSuccessful() { // initialize the configuration $node = new SessionNode(); $node->initFromFile(__DIR__ . '/_files/dd-statefulsessionbean.xml'); // initialize the descriptor from the nodes data $this->descriptor->fromConfiguration($node); // initialize the descriptor to merge $descriptorToMerge = $this->getMockForAbstractClass('AppserverIo\\Description\\StatefulSessionBeanDescriptor'); // initialize the configuration of the descriptor to be merged $nodeToMerge = new SessionNode(); $nodeToMerge->initFromFile(__DIR__ . '/_files/dd-statefulsessionbean-to-merge.xml'); $descriptorToMerge->fromConfiguration($nodeToMerge); // merge the descriptors $this->descriptor->merge($descriptorToMerge); // check that the descriptor has been initialized $this->assertSame('UserProcessor', $this->descriptor->getName()); $this->assertSame('AppserverIo\\Apps\\Example\\Services\\UserProcessor', $this->descriptor->getClassName()); $this->assertSame('Stateful', $this->descriptor->getSessionType()); // check for initialized lifecycle callbacks $this->assertContains('newDetach', $this->descriptor->getPostDetachCallbacks()); $this->assertContains('newAttach', $this->descriptor->getPreAttachCallbacks()); $this->assertContains('newActivate', $this->descriptor->getPostActivateCallbacks()); $this->assertContains('newPassivate', $this->descriptor->getPrePassivateCallbacks()); $this->assertContains('logout', $this->descriptor->getRemoveMethods()); $this->assertCount(2, $this->descriptor->getPostDetachCallbacks()); $this->assertCount(2, $this->descriptor->getPreAttachCallbacks()); $this->assertCount(2, $this->descriptor->getPostActivateCallbacks()); $this->assertCount(2, $this->descriptor->getPrePassivateCallbacks()); }
/** * 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); }
/** * Tests if the merge method works successfully. * * @return void */ public function testMergeSuccessful() { // 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\\SessionBeanDescriptor'); // initialize the configuration of the descriptor to be merged $nodeToMerge = new SessionNode(); $nodeToMerge->initFromFile(__DIR__ . '/_files/dd-sessionbean-to-merge.xml'); $descriptorToMerge->fromConfiguration($nodeToMerge); // merge the descriptors $this->descriptor->merge($descriptorToMerge); // check if all values have been merged $this->assertSame('SampleProcessor', $this->descriptor->getName()); $this->assertSame('AppserverIo\\Apps\\Example\\Services\\SampleProcessor', $this->descriptor->getClassName()); $this->assertSame('Stateless', $this->descriptor->getSessionType()); $this->assertCount(2, $this->descriptor->getEpbReferences()); $this->assertCount(3, $this->descriptor->getResReferences()); $this->assertCount(2, $this->descriptor->getPersistenceUnitReferences()); $this->assertCount(7, $this->descriptor->getReferences()); // check for initialized lifecycle callbacks $this->assertContains('initialize', $this->descriptor->getPostConstructCallbacks()); $this->assertContains('initializeIt', $this->descriptor->getPostConstructCallbacks()); $this->assertContains('destroy', $this->descriptor->getPreDestroyCallbacks()); $this->assertContains('destroyIt', $this->descriptor->getPreDestroyCallbacks()); }