running ECSTask in IOS - ios

I am new to IOS platform. I have a code snippet written using JAVA API.
AmazonECS amazonECS = new AmazonECSClient(credentials).withRegion(usWest1);
String command="bash /opt/run-task.sh "+"/mnt/s3/inputFile1::/mnt/s3/inputFile2"+" "+ "outputFile";
ContainerOverride containerOverrides = new ContainerOverride().withCommand(command).withName("<<container name>>");
TaskOverride overrides = new TaskOverride().withContainerOverrides(containerOverrides);
RunTaskRequest runTaskRequest = new RunTaskRequest().withCluster("<<cluster name>>").withTaskDefinition("<<task definition arn>>")
.withOverrides(overrides).withGeneralProgressListener(new ProgressListener() {
#Override
public void progressChanged(ProgressEvent progressEvent) {
System.out.println(progressEvent.getBytesTransferred());
System.out.println(progressEvent.getEventType());
}
});
Task task = new Task().withTaskDefinitionArn("<<task definition arn>>")
.withOverrides(overrides);
RunTaskResult runTaskResult = amazonECS.runTask(runTaskRequest).withTasks(task);
List<Failure> failures = runTaskResult.withTasks(task).getFailures();
I am using ffmpeg to merge few video files as single file. I need to know if there is equivalent functionality available in IOS.

Related

Invoking Adapter from Java - Worklight 6.2

Below is the java sample code from worklight to invoke adapter.
public static void testAdapterCall(){
try{
DataAccessService service = WorklightBundles.getInstance().getDataAccessService();
String paramArray = "[5, 3,]";
ProcedureQName procedureQname = new ProcedureQName("CalculatorAdapter", "addTwoIntegers");
InvocationResult result = service.invokeProcedure(procedureQname, paramArray);
}
catch(Exception e)
{
e.printStackTrace();
}
}
I'm getting a Null Pointer exception, when it goes to line
DataAccessService service = WorklightBundles.getInstance().getDataAccessService();
Log is as below:
java.lang.NullPointerException
at com.worklight.customcode.Calculator1.testAdapterCall(Calculator1.java:38)
at com.worklight.customcode.Calculator1.main(Calculator1.java:53)
Versions:
Java 1.7
Worklight 6.2
The Adapter is deployed, and the server is also running locally.
I saw this question in other sites also, but it is not answered.
Any help is highly appreciated.
See the documentation in the following PDF document, starting page #13.
public void callProcedure() {
DataAccessService service = worklightBundles.getInstance().getDataAccessService();
String paramArray = "['param1', 'param2', 'param3']";
ProcedureQName procedureQName = new ProcedureQName("adapterName",
"procedureName");
InvocationResult result = service.invokeProcedure(ProcedureQName,
paramArray);
JSONObject jsonObject = result.toJSON();
String value = (String)jsonObject.get("key");
}
Be sure to add any missing includes once you enter the code into a Java IDE, such as Eclipse.

Using websockets/Server sent events with Angular dart

I was trying to use angular dart with websockets/server sent events and could not find any documentation/examples (there are some for angularJS but that seems very different for such things). A few things I tried also did not work.
Does anyone know how to do this?
Here is one version of what I tried and the error:
#NgController (
selector: "ACdistribution",
publishAs : "dstbn")
class ACDstbnController{
List <WtdPres> distbn;
void updateDstbn(List<WtdPres> newdstbn){
distbn = newdstbn;
}
final dstbnsrc = new EventSource("../dstbns")
..onMessage.listen((event){
List wps = JSON.decode(event.data);
List <WtdPres> newdistbn = wps.map((wp) => new WtdPres.fromJson(wp));
updateDstbn(newdistbn);
});
}
The error I got in pub build was:
web/provingground.dart:55:5:
'updateDstbn' is only available in instance methods.
updateDstbn(newdistbn);
^^^^^^^^^^^
There are limitations on what you can do on initializers for final fields.
Can you try to put this code inside the constructor
var dstbnsrc;
ACDstbnController() {
dstbnsrc = new EventSource("../dstbns")
..onMessage.listen((event){
List wps = JSON.decode(event.data);
List <WtdPres> newdistbn = wps.map((wp) => new WtdPres.fromJson(wp));
updateDstbn(newdistbn);
});
}

