예제 #1
0
 /**
  * Test of onMessage method PUT on a ROSTER
  *
  * @throws java.io.IOException this is an error, not a failure, in the test
  * @throws jmri.JmriException this is an error, not a failure, in the test
  */
 @Test
 public void testOnMessagePutRoster() throws IOException, JmriException {
   JsonNode data = this.connection.getObjectMapper().createObjectNode().put(JSON.METHOD, JSON.PUT);
   Locale locale = Locale.ENGLISH;
   JsonException exception = null;
   JsonRosterSocketService instance = new JsonRosterSocketService(this.connection);
   try {
     instance.onMessage(JsonRoster.ROSTER, data, locale);
   } catch (JsonException ex) {
     exception = ex;
   }
   Assert.assertNotNull(exception);
   Assert.assertEquals(HttpServletResponse.SC_NOT_IMPLEMENTED, exception.getCode());
 }
예제 #2
0
 @Override
 public void propertyChange(PropertyChangeEvent e) {
   if (e.getPropertyName().equals("Appearance") || e.getPropertyName().equals("Held")) {
     try {
       try {
         connection.sendMessage(
             service.doGet(SIGNAL_HEAD, this.signalHead.getSystemName(), locale));
       } catch (JsonException ex) {
         connection.sendMessage(ex.getJsonMessage());
       }
     } catch (IOException ie) {
       // if we get an error, de-register
       signalHead.removePropertyChangeListener(this);
       signalHeads.remove(this.signalHead.getSystemName());
     }
   }
 }