Created
July 25, 2012 12:20
-
-
Save iggymacd/3175885 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.datacert.apps.mattermanagement.integration; | |
import com.datacert.core.util.Logger | |
import org.apache.commons.vfs2.FileObject; | |
import org.apache.commons.vfs2.AllFileSelector; | |
import org.apache.commons.vfs2.FileSystem; | |
import org.apache.commons.vfs2.FileSystemException; | |
import org.apache.commons.vfs2.FileSystemManager; | |
import org.gmock.GMockTestCase | |
class LoaderTest extends GMockTestCase { | |
def logger | |
def fileSystemManager | |
def fileObject | |
void testInitialize(){ | |
play{ | |
SampleFTPSourceProviderImpl ftpProvider = null; | |
Map configurationMap = new HashMap(); | |
configurationMap.put("ServerName", "ftp2.cgsinc.ca"); | |
configurationMap.put("UserName", "amacdonald"); | |
configurationMap.put("Password", "D2917yg"); | |
configurationMap.put("RemoteDir", "/"); | |
configurationMap.put("FileSystem", "ftp"); | |
configurationMap.put("PortNumber", "21"); | |
configurationMap.put("LocalDir", "D:\\Users\\al\\temp"); | |
configurationMap.put("FileMask", "test"); | |
configurationMap.put("ArchiveDir", "D:\\Users\\al\\temp"); | |
ftpProvider = new SampleFTPSourceProviderImpl(logger, configurationMap); | |
assertTrue ftpProvider.initialize() | |
} | |
} | |
@Override | |
protected void setUp() throws Exception { | |
// TODO Auto-generated method stub | |
super.setUp(); | |
logger = mock(Logger) | |
logger.info(match { | |
System.out.println(it); | |
return it instanceof String | |
}).stub() | |
logger.info( | |
match { | |
System.out.println(it); | |
return it instanceof String | |
}, | |
match { | |
System.out.println(it.message); | |
System.out.println(it.getCause().message); | |
//it.printStackTrace() | |
return it instanceof Exception | |
}).stub() | |
fileObject = mock(FileObject) | |
fileObject.exists().returns(true).stub() | |
fileSystemManager = mock(FileSystemManager) | |
fileSystemManager.resolveFile( | |
match { | |
System.out.println("in resolveFile :: " + it); | |
return it instanceof String | |
}, | |
match { | |
//System.out.println(it.message); | |
//System.out.println(it.getCause().message); | |
return true | |
}).returns(fileObject).stub() | |
def vfsMock = mock(org.apache.commons.vfs2.VFS) | |
vfsMock.static.getManager().returns(fileSystemManager).stub() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment