Getting an UnknownHostException when trying to fetch data from flickr? - java

I am trying to fetch the xml file from flickr. Here is my code:
public static final String TAG = "FlickrFetchr";
public static final String ENDPOINT = "http://api.flickr.com/services/rest/";
public static final String API_KEY = "d4db9623ea909f4d2a01c8c9667fd378"; //secret=0c764276c114d52f
public static final String METHOD_GET_RECENT = "flickr.photos.getRecent";
public static final String PARAM_EXTRAS = "extras";
public static final String EXTRA_SMALL_URL = "url_s";
private static final String XML_PHOTO = "photo";
String url = Uri.parse(ENDPOINT).buildUpon().appendQueryParameter("method", METHOD_GET_RECENT)
.appendQueryParameter("api_key", API_KEY)
.appendQueryParameter(PARAM_EXTRAS, EXTRA_SMALL_URL)
.build().toString();
String xmlString = getUrl(url);
When i debug, i see that the url is (Docs)and it works, the xml file is there. But i am getting an exception that says "Unable to resolve host "api.flickr.com": No address associated with hostname".
Can anyone see the problem?
Thanks.

Seeing as it was the case and you requested it, here's it as an answer.
If you are running an emulator, please restart it. This happens a lot. That exception is also thrown when the device has no internet connection.

Related

Cucumber integration in testrail(java)

