Search in sources :

Example 6 with Connection

use of com.willwinder.universalgcodesender.connection.Connection in project Universal-G-Code-Sender by winder.

the class BufferedCommunicatorTest method responseMessageOnErrorShouldPauseTheCommunicator.

@Test
public void responseMessageOnErrorShouldPauseTheCommunicator() {
    // Given
    Connection connection = mock(Connection.class);
    instance.setConnection(connection);
    asl.add(new GcodeCommand("G0"));
    asl.add(new GcodeCommand("G0"));
    instance.streamCommands();
    // When
    instance.responseMessage("error");
    // Then
    assertTrue(instance.isPaused());
}
Also used : Connection(com.willwinder.universalgcodesender.connection.Connection) GcodeCommand(com.willwinder.universalgcodesender.types.GcodeCommand) Test(org.junit.Test) GcodeStreamTest(com.willwinder.universalgcodesender.utils.GcodeStreamTest)

Example 7 with Connection

use of com.willwinder.universalgcodesender.connection.Connection in project Universal-G-Code-Sender by winder.

the class BufferedCommunicatorTest method responseMessageOnErrorOnManualCommandShouldPauseTheCommunicator.

@Test
public void responseMessageOnErrorOnManualCommandShouldPauseTheCommunicator() {
    // Given
    Connection connection = mock(Connection.class);
    instance.setConnection(connection);
    cb.add("G0");
    cb.add("G0");
    instance.streamCommands();
    // When
    instance.responseMessage("error");
    // Then
    assertTrue(instance.isPaused());
}
Also used : Connection(com.willwinder.universalgcodesender.connection.Connection) Test(org.junit.Test) GcodeStreamTest(com.willwinder.universalgcodesender.utils.GcodeStreamTest)

Example 8 with Connection

use of com.willwinder.universalgcodesender.connection.Connection in project Universal-G-Code-Sender by winder.

the class BufferedCommunicatorTest method responseMessageOnErrorOnCommandStreamShouldPauseTheCommunicator.

@Test
public void responseMessageOnErrorOnCommandStreamShouldPauseTheCommunicator() throws IOException, GcodeStreamReader.NotGcodeStreamFile {
    // Given
    Connection connection = mock(Connection.class);
    instance.setConnection(connection);
    // Create a gcode file stream
    File gcodeFile = new File(tempDir, "gcodeFile");
    GcodeStreamWriter gcodeStreamWriter = new GcodeStreamWriter(gcodeFile);
    gcodeStreamWriter.addLine("G0", "G0", null, 0);
    gcodeStreamWriter.addLine("G0", "G0", null, 0);
    gcodeStreamWriter.close();
    // Stream
    instance.queueStreamForComm(new GcodeStreamReader(gcodeFile));
    instance.streamCommands();
    // When
    instance.responseMessage("error");
    // Then
    assertTrue(instance.isPaused());
}
Also used : GcodeStreamWriter(com.willwinder.universalgcodesender.utils.GcodeStreamWriter) Connection(com.willwinder.universalgcodesender.connection.Connection) GcodeStreamReader(com.willwinder.universalgcodesender.utils.GcodeStreamReader) File(java.io.File) Test(org.junit.Test) GcodeStreamTest(com.willwinder.universalgcodesender.utils.GcodeStreamTest)

Example 9 with Connection

use of com.willwinder.universalgcodesender.connection.Connection in project Universal-G-Code-Sender by winder.

the class BufferedCommunicatorTest method responseMessageOnErrorOnLastCommandShouldNotPauseTheCommunicator.

@Test
public void responseMessageOnErrorOnLastCommandShouldNotPauseTheCommunicator() {
    // Given
    Connection connection = mock(Connection.class);
    instance.setConnection(connection);
    asl.add(new GcodeCommand("G0"));
    instance.streamCommands();
    // When
    instance.responseMessage("error");
    // Then
    assertFalse(instance.isPaused());
}
Also used : Connection(com.willwinder.universalgcodesender.connection.Connection) GcodeCommand(com.willwinder.universalgcodesender.types.GcodeCommand) Test(org.junit.Test) GcodeStreamTest(com.willwinder.universalgcodesender.utils.GcodeStreamTest)

Aggregations

Connection (com.willwinder.universalgcodesender.connection.Connection)9 GcodeStreamTest (com.willwinder.universalgcodesender.utils.GcodeStreamTest)9 Test (org.junit.Test)9 GcodeCommand (com.willwinder.universalgcodesender.types.GcodeCommand)4 GcodeStreamReader (com.willwinder.universalgcodesender.utils.GcodeStreamReader)3 GcodeStreamWriter (com.willwinder.universalgcodesender.utils.GcodeStreamWriter)3 File (java.io.File)3 SerialCommunicatorListener (com.willwinder.universalgcodesender.listeners.SerialCommunicatorListener)1