is there any scriptella jruby script sample/example? - scriptella

I am new scriptella user.
Is there any sample or tutorial to use jruby
as scripting language?
Thanks and Regards,
Manish
== updated after ejboy's suggesstions ==
Copied jruby.jar (1.7.4) in lib.
However scriptella failed with following exception.
Jun 14, 2013 9:31:36 AM Script /bigdisk/work/cougar/code/leopard-monitor/analytics/kpoint_usage/scriptella/scripts/jruby_sample.xml execution failed.
/etl/script[1] failed: keySet
Location: /etl/script[1]
Jun 14, 2013 9:31:36 AM <SEVERE> Scriptella bug report. Submit to issue tracker.
Scriptella version: 1.1
Exception:
scriptella.execution.EtlExecutorException: /etl/script[1] failed: keySet Location: /etl/script[1]
at scriptella.execution.EtlExecutor.execute(EtlExecutor.java:190)
at scriptella.tools.launcher.EtlLauncher.execute(EtlLauncher.java:276)
at scriptella.tools.launcher.EtlLauncher.launch(EtlLauncher.java:193)
at scriptella.tools.launcher.EtlLauncher.main(EtlLauncher.java:321)
Caused by: scriptella.core.ExceptionInterceptor$ExecutionException: /etl/script[1] failed: keySet
at scriptella.core.ExceptionInterceptor.execute(ExceptionInterceptor.java:44)
at scriptella.core.Session.execute(Session.java:103)
at scriptella.execution.EtlExecutor.execute(EtlExecutor.java:227)
at scriptella.execution.EtlExecutor.execute(EtlExecutor.java:183)
... 3 more
Following is my xml file.
<!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
<etl>
<description>
use jruby as scripting language.
</description>
<connection id="script-jruby" driver="script" url="out/test-out.csv"> <!-- classpath="path/to/jar:path/to/jar2"> -->
language=jruby
</connection>
<script connection-id="script-jruby">
puts "Hello world - using jruby"
</script>
</etl>

Try setting the language property to jruby and make sure the required jars are available on classpath. You can either copy them to <scriptella_home>/lib directory or include in the connection declaration:
<connection id="script" driver="script" classpath="path/to/jar:path/to/jar2">
language=jruby
</connection>

Related

Remove first line comment in properties file in Ant 1.7.1

I have the following properties file - data.ini with the content :
A=1
B=2
C=3
D=4
I run the following code using Ant 1.7.1
<propertyfile file="data.ini">
<entry key="C" value="5" />
</propertyfile>
and get the following output in data.ini:
#Mon Jan 05 14:21:53 IST 2015
A=1
B=2
C=5
D=4
I do not want the first line - #Mon Jan 05 14:21:53 IST 2015 to be added to the properties file when I run the code.
How do I avoid it?
Since you have mention ini file, I would suggest you to take a take a look at
Removing comment in ini file writen by ant when updating the ini file

ANT-Task for FlexUnit for AIR Mobile project in Jenkins

I am building a Mobile application with Flex 4.11.0 and AIR 4.0. My IDE is Flash Builder 4.7. I wrote a lot of unit tests, some of them using AIR features such as File system access.
I am trying to integrate the project into a CI job on jenkins. I have an ANT script doing the following:
Compiling
Packaging for Android
Packaging for iOS
Generating ASDOC
What I want now is to write an ANT-Task to launch my unit tests and generate a report in XML or HTML which can be parsed by Jenkins afterwards.
I have tried the following:
- Followed the tutorial on http://tutorials.digitalprimates.net/flexunit/Unit-16.html and got the example to work. However, this is a Flash project and not an AIR-Project!
- Read the documentation on https://cwiki.apache.org/confluence/display/FLEX/FlexUnit+Ant+Task, downloaded and built the FlexUnit code from git#github.com:flexunit/flexunit.git to get the FlexUnit4AIRCIListener.swc
- Read a LOT of information on the internet from all over the place, not finding an answer (I did find some hints, but a lot of the information is outdated or references dead links)
What I have so far is the following:
<taskdef resource="flexUnitTasks.tasks" classpath="${basedir}\libs\flexUnitTasks-4.1.0.jar" />
<target name="test" >
<echo>Testing...</echo>
<echo>==========</echo>
<!-- 1. Compile FlexUnit-Application -->
<mxmlc file="${PROJECT.src}\FlexUnit.mxml" output="FlexUnit.swf" >
<load-config filename="D:\tools\sdk\flex\4.11.0_AIR4.0\frameworks\air-config.xml" append="true" />
<source-path path-element="${PROJECT.src}" />
<source-path path-element="${basedir}\test" />
<library-path dir="${PROJECT.libs}" append="true">
<include name="**/*.swc" />
<include name="**/*.ane" />
</library-path>
<library-path dir="D:\tools\sdk\flex\4.11.0_AIR4.0\frameworks\libs\air" append="true">
<include name="airglobal.swc" />
</library-path>
<compiler.verbose-stacktraces>true</compiler.verbose-stacktraces>
<compiler.headless-server>true</compiler.headless-server>
</mxmlc>
<!-- 2. Run the compiled SWF -->
<flexunit swf="FlexUnit.swf"
player="air"
timeout="180000"
toDir="${OUTPUT.root}\flexUnit"
haltonfailure="false"
verbose="true"
localTrusted="true"
/>
<!-- 3. Generate readable JUnit-style reports -->
<junitreport todir="${OUTPUT.root}\flexUnit">
<fileset dir="${OUTPUT.root}\flexUnit">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${OUTPUT.root}\flexUnit\html" />
</junitreport>
</target>
Here are the relevant parts of my FlexUnit.mxml-Application:
protected function onCreationComplete(event:FlexEvent):void
{
core = new FlexUnitCore();
core.addListener(new AirCIListener());
core.run(currentRunTestSuite());
}
public function currentRunTestSuite():Array
{
var testsToRun:Array = new Array();
testsToRun.push(test.suites.CLXSatelliteTestSuite);
return testsToRun;
}
Step 1. from the ANT-Task works (at least I get the FlexUnit.swf). However, Launching the SWF in the <flexunit>-Task fails:
VerifyError: Error #1014: Class flash.filesystem::File could not be found.
Console output:
[flexunit] Generating default values ...
[flexunit] Using default working dir [D:\workspaces\flex\projects\clx-satellite]
[flexunit] Using the following settings for the test run:
[flexunit] FLEX_HOME: [D:\tools\sdk\flex\4.11.0_AIR4.0]
[flexunit] haltonfailure: [false]
[flexunit] headless: [false]
[flexunit] display: [99]
[flexunit] localTrusted: [true]
[flexunit] player: [flash]
[flexunit] port: [1024]
[flexunit] swf: [D:\workspaces\flex\projects\clx-satellite\FlexUnit.swf]
[flexunit] timeout: [180000ms]
[flexunit] toDir: [D:\workspaces\flex\projects\clx-satellite\deploy\flexUnit]
[flexunit] Setting up server process ...
[flexunit] Starting server ...
[flexunit] Opening server socket on port [1024].
[flexunit] Waiting for client connection ...
[flexunit] OS: [Windows]
[flexunit] Launching player:
[flexunit] Executing 'rundll32' with arguments:
[flexunit] 'url.dll,FileProtocolHandler'
[flexunit] 'D:\workspaces\flex\projects\clx-satellite\FlexUnit.swf'
[flexunit] The ' characters around the executable and arguments are
[flexunit] not part of the command.
[flexunit] Client connected.
[flexunit] Setting inbound buffer size to [262144] bytes.
[flexunit] Receiving data ...
[flexunit] Sending acknowledgement to player to start sending test data ...
[flexunit]
[flexunit] Stopping server ...
[flexunit] End of test data reached, sending acknowledgement to player ...
BUILD FAILED
D:\workspaces\flex\projects\clx-satellite\build.xml:148:
java.util.concurrent.ExecutionException: could not close client/server socket
When I include a single test which does not use the File-Class, the tests work and I get a similar error (ReferenceError: Error #1065: Variable flash.desktop::NativeApplication is not defined.) but at least the tests run through and I get XML-output. Seems to me like FlexUnit is not really compatible with AIR, although I use player=airin the task.
Does anybody of you have a working example of running Unit Tests with FlexUnit for an AIR Application (possibly a mobile application) through ANT?
Never mind, I figured it out myself and blogged about it in my personal blog:
http://www.tiefenauer.info/ci-for-flex-mobile-applications-part-3-performing-unit-tests/
I described a whole CI process there, just in case anyone has the same problem.
There is Apache FlexUnit feature request for this here: Apache FlexUnit: FLEX-35090
Or you can utilize this feature by compiling your own FlexUnit task by using this fork of FlexUnit 4.1: additionalCompilerOptions branch
The formatting supported with the custom FlexUnit Ant Task is as follows:
<flexunit
workingDir="${bin.loc}"
toDir="${report.loc}"
haltonfailure="false"
verbose="true"
localTrusted="true" >
<!-- only supported with custom FlexUnit Ant tasks -->
<additionalCompilerOption option="-define+=MY_CONST::foo,'BAR'" />
</flexunit>

How can I remove a line with Ant replaceregexp, but not leave an empty line

I have the following text file:
Manifest-Version: 3.0.0
Ant-Version: Apache Ant 1.7.1
Created-By: 10.0-b19 (Sun Microsystems Inc.)
Require-Bundle: org.eclipse.linuxtools.cdt.libhover;bundle-version="1.
1.0"
Bundle-SymbolicName: com.qnx.doc.gestures.lib_ref
Bundle-Version: 3.0.0.20121120
Bundle-Localization: plugin
Bundle-Name: %plugin.name
Bundle-Vendor: %plugin.providername
And I'm trying to use the following pattern in a replaceregexp task
regexp pattern='Require-Bundle: org.eclipse.linuxtools.cdt.libhover;bundle-version="1.
[\s\S]*'
To end up with this:
Manifest-Version: 3.0.0
Ant-Version: Apache Ant 1.7.1
Created-By: 10.0-b19 (Sun Microsystems Inc.)
1.0"
Bundle-SymbolicName: com.qnx.doc.gestures.lib_ref
Bundle-Version: 3.0.0.20121120
Bundle-Localization: plugin
Bundle-Name: %plugin.name
Bundle-Vendor: %plugin.providername
The trouble is I keep getting this:
Manifest-Version: 3.0.0
Ant-Version: Apache Ant 1.7.1
Created-By: 10.0-b19 (Sun Microsystems Inc.)
1.0"
Bundle-SymbolicName: com.qnx.doc.gestures.lib_ref
Bundle-Version: 3.0.0.20121120
Bundle-Localization: plugin
Bundle-Name: %plugin.name
Bundle-Vendor: %plugin.providername
What should my regex be to get rid of the empty line?
Thanks.
Something like this should work:
Require-Bundle: org\.eclipse\.linuxtools\.cdt\.libhover;bundle-version="1\.\s*1.0"\s*
(using \s* to match zero or more whitespace characters, which include \r and \n) but since you're dealing with a manifest file it would make more sense to use a proper manifest parser. Unfortunately the Ant <manifest> task doesn't provide a way to remove attributes, but it's pretty straightforward with a <script> task:
<property name="manifest.file" location="path/to/manifest.txt" />
<script language="javascript"><![CDATA[
importPackage(java.io);
importPackage(java.util.jar);
// read the manifest
manifestFile = new File(project.getProperty('manifest.file'));
manifest = new Manifest();
is = new FileInputStream(manifestFile);
manifest.read(is);
is.close();
// remove the offending attribute
manifest.getMainAttributes().remove(new Attributes.Name('Require-Bundle'));
// write back to the original file
os = new FileOutputStream(manifestFile);
manifest.write(os);
os.close();
]]></script>
<replaceregexp file="manifest.mf" match='Require-Bundle: org.eclipse.linuxtools.cdt.libhover;bundle-version=\"[^\"]+\"[\r\n]*' replace="" flags="m"/>
This works for me.

error message not in development but rather in deployment using NHibernate version 2.1.1.4000

I have had a look at
Unable to load type 'NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle'
I am also having the same error message when running the unit tests after deployment, however my application is running fine. Even during development, I am not having any such error.
What is wrong? Why I am having this error message when running the unit test?
The error message is as follows:
NHibernate.Bytecode.ProxyFactoryFactoryNotConfiguredException : The ProxyFactoryFactory was not configured.
Initialize 'proxyfactory.factory_class' property of the session-factory configuration section with one of the available NHibernate.ByteCode providers.
Example:
NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu
Example:
NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle
]]>
-
-
]]>
Connection string is web.config
> > <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
> <session-factory>
> <property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
> <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
> <property name="connection.connection_string">Server=localhost\SQLServer2005;Database=testDev;</property>
> <property name='proxyfactory.factory_class'>NHibernate.ByteCode.Castle.ProxyFactoryFactory,
> NHibernate.ByteCode.Castle</property>
> </session-factory> </hibernate-configuration>
The dll are:
I have NHIbernate version 2.1.1.4000, and I have NHibernate.ByteCode.Castle version 2.1.1.4000 ,Castle.Core 1.1.0, Castle.DynamicProxy2.dll version 2.1.1.0
Which version of NHibernate are you using? Version 3.2 comes pre-configured with a proxy factory. If you are using this version, you no longer need the proxyfactory.factory_class configuration option.
Also, if your tests are failing but not your app, then maybe the tests are not able to access the right hibernate config file. If you are doing the configuration programmatically, look at it once again to verify the proxy factor is set (if using NH < 3.2) or not set (if using NH >= 3.2) ...

