I am trying to add attachment to QC Test LAB Test Case run from my Java code using Com4J API. I was able to create a successful run, however while adding attachments below code is throwing invalid parameter for "IAttachment attach = attachfac.addItem(null).queryInterface(IAttachment.class);". In this case additem is expecting Java Item Object. I also tried to pass addItem(""), but then attach.Type(1) is failing with reason:- Attachment Type cannot be changed. Could anyone please help me with this:
IBaseFactory obj2 = testset.tsTestFactory().queryInterface(IBaseFactory.class);
IList tstestlist = obj2.newList("");
for(Com4jObject obj3:tstestlist){
ITSTest tstest = obj3.queryInterface(ITSTest.class);
if(tstest.name().contentEquals("[1]TC1")){
System.out.println("TC found");
IRunFactory runfactory = tstest.runFactory().queryInterface(IRunFactory.class);
IRun run=runfactory.addItem("RunNew").queryInterface(IRun.class);
run.status("Passed");
IAttachmentFactory attachfac = run.attachments().queryInterface(IAttachmentFactory.class);
IAttachment attach = attachfac.addItem("").queryInterface(IAttachment.class);
attach.type(1);
attach.fileName("Path to File TC1");
attach.post();
run.post();.
String fileName = new File(Attachment).getName();
String folderName = new File(Attachment).getParent();
try{
IAttachmentFactory attachfac = tsteststeps.attachments().queryInterface(IAttachmentFactory.class);
IAttachment attach = attachfac.addItem(fileName).queryInterface(IAttachment.class);
IExtendedStorage extAttach = attach.attachmentStorage().queryInterface(IExtendedStorage.class);
extAttach.clientPath(folderName);
extAttach.save(fileName, true);
attach.description(Actual);
attach.post();
attach.refresh();
}catch(Exception e) {
System.out.println("QC Exceptione : "+e.getMessage());
}
Related
I'm doing a coursework project for university and I'm in charge of getting the profile system functioning. Our lecturer has given us some sample code to get a file-upload working which I'm going to use for the user's profile picture however even though my code looks to be very similar I just can't seem to get it working. The issue is that the file won't actually create and save in my project, yet the code my lecturer gave me does!
Here is the code the lecturer gave me:
NewsStory newsstory = new NewsStory();
newsstory.uniqueid = "story_"+System.currentTimeMillis();
newsstory.dateItWasPublished = System.currentTimeMillis();
newsstory.title = toProcess.params.get("title");
newsstory.description = toProcess.params.get("description");
newsstory.journalists.add(toProcess.params.get("journalist"));
newsstory.filepathToImage = toProcess.params.get("fileupload");
File uploaded = new File(newsstory.filepathToImage);
int ind = newsstory.filepathToImage.lastIndexOf('.');
String extension = newsstory.filepathToImage.substring(ind);
uploaded.renameTo(new File("httpdocs/"+newsstory.uniqueid+extension));
newsstory.filepathToImage = newsstory.uniqueid+extension;
//At this point you would normally add the newsstory to the database
MVMap<String, NewsStory> newsStories = db.s.openMap("NewsStories");
newsStories.put(newsstory.uniqueid, newsstory);
This basically takes in a String from a fileupload paramater passed in through a form and runs the code below. Here is my code:
user.userEmail = toProcess.params.get("email");
user.profilePicturePath = toProcess.params.get("filepath");
System.out.println(user.profilePicturePath);
File uploaded = new File(user.profilePicturePath);
int ind = user.profilePicturePath.lastIndexOf('.');
String extension = user.profilePicturePath.substring(ind);
uploaded.renameTo(new File("httpdocs/"+user.username+"ProfilePicture"+extension));
user.profilePicturePath = user.username+"ProfilePicture"+extension;
System.out.println(user.profilePicturePath);
users.put(user.username, user);
db.commit();
Does anyone know why I might be having this issue?
I would like to know how to get the API end point of a TestStep in SoapUI Xml using Java.
I have used the following,
for (int i=0; i<numberOfTestSteps; i++) {
WsdlTestStep testStep = testCase.getTestStepAt(i);
WsdlTestCaseRunner runner = new WsdlTestCaseRunner(testCase, new StringToObjectMap());
runner.runTestStep(testStep);
List<TestStepResult> resultList = runner.getResults();
for (TestStepResult result : resultList) {
String endPoint = ((MessageExchange)result).getEndpoint();
System.out.println("End Point = " + endPoint);
}
}
It only gives "www.test.com:8080". But I need the API end point as in the image.
Please someone help me to solve this.
Below should give you what you are looking for:
String resourcePath = ((MessageExchange)result).getResource().getFullPath();
System.out.println("Resource Path = " + resourcePath);
You may look at respective SoapUI's API
There is very simply way too if you wish to show that value from with SoapUI Project itself.
In the test case, there might be a REST Request Test step type. Add a Script Assertion as shown below:
log.info messageExchange.endpoint
I am learning Amazon Cloud Search but I couldn't find any code in either C# or Java (though I am creating in C# but if I can get code in Java then I can try converting in C#).
This is just 1 code I found in C#: https://github.com/Sitefinity-SDK/amazon-cloud-search-sample/tree/master/SitefinityWebApp.
This is 1 method i found in this code:
public IResultSet Search(ISearchQuery query)
{
AmazonCloudSearchDomainConfig config = new AmazonCloudSearchDomainConfig();
config.ServiceURL = "http://search-index2-cdduimbipgk3rpnfgny6posyzy.eu-west-1.cloudsearch.amazonaws.com/";
AmazonCloudSearchDomainClient domainClient = new AmazonCloudSearchDomainClient("AKIAJ6MPIX37TLIXW7HQ", "DnrFrw9ZEr7g4Svh0rh6z+s3PxMaypl607eEUehQ", config);
SearchRequest searchRequest = new SearchRequest();
List<string> suggestions = new List<string>();
StringBuilder highlights = new StringBuilder();
highlights.Append("{\'");
if (query == null)
throw new ArgumentNullException("query");
foreach (var field in query.HighlightedFields)
{
if (highlights.Length > 2)
{
highlights.Append(", \'");
}
highlights.Append(field.ToUpperInvariant());
highlights.Append("\':{} ");
SuggestRequest suggestRequest = new SuggestRequest();
Suggester suggester = new Suggester();
suggester.SuggesterName = field.ToUpperInvariant() + "_suggester";
suggestRequest.Suggester = suggester.SuggesterName;
suggestRequest.Size = query.Take;
suggestRequest.Query = query.Text;
SuggestResponse suggestion = domainClient.Suggest(suggestRequest);
foreach (var suggest in suggestion.Suggest.Suggestions)
{
suggestions.Add(suggest.Suggestion);
}
}
highlights.Append("}");
if (query.Filter != null)
{
searchRequest.FilterQuery = this.BuildQueryFilter(query.Filter);
}
if (query.OrderBy != null)
{
searchRequest.Sort = string.Join(",", query.OrderBy);
}
if (query.Take > 0)
{
searchRequest.Size = query.Take;
}
if (query.Skip > 0)
{
searchRequest.Start = query.Skip;
}
searchRequest.Highlight = highlights.ToString();
searchRequest.Query = query.Text;
searchRequest.QueryParser = QueryParser.Simple;
var result = domainClient.Search(searchRequest).SearchResult;
//var result = domainClient.Search(searchRequest).SearchResult;
return new AmazonResultSet(result, suggestions);
}
I have already created domain in Amazon Cloud Search using AWS console and uploaded document using Amazon predefine configuration option that is movie Imdb json file provided by Amazon for demo.
But in this method I am not getting how to use this method, like if I want to search Director name then how do I pass in this method as because this method parameter is of type ISearchQuery?
I'd suggest using the official AWS CloudSearch .NET SDK. The library you were looking at seems fine (although I haven't look at it any detail) but the official version is more likely to expose new CloudSearch features as soon as they're released, will be supported if you need to talk to AWS support, etc, etc.
Specifically, take a look at the SearchRequest class -- all its params are strings so I think that obviates your question about ISearchQuery.
I wasn't able to find an example of a query in .NET but this shows someone uploading docs using the AWS .NET SDK. It's essentially the same procedure as querying: creating and configuring a Request object and passing it to the client.
EDIT:
Since you're still having a hard time, here's an example. Bear in mind that I am unfamiliar with C# and have not attempted to run or even compile this but I think it should at least be close to working. It's based off looking at the docs at http://docs.aws.amazon.com/sdkfornet/v3/apidocs/
// Configure the Client that you'll use to make search requests
string queryUrl = #"http://search-<domainname>-xxxxxxxxxxxxxxxxxxxxxxxxxx.us-east-1.cloudsearch.amazonaws.com";
AmazonCloudSearchDomainClient searchClient = new AmazonCloudSearchDomainClient(queryUrl);
// Configure a search request with your query
SearchRequest searchRequest = new SearchRequest();
searchRequest.Query = "potato";
// TODO Set your other params like parser, suggester, etc
// Submit your request via the client and get back a response containing search results
SearchResponse searchResponse = searchClient.Search(searchRequest);
I'm trying to use Yellowfin services from my C# code. They are written on Java, so I've enabed JAX services as they recommend.
So JAX services are running at "localhost:8083/webservices/LegacyReportService?wsdl", and I cannot make them work as specified (I'm running RUNDASHBOARDREPORT method of the ReportService)
That's how I use it:
Web References to the YF services running on my localhost:
Here I call the service
public static reportServiceResponse RunDashboardReport(Int32 reportId, Int32 tabId)
{
var rq = CreateYfRequest("RUNDASHBOARDREPORT");
rq.reportId = reportId;
rq.dashboardTabId = tabId;
using (var srv = new LegacyReportServiceService())
{
var resp = srv.remoteReportCall(rq); // there is no "remoteAdministrationCall" as in the doc
return resp;
}
}
private static reportServiceRequest CreateYfRequest(String command)
{
var rq = new reportServiceRequest
{
loginId = "admin#yellowfin.com.au",
password = "test",
orgId = 1, // This is the primary organization
reportRequest = command
};
return rq;
}
And I get "An exception of type 'System.InvalidOperationException' occurred in System.Xml.dll "
when creating
new LegacyReportServiceService()
I've also tried to add it as a Service Reference, but the result is the same.
The YF team sais "We do have clients that are using .net and C# to develop their integration code. ...The support team has confirmed example code provided in development folder in the Yellowfin directory and WSDL code are accurate and are unable to replicate the errors you’ve identified in your original email."
Please help me to find out, what I'm doing wrong
I've found out that VS generates classes for the web service access from "localhost:8083/webservices/LegacyReportService?xsd=1" and it does that improperly. It makes String[] from original String type.
So editing the generated Reference.cs of the Web Reference did the thing.At least, I've got the response with errorCode 25 "Not authorized".
Try the following code to get rid of response code 25.
rsr.orgId = 1;
rsr.orgIdSpecified = true;
rsr.dashboardTabId = 11111;
rsr.dashboardTabIdSpecified = true;
rsr.reportId = 22222;
rsr.reportIdSpecified = true;
Certain parameters for yellowfin need to explicitly told to read.
Check if this works
reportServiceRequest rq = new reportServiceRequest();
rq.loginId = "admin#xxxxx.com";
rq.password = "xxxxxxx";
rq.orgId = 1;
rq.reportRequest = "RUNDASHBOARDREPORT";
rq.reportId = reportId;
rq.orgIdSpecified = true;
rq.dashboardTabId = 11111;
rq.dashboardTabIdSpecified = true;
rq.reportIdSpecified = true;
rq.dashboardTabId = tabId;
using (var srv = new ServiceReference2.LegacyReportServiceClient())
{
YellowFinIntegrationWithDotNet.ServiceReference2.reportServiceResponse resp = null;
try
{
resp = srv.remoteReportCall(rq); // there is no "remoteAdministrationCall" as in the doc
}
catch (System.Exception ex)
{
MessageBox.Show(ex.InnerException.ToString());
return resp;
}
return resp;
}
I would like to change SIM card PIN number using java reflection. Final app will be installed in system/app.
The code I'm using is:
String ICCCARD_CLASS = "com.android.internal.telephony.IccCard";
String PHONEBASE_CLASS = "com.android.internal.telephony.PhoneBase";
Object phoneBaseObject = Class.forName(PHONEBASE_CLASS).getConstructor();
Object iccCardObject = Class.forName(ICCCARD_CLASS).newInstance();
Method iccCardMethod = Class.forName(ICCCARD_CLASS).getMethod("changeIccLockPassword", String.class, String.class, Message.class);
//Method arguments are...
Object arglist1[] = new Object[3];
arglist1[0] = "1111"; //oldPass
arglist1[1] = "2222"; //newPass
arglist1[2] = new Message(); //message handler (not needed)
iccCardMethod.invoke(iccCardObject, arglist1);
But, I'm getting a lot of exceptions like "no such method", "instantiation exception"...
In my Android project packages for IccCard and PhoneBase are not created.
TNX Hackers!
It seems that compiling indeed requires android.jar to be rebuilt with modified classes.dex.