Author: akazakov
Date: 2011-07-28 21:15:06 -0400 (Thu, 28 Jul 2011)
New Revision: 33331
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/NPEValidation.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/ValidationExceptionTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/ValidationExceptionTestSuite.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/KBValidationException.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/WebKbPlugin.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatorManager.java
Log:
https://issues.jboss.org/browse/JBIDE-9423
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/NPEValidation.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/NPEValidation.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/NPEValidation.java 2011-07-29
01:15:06 UTC (rev 33331)
@@ -0,0 +1,17 @@
+package org.jboss.jsr299.tck.tests.jbt.validation;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+public class NPEValidation extends UnResolvedClass implements UnResolvedInterface {
+
+ @Inject UnResolvedType t;
+
+ @Inject
+ public UnResolvedType set(UnResolvedType p) {
+ }
+
+ @Produces
+ public UnResolvedType produce() {
+ }
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/NPEValidation.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java 2011-07-29
00:18:02 UTC (rev 33330)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java 2011-07-29
01:15:06 UTC (rev 33331)
@@ -67,6 +67,7 @@
// it could be done here because it is not needed to be enabled back
JavaModelManager.getIndexManager().disable();
+// ValidationExceptionTestSuite suiteAll = new ValidationExceptionTestSuite("CDI
Core Tests");
TestSuite suiteAll = new TestSuite("CDI Core Tests");
suiteAll.addTestSuite(TypeTest.class);
TestSuite suite = new TestSuite("TCK Tests");
@@ -132,6 +133,7 @@
suiteAll.addTestSuite(DisableCDISupportTest.class);
+// suiteAll.addTestSuite(ValidationExceptionTest.class); // This test should be added
last!
return suiteAll;
}
}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/ValidationExceptionTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/ValidationExceptionTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/ValidationExceptionTest.java 2011-07-29
01:15:06 UTC (rev 33331)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.core.test.tck.validation;
+
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class ValidationExceptionTest extends TestCase {
+
+ public void testExceptions() {
+ Set<IStatus> exceptions = ValidationExceptionTestSuite.getExceptions();
+ StringBuffer error = new StringBuffer("The following exceptions were thrown during
project validation:");
+ for (IStatus status : exceptions) {
+ error.append("\r\n").append(status.getException().toString());
+ }
+ assertTrue(error.toString(), exceptions.isEmpty());
+ }
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/ValidationExceptionTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/ValidationExceptionTestSuite.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/ValidationExceptionTestSuite.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/ValidationExceptionTestSuite.java 2011-07-29
01:15:06 UTC (rev 33331)
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.core.test.tck.validation;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.TestSuite;
+
+import org.eclipse.core.runtime.ILogListener;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+import org.jboss.tools.jst.web.kb.validation.KBValidationException;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class ValidationExceptionTestSuite extends TestSuite implements ILogListener {
+
+ private static Map<String, Set<IStatus>> EXCEPTIONS = new HashMap<String,
Set<IStatus>>();
+
+ public ValidationExceptionTestSuite(String name) {
+ super(name);
+ Platform.addLogListener(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.ILogListener#logging(org.eclipse.core.runtime.IStatus,
java.lang.String)
+ */
+ public void logging(IStatus status, String plugin) {
+ Set<IStatus> statuses = EXCEPTIONS.get(plugin);
+ if(statuses==null) {
+ statuses = new HashSet<IStatus>();
+ EXCEPTIONS.put(plugin, statuses);
+ }
+ statuses.add(status);
+ }
+
+ public static boolean hasExceptions() {
+ return !getExceptions().isEmpty();
+ }
+
+ public static Set<IStatus> getExceptions() {
+ Set<IStatus> result = new HashSet<IStatus>();
+ Set<IStatus> statuses = EXCEPTIONS.get(WebKbPlugin.PLUGIN_ID);
+ for (IStatus status : statuses) {
+ Throwable exception = status.getException();
+ if(exception instanceof KBValidationException) {
+ result.add(status);
+ }
+ }
+ return result;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/ValidationExceptionTestSuite.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/WebKbPlugin.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/WebKbPlugin.java 2011-07-29
00:18:02 UTC (rev 33330)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/WebKbPlugin.java 2011-07-29
01:15:06 UTC (rev 33331)
@@ -6,7 +6,6 @@
import java.util.Set;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ISaveContext;
import org.eclipse.core.resources.ISaveParticipant;
import org.eclipse.core.resources.ResourcesPlugin;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatorManager.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatorManager.java 2011-07-29
00:18:02 UTC (rev 33330)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatorManager.java 2011-07-29
01:15:06 UTC (rev 33331)
@@ -25,6 +25,7 @@
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.validation.internal.core.ValidationException;
@@ -38,6 +39,7 @@
import org.jboss.tools.jst.web.kb.validation.IValidatingProjectSet;
import org.jboss.tools.jst.web.kb.validation.IValidationContextManager;
import org.jboss.tools.jst.web.kb.validation.IValidator;
+import org.jboss.tools.jst.web.kb.validation.KBValidationException;
/**
* This Manager invokes all dependent validators that should be invoked in one job.
@@ -52,6 +54,8 @@
public static final String RUNNING = "Running"; //$NON-NLS-1$
private static String STATUS = SLEEPING;
+ private final IStatus EXCEPTION_STATUS = new Status(IStatus.ERROR,
WebKbPlugin.PLUGIN_ID, 0, "EXCEPTION", null); //$NON-NLS-1$ //$NON-NLS-2$
+
public ValidatorManager() {
super();
}
@@ -107,6 +111,10 @@
}
}
return status;
+ } catch(Exception e) {
+ // We need to catch exceptions and wrap them in KBValidationException to let JUnit
tests catch validation exceptions reported to eclipse log.
+ WebKbPlugin.getDefault().logError(new KBValidationException(e.getMessage(), e));
+ return EXCEPTION_STATUS;
} finally {
STATUS = SLEEPING;
}
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/KBValidationException.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/KBValidationException.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/KBValidationException.java 2011-07-29
01:15:06 UTC (rev 33331)
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.jst.web.kb.validation;
+
+/**
+ * Presents an exception that can be thrown during KB validation.
+ *
+ * @author Alexey Kazakov
+ */
+public class KBValidationException extends Exception {
+
+ private static final long serialVersionUID = -1958111192543021067L;
+
+ public KBValidationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/KBValidationException.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain