public final void testWrongExperimentID() { final ExperimentFactory factory = new ExperimentFactory( new IBoardBaseController() { @Override public void sendCommand(Command command) {} @Override public SessionID getSessionId() { return new SessionID(""); } @Override public void clean() {} @Override public void finish() {} @Override public void sendCommand(Command command, IResponseCommandCallback callback) {} @Override public void sendFile( UploadStructure uploadStructure, IResponseCommandCallback callback) {} @Override public void sendAsyncFile( UploadStructure uploadStructure, IResponseCommandCallback callback) {} @Override public void sendCommand(String command) {} @Override public void sendCommand(String command, IResponseCommandCallback callback) {} @Override public boolean isFacebook() { return false; } @Override public void sendAsyncCommand(Command command) {} @Override public void sendAsyncCommand(Command command, IResponseCommandCallback callback) {} @Override public void sendAsyncCommand(String command) {} @Override public void sendAsyncCommand(String command, IResponseCommandCallback callback) {} @Override public void stopPolling() {} @Override public void disableFinishOnClose() {} @Override public SessionID getReservationId() { return new SessionID(""); } @Override public ExperimentID getExperimentId() { return new ExperimentID("whatever", "whatever"); } }); final ExperimentLoadedCallback callback = new ExperimentLoadedCallback(); factory.experimentFactory( new ExperimentID(new Category("whatever"), "whatever"), callback, false); Assert.assertNotNull(callback.lastThrowable); Assert.assertTrue(callback.lastThrowable instanceof ExperimentNotFoundException); }
public final void testRightExperimentID() { final ExperimentFactory factory = new ExperimentFactory( new IBoardBaseController() { @Override public void sendCommand(Command command) {} @Override public SessionID getSessionId() { return new SessionID(""); } @Override public void clean() {} @Override public void finish() {} @Override public void sendCommand(Command command, IResponseCommandCallback callback) {} @Override public void sendFile( UploadStructure uploadStructure, IResponseCommandCallback callback) {} @Override public void sendAsyncFile( UploadStructure uploadStructure, IResponseCommandCallback callback) {} @Override public void sendCommand(String command) {} @Override public void sendCommand(String command, IResponseCommandCallback callback) {} @Override public boolean isFacebook() { return false; } @Override public void sendAsyncCommand(Command command) {} @Override public void sendAsyncCommand(Command command, IResponseCommandCallback callback) {} @Override public void sendAsyncCommand(String command) {} @Override public void sendAsyncCommand(String command, IResponseCommandCallback callback) {} @Override public void stopPolling() {} @Override public void disableFinishOnClose() {} @Override public SessionID getReservationId() { return new SessionID(""); } @Override public ExperimentID getExperimentId() { return new ExperimentID("PLD experiments", "ud-pld"); } }); final ExperimentLoadedCallback callback = new ExperimentLoadedCallback(); factory.experimentFactory( new ExperimentID(new Category("PLD experiments"), "ud-pld"), callback, false); System.out.println(callback.lastExperiment); Assert.assertTrue(callback.lastExperiment instanceof XilinxExperiment); factory.experimentFactory( new ExperimentID(new Category("FPGA experiments"), "ud-fpga"), callback, false); Assert.assertTrue(callback.lastExperiment instanceof XilinxExperiment); factory.experimentFactory( new ExperimentID(new Category("GPIB experiments"), "ud-gpib"), callback, false); Assert.assertTrue(callback.lastExperiment instanceof GpibExperiment); factory.experimentFactory( new ExperimentID(new Category("GPIB experiments"), "ud-gpib1"), callback, false); Assert.assertTrue(callback.lastExperiment instanceof Gpib1Board); factory.experimentFactory( new ExperimentID(new Category("GPIB experiments"), "ud-gpib2"), callback, false); Assert.assertTrue(callback.lastExperiment instanceof Gpib2Board); }