mirror of https://github.com/apache/activemq.git
AMQ-7393 - Remove unused Selenium tests
This commit is contained in:
parent
85851f7ce8
commit
d49370e363
|
@ -100,36 +100,6 @@
|
|||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-java</artifactId>
|
||||
<version>2.25.0</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-chrome-driver</artifactId>
|
||||
<version>2.25.0</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-firefox-driver</artifactId>
|
||||
<version>2.25.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>websocket-server</artifactId>
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.apache.activemq.transport.ws;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.net.URI;
|
||||
|
@ -32,7 +31,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
import org.apache.activemq.broker.BrokerService;
|
||||
import org.apache.activemq.transport.SocketConnectorFactory;
|
||||
import org.apache.activemq.transport.stomp.StompConnection;
|
||||
import org.apache.activemq.util.Wait;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.api.Request;
|
||||
import org.eclipse.jetty.client.api.Result;
|
||||
|
@ -45,26 +43,15 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
|
|||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.chrome.ChromeDriver;
|
||||
import org.openqa.selenium.chrome.ChromeOptions;
|
||||
import org.openqa.selenium.firefox.FirefoxDriver;
|
||||
import org.openqa.selenium.firefox.FirefoxProfile;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class WSTransportTest extends WSTransportTestSupport {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(WSTransportTest.class);
|
||||
private static final int MESSAGE_COUNT = 1000;
|
||||
|
||||
private Server server;
|
||||
private WebDriver driver;
|
||||
private File profileDir;
|
||||
|
||||
private String stompUri;
|
||||
private StompConnection stompConnection = new StompConnection();
|
||||
|
@ -116,7 +103,6 @@ public class WSTransportTest extends WSTransportTestSupport {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
profileDir = new File("activemq-data/profiles");
|
||||
stompConnect();
|
||||
server = createWebServer();
|
||||
}
|
||||
|
@ -135,12 +121,6 @@ public class WSTransportTest extends WSTransportTestSupport {
|
|||
LOG.warn("Error on super tearDown()");
|
||||
}
|
||||
|
||||
if (driver != null) {
|
||||
try {
|
||||
driver.quit();
|
||||
} catch (Exception e) {}
|
||||
driver = null;
|
||||
}
|
||||
if (server != null) {
|
||||
try {
|
||||
server.stop();
|
||||
|
@ -180,36 +160,6 @@ public class WSTransportTest extends WSTransportTestSupport {
|
|||
assertEquals(HttpStatus.OK_200, status.get());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testFireFoxWebSockets() throws Exception {
|
||||
driver = createFireFoxWebDriver();
|
||||
doTestWebSockets(driver);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testChromeWebSockets() throws Exception {
|
||||
driver = createChromeWebDriver();
|
||||
doTestWebSockets(driver);
|
||||
}
|
||||
|
||||
protected WebDriver createChromeWebDriver() throws Exception {
|
||||
File profile = new File(profileDir, "chrome");
|
||||
profile.mkdirs();
|
||||
ChromeOptions options = new ChromeOptions();
|
||||
options.addArguments("--enable-udd-profiles",
|
||||
"--user-data-dir=" + profile,
|
||||
"--allow-file-access-from-files");
|
||||
return new ChromeDriver(options);
|
||||
}
|
||||
|
||||
protected WebDriver createFireFoxWebDriver() throws Exception {
|
||||
File profile = new File(profileDir, "firefox");
|
||||
profile.mkdirs();
|
||||
return new FirefoxDriver(new FirefoxProfile(profile));
|
||||
}
|
||||
|
||||
private void stompConnect() throws IOException, URISyntaxException, UnknownHostException {
|
||||
URI connectUri = new URI(stompUri);
|
||||
stompConnection.open(createSocket(connectUri));
|
||||
|
@ -231,58 +181,4 @@ public class WSTransportTest extends WSTransportTestSupport {
|
|||
return "http://localhost:" + port + "/websocket.html#" + wsConnectUri;
|
||||
}
|
||||
|
||||
public void doTestWebSockets(WebDriver driver) throws Exception {
|
||||
|
||||
driver.get(getTestURI());
|
||||
|
||||
final WebElement webStatus = driver.findElement(By.id("status"));
|
||||
final WebElement webReceived = driver.findElement(By.id("received"));
|
||||
|
||||
while ("Loading" == webStatus.getText()) {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
|
||||
// Skip test if browser does not support websockets..
|
||||
if (webStatus.getText() != "No WebSockets") {
|
||||
|
||||
assertTrue("Should have connected", Wait.waitFor(new Wait.Condition() {
|
||||
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
return webStatus.getText().equals("Connected");
|
||||
}
|
||||
}));
|
||||
|
||||
stompConnection.connect("system", "manager");
|
||||
|
||||
stompConnection.send("/queue/websocket", "Hello");
|
||||
assertTrue("Should have received message by now.", Wait.waitFor(new Wait.Condition() {
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
return webReceived.getText().equals("Hello");
|
||||
}
|
||||
}));
|
||||
|
||||
for (int i = 1; i <= MESSAGE_COUNT; ++i) {
|
||||
stompConnection.send("/queue/websocket", "messages #" + i);
|
||||
}
|
||||
|
||||
assertTrue("Should have received messages by now.", Wait.waitFor(new Wait.Condition() {
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
return webReceived.getText().equals("messages #" + MESSAGE_COUNT);
|
||||
}
|
||||
}));
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
||||
assertTrue("Should have disconnected", Wait.waitFor(new Wait.Condition() {
|
||||
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
return webStatus.getText().equals("Disconnected");
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue