Set variable to array in Escape Velocity - arrays

I'm trying to set a variable to an array in Escape Velocity like they do in the documentation:
#set ($my = "blah")
#set ($say = ["not", $my, "fault"])
However, I get the following error:
error: An error occurred in the #AutoProtoModel processor while processing com.google.protobuf.contrib.autoprotomodel.prototype.AlbumModel:
com.google.escapevelocity.ParseException: Expected an expression, on line 46, at text starting: ["not", $my, "fault"...
com.google.escapevelocity.Parser.parseException(Parser.java:1093)
com.google.escapevelocity.Parser.parsePrimary(Parser.java:923)
com.google.escapevelocity.Parser.parseUnaryExpression(Parser.java:890)
com.google.escapevelocity.Parser.parseExpression(Parser.java:797)
com.google.escapevelocity.Parser.parseSet(Parser.java:401)
com.google.escapevelocity.Parser.parseDirective(Parser.java:328)
com.google.escapevelocity.Parser.parseNode(Parser.java:218)
com.google.escapevelocity.Parser.parseTokens(Parser.java:126)
com.google.escapevelocity.Parser.parse(Parser.java:118)
com.google.escapevelocity.Template.parseFrom(Template.java:112)
com.google.escapevelocity.Template.parseFrom(Template.java:94)
com.google.protobuf.contrib.autoprotomodel.prototype.BackingClassGenerator.loadTemplate(BackingClassGenerator.java:97)
...
Why doesn't this work?
Is this a bug in the Escape Velocity project?

It seems that Escape Velocity doesn't support to set Java array (from docs):
Unlike Velocity, EscapeVelocity does not allow $indexme to be a Java array.
Why not using Velocity? EscapeVelocity uses old version 1.7 instead of new 2.0, and you have extra tools for velocity
EscapeVelocity is a templating engine that can be used from Java. It is a reimplementation of a subset of functionality from Apache Velocity.
This is not an official Google product.

Related

Integrating Jmeter With Selenium error is showing

when I Integrating Jmeter With Selenium and run it the error is showing.
anyone please help me .
Thread Name:Thread Group 1-1
Sample Start:2022-03-06 14:01:19 IST
Load time:0
Connect Time:0
Latency:0
Size in bytes:1006
Sent bytes:0
Headers size in bytes:0
Body size in bytes:1006
Sample Count:1
Error Count:1
Data type ("text"|"bin"|""):text
Response code:500
Response message:In file: inline evaluation of: WDS.sampleResult.sampleStart() WDS.browser.get('https://www.facebook.com') WDS.s . . . '' Encountered "WDS" at line 2, column 1. in inline evaluation of: WDS.sampleResult.sampleStart() WDS.browser.get('https://www.facebook.com') WDS.s . . . '' at line number 2
SampleResult fields:
ContentType: text/plain
DataEncoding: UTF-8
Make sure to install Selenium/WebDriver Support package using JMeter Plugins Manager, this way you will get the WebDriver Sampler
Add the configuration element for your browser and provide binary and/or driver details there
Add WebDriver Sampler to your test plan and put your code there
Your error means that you're trying to run your code using Beanshell interpreter and you're using incorrect syntax, i.e.
Strings should be surrounded by double quotation marks
There should be semicolons at the end of every statement
Something like:
WDS.sampleResult.sampleStart();
WDS.browser.get("https://www.facebook.com");
Otherwise check the page where you did get the code and pay attention to the language of the WebDriver Sampler, the default is javascript, the recommended is groovy

SMTPSenderRefused when sending mail from GAE dev_appserver on gmail

Here are my email related dev_appserver options:
--smtp_host=smtp.gmail.com --smtp_port=25 --smtp_user=me#mydomain.com --smtp_password="password"
Now, this still doesn't work and every time Google release a new dev_appserver I have to edit api/mail_stub.py to get things to work locally as per this S/O answer.
However, even this workaround has now stopped working. I get the following exception:
SMTPSenderRefused: (555, '5.5.2 Syntax error. mw9sm14633203wib.0 - gsmtp', <email.header.Header instance at 0x10c9c9248>)
Does anyone smarter than me know how to fix it?
UPDATE
I was able to get email to send on dev_appserver by using email addresses (eg. for sender and recipient) in their 'plain' format of a simple string (name#domain.com) rather than using the angle bracket style (Name <name#domain.com>). This is not a problem in production: recipients and sender email addresses can use angle brackets in the mail.send_mail call. I raised a ticket about this divergent behaviour between dev_appserver and production: https://code.google.com/p/googleappengine/issues/detail?id=10211&thanks=10211&ts=1383140754
Looks like it's because the 'sender' is now stored as a "email.header.Header" instance in the dev server instead of a string (since SDK 1.8.3 I think).
From my testing, when a 'From' string like "Name " is passed into smtplib.SMTP.sendmail, it parses the string to find the part within angle brackets, if any, to use as the SMTP sender, giving "". However, if this parameter is an "email.header.Header", then is just converts to string and uses it without further parsing, giving ">", thus causing the problem we're seeing.
Here's the patch I just posted on the issue tracker to google/appengine/api/mail_stub.py to convert this parameter back to a string (works for me):
--- google/appengine/api/mail_stub-orig.py 2014-12-12 20:04:53.612070031 +0000
+++ google/appengine/api/mail_stub.py 2014-12-12 20:05:07.532294605 +0000
## -215,7 +215,7 ##
tos = [mime_message[to] for to in ['To', 'Cc', 'Bcc'] if mime_message[to]]
- smtp.sendmail(mime_message['From'], tos, mime_message.as_string())
+ smtp.sendmail(str(mime_message['From']), tos, mime_message.as_string())
finally:
smtp.quit()
Another alternative is to patch the SMTP server that you use for testing the app engine mail functionality in your dev environment (instead of patching mail_stub.py).
For example, I'm using subethasmtp Wiser and was able to work around this issue by patching org.subethamail.smtp.util.EmailUtils.extractEmailAddress to accept nested angle brackets (details posted here).

XQuery 3.0 and maps in Saxon

I would like to experiment with map features in Saxon (http://www.saxonica.com/documentation/expressions/xpath30maps.xml), but I am unable to get past query compilation. Maybe I am missing some parameter or I use a wrong namespace, but I just can't find the right answer. This is my query code:
xquery version "3.0";
(: i have also tried http://www.w3.org/2005/xpath-functions/map, no difference :)
import module namespace map = "http://ns.saxonica.com/map";
map:get(map { 1 := 'aaa'}, 1)
invoked from command line:
"c:\Program Files\Saxonica\SaxonEE9.4N\bin\Query.exe" -s:play.xml -q:play2.xq" -qversion:3.0
The commands ends with error Cannot locate module for namespace "http://ns.saxonica.com/map"
When I leave out the module namespace map declaration, the error is Prefix map has not been declared, so I assume it must be.
Michael Kay has just posted a new blog entry with details on the Saxon Map implementation:
http://dev.saxonica.com/blog/mike/2012/01/#000188
You should use declare namespace instead of import module namespace for access to builtin functions. As far as I understand it, module import is for user-supplied modules only.
File map.xq:
declare namespace map="http://www.w3.org/2005/xpath-functions/map";
map:get(map { 1 := 'aaa'}, 1)
Works just fine:
> "C:\Program Files\Saxonica\SaxonEE9.4N\bin\Query.exe" -qversion:3.0 map.xq
<?xml version="1.0" encoding="UTF-8"?>aaa
I tried it with Saxon-EE 9.4.0.2J (the Java version) too, with the same effect.
Dunno if this helps, but the BaseX XQuery Processor also offers an implementation of Michael Kay's map proposal (still to be finalized by the W3): http://docs.basex.org/wiki/Map_Module

ParseException Unknown function termfreq in FunctionQuery

What is the right syntax if my query is formulated incorrectly in the link above for Apache 3.5 SOLR and do I have to enable anything specific in solrconfig.xml and schema.xml
Using Apache SOLR 3.5 and receiving a ParseException Uknown function termfreq in FunctionQuery(tf(text,amplifiers)'
http://localhost:8983/solr/select/?fl=score,documentPageId&defType=func&q=tf%28text,amplifiers%29
I am following the syntax on other websites because I don't know how to do it for the documentation on the wiki --> http://wiki.apache.org/solr/FunctionQuery
It won't work, the function query tf(field, term) that you are attempting to use is not available in 3.5, browse through ValueSourceParser if you want to double-check. You need to get Solr 4.x nightly build - Solr Nightly Build from trunk & use it, but beware Solr 4.x is not stable & released yet, there will be a significant level of API changes compared to 3.5.
If you are interested in poking into the code, you could for instance, if you are using Maven modify pom.xml to get the atrifacts from Trunk and browse the source code starting from ValueSourceParser that should let you know if those relevance functions exist & how their implementation is.
For Ex: You will see parsers related to the term vector function queries,
// From Solr 4 `ValueSourceParser` Trunk Source Code
addParser("tf", new ValueSourceParser() {
#Override
public ValueSource parse(FunctionQParser fp) throws ParseException {
TInfo tinfo = parseTerm(fp);
return new TFValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes);
}
});

Tomcat 7 - Retrieve the version of a webapp (versioned WAR)

I've been unable to find any easy way of figuring out the version string for a WAR file deployed with Tomcat 7 versioned naming (ie app##version.war). You can read about it here and what it enables here.
It'd be nice if there was a somewhat more supported approach other than the usual swiss army knife of reflection powered ribcage cracking:
final ServletContextEvent event ...
final ServletContext applicationContextFacade = event.getServletContext();
final Field applicationContextField = applicationContextFacade.getClass().getDeclaredField("context");
applicationContextField.setAccessible(true);
final Object applicationContext = applicationContextField.get(applicationContextFacade);
final Field standardContextField = applicationContext.getClass().getDeclaredField("context");
standardContextField.setAccessible(true);
final Object standardContext = standardContextField.get(applicationContext);
final Method webappVersion = standardContext.getClass().getMethod("getWebappVersion");
System.err.println("WAR version: " + webappVersion.invoke(standardContext));
I think the simplest solution is using the same version (SVN revision + padding as an example) in .war, web.xml and META-INF/MANIFEST.MF properties files, so you could retrieve the version of these files later in your APP or any standard tool that read version from a JAR/WAR
See MANIFEST.MF version-number
Another solution described here uses the path name on the server of the deployed WAR. You'd extract the version number from the string between the "##" and the "/"
runningVersion = StringUtils.substringBefore(
StringUtils.substringAfter(
servletConfig.getServletContext().getRealPath("/"),
"##"),
"/");
Starting from Tomcat versions 9.0.32, 8.5.52 and 7.0.101, the webapp version is exposed as a ServletContext attribute with the name org.apache.catalina.webappVersion.
Link to the closed enhancement request: https://bz.apache.org/bugzilla/show_bug.cgi?id=64189
The easiest way would be for Tomcat to make the version available via a ServletContext attribute (org.apache.catalina.core.StandardContext.webappVersion) or similar. The patch to do that would be trivial. I'd suggest opening an enhancement request in Tomcat's Bugzilla. If you include a patch then it should get applied fairly quickly.

Resources