Encountered this problem when I try to resolve dependencies for a gradle project, the root cause is a ssl certificate file can not be found in JDK installation.
Find below solution on internet:
123456789
#!/bin/shset -e
#the location of certificate file which gradle asks for, create the directory if it's not existed.cacerts=/Library/Java/JavaVirtualMachines/1.6.0_38-b04-436.jdk/Contents/Home/lib/security/cacerts
curl 'https://docs.codehaus.org/download/attachments/158859410/startssl-CA.pem?version=1&modificationDate=1277952972158'\ | keytool -import -alias StartSSL-CA -file /dev/stdin -keystore $cacerts -storepass changeit -noprompt
curl 'https://docs.codehaus.org/download/attachments/158859410/startssl-Intermediate.pem?version=1&modificationDate=1277952972182'\ | keytool -import -alias StartSSL-Intermediate -file /dev/stdin -keystore $cacerts -storepass changeit -noprompt
create a new file and paste the code into it, then run with sudoer permission.
varmyApp=angular.module("myApp",[]);myApp.config(['$httpProvider',function($httpProvider){var$http,interceptor=['$q','$injector',function($q,$injector){functionsuccess(response){// get $http via $injector because of circular dependency problem$http=$http||$injector.get('$http');if($http.pendingRequests.length<1){console.log('ajax cal respond with success');}returnresponse;}functionerror(response){console.log('x',response);// get $http via $injector because of circular dependency problem$http=$http||$injector.get('$http');if($http.pendingRequests.length<1){console.log('ajax call respond with error');}return$q.reject(response);}returnfunction(promise){console.log('before send ajax request');returnpromise.then(success,error);};}];$httpProvider.responseInterceptors.push(interceptor);}]);
publicclassInjectMocksTest{@MockprivateEJBBeanInjectedByContainerInRealCodedependencyBean;//Create a mock object with type EJBBeanInjectedByContainerInRealCode and inject it to a spy object.//Mockito will try to inject this dependency to target object in this order: Constructor, Property, Field.@InjectMocks@SpyprivateMyEJBBeanejbBean;//Create a spy object of MyEJBBean, all fields annotated with @Mock with injected into this spy object.@BeforepublicvoidsetUp(){initMocks(this);//This is required to create all the mock objects and spy objects declared in annotation way.}@TestpublicvoidtestShouldXXX()throwsException{when(dependencyBean.findSomeDataFromDB(anyString(),anyString(),anyString())).thenReturn(anyList());//Mock the behavior the the injected dependency.Object[]objects=ejbBean.myMethod();//Call the real method on the spy object.assertThat(objects).isNotEmpty();}}
Verify method call
Verify method called with expected arguments
123456789
ArgumentCaptor<String>argument=ArgumentCaptor.forClass(String.class);verify(errors,atLeastOnce()).add(argument.capture(),any(ActionMessage.class));//Verify errors.add(_, _) called with expected arguements, mockito will store captured arguemnt into the ArgumentCaptor object.List<String>values=argument.getAllValues();//If method called only once, use getValue() to get the value passed in, if caleed multi times, use getAllVales() to get value list.assertTrue(values.contains("exception.message"));assertTrue(values.contains("exception.detail"));
@And("^i press enter key$")publicvoidi_press_enter_key()throwsThrowable{driver.findElement(By.id("gbqfq")).sendKeys(Keys.ENTER);}
How can wait until a element display or clickable.
1234567891011121314
@Then("^i should see at least (\\d+) results related to my search keyword$")publicvoidi_should_see_at_least_results_related_to_my_search_keyword(intamount)throwsThrowable{WebDriverWaitwait=newWebDriverWait(driver,10);wait.until(ExpectedConditions.elementToBeClickable(By.id("pnnext")));List<WebElement>results=driver.findElements(By.cssSelector("li.g"));assertThat(results.size()).isGreaterThan(amount);List<String>resultTexts=Lambda.extract(results,on(WebElement.class).getText());for(Stringtext:resultTexts){assertThat(text).containsIgnoringCase(keyword);}}
-g, –glue PATH Where glue code (step definitions and hooks) is loaded from.
-f, –format FORMAT[:PATH_OR_URL] How to format results. Goes to STDOUT unless PATH_OR_URL is specified.
Available formats: junit, html, pretty, progress, json, json-pretty.
-t, –tags TAG_EXPRESSION Only run scenarios tagged with tags matching TAG_EXPRESSION.
-n, –name REGEXP Only run scenarios whose names match REGEXP.
-s, –[no-]-strict Treat undefined and pending steps as errors.
--dotcucumber PATH_OR_URL Where to write out runtime information. PATH_OR_URL can be a file system
path or a URL.
-v, –version Print version.
-h, –help You’re looking at it.
IDE support
Be able to run *.feature files directly without any configuration in IntelliJ, you should put feature files as the same package structure as glue code.
configurations{cucumberRuntime{extendsFromtestRuntime}}taskcucumber(){dependsOnassemble,compileTestJavadoLast{javaexec{main="cucumber.api.cli.Main"jvmArgs=["-Dwebdriver.chrome.driver=/Users/edfeng/Downloads/chromedriver"]//Must set if you want to use chrome webdriverclasspath=configurations.cucumberRuntime+sourceSets.main.output+sourceSets.test.outputargs=["-g","gradle.cucumber","src/test/resources"]// 1. must set package name of glue code(where steps are defined). 2. must set directory of feature files.}}}
Advanced configuration
Create gradle based project from template
Simply add the following to your ~/.gradle/init.gradle script: