Ask a Question

Reading files from smb shared drive from Groovy test step?

markgholland
Occasional Contributor

Reading files from smb shared drive from Groovy test step?

I need to read files from a shared smb file location via a Groovy test step in SoapUI. Any suggestions on how I might implement this?

 

Thanks!

2 REPLIES 2
TanyaYatskovska
SmartBear Alumni (Retired)

Hi Markgholland,

 

 

Could you please clarify if you want to read files from your network location or from the Internet?

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager



It's a network location.

 

I've tried the following and it appears that I can connect to the drive(getPath() for example), but for some reason I can't call certain methods(isFile() for example):

 

import jcifs.smb.NtlmPasswordAuthentication
import jcifs.smb.SmbFile

String url = "smb://myserver.com"
String fullPath = ( url + "/path/to/file.txt" )

smbAuth = new NtlmPasswordAuthentication( url, context.expand( '${#TestCase#username}' ), context.expand( '${#TestCase#password}' ) )

dir = new SmbFile( fullPath, smbAuth )

//works
log.info dir.getPath()

//doesn't work
log.info dir.isFile()

Getting this error:

jcifs.smb.SmbException: jcifs.util.transport.TransportException java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:209) at java.net.SocketInputStream.read(SocketInputStream.java:141) at jcifs.util.transport.Transport.readn(Transport.java:29) at jcifs.smb.SmbTransport.peekKey(SmbTransport.java:351) at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:267) at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:298) at jcifs.util.transport.Transport.run(Transport.java:223) at java.lang.Thread.run(Thread.java:745) at jcifs.util.transport.Transport.run(Transport.java:239) at java.lang.Thread.run(Thread.java:745) error at line: 15

I appreciate any assistance!

 

cancel
Showing results for 
Search instead for 
Did you mean: