package com.fanruan.api.cluster.state; import com.fr.cluster.engine.core.jchannel.MachineMarker; import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.api.easymock.PowerMock; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; import org.powermock.modules.junit4.PowerMockRunner; /** * @author Lucian.Chen * @version 10.0 * Created by Lucian.Chen on 2020/3/24 */ @RunWith(PowerMockRunner.class) @PrepareForTest(MachineMarker.class) @SuppressStaticInitializationFor("com.fr.cluster.engine.core.jchannel.MachineMarker") public class MachineKitTest { @Test public void testCurrentID() { PowerMock.mockStatic(MachineMarker.class); EasyMock.expect(MachineMarker.currentID()).andReturn("1").anyTimes(); PowerMock.replay(MachineMarker.class); Assert.assertEquals(MachineKit.currentID(), "1"); PowerMock.verify(MachineMarker.class); } @Test public void testCurrentName() { PowerMock.mockStatic(MachineMarker.class); EasyMock.expect(MachineMarker.currentName()).andReturn("1").anyTimes(); PowerMock.replay(MachineMarker.class); Assert.assertEquals(MachineKit.currentName(), "1"); PowerMock.verify(MachineMarker.class); } }