-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix various ClassNotFoundExceptions for spring-redis extension
Relates #5962
- Loading branch information
1 parent
ee206ec
commit dfe70e0
Showing
15 changed files
with
247 additions
and
66 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
54 changes: 54 additions & 0 deletions
54
...rc/main/java/org/apache/camel/quarkus/component/spring/redis/it/SpringRedisProducers.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,54 @@ | ||
/* | ||
* 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.quarkus.component.spring.redis.it; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Named; | ||
import org.apache.camel.component.redis.RedisConfiguration; | ||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
import org.springframework.data.redis.connection.RedisPassword; | ||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration; | ||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
|
||
@ApplicationScoped | ||
public class SpringRedisProducers { | ||
|
||
@ConfigProperty(name = "redis.host") | ||
String host; | ||
|
||
@ConfigProperty(name = "redis.port") | ||
int port; | ||
|
||
@SuppressWarnings("unchecked") | ||
@Named("redisTemplate") | ||
RedisTemplate<String, String> produceRedisTemplate() { | ||
RedisConfiguration redisConfiguration = new RedisConfiguration(); | ||
|
||
RedisStandaloneConfiguration conf = new RedisStandaloneConfiguration(); | ||
conf.setPassword(RedisPassword.of("p4ssw0rd")); | ||
conf.setHostName(host); | ||
conf.setPort(port); | ||
JedisConnectionFactory connectionFactory = new JedisConnectionFactory(conf); | ||
redisConfiguration.setConnectionFactory(connectionFactory); | ||
|
||
RedisTemplate<String, String> redisTemplate = (RedisTemplate<String, String>) redisConfiguration.getRedisTemplate(); | ||
connectionFactory.start(); | ||
|
||
return redisTemplate; | ||
} | ||
} |
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
46 changes: 46 additions & 0 deletions
46
...s/src/main/java/org/apache/camel/quarkus/component/spring/redis/it/SpringRedisRoutes.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,46 @@ | ||
/* | ||
* 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.quarkus.component.spring.redis.it; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import org.apache.camel.builder.RouteBuilder; | ||
import org.apache.camel.component.redis.RedisConstants; | ||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
|
||
@ApplicationScoped | ||
public class SpringRedisRoutes extends RouteBuilder { | ||
static final String KEY = "test-key"; | ||
|
||
@ConfigProperty(name = "redis.host") | ||
String host; | ||
|
||
@ConfigProperty(name = "redis.port") | ||
int port; | ||
|
||
@Override | ||
public void configure() throws Exception { | ||
from("direct:set") | ||
.setHeader(RedisConstants.COMMAND).constant("SET") | ||
.setHeader(RedisConstants.KEY).constant(KEY) | ||
.toF("spring-redis://%s:%d?redisTemplate=#redisTemplate", host, port); | ||
|
||
from("direct:exists") | ||
.setHeader(RedisConstants.COMMAND).constant("EXISTS") | ||
.setHeader(RedisConstants.KEY).constant(KEY) | ||
.toF("spring-redis://%s:%d?redisTemplate=#redisTemplate", host, port); | ||
} | ||
} |
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
...test/java/org/apache/camel/quarkus/component/spring/redis/it/SpringRedisTestResource.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.quarkus.component.spring.redis.it; | ||
|
||
import java.util.Map; | ||
|
||
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; | ||
import org.eclipse.microprofile.config.ConfigProvider; | ||
import org.testcontainers.containers.BindMode; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.containers.wait.strategy.Wait; | ||
|
||
public class SpringRedisTestResource implements QuarkusTestResourceLifecycleManager { | ||
private static final String REDIS_IMAGE_NAME = ConfigProvider.getConfig().getValue("redis.container.image", String.class); | ||
private static final int REDIS_PORT = 6379; | ||
|
||
private GenericContainer<?> container; | ||
|
||
@Override | ||
public Map<String, String> start() { | ||
container = new GenericContainer<>(REDIS_IMAGE_NAME) | ||
.withExposedPorts(REDIS_PORT) | ||
.withClasspathResourceMapping("redis.conf", "/usr/local/etc/redis", BindMode.READ_ONLY) | ||
.waitingFor(Wait.forListeningPort()); | ||
|
||
container.start(); | ||
|
||
return Map.of( | ||
"redis.host", container.getHost(), | ||
"redis.port", container.getMappedPort(REDIS_PORT).toString()); | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
try { | ||
if (container != null) { | ||
container.stop(); | ||
} | ||
} catch (Exception e) { | ||
// ignored | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
integration-tests-jvm/spring-redis/src/test/resources/redis.conf
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,18 @@ | ||
## --------------------------------------------------------------------------- | ||
## 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. | ||
## --------------------------------------------------------------------------- | ||
|
||
requirepass p4ssw0rd |
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
Oops, something went wrong.