Skip to content

Commit

Permalink
Expand Netty test coverage
Browse files Browse the repository at this point in the history
Fixes #2636
  • Loading branch information
jamesnetherton committed Jul 20, 2021
1 parent e16d416 commit dfd1ff1
Show file tree
Hide file tree
Showing 20 changed files with 994 additions and 220 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import org.apache.camel.quarkus.core.deployment.spi.CamelSerializationBuildItem;

class NettyProcessor {

Expand All @@ -27,4 +28,9 @@ class NettyProcessor {
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}

@BuildStep
CamelSerializationBuildItem serialization() {
return new CamelSerializationBuildItem();
}
}
4 changes: 4 additions & 0 deletions integration-tests/netty/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
== Regenerating Self Signed SSL Certificates

cd src/main/resources/ssl
keytool -genkeypair -keystore keystore.p12 -storetype PKCS12 -storepass changeit -alias localhost -keyalg RSA -keysize 2048 -validity 99999 -dname "CN=localhost"
17 changes: 17 additions & 0 deletions integration-tests/netty/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
<description>Integration tests for Camel Quarkus Netty extension</description>

<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-mock</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-netty</artifactId>
Expand Down Expand Up @@ -63,6 +67,19 @@
</dependency>

<!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-mock-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-netty-deployment</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* 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.netty;

import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import org.apache.camel.component.netty.NettyCamelState;
import org.apache.camel.component.netty.NettyCamelStateCorrelationManager;

public class CustomCorrelationManager implements NettyCamelStateCorrelationManager {

private volatile NettyCamelState stateA;
private volatile NettyCamelState stateB;
private volatile NettyCamelState stateC;

@Override
public void putState(Channel channel, NettyCamelState state) {
String body = state.getExchange().getMessage().getBody(String.class);
if ("A".equals(body)) {
stateA = state;
} else if ("B".equals(body)) {
stateB = state;
} else if ("C".equals(body)) {
stateC = state;
}
}

@Override
public void removeState(ChannelHandlerContext ctx, Channel channel) {
// noop
}

@Override
public NettyCamelState getState(ChannelHandlerContext ctx, Channel channel, Object msg) {
String body = msg.toString();
if (body.endsWith("A")) {
stateA.getExchange().getMessage().setHeader("manager", this);
return stateA;
} else if (body.endsWith("B")) {
stateB.getExchange().getMessage().setHeader("manager", this);
return stateB;
} else if (body.endsWith("C")) {
stateC.getExchange().getMessage().setHeader("manager", this);
return stateC;
}
return null;
}

@Override
public NettyCamelState getState(ChannelHandlerContext ctx, Channel channel, Throwable cause) {
return null;
}
}

This file was deleted.

0 comments on commit dfd1ff1

Please sign in to comment.