forked from apache/seatunnel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw IllegalArgumentException when find multiple connector jar for o…
…ne pluginIdentifier (apache#5551)
- Loading branch information
1 parent
fd77278
commit 512d982
Showing
5 changed files
with
158 additions
and
22 deletions.
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
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
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
86 changes: 86 additions & 0 deletions
86
...a/org/apache/seatunnel/plugin/discovery/seatunnel/SeaTunnelSourcePluginDiscoveryTest.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,86 @@ | ||
/* | ||
* 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.seatunnel.plugin.discovery.seatunnel; | ||
|
||
import org.apache.seatunnel.common.config.Common; | ||
import org.apache.seatunnel.common.config.DeployMode; | ||
import org.apache.seatunnel.common.constants.PluginType; | ||
import org.apache.seatunnel.plugin.discovery.PluginIdentifier; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.DisabledOnOs; | ||
import org.junit.jupiter.api.condition.OS; | ||
|
||
import com.google.common.collect.Lists; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.List; | ||
|
||
@DisabledOnOs(OS.WINDOWS) | ||
class SeaTunnelSourcePluginDiscoveryTest { | ||
|
||
private String originSeatunnelHome = null; | ||
private DeployMode originMode = null; | ||
private static final String seatunnelHome = | ||
SeaTunnelSourcePluginDiscoveryTest.class.getResource("/duplicate").getPath(); | ||
private static final List<Path> pluginJars = | ||
Lists.newArrayList( | ||
Paths.get(seatunnelHome, "connectors", "connector-http-jira.jar"), | ||
Paths.get(seatunnelHome, "connectors", "connector-http.jar")); | ||
|
||
@BeforeEach | ||
public void before() throws IOException { | ||
originMode = Common.getDeployMode(); | ||
Common.setDeployMode(DeployMode.CLIENT); | ||
originSeatunnelHome = Common.getSeaTunnelHome(); | ||
Common.setSeaTunnelHome(seatunnelHome); | ||
|
||
// The file is created under target directory. | ||
for (Path pluginJar : pluginJars) { | ||
Files.createFile(pluginJar); | ||
} | ||
} | ||
|
||
@Test | ||
void getPluginBaseClass() { | ||
List<PluginIdentifier> pluginIdentifiers = | ||
Lists.newArrayList( | ||
PluginIdentifier.of("seatunnel", PluginType.SOURCE.getType(), "HttpJira"), | ||
PluginIdentifier.of("seatunnel", PluginType.SOURCE.getType(), "HttpBase")); | ||
SeaTunnelSourcePluginDiscovery seaTunnelSourcePluginDiscovery = | ||
new SeaTunnelSourcePluginDiscovery(); | ||
Assertions.assertThrows( | ||
IllegalArgumentException.class, | ||
() -> seaTunnelSourcePluginDiscovery.getPluginJarPaths(pluginIdentifiers)); | ||
} | ||
|
||
@AfterEach | ||
public void after() throws IOException { | ||
for (Path pluginJar : pluginJars) { | ||
Files.deleteIfExists(pluginJar); | ||
} | ||
Common.setSeaTunnelHome(originSeatunnelHome); | ||
Common.setDeployMode(originMode); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
seatunnel-plugin-discovery/src/test/resources/duplicate/connectors/plugin-mapping.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,21 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
seatunnel.source.HttpBase = connector-http | ||
seatunnel.sink.HttpBase = connector-http | ||
seatunnel.source.HttpJira = connector-http-jira | ||
seatunnel.sink.HttpJira = connector-http-jira |