Forum Discussion
Sure, I don't know about those other SDKs. Possibly the JavaScript one could be made to work, an interesting challenge, but not something I can guide you on beyond the basics. Like I say I have only played with JavaScript within SoapUI, I wouldn't be surprised if there were limits.
I mainly chose the Groovy approach & Java AWS SDK, because Groovy is a first class citizen within SoapUI, whereas JavaScript might not be. Also the Java syntax is obviously legal Groovy e.g. the AWS Java SDK samples should work with a minimum of effort within SoapUI Groovy TestSteps. I like Python, but I am personally not aware of any synergies with Groovy or SoapUI. The libs that that Java AWS SDK packages are quite a lot:
aspectjrt-1.8.2.jar aspectjweaver.jar commons-codec-1.9.jar commons-logging-1.1.3.jar freemarker-2.3.9.jar httpclient-4.5.2.jar httpcore-4.4.4.jar ion-java-1.0.0.jar jackson-annotations-2.6.0.jar jackson-core-2.6.6.jar jackson-databind-2.6.6.jar jackson-dataformat-cbor-2.6.6.jar javax.mail-api-1.4.6.jar jmespath-java-1.0.jar joda-time-2.8.1.jar spring-beans-3.0.7.RELEASE.jar spring-context-3.0.7.RELEASE.jar spring-core-3.0.7.RELEASE.jar spring-test-3.0.7.RELEASE.jar
The idea of an external wrapper, was also something I was thinking about. It could be the cleanest architectural and most flexible approach at this point.
Interesting stuff you're doing :-)
Regards,
Rup
After doing some more reading my first attempt is to Groovy + aws-java-sdk. To get the dependencies i used grapes (based on this thread http://stackoverflow.com/questions/306139/how-do-i-include-jars-in-a-groovy-script).
My code:
@Grab(group='com.amazonaws', module='aws-java-sdk', version='1.11.39')
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.Bucket;
import com.amazonaws.services.s3.model.CannedAccessControlList;
import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest;
import com.amazonaws.services.s3.model.GetObjectRequest;
import com.amazonaws.services.s3.model.ObjectListing;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.S3ObjectSummary;
AmazonS3Client client = new AmazonS3Client();
client.setRegion(Region.getRegion(Regions.EU_WEST_1));
List<Bucket> buckets = client.listBuckets();
When playing the script it first takes a while (good sign) and actually i do see jars popping up in ~/.groovy/grapes/com.amazonaws/aws-java-sdk/jars
But then an error message:
java.lang.NoSuchMethodError: com.amazonaws.SDKGlobalConfiguration.isInRegionOptimizedModeEnabled()Z @ line 18
I verified and this method is in fact part of the jar so the import is not working?
Also tried to cp the jar into ~/SmartBear/ReadyAPI-1.8.5/bin/ext : same result
I guess i'm missing something on the import part?
Paul
- Paul4248 years agoOccasional Contributor
Hello Rupert,
I was thinking about the external wrapper as well but the downside is then the interface towards that wrapper, in a sense that you will need to think of something support certain arguments etc... and also the results are obviously verbose so you'll need to parse the returned json or whatever you get. It's all overhead in this approach, that is actually the beauty of integrating with the sdk; you'll have 'native' access to the interface of the sdk....
Anyway we are rethinking our approach; soapui does not seem to be a tool for automated component/integration testing which includes reading back/comparing responses and i believe it will be much easier to implement something with plain unittest's in python. You simply import the boto3 (sdk) and it'll work :-)
If i may advise on scripting capabilities for soapui....: support Python ;-) If you support the runtimes from a virtualenv you will not have the issue's like dependency hell i have been in; that has been proven to work very well for years... Also it could give soapui a boost since the Python community is very big.
Paul
- Paul4248 years agoOccasional Contributor
I may have found the cause of the error; it's probably a version conflict with a jar from ReadyAPI-..../lib since appearently an older version from aws is already present (aws-java-sdk-core-1.10.14.jar). I only found that when i had to switch to the open source edition of soapui (because the pro edition did not show my scripts any more!?!?!? but that's something different).
When i succeed in adding grapes support to the open source edition i'll post the results./....
Paul
- rupert_anderson8 years agoValued Contributor
It sounds like you're making good progress!
I wasn't sure whether grapes works inside SoapUI, I only use it in standalone Groovy stuff, so that is an interesting learning in itself - is SoapUI definitely resolving your grape dependencies? I only ever add dependencies to the /ext folder, and sometimes further up the classpath if I am doing something more hacky where I need to override something in SoapUI itself.
Thanks,
Rupert
- rupert_anderson8 years agoValued Contributor
Actually, Grapes seems to work easily enough once ivy is added, just had a quick go - although this is a simple example it worked after a quick pause to download the commons-lang dependency:
@Grab(group='commons-lang', module='commons-lang', version='2.4') import org.apache.commons.lang.WordUtils log.info "Hello ${WordUtils.capitalize('world')}"
Added ivy-2.1.0.jar to /lib
Have you had any luck with the more complex AWS SDK?
Thanks,
Rupert
- Paul4248 years agoOccasional Contributor
Making progress.....
First of all it's important to know i'm running on the open source edition of soapui now (which has .... other dependencies listed in its lib folder).
In order to get Grape running i had to manually add some jars to the lib folder (not the ext folder), versions are dependent on the soapui version:
SoapUI 5.2.1 => Groovy 2.1.7 => ivy 2.2.0 => ant 1.6.2
I downloaded these from maven repo and cp into the lib, then restart soapui and it came alive with this code:
import groovy.grape.Grape
Grape.grab(group: 'com.amazonaws', module: 'aws-java-sdk', version: '1.11.39')
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.Bucket;AmazonS3Client client = new AmazonS3Client();
client.setRegion(Region.getRegion(Regions.EU_WEST_1));
//List<Bucket> buckets = client.listBuckets();I now run into the next issue which is again a missing dependency; probably httpclient...
Error is java.lang.NoClassDefFoundError: Could not initialize class com.amazonaws.http.conn.ssl.SdkTLSSocketFactory error at line: 13 So when i can figure out the dependency/version i can get it via Grape...
Paul
- rupert_anderson8 years agoValued Contributor
Hi,
OK, cool.
I didn't seem to need ant, only ivy.
I got some NoClassDefErrors on my attempt (a year ago, so can't remember what I did), but it was to do with clashes with some overlapping dependencies from the SoapUI lib folder as discussed earlier in the post (some of the ones in the list of jars I posted).
Would be good to know which ones clash, as I or someone else could potentially correct/update the versions in the SoapUI source.
Thanks,
Rupert
- Paul4248 years agoOccasional Contributor
Rupert,
I guess i found that version conflict, and i am now more or less stuck.... :(
Issue is that soapui and groovy use the same set of libraries which is obviously not a good idea.....
So the issue now is that aws-java-sdk-core requires httpclient 4.5.2 is you run a recent version however soapui is shipped with 4.1.1 (5 years old), obviously it makes no sense to run 5yr old aws api's..... I was hoping that Grape.grab(.... would download and override the system loaded library but it does not.
I'm getting all kind of wierd problems:
- java.lang.NoClassDefFoundError: Could not initialize class com.amazonaws.http.conn.ssl.SdkTLSSocketFactory error at line: 14
- I've also seen something with Field INSTANCE missing which i do not understand,..,..
Any tips/advise would be welcome,
Can i override/set the lib path groovy is using?
Paul
- rupert_anderson8 years agoValued Contributor
Hi,
Yeah, it got messy for me too when I tried it..
Aside from getting Groovy to override the lib path, maybe just as a experiment, have you tried adding the problem (duplicate) dependencies first (or in front of lib) in the classpath e.g. in soapui.sh something like
SOAPUI_CLASSPATH=$SOAPUI_HOME/bin/soapuilib_http_teststep_patch-1.0-sample.jar:$SOAPUI_HOME/bin/soapui-5.2.1.jar:$SOAPUI_HOME/lib/*
I've done this successfully before in simpler cases - of course in this case it may be counterproductive!
Thanks,
Rupert
- Paul4248 years agoOccasional Contributor
Rupert,
It does not seem to work; also it looks like the dependencies fetched via Grape are nto available since it's complaining again the aws classes are not found. All in all it feels not stable to me...
I'm switching to the github open source edition to get latest (and hopefully greatest) ;-) but i'm having doubts if i can overcome the dependency hell...
The best solution would be to have groovy scripts running in a sandbox (alike virtualenv for python if you will), it will make it much more flexible to run whatever version of jars that you need. For instance i'm seeing that if i replace the httpclient 4.1.1 with the newest version (that aws requires) then soapui does not startup anymore ... :-(
Paul
- Paul4248 years agoOccasional Contributor
More problems... the github version does not build out-of-the-box; some javafx dependency issue... I have no time to go through that now, i think this is going to be a dead end... :-(
Related Content
- 6 months agosohailalam2696
- 10 years agogus
- 3 years agofdelmoro
- 12 months agosinis
Recent Discussions
- 16 hours agoemoya
- 20 hours agoMyBalanceNow