Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

SWITCHYARD-2194 - Work on validation of Camel Route implementation #395

Closed
wants to merge 1 commit into from

2 participants

@bfitzpat
Collaborator

No description provided.

@bfitzpat
Collaborator

@rcernich Can you take another look and see if this addresses your comments from before? Thanks for all the great feedback - it helped a ton.

@bfitzpat
Collaborator

Ok @rcernich I have updated this PR with a negative test. When I import the project into my local workspace (outside the test) I see 10 switchyard markers, which is what I'm expecting. But when I run the test, I'm getting zero. I have run this thing more times than I can count over the last 12 hours and it fails every time. I'm sure it's something stupid. Any suggestions?

@rcernich
Collaborator

You might try nuking the .project, .classpath, .settings and other . files from the project prior to running your build. That's just a guess. Check the output for any stack traces; maybe something is preventing the builder from running.

@bfitzpat
Collaborator

Ok I'll give that a shot. Thanks!

@bfitzpat
Collaborator

That did the trick. It was the SwitchYard model version in the pom causing the problems. I have that resolved now. Will add a positive test (i.e. a project with all the necessary bits in place and no errors) and then think this is done. Thanks for the help Rob!

@bfitzpat
Collaborator

Ok. Added positive and negative tests and updated to use the adapter instead of the custom file utility. All seems good with the world. Let me know what you think when you get a chance @rcernich! :)

@rcernich
Collaborator

pushed

@rcernich rcernich closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 982 additions and 4 deletions.
  1. +3 −0  eclipse/plugins/org.switchyard.tools.ui/plugin.properties
  2. +32 −0 eclipse/plugins/org.switchyard.tools.ui/plugin.xml
  3. +24 −1 eclipse/plugins/org.switchyard.tools.ui/src/org/switchyard/tools/ui/i18n/Messages.java
  4. +11 −0 eclipse/plugins/org.switchyard.tools.ui/src/org/switchyard/tools/ui/i18n/messages.properties
  5. +490 −0 eclipse/plugins/org.switchyard.tools.ui/src/org/switchyard/tools/ui/validation/CamelComponentConstraint.java
  6. +49 −2 eclipse/plugins/org.switchyard.tools.ui/src/org/switchyard/tools/ui/validation/ValidationProblem.java
  7. +70 −1 eclipse/tests/org.switchyard.tools.ui.tests/src/org/switchyard/tools/ui/tests/SwitchYardValidatorTest.java
  8. +83 −0 eclipse/tests/org.switchyard.tools.ui.tests/test-data/validator-tests/camel-route-tests/pom.xml
  9. +12 −0 ...lidator-tests/camel-route-tests/src/main/java/com/switchyard/camel_route_tests/BrokenCamelServiceRoute.java
  10. +20 −0 ...ata/validator-tests/camel-route-tests/src/main/java/com/switchyard/camel_route_tests/CamelServiceRoute.java
  11. +16 −0 ...idator-tests/camel-route-tests/src/main/java/com/switchyard/camel_route_tests/CorrectCamelServiceRoute.java
  12. +7 −0 ...t-data/validator-tests/camel-route-tests/src/main/java/com/switchyard/camel_route_tests/MyFirstService.java
  13. +7 −0 ...-data/validator-tests/camel-route-tests/src/main/java/com/switchyard/camel_route_tests/MySecondService.java
  14. +13 −0 ...ta/validator-tests/camel-route-tests/src/main/java/com/switchyard/camel_route_tests/NestedServiceRoute.java
  15. +13 −0 ...lidator-tests/camel-route-tests/src/main/java/com/switchyard/camel_route_tests/ParentCamelServiceRoute.java
  16. +6 −0 ...switchyard.tools.ui.tests/test-data/validator-tests/camel-route-tests/src/main/resources/META-INF/beans.xml
  17. +101 −0 ...hyard.tools.ui.tests/test-data/validator-tests/camel-route-tests/src/main/resources/META-INF/switchyard.xml
  18. +8 −0 ...g.switchyard.tools.ui.tests/test-data/validator-tests/camel-route-tests/src/main/resources/correctroute.xml
  19. +11 −0 ...ests/org.switchyard.tools.ui.tests/test-data/validator-tests/camel-route-tests/src/main/resources/route.xml
  20. +6 −0 ...yard.tools.ui.tests/test-data/validator-tests/wiring-validation-tests/src/test/resources/META-INF/beans.xml
