Skip to content

Commit

Permalink
Do some minor cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrueden committed Jul 17, 2024
1 parent ef7d952 commit 8527595
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/apposed/appose/SharedMemory.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static SharedMemory createOrAttach(String name, boolean create, int size) {
throw new IllegalArgumentException("'name' can only be null if create=true");
}
ServiceLoader<ShmFactory> loader = ServiceLoader.load(ShmFactory.class);
for (ShmFactory factory: loader) {
for (ShmFactory factory : loader) {
SharedMemory shm = factory.create(name, create, size);
if (shm != null) return shm;
}
Expand Down
46 changes: 23 additions & 23 deletions src/test/java/org/apposed/appose/ApposeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,27 @@

public class ApposeTest {

private static final String COLLATZ_GROOVY = "" + //
"// Computes the stopping time of a given value\n" + //
"// according to the Collatz conjecture sequence.\n" + //
"time = 0\n" + //
private static final String COLLATZ_GROOVY =
"// Computes the stopping time of a given value\n" +
"// according to the Collatz conjecture sequence.\n" +
"time = 0\n" +
"BigInteger v = 9999\n" +
"while (v != 1) {\n" + //
" v = v%2==0 ? v/2 : 3*v+1\n" + //
" task.update(\"[${time}] -> ${v}\", time, null)\n" + //
" time++\n" + //
"}\n" + //
"while (v != 1) {\n" +
" v = v%2==0 ? v/2 : 3*v+1\n" +
" task.update(\"[${time}] -> ${v}\", time, null)\n" +
" time++\n" +
"}\n" +
"return time\n";

private static final String COLLATZ_PYTHON = "" + //
"# Computes the stopping time of a given value\n" + //
"# according to the Collatz conjecture sequence.\n" + //
"time = 0\n" + //
private static final String COLLATZ_PYTHON =
"# Computes the stopping time of a given value\n" +
"# according to the Collatz conjecture sequence.\n" +
"time = 0\n" +
"v = 9999\n" +
"while v != 1:\n" + //
" v = v//2 if v%2==0 else 3*v+1\n" + //
" task.update(f\"[{time}] -> {v}\", current=time)\n" + //
" time += 1\n" + //
"while v != 1:\n" +
" v = v//2 if v%2==0 else 3*v+1\n" +
" task.update(f\"[{time}] -> {v}\", current=time)\n" +
" time += 1\n" +
"task.outputs[\"result\"] = time\n";

@Test
Expand Down Expand Up @@ -108,12 +108,12 @@ public void executeAndAssert(Service service, String script)

// Record the state of the task for each event that occurs.
class TaskState {
ResponseType responseType;
TaskStatus status;
String message;
Long current;
Long maximum;
String error;
final ResponseType responseType;
final TaskStatus status;
final String message;
final Long current;
final Long maximum;
final String error;
TaskState(TaskEvent event) {
responseType = event.responseType;
status = event.task.status;
Expand Down
11 changes: 5 additions & 6 deletions src/test/java/org/apposed/appose/TypesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.LinkedHashMap;
Expand All @@ -49,7 +48,7 @@
*/
public class TypesTest {

private static String JSON = "{" +
private static final String JSON = "{" +
"\"posByte\":123,\"negByte\":-98," +
"\"posDouble\":9.876543210123456,\"negDouble\":-1.234567890987654E302," +
"\"posFloat\":9.876543,\"negFloat\":-1.2345678," +
Expand All @@ -65,13 +64,13 @@ public class TypesTest {
"\"words\":[\"quick\",\"brown\",\"fox\"]" +
"}";

private static String STRING = "-=[]\\;',./_+{}|:\"<>?" +
private static final String STRING = "-=[]\\;',./_+{}|:\"<>?" +
"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz" +
"~!@#$%^&*()";

private static int[] NUMBERS = {1, 1, 2, 3, 5, 8};
private static final int[] NUMBERS = {1, 1, 2, 3, 5, 8};

private static String[] WORDS = {"quick", "brown", "fox"};
private static final String[] WORDS = {"quick", "brown", "fox"};

@Test
public void testEncode() {
Expand Down Expand Up @@ -101,7 +100,7 @@ public void testEncode() {
}

@Test
public void testDecode() throws IOException {
public void testDecode() {
Map<String, Object> data = Types.decode(JSON);
assertNotNull(data);
assertEquals(18, data.size());
Expand Down

0 comments on commit 8527595

Please sign in to comment.