WICKET-5452 Make Wicket-Atmosphere testable - AtmosphereTester Atmosphere tester - write to the http response (doesn't work)
(cherry picked from commit 0582a24373b2bcd981f398c39f8cfea85cd08e06) Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/fb061963 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/fb061963 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/fb061963 Branch: refs/heads/master Commit: fb061963dd2d8f1edc0a33278552e05afca23aa1 Parents: 5433759 Author: Martin Tzvetanov Grigorov <[email protected]> Authored: Tue Aug 12 17:30:46 2014 +0200 Committer: Martin Tzvetanov Grigorov <[email protected]> Committed: Fri Aug 15 10:11:01 2014 +0200 ---------------------------------------------------------------------- .../wicket/atmosphere/AtmosphereBehavior.java | 1 + .../atmosphere/AtmosphereApplication.java | 79 -------------------- .../wicket/atmosphere/AtmosphereTest.java | 3 + 3 files changed, 4 insertions(+), 79 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/fb061963/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/AtmosphereBehavior.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/AtmosphereBehavior.java b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/AtmosphereBehavior.java index be4a0e0..363fed5 100644 --- a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/AtmosphereBehavior.java +++ b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/AtmosphereBehavior.java @@ -211,6 +211,7 @@ public class AtmosphereBehavior extends AbstractAjaxBehavior @Override public void renderHead(Component component, IHeaderResponse response) { + super.renderHead(component, response); try { CoreLibrariesContributor.contributeAjax(component.getApplication(), response); http://git-wip-us.apache.org/repos/asf/wicket/blob/fb061963/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/AtmosphereApplication.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/AtmosphereApplication.java b/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/AtmosphereApplication.java deleted file mode 100644 index aca6e62..0000000 --- a/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/AtmosphereApplication.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.wicket.atmosphere; - -import java.util.Date; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import org.apache.wicket.Application; -import org.apache.wicket.atmosphere.config.AtmosphereLogLevel; -import org.apache.wicket.atmosphere.config.AtmosphereTransport; -import org.apache.wicket.protocol.http.WebApplication; - -/** - * Application object for your web application. If you want to run this application without - * deploying, run the Start class. - */ -public class AtmosphereApplication extends WebApplication -{ - private EventBus eventBus; - - @Override - public Class<HomePage> getHomePage() - { - return HomePage.class; - } - - public EventBus getEventBus() - { - return eventBus; - } - - public static AtmosphereApplication get() - { - return (AtmosphereApplication)Application.get(); - } - - @Override - public void init() - { - super.init(); - eventBus = new EventBus(this); - eventBus.getParameters().setTransport(AtmosphereTransport.STREAMING); - eventBus.getParameters().setLogLevel(AtmosphereLogLevel.DEBUG); - - ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - final Runnable beeper = new Runnable() - { - @Override - public void run() - { - try - { - eventBus.post(new Date()); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - }; - scheduler.scheduleWithFixedDelay(beeper, 2, 2, TimeUnit.SECONDS); - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/fb061963/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/AtmosphereTest.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/AtmosphereTest.java b/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/AtmosphereTest.java index 5accac5..e8a5b30 100644 --- a/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/AtmosphereTest.java +++ b/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/AtmosphereTest.java @@ -42,6 +42,7 @@ public class AtmosphereTest extends Assert super.updateTime(target, event); System.err.println("updateTime"); + target.appendJavaScript("updateTime is executed"); } @Subscribe(contextAwareFilter = ReceiverFilter.class) @@ -60,6 +61,8 @@ public class AtmosphereTest extends Assert Date payload = new Date(); waTester.post(payload); + System.err.println(tester.getLastResponseAsString()); + tester.destroy(); } }
