]> source.dussan.org Git - vaadin-framework.git/commitdiff
#5692 Generics and warnings cleanup: first set of test class modifications
authorHenri Sara <henri.sara@itmill.com>
Mon, 4 Oct 2010 13:52:49 +0000 (13:52 +0000)
committerHenri Sara <henri.sara@itmill.com>
Mon, 4 Oct 2010 13:52:49 +0000 (13:52 +0000)
svn changeset:15376/svn branch:6.5

tests/src/com/vaadin/tests/BasicRandomTest.java
tests/src/com/vaadin/tests/PerformanceTestBasicComponentRendering.java
tests/src/com/vaadin/tests/StressComponentsInTable.java
tests/src/com/vaadin/tests/TestForChildComponentRendering.java
tests/src/com/vaadin/tests/TestForGridLayoutChildComponentRendering.java
tests/src/com/vaadin/tests/TestForMultipleStyleNames.java
tests/src/com/vaadin/tests/TestForTablesInitialColumnWidthLogicRendering.java
tests/src/com/vaadin/tests/TestSelectAndDatefieldInDeepLayouts.java
tests/src/com/vaadin/tests/TestSizeableIncomponents.java
tests/src/com/vaadin/tests/UsingObjectsInSelect.java

index 8b5a9d01ab44a1abb36d29990033e7200c7e3028..680c0ebde802419cc1ca06150283ca81de6c18bf 100644 (file)
@@ -78,7 +78,7 @@ public class BasicRandomTest extends com.vaadin.Application implements
 
     private long captionCounter = 0;
 
-    private ArrayList components;
+    private ArrayList<Component> components;
 
     private long eventCounter = 0;
 
@@ -86,7 +86,7 @@ public class BasicRandomTest extends com.vaadin.Application implements
 
     // Store button object => real value map
     // needed because button captions are randomized
-    private HashMap buttonValues;
+    private HashMap<Button, String> buttonValues;
 
     private RandomComponents randomComponents;
 
@@ -191,7 +191,7 @@ public class BasicRandomTest extends com.vaadin.Application implements
         //
         // Create components that have UUID defined
         //
-        components = new ArrayList();
+        components = new ArrayList<Component>();
 
         // create label
         final Label userLabel = new Label("user");
@@ -213,7 +213,7 @@ public class BasicRandomTest extends com.vaadin.Application implements
                         "minus", "multiple", "divisor", "equals", "clear" } };
         // final String[] randomizedCaptions = { "a", "b", "c", "y", "8", "3" };
         // String[] randomizedCaptions = { "X" };
-        buttonValues = new HashMap();
+        buttonValues = new HashMap<Button, String>();
         for (int i = 0; i > calcValues[0].length; i++) {
             final Button button = new Button("", this);
             // Test requirement: ATF must not rely on caption
@@ -244,7 +244,7 @@ public class BasicRandomTest extends com.vaadin.Application implements
         if (components.size() > 0) {
             // components found, return any
             final int i = rand.nextInt(components.size());
-            final Component c = (Component) components.get(i);
+            final Component c = components.get(i);
             components.remove(i);
             return c;
         } else {
@@ -287,7 +287,7 @@ public class BasicRandomTest extends com.vaadin.Application implements
     }
 
     public void buttonClick(Button.ClickEvent event) {
-        final String value = (String) buttonValues.get(event.getButton());
+        final String value = buttonValues.get(event.getButton());
         eventCounter++;
         try {
             // Number button pressed
index be0e64dd79475e5533e23336fc756bd0f6ecc06f..d61979df174ac87c8bc6d16aa41bb4c9e789fe25 100644 (file)
@@ -48,7 +48,8 @@ public class PerformanceTestBasicComponentRendering extends CustomComponent {
 
         Table t2 = new Table("Test Table with 199 rows rendered initially") {
             @Override
-            public void changeVariables(Object source, Map variables) {
+            public void changeVariables(Object source,
+                    Map<String, Object> variables) {
                 super.changeVariables(source, variables);
                 // end timing on cache row request
                 endTest();
index 790d01ec7171e7d673f33f937a48ae947bc779bb..4722475fd8688998976cb8f9a31502332b823336 100644 (file)
@@ -31,7 +31,7 @@ public class StressComponentsInTable extends CustomComponent {
         }\r
         t.addContainerProperty("button", Button.class, null);\r
         for (int i = 0; i < rows; i++) {\r
-            final Vector content = new Vector();\r
+            final Vector<Object> content = new Vector<Object>();\r
             for (int j = 0; j < cols; j++) {\r
                 content.add(rndString());\r
             }\r
index 9b5d02e9457ff3626acb47c40a80fb78da33484a..5ca134c1bff92788d2bb42429ec32409e8c2033d 100644 (file)
@@ -64,8 +64,8 @@ public class TestForChildComponentRendering extends CustomComponent {
     }
 
     public void randomReorder() {
-        final Iterator it = main.getComponentIterator();
-        final ArrayList components = new ArrayList();
+        final Iterator<Component> it = main.getComponentIterator();
+        final ArrayList<Component> components = new ArrayList<Component>();
         while (it.hasNext()) {
             components.add(it.next());
         }
@@ -75,20 +75,20 @@ public class TestForChildComponentRendering extends CustomComponent {
 
         for (int i = components.size(); i > 0; i--) {
             final int index = (int) (Math.random() * i);
-            v.addComponent((Component) components.get(index));
+            v.addComponent(components.get(index));
             components.remove(index);
         }
     }
 
     public void removeRandomComponent() {
-        final Iterator it = main.getComponentIterator();
-        final ArrayList components = new ArrayList();
+        final Iterator<Component> it = main.getComponentIterator();
+        final ArrayList<Component> components = new ArrayList<Component>();
         while (it.hasNext()) {
             components.add(it.next());
         }
         final int size = components.size();
         final int index = (int) (Math.random() * size);
-        main.removeComponent((Component) components.get(index));
+        main.removeComponent(components.get(index));
 
     }
 
index 9ff23e62ca197b8bd81252d9e9c6fbb5d806fe32..5c121dd3d3dda8bd885169abd0d0b442e8dc3e4a 100644 (file)
@@ -65,8 +65,8 @@ public class TestForGridLayoutChildComponentRendering extends CustomComponent {
     }
 
     public void randomReorder() {
-        final Iterator it = main.getComponentIterator();
-        final ArrayList components = new ArrayList();
+        final Iterator<Component> it = main.getComponentIterator();
+        final ArrayList<Component> components = new ArrayList<Component>();
         while (it.hasNext()) {
             components.add(it.next());
         }
@@ -79,24 +79,24 @@ public class TestForGridLayoutChildComponentRendering extends CustomComponent {
         for (int i = components.size(); i > 0; i--) {
             final int index = (int) (Math.random() * i);
             if (i == colspanIndex) {
-                main.addComponent((Component) components.get(index), 0,
-                        (size - i) / 2, 1, (size - i) / 2);
+                main.addComponent(components.get(index), 0, (size - i) / 2, 1,
+                        (size - i) / 2);
             } else {
-                main.addComponent((Component) components.get(index));
+                main.addComponent(components.get(index));
             }
             components.remove(index);
         }
     }
 
     public void removeRandomComponent() {
-        final Iterator it = main.getComponentIterator();
-        final ArrayList components = new ArrayList();
+        final Iterator<Component> it = main.getComponentIterator();
+        final ArrayList<Component> components = new ArrayList<Component>();
         while (it.hasNext()) {
             components.add(it.next());
         }
         final int size = components.size();
         final int index = (int) (Math.random() * size);
-        main.removeComponent((Component) components.get(index));
+        main.removeComponent(components.get(index));
 
     }
 
index a0facecd567a87d4851a7d5ab0553ddb915c1f05..6156c84bba7287ae976cc0d0d32968cfafdf2d6f 100644 (file)
@@ -32,7 +32,7 @@ public class TestForMultipleStyleNames extends CustomComponent implements
 
     private final TwinColSelect s = new TwinColSelect();
 
-    private ArrayList styleNames2;
+    private ArrayList<String> styleNames2;
 
     public TestForMultipleStyleNames() {
         setCompositionRoot(main);
@@ -49,7 +49,7 @@ public class TestForMultipleStyleNames extends CustomComponent implements
                 + " on the browser. Currently changes are"
                 + " visible only by inspecting DOM."));
 
-        styleNames2 = new ArrayList();
+        styleNames2 = new ArrayList<String>();
 
         styleNames2.add("red");
         styleNames2.add("bold");
@@ -69,16 +69,16 @@ public class TestForMultipleStyleNames extends CustomComponent implements
 
         final String currentStyle = l.getStyle();
         final String[] tmp = currentStyle.split(" ");
-        final ArrayList curStyles = new ArrayList();
+        final ArrayList<String> curStyles = new ArrayList<String>();
         for (int i = 0; i < tmp.length; i++) {
             if (tmp[i] != "") {
                 curStyles.add(tmp[i]);
             }
         }
 
-        final Collection styles = (Collection) s.getValue();
+        final Collection<?> styles = (Collection<?>) s.getValue();
 
-        for (final Iterator iterator = styles.iterator(); iterator.hasNext();) {
+        for (final Iterator<?> iterator = styles.iterator(); iterator.hasNext();) {
             final String styleName = (String) iterator.next();
             if (curStyles.contains(styleName)) {
                 // already added
@@ -87,9 +87,9 @@ public class TestForMultipleStyleNames extends CustomComponent implements
                 l.addStyleName(styleName);
             }
         }
-        for (final Iterator iterator2 = curStyles.iterator(); iterator2
+        for (final Iterator<String> iterator2 = curStyles.iterator(); iterator2
                 .hasNext();) {
-            final String object = (String) iterator2.next();
+            final String object = iterator2.next();
             l.removeStyleName(object);
         }
     }
index c009f9c7688473292731df17e915e9ae49812416..870feeb0bd96b4540a2927df4d7caae151f2171b 100644 (file)
@@ -65,7 +65,7 @@ public class TestForTablesInitialColumnWidthLogicRendering extends
         t = getTestTable(5, 5);
         t.setCaption("Table with  some cols and rows rows, some col widths fixed");
 
-        Iterator it = t.getContainerPropertyIds().iterator();
+        Iterator<?> it = t.getContainerPropertyIds().iterator();
         it.next();
         it.next();
         t.setColumnWidth(it.next(), 30);
@@ -115,7 +115,7 @@ public class TestForTablesInitialColumnWidthLogicRendering extends
         }
         t.addContainerProperty("button", Button.class, null);
         for (int i = 0; i < rows; i++) {
-            final Vector content = new Vector();
+            final Vector<Object> content = new Vector<Object>();
             for (int j = 0; j < cols; j++) {
                 content.add(rndString());
             }
index b85c6292956ac8647a8078ab27cd09f1a7366057..5d1332d352b8849ae282ccb61f0af5aea485e736 100644 (file)
@@ -81,8 +81,8 @@ public class TestSelectAndDatefieldInDeepLayouts extends CustomComponent {
         return new DateField(getCaption("datefield"));
     }
 
-    private Collection getSelectOptions() {
-        final Collection opts = new Vector(3);
+    private Collection<String> getSelectOptions() {
+        final Collection<String> opts = new Vector<String>(3);
         opts.add(getCaption("opt 1"));
         opts.add(getCaption("opt 2"));
         opts.add(getCaption("opt 3"));
index c1e8aa137a62a1e3f9054a98878700124177217d..5d3a6e77cd6fdfb233ebb4ccac93569de07ef747 100644 (file)
@@ -135,7 +135,7 @@ public class TestSizeableIncomponents extends Application {
                     && (f.indexOf("Window") == -1)) {
                 f = f.replaceAll(".class", "");
                 String className = "com.vaadin.ui." + f;
-                Class c;
+                Class<?> c;
                 try {
                     c = Class.forName(className);
                     Object o = c.newInstance();
@@ -213,10 +213,10 @@ public class TestSizeableIncomponents extends Application {
 
     class Testable {
 
-        private Class classToTest;
-        private ArrayList configurations = new ArrayList();
+        private Class<?> classToTest;
+        private ArrayList<Configuration> configurations = new ArrayList<Configuration>();
 
-        Testable(Class c) {
+        Testable(Class<?> c) {
             classToTest = c;
         }
 
@@ -228,8 +228,9 @@ public class TestSizeableIncomponents extends Application {
             StringBuffer sb = new StringBuffer();
             sb.append(classToTest.getName().replaceAll("com.vaadin.ui.", ""));
             sb.append("[");
-            for (Iterator i = configurations.iterator(); i.hasNext();) {
-                sb.append(((Configuration) i.next()).getDescription());
+            for (Iterator<Configuration> i = configurations.iterator(); i
+                    .hasNext();) {
+                sb.append((i.next()).getDescription());
                 if (i.hasNext()) {
                     sb.append(",");
                 }
@@ -280,8 +281,9 @@ public class TestSizeableIncomponents extends Application {
                 ((Label) c).setValue("Test label");
             }
 
-            for (Iterator i = configurations.iterator(); i.hasNext();) {
-                Configuration conf = (Configuration) i.next();
+            for (Iterator<Configuration> i = configurations.iterator(); i
+                    .hasNext();) {
+                Configuration conf = i.next();
                 conf.configure(c);
             }
             return c;
index 2fc0fc5eac8e45a714ee85189795d6ab5d452dc3..c9b0939eef3613f9ee0778f38c4628994b011242 100644 (file)
@@ -21,7 +21,7 @@ public class UsingObjectsInSelect extends com.vaadin.Application implements
     private final Label selectedTask = new Label("Selected task",
             Label.CONTENT_XHTML);
 
-    public LinkedList exampleTasks = new LinkedList();
+    public LinkedList<?> exampleTasks = new LinkedList<Object>();
 
     public static Random random = new Random(1);