Search This Blog

Wednesday, November 28, 2018

ReadyApi SoapApi Cheats and Notes


To Add an Step right click on the Test case and choose the script type.

To see any values log the value

def val = "fffff";
log.info(val);

Use Groovy script to do any tasks which are not already available.

to create a new property at test case level
def newProperty = 'Test' + System.currentTimeMillis();
testRunner.testCase.setPropertyValue("newProperty", newProperty);

And then it can be used in a subsequent step with
def property1 =  context.expand( '${#TestCase#newProperty}')


Reading xml request and response for soap steps

after the step can use following groovy script step to save the request and response to testcase level properties

//first grab the request, response , row request, row response.
def request  = testRunner.testCase.getTestStepByName("stepName").getProperty("Request").getValue();
def response  = testRunner.testCase.getTestStepByName("stepName").getProperty("Response").getValue();

def rawRequest  = testRunner.testCase.getTestStepByName("stepName").getProperty("RawRequest").getValue();
def rawResponse  = testRunner.testCase.getTestStepByName("stepName").getProperty("RawResponse").getValue();

//then save them to testcase level properties.

testRunner.testCase.setPropertyValue("xmlRequest", request);
testRunner.testCase.setPropertyValue("xmlResponse", response);

testRunner.testCase.setPropertyValue("rawRequest", rawRequest);
testRunner.testCase.setPropertyValue("rawResponse", rawResponse);


To query database
create a database step and select appropriate driver and connection string. place the drive in the SoapUI jars folder.

write a SQL select query and execute and see the results in the response pane.

to grab the results for assertions add an script assertion
click on the database script step, click on Assertions tab, click on + and select Script Assertion
right click and select Get Data > pick the step or test case to get the data from, eg the database step and then pick a variable.

let's say we picked ResponseAsXml
then click on Add button, pick the element from the xml view.(xpath expression is displayed when the element is selected). click OK. give a name for the property. click OK. this will add a linie to the script. something like below.

def responseAsXml = context.expand( '${MyStepName#ResponseAsXml#//Results[1]/ResultSet[1]/Row[1]/COMMUNICATION_ID[1]}' )


Sunday, November 25, 2018

Spring boot configuration to run both in websphere and tomcat with jta


if required to decalare additional configuration from dependancy jar modules use component scan
@SpringBootApplication(scanBasePackages = {"au.com.myserver.app.*", "au.com.otherApp.service.*"})

if required to exclude all datasource autoconfiguration
@SpringBootApplication(scanBasePackages = {"aa.bb.cc.*", "aa.bb.cd.ee.*"}, exclude = {DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
//or can specify on application.properties or application.yaml
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration

creating Tomcat JNDI datasources

@Configuration@Profile({ "tomcat" })
public class TomcatWebConfiguration  {


    @Value("${spring.datasource.app.jdbc-url}")
    private String appDataSourceUrl;
    @Value("${spring.datasource.app.username}")
    private String appDataSourceUsername;
    @Value("${spring.datasource.app.password}")
    private String appDataSourcePassword;
    @Value("${spring.datasource.app.jndi-name}")
    private String appDataSourceJndi;

    @Bean    public TomcatServletWebServerFactory tomcatFactory() {
        return new TomcatServletWebServerFactory() {
            @Override  protected TomcatWebServer getTomcatWebServer(org.apache.catalina.startup.Tomcat tomcat) {
                tomcat.enableNaming();                
                return super.getTomcatWebServer(tomcat);
            }

            @Override  protected void postProcessContext(Context context) {

                // context                
                ContextResource resource = new ContextResource();
                resource.setName(appDataSourceJndi);                
                resource.setType(DataSource.class.getName());
                resource.setProperty("url", appDataSourceUrl);
                resource.setProperty("username", appDataSourceUsername);
                resource.setProperty("password", appDataSourcePassword);
                context.getNamingResources()
                        .addResource(resource);
            }

        };    
    }

}





for SprintBootTest use following to disable autoconfigure
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, properties = {"spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration"})



Mockito notes


to use @Mock and @MockInjects do either of these


@RunWith(MockitoJUnitRunner.class)
public class MockitoAnnotationTest {
    ...
}

@Before
public void init() {
    MockitoAnnotations.initMocks(this);
}


Thursday, November 15, 2018

Useful Online tools

Json Path Online Evaluator
http://jsonpath.com/?

One stop shop for lot of online tools
https://www.regextester.com/

big number converter
https://www.mobilefish.com/services/big_number/big_number.php

Monday, November 12, 2018

iBM HTTP SERVER VIRTUAL HOST CONFIG FOR PROXY

<VirtualHost *:443>
 DocumentRoot "d:/IBM/HTTPServer/htdocs"
 ServerName localtest.com.au
 ServerAlias localtest
 ErrorLog logs/localtest-error.log
 CustomLog logs/localtest-access.log deflatelog
 Options -FollowSymLinks -Indexes -ExecCGI
 SSLEnable
 SSLProtocolDisable SSLv3 SSLv2
    SSLClientAuth Required
    SSLClientAuthRequire (CN = "www.myserver.com.au" || CN = "fake server" || OU="LTX,ABC")

## SSLv3 128 bit Ciphers
 #SSLCipherSpec SSL_RSA_WITH_RC4_128_MD5
 #SSLCipherSpec SSL_RSA_WITH_RC4_128_SHA
## FIPS approved SSLV3 and TLSv1 128 bit AES Cipher
 SSLCipherSpec TLS_RSA_WITH_AES_128_CBC_SHA
## FIPS approved SSLV3 and TLSv1 256 bit AES Cipher
 SSLCipherSpec TLS_RSA_WITH_AES_256_CBC_SHA
## Triple DES 168 bit Ciphers
 ## These can still be used, but only if the client does
 ## not support any of the ciphers listed above.
 #Commented out - birthday attack
 #SSLCipherSpec SSL_RSA_WITH_3DES_EDE_CBC_SHA
SSLServerCert mysever.com.au
    ProxyPass     /angular     http://localhost:4200/angular
    ProxyPass     /website1   http://localhost:8081/website
</VirtualHost>