Skip to content

Commit

Permalink
#49 Fixed some unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mcweba committed Jun 5, 2024
1 parent b35a9b7 commit cdceaa0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
24 changes: 21 additions & 3 deletions gateleen-test/src/test/java/org/swisspush/gateleen/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
import org.swisspush.gateleen.hook.HookHandler;
import org.swisspush.gateleen.hook.HookTriggerType;

import java.util.Arrays;
import java.util.Map;
import java.util.*;
import java.util.Map.Entry;
import java.util.Set;
import java.util.regex.Pattern;

import static org.awaitility.Awaitility.await;
Expand Down Expand Up @@ -365,9 +363,29 @@ public static void registerListener(final String requestUrl, final String target
public static void registerListener(final String requestUrl, final String target, String[] methods, String filter,
Integer queueExpireTime, Map<String, String> staticHeaders, HookTriggerType type,
String headersFilter) {
registerListener(requestUrl, target, methods, filter, queueExpireTime, staticHeaders, type, headersFilter, null);
}

/**
* Registers a listener with a filter, static headers, a queue header and a event trigger.
*
* @param requestUrl
* @param target
* @param methods
* @param filter
* @param queueExpireTime
* @param staticHeaders
* @param queueHeader
*/
public static void registerListener(final String requestUrl, final String target, String[] methods, String filter,
Integer queueExpireTime, Map<String, String> staticHeaders, HookTriggerType type,
String headersFilter, String queueHeader) {
JsonObject route = new JsonObject();
route.put("destination", target);

if(queueHeader != null) {
route.put("headers", new JsonArray(List.of(new JsonObject().put("header", "x-queue").put("value", queueHeader))));
}
if(methods != null){
route.put("methods", new JsonArray(Arrays.asList(methods)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,6 @@ public void testDeadLock(TestContext context) {
}

@Test
@Ignore
public void testHookQueueExpiryOverride(TestContext context) {
// Prepare Environment
// ----
Expand All @@ -681,7 +680,7 @@ public void testHookQueueExpiryOverride(TestContext context) {
String requestUrl = sourceUrl + TestUtils.getHookListenersUrlSuffix() + "testservice" + "/" + 1;
String targetUrl = targetUrlBase + "/result";

String queueName = HookHandler.LISTENER_QUEUE_PREFIX + "-" + hookHandler.getUniqueListenerId(SERVER_ROOT + requestUrl);
String queueName = "hook-queue-expiry-test";

String putRequest = sourceUrl + "/test1";
String putTarget = targetUrl + "/test1";
Expand All @@ -692,7 +691,8 @@ public void testHookQueueExpiryOverride(TestContext context) {
// ----

// register Listener
TestUtils.registerListener(requestUrl, targetUrl, null, null, 5);
TestUtils.registerListener(requestUrl, targetUrl, null, null, 5,
null, null, null, queueName);

// lock queue
String lockRequestUrl = "queuing/locks/" + queueName;
Expand Down

0 comments on commit cdceaa0

Please sign in to comment.