i try to integrate cucumber scenarios in testrail, but i don't find some solutions, if somebody integrate it, can help?
i have scenarios write in java cucumber and need to integrate it in testrail. if it possible.
i try with api from documentation, but it is not work or i have some mistake
public static String TEST_RUN_ID = "5400";
public static String TESTRAIL_USERNAME = "username";
public static String TESTRAIL_PASSWORD = "password";
public static String RAILS_URL = "url";
public static final int TEST_CASE_PASSED_STATUS = 1;
public static final int TEST_CASE_FAILED_STATUS = 5;
public static void addResultForTestCase(String testCseId, int status,
String error) throws IOException, APIException {
String testRunId = TEST_RUN_ID;
APIClient client = new APIClient(RAILS_URL);
client.setUser(TESTRAIL_USERNAME);
client.setPassword(TESTRAIL_PASSWORD);
Map data = new HashMap();
data.put("status_id", status);
data.put("comment", "Test Executed - status updates automatically");
client.sendPost("add_result_for_case/" + testRunId+ "/" + testCseId + "", data);
}
}```
You might want to have a look at Railflow - it can parse Cucumber JSON reports and create/update tests and test runs in TestRail.
P.S. I'm developer of TestRail

How to fix square in-app-payments error, 'There was an error processing the payment, please check your network connection.'

I set up a server in Heroku, to serve as a backend server for the In-App-Payments to test taking payments from costumers.
I tried creating a new Heroku app, but it still wouldn't connect to it
private static final String CHARGE_SERVER_HOST = ".heroku.com/chargePayment";
private static final String CHARGE_SERVER_URL = "https://" + CHARGE_SERVER_HOST + "/ ";
private static final String YOUR_ACCESS_TOKEN = "LKJH#OJ$HNO#UY $)*#O$H#OH $KJ#HLK$H#K$H:#LKJH$ #JH$LK H#$JH#LKJH$LK#HJ$j";
public static boolean serverHostSet() {
return !CHARGE_SERVER_HOST.equals("REPLACE_ME");
}
public static boolean squareLocationIdSet() {
return !SQUARE_LOCATION_ID_FOR_GOOGLE_PAY.equals("REPLACE_ME");
}
I expected Heroku to work since I use the sample server from Square but it keeps saying Cannot GET \

Can i send information to testrail for selenium when my test runs its course

I am trying to send my tests to testrail from selenium but im not using an assert to end the test, i just want it to pass if it runs to completion? Is this possible? Also is there any examples of how this working in the code? I currently have:
public class login_errors extends ConditionsWebDriverFactory {
public static String TEST_RUN_ID = "R1713";
public static String TESTRAIL_USERNAME = "f2009#hotmail.com";
public static String TESTRAIL_PASSWORD = "Password100";
public static String RAILS_ENGINE_URL = "https://testdec.testrail.com/";
public static final int TEST_CASE_PASSED_STATUS = 1;
public static final int TEST_CASE_FAILED_STATUS = 5;
#Test
public void login_errors() throws IOException, APIException {
Header header = new Header();
header.guest_select_login();
Pages.Login login = new Pages.Login();
login.login_with_empty_fields();
login.login_with_invalid_email();
login.email_or_password_incorrect();
login.login_open_and_close();
login_errors.addResultForTestCase("T65013",TEST_CASE_PASSED_STATUS," ");
}
public static void addResultForTestCase(String testCaseId, int status,
String error) throws IOException, APIException {
String testRunId = TEST_RUN_ID;
APIClient client = new APIClient(RAILS_ENGINE_URL);
client.setUser(TESTRAIL_USERNAME);
client.setPassword(TESTRAIL_PASSWORD);
Map data = new HashMap();
data.put("status_id", status);
data.put("comment", "Test Executed - Status updated automatically from Selenium test automation.");
client.sendPost("add_result_for_case/"+testRunId+"/"+testCaseId+"",data );
}
}
I am getting a 401 status from this code.
Simply place the addResultForTestCase method at the end of the run. Ensure the Test CASE is used rather than the run id. You are currently using the incorrect ID

How to send my test results from selenium to testrail

I am having trouble sending my test results from selenium to testrail. I cant seem to figure it out using the paperwork provided. I am currently using this:
public class login_errors extends ConditionsWebDriverFactory {
public static String TEST_RUN_ID = "R1713";
public static String TESTRAIL_USERNAME = "testemai9#hotmail.com";
public static String TESTRAIL_PASSWORD = "Password1";
public static String RAILS_ENGINE_URL = "https://testproj.testrail.com/";
public static final int TEST_CASE_PASSED_STATUS = 1;
public static final int TEST_CASE_FAILED_STATUS = 5;
#Test
public void login_errors() throws IOException, APIException {
Header header = new Header();
header.guest_select_login();
Pages.Login login = new Pages.Login();
login.login_with_empty_fields();
login.login_with_invalid_email();
login.email_or_password_incorrect();
login.login_open_and_close();
login_errors.addResultForTestCase(TEST_RUN_ID,TEST_CASE_PASSED_STATUS," ");
}
public static void addResultForTestCase(String testCaseId, int status,
String error) throws IOException, APIException {
String testRunId = TEST_RUN_ID;
APIClient client = new APIClient(RAILS_ENGINE_URL);
client.setUser(TESTRAIL_USERNAME);
client.setPassword(TESTRAIL_PASSWORD);
Map data = new HashMap();
data.put("status_id", status);
data.put("comment", "Test Executed - Status updated automatically from Selenium test automation.");
client.sendPost("add_result_for_case/"+testRunId+"/"+testCaseId+"",data );
}
}
But i keep getting the following exception:
com.gurock.testrail.APIException: TestRail API returned HTTP
401("Authentication failed: invalid or missing user/password or
session cookie.")
Can anybody help me on the exact way this should be done out in java? I am not sure I am doing it correctly.
I'm using my own custom made API for testrail, but it is all based on same thing.
But looking to official gurrock,
documentation
First You need to add "testrail/" at the end of Your URL endpoint,
APIClient client = new APIClient("http://<server>/testrail/");
client.setUser("..");
client.setPassword("..");
Should be like this:
public static String RAILS_ENGINE_URL ="https://testproj.testrail.com/testrail/";
Second thing what I found out is that You're sending test run id in variable for testcase ID, this is not same.
And another thing is that test case ID shouldn't be with anything in front just pure number, not like "R123" but "123"
And Your method should than accept one more parameter, testRunId
public static void addResultForTestCase(String testRunId, String testCaseId, int status,String error) throws IOException, APIException {
String testRunId = TEST_RUN_ID;
APIClient client = new APIClient(RAILS_ENGINE_URL);
client.setUser(TESTRAIL_USERNAME);
client.setPassword(TESTRAIL_PASSWORD);
Map data = new HashMap();
data.put("status_id", status);
data.put("comment", "Test Executed - Status updated automatically from Selenium test automation.");
client.sendPost("add_result_for_case/"+testRunId+"/"+testCaseId+"",data );
}
And another thing is that You have to have created testrun, so You can have Yourself your testrun ID, like pic bellow:
And than test case ID is different from testrun id.

Trying to import data from Mysql to hive using SqoopOptions

Iam Trying to import data from Mysql to hive using SqoopOptions but getting this error:
ERROR tool.ImportTool: Imported Failed: Wrong FS: hdfs://localhost:8020/user/hive/warehouse/default/emp/_logs, expected: file:///
it is importing data into hdfs but not in hive.
here is my complete code.
import org.apache.sqoop.tool.ImportTool;
import com.cloudera.sqoop.SqoopOptions;
public class App
{
public static void main( String[] args )
{
importToHive("emp");
}
/* CONSTANTS */
private static final String JOB_NAME = "Sqoop Hive Job";
private static final String MAPREDUCE_JOB = "Hive Map Reduce Job";
private static final String DBURL ="jdbc:mysql://localhost:3306/sample";
private static final String DRIVER = "com.mysql.jdbc.Driver";
private static final String USERNAME = "root";
private static final String PASSWORD = "cloudera";
private static final String HADOOP_HOME ="/usr/lib/hadoop-0.20-mapreduce";
private static final String JAR_OUTPUT_DIR = "/tmp/sqoop/compile";
private static final String HIVE_HOME = "/usr/lib/hive";
private static final String HIVE_DIR = "/user/hive/warehouse/";
private static final String WAREHOUSE_DIR = "hdfs://localhost:8020/user/hive/warehouse/default";
private static final String SUCCESS = "SUCCESS !!!";
private static final String FAIL = "FAIL !!!";
/* **
* Imports data from RDBMS MySQL and uploads into Hive environment
*/
public static void importToHive(String table){
System.out.println("SqoopOptions loading .....");
/* MySQL connection parameters */
SqoopOptions options = new SqoopOptions();
options.setConnectString(DBURL);
options.doOverwriteHiveTable();
options.setTableName(table);
options.setDriverClassName(DRIVER);
options.setUsername(USERNAME);
options.setPassword(PASSWORD);
options.setHadoopMapRedHome(HADOOP_HOME);
/* Hive connection parameters */
options.setHiveHome(HIVE_HOME);
options.setHiveImport(true);
options.setHiveTableName("bsefmcgh");
options.setOverwriteHiveTable(true);
options.setFailIfHiveTableExists(false);
//options.setFieldsTerminatedBy(',');
options.setOverwriteHiveTable(true);
options.setDirectMode(true);
options.setNumMappers(1); // No. of Mappers to be launched for the job
options.setWarehouseDir(WAREHOUSE_DIR);
options.setJobName(JOB_NAME);
options.setMapreduceJobName(MAPREDUCE_JOB);
options.setTableName(table);
options.setJarOutputDir(JAR_OUTPUT_DIR);
System.out.println("Import Tool running ....");
ImportTool it = new ImportTool();
int retVal = it.run((com.cloudera.sqoop.SqoopOptions) options);
}
}
I believe you do not need to specify the name node address in the warehouse-dir option.
Try this:
private static final String WAREHOUSE_DIR = "/user/hive/warehouse/default";

Categories