@Override
    public void beforeMethod(final TargetAdviceObject target, final TargetAdviceMethod method, final Object[] args, final String pluginType) {
        if ("close".equals(method.getName())) {
            ContextManager contextManager = AgentReflectionUtils.getFieldValue(target, "contextManager");
            ShardingSphereDataSourceContextHolder.remove(contextManager.getComputeNodeInstanceContext().getInstance().getMetaData().getId());
        }
    }
@Test
    void assertBeforeMethod() {
        ContextManager contextManager = mockContextManager();
        when(AgentReflectionUtils.getFieldValue(fixture, "contextManager")).thenReturn(contextManager);
        ShardingSphereDataSourceContextHolder.put(instanceId, new ShardingSphereDataSourceContext(databaseName, mock(ContextManager.class, RETURNS_DEEP_STUBS)));
        assertThat(ShardingSphereDataSourceContextHolder.getShardingSphereDataSourceContexts().size(), is(1));
        TargetAdviceMethod method = mock(TargetAdviceMethod.class);
        when(method.getName()).thenReturn("close");
        ShardingSphereDataSourceAdvice advice = new ShardingSphereDataSourceAdvice();
        advice.beforeMethod(fixture, method, new Object[]{}, "FIXTURE");
        assertThat(ShardingSphereDataSourceContextHolder.getShardingSphereDataSourceContexts().size(), is(0));
    }