use of com.alibaba.csp.sentinel.slots.statistic.StatisticSlot in project Sentinel by alibaba.
the class DefaultSlotChainBuilderTest method testBuild.
@Test
public void testBuild() {
DefaultSlotChainBuilder builder = new DefaultSlotChainBuilder();
ProcessorSlotChain slotChain = builder.build();
assertNotNull(slotChain);
// Verify the order of slot
AbstractLinkedProcessorSlot<?> next = slotChain.getNext();
assertTrue(next instanceof NodeSelectorSlot);
// Store the first NodeSelectorSlot instance
NodeSelectorSlot nodeSelectorSlot = (NodeSelectorSlot) next;
next = next.getNext();
assertTrue(next instanceof ClusterBuilderSlot);
next = next.getNext();
assertTrue(next instanceof LogSlot);
next = next.getNext();
assertTrue(next instanceof StatisticSlot);
next = next.getNext();
assertTrue(next instanceof AuthoritySlot);
next = next.getNext();
assertTrue(next instanceof SystemSlot);
next = next.getNext();
assertTrue(next instanceof FlowSlot);
next = next.getNext();
assertTrue(next instanceof DegradeSlot);
next = next.getNext();
assertNull(next);
// Build again to verify different instances
ProcessorSlotChain slotChain2 = builder.build();
assertNotNull(slotChain2);
// Verify the two ProcessorSlotChain instances are different
assertNotSame(slotChain, slotChain2);
next = slotChain2.getNext();
assertTrue(next instanceof NodeSelectorSlot);
// Store the second NodeSelectorSlot instance
NodeSelectorSlot nodeSelectorSlot2 = (NodeSelectorSlot) next;
// Verify the two NodeSelectorSlot instances are different
assertNotSame(nodeSelectorSlot, nodeSelectorSlot2);
}
use of com.alibaba.csp.sentinel.slots.statistic.StatisticSlot in project Sentinel by alibaba.
the class SpiLoaderTest method testLoadInstanceByClass.
@Test
public void testLoadInstanceByClass() {
ProcessorSlot slot = SpiLoader.of(ProcessorSlot.class).loadInstance(StatisticSlot.class);
assertNotNull(slot);
assertTrue(slot instanceof StatisticSlot);
}
use of com.alibaba.csp.sentinel.slots.statistic.StatisticSlot in project Sentinel by alibaba.
the class SpiLoaderTest method testLoadInstanceByAliasName.
@Test
public void testLoadInstanceByAliasName() {
ProcessorSlot slot = SpiLoader.of(ProcessorSlot.class).loadInstance("com.alibaba.csp.sentinel.slots.statistic.StatisticSlot");
assertNotNull(slot);
assertTrue(slot instanceof StatisticSlot);
}
Aggregations