summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@itmill.com>2011-08-10 06:25:40 +0000
committerHenri Sara <henri.sara@itmill.com>2011-08-10 06:25:40 +0000
commita41fbd0e685cc8f63b79805a5171777b2153807f (patch)
treed8768d55cab93148deb86ac82ab26b506a1ce42f
parent32f1da4ee0bb6627e1fa1318185121873cca8443 (diff)
downloadvaadin-framework-a41fbd0e685cc8f63b79805a5171777b2153807f.tar.gz
vaadin-framework-a41fbd0e685cc8f63b79805a5171777b2153807f.zip
#7178 Removed some references to demo classes from Vaadin 6.7 (unit tests etc.)
svn changeset:20243/svn branch:6.7
-rw-r--r--WebContent/VAADIN/readme.txt4
-rw-r--r--tests/src/com/vaadin/tests/TestBench.java3
-rw-r--r--tests/src/com/vaadin/tests/TreeFilesystem.java2
-rw-r--r--tests/src/com/vaadin/tests/TreeFilesystemContainer.java2
-rw-r--r--tests/src/com/vaadin/tests/VaadinClasses.java3
-rw-r--r--tests/src/com/vaadin/tests/dd/DDTest2.java4
-rw-r--r--tests/src/com/vaadin/tests/dd/DDTest4.java4
-rw-r--r--tests/src/com/vaadin/tests/dd/DDTest7.java4
-rw-r--r--tests/src/com/vaadin/tests/tickets/Ticket1737.java4
-rw-r--r--tests/src/com/vaadin/tests/util/Person.java120
-rw-r--r--tests/src/com/vaadin/tests/util/PersonContainer.java94
-rw-r--r--tests/src/com/vaadin/tests/util/SampleDirectory.java73
12 files changed, 301 insertions, 16 deletions
diff --git a/WebContent/VAADIN/readme.txt b/WebContent/VAADIN/readme.txt
index cabf68b41a..6d1f907fd0 100644
--- a/WebContent/VAADIN/readme.txt
+++ b/WebContent/VAADIN/readme.txt
@@ -20,8 +20,8 @@ command below in the top project directory:
ant -f build-widgetsets.xml
-See build-widgetsets.xml, com.vaadin.demo.colorpicker package, and the
-Reference Manual for more information regarding widget sets.
+See build-widgetsets.xml and the Reference Manual for more information
+regarding widget sets.
---------------------------
Vaadin Development
diff --git a/tests/src/com/vaadin/tests/TestBench.java b/tests/src/com/vaadin/tests/TestBench.java
index 3a92864df2..98c6cd41f8 100644
--- a/tests/src/com/vaadin/tests/TestBench.java
+++ b/tests/src/com/vaadin/tests/TestBench.java
@@ -43,8 +43,7 @@ public class TestBench extends com.vaadin.Application implements
Property.ValueChangeListener {
// Add here packages which are used for finding testable classes
- String[] testablePackages = { "com.vaadin.tests", "com.vaadin.demo",
- "com.vaadin.demo.colorpicker", "com.vaadin.demo.features",
+ String[] testablePackages = { "com.vaadin.tests",
"com.vaadin.tests.tickets" };
HierarchicalContainer testables = new HierarchicalContainer();
diff --git a/tests/src/com/vaadin/tests/TreeFilesystem.java b/tests/src/com/vaadin/tests/TreeFilesystem.java
index d39c6008f6..9b05bbce1c 100644
--- a/tests/src/com/vaadin/tests/TreeFilesystem.java
+++ b/tests/src/com/vaadin/tests/TreeFilesystem.java
@@ -7,7 +7,7 @@ package com.vaadin.tests;
import java.io.File;
import com.vaadin.data.Item;
-import com.vaadin.demo.util.SampleDirectory;
+import com.vaadin.tests.util.SampleDirectory;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Tree;
diff --git a/tests/src/com/vaadin/tests/TreeFilesystemContainer.java b/tests/src/com/vaadin/tests/TreeFilesystemContainer.java
index 618fa21ccf..085abd1666 100644
--- a/tests/src/com/vaadin/tests/TreeFilesystemContainer.java
+++ b/tests/src/com/vaadin/tests/TreeFilesystemContainer.java
@@ -8,7 +8,7 @@ import java.io.File;
import com.vaadin.data.util.FilesystemContainer;
import com.vaadin.data.util.FilesystemContainer.FileItem;
-import com.vaadin.demo.util.SampleDirectory;
+import com.vaadin.tests.util.SampleDirectory;
import com.vaadin.ui.Component.Event;
import com.vaadin.ui.Component.Listener;
import com.vaadin.ui.Field;
diff --git a/tests/src/com/vaadin/tests/VaadinClasses.java b/tests/src/com/vaadin/tests/VaadinClasses.java
index f6a737b957..6f826402f4 100644
--- a/tests/src/com/vaadin/tests/VaadinClasses.java
+++ b/tests/src/com/vaadin/tests/VaadinClasses.java
@@ -62,8 +62,7 @@ public class VaadinClasses {
public static List<Class<? extends Object>> getAllServerSideClasses() {
try {
return findClasses(Object.class, "com.vaadin", new String[] {
- "com.vaadin.tests", "com.vaadin.demo",
- "com.vaadin.terminal.gwt.client" });
+ "com.vaadin.tests", "com.vaadin.terminal.gwt.client" });
} catch (IOException e) {
e.printStackTrace();
return null;
diff --git a/tests/src/com/vaadin/tests/dd/DDTest2.java b/tests/src/com/vaadin/tests/dd/DDTest2.java
index 690b44ff74..69af2d3f1d 100644
--- a/tests/src/com/vaadin/tests/dd/DDTest2.java
+++ b/tests/src/com/vaadin/tests/dd/DDTest2.java
@@ -7,8 +7,6 @@ import java.util.Set;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
import com.vaadin.data.util.HierarchicalContainer;
-import com.vaadin.demo.tutorial.addressbook.data.Person;
-import com.vaadin.demo.tutorial.addressbook.data.PersonContainer;
import com.vaadin.event.DataBoundTransferable;
import com.vaadin.event.Transferable;
import com.vaadin.event.dd.DragAndDropEvent;
@@ -20,6 +18,8 @@ import com.vaadin.event.dd.acceptcriteria.SourceIs;
import com.vaadin.terminal.Resource;
import com.vaadin.terminal.ThemeResource;
import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.Person;
+import com.vaadin.tests.util.PersonContainer;
import com.vaadin.ui.AbstractSelect;
import com.vaadin.ui.AbstractSelect.AbstractSelectTargetDetails;
import com.vaadin.ui.AbstractSelect.AcceptItem;
diff --git a/tests/src/com/vaadin/tests/dd/DDTest4.java b/tests/src/com/vaadin/tests/dd/DDTest4.java
index 8685c6f5de..b4da141ce2 100644
--- a/tests/src/com/vaadin/tests/dd/DDTest4.java
+++ b/tests/src/com/vaadin/tests/dd/DDTest4.java
@@ -4,8 +4,6 @@ import java.util.Collection;
import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.demo.tutorial.addressbook.data.Person;
-import com.vaadin.demo.tutorial.addressbook.data.PersonContainer;
import com.vaadin.event.DataBoundTransferable;
import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.DropHandler;
@@ -13,6 +11,8 @@ import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.event.dd.acceptcriteria.SourceIs;
import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation;
import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.Person;
+import com.vaadin.tests.util.PersonContainer;
import com.vaadin.tests.util.TestUtils;
import com.vaadin.ui.AbstractSelect.AbstractSelectTargetDetails;
import com.vaadin.ui.HorizontalLayout;
diff --git a/tests/src/com/vaadin/tests/dd/DDTest7.java b/tests/src/com/vaadin/tests/dd/DDTest7.java
index 8efaff8759..6027b3e499 100644
--- a/tests/src/com/vaadin/tests/dd/DDTest7.java
+++ b/tests/src/com/vaadin/tests/dd/DDTest7.java
@@ -6,13 +6,13 @@ import java.util.Set;
import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.demo.tutorial.addressbook.data.Person;
-import com.vaadin.demo.tutorial.addressbook.data.PersonContainer;
import com.vaadin.event.DataBoundTransferable;
import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.DropHandler;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.Person;
+import com.vaadin.tests.util.PersonContainer;
import com.vaadin.tests.util.TestUtils;
import com.vaadin.ui.AbstractSelect.AbstractSelectTargetDetails;
import com.vaadin.ui.HorizontalLayout;
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1737.java b/tests/src/com/vaadin/tests/tickets/Ticket1737.java
index 5f8563599a..f45fe88889 100644
--- a/tests/src/com/vaadin/tests/tickets/Ticket1737.java
+++ b/tests/src/com/vaadin/tests/tickets/Ticket1737.java
@@ -1,7 +1,6 @@
package com.vaadin.tests.tickets;
import com.vaadin.Application;
-import com.vaadin.demo.Calc;
import com.vaadin.terminal.ClassResource;
import com.vaadin.terminal.DownloadStream;
import com.vaadin.terminal.Resource;
@@ -13,7 +12,8 @@ import com.vaadin.ui.Window;
public class Ticket1737 extends Application {
- Resource slowRes = new ClassResource(Calc.class, "m-bullet-blue.gif", this) {
+ Resource slowRes = new ClassResource(Ticket1737.class, "m-bullet-blue.gif",
+ this) {
@Override
public DownloadStream getStream() {
try {
diff --git a/tests/src/com/vaadin/tests/util/Person.java b/tests/src/com/vaadin/tests/util/Person.java
new file mode 100644
index 0000000000..822f62d17a
--- /dev/null
+++ b/tests/src/com/vaadin/tests/util/Person.java
@@ -0,0 +1,120 @@
+package com.vaadin.tests.util;
+
+import java.io.Serializable;
+
+@SuppressWarnings("serial")
+public class Person implements Serializable {
+ private String firstName = "";
+ private String lastName = "";
+ private String email = "";
+ private String phoneNumber = "";
+ private String streetAddress = "";
+ private Integer postalCode = null;
+ private String city = "";
+
+ /**
+ * @return the firstName
+ */
+ public String getFirstName() {
+ return firstName;
+ }
+
+ /**
+ * @param firstName
+ * the firstName to set
+ */
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ /**
+ * @return the lastName
+ */
+ public String getLastName() {
+ return lastName;
+ }
+
+ /**
+ * @param lastName
+ * the lastName to set
+ */
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ /**
+ * @return the email
+ */
+ public String getEmail() {
+ return email;
+ }
+
+ /**
+ * @param email
+ * the email to set
+ */
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ /**
+ * @return the phoneNumber
+ */
+ public String getPhoneNumber() {
+ return phoneNumber;
+ }
+
+ /**
+ * @param phoneNumber
+ * the phoneNumber to set
+ */
+ public void setPhoneNumber(String phoneNumber) {
+ this.phoneNumber = phoneNumber;
+ }
+
+ /**
+ * @return the streetAddress
+ */
+ public String getStreetAddress() {
+ return streetAddress;
+ }
+
+ /**
+ * @param streetAddress
+ * the streetAddress to set
+ */
+ public void setStreetAddress(String streetAddress) {
+ this.streetAddress = streetAddress;
+ }
+
+ /**
+ * @return the postalCode
+ */
+ public Integer getPostalCode() {
+ return postalCode;
+ }
+
+ /**
+ * @param postalCode
+ * the postalCode to set
+ */
+ public void setPostalCode(Integer postalCode) {
+ this.postalCode = postalCode;
+ }
+
+ /**
+ * @return the city
+ */
+ public String getCity() {
+ return city;
+ }
+
+ /**
+ * @param city
+ * the city to set
+ */
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+} \ No newline at end of file
diff --git a/tests/src/com/vaadin/tests/util/PersonContainer.java b/tests/src/com/vaadin/tests/util/PersonContainer.java
new file mode 100644
index 0000000000..8195b4d5f0
--- /dev/null
+++ b/tests/src/com/vaadin/tests/util/PersonContainer.java
@@ -0,0 +1,94 @@
+package com.vaadin.tests.util;
+
+import java.io.Serializable;
+import java.util.Random;
+
+import com.vaadin.data.util.BeanItemContainer;
+
+@SuppressWarnings("serial")
+public class PersonContainer extends BeanItemContainer<Person> implements
+ Serializable {
+
+ /**
+ * Natural property order for Person bean. Used in tables and forms.
+ */
+ public static final Object[] NATURAL_COL_ORDER = new Object[] {
+ "firstName", "lastName", "email", "phoneNumber", "streetAddress",
+ "postalCode", "city" };
+
+ /**
+ * "Human readable" captions for properties in same order as in
+ * NATURAL_COL_ORDER.
+ */
+ public static final String[] COL_HEADERS_ENGLISH = new String[] {
+ "First name", "Last name", "Email", "Phone number",
+ "Street Address", "Postal Code", "City" };
+
+ public PersonContainer() throws InstantiationException,
+ IllegalAccessException {
+ super(Person.class);
+ }
+
+ public static PersonContainer createWithTestData() {
+ final String[] fnames = { "Peter", "Alice", "Joshua", "Mike", "Olivia",
+ "Nina", "Alex", "Rita", "Dan", "Umberto", "Henrik", "Rene",
+ "Lisa", "Marge" };
+ final String[] lnames = { "Smith", "Gordon", "Simpson", "Brown",
+ "Clavel", "Simons", "Verne", "Scott", "Allison", "Gates",
+ "Rowling", "Barks", "Ross", "Schneider", "Tate" };
+ final String cities[] = { "Amsterdam", "Berlin", "Helsinki",
+ "Hong Kong", "London", "Luxemburg", "New York", "Oslo",
+ "Paris", "Rome", "Stockholm", "Tokyo", "Turku" };
+ final String streets[] = { "4215 Blandit Av.", "452-8121 Sem Ave",
+ "279-4475 Tellus Road", "4062 Libero. Av.", "7081 Pede. Ave",
+ "6800 Aliquet St.", "P.O. Box 298, 9401 Mauris St.",
+ "161-7279 Augue Ave", "P.O. Box 496, 1390 Sagittis. Rd.",
+ "448-8295 Mi Avenue", "6419 Non Av.",
+ "659-2538 Elementum Street", "2205 Quis St.",
+ "252-5213 Tincidunt St.", "P.O. Box 175, 4049 Adipiscing Rd.",
+ "3217 Nam Ave", "P.O. Box 859, 7661 Auctor St.",
+ "2873 Nonummy Av.", "7342 Mi, Avenue",
+ "539-3914 Dignissim. Rd.", "539-3675 Magna Avenue",
+ "Ap #357-5640 Pharetra Avenue", "416-2983 Posuere Rd.",
+ "141-1287 Adipiscing Avenue", "Ap #781-3145 Gravida St.",
+ "6897 Suscipit Rd.", "8336 Purus Avenue", "2603 Bibendum. Av.",
+ "2870 Vestibulum St.", "Ap #722 Aenean Avenue",
+ "446-968 Augue Ave", "1141 Ultricies Street",
+ "Ap #992-5769 Nunc Street", "6690 Porttitor Avenue",
+ "Ap #105-1700 Risus Street",
+ "P.O. Box 532, 3225 Lacus. Avenue", "736 Metus Street",
+ "414-1417 Fringilla Street", "Ap #183-928 Scelerisque Road",
+ "561-9262 Iaculis Avenue" };
+ PersonContainer c = null;
+ Random r = new Random(0);
+ try {
+ c = new PersonContainer();
+ for (int i = 0; i < 100; i++) {
+ Person p = new Person();
+ p.setFirstName(fnames[r.nextInt(fnames.length)]);
+ p.setLastName(lnames[r.nextInt(lnames.length)]);
+ p.setCity(cities[r.nextInt(cities.length)]);
+ p.setEmail(p.getFirstName().toLowerCase() + "."
+ + p.getLastName().toLowerCase() + "@vaadin.com");
+ p.setPhoneNumber("+358 02 555 " + r.nextInt(10) + r.nextInt(10)
+ + r.nextInt(10) + r.nextInt(10));
+ int n = r.nextInt(100000);
+ if (n < 10000) {
+ n += 10000;
+ }
+ p.setPostalCode(n);
+ p.setStreetAddress(streets[r.nextInt(streets.length)]);
+ c.addItem(p);
+ }
+ } catch (InstantiationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return c;
+ }
+
+}
diff --git a/tests/src/com/vaadin/tests/util/SampleDirectory.java b/tests/src/com/vaadin/tests/util/SampleDirectory.java
new file mode 100644
index 0000000000..ab52e4050c
--- /dev/null
+++ b/tests/src/com/vaadin/tests/util/SampleDirectory.java
@@ -0,0 +1,73 @@
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests.util;
+
+import java.io.File;
+
+import com.vaadin.Application;
+import com.vaadin.terminal.SystemError;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+
+/**
+ * Provides sample directory based on application directory. If this fails then
+ * sampleDirectory property is read. If no sample directory is resolved, then a
+ * panel displaying error message is added to main window.
+ *
+ * @author IT Mill Ltd.
+ *
+ */
+public class SampleDirectory {
+
+ /**
+ * Get sample directory.
+ *
+ * @param application
+ * @return file pointing to sample directory
+ */
+ public static File getDirectory(Application application) {
+ String errorMessage = "Access to application "
+ + "context base directory failed, "
+ + "possible security constraint with Application "
+ + "Server or Servlet Container.<br />";
+ File file = application.getContext().getBaseDirectory();
+ if ((file == null) || (!file.canRead())
+ || (file.getAbsolutePath() == null)) {
+ // cannot access example directory, possible security issue with
+ // Application Server or Servlet Container
+ // Try to read sample directory from web.xml parameter
+ if (application.getProperty("sampleDirectory") != null) {
+ file = new File(application.getProperty("sampleDirectory"));
+ if ((file != null) && (file.canRead())
+ && (file.getAbsolutePath() != null)) {
+ // Success using property
+ return file;
+ }
+ // Failure using property
+ errorMessage += "Failed also to access sample directory <b>["
+ + application.getProperty("sampleDirectory")
+ + "]</b> defined in <b>sampleDirectory property</b>.";
+ } else {
+ // Failure using application context base dir, no property set
+ errorMessage += "<b>Note: </b>You can set this manually in "
+ + "web.xml by defining " + "sampleDirectory property.";
+ }
+ } else {
+ // Success using application context base dir
+ return file;
+ }
+ // Add failure notification as an Panel to main window
+ final Panel errorPanel = new Panel("Demo application error");
+ errorPanel.setStyleName("strong");
+ errorPanel.setComponentError(new SystemError(
+ "Cannot provide sample directory"));
+ errorPanel.addComponent(new Label(errorMessage, Label.CONTENT_XHTML));
+ // Remove all components from applications main window
+ application.getMainWindow().getContent().removeAllComponents();
+ // Add error panel
+ application.getMainWindow().getContent().addComponent(errorPanel);
+ return null;
+ }
+}