Update deps for spring-websocket

This commit is contained in:
Rossen Stoyanchev
2013-05-06 16:42:42 -04:00
parent e7f38e5b17
commit 37c6a94905
5 changed files with 22 additions and 114 deletions

View File

@@ -1,87 +0,0 @@
/*
* Copyright 2002-2013 the original author or authors.
*
* Licensed 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.springframework.web.socket.sockjs;
import java.util.Date;
import java.util.concurrent.Callable;
import java.util.concurrent.Delayed;
import java.util.concurrent.FutureTask;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.Trigger;
/**
* @author Rossen Stoyanchev
*/
public class StubTaskScheduler implements TaskScheduler {
@Override
public ScheduledFuture schedule(Runnable task, Trigger trigger) {
return new StubScheduledFuture();
}
@Override
public ScheduledFuture schedule(Runnable task, Date startTime) {
return new StubScheduledFuture();
}
@Override
public ScheduledFuture scheduleAtFixedRate(Runnable task, Date startTime, long period) {
return new StubScheduledFuture();
}
@Override
public ScheduledFuture scheduleAtFixedRate(Runnable task, long period) {
return new StubScheduledFuture();
}
@Override
public ScheduledFuture scheduleWithFixedDelay(Runnable task, Date startTime, long delay) {
return new StubScheduledFuture();
}
@Override
public ScheduledFuture scheduleWithFixedDelay(Runnable task, long delay) {
return new StubScheduledFuture();
}
private static class StubScheduledFuture extends FutureTask implements ScheduledFuture {
@SuppressWarnings("unchecked")
public StubScheduledFuture() {
super(new Callable() {
public Object call() throws Exception {
return null;
}
});
}
@Override
public long getDelay(TimeUnit unit) {
return 0;
}
@Override
public int compareTo(Delayed o) {
return 0;
}
}
}

View File

@@ -20,9 +20,8 @@ import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.web.socket.AbstractHttpRequestTests;
import org.springframework.web.socket.adapter.TextWebSocketHandlerAdapter;
import org.springframework.web.socket.sockjs.StubTaskScheduler;
import org.springframework.web.socket.sockjs.TransportHandler;
import org.springframework.web.socket.sockjs.TransportType;
@@ -42,7 +41,7 @@ public class DefaultSockJsServiceTests extends AbstractHttpRequestTests {
@Before
public void setUp() {
super.setUp();
this.service = new DefaultSockJsService(new StubTaskScheduler());
this.service = new DefaultSockJsService(new ThreadPoolTaskScheduler());
this.service.setValidSockJsPrefixes("/echo");
}
@@ -62,21 +61,4 @@ public class DefaultSockJsServiceTests extends AbstractHttpRequestTests {
assertNotNull(handlers.get(TransportType.EVENT_SOURCE));
}
@Test
public void xhrSend() throws Exception {
setRequest("POST", "/echo/000/c5839f69/xhr");
this.service.handleRequest(this.request, this.response, new TextWebSocketHandlerAdapter());
resetResponse();
setRequest("POST", "/echo/000/c5839f69/xhr_send");
this.servletRequest.setContent("[\"x\"]".getBytes("UTF-8"));
this.service.handleRequest(this.request, this.response, new TextWebSocketHandlerAdapter());
assertEquals(204, this.servletResponse.getStatus());
assertEquals("text/plain;charset=UTF-8", this.servletResponse.getContentType());
}
}