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

Tests #20

Merged
merged 9 commits into from
Dec 19, 2023
Merged
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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
34 changes: 29 additions & 5 deletions tests/tests/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion tests/tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,12 @@
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
62 changes: 60 additions & 2 deletions tests/tests/src/main/java/org/example/Main.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,65 @@
package org.example;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;




public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");



public static void main(String[] args) throws IOException, InterruptedException, ExecutionException, TimeoutException {
// System.out.println("Hello world!");
// notNotOdd();
}

public int notNotOdd() throws IOException, InterruptedException, ExecutionException, TimeoutException {
ExecutorService executor = Executors.newFixedThreadPool(8);
ProcessBuilder p = new ProcessBuilder().command(new String[]{"node", "notNotOddNegCase.js"});
Process process = p.start();
StreamRead stream = new StreamRead(process.getInputStream(),System.out::println);
Future<?> future = executor.submit(stream);


while(!future.isDone()){

}
Object val = future.get(10, TimeUnit.SECONDS);
int exit = process.waitFor();


executor.shutdown();
return exit;
};

private static class StreamRead implements Runnable {
private InputStream inputStream;
private Consumer<String> consumer;

public StreamRead(InputStream inputStream, Consumer<String> consumer){
this.inputStream = inputStream;
this.consumer = consumer;
}
@Override
public void run(){
new BufferedReader(new InputStreamReader(inputStream)).lines().forEach(consumer);
}

}


}
9 changes: 9 additions & 0 deletions tests/tests/src/main/java/org/example/notNotOddNegCase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { notNotOdd } from "../../../../../../../index.js";
//this needs to become a readable stream

const main = (num) => {

return notNotOdd(num)
}

console.log(main(1));
2 changes: 2 additions & 0 deletions tests/tests/src/main/java/org/example/notNotOddPosCase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { notNotOdd } from "../../../../../../../index.js";
console.log(notNotOdd(1));
23 changes: 23 additions & 0 deletions tests/tests/src/test/java/org/example/MainTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.example;

import java.io.IOException;
import java.util.Scanner;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;

class MainTest {
Main main = new Main();


@Test
void shouldBeNotNotOdd() throws IOException, ExecutionException, InterruptedException, TimeoutException {
main.notNotOdd();
Scanner s = new Scanner(System.in);
String val = s.nextLine();
assertEquals("true", val);
}

}