Changing Android Apk Locale via Robotium

I'm working on an activity instrumentation test case which automates verification of an AUT using the Robotium framework. There are several language tests I want to automate. I've attempted to change language via Robotium by pulling the resources from the AUT and forcing the local locale configuration to a different language, but to no avail:
Locale locale = new Locale(lang);
Locale.setDefault(locale);
Configuration config = res.getConfiguration();
config.locale = locale;
res.updateConfiguration(config, res.getDisplayMetrics());
I've also heard that it used to be possible that one could change the language using ADB using the activity manager, but I've been unable to find a working solution for V4.2.2. Short of embedding code in the application itself or rooting the device, is there any way to change locale remotely, through Robotium or otherwise?
Thanks in advance
I had a similar problem some time ago and came to the following solution:
private void changeActivityLocale(final Activity a, String locale ){
Resources res = a.getResources();
DisplayMetrics dm = res.getDisplayMetrics();
Configuration conf = res.getConfiguration();
conf.locale = new Locale(locale);
res.updateConfiguration(conf, dm);
a.getResources().updateConfiguration(conf, dm);
getInstrumentation().runOnMainSync(new Runnable() {
public void run() {
a.recreate();
}
});
}
I call this method inside my test case before starting some locale specific tests.
Hope it helps you.
Best regards,
Peter
protected void changeLocale(Locale locale)
throws ClassNotFoundException, SecurityException,
NoSuchMethodException, IllegalArgumentException,
IllegalAccessException, InvocationTargetException,
NoSuchFieldException {
#SuppressWarnings("rawtypes")
Class amnClass = Class.forName("android.app.ActivityManagerNative");
Object amn = null;
Configuration config = null;
// amn = ActivityManagerNative.getDefault();
Method methodGetDefault = amnClass.getMethod("getDefault");
methodGetDefault.setAccessible(true);
amn = methodGetDefault.invoke(amnClass);
// config = amn.getConfiguration();
Method methodGetConfiguration = amnClass.getMethod("getConfiguration");
methodGetConfiguration.setAccessible(true);
config = (Configuration) methodGetConfiguration.invoke(amn);
// config.userSetLocale = true;
#SuppressWarnings("rawtypes")
Class configClass = config.getClass();
Field f = configClass.getField("userSetLocale");
f.setBoolean(config, true);
// set the locale to the new value
config.locale = locale;
// amn.updateConfiguration(config);
Method methodUpdateConfiguration = amnClass.getMethod(
"updateConfiguration", Configuration.class);
methodUpdateConfiguration.setAccessible(true);
methodUpdateConfiguration.invoke(amn, config);
}
You will need permission in your application:
android.permission.CHANGE_CONFIGURATION
for api level >= 17 you have to grant it via adb:
adb shell pm grant application_package android.permission.CHANGE_CONFIGURATION

can't run the automated project in testcomplete when it calls from jenkins

