Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify UTF8 encoding. #141

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.source>11</maven.compiler.source>
<mockito-core.version>2.7.17</mockito-core.version>
</properties>

Expand All @@ -45,7 +45,26 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito-core.version}</version>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.11.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
<version>1.11.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
<version>3.2</version>
<scope>runtime</scope>
</dependency>
</dependencies>

Expand Down Expand Up @@ -76,10 +95,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<version>3.8.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -116,7 +135,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.7.201606060606</version>
<version>0.8.7</version>
<executions>
<execution>
<goals>
Expand Down
9 changes: 9 additions & 0 deletions src/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module vidstige.jadb {
exports se.vidstige.jadb;
exports se.vidstige.jadb.managers;
exports se.vidstige.jadb.server;
opens se.vidstige.jadb;
opens se.vidstige.jadb.managers;
opens se.vidstige.jadb.server;

}
2 changes: 1 addition & 1 deletion src/se/vidstige/jadb/Transport.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public String readString(int length) throws IOException {
}

private String getCommandLength(String command) {
return String.format("%04x", command.getBytes().length);
return String.format("%04x", command.getBytes(StandardCharsets.UTF_8).length);
}

public void send(String command) throws IOException {
Expand Down
27 changes: 18 additions & 9 deletions test/se/vidstige/jadb/test/fakes/FakeAdbServer.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
package se.vidstige.jadb.test.fakes;

import se.vidstige.jadb.JadbException;
import se.vidstige.jadb.RemoteFile;
import se.vidstige.jadb.server.AdbDeviceResponder;
import se.vidstige.jadb.server.AdbResponder;
import se.vidstige.jadb.server.AdbServer;

import java.io.ByteArrayOutputStream;
import java.io.DataInput;
import java.io.DataOutputStream;
Expand All @@ -15,11 +9,17 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import se.vidstige.jadb.JadbException;
import se.vidstige.jadb.RemoteFile;
import se.vidstige.jadb.server.AdbDeviceResponder;
import se.vidstige.jadb.server.AdbResponder;
import se.vidstige.jadb.server.AdbServer;

/**
* Created by vidstige on 2014-03-20.
*/
public class FakeAdbServer implements AdbResponder {

private final AdbServer server;
private final List<DeviceResponder> devices = new ArrayList<>();

Expand Down Expand Up @@ -56,11 +56,13 @@ public void add(String serial, String type) {
}

public void verifyExpectations() {
for (DeviceResponder d : devices)
for (DeviceResponder d : devices) {
d.verifyExpectations();
}
}

public interface ExpectationBuilder {

void failWith(String message);

void withContent(byte[] content);
Expand All @@ -70,7 +72,9 @@ public interface ExpectationBuilder {

private DeviceResponder findBySerial(String serial) {
for (DeviceResponder d : devices) {
if (d.getSerial().equals(serial)) return d;
if (d.getSerial().equals(serial)) {
return d;
}
}
return null;
}
Expand Down Expand Up @@ -101,6 +105,7 @@ public List<AdbDeviceResponder> getDevices() {
}

private static class DeviceResponder implements AdbDeviceResponder {

private final String serial;
private final String type;
private List<FileExpectation> fileExpectations = new ArrayList<>();
Expand Down Expand Up @@ -193,6 +198,7 @@ public void verifyExpectations() {
}

private static class FileExpectation implements ExpectationBuilder {

private final RemoteFile path;
private byte[] content;
private String failMessage;
Expand Down Expand Up @@ -223,7 +229,9 @@ public boolean matches(RemoteFile path) {
}

public void throwIfFail() throws JadbException {
if (failMessage != null) throw new JadbException(failMessage);
if (failMessage != null) {
throw new JadbException(failMessage);
}
}

public void verifyContent(byte[] content) {
Expand All @@ -236,6 +244,7 @@ public void returnFile(ByteArrayOutputStream buffer) throws IOException {
}

public static class ShellExpectation {

private final String command;
private byte[] stdout;

Expand Down
188 changes: 0 additions & 188 deletions test/se/vidstige/jadb/test/unit/MockedTestCases.java

This file was deleted.