Browse Source
* commit 'cf51c366b49654321d2671f1c0826add1a729852': REPORT-148096 整体代码已重构,删除无效单测 REPORT-148096 该方法的单测没用了,之前补充了新的没有删除旧的 && 改动,出现了未预期调用的方法 REPORT-148096 暂时过滤掉与UI相关的单测bugfix/11.0
18 changed files with 39 additions and 87 deletions
@ -1,60 +0,0 @@ |
|||||||
package com.fr.design.mainframe.socketio; |
|
||||||
|
|
||||||
import com.fr.invoke.Reflect; |
|
||||||
import com.fr.workspace.WorkContext; |
|
||||||
import com.fr.workspace.Workspace; |
|
||||||
import io.socket.client.IO; |
|
||||||
import io.socket.client.Socket; |
|
||||||
|
|
||||||
import org.easymock.EasyMock; |
|
||||||
import org.junit.Assert; |
|
||||||
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.modules.junit4.PowerMockRunner; |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* @author: Maksim |
|
||||||
* @Date: Created in 2019/12/9 |
|
||||||
* @Description: |
|
||||||
*/ |
|
||||||
@RunWith(PowerMockRunner.class) |
|
||||||
@PrepareForTest({WorkContext.class,DesignerSocketIO.class, IO.class}) |
|
||||||
public class DesignerSocketIOTest { |
|
||||||
|
|
||||||
@Test |
|
||||||
public void close() throws Exception { |
|
||||||
this.update(); |
|
||||||
DesignerSocketIO.close(); |
|
||||||
DesignerSocketIO.Status status = Reflect.on(DesignerSocketIO.class).field("status").get(); |
|
||||||
Socket socket = Reflect.on(DesignerSocketIO.class).field("socket").get(); |
|
||||||
|
|
||||||
Assert.assertEquals(DesignerSocketIO.Status.Disconnecting,status); |
|
||||||
Assert.assertNull(socket); |
|
||||||
} |
|
||||||
|
|
||||||
@Test |
|
||||||
public void update() throws Exception { |
|
||||||
Workspace current = EasyMock.mock(Workspace.class); |
|
||||||
EasyMock.expect(current.isLocal()).andReturn(false); |
|
||||||
|
|
||||||
PowerMock.mockStatic(WorkContext.class); |
|
||||||
EasyMock.expect(WorkContext.getCurrent()).andReturn(current); |
|
||||||
|
|
||||||
String[] uri = {"http://127.0.0.1:8888/workspace","http://127.0.0.1:9999/workspace"}; |
|
||||||
PowerMock.mockStaticPartial(DesignerSocketIO.class,"getSocketUri"); |
|
||||||
PowerMock.expectPrivate(DesignerSocketIO.class,"getSocketUri").andReturn(uri); |
|
||||||
|
|
||||||
EasyMock.replay(current); |
|
||||||
PowerMock.replayAll(); |
|
||||||
|
|
||||||
DesignerSocketIO.update(); |
|
||||||
DesignerSocketIO.Status status = Reflect.on(DesignerSocketIO.class).field("status").get(); |
|
||||||
Socket socket = Reflect.on(DesignerSocketIO.class).field("socket").get(); |
|
||||||
|
|
||||||
Assert.assertEquals(DesignerSocketIO.Status.Connected,status); |
|
||||||
Assert.assertNotNull(socket); |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue