package com.exedio.copernica;

import net.sourceforge.jwebunit.WebTestCase;

public class WebTest extends WebTestCase
{

	public WebTest(String name)
	{
		super(name);
	}

	String someNotNullString;
	String someNotNullInteger;

	public void setUp() throws Exception
	{
		super.setUp();
		getTestContext().setBaseUrl("http://localhost:8080/copernicatest/");
		someNotNullString = "running100";
		someNotNullInteger = "107";
	}
	
	private void assertItemForm()
	{
		assertFormElementEquals("someNotNullString", someNotNullString);
		assertFormElementEquals("someNotNullInteger", someNotNullInteger);
	}

	public void testSearch()
	{
		beginAt("copernica.jsp");
		assertTitleEquals("Copernica");
		assertLinkPresentWithText("de");

		clickLinkWithText("Attribute Item");
		assertTitleEquals("Attribute Item");
		assertTextPresent("Attribute Item");
		
		assertLinkPresentWithText("50");
		clickLinkWithText("50");
		assertTitleEquals("Attribute Item");
		assertLinkNotPresentWithText("50");

		clickLinkWithText("[X]");
		assertTitleEquals("AttributeItem.103");
		assertItemForm();

		setFormElement("someNotNullString", "running100changed"); someNotNullString = "running100changed";
		submit("SAVE");
		assertTitleEquals("AttributeItem.103");
		assertItemForm();

		setFormElement("someNotNullInteger", "1077"); someNotNullInteger = "1077";
		submit("SAVE");
		assertTitleEquals("AttributeItem.103");
		assertItemForm();

		setFormElement("someNotNullString", "running100"); someNotNullString = "running100";
		setFormElement("someNotNullInteger", "107"); someNotNullInteger = "107";
		submit("SAVE");
		assertTitleEquals("AttributeItem.103");
		assertItemForm();
	}
}

@@ -219,16 +219,37 @@
 Integer;
+%0A%09String someBoolean;
 %0A%0A%09publi
@@ -437,16 +437,40 @@
  %22107%22;%0A
+%09%09someBoolean = %22NULL%22;%0A
 %09%7D%0A%09%0A%09pr
@@ -567,16 +567,16 @@
 tring);%0A
-
 %09%09assert
@@ -636,16 +636,71 @@
 teger);%0A
+%09%09assertFormElementEquals(%22someBoolean%22, someBoolean);%0A
 %09%7D%0A%0A%09pub
@@ -1505,32 +1505,176 @@
 ertItemForm();%0A%0A
+%09%09setFormElement(%22someBoolean%22, %22TRUE%22); someBoolean = %22TRUE%22;%0A%09%09submit(%22SAVE%22);%0A%09%09assertTitleEquals(%22AttributeItem.103%22);%0A%09%09assertItemForm();%0A%0A
 %09%09setFormElement
@@ -1815,24 +1815,87 @@
 er = %22107%22;%0A
+%09%09setFormElement(%22someBoolean%22, %22NULL%22); someBoolean = %22NULL%22;%0A
 %09%09submit(%22SA

set someBoolean