Skip to content

Commit 579a500

Browse files
committed
Merged in initial-client-impl (pull request #1)
Initial client implementation
2 parents 8597346 + 1e2523a commit 579a500

28 files changed

+2039
-402
lines changed

cdtp-java-client/Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
MVN=mvn
3+
4+
SONAR_HOST=http://localhost:9999
5+
6+
sonar-analysis:
7+
# Running sonar analysis
8+
$(MVN) clean test && $(MVN) sonar:sonar -Dsonar.host.url=$(SONAR_HOST) \
9+
-Dsonar.tests="src/test" \
10+
-Dsonar.exclusions="**/com/github/kklisura/cdtp/protocol/**/*" \
11+
-Dsonar.coverage.exclusions="**/com/github/kklisura/cdtp/protocol/**/*"

cdtp-java-client/pom.xml

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@
1919
<websocket.api.version>1.1</websocket.api.version>
2020
<tyrus.version>1.13.1</tyrus.version>
2121
<logback.version>1.2.3</logback.version>
22+
<javassist.version>3.22.0-GA</javassist.version>
2223

2324
<junit.version>4.12</junit.version>
2425
<jacoco.version>0.8.0</jacoco.version>
2526
<easy.mock.version>3.4</easy.mock.version>
2627
<jsonassert.version>1.5.0</jsonassert.version>
27-
<tyrus.server.version>1.13.1</tyrus.server.version>
28-
<tyrus.server.version>1.13.1</tyrus.server.version>
29-
<tyrus.container.version>1.2.1</tyrus.container.version>
3028
<mockwebserver.version>2.7.5</mockwebserver.version>
3129
</properties>
3230

@@ -36,13 +34,23 @@
3634
<artifactId>javax.websocket-api</artifactId>
3735
<version>${websocket.api.version}</version>
3836
</dependency>
39-
4037
<dependency>
4138
<groupId>org.glassfish.tyrus</groupId>
42-
<artifactId>tyrus-container-jdk-client</artifactId>
39+
<artifactId>tyrus-client</artifactId>
40+
<version>${tyrus.version}</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.glassfish.tyrus</groupId>
44+
<artifactId>tyrus-container-grizzly-server</artifactId>
4345
<version>${tyrus.version}</version>
4446
</dependency>
4547

48+
<dependency>
49+
<groupId>org.javassist</groupId>
50+
<artifactId>javassist</artifactId>
51+
<version>${javassist.version}</version>
52+
</dependency>
53+
4654
<dependency>
4755
<groupId>ch.qos.logback</groupId>
4856
<artifactId>logback-classic</artifactId>
@@ -83,28 +91,10 @@
8391
<version>${easy.mock.version}</version>
8492
<scope>test</scope>
8593
</dependency>
86-
<dependency>
87-
<groupId>org.jacoco</groupId>
88-
<artifactId>jacoco-maven-plugin</artifactId>
89-
<version>${jacoco.version}</version>
90-
<scope>test</scope>
91-
</dependency>
9294
<dependency>
9395
<groupId>org.glassfish.tyrus</groupId>
9496
<artifactId>tyrus-server</artifactId>
95-
<version>${tyrus.server.version}</version>
96-
<scope>test</scope>
97-
</dependency>
98-
<dependency>
99-
<groupId>org.glassfish.tyrus</groupId>
100-
<artifactId>tyrus-container-grizzly-server</artifactId>
101-
<version>${tyrus.server.version}</version>
102-
<scope>test</scope>
103-
</dependency>
104-
<dependency>
105-
<groupId>org.glassfish.tyrus</groupId>
106-
<artifactId>tyrus-spi</artifactId>
107-
<version>${tyrus.server.version}</version>
97+
<version>${tyrus.version}</version>
10898
<scope>test</scope>
10999
</dependency>
110100
<dependency>
@@ -126,6 +116,7 @@
126116
<plugin>
127117
<groupId>org.jacoco</groupId>
128118
<artifactId>jacoco-maven-plugin</artifactId>
119+
<version>${jacoco.version}</version>
129120
<executions>
130121
<execution>
131122
<id>pre-unit-test</id>
Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,43 @@
11
package com.github.kklisura.cdtp;
22

3+
import com.github.kklisura.cdtp.services.ChromeDevToolsService;
4+
import com.github.kklisura.cdtp.services.ChromeService;
5+
import com.github.kklisura.cdtp.services.impl.ChromeServiceImpl;
6+
import com.github.kklisura.cdtp.services.model.chrome.ChromeTab;
7+
38
/**
49
* Hello world!
510
*
611
*/
712
public class App {
8-
public static void main( String[] args ) {
13+
public static void main( String[] args ) throws Exception {
14+
final ChromeService chromeService = new ChromeServiceImpl(9222);
15+
final ChromeTab tab = chromeService.createTab();
16+
17+
try (ChromeDevToolsService cdtpService = chromeService.createDevToolsService(tab)) {
18+
19+
// Network requestWillBeSent event
20+
// Page loadEventFired
21+
22+
cdtpService.getPage().navigate("http://google.com");
23+
cdtpService.getPage().navigate("http://twitter.com");
24+
cdtpService.getPage().navigate("http://facebook.com");
25+
26+
cdtpService.getPage().navigate("http://atlantbh.com");
27+
}
28+
29+
try (ChromeDevToolsService cdtpService = chromeService.createDevToolsService(tab)) {
30+
31+
// Network requestWillBeSent event
32+
// Page loadEventFired
33+
34+
cdtpService.getPage().navigate("http://google.com");
35+
cdtpService.getPage().navigate("http://twitter.com");
36+
cdtpService.getPage().navigate("http://facebook.com");
37+
38+
cdtpService.getPage().navigate("http://atlantbh.com");
39+
}
40+
41+
chromeService.closeTab(tab);
942
}
1043
}

cdtp-java-client/src/main/java/com/github/kklisura/cdtp/client/services/impl/ChromeServiceImpl.java

Lines changed: 0 additions & 161 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.github.kklisura.cdtp.services;
2+
3+
import com.github.kklisura.cdtp.protocol.ChromeDevTools;
4+
import com.github.kklisura.cdtp.services.exceptions.ChromeDevToolsInvocationException;
5+
import com.github.kklisura.cdtp.services.model.chrome.MethodInvocation;
6+
7+
/**
8+
* Chrome dev tools service.
9+
*
10+
* @author Kenan Klisura
11+
*/
12+
public interface ChromeDevToolsService extends ChromeDevTools, AutoCloseable {
13+
/**
14+
* Invokes a dev tools method.
15+
*
16+
* @param returnProperty Return property.
17+
* @param clazz Return class type.
18+
* @param methodInvocation Method invocation definition.
19+
* @param <T> Type of a return class.
20+
* @return Return object.
21+
* @throws ChromeDevToolsInvocationException If invocation fails.
22+
*/
23+
<T> T invoke(String returnProperty, Class<T> clazz, MethodInvocation methodInvocation);
24+
25+
/**
26+
* Closes the dev tools service.
27+
*/
28+
void close();
29+
}

cdtp-java-client/src/main/java/com/github/kklisura/cdtp/client/services/ChromeService.java renamed to cdtp-java-client/src/main/java/com/github/kklisura/cdtp/services/ChromeService.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package com.github.kklisura.cdtp.client.services;
1+
package com.github.kklisura.cdtp.services;
22

3-
import com.github.kklisura.cdtp.client.services.exceptions.ChromeServiceException;
4-
import com.github.kklisura.cdtp.client.services.model.chrome.ChromeTab;
5-
import com.github.kklisura.cdtp.client.services.model.chrome.ChromeVersion;
3+
import com.github.kklisura.cdtp.services.exceptions.ChromeServiceException;
4+
import com.github.kklisura.cdtp.services.model.chrome.ChromeTab;
5+
import com.github.kklisura.cdtp.services.model.chrome.ChromeVersion;
66

77
import java.util.List;
88

@@ -20,6 +20,14 @@ public interface ChromeService {
2020
*/
2121
List<ChromeTab> getTabs() throws ChromeServiceException;
2222

23+
/**
24+
* Creates a new chrome tab that points to about:blank
25+
*
26+
* @return Chrome tab.
27+
* @throws ChromeServiceException If creation fails for any reason.
28+
*/
29+
ChromeTab createTab() throws ChromeServiceException;
30+
2331
/**
2432
* Creates a new chrome tab.
2533
*
@@ -52,4 +60,12 @@ public interface ChromeService {
5260
* @throws ChromeServiceException If request fails for any reason.
5361
*/
5462
ChromeVersion getVersion() throws ChromeServiceException;;
63+
64+
/**
65+
* Creates a dev tools service to specified tab.
66+
*
67+
* @param tab Tab.
68+
* @return Dev tools.
69+
*/
70+
ChromeDevToolsService createDevToolsService(ChromeTab tab) throws ChromeServiceException;
5571
}

cdtp-java-client/src/main/java/com/github/kklisura/cdtp/client/services/WebSocketService.java renamed to cdtp-java-client/src/main/java/com/github/kklisura/cdtp/services/WebSocketService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package com.github.kklisura.cdtp.client.services;
1+
package com.github.kklisura.cdtp.services;
22

3-
import com.github.kklisura.cdtp.client.services.exceptions.WebSocketServiceException;
3+
import com.github.kklisura.cdtp.services.exceptions.WebSocketServiceException;
44

55
import java.net.URI;
66
import java.util.function.Consumer;

0 commit comments

Comments
 (0)