Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

minor fixes and cleanup

  • Loading branch information...
commit 409f8990c1c1780e8c7e3ee250cee43ce3fc8202 1 parent b9d1e63
InterCommIT authored
Showing with 1,185 additions and 3 deletions.
  1. +39 −0 src/test/java/nl/intercommit/weaves/TestConfirm.java
  2. +46 −0 src/test/java/nl/intercommit/weaves/TestDropDownMenu.java
  3. +52 −0 src/test/java/nl/intercommit/weaves/TestEditableSelect.java
  4. +39 −0 src/test/java/nl/intercommit/weaves/TestHoverlink.java
  5. +42 −0 src/test/java/nl/intercommit/weaves/TestModalBox.java
  6. +47 −0 src/test/java/nl/intercommit/weaves/TestPagedGrid.java
  7. +46 −0 src/test/java/nl/intercommit/weaves/TestPopupWindow.java
  8. +57 −0 src/test/java/nl/intercommit/weaves/TestSwitch.java
  9. +41 −0 src/test/java/nl/intercommit/weaves/TestTextMarker.java
  10. +33 −0 src/test/java/nl/intercommit/weaves/grid/TestCollectionFilter.java
  11. +117 −0 src/test/java/nl/intercommit/weaves/grid/TestGridSourceFilter.java
  12. +39 −0 src/test/java/nl/intercommit/weaves/test/beans/Box.java
  13. +51 −0 src/test/java/nl/intercommit/weaves/test/entities/Person.java
  14. +23 −0 src/test/java/nl/intercommit/weaves/test/pages/ConfirmPage.java
  15. +74 −0 src/test/java/nl/intercommit/weaves/test/pages/DropDownMenuPage.java
  16. +39 −0 src/test/java/nl/intercommit/weaves/test/pages/EditableSelectPage.java
  17. +33 −0 src/test/java/nl/intercommit/weaves/test/pages/HoverLinkPage.java
  18. +33 −0 src/test/java/nl/intercommit/weaves/test/pages/ModalBoxPage.java
  19. +69 −0 src/test/java/nl/intercommit/weaves/test/pages/PagedGridPage.java
  20. +30 −0 src/test/java/nl/intercommit/weaves/test/pages/PopupWindowPage.java
  21. +36 −0 src/test/java/nl/intercommit/weaves/test/pages/SwitchPage.java
  22. +39 −0 src/test/java/nl/intercommit/weaves/test/pages/TextMarkerPage.java
  23. +48 −0 src/test/java/nl/intercommit/weaves/test/services/WeavesTestModule.java
  24. +43 −0 src/test/java/nl/intercommit/weaves/util/TestHoverlinkStreamResponse.java
  25. +19 −3 src/test/java/util/HibernateUtil.java
  26. +50 −0 src/test/java/util/WeaveTestCase.java
View
39 src/test/java/nl/intercommit/weaves/TestConfirm.java
@@ -0,0 +1,39 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves;
+
+import util.WeaveTestCase;
+
+public class TestConfirm extends WeaveTestCase {
+
+
+ public void testConfirmationPopup() {
+ org.apache.tapestry5.dom.Document dom = getTester().renderPage("ConfirmPage");
+ assertNotNull(dom);
+ assertNull(dom.getElementById("t-error"));
+ assertFalse(dom.toString().contains("<h1 class=\"t-exception-report\">"));
+
+ System.err.println(dom);
+
+ assertNotNull(dom.getElementById("actionlink"));
+ assertTrue(dom.toString().contains("new Confirm('actionlink', 'Are you sure?')"));
+ }
+
+
+}
View
46 src/test/java/nl/intercommit/weaves/TestDropDownMenu.java
@@ -0,0 +1,46 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves;
+
+import util.WeaveTestCase;
+
+public class TestDropDownMenu extends WeaveTestCase {
+
+ public void testEmptyMenu() {
+ org.apache.tapestry5.dom.Document dom = getTester().renderPage("DropDownMenuPage");
+
+ assertNull(dom.getElementById("t-error"));
+ assertNotNull(dom.getElementById("root"));
+
+ assertEquals("<ul id=\"root\" class=\"level1\"></ul>",dom.getElementById("root").toString().trim());
+
+ }
+
+
+ public void testFullMenu() {
+
+ org.apache.tapestry5.dom.Document dom = getTester().renderPage("DropDownMenuPage/full");
+
+ assertNotNull(dom.getElementById("root"));
+
+ assertEquals("<ul id=\"root\" class=\"level1\"><li id=\"none\"><a href=\"/foo/pagedgridpage\"><div style=\"display:inline; margin-right: 5px;\"><img src=\"/images/menu1.png\"/></div>top1</a><ul class=\"level2\"><li><a href=\"/foo/dropdownmenupage\">item1</a></li><li><a href=\"/foo/dropdownmenupage\">item2</a></li></ul></li><li id=\"none\"><a href=\"/foo/switchpage\">top2</a><ul class=\"level2\"><li><a href=\"/foo/dropdownmenupage\">item1</a></li><li><a href=\"/foo/dropdownmenupage\">item2<div class=\"morelevels\"> &gt; </div></a><ul class=\"level3\"><li><a href=\"/foo/dropdownmenupage\">sub1</a></li><li><a href=\"/foo/dropdownmenupage\">sub2</a></li><li><a href=\"/foo/dropdownmenupage\">sub3</a></li></ul></li></ul></li></ul>",dom.getElementById("root").toString());
+
+ }
+
+}
View
52 src/test/java/nl/intercommit/weaves/TestEditableSelect.java
@@ -0,0 +1,52 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tapestry5.internal.test.TestableResponse;
+
+import util.WeaveTestCase;
+
+public class TestEditableSelect extends WeaveTestCase {
+
+
+
+ public void testConfirmationPopup() {
+ org.apache.tapestry5.dom.Document dom = getTester().renderPage("EditableSelectPage");
+ assertNotNull(dom);
+ assertNull(dom.getElementById("t-error"));
+ assertFalse(dom.toString().contains("<h1 class=\"t-exception-report\">"));
+
+ assertNotNull(dom.getElementById("editableselectbox"));
+
+ assertEquals("off",dom.getElementById("editableselectbox").getAttribute("autocomplete"));
+
+ Map<String, String > params = new HashMap<String, String>();
+ params.put(dom.getElementById("editableselectbox").getAttribute("id"), "test");
+
+ TestableResponse resp = getTester().submitFormAndReturnResponse(dom.getElementById("form"),params);
+
+ assertEquals(200,resp.getStatus());
+
+ }
+
+
+}
View
39 src/test/java/nl/intercommit/weaves/TestHoverlink.java
@@ -0,0 +1,39 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves;
+
+import util.WeaveTestCase;
+
+public class TestHoverlink extends WeaveTestCase {
+
+
+
+ public void testHoverLinkComponent() {
+ org.apache.tapestry5.dom.Document dom = getTester().renderPage("HoverlinkPage");
+
+ assertNotNull(dom);
+ assertNotNull(dom.getElementById("hoverlink"));
+
+ assertTrue(dom.getElementById("hoverlink").toString().equals("<a onclick=\"return false;\" class=\"ic_t5-hoverlink\" id=\"hoverlink\" href=\"#\">consectetur</a>"));
+ assertTrue(dom.toString().contains("\"dataURL\":\"http://localhost/foo/hoverlinkpage.hoverlink:retrievecontent\""));
+
+ }
+
+
+}
View
42 src/test/java/nl/intercommit/weaves/TestModalBox.java
@@ -0,0 +1,42 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves;
+
+import util.WeaveTestCase;
+
+public class TestModalBox extends WeaveTestCase {
+
+
+
+
+ public void testModalBox() {
+ org.apache.tapestry5.dom.Document dom = getTester().renderPage("ModalBoxPage");
+
+ System.err.println(dom);
+
+ assertNotNull(dom);
+ assertNull(dom.getElementById("t-error"));
+ assertFalse(dom.toString().contains("<h1 class=\"t-exception-report\">"));
+
+ assertTrue(dom.getElementById("modalbox")!=null);
+
+ }
+
+
+}
View
47 src/test/java/nl/intercommit/weaves/TestPagedGrid.java
@@ -0,0 +1,47 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves;
+
+import org.apache.tapestry5.dom.Element;
+
+import util.WeaveTestCase;
+
+public class TestPagedGrid extends WeaveTestCase {
+
+
+
+
+ public void testPagedGrids() {
+
+ org.apache.tapestry5.dom.Document dom = getTester().renderPage("PagedGridPage");
+
+ assertNotNull(dom);
+
+ Element el = dom.find("html/body/h1");
+ if (el != null) {
+ if (el.getAttribute("class").equals("t-exception-report")) {
+ fail("Tapestry Exception:" + dom);
+ }
+ }
+ }
+
+
+
+
+}
View
46 src/test/java/nl/intercommit/weaves/TestPopupWindow.java
@@ -0,0 +1,46 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves;
+
+import org.apache.tapestry5.dom.Element;
+
+import util.WeaveTestCase;
+
+public class TestPopupWindow extends WeaveTestCase {
+
+
+
+
+ public void testPopupWindow() {
+
+ org.apache.tapestry5.dom.Document dom = getTester().renderPage("PopupWindowPage");
+ Element el = dom.find("html/body/h1");
+ if (el != null) {
+ if (el.getAttribute("class").equals("t-exception-report")) {
+ fail("Tapestry Exception:" + dom);
+ }
+ }
+
+ assertNotNull(dom.getElementById("pw_popupWindowContent"));
+ }
+
+
+
+
+}
View
57 src/test/java/nl/intercommit/weaves/TestSwitch.java
@@ -0,0 +1,57 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves;
+
+import org.apache.tapestry5.dom.Element;
+
+import util.WeaveTestCase;
+
+public class TestSwitch extends WeaveTestCase {
+
+
+
+ public void testSwitchComponent() {
+
+ org.apache.tapestry5.dom.Document dom = getTester().renderPage("SwitchPage/one");
+ assertNotNull(dom.getElementById("switch"));
+ Element el = dom.getElementById("switch");
+ assertEquals("one!",el.getChildMarkup().trim());
+
+
+ dom = getTester().renderPage("SwitchPage/unknown");
+ assertNotNull(dom.getElementById("switch"));
+ el = dom.getElementById("switch");
+ assertEquals("<h1>default</h1>",el.getChildMarkup().trim());
+
+
+ dom = getTester().renderPage("SwitchPage/someother");
+ assertNotNull(dom.getElementById("switch"));
+ el = dom.getElementById("switch");
+ assertEquals("someother...",el.getChildMarkup().trim());
+
+ dom = getTester().renderPage("SwitchPage");
+ assertNotNull(dom.getElementById("switch"));
+ el = dom.getElementById("switch");
+ assertEquals("<h1>default</h1>",el.getChildMarkup().trim());
+ }
+
+
+
+
+}
View
41 src/test/java/nl/intercommit/weaves/TestTextMarker.java
@@ -0,0 +1,41 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves;
+
+import util.WeaveTestCase;
+
+public class TestTextMarker extends WeaveTestCase {
+
+
+ public void testTextMarkerComponent() {
+
+ org.apache.tapestry5.dom.Document dom = getTester().renderPage("TextMarkerPage");
+ assertNotNull(dom.getElementById("result"));
+ assertEquals("<div class=\"textmarker\">Lorem <div class=\"highlight\">ipsum</div> dolor sit amet...<div class=\"highlight\">Ut</div> labore et dolo...<div class=\"highlight\">Ut</div> enim ad minim ...<div class=\"highlight\">exercitation</div> ullamco labori...<div class=\"highlight\">ut</div> aliquip ex ea ...<div class=\"highlight\">ut</div>e irure dolor i...</div>",dom.getElementById("result").getChildMarkup());
+ }
+
+ public void testTextMarkerComponentMaxLength() {
+
+ org.apache.tapestry5.dom.Document dom = getTester().renderPage("TextMarkerPage/30");
+ assertNotNull(dom.getElementById("result"));
+ assertEquals("<div class=\"textmarker\">Lorem <div class=\"highlight\">ipsum</div> dolor sit amet...<div class=\"highlight\">Ut</div></div>",dom.getElementById("result").getChildMarkup());
+ }
+
+
+}
View
33 src/test/java/nl/intercommit/weaves/grid/TestCollectionFilter.java
@@ -0,0 +1,33 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves.grid;
+
+import junit.framework.TestCase;
+import nl.intercommit.weaves.grid.CollectionFilter.OPERATOR;
+
+public class TestCollectionFilter extends TestCase {
+
+ public void testFilter() {
+ CollectionFilter cf = new CollectionFilter("name","Smith",OPERATOR.EQ);
+
+ assertTrue(cf.getValue().equals("Smith"));
+ assertTrue(cf.getOp().equals(OPERATOR.EQ));
+ assertTrue(cf.getName().equals("name"));
+ }
+}
View
117 src/test/java/nl/intercommit/weaves/grid/TestGridSourceFilter.java
@@ -0,0 +1,117 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves.grid;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
+import junit.framework.TestCase;
+import nl.intercommit.weaves.grid.CollectionFilter.OPERATOR;
+import nl.intercommit.weaves.test.entities.Person;
+
+import org.apache.tapestry5.grid.SortConstraint;
+import org.hibernate.Criteria;
+import org.hibernate.Session;
+import org.hibernate.criterion.Restrictions;
+
+import util.HibernateUtil;
+
+public class TestGridSourceFilter extends TestCase {
+
+ HibernateUtil util = null;
+ Session session = null;
+ Collection<Person> persons = new LinkedList<Person>();
+
+ @Override
+ protected void setUp() throws Exception {
+ util = new HibernateUtil();
+
+ session = util.create();
+
+ Person p1 = new Person();
+ p1.setName("fred");
+ session.persist(p1);
+ persons.add(p1);
+
+ Person p2 = new Person();
+ p2.setName("wilma");
+ session.persist(p2);
+ persons.add(p2);
+
+ session.flush();
+
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ util.shutdown();
+ }
+
+
+ public void testHibernateGridSource() {
+ HibernatePagedGridDataSource hpds = new HibernatePagedGridDataSource(session,Person.class) {
+
+ @Override
+ public void applyFiltering(Criteria criteria) {
+ criteria.add(Restrictions.eq("name", "fred"));
+ }
+ };
+
+ hpds.prepare(0, 10, new LinkedList<SortConstraint>());
+
+ Person p1 = (Person)(hpds.getRowValue(0));
+ assertNotNull(p1);
+ assertEquals("fred", p1.getName());
+
+ assertNotNull(hpds.getIdentifierForRowValue(p1));
+ }
+
+ public void testCollectionGridSource() {
+ CollectionPagedGridDataSource cpds = new CollectionPagedGridDataSource(persons,Person.class) {
+
+ @Override
+ public List<CollectionFilter> createFilter() {
+ List<CollectionFilter> list = new LinkedList<CollectionFilter>();
+
+ CollectionFilter cf = new CollectionFilter("name","fred",OPERATOR.EQ);
+ list.add(cf);
+ return list;
+ }
+ };
+
+ cpds.prepare(0,10,new LinkedList<SortConstraint>());
+
+ Person p1 = (Person)(cpds.getRowValue(1));
+
+ assertNull(p1); // it only contains fred..
+
+ p1 = (Person)(cpds.getRowValue(0));
+
+ assertEquals("fred",p1.getName());
+
+
+
+ }
+
+
+}
+
+
View
39 src/test/java/nl/intercommit/weaves/test/beans/Box.java
@@ -0,0 +1,39 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves.test.beans;
+
+public class Box {
+
+ private Long id;
+ private String type;
+ public Long getId() {
+ return id;
+ }
+ public void setId(Long id) {
+ this.id = id;
+ }
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+
+
+}
View
51 src/test/java/nl/intercommit/weaves/test/entities/Person.java
@@ -0,0 +1,51 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves.test.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class Person {
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ private String name;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+}
View
23 src/test/java/nl/intercommit/weaves/test/pages/ConfirmPage.java
@@ -0,0 +1,23 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves.test.pages;
+
+public class ConfirmPage {
+
+}
View
74 src/test/java/nl/intercommit/weaves/test/pages/DropDownMenuPage.java
@@ -0,0 +1,74 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves.test.pages;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import nl.intercommit.weaves.menu.MenuItem;
+
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.services.PageRenderLinkSource;
+
+public class DropDownMenuPage {
+
+ private String menutype;
+
+ @Inject
+ private PageRenderLinkSource prls;
+
+ private void onActivate(String menutype) {
+ this.menutype = menutype;
+ }
+
+
+
+
+
+ public Map<MenuItem,Map<MenuItem, List<MenuItem>>> getMenu() {
+
+ Map menu = new LinkedHashMap<MenuItem,Map<MenuItem, List<MenuItem>>>();
+
+ if ("full".equals(menutype)) {
+
+
+
+ Map<MenuItem,List<MenuItem>> level1 = new LinkedHashMap<MenuItem, List<MenuItem>>();
+
+ level1.put(new MenuItem("item1",prls.createPageRenderLink("DropDownMenuPage")), null);
+ level1.put(new MenuItem("item2",prls.createPageRenderLink("DropDownMenuPage")), null);
+
+ menu.put(new MenuItem("/images/menu1.png","top1",prls.createPageRenderLink("PagedGridPage")),level1);
+
+ List<MenuItem> submenu = new ArrayList<MenuItem>();
+ submenu.add(new MenuItem("sub1",prls.createPageRenderLink("DropDownMenuPage")));
+ submenu.add(new MenuItem("sub2",prls.createPageRenderLink("DropDownMenuPage")));
+ submenu.add(new MenuItem("sub3",prls.createPageRenderLink("DropDownMenuPage")));
+
+ Map<MenuItem,List<MenuItem>> level2 = new LinkedHashMap<MenuItem, List<MenuItem>>();
+ level2.put(new MenuItem("item1",prls.createPageRenderLink("DropDownMenuPage")), null);
+ level2.put(new MenuItem("item2",prls.createPageRenderLink("DropDownMenuPage")), submenu);
+
+ menu.put(new MenuItem("top2",prls.createPageRenderLink("SwitchPage")),level2);
+ }
+ return menu;
+ }
+}
View
39 src/test/java/nl/intercommit/weaves/test/pages/EditableSelectPage.java
@@ -0,0 +1,39 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves.test.pages;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.tapestry5.annotations.Property;
+
+public class EditableSelectPage {
+
+ @Property
+ private String item;
+
+ public List<String> getList() {
+ List<String> items = new LinkedList<String>();
+ items.add("psp");
+ items.add("ipad");
+ items.add("3ds");
+ return items;
+
+ }
+}
View
33 src/test/java/nl/intercommit/weaves/test/pages/HoverLinkPage.java
@@ -0,0 +1,33 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves.test.pages;
+
+import nl.intercommit.weaves.components.HoverLink;
+import nl.intercommit.weaves.util.HoverlinkStreamResponse;
+
+import org.apache.tapestry5.StreamResponse;
+import org.apache.tapestry5.annotations.OnEvent;
+
+public class HoverLinkPage {
+
+ @OnEvent(component="hoverlink",value=HoverLink.RETRIEVE_CONTENT_EVENT)
+ private StreamResponse returnContent1() {
+ return new HoverlinkStreamResponse("Popup Title","Popup test content");
+ }
+}
View
33 src/test/java/nl/intercommit/weaves/test/pages/ModalBoxPage.java
@@ -0,0 +1,33 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves.test.pages;
+
+import org.apache.tapestry5.Block;
+import org.apache.tapestry5.ioc.annotations.Inject;
+
+public class ModalBoxPage {
+
+ @Inject
+ private Block messageBlock;
+
+ public Object onEvent() {
+ return messageBlock;
+ }
+
+}
View
69 src/test/java/nl/intercommit/weaves/test/pages/PagedGridPage.java
@@ -0,0 +1,69 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves.test.pages;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import nl.intercommit.weaves.grid.CollectionPagedGridDataSource;
+import nl.intercommit.weaves.grid.HibernatePagedGridDataSource;
+import nl.intercommit.weaves.hibernate.HibernateMultiSessionManager;
+import nl.intercommit.weaves.test.beans.Box;
+import nl.intercommit.weaves.test.entities.Person;
+
+import org.apache.tapestry5.ioc.annotations.Inject;
+
+public class PagedGridPage {
+
+ @Inject
+ private HibernateMultiSessionManager manager;
+
+
+ public CollectionPagedGridDataSource getCollectionPagedSource() {
+ List<Box> boxes = new LinkedList<Box>();
+
+ Box box = new Box();
+ box.setId(Long.valueOf(1));
+ box.setType("type 1");
+ boxes.add(box);
+
+ box = new Box();
+ box.setId(Long.valueOf(2));
+ box.setType("type 2");
+ boxes.add(box);
+
+ return new CollectionPagedGridDataSource(boxes,Box.class);
+ }
+
+ public HibernatePagedGridDataSource getHibernatePagedSource() {
+ return new HibernatePagedGridDataSource(manager.getSession("Factory1"),Person.class);
+ }
+
+ public List<Long> getPagination() {
+ ArrayList<Long> list = new ArrayList<Long>();
+ list.add(new Long(1));
+ list.add(new Long(2));
+ list.add(new Long(10));
+ return list;
+ }
+
+
+
+}
View
30 src/test/java/nl/intercommit/weaves/test/pages/PopupWindowPage.java
@@ -0,0 +1,30 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves.test.pages;
+
+import nl.intercommit.weaves.components.PopupWindow;
+
+import org.apache.tapestry5.annotations.Component;
+
+public class PopupWindowPage {
+
+ @Component(parameters={"width=200","height=200","windowStyle=darkX"})
+ private PopupWindow popupWindow;
+
+}
View
36 src/test/java/nl/intercommit/weaves/test/pages/SwitchPage.java
@@ -0,0 +1,36 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves.test.pages;
+
+public class SwitchPage {
+
+ private String testValue;
+
+ public String getTestValue() {
+ return testValue;
+ }
+
+ public String getHtml() {
+ return "<h1>default</h1>";
+ }
+
+ private void onActivate(String param) {
+ testValue = param;
+ }
+}
View
39 src/test/java/nl/intercommit/weaves/test/pages/TextMarkerPage.java
@@ -0,0 +1,39 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves.test.pages;
+
+import org.apache.tapestry5.annotations.Property;
+
+public class TextMarkerPage {
+
+ @Property
+ private int maxLength;
+
+ public String getMessage() {
+ return "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt Ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
+ }
+
+ public String[] getWords() {
+ return new String[] {"ipsum","Ut","exercitation"};
+ }
+
+ private void onActivate(String param) {
+ maxLength = Integer.parseInt(param);
+ }
+}
View
48 src/test/java/nl/intercommit/weaves/test/services/WeavesTestModule.java
@@ -0,0 +1,48 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves.test.services;
+
+import java.io.File;
+
+import nl.intercommit.weaves.hibernate.SessionFactoryConfiguration;
+
+import org.apache.tapestry5.ioc.Configuration;
+import org.apache.tapestry5.ioc.MappedConfiguration;
+import org.apache.tapestry5.ioc.internal.util.TapestryException;
+import org.apache.tapestry5.services.LibraryMapping;
+
+public class WeavesTestModule {
+
+ public static void contributeComponentClassResolver(
+ Configuration configuration) {
+ configuration.add(new LibraryMapping("weave", "nl.intercommit.weaves"));
+ }
+
+ public void contributeSessionFactorySource(MappedConfiguration<String,SessionFactoryConfiguration> configuration) {
+ try {
+ final File configFile = new File(this.getClass().getResource("/factory1.cfg.xml").toURI());
+ final SessionFactoryConfiguration factory1Config = new SessionFactoryConfiguration(new String[] {"nl.intercommit.tapestry.test.entities"},configFile);
+ configuration.add("Factory1",factory1Config);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new TapestryException("Could not initialize session factory due to: ["+e.getMessage()+"]",e);
+ }
+ }
+
+}
View
43 src/test/java/nl/intercommit/weaves/util/TestHoverlinkStreamResponse.java
@@ -0,0 +1,43 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package nl.intercommit.weaves.util;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.io.IOUtils;
+
+public class TestHoverlinkStreamResponse extends TestCase {
+
+ public void testContent() {
+ HoverlinkStreamResponse hsr = new HoverlinkStreamResponse("Test title","<html><body>And some comment</body></html");
+
+ try {
+ final String output = new String(IOUtils.toByteArray(hsr.getStream()));
+
+ assertEquals("<HelpBalloon><title>Test title</title><content>&#60;html&#62;&#60;body&#62;And some comment&#60;/body&#62;&#60;/html</content></HelpBalloon>",output);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ fail();
+ }
+
+ }
+}
View
22 src/test/java/util/HibernateUtil.java
@@ -1,16 +1,32 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
package util;
import java.io.File;
import java.net.URISyntaxException;
import junit.framework.Assert;
-
-import nl.intercommit.tapestry.test.entities.Person;
+import nl.intercommit.weaves.test.entities.Person;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
-import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
View
50 src/test/java/util/WeaveTestCase.java
@@ -0,0 +1,50 @@
+/* Copyright 2011 InterCommIT b.v.
+*
+* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves
+*
+* Weaves is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* any later version.
+*
+* Weaves is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with Weaves. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+package util;
+
+import junit.framework.TestCase;
+
+import org.apache.tapestry5.test.PageTester;
+
+public abstract class WeaveTestCase extends TestCase {
+
+ private PageTester tester;
+
+ @Override
+ protected void setUp() throws Exception {
+ if (tester == null) {
+ tester = new PageTester("nl.intercommit.weaves.test", "WeavesTest");
+ }
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ if (tester != null) {
+ tester.shutdown();
+ }
+ }
+
+ public PageTester getTester() {
+ if (tester == null) {
+ fail("Tapestry PageTester not initialized yet!");
+ }
+ return tester;
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.