Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions docs/rest-plugins-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ into the `handleMessage` function. It simply replaces the Google logo with the B
* Respond with the output, error and blocking flags as needed

### Request

* The request will be in the following format

```
Expand All @@ -30,8 +31,10 @@ into the `handleMessage` function. It simply replaces the Google logo with the B

Where

* inputType: The simple class name of the input object, Object for any (included null). For DB calls can use `JdbcCall`, for Http/s `Request`
* outputType: The simple class name of the output object, Object for any (included null). For DB calls can use `SelectResult`, for Http/s `Response`
* inputType: The simple class name of the input object, Object for any (included null). For DB calls can use `JdbcCall`,
for Http/s `Request`
* outputType: The simple class name of the output object, Object for any (included null). For DB calls can use
`SelectResult`, for Http/s `Response`
* phase: the protocol phase

### Response
Expand Down Expand Up @@ -86,10 +89,10 @@ Just set in the settings file the relative interceptor where
* destinationAddress: The API to call
* inputType: `Request`
* outputType: `Response`
* inMatcher: The matcher for the input content, can be a
* regexp, prepend `@`
* [tpmQl](tpmql.md), prepend `!`
* contains, just the string that should be founded
* inMatcher: The matcher for the input content, can be a
* regexp, prepend `@`
* [tpmQl](tpmql.md), prepend `!`
* contains, just the string that should be founded

If you need it exists even the outputMatcher that follows the same rules

Expand Down
2 changes: 0 additions & 2 deletions docs/selenium.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


```