Jaxb binding file being ignored

I having a bit of trouble building JAXB bindings fora set of schemas and its driving me a bit batty. Here is the schema in question (it is just one of may schema in this particular build):
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xml="http://www.w3.org/XML/1998/namespace" targetNamespace="http://www.w3.org/XML/1998/namespace">
<attribute name="lang" type="language">
<annotation>
<documentation>In due course, we should install the relevant ISO 2- and 3-letter
codes as the enumerated possible values . . .</documentation>
</annotation>
</attribute>
<attribute name="space" default="preserve">
<simpleType>
<restriction base="NCName">
<enumeration value="default"/>
<enumeration value="preserve"/>
</restriction>
</simpleType>
</attribute>
<attributeGroup name="specialAttrs">
<attribute ref="xml:lang"/>
<attribute ref="xml:space"/>
</attributeGroup>
xjc is claiming that the attributes declared above are already declared elsewhere:
parsing a schema...
[ERROR] 'lang' is already defined
line 26 of file:../../gml/3.1.1/smil/xml-mod.xsd
[ERROR] (related to above error) the first definition appears here
line 88 of http://www.w3.org/2001/03/xml.xsd
[ERROR] 'space' is already defined
line 34 of file:../../gml/3.1.1/smil/xml-mod.xsd
[ERROR] (related to above error) the first definition appears here
line 95 of http://www.w3.org/2001/03/xml.xsd
[ERROR] 'specialAttrs' is already defined
line 39 of file:../../gml/3.1.1/smil/xml-mod.xsd
[ERROR] (related to above error) the first definition appears here
line 111 of http://www.w3.org/2001/03/xml.xsd
Failed to parse a schema.
Doing a bit of research would lead me to believe that the problem is that I need a binding file to resolve the duplicate attributes....and I have one :
<jaxb:bindings version="1.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jaxb:extensionBindingPrefixes="xjc">
<jaxb:bindings schemaLocation="../../gml/3.1.1/smil/xml-mod.xsd" node="/xs:schema">
<jaxb:bindings node="//xs:attribute[#name='lang']">
<jaxb:property name="langAttribute"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:attribute[#name='space']">
<jaxb:property name="spaceAttribute"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:attributeGroup[#name='specialAttrs']">
<jaxb:property name="specialAttrsAttribute"/>
</jaxb:bindings>
</jaxb:bindings>
Yet the problem persists. The error message with or without the bindings file is the same. I know the file is being used , because if I mess up the xpath for the node selector I get an error message. It's like xjc knows the bindings file is there but ignores it.
Here's the command line that fails to build the bindings:
C:\tools\jaxb-ri-20110512\bin\xjc -episode ..\..\..\common.ogc -d ..\..\..\src -p com.ogc.bindings -b ..\..\..\bindings.xsd -catalog ..\..\..\ogc.cat -extension sosAll.xsd
I have tried this with both the jdk6 native jaxb (2.0) and jaxb 2.2.4 (I installed the jaxb-api.jar in the endorsed directory)
XJC (bundled with JDK), ignores binding file, if the path to the binding file or the XSD / WSDL is too long.
Issue observed and confirmed on Oracle 64 bit JDK 1.6.0.45, on Windows 7 ultimate and on Linux, XJC (bundled with JDK), ignores binding file, if the path to the binding file is too long.
I did NOT have the time to do detail research on the issue; I solved my problem by simply shortening the svn checkout path. It was the most bizarre issue - I could not reproduce the problem on my Windows 8 Laptop and on Linux, but on a Windows 7 workstation, build kept on failing. I identified this issue by confirming that other then path, there is NO difference between Windows 8 LAPTOP, where the build works, vs. Windows 7 Ultimate where the path is a bit long (6 characters -> /trunk).
Problem was solved without any code, configuration, xml schema or binding file change. Posting here so that others who may run into this, have a bit of easier time then me.
i believe this is an issue with namespace collision, you dont have a namespace defined for your schema elements and it seems you are using names for your attributes that are in conflict with the ones defined in xml's schema (xml.xsd)

Resources