View
3  eclipse/plugins/org.switchyard.tools.ui/plugin.properties
@@ -45,6 +45,7 @@ wizardDescription.genericArtifactReference = Adds an<artifact> element to the pr
projectValidator.switchyardConfiguration = SwitchYard Configuration Validator
constraintCategoryName.sca = SwitchYard SCA Constraints
constraintCategoryName.bean = SwitchYard Bean Component Constraints
+constraintCategoryName.camel = SwitchYard Camel Component Constraints
constraintCategory.childConstraintName.serviceWiring = Service Wiring Constraints
constraintCategory.childConstraintMessage.serviceWiring = Service wiring constraints.
constraintCategory.childConstraintName.serviceInterface = Service Interface Not Defined
@@ -52,6 +53,8 @@ constraintCategory.childConstraintMessage.serviceInterface = No interface is def
constraintCategory.childConstraintDescription.serviceInterface = All services and references must define an interface.
constraintCategory.childConstraintName.beanComponent = Bean Component Constraints
constraintCategory.childConstraintMessage.beanComponent = Bean component constraints.
+constraintCategory.childConstraintName.camelRouteComponent = Camel Route Component Constraints
+constraintCategory.childConstraintMessage.camelRouteComponent = Camel Route component constraints.
extensionPointName.switchyardComponent = SwitchYardComponent
extensionPointName.repositorySupport = RepositorySupport
extensionPointName.switchyardTestMixIn = switchYardTestMixIn
View
32 eclipse/plugins/org.switchyard.tools.ui/plugin.xml
@@ -1463,6 +1463,10 @@
category="org.switchyard.tools.validationCategory/bean"
context="org.switchyard.tools.validationContext">
</binding>
+ <binding
+ category="org.switchyard.tools.validationCategory/camel"
+ context="org.switchyard.tools.validationContext">
+ </binding>
</extension>
<extension
point="org.eclipse.emf.validation.constraintProviders">
@@ -1474,6 +1478,10 @@
id="org.switchyard.tools.validationCategory/bean"
name="%constraintCategoryName.bean">
</category>
+ <category
+ id="org.switchyard.tools.validationCategory/camel"
+ name="%constraintCategoryName.camel">
+ </category>
<constraintProvider
cache="true">
<package
@@ -1541,6 +1549,30 @@
</constraint>
</constraints>
</constraintProvider>
+ <constraintProvider
+ cache="true">
+ <package
+ namespaceUri="urn:switchyard-component-camel:config:2.0">
+ </package>
+ <constraints
+ categories="org.switchyard.tools.validationCategory/camel">
+ <constraint
+ class="org.switchyard.tools.ui.validation.CamelComponentConstraint"
+ id="org.switchyard.tools.validation.constraint.component/camel/route"
+ isEnabledByDefault="true"
+ lang="Java"
+ mode="Batch"
+ name="%constraintCategory.childConstraintName.camelRouteComponent"
+ statusCode="0">
+ <message>
+ %constraintCategory.childConstraintMessage.camelRouteComponent
+ </message>
+ <target
+ class="CamelImplementationType">
+ </target>
+ </constraint>
+ </constraints>
+ </constraintProvider>
</extension>
<extension point="org.eclipse.core.expressions.propertyTesters">
View
25 eclipse/plugins/org.switchyard.tools.ui/src/org/switchyard/tools/ui/i18n/Messages.java
@@ -759,6 +759,8 @@
public static String ValidationProblem_UnimplementedServiceDeclaration;
public static String ValidationProblem_UnresolvableBeanClass;
+
+ public static String ValidationProblem_UnresolvableCamelRouteClass;
public static String ValidationProblem_UnresolvableServiceInterface;
@@ -766,6 +768,8 @@
public static String ValidationProblem_UnspecifiedBeanClass;
+ public static String ValidationProblem_UnspecifiedCamelRouteClass;
+
public static String ValidationProblem_UnusedCapability;
public static String ValidationProblem_UnusedComponentReference;
@@ -813,7 +817,25 @@
public static String WSDLPortTypeSelectionDialog_validateMessage_SelectWSDLFileAndPortType;
public static String InterfaceControl_DefaultESBInterface_ServiceName;
-
+
+ public static String ValidationProblem_CamelJavaClassDoesNotExtendRouteBuilder;
+
+ public static String ValidationProblem_NoCamelXMLSpecified;
+
+ public static String ValidationProblem_CamelImplementationTypeMissing;
+
+ public static String ValidationProblem_InvalidCamelRouteOperationReference;
+
+ public static String ValidationProblem_CamelRouteOperationNotFoundAsReference;
+
+ public static String ValidationProblem_CamelRouteOperationNotFoundAsService;
+
+ public static String ValidationProblem_CamelRouteOperationRequiredNotSpecified;
+
+ public static String ValidationProblem_CamelXMLNotFound;
+
+ public static String ValidationProblem_CamelRouteMoreThanOneFromFound;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
@@ -822,3 +844,4 @@
private Messages() {
}
}
+
View
11 eclipse/plugins/org.switchyard.tools.ui/src/org/switchyard/tools/ui/i18n/messages.properties
@@ -365,14 +365,25 @@ ValidationProblem_UnboundService=Unbound Service: The service "{0}" is not bound
ValidationProblem_UnhandledFault=Unhandled fault: The source operation "{0}" must declare a fault.
ValidationProblem_UnimplementedServiceDeclaration=Unimplemented Service Declaration: Service "{0}" defined by component "{1}" is not provided by the component's implementation.
ValidationProblem_UnresolvableBeanClass=Unresolvable Bean Class: "{0}" cannot be resolved for "{1}".
+ValidationProblem_UnresolvableCamelRouteClass=Unresolvable Camel Route Class: "{0}" cannot be resolved for "{1}".
ValidationProblem_UnresolvableServiceInterface=Unresolvable Service Interface: The specified interface does not exist on the project classpath.
ValidationProblem_UnresolvedReference=Unresolved Reference: The component reference "{0}" cannot be resolved to a service.
ValidationProblem_UnspecifiedBeanClass=Unspecified Bean Class: "{0}" component is implemented as a bean, but no class is specified.
+ValidationProblem_UnspecifiedCamelRouteClass=Unspecified Camel Route Class: "{0}" component is implemented as a Java Camel Route, but no class is specified.
ValidationProblem_UnusedCapability=Unused Capability: The "{0}" capability is configured on the project, but is not required by any SwitchYard binding or implementation types used in the project.
ValidationProblem_UnusedComponentReference=Unused Component Reference: Reference "{0}" defined by component "{1}" is not used by the component's implementation.
ValidationProblem_UnusedReference=Unused Reference: The reference "{0}" is unused (i.e. it promotes no component references).
ValidationProblem_UnusedReturnValue=Unused Return Value: The source operation "{0}" is in-only, but the target is in-out.
+ValidationProblem_CamelJavaClassDoesNotExtendRouteBuilder=Camel Java Implementation Issue\: "{0}" class does not extend org.apache.camel.builder.RouteBuilder
+ValidationProblem_NoCamelXMLSpecified=No Camel route XML specified for component "{0}".
+ValidationProblem_CamelImplementationTypeMissing=Incomplete Implementation Definition\: A Camel implementation is specified for component "{0}" but neither a Java or XML route is selected.
ValidationProblem_ValidateProblem=ValidationProblem.code
+ValidationProblem_InvalidCamelRouteOperationReference=The operation specified in the SwitchYard URI for the Camel route in component "{0}" is "{1}". The operation must be specified in the format "?operationName=[operation-name]".
+ValidationProblem_CamelRouteOperationNotFoundAsReference=The referenced operation "{0}" is not available an operation from reference "{1}".
+ValidationProblem_CamelRouteOperationNotFoundAsService=The referenced operation "{0}" is not available an operation from service "{1}".
+ValidationProblem_CamelRouteOperationRequiredNotSpecified=Component interface "{0}" has more than one available operation. The SwitchYard URI specified in the Camel route should explicitly call out to a specific operation in the format "?operationName=[operation-name]".
+ValidationProblem_CamelXMLNotFound=Camel route XML file specified "{0}" not found for component "{1}".
+ValidationProblem_CamelRouteMoreThanOneFromFound=Multiple "FROM" references found in Camel route for component "{0}". SwitchYard only supports one "FROM" per component implementation route.
WiringValidationContext_statusMessage_errorLoadingServiceInterfaceMetadata=Error loading service interface meta-data. Interface compatibility cannot be verified.
WSDL2JavaOptionsWizardPage_buttonBrowse=Browse...
WSDL2JavaOptionsWizardPage_checkboxLabelCreateWrapperForMessageParts=Create wrapper for message parts
View
490 ...pse/plugins/org.switchyard.tools.ui/src/org/switchyard/tools/ui/validation/CamelComponentConstraint.java
@@ -0,0 +1,490 @@
+/*************************************************************************************
+ * Copyright (c) 2014 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.switchyard.tools.ui.validation;
+
+import static org.switchyard.tools.ui.validation.ValidationProblem.CamelImplementationIncomplete;
+import static org.switchyard.tools.ui.validation.ValidationProblem.CamelJavaUnresolvableClass;
+import static org.switchyard.tools.ui.validation.ValidationProblem.CamelJavaUnspecifiedClass;
+import static org.switchyard.tools.ui.validation.ValidationProblem.CamelJavaWrongSuperclass;
+import static org.switchyard.tools.ui.validation.ValidationProblem.CamelRouteOperationNotFoundAsReference;
+import static org.switchyard.tools.ui.validation.ValidationProblem.CamelRouteOperationNotFoundAsService;
+import static org.switchyard.tools.ui.validation.ValidationProblem.CamelRouteOperationRequiredNotSpecified;
+import static org.switchyard.tools.ui.validation.ValidationProblem.CamelXMLUnspecified;
+import static org.switchyard.tools.ui.validation.ValidationProblem.InvalidCamelRouteOperationReference;
+import static org.switchyard.tools.ui.validation.ValidationProblem.MissingReferenceDeclaration;
+import static org.switchyard.tools.ui.validation.ValidationProblem.MissingServiceDeclaration;
+import static org.switchyard.tools.ui.validation.ValidationProblem.CamelXMLNotFound;
+import static org.switchyard.tools.ui.validation.ValidationProblem.CamelRouteMoreThanOneFromFound;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.validation.AbstractModelConstraint;
+import org.eclipse.emf.validation.EMFEventType;
+import org.eclipse.emf.validation.IValidationContext;
+import org.eclipse.emf.validation.model.ConstraintStatus;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeHierarchy;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.soa.sca.sca1_1.model.sca.Component;
+import org.eclipse.soa.sca.sca1_1.model.sca.ComponentReference;
+import org.eclipse.soa.sca.sca1_1.model.sca.ComponentService;
+import org.eclipse.soa.sca.sca1_1.model.sca.Interface;
+import org.eclipse.soa.sca.sca1_1.model.sca.JavaInterface;
+import org.switchyard.metadata.ServiceInterface;
+import org.switchyard.tools.models.switchyard1_0.camel.CamelImplementationType;
+import org.switchyard.tools.models.switchyard1_0.switchyard.EsbInterface;
+import org.switchyard.tools.ui.PlatformResourceAdapterFactory;
+import org.switchyard.tools.ui.SwitchYardModelUtils;
+import org.switchyard.tools.ui.validation.SwitchYardProjectValidator.ValidationAdapter;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * CamelComponentConstraint
+ *
+ * <p/>
+ * Validates details specific to Camel components.
+ * Specifically if it's a Camel Java implementation, it verifies that the class exists
+ * and if it points "to" or "from" particular services or references that those match
+ * what's in the switchyard.xml.
+ * Same for Camel XML implementations, where it verifies the route file is accessible
+ * and that the referenced services and references (to/from) exist in the switchyard
+ * configuration.
+ */
+public class CamelComponentConstraint extends AbstractModelConstraint {
+
+ private static final String CONFIGURE_METHOD = "configure"; //$NON-NLS-1$
+ private static final String TO_TAG = "to"; //$NON-NLS-1$
+ private static final String URI_ATTRIBUTE = "uri"; //$NON-NLS-1$
+ private static final String FROM_TAG = "from"; //$NON-NLS-1$
+
+ @Override
+ public IStatus validate(IValidationContext ctx) {
+ EObject eObj = ctx.getTarget();
+ EMFEventType eType = ctx.getEventType();
+
+ // In the case of batch mode.
+ if (eType == EMFEventType.NULL) {
+ if (eObj instanceof CamelImplementationType) {
+ CamelImplementationType camelImpl = (CamelImplementationType) eObj;
+ if (camelImpl.getJava() != null) {
+ return validateJava(ctx, camelImpl);
+ } else if (camelImpl.getXml() != null) {
+ return validateXML(ctx, camelImpl);
+ } else {
+ Component component = (Component) camelImpl.eContainer();
+ return ConstraintStatus.createStatus(ctx, component, null, CamelImplementationIncomplete.getSeverity(),
+ CamelImplementationIncomplete.ordinal(), CamelImplementationIncomplete.getMessage(), component.getName());
+ }
+ }
+ // } else { // In the case of live mode.
+ }
+
+ return ctx.createSuccessStatus();
+ }
+
+ private IStatus validateXML(IValidationContext ctx, CamelImplementationType camelImpl) {
+ final Component component = (Component) camelImpl.eContainer();
+ final String xmlName = camelImpl.getXml().getPath();
+ if (xmlName == null || xmlName.trim().isEmpty()) {
+ return ConstraintStatus.createStatus(ctx, component, null, CamelXMLUnspecified.getSeverity(),
+ CamelXMLUnspecified.ordinal(), CamelXMLUnspecified.getMessage(), component.getName());
+ }
+ final List<IStatus> statuses = new ArrayList<IStatus>();
+ final ValidationAdapter adapter = (ValidationAdapter) EcoreUtil.getAdapter(camelImpl.eResource().eAdapters(),
+ ValidationAdapter.class);
+
+ final IJavaProject javaProject = adapter.getJavaProject();
+ IResource xmlFileResource;
+
+ /* look in any of the resource folders for the first instance of the xml file */
+ xmlFileResource = PlatformResourceAdapterFactory.getFileForObject(camelImpl, javaProject.getProject());
+ if (xmlFileResource == null) {
+ return ConstraintStatus.createStatus(ctx, component, null, CamelXMLNotFound.getSeverity(),
+ CamelXMLNotFound.ordinal(), CamelXMLNotFound.getMessage(), xmlName, component.getName());
+ }
+
+ if (xmlFileResource != null && xmlFileResource instanceof IFile) {
+ IFile xmlFile = (IFile) xmlFileResource;
+ IPath location = xmlFile.getLocation();
+ java.io.File file = location.toFile();
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db;
+ try {
+ db = dbf.newDocumentBuilder();
+ Document document = db.parse(file);
+ NodeList fromTags = document.getElementsByTagName(FROM_TAG);
+
+ if (fromTags.getLength() > 0) {
+ if (fromTags.getLength() > 1) {
+ // only one "from" supported per component
+ return ConstraintStatus.createStatus(ctx, component, null, CamelRouteMoreThanOneFromFound.getSeverity(),
+ CamelRouteMoreThanOneFromFound.ordinal(), CamelRouteMoreThanOneFromFound.getMessage(), component.getName());
+ }
+ for (int i = 0; i < fromTags.getLength(); i++) {
+ Node fromTag = fromTags.item(i);
+ Node uriAttribute = fromTag.getAttributes().getNamedItem(URI_ATTRIBUTE);
+ if (uriAttribute != null) {
+ String switchyardString = uriAttribute.getNodeValue();
+ IStatus status = verifyURI(switchyardString, ctx, component, true, javaProject);
+ if (status != Status.OK_STATUS) {
+ statuses.add(status);
+ }
+ }
+ }
+ }
+
+ NodeList toTags = document.getElementsByTagName(TO_TAG);
+ if (toTags.getLength() > 0) {
+ for (int i = 0; i < toTags.getLength(); i++) {
+ Node fromTag = toTags.item(i);
+ Node uriAttribute = fromTag.getAttributes().getNamedItem(URI_ATTRIBUTE);
+ if (uriAttribute != null) {
+ String switchyardString = uriAttribute.getNodeValue();
+ IStatus status = verifyURI(switchyardString, ctx, component, false, javaProject);
+ if (status != Status.OK_STATUS) {
+ statuses.add(status);
+ }
+ }
+ }
+ }
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ } catch (SAXException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ if (statuses.isEmpty()) {
+ return ctx.createSuccessStatus();
+ }
+ return ConstraintStatus.createMultiStatus(ctx, statuses);
+ }
+
+ private IStatus validateJava(IValidationContext ctx, CamelImplementationType camelImpl) {
+ final Component component = (Component) camelImpl.eContainer();
+ final String className = camelImpl.getJava().getClass_();
+ if (className == null || className.length() == 0) {
+ return ConstraintStatus.createStatus(ctx, component, null, CamelJavaUnspecifiedClass.getSeverity(),
+ CamelJavaUnspecifiedClass.ordinal(), CamelJavaUnspecifiedClass.getMessage(), component.getName());
+ }
+ final ValidationAdapter adapter = (ValidationAdapter) EcoreUtil.getAdapter(camelImpl.eResource().eAdapters(),
+ ValidationAdapter.class);
+ final IJavaProject javaProject = adapter.getJavaProject();
+ try {
+ final IType javaClass = javaProject == null ? null : javaProject.findType(className);
+ if (javaClass == null) {
+ return ConstraintStatus.createStatus(ctx, component, null, CamelJavaUnresolvableClass.getSeverity(),
+ CamelJavaUnresolvableClass.ordinal(), CamelJavaUnresolvableClass.getMessage(), className,
+ component.getName());
+ }
+ final List<IStatus> statuses = new ArrayList<IStatus>();
+ adapter.addDependency(javaClass.getResource());
+ statuses.add(validateRouteClass(camelImpl, className, javaProject, ctx, component));
+ return ConstraintStatus.createMultiStatus(ctx, statuses);
+ } catch (JavaModelException e) {
+ return ConstraintStatus
+ .createStatus(ctx, component, null, CamelJavaUnresolvableClass.getSeverity(),
+ CamelJavaUnresolvableClass.ordinal(), CamelJavaUnresolvableClass.getMessage(), className,
+ component.getName());
+ }
+ }
+
+ private boolean canFindSuperClass(IType searchType, String superClassName) throws JavaModelException {
+ if (searchType.getSuperclassName() != null
+ && searchType.getSuperclassName().contentEquals(superClassName)) {
+ return true;
+ }
+ ITypeHierarchy supertypehierarchy = searchType.newSupertypeHierarchy(new NullProgressMonitor());
+ IType supertype = supertypehierarchy.getSuperclass(searchType);
+ if (supertype != null) {
+ return canFindSuperClass(supertype, superClassName);
+ }
+ return false;
+ }
+
+ private IStatus validateRouteClass(CamelImplementationType impl, String className, final IJavaProject javaProject, IValidationContext ctx, Component component) {
+ final List<IStatus> statuses = new ArrayList<IStatus>();
+
+ try {
+ final IType javaClass = javaProject == null ? null : javaProject.findType(className);
+ if (javaClass != null) {
+ boolean extendsRouteBuilder = canFindSuperClass(javaClass, "RouteBuilder"); //$NON-NLS-1$
+ if (!extendsRouteBuilder) {
+ return ConstraintStatus
+ .createStatus(ctx, component, null, CamelJavaWrongSuperclass.getSeverity(),
+ CamelJavaWrongSuperclass.ordinal(), CamelJavaWrongSuperclass.getMessage(), className,
+ component.getName());
+ }
+ IMethod[] methods = javaClass.getMethods();
+ IMethod configureMethod = null;
+ if (methods != null && methods.length > 0) {
+ for (int i = 0; i < methods.length; i++) {
+ IMethod method = methods[i];
+ if (method.getElementName().contentEquals(CONFIGURE_METHOD)) {
+ configureMethod = method;
+ break;
+ }
+ }
+ }
+ if (configureMethod != null) {
+ String source = configureMethod.getSource();
+
+
+ // first pass just to make sure we're dealing with one FROM
+ String tryThis = ".?from\\(\".*?\"\\)(.?)"; //$NON-NLS-1$
+ Pattern fromPattern = Pattern.compile(tryThis); //$NON-NLS-1$
+ Matcher fromMatcher = fromPattern.matcher(source);
+ int fromCount = 0;
+ while (fromMatcher.find()) {
+ fromCount++;
+ }
+ if (fromCount > 1) {
+ // only one "from" supported per component
+ return ConstraintStatus.createStatus(ctx, component, null, CamelRouteMoreThanOneFromFound.getSeverity(),
+ CamelRouteMoreThanOneFromFound.ordinal(), CamelRouteMoreThanOneFromFound.getMessage(), component.getName());
+ }
+
+ // now process the FROMs and TOs to verify URIs
+ String tryThisNext = ".?(from|to)\\(\".*?\"\\)(.?)"; //$NON-NLS-1$
+ Pattern fromToPattern = Pattern.compile(tryThisNext);
+ Matcher fromToMatcher = fromToPattern.matcher(source);
+ while (fromToMatcher.find()) {
+ String fromToString = source.substring(fromToMatcher.start(), fromToMatcher.end());
+ Pattern switchyardPattern = Pattern.compile("switchyard://.*\""); //$NON-NLS-1$
+ Matcher switchyardMatcher = switchyardPattern.matcher(fromToString);
+ boolean isFrom = (fromToString.matches(tryThis)); //$NON-NLS-1$
+ while (switchyardMatcher.find()) {
+ String switchyardString = fromToString.substring(switchyardMatcher.start(), switchyardMatcher.end() - 1);
+ IStatus status = verifyURI(switchyardString, ctx, component, isFrom, javaProject);
+ if (status != Status.OK_STATUS) {
+ statuses.add(status);
+ }
+ }
+ }
+ }
+ }
+ } catch (JavaModelException e) {
+ return ConstraintStatus
+ .createStatus(ctx, component, null, CamelJavaUnresolvableClass.getSeverity(),
+ CamelJavaUnresolvableClass.ordinal(), CamelJavaUnresolvableClass.getMessage(), className,
+ component.getName());
+ }
+
+ if (statuses.isEmpty()) {
+ return ctx.createSuccessStatus();
+ }
+ return ConstraintStatus.createMultiStatus(ctx, statuses);
+ }
+
+ private ComponentService findService(String serviceName, Component component) {
+ if (component != null && !component.getService().isEmpty()) {
+ EList<ComponentService> list = component.getService();
+ Iterator<ComponentService> iter = list.iterator();
+ while (iter.hasNext()) {
+ ComponentService cs = iter.next();
+ if (cs.getName().equals(serviceName)) {
+ return cs;
+ }
+ }
+ }
+ return null;
+ }
+
+ private ComponentReference findReference(String referenceName, Component component) {
+ if (component != null && !component.getReference().isEmpty()) {
+ EList<ComponentReference> list = component.getReference();
+ Iterator<ComponentReference> iter = list.iterator();
+ while (iter.hasNext()) {
+ ComponentReference cr = iter.next();
+ if (cr.getName().equals(referenceName)) {
+ return cr;
+ }
+ }
+ }
+ return null;
+ }
+
+ private IStatus verifyURI(String uriValue, IValidationContext ctx, Component component, boolean isFrom,
+ IJavaProject javaProject) {
+ final List<IStatus> statuses = new ArrayList<IStatus>();
+
+ try {
+ // switchyard://[service-name]?operationName=[operation-name]
+ URI testURI = new URI(uriValue);
+ final String scheme = testURI.getScheme();
+ ComponentService serviceFound = null;
+ ComponentReference referenceFound = null;
+
+ // does the URI start with "switchyard"? if not, ignore it
+ if (scheme.equals("switchyard")) {
+
+ // the authority is equivalent to the referenced service or reference
+ final String schemeName = testURI.getAuthority();
+
+ if (isFrom) {
+ // verify that the named service exists in the component
+ final String serviceName = schemeName;
+ serviceFound = findService(serviceName, component);
+ if (serviceFound == null) {
+ statuses.add(ConstraintStatus
+ .createStatus(ctx, component, null, MissingServiceDeclaration.getSeverity(),
+ MissingServiceDeclaration.ordinal(), MissingServiceDeclaration.getMessage(), serviceName,
+ component.getName()));
+ }
+ } else {
+ // verify that the named reference exists in the component
+ final String referenceName = schemeName;
+ referenceFound = findReference(referenceName, component);
+ if (referenceFound == null) {
+ statuses.add(ConstraintStatus
+ .createStatus(ctx, component, null, MissingReferenceDeclaration.getSeverity(),
+ MissingReferenceDeclaration.ordinal(), MissingReferenceDeclaration.getMessage(), referenceName,
+ component.getName()));
+ }
+ }
+
+ final String query = testURI.getQuery();
+ String operationName = null;
+ if (query != null) {
+ int posEquals = query.indexOf('=');
+ if (query != null && posEquals > -1) {
+ operationName = query.substring(posEquals + 1);
+ } else {
+ // invalid - operation name must be in the format "operationName=[operation-name]"
+ statuses.add(ConstraintStatus
+ .createStatus(ctx, component, null, InvalidCamelRouteOperationReference.getSeverity(),
+ InvalidCamelRouteOperationReference.ordinal(), InvalidCamelRouteOperationReference.getMessage(),
+ component.getName(), query));
+ }
+ }
+ if (!isFrom && operationName != null && referenceFound != null) {
+ // verify that the referenced interface includes the operation
+ if (!checkInterfaceForOperation(referenceFound.getInterface(), operationName, javaProject)) {
+ statuses.add(ConstraintStatus
+ .createStatus(ctx, component, null, CamelRouteOperationNotFoundAsReference.getSeverity(),
+ CamelRouteOperationNotFoundAsReference.ordinal(), CamelRouteOperationNotFoundAsReference.getMessage(), operationName,
+ referenceFound.getName()));
+ }
+ } else if (isFrom && operationName != null && serviceFound != null) {
+ // verify that the referenced interface includes the operation
+ if (!checkInterfaceForOperation(serviceFound.getInterface(), operationName, javaProject)) {
+ statuses.add(ConstraintStatus
+ .createStatus(ctx, component, null, CamelRouteOperationNotFoundAsService.getSeverity(),
+ CamelRouteOperationNotFoundAsService.ordinal(), CamelRouteOperationNotFoundAsService.getMessage(), operationName,
+ serviceFound.getName()));
+ }
+ }
+ if (operationName == null && referenceFound != null) {
+ // verify that the referenced interface has zero or one operation.
+ // if more, it's invalid and an operation name must be specified
+ if (!checkInterfaceForNumberOfOperations(referenceFound.getInterface(), javaProject)) {
+ statuses.add(ConstraintStatus
+ .createStatus(ctx, component, null, CamelRouteOperationRequiredNotSpecified.getSeverity(),
+ CamelRouteOperationRequiredNotSpecified.ordinal(), CamelRouteOperationRequiredNotSpecified.getMessage(),
+ component.getName()));
+ }
+ }
+ }
+
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+
+ if (statuses.isEmpty()) {
+ return ctx.createSuccessStatus();
+ }
+ return ConstraintStatus.createMultiStatus(ctx, statuses);
+ }
+
+ private boolean checkInterfaceForOperation(Interface intfc, String opName, IJavaProject javaProject) {
+ try {
+ if (intfc instanceof JavaInterface) {
+ JavaInterface javaIntfc = (JavaInterface) intfc;
+ String className = javaIntfc.getInterface();
+ final IType javaClass = javaProject == null ? null : javaProject.findType(className);
+ if (javaClass != null && javaClass.getMethods() != null && javaClass.getMethods().length > 0) {
+ for (int i = 0; i < javaClass.getMethods().length; i++) {
+ IMethod method = javaClass.getMethods()[i];
+ if (method.getElementName().equals(opName)) {
+ return true;
+ }
+ }
+ }
+ } else if (intfc instanceof EsbInterface) {
+ // ignore operation names for ESB?
+ return true;
+ } else {
+ ServiceInterface serviceIntfc = SwitchYardModelUtils.getServiceInterface(intfc);
+ if (serviceIntfc != null && serviceIntfc.getOperations() != null) {
+ if (serviceIntfc.getOperation(opName) != null) {
+ return true;
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ private boolean checkInterfaceForNumberOfOperations(Interface intfc, IJavaProject javaProject) {
+ // if we have zero or one operation, no operation name is required
+ try {
+ if (intfc instanceof JavaInterface) {
+ JavaInterface javaIntfc = (JavaInterface) intfc;
+ String className = javaIntfc.getInterface();
+ final IType javaClass = javaProject == null ? null : javaProject.findType(className);
+ if (javaClass != null && javaClass.getMethods() != null && javaClass.getMethods().length < 2) {
+ return true;
+ }
+ } else if (intfc instanceof EsbInterface) {
+ // ignore operation names for ESB?
+ return true;
+ } else {
+ ServiceInterface serviceIntfc = SwitchYardModelUtils.getServiceInterface(intfc);
+ if (serviceIntfc != null && serviceIntfc.getOperations() != null) {
+ if (serviceIntfc.getOperations().size() < 2) {
+ return true;
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+}
View
51 eclipse/plugins/org.switchyard.tools.ui/src/org/switchyard/tools/ui/validation/ValidationProblem.java
@@ -88,7 +88,9 @@
Messages.ValidationProblem_UnspecifiedBeanClass,
IStatus.ERROR, false),
/** Class cannot be resolved for implementation.bean. */
- BeanUnresolvableClass(Messages.ValidationProblem_UnresolvableBeanClass, IStatus.ERROR, false),
+ BeanUnresolvableClass(Messages.ValidationProblem_UnresolvableBeanClass,
+ IStatus.ERROR, false),
+
/** Service specified on implementation, but not in switchyard.xml. */
MissingServiceDeclaration(
Messages.ValidationProblem_MissingComponentService,
@@ -120,7 +122,52 @@
/** Reference is not used by implementation. */
UnusedReferenceDeclaration(
Messages.ValidationProblem_UnusedComponentReference,
- IStatus.WARNING, false);
+ IStatus.WARNING, false),
+
+ /** No class specified on implementation.camel (java). */
+ CamelJavaUnspecifiedClass(
+ Messages.ValidationProblem_UnspecifiedCamelRouteClass,
+ IStatus.ERROR, false),
+ /** Class cannot be resolved for implementation.camel (java). */
+ CamelJavaUnresolvableClass(Messages.ValidationProblem_UnresolvableCamelRouteClass,
+ IStatus.ERROR, false),
+ /** Camel Java route class for implementation.camel (java) does not extend RouteBuilder. */
+ CamelJavaWrongSuperclass(Messages.ValidationProblem_CamelJavaClassDoesNotExtendRouteBuilder,
+ IStatus.ERROR, false),
+ /** No XML specified on implementation.camel (xml). */
+ CamelXMLUnspecified(
+ Messages.ValidationProblem_NoCamelXMLSpecified,
+ IStatus.ERROR, false),
+ /** No XML or Java route specified on implementation.camel (xml). */
+ CamelImplementationIncomplete(
+ Messages.ValidationProblem_CamelImplementationTypeMissing,
+ IStatus.ERROR, false),
+ /** The operation specified in the route for a implementation.camel (xml) is
+ * incorrect. */
+ InvalidCamelRouteOperationReference(
+ Messages.ValidationProblem_InvalidCamelRouteOperationReference,
+ IStatus.ERROR, false),
+ /** The reference specified in the camel route URI is not available in the component. */
+ CamelRouteOperationNotFoundAsReference(
+ Messages.ValidationProblem_CamelRouteOperationNotFoundAsReference,
+ IStatus.ERROR, false),
+ /** The service specified in the camel route URI is not available in the component. */
+ CamelRouteOperationNotFoundAsService(
+ Messages.ValidationProblem_CamelRouteOperationNotFoundAsService,
+ IStatus.ERROR, false),
+ /** The referenced service or reference has multiple operations available. Route URI should
+ * specify one. */
+ CamelRouteOperationRequiredNotSpecified(
+ Messages.ValidationProblem_CamelRouteOperationRequiredNotSpecified,
+ IStatus.WARNING, false),
+ /** XML specified on implementation.camel (xml) not found. */
+ CamelXMLNotFound(
+ Messages.ValidationProblem_CamelXMLNotFound,
+ IStatus.ERROR, false),
+ /** Route for implementation.camel specifies more than a single "from". */
+ CamelRouteMoreThanOneFromFound(
+ Messages.ValidationProblem_CamelRouteMoreThanOneFromFound,
+ IStatus.ERROR, false);
/** Used to identify the problem code attribute in IMarker objects. */
public static final String PROBLEM_CODE = Messages.ValidationProblem_ValidateProblem;
View
71 eclipse/tests/org.switchyard.tools.ui.tests/src/org/switchyard/tools/ui/tests/SwitchYardValidatorTest.java
@@ -24,7 +24,7 @@
*
* Tests the validator logic.
*
- * @author Rob Cernich
+ * @author Rob Cernich, Brian Fitzpatrick
*/
@SuppressWarnings("restriction")
public class SwitchYardValidatorTest extends AbstractMavenProjectTestCase {
@@ -98,4 +98,73 @@ public void testWiringValidation() throws Exception {
assertEquals(WorkspaceHelpers.toString(markers), 23, markers.length);
}
+ /**
+ * Tests Camel route validation.
+ *
+ * @throws Exception if a failure occurs.
+ */
+ public void testCamelRouteValidation() throws Exception {
+ IProject project = importProject("test-data/validator-tests/camel-route-tests/pom.xml");
+ waitForJobsToComplete();
+
+ project.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
+ waitForJobsToComplete();
+ project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
+ waitForJobsToComplete();
+
+ IFile switchYardFile = project.getFile("src/main/resources/META-INF/switchyard.xml");
+ assertTrue("switchyard.xml does not exist.", switchYardFile != null && switchYardFile.exists());
+
+ IMarker[] markers = switchYardFile.findMarkers(SwitchYardProjectValidator.SWITCHYARD_MARKER_ID, true,
+ IFile.DEPTH_ZERO);
+ int errorCount = 0;
+ int warningCount = 0;
+ int infoCount = 0;
+ int unknownCount = 0;
+ for (IMarker marker : markers) {
+ switch (marker.getAttribute(IMarker.SEVERITY, -1)) {
+ case IMarker.SEVERITY_ERROR:
+ ++errorCount;
+ break;
+ case IMarker.SEVERITY_INFO:
+ ++infoCount;
+ break;
+ case IMarker.SEVERITY_WARNING:
+ ++warningCount;
+ break;
+ default:
+ ++unknownCount;
+ break;
+ }
+ }
+
+ assertEquals("Expecting 10 errors: " + WorkspaceHelpers.toString(markers), 10, errorCount);
+ assertEquals("Expecting 0 warnings: " + WorkspaceHelpers.toString(markers), 0, warningCount);
+ assertEquals("Expecting 0 infos: " + WorkspaceHelpers.toString(markers), 0, infoCount);
+ assertEquals("Unexpected marker severity (not info, warning, error): " + WorkspaceHelpers.toString(markers), 0,
+ unknownCount);
+
+ project.build(IncrementalProjectBuilder.CLEAN_BUILD, monitor);
+ waitForJobsToComplete();
+ markers = project.findMarkers(null, true, IFile.DEPTH_INFINITE);
+ assertEquals(WorkspaceHelpers.toString(markers), 0, markers.length);
+
+ project.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
+ waitForJobsToComplete();
+ markers = switchYardFile.findMarkers(SwitchYardProjectValidator.SWITCHYARD_MARKER_ID, true,
+ IFile.DEPTH_ZERO);
+ assertEquals(WorkspaceHelpers.toString(markers), 10, markers.length);
+
+ MavenPlugin.getProjectConfigurationManager().updateProjectConfiguration(project, monitor);
+ project.build(IncrementalProjectBuilder.CLEAN_BUILD, monitor);
+ waitForJobsToComplete();
+ markers = project.findMarkers(null, true, IFile.DEPTH_INFINITE);
+ assertEquals(WorkspaceHelpers.toString(markers), 0, markers.length);
+
+ project.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
+ waitForJobsToComplete();
+ markers = switchYardFile.findMarkers(SwitchYardProjectValidator.SWITCHYARD_MARKER_ID, true,
+ IFile.DEPTH_ZERO);
+ assertEquals(WorkspaceHelpers.toString(markers), 10, markers.length);
+ }
}
View
83 eclipse/tests/org.switchyard.tools.ui.tests/test-data/validator-tests/camel-route-tests/pom.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>com.tests.switchyard</groupId>
+ <artifactId>camel-route-tests</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <name>com.tests.switchyard:camel-route-tests</name>
+ <properties>
+ <switchyard.version>1.1.0.Final</switchyard.version>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.switchyard.components</groupId>
+ <artifactId>switchyard-component-camel</artifactId>
+ <version>${switchyard.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.switchyard</groupId>
+ <artifactId>switchyard-api</artifactId>
+ <version>${switchyard.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.switchyard</groupId>
+ <artifactId>switchyard-transform</artifactId>
+ <version>${switchyard.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.switchyard</groupId>
+ <artifactId>switchyard-validate</artifactId>
+ <version>${switchyard.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.switchyard</groupId>
+ <artifactId>switchyard-plugin</artifactId>
+ <version>${switchyard.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.switchyard</groupId>
+ <artifactId>switchyard-test</artifactId>
+ <version>${switchyard.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.switchyard.components</groupId>
+ <artifactId>switchyard-component-test-mixin-cdi</artifactId>
+ <version>${switchyard.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.switchyard</groupId>
+ <artifactId>switchyard-plugin</artifactId>
+ <version>${switchyard.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>configure</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <scannerClassNames>
+ <param>org.switchyard.transform.config.model.TransformSwitchYardScanner</param>
+ </scannerClassNames>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <debug>true</debug>
+ <showWarnings>true</showWarnings>
+ <showDeprecation>true</showDeprecation>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
View
12 ...ator-tests/camel-route-tests/src/main/java/com/switchyard/camel_route_tests/BrokenCamelServiceRoute.java
@@ -0,0 +1,12 @@
+package com.switchyard.camel_route_tests;
+
+public class BrokenCamelServiceRoute {
+
+ /**
+ * The Camel route is configured via this method. The from endpoint is required to be a SwitchYard service.
+ */
+ public void configure() {
+ System.out.println("Broken");
+ }
+
+}
View
20 .../validator-tests/camel-route-tests/src/main/java/com/switchyard/camel_route_tests/CamelServiceRoute.java
@@ -0,0 +1,20 @@
+package com.switchyard.camel_route_tests;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class CamelServiceRoute extends RouteBuilder {
+
+ /**
+ * The Camel route is configured via this method. The from endpoint is required to be a SwitchYard service.
+ */
+ public void configure() {
+ from("switchyard://MySecondService")
+ .log("Received message for MySecondService: ${body}")
+ .split(body(String.class).tokenize("\n"))
+ .filter(body(String.class).startsWith("sally:"))
+ .to("switchyard://MyThirdService");
+ from("switchyard://MyFirstService")
+ .log("Received message for MyFirstService: ${body}");
+ }
+
+}
View
16 ...tor-tests/camel-route-tests/src/main/java/com/switchyard/camel_route_tests/CorrectCamelServiceRoute.java
@@ -0,0 +1,16 @@
+package com.switchyard.camel_route_tests;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class CorrectCamelServiceRoute extends RouteBuilder {
+
+ /**
+ * The Camel route is configured via this method. The from endpoint is required to be a SwitchYard service.
+ */
+ public void configure() {
+ from("switchyard://MyOtherFirstService").log(
+ "Received message for 'MyFirstService' : ${body}")
+ .to("switchyard://MyOtherSecondService?operationName=doSomethingElse");
+ }
+
+}
View
7 ...ata/validator-tests/camel-route-tests/src/main/java/com/switchyard/camel_route_tests/MyFirstService.java
@@ -0,0 +1,7 @@
+package com.switchyard.camel_route_tests;
+
+public interface MyFirstService {
+
+ public void doSomething(String withThis);
+
+}
View
7 ...ta/validator-tests/camel-route-tests/src/main/java/com/switchyard/camel_route_tests/MySecondService.java
@@ -0,0 +1,7 @@
+package com.switchyard.camel_route_tests;
+
+public interface MySecondService {
+
+ public void doSomethingElse(String withThat);
+
+}
View
13 ...validator-tests/camel-route-tests/src/main/java/com/switchyard/camel_route_tests/NestedServiceRoute.java
@@ -0,0 +1,13 @@
+package com.switchyard.camel_route_tests;
+
+public class NestedServiceRoute extends ParentCamelServiceRoute {
+
+ /**
+ * The Camel route is configured via this method. The from endpoint is required to be a SwitchYard service.
+ */
+ protected void doSomeFunkyRoute() {
+ from("switchyard://MySecondService")
+ .log("Received message for MySecondService: ${body}");
+ }
+
+}
View
13 ...ator-tests/camel-route-tests/src/main/java/com/switchyard/camel_route_tests/ParentCamelServiceRoute.java
@@ -0,0 +1,13 @@
+package com.switchyard.camel_route_tests;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public abstract class ParentCamelServiceRoute extends RouteBuilder {
+
+ public void configure() {
+ doSomeFunkyRoute();
+ }
+
+ abstract protected void doSomeFunkyRoute();
+
+}
View
6 ...tchyard.tools.ui.tests/test-data/validator-tests/camel-route-tests/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+</beans>
View
101 ...rd.tools.ui.tests/test-data/validator-tests/camel-route-tests/src/main/resources/META-INF/switchyard.xml
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sy:switchyard xmlns:camel="urn:switchyard-component-camel:config:1.1" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:sy="urn:switchyard-config:switchyard:1.1" name="camel-route-tests" targetNamespace="urn:com.tests.switchyard:camel-route-tests:1.0">
+ <sca:composite name="camel-route-tests" targetNamespace="urn:com.tests.switchyard:camel-route-tests:1.0">
+ <sca:component name="Route">
+ <camel:implementation.camel>
+ <camel:xml path="route.xml"/>
+ </camel:implementation.camel>
+ <sca:service name="MyFirstService">
+ <sca:interface.java interface="com.switchyard.camel_route_tests.MyFirstService"/>
+ </sca:service>
+ </sca:component>
+ <sca:service name="MyFirstService" promote="Route/MyFirstService">
+ <sca:interface.java interface="com.switchyard.camel_route_tests.MyFirstService"/>
+ </sca:service>
+ <sca:component name="CamelServiceRoute">
+ <camel:implementation.camel>
+ <camel:java class="com.switchyard.camel_route_tests.CamelServiceRoute"/>
+ </camel:implementation.camel>
+ <sca:service name="MySecondService">
+ <sca:interface.java interface="com.switchyard.camel_route_tests.MySecondService"/>
+ </sca:service>
+ </sca:component>
+ <sca:service name="MySecondService" promote="CamelServiceRoute/MySecondService">
+ <sca:interface.java interface="com.switchyard.camel_route_tests.MySecondService"/>
+ </sca:service>
+ <sca:component name="BrokenRoute">
+ <camel:implementation.camel>
+ <camel:xml path="brokenroute.xml"/>
+ </camel:implementation.camel>
+ </sca:component>
+ <sca:component name="BrokenRoute2">
+ <camel:implementation.camel>
+ <camel:xml path=""/>
+ </camel:implementation.camel>
+ </sca:component>
+ <sca:component name="BrokenRoute3">
+ <camel:implementation.camel>
+ <camel:xml/>
+ </camel:implementation.camel>
+ </sca:component>
+ <sca:component name="BrokenJavaRoute">
+ <camel:implementation.camel>
+ <camel:java class="this.class.does.not.Exist"/>
+ </camel:implementation.camel>
+ </sca:component>
+ <sca:component name="BrokenJavaRoute2">
+ <camel:implementation.camel>
+ <camel:java class=""/>
+ </camel:implementation.camel>
+ </sca:component>
+ <sca:component name="BrokenJavaRoute3">
+ <camel:implementation.camel>
+ <camel:java/>
+ </camel:implementation.camel>
+ </sca:component>
+ <sca:component name="NestedCamelServiceRoute">
+ <camel:implementation.camel>
+ <camel:java class="com.switchyard.camel_route_tests.NestedCamelServiceRoute"/>
+ </camel:implementation.camel>
+ </sca:component>
+ <sca:component name="BadParentCamelServiceRoute">
+ <camel:implementation.camel>
+ <camel:java class="com.switchyard.camel_route_tests.BrokenCamelServiceRoute"/>
+ </camel:implementation.camel>
+ </sca:component>
+ <sca:component name="CorrectCamelServiceRoute">
+ <camel:implementation.camel>
+ <camel:java class="com.switchyard.camel_route_tests.CorrectCamelServiceRoute"/>
+ </camel:implementation.camel>
+ <sca:service name="MyOtherFirstService">
+ <sca:interface.java interface="com.switchyard.camel_route_tests.MyFirstService"/>
+ </sca:service>
+ <sca:reference name="MyOtherSecondService">
+ <sca:interface.java interface="com.switchyard.camel_route_tests.MySecondService"/>
+ </sca:reference>
+ </sca:component>
+ <sca:service name="MyOtherFirstService" promote="CorrectCamelServiceRoute/MyOtherFirstService">
+ <sca:interface.java interface="com.switchyard.camel_route_tests.MyFirstService"/>
+ </sca:service>
+ <sca:reference name="MyOtherSecondService" multiplicity="0..1" promote="CorrectCamelServiceRoute/MyOtherSecondService">
+ <sca:interface.java interface="com.switchyard.camel_route_tests.MySecondService"/>
+ </sca:reference>
+ <sca:component name="Correctroute">
+ <camel:implementation.camel>
+ <camel:xml path="correctroute.xml"/>
+ </camel:implementation.camel>
+ <sca:service name="MyOtherFirstService2">
+ <sca:interface.java interface="com.switchyard.camel_route_tests.MyFirstService"/>
+ </sca:service>
+ <sca:reference name="MyOtherSecondService2">
+ <sca:interface.java interface="com.switchyard.camel_route_tests.MySecondService"/>
+ </sca:reference>
+ </sca:component>
+ <sca:service name="MyOtherFirstService2" promote="Correctroute/MyOtherFirstService2">
+ <sca:interface.java interface="com.switchyard.camel_route_tests.MyFirstService"/>
+ </sca:service>
+ <sca:reference name="MyOtherSecondService2" multiplicity="0..1" promote="Correctroute/MyOtherSecondService2">
+ <sca:interface.java interface="com.switchyard.camel_route_tests.MySecondService"/>
+ </sca:reference>
+ </sca:composite>
+</sy:switchyard>
View
8 ...witchyard.tools.ui.tests/test-data/validator-tests/camel-route-tests/src/main/resources/correctroute.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="ASCII"?>
+<routes xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ <from uri="switchyard://MyOtherFirstService2"/>
+ <log message="MyOtherFirstService2 - message received: ${body}"/>
+ <to uri="switchyard://MyOtherSecondService2?operationName=doSomethingElse"/>
+ </route>
+</routes>
View
11 ...s/org.switchyard.tools.ui.tests/test-data/validator-tests/camel-route-tests/src/main/resources/route.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="ASCII"?>
+<routes xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ <from uri="switchyard://MyFirstService"/>
+ <log message="Inside XML Camel Route"/>
+ </route>
+ <route>
+ <from uri="switchyard://MyFourthService"/>
+ <log message="Inside nonexistent XML Camel Route"/>
+ </route>
+</routes>
View
6 ...d.tools.ui.tests/test-data/validator-tests/wiring-validation-tests/src/test/resources/META-INF/beans.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+</beans>
Something went wrong with that request. Please try again.