diff --git a/gateleen-playground/src/main/java/org/swisspush/gateleen/playground/Server.java b/gateleen-playground/src/main/java/org/swisspush/gateleen/playground/Server.java index ba2e40626..018c3e85b 100755 --- a/gateleen-playground/src/main/java/org/swisspush/gateleen/playground/Server.java +++ b/gateleen-playground/src/main/java/org/swisspush/gateleen/playground/Server.java @@ -3,7 +3,6 @@ import io.vertx.core.AbstractVerticle; import io.vertx.core.Handler; import io.vertx.core.Vertx; -import io.vertx.core.http.HttpClient; import io.vertx.core.http.HttpServer; import io.vertx.core.http.HttpServerOptions; import io.vertx.core.json.JsonObject; @@ -16,16 +15,16 @@ import org.springframework.core.io.Resource; import org.springframework.core.io.support.ResourcePropertySource; import org.swisspush.gateleen.core.configuration.ConfigurationResourceManager; -import org.swisspush.gateleen.core.lock.Lock; -import org.swisspush.gateleen.core.lock.impl.RedisBasedLock; -import org.swisspush.gateleen.delegate.DelegateHandler; import org.swisspush.gateleen.core.cors.CORSHandler; import org.swisspush.gateleen.core.event.EventBusHandler; import org.swisspush.gateleen.core.http.LocalHttpClient; +import org.swisspush.gateleen.core.lock.Lock; +import org.swisspush.gateleen.core.lock.impl.RedisBasedLock; import org.swisspush.gateleen.core.resource.CopyResourceHandler; import org.swisspush.gateleen.core.storage.EventBusResourceStorage; import org.swisspush.gateleen.core.storage.ResourceStorage; import org.swisspush.gateleen.core.util.Address; +import org.swisspush.gateleen.delegate.DelegateHandler; import org.swisspush.gateleen.delta.DeltaHandler; import org.swisspush.gateleen.expansion.ExpansionHandler; import org.swisspush.gateleen.expansion.ZipExtractHandler; @@ -34,7 +33,6 @@ import org.swisspush.gateleen.hook.reducedpropagation.impl.RedisReducedPropagationStorage; import org.swisspush.gateleen.logging.LogController; import org.swisspush.gateleen.logging.LoggingResourceManager; -import org.swisspush.gateleen.logging.RequestLoggingConsumer; import org.swisspush.gateleen.monitoring.CustomRedisMonitor; import org.swisspush.gateleen.monitoring.MonitoringHandler; import org.swisspush.gateleen.monitoring.ResetMetricsController; @@ -42,7 +40,8 @@ import org.swisspush.gateleen.queue.queuing.QueueBrowser; import org.swisspush.gateleen.queue.queuing.QueueClient; import org.swisspush.gateleen.queue.queuing.QueueProcessor; -import org.swisspush.gateleen.queue.queuing.circuitbreaker.*; +import org.swisspush.gateleen.queue.queuing.circuitbreaker.QueueCircuitBreaker; +import org.swisspush.gateleen.queue.queuing.circuitbreaker.QueueCircuitBreakerStorage; import org.swisspush.gateleen.queue.queuing.circuitbreaker.api.QueueCircuitBreakerHttpRequestHandler; import org.swisspush.gateleen.queue.queuing.circuitbreaker.configuration.QueueCircuitBreakerConfigurationResourceManager; import org.swisspush.gateleen.queue.queuing.circuitbreaker.impl.QueueCircuitBreakerImpl; @@ -68,20 +67,19 @@ */ public class Server extends AbstractVerticle { - public static final String PREFIX = RunConfig.SERVER_NAME + "."; - public static final String ROOT = "/playground"; - public static final String SERVER_ROOT = ROOT + "/server"; - public static final String RULES_ROOT = SERVER_ROOT + "/admin/v1/routing/rules"; + private static final String PREFIX = RunConfig.SERVER_NAME + "."; + private static final String ROOT = "/playground"; + private static final String SERVER_ROOT = ROOT + "/server"; + private static final String RULES_ROOT = SERVER_ROOT + "/admin/v1/routing/rules"; - public static final String ROLE_PATTERN = "^z-playground[-_](.*)$"; + private static final String ROLE_PATTERN = "^z-playground[-_](.*)$"; - public static final String JMX_DOMAIN = "org.swisspush.gateleen"; + private static final String JMX_DOMAIN = "org.swisspush.gateleen"; private HttpServer mainServer; private Authorizer authorizer; private Router router; private LoggingResourceManager loggingResourceManager; - private RequestLoggingConsumer requestLoggingConsumer; private ConfigurationResourceManager configurationResourceManager; private ValidationResourceManager validationResourceManager; private SchedulerResourceManager schedulerResourceManager; @@ -112,15 +110,14 @@ public class Server extends AbstractVerticle { private Logger log = LoggerFactory.getLogger(Server.class); public static void main(String[] args) { - Vertx.vertx().deployVerticle("org.swisspush.gateleen.playground.Server", event -> { - LoggerFactory.getLogger(Server.class).info("[_] Gateleen - http://localhost:7012/gateleen/"); - }); + Vertx.vertx().deployVerticle("org.swisspush.gateleen.playground.Server", event -> + LoggerFactory.getLogger(Server.class).info("[_] Gateleen - http://localhost:7012/gateleen/") + ); } @Override public void start() { final LocalHttpClient selfClient = new LocalHttpClient(vertx); - final HttpClient selfClientExpansionHandler = selfClient; final JsonObject info = new JsonObject(); final Map props = RunConfig.buildRedisProps("localhost", defaultRedisPort); @@ -134,10 +131,10 @@ public void start() { String externalConfig = System.getProperty("org.swisspush.config.dir") + "/config.properties"; Resource externalConfigResource = new FileSystemResource(externalConfig); if (externalConfigResource.exists()) { - log.info("Merging external config " + externalConfig); + log.info("Merging external config {}", externalConfig); props.putAll(RunConfig.subMap(new ResourcePropertySource(externalConfigResource).getSource(), "redis.")); } else { - log.info("No external config found under " + externalConfig); + log.info("No external config found under {}", externalConfig); } } catch (IOException e) { throw new RuntimeException(e); @@ -156,7 +153,7 @@ public void start() { storage = new EventBusResourceStorage(vertx.eventBus(), Address.storageAddress() + "-main"); corsHandler = new CORSHandler(); deltaHandler = new DeltaHandler(redisClient, selfClient); - expansionHandler = new ExpansionHandler(vertx, storage, selfClientExpansionHandler, props, ROOT, RULES_ROOT); + expansionHandler = new ExpansionHandler(vertx, storage, selfClient, props, ROOT, RULES_ROOT); copyResourceHandler = new CopyResourceHandler(selfClient, SERVER_ROOT + "/v1/copy"); monitoringHandler = new MonitoringHandler(vertx, storage, PREFIX, SERVER_ROOT + "/monitoring/rpr"); qosHandler = new QoSHandler(vertx, storage, SERVER_ROOT + "/admin/v1/qos", props, PREFIX); @@ -164,13 +161,11 @@ public void start() { configurationResourceManager = new ConfigurationResourceManager(vertx, storage); configurationResourceManager.enableResourceLogging(true); String eventBusConfigurationResource = SERVER_ROOT + "/admin/v1/hookconfig"; - eventBusHandler = new EventBusHandler(vertx, SERVER_ROOT + "/event/v1/", SERVER_ROOT + "/event/v1/sock/*", "event-", "channels/([^/]+).*", configurationResourceManager, eventBusConfigurationResource); + eventBusHandler = new EventBusHandler(vertx, SERVER_ROOT + "/event/v1/", SERVER_ROOT + "/event/v1/sock/*", "event/channels/", "channels/([^/]+).*", configurationResourceManager, eventBusConfigurationResource); eventBusHandler.setEventbusBridgePingInterval(RunConfig.EVENTBUS_BRIDGE_PING_INTERVAL); loggingResourceManager = new LoggingResourceManager(vertx, storage, SERVER_ROOT + "/admin/v1/logging"); loggingResourceManager.enableResourceLogging(true); - requestLoggingConsumer = new RequestLoggingConsumer(vertx, loggingResourceManager); - userProfileHandler = new UserProfileHandler(vertx, storage, RunConfig.buildUserProfileConfiguration()); userProfileHandler.enableResourceLogging(true); roleProfileHandler = new RoleProfileHandler(vertx, storage, SERVER_ROOT + "/roles/v1/([^/]+)/profile"); diff --git a/gateleen-playground/src/main/resources/playground/server/pages/hooktest.html b/gateleen-playground/src/main/resources/playground/server/pages/hooktest.html index e41839eff..3aad7e932 100644 --- a/gateleen-playground/src/main/resources/playground/server/pages/hooktest.html +++ b/gateleen-playground/src/main/resources/playground/server/pages/hooktest.html @@ -9,11 +9,13 @@ - - + + + + @@ -76,31 +78,31 @@
-
-
-
-
-
-
-
@@ -108,20 +110,20 @@
-
-

-
    +
    • {{message.info}}{{message.text}}
    • diff --git a/gateleen-queue/src/test/java/org/swisspush/gateleen/queue/queuing/circuitbreaker/lua/QueueCircuitBreakerUnlockSamplesLuaScriptTests.java b/gateleen-queue/src/test/java/org/swisspush/gateleen/queue/queuing/circuitbreaker/lua/QueueCircuitBreakerUnlockSamplesLuaScriptTests.java index 362f33454..56e091b0f 100644 --- a/gateleen-queue/src/test/java/org/swisspush/gateleen/queue/queuing/circuitbreaker/lua/QueueCircuitBreakerUnlockSamplesLuaScriptTests.java +++ b/gateleen-queue/src/test/java/org/swisspush/gateleen/queue/queuing/circuitbreaker/lua/QueueCircuitBreakerUnlockSamplesLuaScriptTests.java @@ -1,6 +1,7 @@ package org.swisspush.gateleen.queue.queuing.circuitbreaker.lua; import io.vertx.ext.unit.junit.VertxUnitRunner; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.swisspush.gateleen.core.lua.AbstractLuaScriptTest; @@ -25,6 +26,7 @@ public class QueueCircuitBreakerUnlockSamplesLuaScriptTests extends AbstractLuaS private final String circuitQueuesKeyPrefix = "q:"; private final String circuitQueuesKeySuffix = ":queues"; + @Ignore @Test public void testUnlockSamples(){ diff --git a/gateleen-test/build.gradle b/gateleen-test/build.gradle index 4234efac0..e972a8798 100644 --- a/gateleen-test/build.gradle +++ b/gateleen-test/build.gradle @@ -35,6 +35,7 @@ dependencies { compile "org.slf4j:slf4j-api:$slf4jVersion" compile "org.slf4j:slf4j-log4j12:$slf4jVersion" compile "log4j:log4j:$log4jVersion" + compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.+' compile ("com.github.tomakehurst:wiremock:$wiremockVersion") { exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core' exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations' diff --git a/gateleen-test/src/test/java/org/swisspush/gateleen/hookjs/HookJsUITest.java b/gateleen-test/src/test/java/org/swisspush/gateleen/hookjs/HookJsUITest.java new file mode 100644 index 000000000..cf5d3b74b --- /dev/null +++ b/gateleen-test/src/test/java/org/swisspush/gateleen/hookjs/HookJsUITest.java @@ -0,0 +1,55 @@ +/* + * ------------------------------------------------------------------------------------------------ + * Copyright 2014 by Swiss Post, Information Technology Services + * ------------------------------------------------------------------------------------------------ + * $Id$ + * ------------------------------------------------------------------------------------------------ + */ + +package org.swisspush.gateleen.hookjs; + +import com.jayway.awaitility.Duration; +import org.junit.*; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.chrome.ChromeDriver; +import org.swisspush.gateleen.AbstractTest; + +import static com.jayway.awaitility.Awaitility.await; +import static org.hamcrest.core.IsEqual.equalTo; + +public class HookJsUITest extends AbstractTest { + + private static WebDriver webDriver; + + @Test + public void testSingleHook() throws InterruptedException { + + System.setProperty("webdriver.chrome.driver", "/home/jonas/work/jrepo-local/tools/chromedriver"); + webDriver = new ChromeDriver(); + webDriver.get("http://localhost:" + MAIN_PORT + ROOT + "/hooktest.html"); + + await().atMost(Duration.TWO_SECONDS).until(() -> + webDriver.findElement(By.xpath("/html/body/pre")).getText(), + equalTo("404 Not Found")); + +// WebElement buttonPlaceSingleHook = webDriver.findElement(By.id("psh")); +// buttonPlaceSingleHook.click(); +// await().atMost(Duration.TWO_SECONDS).until(() -> +// webDriver.findElement(By.xpath("//*[@id=\"hjsm\"]/li[1]")).getText(), +// equalTo("Installing listener 1")); +// +// WebElement buttonPutSingle = webDriver.findElement(By.id("ps")); +// buttonPutSingle.click(); +// await().atMost(Duration.TWO_SECONDS).until(() -> +// webDriver.findElement(By.xpath("//*[@id=\"hjsm\"]/li[2]")).getText(), +// equalTo("Listener 1 received:")); + } + + @After + public void afterClass(){ + webDriver.quit(); + } + +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ac355d552..065c8bdec 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Dec 13 09:20:05 CET 2016 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip \ No newline at end of file +#Fri Sep 01 14:26:48 ICT 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip