public void testRename() {
   // get light
   Reporter t1 = l.newReporter(getSystemName(getNumToTest1()), "before");
   Assert.assertNotNull("t1 real object ", t1);
   t1.setUserName("after");
   Reporter t2 = l.getByUserName("after");
   Assert.assertEquals("same object", t1, t2);
   Assert.assertEquals("no old object", null, l.getByUserName("before"));
 }
  public void testProvideUser() {
    Reporter l1 = l.provideReporter("211");
    l1.setUserName("user 1");
    Reporter l2 = l.provideReporter("user 1");
    Reporter l3 = l.getReporter("user 1");

    Assert.assertNotNull(l1);
    Assert.assertNotNull(l2);
    Assert.assertNotNull(l3);
    Assert.assertEquals(l1, l2);
    Assert.assertEquals(l3, l2);
    Assert.assertEquals(l1, l3);

    Reporter l4 = l.getReporter("JLuser 1");
    Assert.assertNull(l4);
  }
示例#3
0
 @Override
 public Object getValueAt(int row, int col) {
   if (row > sysNameList.size()) {
     return "";
   }
   OBlock b = null;
   if (row < sysNameList.size()) {
     String name = sysNameList.get(row);
     b = _manager.getBySystemName(name);
   }
   switch (col) {
     case SYSNAMECOL:
       if (b != null) {
         return b.getSystemName();
       }
       return tempRow[col];
     case USERNAMECOL:
       if (b != null) {
         return b.getUserName();
       }
       return tempRow[col];
     case COMMENTCOL:
       if (b != null) {
         return b.getComment();
       }
       return tempRow[col];
     case STATECOL:
       if (b != null) {
         int state = b.getState();
         int num = Integer.numberOfLeadingZeros(state) - 24;
         if (num >= 0) {
           return ZEROS.substring(0, num) + Integer.toBinaryString(state);
         }
       }
       return ZEROS;
     case SENSORCOL:
       if (b != null) {
         Sensor s = b.getSensor();
         if (s == null) {
           return "";
         }
         return s.getDisplayName();
       }
       return tempRow[col];
     case LENGTHCOL:
       if (b != null) {
         if (b.isMetric()) {
           return (twoDigit.format(b.getLengthCm()));
         }
         return (twoDigit.format(b.getLengthIn()));
       }
       if (tempRow[UNITSCOL].equals(Bundle.getMessage("cm"))) {
         return (twoDigit.format(_tempLen / 10));
       }
       return (twoDigit.format(_tempLen / 25.4f));
     case UNITSCOL:
       if (b != null) {
         if (log.isDebugEnabled()) {
           log.debug(
               "getValueAt: row= "
                   + row
                   + ", col= "
                   + col
                   + ", "
                   + b.getDisplayName()
                   + " isMetric= "
                   + b.isMetric());
         }
         return b.isMetric();
       }
       if (log.isDebugEnabled()) {
         log.debug(
             "getValueAt: row= "
                 + row
                 + ", col= "
                 + col
                 + ", is cm= "
                 + tempRow[UNITSCOL].equals(Bundle.getMessage("cm")));
       }
       return Boolean.valueOf(tempRow[UNITSCOL].equals(Bundle.getMessage("cm")));
     case CURVECOL:
       if (b != null) {
         String c = "";
         if (b.getCurvature() == Block.NONE) {
           c = noneText;
         } else if (b.getCurvature() == Block.GRADUAL) {
           c = gradualText;
         } else if (b.getCurvature() == Block.TIGHT) {
           c = tightText;
         } else if (b.getCurvature() == Block.SEVERE) {
           c = severeText;
         }
         return c;
       }
       return tempRow[col];
     case ERR_SENSORCOL:
       if (b != null) {
         Sensor s = b.getErrorSensor();
         if (s == null) {
           return "";
         }
         return s.getDisplayName();
       }
       return tempRow[col];
     case REPORTERCOL:
       if (b != null) {
         Reporter r = b.getReporter();
         if (r == null) {
           return "";
         }
         return r.getDisplayName();
       }
       return tempRow[col];
     case REPORT_CURRENTCOL:
       if (b != null) {
         if (b.getReporter() != null) {
           return b.isReportingCurrent();
         }
         return "";
       }
       return Boolean.valueOf(tempRow[REPORT_CURRENTCOL].equals(Bundle.getMessage("Current")));
     case PERMISSIONCOL:
       if (b != null) {
         return b.getPermissiveWorking();
       }
       return Boolean.valueOf(tempRow[PERMISSIONCOL].equals(Bundle.getMessage("Permissive")));
     case SPEEDCOL:
       if (b != null) {
         return b.getBlockSpeed();
       }
       return tempRow[col];
     case EDIT_COL:
       if (b != null) {
         return Bundle.getMessage("ButtonEditPath");
       }
       return "";
     case DELETE_COL:
       if (b != null) {
         return Bundle.getMessage("ButtonDelete");
       }
       return Bundle.getMessage("ButtonClear");
   }
   return super.getValueAt(row, col);
 }
 public void testUpperLower() {
   Reporter t = l.provideReporter("" + getNumToTest2());
   String name = t.getSystemName();
   Assert.assertNull(l.getReporter(name.toLowerCase()));
 }
  public void testDefaultNotInternal() {
    Reporter lut = l.provideReporter("211");

    Assert.assertNotNull(lut);
    Assert.assertEquals("IR211", lut.getSystemName());
  }