Skip to content

Instantly share code, notes, and snippets.

@astachelek
Created September 9, 2011 22:03
Show Gist options
  • Save astachelek/1207450 to your computer and use it in GitHub Desktop.
Save astachelek/1207450 to your computer and use it in GitHub Desktop.
Reusable base unit test class that launches the FTP server
import org.junit.Before
import grails.test.GrailsUnitTestCase
/**
* Common base class for all integration tests starts an FTP server and ensures FTP folders exist
*/
class BaseIntegrationTestCase extends GrailsUnitTestCase {
// Load our configured FTP server
def testFtpServer
/**
* Convenience method to ensure that local folders in test directory are created
* @param path the path to be created if it does not exist
*/
protected void initLocalTestFolder(String path) {
if (!path) return
File localFile = new File(path)
if (!localFile.exists()) {
localFile.mkdirs();
}
}
@Before
public void setUp() {
super.setUp();
// Ensure the test FTP folder is created; this folder is configured in user.properties
initLocalTestFolder("target/test-ftp")
// Check to see if the server is started yet, if not, start er' up
if (testFtpServer && testFtpServer.isStopped()) {
testFtpServer.start()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment