@@ -0,0 +1,1947 @@
+package com.github.phantomthief.failover.util;%0A%0Aimport static org.junit.Assert.assertFalse;%0Aimport static org.junit.Assert.assertTrue;%0Aimport static org.junit.Assert.fail;%0A%0Aimport org.junit.Test;%0A%0A/**%0A * @author w.vela%0A * Created on 16/2/19.%0A */%0Apublic class SharedResourceTest %7B%0A%0A    private static SharedResource%3CString, MockResource%3E resources = new SharedResource%3C%3E();%0A%0A    @Test%0A    public void test() throws Exception %7B%0A        resources.register(%221%22, MockResource::new);%0A        resources.register(%221%22, MockResource::new);%0A        resources.register(%222%22, MockResource::new);%0A%0A        MockResource mockResource1 = resources.get(%221%22);%0A        MockResource mockResource2 = resources.get(%221%22);%0A        assertTrue(mockResource1 == mockResource2);%0A        assertFalse(mockResource1.isShutdown());%0A%0A        resources.unregister(%221%22, MockResource::close);%0A        mockResource1 = resources.get(%221%22);%0A        assertFalse(mockResource1.isShutdown());%0A%0A        resources.unregister(%221%22, MockResource::close);%0A        assertTrue(mockResource1.isShutdown());%0A        mockResource1 = resources.get(%221%22);%0A        assertTrue(mockResource1 == null);%0A    %7D%0A%0A    @Test%0A    public void testUnpairUnregister() %7B%0A        resources.register(%223%22, MockResource::new);%0A        resources.unregister(%223%22, MockResource::close);%0A        try %7B%0A            resources.unregister(%223%22, MockResource::close);%0A            fail(%22fail.%22);%0A        %7D catch (IllegalStateException e) %7B%0A            assertTrue(true);%0A        %7D%0A    %7D%0A%0A    private static class MockResource %7B%0A%0A        private String name;%0A        private boolean shutdown = false;%0A%0A        MockResource(String name) %7B%0A            this.name = name;%0A        %7D%0A%0A        boolean isShutdown() %7B%0A            return shutdown;%0A        %7D%0A%0A        void close() %7B%0A            if (shutdown) %7B%0A                fail();%0A            %7D%0A            shutdown = true;%0A            System.out.println(%22shutdown:%22 + name);%0A        %7D%0A    %7D%0A%7D%0A

add testcase.