Skip to content

Commit 4b439ce

Browse files
committed
AC-14558::Migration form RabbitMQ to Apache ActiveMQ
1 parent 1e1545c commit 4b439ce

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Framework\Stomp;
10+
11+
use Magento\Framework\MessageQueue\DefaultValueProvider;
12+
use Magento\TestFramework\Helper\Stomp;
13+
use Magento\TestFramework\Helper\Bootstrap;
14+
use Magento\TestFramework\ObjectManager;
15+
use PHPUnit\Framework\TestCase;
16+
17+
/**
18+
* @see dev/tests/integration/_files/Magento/TestModuleMessageQueueConfiguration
19+
*/
20+
class TopologyTest extends TestCase
21+
{
22+
/**
23+
* List of declared queues.
24+
*
25+
* @var array
26+
*/
27+
private $declaredQueues;
28+
29+
/**
30+
* @var Stomp
31+
*/
32+
private $helper;
33+
34+
/**
35+
* @var ObjectManager
36+
*/
37+
private $objectManager;
38+
39+
/**
40+
* @var string
41+
*/
42+
private $connectionType;
43+
44+
/**
45+
* @return void
46+
*/
47+
protected function setUp(): void
48+
{
49+
$this->objectManager = Bootstrap::getObjectManager();
50+
51+
/** @var DefaultValueProvider $defaultValueProvider */
52+
$defaultValueProvider = $this->objectManager->get(DefaultValueProvider::class);
53+
$this->connectionType = $defaultValueProvider->getConnection();
54+
55+
if ($this->connectionType === 'stomp') {
56+
$this->helper = $this->objectManager->create(Stomp::class);
57+
58+
if (!$this->helper->isAvailable()) {
59+
$this->fail('This test relies on ActiveMq JMX/Jalokia.');
60+
}
61+
$this->declaredQueues = $this->helper->getQueues();
62+
}
63+
}
64+
65+
/**
66+
* @dataProvider queueDataProvider
67+
* @param array $expectedConfig
68+
*/
69+
public function testTopologyInstallation(array $expectedConfig): void
70+
{
71+
if ($this->connectionType === 'amqp') {
72+
$this->markTestSkipped('STOMP test skipped because AMQP connection is available.
73+
This test is STOMP-specific.');
74+
}
75+
76+
$name = $expectedConfig['name'];
77+
$this->assertArrayHasKey($name, $this->declaredQueues);
78+
79+
$allowedKeys = ['name', 'durable', 'autoDelete', 'internalQueue', 'routingType'];
80+
// Keep only the allowed keys
81+
$filtered = array_intersect_key($this->declaredQueues[$name], array_flip($allowedKeys));
82+
83+
$this->assertEquals(
84+
$expectedConfig,
85+
$filtered,
86+
'Invalid queue configuration: ' . $name
87+
);
88+
}
89+
90+
/**
91+
* @return array
92+
*/
93+
public static function queueDataProvider(): array
94+
{
95+
return [
96+
'stomp.consumer.config.queue' => [
97+
'expectedConfig' => [
98+
'name' => 'stomp.consumer.config.queue',
99+
'durable' => 'true',
100+
'autoDelete' => 'false',
101+
'internalQueue' => 'false',
102+
'routingType' => 'ANYCAST'
103+
]
104+
]
105+
];
106+
}
107+
}

0 commit comments

Comments
 (0)