pipeline {
Expand Down
2 changes: 1 addition & 1 deletion jacoco/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<goal>run</goal>
</goals>
<configuration>
<target name="report" >
<target name="report">
<echo message="Generating JaCoCo Reports"/>
<mkdir dir="${basedir}/target/coverage-report"/>
<taskdef name="report"
Expand Down
4 changes: 1 addition & 3 deletions jacoco/src/main/resources/zip.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<assembly xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<assembly>
<id>coverage</id>
<baseDirectory>/</baseDirectory>
<formats>
Expand Down
8 changes: 5 additions & 3 deletions protocol-amqp-091/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,18 @@ Introduce random latency. Not applicable to async calls

### rest-plugins-plugin

This plugin is used to intercept protocol calls and forward the request to a REST API
This plugin is used to intercept protocol calls and forward the request to a REST API
that will need to respond with the correct response data. Contains a list of "interceptors"
definitions. For details on the implementation [here](../docs/rest-plugins-plugin.md)

* name: The name of the interceptor
* destinationAddress: The api to call (POST)
* inputType: The expected input type (simple class name), Object for any
* inMatcher: The matcher for the in content, `@` for Java regexp, `!` for [tpmql](../docs/tpmql.md), generic string from contains
* inMatcher: The matcher for the in content, `@` for Java regexp, `!` for [tpmql](../docs/tpmql.md), generic string from
contains
* outputType: The expected output type (simple class name), Object for any
* outMatcher: The matcher for the out content, `@` for Java regexp, `!` for [tpmql](../docs/tpmql.md), generic string from contains
* outMatcher: The matcher for the out content, `@` for Java regexp, `!` for [tpmql](../docs/tpmql.md), generic string
from contains
* blockOnException: If there is an exception return the error and stop the filtering

## Documentation used
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class AmqpProtocol extends NetworkProtoDescriptor {
private static final int PORT = 5672;
final AtomicBoolean running = new AtomicBoolean(true);
private final Logger log = LoggerFactory.getLogger(AmqpProtocol.class);
private int port = PORT;
private int port;
private TimerInstance timer;

@TpmConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected Iterator<ProtoStep> executeMethod(short channel, short classId, short
var bd = new BasicCancelOk();
bd.setChannel(channel);
bd.setConsumerTag(ShortStringHelper.read(rb));
//DOUBT Should'nt we send the newly created BasicCancelOk
//DOUBT Should we send the newly created BasicCancelOk

return iteratorOfList(bd);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.kendar.amqp.v09.messages.methods.basic.BasicDeliver;
import org.kendar.di.annotations.TpmService;
import org.kendar.plugins.BasicRecordPlugin;
import org.kendar.plugins.settings.BasicAysncRecordPluginSettings;
import org.kendar.plugins.settings.BasicAsyncRecordPluginSettings;
import org.kendar.storage.CompactLine;
import org.kendar.storage.StorageItem;
import org.kendar.storage.generic.StorageRepository;
Expand All @@ -20,7 +20,7 @@
import java.util.Map;

@TpmService(tags = "amqp091")
public class AmqpRecordPlugin extends BasicRecordPlugin<BasicAysncRecordPluginSettings> {
public class AmqpRecordPlugin extends BasicRecordPlugin<BasicAsyncRecordPluginSettings> {
private static final List<String> toAvoid = List.of("byte[]",
"ConnectionStartOk", "ConnectionTuneOk", "ConnectionOpen", "ChannelOpen", "BasicPublish",
"HeaderFrame", "BasicPublish", "BodyFrame", "BasicAck", "ChannelClose", "ConnectionClose",
Expand All @@ -40,7 +40,7 @@ private static int getConsumeId(JsonNode data, int consumeId) {

@Override
public Class<?> getSettingClass() {
return BasicAysncRecordPluginSettings.class;
return BasicAsyncRecordPluginSettings.class;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.kendar.di.annotations.TpmService;
import org.kendar.exceptions.PluginException;
import org.kendar.plugins.BasicReplayPlugin;
import org.kendar.plugins.settings.BasicAysncReplayPluginSettings;
import org.kendar.plugins.settings.BasicAsyncReplayPluginSettings;
import org.kendar.protocol.context.NetworkProtoContext;
import org.kendar.protocol.context.ProtoContext;
import org.kendar.protocol.messages.ReturnMessage;
Expand All @@ -28,7 +28,7 @@
import java.util.concurrent.ConcurrentHashMap;

@TpmService(tags = "amqp091")
public class AmqpReplayPlugin extends BasicReplayPlugin<BasicAysncReplayPluginSettings> {
public class AmqpReplayPlugin extends BasicReplayPlugin<BasicAsyncReplayPluginSettings> {
protected static final JsonMapper mapper = new JsonMapper();
private static final Logger log = LoggerFactory.getLogger(AmqpReplayPlugin.class);
private static final List<String> repeatableItems = Arrays.asList(
Expand Down Expand Up @@ -60,7 +60,7 @@ protected void handleActivation(boolean active) {

@Override
public Class<?> getSettingClass() {
return BasicAysncReplayPluginSettings.class;
return BasicAsyncReplayPluginSettings.class;
}

@Override
Expand All @@ -74,14 +74,14 @@ protected boolean hasCallbacks() {
}

@Override
protected void buildState(PluginContext pluginContext, ProtoContext context, Object in, Object outObj, Object toread, LineToRead lineToRead) {
protected void buildState(PluginContext pluginContext, ProtoContext context, Object in, Object outObj, Object toRead, LineToRead lineToRead) {
if (outObj == null) return;
if (toread == null) return;
if (toRead == null) return;
var out = mapper.toJsonNode(outObj);

var result = mapper.deserialize(out, toread.getClass());
var result = mapper.deserialize(out, toRead.getClass());
try {
ExtraBeanUtils.copyProperties(toread, result, "Reserved1", "consumerTag");
ExtraBeanUtils.copyProperties(toRead, result, "Reserved1", "consumerTag");
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
throw new PluginException(e);
}
Expand All @@ -106,7 +106,7 @@ protected void sendBackResponses(ProtoContext context, List<StorageItem> storage
}
}
}
if(!isActive())return;
if (!isActive()) return;


var out = mapper.toJsonNode(item.getOutput());
Expand All @@ -123,7 +123,7 @@ protected void sendBackResponses(ProtoContext context, List<StorageItem> storage
ReturnMessage fr = null;
try {
log.debug("Sending back response for {}:{}", item.getIndex(), mapper.serialize(out));
} catch (Exception e) {
} catch (Exception ignored) {

}
NetworkProtoContext ctx = null;
Expand Down Expand Up @@ -152,7 +152,7 @@ protected void sendBackResponses(ProtoContext context, List<StorageItem> storage
case "BasicCancel":
var bc = mapper.deserialize(out, BasicCancel.class);
ctx = realConnectionToRecorded.get(bc.getConsumeId());
if(ctx==null){
if (ctx == null) {
ctx = (NetworkProtoContext) context.getDescriptor().getContextsCache().get(consumeId);
}
fr = bc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public void getConnections(Request request, Response response) {
private List<AmqpConnection> loadConnections() {
var pInstance = getDescriptor().getProtocolInstance();
var result = new ArrayList<AmqpConnection>();
for (var ccache : pInstance.getContextsCache().entrySet()) {
var key = ccache.getKey();
var context = (AmqpProtoContext) ccache.getValue();
for (var cache : pInstance.getContextsCache().entrySet()) {
var key = cache.getKey();
var context = (AmqpProtoContext) cache.getValue();
for (var channel : context.getChannels()) {

var connection = new AmqpConnection();
Expand Down Expand Up @@ -120,9 +120,9 @@ public void publish(Request request, Response response) {
var channelId = Integer.parseInt(request.getPathParameter("channel"));

var published = doPublish(messageData, connectionId, channelId);
if(published==0){
if (published == 0) {
respondKo(response, "Publish failed");
}else{
} else {
respondOk(response);
}
}
Expand Down Expand Up @@ -153,7 +153,7 @@ public int doPublish(PublishAmqpMessage messageData, int connectionId, int chann
}
}

//From most recents
//From most recent
Collections.reverse(basicConsumes);
//{id=1, channel=1, consumeOrigin='quotations|1|{}', consumerTag=None1, canPublish=true, consumeId=1, exchange='stock'}
for (var basicConsume : basicConsumes) {
Expand Down Expand Up @@ -221,7 +221,7 @@ public int doPublish(PublishAmqpMessage messageData, int connectionId, int chann
bf.setContent(content);
context.write(bf);
written++;
} catch (Exception ex) {
} catch (Exception ignored) {

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ public void setExchange(String exchange) {
this.exchange = exchange;
}

public void setLastAccess(long lastAccess) {
this.lastAccess = lastAccess;
}

public long getLastAccess() {
return lastAccess;
}

public void setLastAccess(long lastAccess) {
this.lastAccess = lastAccess;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ public class PublishAmqpMessage {
private String queue = null;
private String exchange = null;

public PublishAmqpMessage() {

}

public String getExchange() {
return exchange;
}
Expand All @@ -26,10 +30,6 @@ public void setQueue(String queue) {
this.queue = queue;
}

public PublishAmqpMessage() {

}

public int getPropertyFlag() {
return propertyFlag;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import java.util.Iterator;

import static org.kendar.protocol.states.ProtoState.iteratorOfRunnable;

public class ProxyedBehaviour {
protected static final JsonMapper mapper = new JsonMapper();

Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
var protocolSettings = globalSettings.getProtocolForKey(data.getInstanceId());
var storage = org.kendar.di.DiService.getThreadContext().getInstance(org.kendar.storage.generic.StorageRepository.class);
var files = storage.listFiles("scenario").stream().filter(f->f.endsWith("."+protocolSettings.getProtocolInstanceId())).toList();
var pluginSettings = (org.kendar.plugins.settings.BasicAysncRecordPluginSettings)protocolSettings.getPlugin(data.getId(),org.kendar.plugins.settings.BasicAysncRecordPluginSettings.class);
var pluginSettings = (org.kendar.plugins.settings.BasicAsyncRecordPluginSettings)protocolSettings.getPlugin(data.getId(),org.kendar.plugins.settings.BasicAsyncRecordPluginSettings.class);
}

<script type="text/javascript">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.kendar.events.EventsQueue;
import org.kendar.events.ReportDataEvent;
import org.kendar.plugins.base.ProtocolPluginDescriptor;
import org.kendar.plugins.settings.BasicAysncRecordPluginSettings;
import org.kendar.plugins.settings.BasicAsyncRecordPluginSettings;
import org.kendar.plugins.settings.LatencyPluginSettings;
import org.kendar.plugins.settings.NetworkErrorPluginSettings;
import org.kendar.settings.ByteProtocolSettingsWithLogin;
Expand Down Expand Up @@ -92,7 +92,7 @@ public static void beforeEachBase(TestInfo testInfo) {
var gs = new GlobalSettings();
var mapper = new JsonMapper();
recordPlugin = new AmqpRecordPlugin(mapper, storage,
new MultiTemplateEngine(), new SimpleParser()).initialize(gs, new ByteProtocolSettingsWithLogin(), new BasicAysncRecordPluginSettings());
new MultiTemplateEngine(), new SimpleParser()).initialize(gs, new ByteProtocolSettingsWithLogin(), new BasicAsyncRecordPluginSettings());
var rep = new AmqpReportPlugin(mapper).initialize(gs, new ByteProtocolSettingsWithLogin(), new PluginSettings());
publishPlugin = new AmqpPublishPlugin(mapper, new MultiTemplateEngine()).initialize(gs, new ByteProtocolSettingsWithLogin(), new PluginSettings());
errorPlugin = new AmqpNetErrorPlugin(mapper).initialize(gs, new ByteProtocolSettingsWithLogin(), new NetworkErrorPluginSettings().withPercentAction(80));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.util.ArrayList;
import java.util.stream.Collectors;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

@TestMethodOrder(MethodOrderer.MethodName.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.kendar.amqp.v09.plugins.AmqpReplayPlugin;
import org.kendar.plugins.settings.BasicAysncReplayPluginSettings;
import org.kendar.plugins.settings.BasicAsyncReplayPluginSettings;
import org.kendar.settings.ByteProtocolSettingsWithLogin;
import org.kendar.settings.GlobalSettings;
import org.kendar.storage.FileStorageRepository;
Expand All @@ -22,9 +22,6 @@
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

@TestMethodOrder(MethodOrderer.MethodName.class)
public class ReplayerTest {

Expand Down Expand Up @@ -71,7 +68,7 @@ void test2_differentChannelAndConnection() throws Exception {
"test", "resources", "test2_differentChannelAndConnection"));
storage.initialize();
var gs = new GlobalSettings();
var pl = new AmqpReplayPlugin(new JsonMapper(), storage).initialize(gs, new ByteProtocolSettingsWithLogin(), new BasicAysncReplayPluginSettings());
var pl = new AmqpReplayPlugin(new JsonMapper(), storage).initialize(gs, new ByteProtocolSettingsWithLogin(), new BasicAsyncReplayPluginSettings());
proxy.setPluginHandlers(List.of(pl));
pl.setActive(true);

Expand Down Expand Up @@ -156,7 +153,7 @@ void test5_noPublish() throws Exception {
"test", "resources", "test5_noPublish"));
storage.initialize();
var gs = new GlobalSettings();
var pl = new AmqpReplayPlugin(new JsonMapper(), storage).initialize(gs, new ByteProtocolSettingsWithLogin(), new BasicAysncReplayPluginSettings());
var pl = new AmqpReplayPlugin(new JsonMapper(), storage).initialize(gs, new ByteProtocolSettingsWithLogin(), new BasicAsyncReplayPluginSettings());
proxy.setPluginHandlers(List.of(pl));
pl.setActive(true);

Expand Down Expand Up @@ -206,7 +203,7 @@ void test3_openConnection() throws Exception {
"test", "resources", "test3_openConnection"));
storage.initialize();
var gs = new GlobalSettings();
var pl = new AmqpReplayPlugin(new JsonMapper(), storage).initialize(gs, new ByteProtocolSettingsWithLogin(), new BasicAysncReplayPluginSettings());
var pl = new AmqpReplayPlugin(new JsonMapper(), storage).initialize(gs, new ByteProtocolSettingsWithLogin(), new BasicAsyncReplayPluginSettings());
proxy.setPluginHandlers(List.of(pl));
pl.setActive(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;

import static org.junit.jupiter.api.Assertions.*;

@TestMethodOrder(MethodOrderer.MethodName.class)
public class SimpleTest extends AmqpBasicTest {

Expand Down Expand Up @@ -137,7 +135,6 @@ void test0_sameChannel() throws Exception {
chanConsume.basicPublish("", MAIN_QUEUE, props, (exectedMessage + "3").getBytes());



Sleeper.sleep(1000, () -> messages.size() == 3);

assertEquals(3, messages.size());
Expand Down Expand Up @@ -294,9 +291,9 @@ void test2_differentChannelAndConnection() throws Exception {
System.out.println("WAIT------------------------------------------------------------");


Sleeper.sleep(6000,()->{
System.out.println("SIZE2 "+messages.size());
return messages.size()==3;
Sleeper.sleep(6000, () -> {
System.out.println("SIZE2 " + messages.size());
return messages.size() == 3;
});

assertEquals(3, messages.size());
Expand Down
Loading