Page 1 of 1
Smartfox Extension Unit Testing (the beginning)
Posted: 29 Nov 2009, 15:29
by starzero
Hello everyone, this is my first attempt at something resembling a testing structure for my extension that I thought I'd share. Feel free to comment / critique.
http://ideacandi.com/blogzero/?p=44
Thanks!
Paul
Posted: 03 Dec 2009, 21:29
by Lapo
Excellent work.
I've made the post a sticky so that it doesn't get lost.
Posted: 16 Dec 2009, 22:01
by hadrien
I have read your article (
http://ideacandi.com/blogzero/?p=44) with lots of attention: Thank you! I (and my team) are facing the same issue:
How to unit test asynchronous calls to SFS server via java client?
Here are some answers I've just googled on junit asynchronous tests:
Actually, your article makes me wonder lots of things on SFS (thank you a lot!) and, it raised some questions:
- Why is there no any synchronous java methods in the java client (using blocking IO rather than NIO with apache mina) so that we can write unit test in a linear manner without the asynchronous issue?
- Is there a plan to provide such unit test case framework in future?
- If yes, when?
- How do SFS/gotoandplay team do develop server extensions with continuous integration and team collaboration in mind?
Thank you a lot!
Posted: 18 Dec 2009, 15:40
by Lapo
Thanks for your comments and links.
As regards the Java API they where not aimed at providing a Unit Testing tool.
As you might have already noticed from some of our posts we are working on a major new release which will take a significant leap forward in all departments. On of them will certainly be Java Extension development which will see big improvements. (At the moment I am not allowed to say much more than this but it shouldn't take much before we can release more details)
Back to the topic I think unit testing of asynchronous code would be an cool feature and we are interested in providing a solution for it. It is still a bit premature at this point of our road map as we have lots of other priorities but we'll definitely put in the queue for later discussion and analysis.
hope it helps
SmartFoxClient.class
Posted: 22 Mar 2010, 17:35
by rockycaam
How do I get the classes that are imported in the unit test classes?
import it.gotoandplay.smartfoxclient.ISFSEventListener;
import it.gotoandplay.smartfoxclient.SFSEvent;
import it.gotoandplay.smartfoxclient.SmartFoxClient;
import it.gotoandplay.smartfoxclient.data.SFSObject;
The SmartFox jar I have does not contain any of those file...
Posted: 22 Mar 2010, 18:30
by Lapo
Those are client side API classes, not server side.
SmartFoxClient
Posted: 22 Mar 2010, 18:50
by rockycaam
Lapo,
The SFSTest.java class sample from the link on the first post (
http://ideacandi.com/blogzero/?p=44)contains the following code:
Code: Select all
package com.foo.test;
import it.gotoandplay.smartfoxclient.SFSEvent;
import it.gotoandplay.smartfoxclient.SmartFoxClient;
import it.gotoandplay.smartfoxclient.data.SFSObject;
import org.junit.Before;
import com.smithandtinker.smartfox.cluster.test.junit.SFSTestCase;
public class SFFTest extends SFSTestCase{
public SmartFoxClient sfsClient = null;
public void sfsSetUp() {
sfsClient = this.getSmartFoxClient();
}
public void testAvatarCard() {
//your test method will depend heavily on how your class structures are implemented
SFSObject sfsObject = new SFSObject();
sfsObject.put("type", "clothing");
sfsObject.put("sex", "male");
sfsObject.put("method", "getItemsByType");
sfsClient.sendXtMessage("requestHandler", "store", sfsObject);
try {
Thread.sleep(20000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//this is for demo only ... no validation included
}
public void sfsTearDown(){
sfsClient.logout();
sfsClient.disconnect();
}
}
You are saying those classes do not exist?
So "startzero" (the user that posted that link) created them from scratch?
Posted: 22 Mar 2010, 23:07
by Lapo
Sorry, this post was started more than 6 months ago

You are referring to the Java API client classes.
Here you go -->
http://www.smartfoxserver.com/labs/API/
Scroll down a bit until you see the Java logo

Re: Smartfox Extension Unit Testing (the beginning)
Posted: 21 Aug 2014, 18:17
by Zammy
The main article link is dead.
Re: Smartfox Extension Unit Testing (the beginning)
Posted: 09 Mar 2016, 10:52
by alexdev
Would it be possible to provide a working link to the code ?
Re: Smartfox Extension Unit Testing (the beginning)
Posted: 09 Mar 2016, 12:31
by Lapo
This is a 6 year old post regarding SmartFoxServer 1.x. Is it possible you're referring to SFS2X?