-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KnownDependenciesResolver to support packages (#17035)
* Enhance KnownDependenciesResolver to iterate over packages up to the root package * add ASF headers
- Loading branch information
1 parent
b4eea1d
commit e8365c9
Showing
3 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...elet-main/src/test/java/org/apache/camel/main/download/KnownDependenciesResolverTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.camel.main.download; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import org.apache.camel.impl.engine.SimpleCamelContext; | ||
import org.apache.camel.tooling.maven.MavenGav; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class KnownDependenciesResolverTest { | ||
|
||
@Test | ||
void mavenGavForClass_returnsClassScopedDependency() { | ||
KnownDependenciesResolver resolver = new KnownDependenciesResolver(new SimpleCamelContext(), null, null); | ||
resolver.loadKnownDependencies(); | ||
|
||
MavenGav dependency = resolver.mavenGavForClass(SomeClass.class.getName()); | ||
|
||
assertNotNull(dependency); | ||
assertEquals(dependency.getGroupId(), "com.example"); | ||
assertEquals(dependency.getArtifactId(), "class-scoped"); | ||
assertEquals(dependency.getVersion(), "1.0.0"); | ||
} | ||
|
||
@Test | ||
void mavenGavForClass_returnsPackageScopedDependency() { | ||
KnownDependenciesResolver resolver = new KnownDependenciesResolver(new SimpleCamelContext(), null, null); | ||
resolver.loadKnownDependencies(); | ||
|
||
MavenGav dependency = resolver.mavenGavForClass(SomeClass.class.getPackage().getName()); | ||
|
||
|
||
assertNotNull(dependency); | ||
assertEquals(dependency.getGroupId(), "org.example"); | ||
assertEquals(dependency.getArtifactId(), "package-scoped"); | ||
assertEquals(dependency.getVersion(), "2.0.0"); | ||
} | ||
|
||
public static class SomeClass { | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
dsl/camel-kamelet-main/src/test/resources/camel-main-known-dependencies.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## --------------------------------------------------------------------------- | ||
## Licensed to the Apache Software Foundation (ASF) under one or more | ||
## contributor license agreements. See the NOTICE file distributed with | ||
## this work for additional information regarding copyright ownership. | ||
## The ASF licenses this file to You under the Apache License, Version 2.0 | ||
## (the "License"); you may not use this file except in compliance with | ||
## the License. You may obtain a copy of the License at | ||
## | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## | ||
## Unless required by applicable law or agreed to in writing, software | ||
## distributed under the License is distributed on an "AS IS" BASIS, | ||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
## --------------------------------------------------------------------------- | ||
|
||
org.apache.camel.main.download.KnownDependenciesResolverTest$SomeClass=com.example:class-scoped:1.0.0 | ||
org.apache.camel.main=org.example:package-scoped:2.0.0 |