Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

AtmospherePushConnectionTest.java 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright 2000-2014 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.server.communication;
  17. import java.io.ByteArrayInputStream;
  18. import java.io.ByteArrayOutputStream;
  19. import java.io.ObjectInputStream;
  20. import java.io.ObjectOutputStream;
  21. import org.atmosphere.cpr.AtmosphereResource;
  22. import org.easymock.EasyMock;
  23. import org.junit.Assert;
  24. import org.junit.Test;
  25. import com.vaadin.server.communication.AtmospherePushConnection.State;
  26. import com.vaadin.ui.UI;
  27. public class AtmospherePushConnectionTest {
  28. @Test
  29. public void testSerialization() throws Exception {
  30. UI ui = EasyMock.createNiceMock(UI.class);
  31. AtmosphereResource resource = EasyMock
  32. .createNiceMock(AtmosphereResource.class);
  33. AtmospherePushConnection connection = new AtmospherePushConnection(ui);
  34. connection.connect(resource);
  35. Assert.assertEquals(State.CONNECTED, connection.getState());
  36. ByteArrayOutputStream baos = new ByteArrayOutputStream();
  37. new ObjectOutputStream(baos).writeObject(connection);
  38. connection = (AtmospherePushConnection) new ObjectInputStream(
  39. new ByteArrayInputStream(baos.toByteArray())).readObject();
  40. Assert.assertEquals(State.DISCONNECTED, connection.getState());
  41. }
  42. }