stub

Stubbing WebSocket in JavaScript with Jasmine

≡放荡痞女 提交于 2019-12-30 04:50:05
问题 I try to test if onmessage is a proper function. Here is a test: describe(".init(address, window)", function() { beforeEach(function() { address = 'ws://test.address'; window = {}; e = { data: {} } spyOn(window, 'WebSocket').and.returnValue(function() {return {onmessage: null}}); spyOn(subject, 'handleMessage'); }); it("should create a WebSocket client which connects to the given address", function() { subject.init(address, window); expect(window.WebSocket).toHaveBeenCalledWith(address); });

How to use stubs in JUnit and Java?

℡╲_俬逩灬. 提交于 2019-12-30 01:12:09
问题 I have worked with JUnit and Mocks but I'm wondering, what are the differences between Mocks and Stubs in JUnit and how to use Stubs in JUnit, Java? And as Mocks that have EasyMock, Mockito and so on, what does Stubs uses in Java? Please give some example code for Stubs in Java. 回答1: To use stubs in junit you don't need any frameworks. If you want to stub some interface just implement it: interface Service { String doSomething(); } class ServiceStub implements Service { public String

Stub Controller in Play 2.0

♀尐吖头ヾ 提交于 2019-12-25 14:23:53
问题 I am trying folow the example from Mock Objects in Play[2.0] but unfortunately I am not having success. I have a UsersController that uses a UserModel. trait UserModel extends ModelCompanion[User, ObjectId] { // ... } Next, the abstract controller abstract class UsersController extends Controller { val userModel: UserModel def sayHello = Action(parse.json) { request => // return a play Action. Doesn't use userModel } // Other methods } In the routes file, I call method say Hello in this way:

Powermock constructor mocking has no effect on the instantiated object

有些话、适合烂在心里 提交于 2019-12-24 11:47:10
问题 Class A{ B objB = new B(); objB.someBMethod(); } Class B{ public void someBMethof(){ C objC = new C(); } } class C{ int a=1; public C(){} public C(int v){ a=v; } } @RunWith( PoswerMockRunner.class ) @PrepareForTest({ A.class, B.class, C.class}) Class TestApp{ @Mock C mockC; PowerMockito.whenNew( C.class ).withNoArguments().thenReturn(mockC); } The above code captures what im trying to do. But the whenNew() does not seem to be working and when i try debuggin the C object created is not the

Passing remote parameters in RMI

北战南征 提交于 2019-12-24 08:56:50
问题 I would like to have confirm about RMI theory. Let us suppose that Client A requests a remote reference of an object O to a Server B. Well, now if In O interface (Interf) there is a method like: void foo(Interf obj); When Client A calls O.foo(O) it passes stub reference (before received ) and then Server does not use its local reference but the Stub Object (received by Client), and so each call on O methods by Server will make use of its TCP/IP service. Is it Ok? You should feel free to add

Axis wsdl2java not generating all interfaces in stub

耗尽温柔 提交于 2019-12-24 07:52:36
问题 I am trying to generate stub using wsdl2java.bat, my wsdl consists of two bindings. I see that wsdl2bat creates interface for operations in the first binding but does not generate anything for operations in the seconds binding. wsdl2java.bat -uri http://... -o client -d adb -s -u. For example the code should look like this try { //Create the stub by passing the AXIS_HOME and target EPR. //We pass null to the AXIS_HOME and hence the stub will use the current directory as the AXIS_HOME

adding authentification header to client stub axis2

送分小仙女□ 提交于 2019-12-24 07:35:15
问题 I built the wsdl-client-stub based on xmlbeans. Now I got stuck adding a custom header for authentification using xmlbeans since xmlbeans stubs are lacking the necessary Classes(?) Actually, the header should look like: <SOAP-ENV:Header> <ns2:verifyingToken> <UserID>9</UserID> <Token>29438094lkjslfkjlsdkjf</Token> </ns2:verifyingToken> </SOAP-ENV:Header> So I tried as fallback going in between stub and ServiceClient: ServiceClient sc = stub._getServiceClient(); OMFactory omFactory =

What's the purpose of the lua “stub” dll for windows

房东的猫 提交于 2019-12-24 01:54:18
问题 I'm looking at incorporating Lua into a C++ project, and am a bit confused by the presence of the two binaries (lua51.dll and lua5.1.dll) in the distribution from Luabinaries. According to the docs... In Windows your library or application must be linked with a stub library. A stub library is a library with only the function declarations that will bind your DLL with the Lua DLL. Why? I've never needed stub DLLs before when linking with third-party DLLs? 回答1: A stub library is a .lib file, not

Generate a C# delegate method stub

醉酒当歌 提交于 2019-12-23 02:51:12
问题 Anyone know how to automatically create a delegate stub method? In WPF it seems im constantly having to pass delegates around. i would like to be able to type a method name that doesnt exist and have a method stub automatically generated...currently i'am having to constantly reference the docs to get the delegate signature and then manually create method with matching signature. 回答1: Use an IDE plugin like Refactor Pro! It also allows you to convert your delegates to instance methods, or if

SQL server stub for java

别等时光非礼了梦想. 提交于 2019-12-22 06:41:46
问题 I have a java application that is using MSSQL server through the JDBC driver. Is there some kind of stub that I can use for testing? For example I want to test how my application handle cases of connection errors, SQL server out of disk, and other exceptions. It's pretty hard and complex to simulate this with real SQL server. Thanks 回答1: You could write unit tests against your DAO s or repositories returning mock Connection objects using a mock library such as https://mocquer.dev.java.net/.