I have a problem with deploying module. Here is module.epl:
import com.fss.demo.esperevent.*;
#Name('Count-Switched-On')
select count(*) from DemoSimpleEvent1;
and the code
{
DemoSimpleEvent1 demoSimpleEvent1 = new DemoSimpleEvent1();
Configuration config = new Configuration();
config.addEventTypeAutoName("com.fss.demo.esperevent");
EPServiceProvider EpService = EPServiceProviderManager.getDefaultProvider(config);
EPDeploymentAdmin deployAdmin = EpService.getEPAdministrator().getDeploymentAdmin();
MyListener myListener = new MyListener();
try {
Module module = deployAdmin.read(new File("module.epl"));
DeploymentResult MyResult = deployAdmin.deploy(module, new DeploymentOptions());
EPStatement Stta = EpService.getEPAdministrator().getStatement("Count-Switched-On");
} catch (IOException | ParseException | DeploymentException e) {
e.printStackTrace();
}
}
}
but Stta is null,and MyResult.statement does not contain any statement.
So what am I doing wrong?
It looks allright, maybe the code is reading the wrong file?
Perhaps pack it up into a complete test class and send it to the Esper user mailing list.
I think I figured out the problem.
The problem here is version of library antlr-runtime.jar
With esper 4.11.0.jar, should use antlr-runtime-3.2.jar
Related
I tryed to write a groovy script with extened choice parameter:
import jcifs.smb.*
try {
def source = "smb://192.168.1.xx/build/"
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("mydc", "jenkins", "*****");
def dir = new SmbFile(source, auth)
// def dir = new SmbFile(source)
def files = dir.listFiles()
return ["xx"]
def list = []
for (SmbFile f : files)
{
list << f.getName()
}
list << "xx"
return list
} catch (Exception e1) {
return [e1.getMessage()]
}
but then I get the exception:
Failed to connect: 0.0.0.0<00>/192.168.1.xx .
I have open the server's smb1 support.
How can I list the smb folder or file with jenkins parameter choice?
I find the solution my self:
import groovy.io.FileType
try {
def source = "\\\\192.168.xx.xx\\xx\\xx"
def dir = new File(source)
def list = []
dir.eachFile(FileType.DIRECTORIES) {
list << it.name
}
return list
} catch (Exception e1) {
return [e1.getMessage()]
}
maybe I have saw the answer some place, but my java is so poor, I didn't understand. I tried many times to get the solution.
I have an issue to run this service in my client
but when I console.log before the request it was fine
here is the code :
import 'package:grpc/grpc.dart';
import 'package:rpc/src/generated/blog.pb.dart';
import 'package:rpc/src/generated/blog.pbgrpc.dart';
Future<void> main() async {
final channel = ClientChannel(
'localhost',
port: 50051,
options: const ChannelOptions(credentials: ChannelCredentials.insecure()),
);
var stub = BlogServiceClient(channel);
// final name = args.isNotEmpty ? args[0] : 'world';
try {
var bg = Blog();
bg.authorId = "name";
bg.title = "LOL";
bg.content = "Content here";
var data = CreateBlogRequest();
data.blog = bg;
print(data);
await stub.createBlog(data);
// print(gotIt.);
} catch (er) {
print('something error yeahh ===> $er');
}
await channel.shutdown();
}
blog.proto ::
syntax = "proto3";
package blog;
//option go_package="blogpb";
message Blog {
string id = 1;
string author_id = 2;
string title = 3;
string content = 4;
}
message CreateBlogRequest {
Blog blog = 1;
}
message CreateBlogResponse {
Blog blog = 1;
}
message ReadBlogRequest {
string blog_id = 1;
}
message ReadBlogResponse {
Blog blog = 1;
}
message UpdateBlogRequest {
Blog blog = 1;
}
message UpdateBlogResponse {
Blog blog = 1;
}
service BlogService {
rpc CreateBlog (CreateBlogRequest) returns (CreateBlogResponse);
rpc ReadBlog (ReadBlogRequest) returns (ReadBlogResponse);
rpc UpdateBlog (UpdateBlogRequest) returns (UpdateBlogResponse);
}
what I got is gRPC Error (12, unknown service blog.BlogService)
I think I already change port and command options also, but still doesn't work
and the same result
what I expect it I create the blog with that service createBlog
i run the server on Go
I really need to know this badly what's wrong,
I think dart developer not too many because it hards for me to find info about this out on the internet there,
so I came here to ask, and hope grpc Dart team will help some developers about some issues, I have seen on the GitHub issue on grpc-dart, not many the team answer some issues on grpc-dart
i gave wrong package name on .proto file
it was not same like service BlogService {}
my package name was named package something , after i changed tp package blog
it was work well
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.
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
I have the included grails script that I found in some random place on the internet and it works pretty well for firing up scripts in a bootstrapped grails env. The only thing it doesn't seem to do is kick off my conf/*Bootstrap.groovy scripts like when I do run-app.
Is there another function like loadApp() and configureApp() that will do that for me?
import org.codehaus.groovy.grails.support.PersistenceContextInterceptor
Ant.property(environment: "env")
grailsHome = Ant.antProject.properties."env.GRAILS_HOME"
includeTargets << new File("${grailsHome}/scripts/Bootstrap.groovy")
target('default': "Runs scripts in the test/local directory") {
if (!args) { throw new RuntimeException("[fail] This script requires an argument - the script to run.") }
depends(configureProxy, packageApp, classpath)
classLoader = new URLClassLoader([classesDir.toURI().toURL()] as URL[], rootLoader)
Thread.currentThread().setContextClassLoader(classLoader)
loadApp()
configureApp()
def interceptor = null
def beanNames = appCtx.getBeanNamesForType(PersistenceContextInterceptor)
if (beanNames && beanNames.size() == 1) {
interceptor = appCtx.getBean(beanNames[0])
}
try {
interceptor?.init()
new GroovyScriptEngine(Ant.antProject.properties."base.dir", classLoader).run("scripts/${args}.groovy", new Binding(['appCtx':appCtx]))
interceptor?.flush()
} catch (Exception e) {
e.printStackTrace()
interceptor?.clear()
} finally {
interceptor?.destroy()
}
}
Yes, try
new BootStrap().init()