package com.xaadin;

import com.vaadin.ui.*;
import org.junit.Test;

import java.net.URL;

import static org.fest.assertions.api.Assertions.assertThat;

public class ParserTest {

	public static final String PARSER_TEST_ALL_COMPONENTS = "ParserTestAllComponents.xml";

	@Test
	public void testParseAllComponents() throws Exception {
		Class[] componentsToCheck = {
			Label.class,
			TextField.class,
			Button.class,
			ComboBox.class,
			Table.class,
			ProgressBar.class,
			TextArea.class,
			Panel.class,
			TabSheet.class,
			VerticalLayout.class,
			HorizontalLayout.class,
			GridLayout.class
		};

		URL url = ClassLoader.getSystemResource(PARSER_TEST_ALL_COMPONENTS);
		VisualTreeNode visualTreeNode = Parser.parse(url, null);

		for (Class clazz : componentsToCheck) {
			String className = clazz.getSimpleName().substring(0, 1).toLowerCase() + clazz.getSimpleName().substring(1);
			Component component = visualTreeNode.findComponentById(className);

			assertThat(component).isNotNull();
			assertThat(component).isOfAnyClassIn(clazz);
		}
	}

}

@@ -266,107 +266,80 @@
 %22;%0A%0A
-%09@Test%0A%09public void testParseAllComponents() throws Exception %7B%0A%09%09Class%5B%5D componentsToCheck = %7B%0A%09%09%09
+    private Class%5B%5D TEST_COMPONENTS_TO_PARSE = new Class%5B%5D%7B%0A            
 Labe
@@ -343,27 +343,36 @@
 abel.class,%0A
-%09%09%09
+            
 TextField.cl
@@ -376,19 +376,28 @@
 .class,%0A
-%09%09%09
+            
 Button.c
@@ -402,19 +402,28 @@
 .class,%0A
-%09%09%09
+            
 ComboBox
@@ -430,19 +430,28 @@
 .class,%0A
-%09%09%09
+            
 Table.cl
@@ -455,19 +455,28 @@
 .class,%0A
-%09%09%09
+            
 Progress
@@ -486,19 +486,28 @@
 .class,%0A
-%09%09%09
+            
 TextArea
@@ -514,19 +514,28 @@
 .class,%0A
-%09%09%09
+            
 Panel.cl
@@ -539,19 +539,28 @@
 .class,%0A
-%09%09%09
+            
 TabSheet
@@ -567,19 +567,28 @@
 .class,%0A
-%09%09%09
+            
 Vertical
@@ -601,19 +601,28 @@
 .class,%0A
-%09%09%09
+            
 Horizont
@@ -637,19 +637,28 @@
 .class,%0A
-%09%09%09
+            
 GridLayo
@@ -670,13 +670,94 @@
 ass%0A
-%09%09%7D;%0A
+    %7D;%0A%0A    @Test%0A%09public void shouldParseAllComponentsInGivenXml() throws Exception %7B
 %0A%09%09U
@@ -909,25 +909,32 @@
 z : 
-componentsToCheck
+TEST_COMPONENTS_TO_PARSE
 ) %7B%0A
@@ -1120,46 +1120,8 @@
 );%0A%0A
-%09%09%09assertThat(component).isNotNull();%0A
 %09%09%09a

Test refactoring (Main reason: Trigger a travis build)