RetailMeNot / TestRailSDK

TestRail integration with Java WebDriver implementation.
MIT License
25 stars 27 forks source link

Branch "ST-67", compile local jar in error #25

Closed ansonliao closed 8 years ago

ansonliao commented 8 years ago

Dear Sir, I checkout branch "ST-67", and compile to get local jar, get error. mvn install Error:

Error:(267, 11) java: exception java.io.IOException is never thrown in body of corresponding try statement
Error:(302, 11) java: exception java.io.IOException is never thrown in body of corresponding try statement
Error:(319, 11) java: exception java.io.IOException is never thrown in body of corresponding try statement
Error:(336, 11) java: exception java.io.IOException is never thrown in body of corresponding try statement
Error:(353, 11) java: exception java.io.IOException is never thrown in body of corresponding try statement
Error:(370, 11) java: exception java.io.IOException is never thrown in body of corresponding try statement
Error:(389, 11) java: exception java.io.IOException is never thrown in body of corresponding try statement

Follow up the suggestion of IDE to fix the errors above, and create a test for connect to personal Testrail, when run the test was fail, detail is below: Test script Test.java:

public class TestMaaii {

    public static void main(String[] agrs) {
        String username = "exampleTestRail@exmple.com";
        String api_endPoint = "exampleTestRail";
        String password = "pwd123456";

        TestRailService testRailService = new TestRailService(api_endPoint, username, password);

        for (Project project : testRailService.getProjects()) {
            System.out.println("Project name: " + project.getName());
            System.out.println("Project ID: " + project.getId());
        }
    }
}

Error message:

Mar 11, 2016 16:16:34:156 PM....DEBUG [main] url: http://testrail.com/index.php?/api/v2/get_projects
Mar 11, 2016 16:16:34:185 PM....DEBUG [main] Attempting to get http://testrail.com/index.php?/api/v2/get_projects
Mar 11, 2016 16:16:34:186 PM....DEBUG [main] Adding header [Content-Type: application/json]
Mar 11, 2016 16:16:37:449 PM....DEBUG [main]  **OK**
Mar 11, 2016 16:16:37:449 PM....DEBUG [main] 
org.codehaus.jackson.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
 at [Source: java.io.StringReader@67205a84; line: 1, column: 2]
    at org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1433)
    at org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:521)
    at org.codehaus.jackson.impl.JsonParserMinimalBase._reportUnexpectedChar(JsonParserMinimalBase.java:442)
    at org.codehaus.jackson.impl.ReaderBasedParser._handleUnexpectedValue(ReaderBasedParser.java:1198)
    at org.codehaus.jackson.impl.ReaderBasedParser.nextToken(ReaderBasedParser.java:485)
    at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:2770)
    at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2718)
    at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1877)
    at com.rmn.testrail.util.JSONUtils.getMappedJsonObjectList(JSONUtils.java:81)
    at com.rmn.testrail.util.JSONUtils.getMappedJsonObjectList(JSONUtils.java:63)
    at com.rmn.testrail.service.TestRailService.getEntityList(TestRailService.java:128)
    at com.rmn.testrail.service.TestRailService.getProjects(TestRailService.java:548)
    at com.rmn.testrail.service.Test.main(TestMaaii.java:17)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Exception in thread "main" java.lang.RuntimeException: Could not process JSON
    at com.rmn.testrail.util.JSONUtils.getMappedJsonObjectList(JSONUtils.java:86)
    at com.rmn.testrail.util.JSONUtils.getMappedJsonObjectList(JSONUtils.java:63)
    at com.rmn.testrail.service.TestRailService.getEntityList(TestRailService.java:128)
    at com.rmn.testrail.service.TestRailService.getProjects(TestRailService.java:548)
    at com.rmn.testrail.service.TestMaaii.main(TestMaaii.java:17)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

and I modified class TestRailService.java, changed variable apiEndpoint value to "http://%s.testrail.com/", and then re-run the test, got error message below:

Mar 11, 2016 18:38:36:737 PM....DEBUG [main] url: http://exampleTestRail.testrail.com/index.php?/api/v2/get_projects
Mar 11, 2016 18:38:36:756 PM....DEBUG [main] Attempting to get http://exampleTestRail.testrail.com/index.php?/api/v2/get_projects
Mar 11, 2016 18:38:36:757 PM....DEBUG [main] Adding header [Content-Type: application/json]
Mar 11, 2016 18:38:38:622 PM....ERROR [main]  **unknown response code**.
Exception in thread "main" Mar 11, 2016 18:38:38:622 PM....DEBUG [main] 
java.lang.RuntimeException: Could not read contents from connection: no content-type
    at com.rmn.testrail.util.HTTPUtils.getContentsFromConnection(HTTPUtils.java:174)
    at com.rmn.testrail.service.TestRailService.getEntityList(TestRailService.java:127)
    at com.rmn.testrail.service.TestRailService.getProjects(TestRailService.java:548)

It seems that can't add property Content-Type with value application/jason to header.

Any idea to fix the problem?

ansonliao commented 8 years ago

Dear Sir, I fixed the problem and can connect to testrail cloud. the bugs have three:

  1. Test case sample TestRailServiceIntegrationTest have throw exception error, remove throw IOException can fix the problem.
  2. Class TestRailService, variable apiEndpoint have two bug:
    • https:// should be correct, and original http:// is incorrect.
    • This variable value should include one parameter. so the correct value of variable apiEndpoint should be initialize to String apiEndpoint = "https://%s.testrail.com"

still not test private testrail now.

vinceis1337 commented 8 years ago

@ansonliao Thank you so much for this information! I will fix it as soon as possible.

vinceis1337 commented 8 years ago

@ansonliao I have fixed the issues and merged them into ST-67. Thanks again for reporting these problems!

P.S. 我也姓廖 :)

ansonliao commented 8 years ago

@vinceis1337 Thanks for your reply. BTW, are you Chinese? I am from Hong Kong, my family name is "廖"。

vinceis1337 commented 8 years ago

@ansonliao I am American, but my parents are from Taiwan. My family name is also "廖".

ansonliao commented 8 years ago

@vinceis1337 nice to talk you, Vinceis. grade that you know my family name from english word "Liao", not Chinese character.