I need to set classpath property in fitnesse slim. I have set as
!define CLASSPATH_PROPERTY {my-fitnesse-path}
!path ${CLASSPATH_PROPERTY}/fitnesse-20080812.jar
But it is not getting applied. Where and how should I set this CLASSPATH_PROPERTY?
Where to set 'CLASSPATH_PROPERTY?
!define CLASSPATH_PROPERTY {A_SELF_DEFINED_PROPERTY_NAME}
This is correct syntax to set it. You can set it anywhere before the test, either on the same page or on its parent page.
But I do have a feeling that you understand the usage of CLASSPATH_PROPERTY wrongly.
CLASSPATH_PROPERTY specifies the name of the environment variable into which the classpath (gathered from !path statements) will be placed before running the test. This is most commonly used when the size of the classpath is too large for certain inept operating systems to deal with. Instead of specifying the %p argument of the COMMAND_PATTERN, you can instead !define CLASSPATH_PROPERTY {CLASSPATH}. This is most useful for Java. For other languages it may not have much meaning.
Fitnesse use java -cp %p %m to launch a test. When CLASSPATH_PROPERTY is defined, whatever paths gathered from !path will be concated and placed into CLASSPATH_PROPERTY first and replace %p in the test launch command.
When this property is not defined, definitions from !path will be placed into %p directly. In fact, most of the time, this CLASSPATH_PROPERTY is not needed, unless you have a very very long classpath (or too many of them), as mentioned above.
I guess you just want to define classpath for your test. Just leave CLASSPATH_PROPERTY first, and put the full path into a !path statement first.
You should define the full class path using !path on your root page. so all the sub wiki's will use the same. Look at http://www.fitnesse.org/FitNesse.FullReferenceGuide.UserGuide.WritingAcceptanceTests.ClassPath for more info on it.
However if you want to mavenize your project, its a good idea to use maven-classpath-plugin and you define all your dependencies like in your case if you want to have specific fitnesse version under your classpath you define it as a dependency, that's all. On your root page this time instead of declaring 100 dependencies simply use !pomFile pom.xml and rest will be taken care by the plug-in. see https://github.com/amolenaar/fitnesse-maven-classpath for more info.
An example pom.xml might look something like below
<dependency>
<groupId>org.fitnesse</groupId>
<artifactId>fitnesse</artifactId>
<version>20150814</version>
</dependency>
.
.
<dependency>
<groupId>org.fitnesse.plugins</groupId>
<artifactId>maven-classpath-plugin</artifactId>
<version>1.6</version>
<!-- <scope>runtime</scope> -->
</dependency>
You can also use fitnesse launcher maven plug-in as well, which works great from my experience when you are working in a CI environment. Check http://fitnesse-launcher-maven-plugin.googlecode.com/svn/maven/site/fitnesse-launcher-maven-plugin/config.html for more info.
Related
was wondering if it is possible to allow global variables like ${PAGE_NAME} be a part of an include?
We have different teams using different feature environments (and more environments coming up) which uses symlinks and includes to environment setup pages. At the moment we're copying everytime the literal path. It is less error prone when we can use the global variables FitNesse has to offer.
For example a simple setup:
root
.Env
.FEAT1 --> connection details to setup/connect env 1.
.FEAT2 --> connection details to setup/connect env 2.
.FEAT300 --> connection details to setup/connect env 300.
.Team1
.FEAT2 --> uses !include -seamless .Env.FEAT2 and uses a symlink to suiteX
.Team10
.FEAT300 --> uses !include -seamless .Env.FEAT300 and uses symlinks to suiteX, suiteB and suiteC
etc
When using include -seamless .Env.${PAGE_NAME} it does not load the include. Preferably we want to use the variables FitNesse offers, but I'm sure we are doing something wrong or using the wrong syntax.
Any suggestions on how to use the global variables in a way we try to achieve?
I tried an other solution by defining the whole include into a variable, but that has unfortunately the same result:
!define includes {!include -seamless .Env.${PAGE_NAME} }
$includes
Writing down the global var itself resolves as expected.
I have an ant script which has a taskdef and the task creates an https internet connection and somethin with that SSL stuff is wrong. Thus I want to set the system property javax.net.debug=all to get some more information.
In java I would do this using the -D option, but in ant this is used for ant properties which is not the same as a system property.
If this wouldn't be a taskdef but instead a java task, I could use the sysproperty property, but it is no java-task.
Googling for this is frustratingly complicated because ant properties and system properties in ant are so similar that most search results are about the other (or about the java-task).
Obviously I am not the only one with the problem, but other people's questions that I have found (like here) are unanswered or went for hack (like here).
One way to set such a property is the ANT_OPTS system variable. You have to be very carefully to not simply skim over answers on google that state that options can be set that way, because it sounds so much like not what it does:
The documentation says:
ANT_OPTS - command-line arguments that should be passed to the JVM.
For example, you can define system properties or set the maximum Java
heap size here.
Who what have expected that? ANT_OPTS are options for the JVM and not for ant like the name suggests. The var which is used for ant options is called ANT_ARGS.
Now I can launch ant like this: ANT_OPTS="-Djavax.net.debug=all" ant myTarget and can see tons of log output.
(However this leaves the question open whether such a variable can be set using XML).
You can declare system properties in the xml with <sysproperty key="key" value="value"/>.
http://www.java2s.com/Code/Java/Ant/SetsystempropertiesinAntbuildscript.htm
You can use scripting:
<script language="javascript">
java.lang.System.setProperty('myKey', 'myValue');
</script>
When trying to compile a Javadoc taglet, which requires $JAVA_HOME/lib/tools.jar, I discovered that ant (version 1.8.4) sets java.home to $JAVA_HOME/jre rather than just $JAVA_HOME. I verified this thusly:
<echo>${java.home}</echo>
<echo>${env.JAVA_HOME}</echo>
[echo] /usr/java/jdk1.7.0_21/jre
[echo] /usr/java/jdk1.7.0_21
According to ant -diagnostics, there isn't any property like a jdk.home. Thus, to use tools.jar I have to do:
<classpath location="${java.home}/../lib/tools.jar"/>
So, I have two questions:
1) Is there something wrong with my setup of ant that's causing java.home to point to the JRE instead of the JDK?
2) If this is the way ant is supposed to work, is using the .. in my classpath the way I'm supposed to do things? Or should I do ${env.JAVA_HOME}/lib/tools.jar? Or something else entirely?
Here are the answers:
"Is there something wrong with my setup ...?" No. Ant is setting it's internal java.home based on JVM System properties. The code for HotSpot (JVM internals) sets it with "/jre" appended on purpose. In fact, the Java(TM) Tutorials for System Properties describes it exactly that way. The "java.home" variable from inside ant really isn't one-in-the-same as the "JAVA_HOME" that is set in your environment -- different but with similar names.
"(What is) the way I'm supposed to do things?" You can really do whatever you feel is appropriate, but remember that Ant can and usually does run in a separate JVM process. I'd assume that your system environment is probably specifying the JVM that was used to develop the app, so I would just use "${env.JAVA_HOME}" to ensure that development expectations meet build expectations.
For more information, please see another similar answer here.
Also, consider that more info can be collected from ant by running it with the -debug, -diagnostics and/or -verbose flags.
Had the same problem. I found that adding fork="true" to the javac tag solves this issue. So do something like this:
<javac target="1.7" source="1.7" fork="true" ...>
I will thank whoever can explain why this works.
I'm having trouble getting FitNesse to play nice with jmockit.
I'm using version v20110104 of FitNesse and version 0.999.9 of jmockit.
I had some ClassDefNotFound exceptions being thrown, but those were solved by adding the following to my FitNesse root:
!define COMMAND_PATTERN {java -javaagent:../lib/jmockit.jar}
Which is the location of my jmockit jar. However, now my tests that use jmockit hang in the "running" state, never to return.
I asked around on some FitNesse boards, and tried altering the command pattern like so:
!define COMMAND_PATTERN {java -javaagent:../lib/jmockit.jar -cp %p %m}
This defines the classpath (%p represents all defined path variables and %m represents the main java method)
This prevents the test from hanging, but I get a new exception:
java.lang.IllegalStateException: Invalid context for the recording of expectations
I can't find much information about this exception.
Has anyone gotten the latest release of jmockit to work with FitNesse?
This link may help you: http://tech.dir.groups.yahoo.com/group/fitnesse/message/17815
Are you using jmockit inside the fixtures, or how? What purpose? I'm just curious, had never needed to mock anything in my acceptance tests.
I Have a property file which contains list of jars from different paths like this
/gwt/X/2.1.0/gwt-servlet.jar
/gwt/X/2.1.0/gwt-user.jar
/gwt/X/2.1.0/gwt-dev.jar
/gwt/X/2.1.0/gwt-soyc-vis.jar
/log4j/X/1.2.15/log4j-1.2.15.jar
/GWT_LOG/X/3.0.3/gwt-log-3.0.3.jar
/GWT_MATH/X/2.1/gwt-math-2.1.jar
/GWT_MATH/X/2.1/gwt-math-server-2.1.jar
/GWT_Commons_Logging/X/0.3/GWT-commons-logging/gwt-commons-logging-0.3.jar
/GWT_Commons_Logging/X/0.3/GWT-commons-logging/gwt-commons-logging-service-0.3.jar
I have around 1000 jars like this in this list.
I would like to remove relative paths before jar name and out put jar names in a new file some thing like this
gwt-servlet.jar
gwt-user.jar
gwt-dev.jar
gwt-soyc-vis.jar
log4j-1.2.15.jar
gwt-log-3.0.3.jar
gwt-math-2.1.jar
gwt-math-server-2.1.jar
gwt-commons-logging-0.3.jar
gwt-commons-logging-service-0.3.jar
This is not a one time activity, so i would like to create a target or task in My build.xml for daily usage.
<replaceregexp file="file.txt" match="[^ ]*/" replace="" byline="true" flags="g"/>
Ant isn't well suited for tasks like this. It's probably much more simple to write a simple Ant Task in Java for that (or a small Java program; just create File objects and invoke getName() to get the last path element).
But if you have to: script and scriptdef are probably your friends (provided that your version of Ant is recent enough; the docs mention 1.6.3). You can call any Java method from these scripts. See the manual for examples.