Hello Jim
Sorry, i should have provided more information before.
WebFixture is a class that is part of jWebUnit. I found it in the CVS of jWebUnit under fitplugin
http://cvs.sourceforge.net/viewcvs.py/jwebunit/jWebUnit/fitplugin/src/net/sourceforge/jwebunit/fit/
A co-worker checked it out for me and i built the project.
I am using fitnesse to work with that WebFixture but my logging method(see attachment) tells me,
that the essencially needed call to WebFixture.doCells() is never being executed.
The consequence is, that the first call to WebFixture.baseUrl() throws a nullpointer-exception:
------------------------
java.lang.NullPointerException
at myFixtures.WebFixture.baseUrl(WebFixture.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at fit.ActionFixture.press(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at fit.ActionFixture.doCells(Unknown Source)
at fit.Fixture.doRow(Unknown Source)
at fit.Fixture.doRows(Unknown Source)
at fit.Fixture.doTable(Unknown Source)
at fit.Fixture.doTables(Unknown Source)
at fit.FitServer.process(Unknown Source)
at fit.FitServer.run(Unknown Source)
at fit.FitServer.main(Unknown Source)
-----------------------you can see the call to ActionFixture.doCells this should call WebFixture.doCells() but it doesn't. is that all caused because of a version conflict between fit and fitnesse?
i would really like to use WebFixture because its exactly what i need now and it would be a very comfortable way to write tests.
Robert
Hi Robert,
Can you post the test fixture that is giving you a problem along with the full trace of the exception?
Jim
Jim Weaver Software Developer - ThoughtWorks Office : 615-850-4724 Cell : 312-286-7496
Robert Schipper <[EMAIL PROTECTED] l-it.de> To Sent by: jwebunit mailing list jwebunit-users-ad <[EMAIL PROTECTED] [EMAIL PROTECTED] et> orge.net cc Subject 09/14/2004 06:43 [Fwd: [Fwd: [Jwebunit-users] AM WebFixture doesn't work]]
Hello,
I posted this message some days before and now i really need WebFixture.
Could anyone help me in this case, please? I just don't know what i am doing wrong.
Robert
----- Message from Robert Schipper <[EMAIL PROTECTED]> on Thu, 09 Sep
2004 11:23:11 +0200 -----
To: jwebunit mailing list <[EMAIL PROTECTED]> Subject: [Fwd: [Jwebunit-users] WebFixture doesn't work]
----- Message from Robert Schipper <[EMAIL PROTECTED]> on Wed, 08 Sep
2004 18:06:32 +0200 -----
To: [EMAIL PROTECTED] Subject: [Jwebunit-users] WebFixture doesn't work
hello,
i need some help for using the WebFixture. it seems that the method doCells() is never called which causes a NullpointerException in baseUrl()!
i would be glad if someone could help me, Robert
------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click _______________________________________________ Jwebunit-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jwebunit-users
-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Jwebunit-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users
-- Mit freundlichen Gr��en, Robert Schipper --------------------------------------------------------------- Robert Schipper Trainee Fachinformatiker/Anwendungsentwicklung Controll-IT GmbH mailto:[EMAIL PROTECTED] phone: +494089066476
package net.sourceforge.jwebunit.fit;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import junit.framework.AssertionFailedError;
import net.sourceforge.jwebunit.WebTester;
import net.sourceforge.jwebunit.util.reflect.MethodInvoker;
import fit.ActionFixture;
import fit.Parse;
public class WebFixture extends ActionFixture {
protected static WebTester tester = new WebTester();
public WebFixture() {
logg("Konstructor aufgerufen! \n");
actor = this;
}
public void doCells(Parse cells) {
logg("doCells aufgerufen '"+cells+"'\n");
this.cells = cells;
try {
Method action = getClass().getMethod(camel(cells.text()), empty);
action.invoke(this, empty);
} catch (Exception e) {
exception(cells, e);
}
}
private void logg(String s) {
File f = new File("C:\\fit.log");
if (!f.isFile()) {
try {
f.createNewFile();
} catch (IOException e) {
}
}
try {
FileOutputStream stream = new FileOutputStream(f,true);
for (int i=0;i<s.length();i++)
stream.write(s.charAt(i));
stream.close();
} catch (IOException e) {
}
}
public void ignore() {
ignore(cells);
Parse cell = cells.more;
while (cell != null) {
cell.addToTag(" bgcolor=\"#efefef\"");
cell = cell.more;
}
}
public void ignore(Parse cell) {
cell.addToTag(" bgcolor=\"#efefef\"");
counts.ignores++;
}
public String getBaseUrl() {
return tester.getTestContext().getBaseUrl();
}
public void setBaseUrl(String url) {
tester.getTestContext().setBaseUrl(url);
}
// Actions
public void baseUrl() {
logg("baseUrl aufgerufen.\n");
setBaseUrl(cells.more.text());
}
public void bundle() {
tester.getTestContext().setResourceBundleName(cells.more.text());
}
public void begin() {
tester.beginAt(cells.more.text());
}
public void form() {
tester.setWorkingForm(cells.more.text());
}
public void frame() {
tester.gotoFrame(cells.more.text());
}
public void window() {
tester.gotoWindow(cells.more.text());
}
public void baseWindow() {
tester.gotoRootWindow();
}
public void enter() throws Exception {
tester.setFormElement(cells.more.text(), cells.more.more.text());
}
public void select() {
if (cells.more.text().equals("checkbox")) {
Parse fieldNameCell = cells.more.more;
if(fieldNameCell.more == null)
tester.checkCheckbox(fieldNameCell.text());
else
tester.checkCheckbox(fieldNameCell.text(), fieldNameCell.more.text());
} else if (cells.more.text().equals("option")) {
tester.selectOption(
cells.more.more.text(),
cells.more.more.more.text());
} else {
exception(
cells.more,
new RuntimeException("Unsupported select target"));
}
}
public void deselect() {
if (cells.more.text().equals("checkbox"))
tester.uncheckCheckbox(cells.more.more.text());
else
exception(
cells.more,
new RuntimeException("Unsupported deselection target"));
}
public void submit() {
if (isNotEmpty(cells.more.more))
tester.submit(cells.more.more.text());
else
tester.submit();
}
public void link() {
try {
tester.clickLinkWithText(cells.more.more.text());
} catch (Throwable t) {
if (t instanceof AssertionFailedError) {
markLastArgumentWrong(cells.more.more, 1, t.getMessage());
} else {
exception(cells.last(), t);
}
}
}
public void linkId() {
tester.clickLink(cells.more.more.text());
}
public void check() throws Exception {
String args[] = getArgs(cells.more.more);
try {
getInvoker(args).invoke();
if (isNotEmpty(cells.more.more))
markLastArgumentRight(cells.more.more, args.length);
else
right(cells.more); // for no arg checks
} catch (InvocationTargetException ite) {
Throwable t = ite.getTargetException();
if (t instanceof AssertionFailedError) {
if (isNotEmpty(cells.more.more))
markLastArgumentWrong(
cells.more.more,
args.length,
t.getMessage());
else
wrong(cells.more, t.getMessage()); // for no arg checks
} else {
exception(cells.last(), t);
}
} catch (NoSuchMethodException noMeth) {
exception(cells.more, noMeth);
} catch (Exception e) {
exception(cells.last(), e);
}
}
private MethodInvoker getInvoker(String[] args)
throws NoSuchMethodException {
String baseName = AssertionMap.getAssertionName(cells.more.text());
try {
return getInvoker(this, camel("check " + baseName), args);
} catch (NoSuchMethodException e) {
return getInvoker(tester, camel("assert " + baseName), args);
}
}
private MethodInvoker getInvoker(
Object target,
String methName,
String[] args)
throws NoSuchMethodException {
MethodInvoker invoker;
invoker = new MethodInvoker(target, methName, args);
invoker.getMethod();
return invoker;
}
private void markLastArgumentRight(Parse more, int length) {
right(more.at(length - 1));
}
private void markLastArgumentWrong(
Parse more,
int length,
String message) {
if (message == null)
message = "No message!";
wrong(more.at(length - 1));
more.at(length - 1).addToBody(
label("expected") + "<hr>" + escape(message));
}
private String[] getArgs(Parse cell) {
List args = new ArrayList();
while ((cell != null) && (!cell.text().equals(""))) {
args.add(cell.text());
cell = cell.more;
}
return (String[]) args.toArray(new String[0]);
}
protected boolean isNotEmpty(Parse cell) {
return cell != null && !cell.text().equals("");
}
public void dumpResponse() {
System.err.println("***************begin page***********************");
tester.dumpResponse(System.err);
System.err.println("***************end page*************************");
}
// Checks
public void checkLink(String text) {
tester.assertLinkPresentWithText(text);
}
public void checkLinkId(String anID) {
tester.assertLinkPresent(anID);
}
}
