Skip to content

Commit

Permalink
Avoid false positive for "lenient" properties camel-tooling#220
Browse files Browse the repository at this point in the history
Some Camel components have "lenient" properties. It means that they can
have custom parameters. These parameters were reported as "unknown
parameter" although they are valid.

provided a test for using toD and Camel global properties and set it as
@ignore waiting for a fix at Camel level. see CAMEL-13382

Signed-off-by: Aurélien Pupier <apupier@redhat.com>
  • Loading branch information
apupier committed Apr 8, 2019
1 parent b3398a5 commit c15bb4c
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private Map<CamelEndpointDetails, EndpointValidationResult> diagnoseEndpoints(St
try {
CamelCatalog camelCatalogResolved = camelCatalog.get();
for (CamelEndpointDetails camelEndpointDetails : endpoints) {
EndpointValidationResult validateEndpointProperties = camelCatalogResolved.validateEndpointProperties(camelEndpointDetails.getEndpointUri(), true);
EndpointValidationResult validateEndpointProperties = camelCatalogResolved.validateEndpointProperties(camelEndpointDetails.getEndpointUri(), false);
if (validateEndpointProperties.hasErrors()) {
endpointErrors.put(camelEndpointDetails, validateEndpointProperties);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.eclipse.lsp4j.TextDocumentContentChangeEvent;
import org.eclipse.lsp4j.TextDocumentIdentifier;
import org.eclipse.lsp4j.VersionedTextDocumentIdentifier;
import org.junit.Ignore;
import org.junit.Test;

import com.github.cameltooling.lsp.internal.AbstractCamelLanguageServerTest;
Expand Down Expand Up @@ -123,6 +124,22 @@ public void testValidationErrorUpdatedOnChange() throws Exception {
await().timeout(AWAIT_TIMEOUT).untilAsserted(() -> assertThat(lastPublishedDiagnostics.getDiagnostics()).isEmpty());
}

@Test
@Ignore("Not yet supported by Camel, see CAMEL-13382")
public void testNoErrorWithProperty() throws Exception {
testDiagnostic("camel-with-properties", 0, ".xml");
}

@Test
public void testUnknowPropertyOnNonLenientPropertiesComponent() throws Exception {
testDiagnostic("camel-with-unknownParameter", 1, ".xml");
}

@Test
public void testUnknowPropertyOnLenientPropertiesComponent() throws Exception {
testDiagnostic("camel-with-unknownParameter-forlenientcomponent", 0, ".xml");
}

private void testDiagnostic(String fileUnderTest, int expectedNumberOfError, String extension) throws FileNotFoundException {
File f = new File("src/test/resources/workspace/diagnostic/" + fileUnderTest + extension);
camelLanguageServer = initializeLanguageServer(new FileInputStream(f), extension);
Expand Down
14 changes: 14 additions & 0 deletions src/test/resources/workspace/diagnostic/camel-with-properties.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route id="a route">
<from uri="timer:timerName?delay=1000"/>
<to uri="timer:timerName?${aProperty}=10"></to>
</route>
</camelContext>
</beans>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route id="a route">
<from uri="http://an.url?unknownParam=1000"/>
<to uri="direct:drink"/>
</route>
</camelContext>
</beans>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route id="a route">
<from uri="timer:timerName?unknownParam=1000"/>
<to uri="direct:drink"/>
</route>
</camelContext>
</beans>

0 comments on commit c15bb4c

Please sign in to comment.