[jbosstools-commits] JBoss Tools SVN: r42610 - in trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test: tests and 1 other directory.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Tue Jul 17 03:44:05 EDT 2012
Author: jjankovi
Date: 2012-07-17 03:44:04 -0400 (Tue, 17 Jul 2012)
New Revision: 42610
Added:
trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/tests/SeamConfigValidationTest.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/CDISeam3AllBotTests.java
Log:
new test SeamConfigValidationTest implemented and added into test suite
Modified: trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/CDISeam3AllBotTests.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/CDISeam3AllBotTests.java 2012-07-17 07:42:59 UTC (rev 42609)
+++ trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/CDISeam3AllBotTests.java 2012-07-17 07:44:04 UTC (rev 42610)
@@ -22,9 +22,10 @@
import org.jboss.tools.cdi.seam3.bot.test.tests.NamedPackagesTest;
import org.jboss.tools.cdi.seam3.bot.test.tests.RequiresAnnotationTest;
import org.jboss.tools.cdi.seam3.bot.test.tests.ResourceOpenOnTest;
+import org.jboss.tools.cdi.seam3.bot.test.tests.SeamConfigClassBaseOpenOnTest;
import org.jboss.tools.cdi.seam3.bot.test.tests.SeamConfigEEOpenOnTest;
-import org.jboss.tools.cdi.seam3.bot.test.tests.SeamConfigClassBaseOpenOnTest;
import org.jboss.tools.cdi.seam3.bot.test.tests.SeamConfigInjectOpenOnTest;
+import org.jboss.tools.cdi.seam3.bot.test.tests.SeamConfigValidationTest;
import org.jboss.tools.cdi.seam3.bot.test.tests.VetoAnnotationTest;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
import org.junit.runner.RunWith;
@@ -50,7 +51,8 @@
MessageLoggerAnnotationTest.class,
SeamConfigClassBaseOpenOnTest.class,
SeamConfigEEOpenOnTest.class,
- SeamConfigInjectOpenOnTest.class
+ SeamConfigInjectOpenOnTest.class,
+ SeamConfigValidationTest.class
})
public class CDISeam3AllBotTests extends AbstractTestSuite {
Added: trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/tests/SeamConfigValidationTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/tests/SeamConfigValidationTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/tests/SeamConfigValidationTest.java 2012-07-17 07:44:04 UTC (rev 42610)
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.seam3.bot.test.tests;
+
+import org.eclipse.core.resources.IMarker;
+import org.jboss.tools.cdi.bot.test.CDIConstants;
+import org.jboss.tools.cdi.seam3.bot.test.base.Seam3TestBase;
+import org.jboss.tools.cdi.seam3.bot.test.util.SeamLibrary;
+import org.jboss.tools.ui.bot.ext.helper.MarkerHelper;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author jjankovi
+ *
+ */
+public class SeamConfigValidationTest extends Seam3TestBase {
+
+ private static String projectName = "seamConfigValidation";
+ private static final String SEAM_CONFIG = "seam-beans.xml";
+ private static IMarker[] markers = null;
+
+ @BeforeClass
+ public static void setup() {
+ importSeam3ProjectWithLibrary(projectName, SeamLibrary.SOLDER_3_1);
+ openSeamConfig();
+ getAllSeamConfigMarkers();
+ assertExpectedCount(markers.length, 4);
+ }
+
+ @Test
+ public void testNonExistedField() {
+
+ /* get marker by its location */
+ IMarker marker = getMarkerByLocation(markers, 8);
+ assertNotNull(marker);
+
+ /* test the message of marker */
+ assertMessageContainsExpectedValue(MarkerHelper.getMarkerMessage(marker),
+ "Cannot resolve field or method");
+ }
+
+ @Test
+ public void testNonExistedConstructor() {
+
+ /* get marker by its location */
+ IMarker marker = getMarkerByLocation(markers, 11);
+ assertNotNull(marker);
+
+ /* test the message of marker */
+ assertMessageContainsExpectedValue(MarkerHelper.getMarkerMessage(marker),
+ "Cannot resolve constructor");
+
+ }
+
+ @Test
+ public void testNonSupportedParameters() {
+
+ /* get marker by its location */
+ IMarker marker = getMarkerByLocation(markers,15);
+ assertNotNull(marker);
+
+ /* test the message of marker */
+ assertMessageContainsExpectedValue(MarkerHelper.getMarkerMessage(marker),
+ "Cannot resolve method");
+
+ }
+
+ @Test
+ public void testNonExistedClass() {
+
+ /* get marker by its location */
+ IMarker marker = getMarkerByLocation(markers, 24);
+ assertNotNull(marker);
+
+ /* test the message of marker */
+ assertMessageContainsExpectedValue(MarkerHelper.getMarkerMessage(marker),
+ "Cannot resolve type");
+
+ }
+
+ private static void getAllSeamConfigMarkers() {
+ markers = getMarkersForResource(SEAM_CONFIG, projectName,
+ CDIConstants.WEBCONTENT, CDIConstants.WEB_INF);
+ }
+
+ private static void openSeamConfig() {
+ packageExplorer.openFile(projectName, CDIConstants.WEBCONTENT,
+ CDIConstants.WEB_INF, SEAM_CONFIG);
+ bot.cTabItem("Source").activate();
+ }
+
+ private static IMarker[] getMarkersForResource(String resource, String ... path) {
+ MarkerHelper markerHelper = new MarkerHelper(resource, path);
+ return markerHelper.getMarkers();
+ }
+
+ private static void assertExpectedCount(int realCount, int expectedCount) {
+ assertTrue("Expected count: " + expectedCount + " real count: " + realCount,
+ realCount == expectedCount);
+ }
+
+ private IMarker getMarkerByLocation(IMarker[] markers, int location) {
+ for (IMarker m : markers) {
+ int markerLocation;
+ try {
+ markerLocation = Integer.parseInt(MarkerHelper.getMarkerLineNumber(m));
+ } catch (NumberFormatException nfe) {
+ return null;
+ }
+ if (markerLocation == location) {
+ return m;
+ }
+ }
+ return null;
+ }
+
+ private void assertMessageContainsExpectedValue(String message,
+ String... expectedValues) {
+ for (String value : expectedValues) {
+ assertContains(value, message);
+ }
+ }
+
+}
More information about the jbosstools-commits
mailing list