can't run the automated project in testcomplete when calls from jenkins.
In our continuous integration part ,the project is automated using testcomplete and it is calling through jenkins with the help of bat file.The scripts inside the bat file is
"C:\Program Files\Automated QA\TestComplete 7\Bin\TestComplete.exe " "D:\Test Complete7 Projects\ProjectInput_AllSamples\ProjecInputs.pjs" /r /p:Samples /rt:Main "iexplore" /e
It will open testcomplete and iexplorer ,but it is not filling the data(automation).
It is working perfectly when we directly call the bat file with out jenkins.Is there any solution
From your description it sounds like something in Windows stopping you from allowing your test application to work normally. It might be the fact that the second user could be a problem but I can't confirm that as I was not able find any definite explanations of how it works in Windows XP. I am pretty sure that this won't work on a Windows Vista, 7, 8 or server machine though because of the changes in architecture.
It sounds like the best solution is to make sure that your automated UI tests are started by an interactive user. When I was trying to add automated testing to our builds we used TestComplete 7 on a Windows XP SP2 virtual machine. In order to start our tests as an interactive user we:
Made an user log on when windows started, this way there was always an interactive user which means there was an actual desktop session which has access to the keyboard / mouse. I seem to remember (but can't find any links at the moment) that without an interactive user there is no active desktop that can access the keyboard / mouse.
We wrote a little app that would start when the interactive user logged on. This app would look at a specific file and when that file changed / was created it would read the file and start the application. The code for this app looked somewhat like this:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ApplicationStarter
{
class Program
{
// The string used to indicate that the application should quit.
private const string ExitString = "exit";
// The path which is being watched for changes.
private static string s_LoadFilePath;
static void Main(string[] args)
{
try
{
{
Debug.Assert(
args != null,
"The arguments array should not be null.");
Debug.Assert(
args.Length == 1,
"There should only be one argument.");
}
s_LoadFilePath = args[0];
{
Console.WriteLine(
string.Format(
CultureInfo.InvariantCulture,
"Watching: {0}",
s_LoadFilePath));
}
if (File.Exists(s_LoadFilePath))
{
RunApplication(s_LoadFilePath);
}
using (var watcher = new FileSystemWatcher())
{
watcher.IncludeSubdirectories = false;
watcher.NotifyFilter =
NotifyFilters.LastAccess
| NotifyFilters.LastWrite
| NotifyFilters.FileName
| NotifyFilters.DirectoryName;
watcher.Path = Path.GetDirectoryName(s_LoadFilePath);
watcher.Filter = Path.GetFileName(s_LoadFilePath);
try
{
watcher.Created += OnConfigFileCreate;
watcher.EnableRaisingEvents = true;
// Now just sit here and wait until hell freezes over
// or until the user tells us that it has
string line = string.Empty;
while (!string.Equals(line, ExitString, StringComparison.OrdinalIgnoreCase))
{
line = Console.ReadLine();
}
}
finally
{
watcher.Created -= OnConfigFileCreate;
}
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
private static void RunApplication(string configFilePath)
{
var appPath = string.Empty;
var arguments = string.Empty;
using (var reader = new StreamReader(configFilePath, Encoding.UTF8))
{
appPath = reader.ReadLine();
arguments = reader.ReadLine();
}
// Run the application
StartProcess(appPath, arguments);
}
private static void StartProcess(string path, string arguments)
{
var startInfo = new ProcessStartInfo();
{
startInfo.FileName = path;
startInfo.Arguments = arguments;
startInfo.ErrorDialog = false;
startInfo.UseShellExecute = true;
startInfo.RedirectStandardOutput = false;
startInfo.RedirectStandardError = false;
}
Console.WriteLine(
string.Format(
CultureInfo.InvariantCulture,
"{0} Starting process {1}",
DateTime.Now,
path));
using (var exec = new Process())
{
exec.StartInfo = startInfo;
exec.Start();
}
}
private static void OnConfigFileCreate(
object sender,
FileSystemEventArgs e)
{
Console.WriteLine(
string.Format(
CultureInfo.InvariantCulture,
"{0} File change event ({1}) for: {2}",
DateTime.Now,
e.ChangeType,
e.FullPath));
// See that the file is there. If so then start the app
if (File.Exists(e.FullPath) &&
string.Equals(s_LoadFilePath, e.FullPath, StringComparison.OrdinalIgnoreCase))
{
// Wait for a bit so that the file is no
// longer locked by other processes
Thread.Sleep(500);
// Now run the application
RunApplication(e.FullPath);
}
}
}
}
This app expects the file to have 2 lines, the first with the app you want to start and the second with the arguments, so in your case something like this:
C:\Program Files\Automated QA\TestComplete 7\Bin\TestComplete.exe
"D:\Test Complete7 Projects\ProjectInput_AllSamples\ProjecInputs.pjs" /r /p:Samples /rt:Main "iexplore" /e
You should be able to generate this file from Jenkins in a build step.
Finally you may need to watch the TestComplete process for exit so that you can grab the results at the end but I'll leave that as an exercise to reader.
If you are running Jenkins (either master or slave) as a windows service, ensure it is running as a user and not as Local System.
We also do the same as Gentlesea's recommends, we run TestExecute on our Jenkins Slaves and keepo the TestComplete licenses for the people designing the TestComplete scripts.

EntityClassGenerator : Not generating any output for NorthwindDataService

I am trying to generate the OData Proxy for the service : http://services.odata.org/Northwind/Northwind.svc/$metadata
I am using System.Data.Services.Design.EntityClassGenerator for generating the OData proxy.
When I instantiate the EntityClassGenerator and call GenerateCode the output has no errors. But there is no code in the generated proxy code.
The same code works for my own service. But when I point it to any external service the EntityClassGenerator is not working.
Here is the code :
HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(metadataEndpoint);
webRequest.Method = "GET";
webRequest.ContentType = "text/xml;encoding='utf-8";
webRequest.Proxy = (proxy != null) ? proxy : WebRequest.DefaultWebProxy;
using (WebResponse response = webRequest.GetResponse())
{
string xml = string.Empty;
XmlReaderSettings settings = new XmlReaderSettings();
using (TextReader reader = new StreamReader(response.GetResponseStream()))
{
xml = reader.ReadToEnd();
using (XmlTextReader sourceReader = new XmlTextReader(reader))
{
using (StringWriter targetWriter = new StringWriter())
{
// Generate the OData End point proxy.
EntityClassGenerator entityGenerator = new EntityClassGenerator(LanguageOption.GenerateCSharpCode);
entityGenerator.OnPropertyGenerated += new EventHandler<PropertyGeneratedEventArgs>(entityGenerator_OnPropertyGenerated);
IList<System.Data.Metadata.Edm.EdmSchemaError> errors = entityGenerator.GenerateCode(sourceReader, targetWriter, namespacename);
entityGenerator.OnPropertyGenerated -= new EventHandler<PropertyGeneratedEventArgs>(entityGenerator_OnPropertyGenerated);
odataProxyCode = targetWriter.ToString();
}
}
}
}
I found the code in the question to be a useful starting point for doing exactly what the OP was asking. So even though the OP doesn't accept answers, I'll describe the changes I made to get it to work in case it is useful to someone else.
Removed the xml = reader.ReadToEnd(); call. I assume that was for debugging purposes to look at the response from the web request, but it had the result of "emptying" the reader object of the response. That meant that there was nothing left in the reader for the GenerateCode call.
The important one: Changed the use of EntityClassGenerator to System.Data.Services.Design.EntityClassGenerator. In the code below, I included the entire name space for clarity and specificity. Based on the code in the question, it appears the OP was probably using System.Data.Entity.Design.EntityClassGenerator. I used .NET Reflector to examine datasvcutil.exe, which is a command-line utility that can generate the proxy classes. I saw that it referenced the generator in that other name space.
For figuring out the problems, I dumped the errors from the GenerateCode call. One could examine them in the debugger, but some kind of automated checking of them would be needed regardless.
Here is what I ended up with:
HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.
Create("http://services.odata.org/Northwind/Northwind.svc/$metadata");
webRequest.Method = "GET";
webRequest.ContentType = "text/xml;encoding='utf-8";
webRequest.Proxy = WebRequest.DefaultWebProxy;
using (WebResponse response = webRequest.GetResponse())
{
using (TextReader reader = new StreamReader(response.GetResponseStream()))
{
using (XmlTextReader sourceReader = new XmlTextReader(reader))
{
using (StringWriter targetWriter = new StringWriter())
{
// Generate the OData End point proxy.
System.Data.Services.Design.EntityClassGenerator entityGenerator =
new System.Data.Services.Design.EntityClassGenerator(
System.Data.Services.Design.LanguageOption.GenerateCSharpCode);
IList<System.Data.Metadata.Edm.EdmSchemaError> errors =
entityGenerator.GenerateCode(sourceReader, targetWriter,
"My.Model.Entities");
foreach (System.Data.Metadata.Edm.EdmSchemaError error in errors)
Console.WriteLine("{0}: {1}", error.Severity.ToString(), error.Message);
string odataProxyCode = targetWriter.ToString();
}
}
}
}

Resources