Example #1
0
  /**
   * Processes the request for the list of files that constitute a valid backup. If a leased
   * DbBackup instance is available, it uses it, otherwise it creates a new instance and uses it
   * instead.
   */
  private void sendFileList(Protocol protocol)
      throws IOException, ProtocolException, DatabaseException {

    /* Wait for the request message. */
    protocol.read(namedChannel.getChannel(), Protocol.FileListReq.class);

    if (dbBackup == null) {
      dbBackup = new DbBackup(feederManager.getEnvImpl());
      dbBackup.startBackup();
    } else {
      feederManager.leaseRenewalCount++;
    }

    /*
     * Remove the subdirectory header of the log files, because the nodes
     * that need to copy those log files may not configure the spreading
     * log files into sub directories feature.
     */
    String[] files = dbBackup.getLogFilesInBackupSet();
    for (int i = 0; i < files.length; i++) {
      if (files[i].contains(File.separator)) {
        files[i] = files[i].substring(files[i].indexOf(File.separator) + 1, files[i].length());
      }
    }

    protocol.write(protocol.new FileListResp(files), namedChannel);
  }
  /** This method test a few specila inquirey fields are set up properly. */
  @Test
  public void testGetInquiryUrl() {
    Protocol protocol = initProtocol();

    final KcPersonService kcPersonService = context.mock(KcPersonService.class);
    final String principalId = GlobalVariables.getUserSession().getPrincipalId();
    context.checking(
        new Expectations() {
          {
            one(kcPersonService).getKcPersonByPersonId(principalId);
            will(returnValue(KcPerson.fromPersonId(principalId)));
          }
        });
    protocolLookupableHelperServiceImpl.setKcPersonService(kcPersonService);

    HtmlData inquiryUrl =
        protocolLookupableHelperServiceImpl.getInquiryUrl(protocol, "leadUnitNumber");
    assertEquals(((HtmlData.AnchorHtmlData) inquiryUrl).getHref(), UNIT_INQ_URL);
    inquiryUrl = protocolLookupableHelperServiceImpl.getInquiryUrl(protocol, "investigator");
    assertEquals(((HtmlData.AnchorHtmlData) inquiryUrl).getHref(), PERSON_INQ_URL);
    ProtocolPerson protocolPerson = (ProtocolPerson) protocol.getProtocolPersons().get(0);
    protocolPerson.setPersonId("");
    protocolPerson.setRolodexId(new Integer(1727));
    protocol.getProtocolPersons().clear();
    protocol.getProtocolPersons().add(protocolPerson);
    inquiryUrl = protocolLookupableHelperServiceImpl.getInquiryUrl(protocol, "investigator");
    assertEquals(((HtmlData.AnchorHtmlData) inquiryUrl).getHref(), ROLODEX_INQ_URL);
  }
Example #3
0
  /**
   * Verify that the protocols are compatible, switch to a different protocol version, if we need
   * to.
   */
  private Protocol checkProtocol(Protocol protocol) throws IOException, ProtocolException {

    ClientVersion clientVersion =
        protocol.read(namedChannel.getChannel(), Protocol.ClientVersion.class);
    clientId = clientVersion.getNodeId();
    FeederManager.Lease lease = feederManager.leases.get(clientId);
    if (lease != null) {
      dbBackup = lease.terminate();
    }
    feederManager.feeders.put(clientId, this);
    if (clientVersion.getVersion() != protocol.getVersion()) {
      String message =
          "Client requested protocol version: "
              + clientVersion.getVersion()
              + " but the server version is "
              + protocol.getVersion();

      /*
       * Simply log the difference on the server, it's up to the client
       * to reject the protocol version, if it can't accommodate it.
       */
      LoggerUtils.warning(logger, feederManager.getEnvImpl(), message);
    }
    protocol.write(protocol.new ServerVersion(), namedChannel);

    /* In future we may switch protocol versions to accommodate the client.
     * For now, simply return the one and only version.
     */
    return protocol;
  }
 /** Update fixed data. */
 public void updateFixedData() {
   Protocol p = device.getProtocol();
   device.setValues(p.getDeviceParmValues());
   fixedData.getDocument().removeDocumentListener(this);
   fixedData.setText(device.getFixedData().toString());
   fixedData.getDocument().addDocumentListener(this);
 }
 public static void createNewVoicemail(Context context) {
   VibratePattern vibratePattern =
       createVibratePatternFromPreference(context, "settingsVoicemailNumberBuzzes");
   String description = "New Voicemail";
   Bitmap icon = Utils.getBitmap(context, "voicemail.bmp");
   if (MetaWatchService.watchType == WatchType.DIGITAL) {
     Bitmap bitmap =
         smartLines(context, icon, "Voicemail", new String[] {"You have", "new voicemail"});
     Notification.addBitmapNotification(
         context,
         bitmap,
         vibratePattern,
         Notification.getDefaultNotificationTimeout(context),
         description);
   } else {
     Notification.addOledNotification(
         context,
         Protocol.createOled1line(context, icon, "Voicemail"),
         Protocol.createOled2lines(context, "You have", "new voicemail"),
         null,
         0,
         vibratePattern,
         description);
   }
 }
 public static void createBatterylow(Context context) {
   VibratePattern vibratePattern =
       createVibratePatternFromPreference(context, "settingsBatteryNumberBuzzes");
   StringBuilder builder = new StringBuilder();
   builder.append(Monitors.BatteryData.level);
   builder.append("%");
   String description = "Battery low";
   Bitmap icon = Utils.getBitmap(context, "batterylow.bmp");
   if (MetaWatchService.watchType == WatchType.DIGITAL) {
     Bitmap bitmap =
         smartLines(
             context, icon, "Battery", new String[] {"Phone battery at", builder.toString()});
     Notification.addBitmapNotification(
         context,
         bitmap,
         vibratePattern,
         Notification.getDefaultNotificationTimeout(context),
         description);
   } else {
     Notification.addOledNotification(
         context,
         Protocol.createOled1line(context, icon, "Warning!"),
         Protocol.createOled2lines(context, "Phone battery at", builder.toString()),
         null,
         0,
         vibratePattern,
         description);
   }
 }
  /** Update. */
  public void update() {
    Protocol p = device.getProtocol();
    p.setDeviceParms(device.getValues());
    updateParameters();
    protocolList.setSelectedItem(p);
    if (protocolList.getSelectedItem() != p) {
      protocolList.addItem(p);
      protocolList.setSelectedItem(p);
    }
    fixedData.getDocument().removeDocumentListener(this);
    protocolID.getDocument().removeDocumentListener(this);
    deviceNotes.getDocument().removeDocumentListener(this);

    fixedData.setText(device.getFixedData().toString());
    Hex id = p.getID(remote);
    if (id != null) protocolID.setText(id.toString());
    else protocolID.setText(null);
    deviceNotes.setText(device.getNotes());

    fixedData.getDocument().addDocumentListener(this);
    protocolID.getDocument().addDocumentListener(this);
    deviceNotes.getDocument().addDocumentListener(this);

    protocolNotes.setText(p.getNotes());
    protocolNotes.setCaretPosition(0);
  }
 public static void createGmail(
     Context context, String sender, String email, String subject, String snippet) {
   VibratePattern vibratePattern =
       createVibratePatternFromPreference(context, "settingsGmailNumberBuzzes");
   Bitmap icon = Utils.getBitmap(context, "gmail.bmp");
   String description = "Gmail: " + sender;
   if (MetaWatchService.watchType == WatchType.DIGITAL) {
     Bitmap bitmap = smartLines(context, icon, "Gmail", new String[] {sender, email, subject});
     Notification.addBitmapNotification(
         context,
         bitmap,
         vibratePattern,
         Notification.getDefaultNotificationTimeout(context),
         description);
     Notification.addTextNotification(
         context,
         snippet,
         Notification.VibratePattern.NO_VIBRATE,
         Notification.getDefaultNotificationTimeout(context));
   } else {
     byte[] scroll = new byte[800];
     int len = Protocol.createOled2linesLong(context, snippet, scroll);
     Notification.addOledNotification(
         context,
         Protocol.createOled2lines(context, "Gmail from " + sender, email),
         Protocol.createOled2lines(context, subject, snippet),
         scroll,
         len,
         vibratePattern,
         description);
   }
 }
 public static void createOtherNotification(
     Context context, Bitmap icon, String appName, String notificationText, int buzzes) {
   VibratePattern vibratePattern;
   if (buzzes != -1) {
     vibratePattern = createVibratePatternFromBuzzes(buzzes);
   } else {
     vibratePattern =
         createVibratePatternFromPreference(context, "settingsOtherNotificationNumberBuzzes");
   }
   if (icon == null) {
     icon = Utils.getBitmap(context, "notify.bmp");
   }
   String description = appName;
   if (MetaWatchService.watchType == WatchType.DIGITAL) {
     Bitmap bitmap = smartLines(context, icon, appName, new String[] {notificationText});
     Notification.addBitmapNotification(
         context,
         bitmap,
         vibratePattern,
         Notification.getDefaultNotificationTimeout(context),
         description);
   } else {
     byte[] scroll = new byte[800];
     int len = Protocol.createOled2linesLong(context, notificationText, scroll);
     Notification.addOledNotification(
         context,
         Protocol.createOled1line(context, icon, appName),
         Protocol.createOled2lines(context, "Notification", notificationText),
         scroll,
         len,
         vibratePattern,
         description);
   }
 }
 public static void createWinamp(Context context, String artist, String track, String album) {
   VibratePattern vibratePattern =
       createVibratePatternFromPreference(context, "settingsMusicNumberBuzzes");
   Bitmap icon = Utils.getBitmap(context, "winamp.bmp");
   String description = "Winamp: " + track;
   if (MetaWatchService.watchType == WatchType.DIGITAL) {
     Bitmap bitmap = smartLines(context, icon, "Winamp", new String[] {track, album, artist});
     Notification.addBitmapNotification(
         context,
         bitmap,
         vibratePattern,
         Notification.getDefaultNotificationTimeout(context),
         description);
   } else {
     byte[] scroll = new byte[800];
     int len = Protocol.createOled2linesLong(context, track, scroll);
     Notification.addOledNotification(
         context,
         Protocol.createOled1line(context, icon, artist),
         Protocol.createOled2lines(context, album, track),
         scroll,
         len,
         vibratePattern,
         description);
   }
 }
 public static void createAlarm(Context context) {
   VibratePattern vibratePattern =
       createVibratePatternFromPreference(context, "settingsAlarmNumberBuzzes");
   final Calendar t = Calendar.getInstance();
   final String currentTime = DateFormat.getTimeFormat(context).format(t.getTime());
   Bitmap icon = Utils.getBitmap(context, "timer.bmp");
   String description = "Alarm";
   if (MetaWatchService.watchType == WatchType.DIGITAL) {
     Bitmap bitmap =
         smartLines(context, icon, "Alarm", new String[] {currentTime}, FontCache.FontSize.LARGE);
     Notification.addBitmapNotification(
         context,
         bitmap,
         vibratePattern,
         Notification.getDefaultNotificationTimeout(context),
         description);
   } else {
     Notification.addOledNotification(
         context,
         Protocol.createOled1line(context, icon, "Alarm"),
         Protocol.createOled1line(context, null, currentTime),
         null,
         0,
         vibratePattern,
         description);
   }
 }
 public static void createTimezonechange(Context context) {
   VibratePattern vibratePattern =
       createVibratePatternFromPreference(context, "settingsTimezoneNumberBuzzes");
   TimeZone tz = TimeZone.getDefault();
   Bitmap icon = Utils.getBitmap(context, "timezone.bmp");
   String description = "Timezone Changed";
   if (MetaWatchService.watchType == WatchType.DIGITAL) {
     Bitmap bitmap =
         smartLines(
             context, icon, "Timezone", new String[] {"Timezone Changed", tz.getDisplayName()});
     Notification.addBitmapNotification(
         context,
         bitmap,
         vibratePattern,
         Notification.getDefaultNotificationTimeout(context),
         description);
   } else {
     Notification.addOledNotification(
         context,
         Protocol.createOled1line(context, icon, "Timezone"),
         Protocol.createOled1line(context, null, tz.getDisplayName()),
         null,
         0,
         vibratePattern,
         description);
   }
 }
 public static void createTouchdownMail(Context context, String title, String ticker) {
   VibratePattern vibratePattern =
       createVibratePatternFromPreference(context, "settingsTDNumberBuzzes");
   Bitmap icon = Utils.getBitmap(context, "email.bmp");
   String description = "TouchDown: " + title;
   if (MetaWatchService.watchType == WatchType.DIGITAL) {
     Bitmap bitmap = smartLines(context, icon, "TouchDown", new String[] {title, ticker});
     Notification.addBitmapNotification(
         context,
         bitmap,
         vibratePattern,
         Notification.getDefaultNotificationTimeout(context),
         description);
   } else {
     byte[] scroll = new byte[800];
     int len = Protocol.createOled2linesLong(context, ticker, scroll);
     Notification.addOledNotification(
         context,
         Protocol.createOled1line(context, icon, "TouchDown"),
         Protocol.createOled2lines(context, title, ticker),
         scroll,
         len,
         vibratePattern,
         description);
   }
 }
 public static void createCalendar(Context context, String text) {
   VibratePattern vibratePattern =
       createVibratePatternFromPreference(context, "settingsCalendarNumberBuzzes");
   Bitmap icon = Utils.getBitmap(context, "calendar.bmp");
   String description = "Cal: " + text;
   if (MetaWatchService.watchType == WatchType.DIGITAL) {
     Bitmap bitmap = smartLines(context, icon, "Calendar", new String[] {text});
     Notification.addBitmapNotification(
         context,
         bitmap,
         vibratePattern,
         Notification.getDefaultNotificationTimeout(context),
         description);
   } else {
     byte[] scroll = new byte[800];
     int len = Protocol.createOled2linesLong(context, text, scroll);
     Notification.addOledNotification(
         context,
         Protocol.createOled1line(context, icon, "  Calendar"),
         Protocol.createOled2lines(context, "Event Reminder:", text),
         scroll,
         len,
         vibratePattern,
         description);
   }
 }
 public static void createMMS(Context context, String number) {
   String name = Utils.getContactNameFromNumber(context, number);
   VibratePattern vibratePattern =
       createVibratePatternFromPreference(context, "settingsSMSNumberBuzzes");
   Bitmap icon = Utils.getBitmap(context, "message.bmp");
   String description = "MMS: " + name;
   if (MetaWatchService.watchType == WatchType.DIGITAL) {
     Bitmap bitmap = smartLines(context, icon, "MMS from", new String[] {name});
     Notification.addBitmapNotification(
         context,
         bitmap,
         vibratePattern,
         Notification.getDefaultNotificationTimeout(context),
         description);
   } else {
     byte[] scroll = new byte[800];
     int len = Protocol.createOled2linesLong(context, name, scroll);
     Notification.addOledNotification(
         context,
         Protocol.createOled1line(context, icon, "MMS from"),
         Protocol.createOled2lines(context, name, ""),
         scroll,
         len,
         vibratePattern,
         description);
   }
 }
 public static void createGmailBlank(Context context, String recipient, int count) {
   VibratePattern vibratePattern =
       createVibratePatternFromPreference(context, "settingsGmailNumberBuzzes");
   String messages = count + " new " + (count == 1 ? "message" : "messages");
   Bitmap icon = Utils.getBitmap(context, "gmail.bmp");
   String description = "Gmail: unread " + count;
   if (MetaWatchService.watchType == WatchType.DIGITAL) {
     Bitmap bitmap = smartLines(context, icon, "Gmail", new String[] {messages, recipient});
     Notification.addBitmapNotification(
         context,
         bitmap,
         vibratePattern,
         Notification.getDefaultNotificationTimeout(context),
         description);
   } else {
     byte[] scroll = new byte[800];
     int len = Protocol.createOled2linesLong(context, recipient, scroll);
     Notification.addOledNotification(
         context,
         Protocol.createOled1line(context, icon, " Gmail"),
         Protocol.createOled2lines(context, messages, recipient),
         scroll,
         len,
         vibratePattern,
         description);
   }
 }
 public static void createSmart(
     Context context,
     String title,
     String text,
     Bitmap icon,
     boolean sticky,
     VibratePattern vibratePattern) {
   if (icon == null) {
     icon = Utils.getBitmap(context, "notify.bmp");
   }
   String description = "Smart: " + text;
   if (MetaWatchService.watchType == WatchType.DIGITAL) {
     Bitmap[] bitmaps;
     if (sticky) {
       bitmaps = smartNotify(context, icon, title, text);
     } else {
       bitmaps = new Bitmap[] {smartLines(context, icon, title, new String[] {text})};
     }
     Notification.addBitmapNotification(context, bitmaps, vibratePattern, -1, description);
   } else {
     byte[] scroll = new byte[800];
     int len = Protocol.createOled2linesLong(context, text, scroll);
     Notification.addOledNotification(
         context,
         Protocol.createOled1line(context, icon, title),
         Protocol.createOled2lines(context, title, text),
         scroll,
         len,
         vibratePattern,
         description);
   }
 }
 public static void createK9(Context context, String sender, String subject, String folder) {
   VibratePattern vibratePattern =
       createVibratePatternFromPreference(context, "settingsK9NumberBuzzes");
   Bitmap icon = Utils.getBitmap(context, "email.bmp");
   String description = "K9: " + sender;
   if (MetaWatchService.watchType == WatchType.DIGITAL) {
     Bitmap bitmap = smartLines(context, icon, "K9 mail", new String[] {sender, subject, folder});
     Notification.addBitmapNotification(
         context,
         bitmap,
         vibratePattern,
         Notification.getDefaultNotificationTimeout(context),
         description);
   } else {
     byte[] scroll = new byte[800];
     int len = Protocol.createOled2linesLong(context, subject, scroll);
     Notification.addOledNotification(
         context,
         Protocol.createOled1line(context, icon, "K9 mail"),
         Protocol.createOled2lines(context, sender, subject),
         scroll,
         len,
         vibratePattern,
         description);
   }
 }
 public static void createNMA(
     Context context, String appName, String event, String desc, int prio, String url) {
   VibratePattern vibratePattern =
       createVibratePatternFromPreference(context, "settingsNMANumberBuzzes");
   Bitmap icon = Utils.getBitmap(context, "notifymyandroid.bmp");
   if (MetaWatchService.watchType == WatchType.DIGITAL) {
     Bitmap bitmap = smartLines(context, icon, appName, new String[] {event, desc});
     Notification.addBitmapNotification(
         context,
         bitmap,
         vibratePattern,
         Notification.getDefaultNotificationTimeout(context),
         appName + ": " + event);
   } else {
     byte[] scroll = new byte[800];
     int len = Protocol.createOled2linesLong(context, desc, scroll);
     Notification.addOledNotification(
         context,
         Protocol.createOled1line(context, icon, appName),
         Protocol.createOled2lines(context, event, desc),
         scroll,
         len,
         vibratePattern,
         appName + ": " + event);
   }
 }
 public static void createSMS(Context context, String number, String text) {
   String name = Utils.getContactNameFromNumber(context, number);
   VibratePattern vibratePattern =
       createVibratePatternFromPreference(context, "settingsSMSNumberBuzzes");
   Bitmap icon = Utils.getBitmap(context, "message.bmp");
   String description = "SMS: " + name;
   if (MetaWatchService.watchType == WatchType.DIGITAL) {
     if (Preferences.stickyNotifications & !number.equals("Google Chat")) {
       Bitmap[] bitmaps = smartNotify(context, icon, name, text);
       Notification.addBitmapNotification(context, bitmaps, vibratePattern, -1, description);
     } else {
       Bitmap bitmap = smartLines(context, icon, "SMS from", new String[] {name});
       Notification.addBitmapNotification(context, bitmap, vibratePattern, 4000, description);
       Notification.addTextNotification(
           context,
           text,
           Notification.VibratePattern.NO_VIBRATE,
           Notification.getDefaultNotificationTimeout(context));
     }
   } else {
     byte[] scroll = new byte[800];
     int len = Protocol.createOled2linesLong(context, text, scroll);
     Notification.addOledNotification(
         context,
         Protocol.createOled1line(context, icon, "SMS from"),
         Protocol.createOled2lines(context, name, text),
         scroll,
         len,
         vibratePattern,
         description);
   }
 }
Example #21
0
  private void saveDoc(XInterface xDoc, String sURL) {
    m_aLog.log(Protocol.TYPE_SCOPE_OPEN, "saveDoc('" + sURL + "') started ...");
    try {
      URL[] aURL = new URL[1];
      aURL[0] = new URL();
      aURL[0].Complete = ".uno:SaveAs";
      m_xURLParser.parseStrict(aURL);

      XModel xModel = UnoRuntime.queryInterface(XModel.class, xDoc);
      XDispatchProvider xProvider =
          UnoRuntime.queryInterface(XDispatchProvider.class, xModel.getCurrentController());
      XDispatch xDispatch = xProvider.queryDispatch(aURL[0], "_self", 0);

      PropertyValue[] lArgs = new PropertyValue[3];
      lArgs[0] = new PropertyValue();
      lArgs[0].Name = "URL";
      lArgs[0].Value = sURL;
      lArgs[1] = new PropertyValue();
      lArgs[1].Name = "Overwrite";
      lArgs[1].Value = Boolean.TRUE;
      lArgs[2] = new PropertyValue();
      lArgs[2].Name = "StoreTo";
      lArgs[2].Value = Boolean.TRUE;

      xDispatch.dispatch(aURL[0], lArgs);

      m_aLog.log(Protocol.TYPE_OK, "saveDoc('" + sURL + "') = OK.");
    } catch (Throwable ex) {
      m_aLog.log(ex);
    }
    m_aLog.log(Protocol.TYPE_SCOPE_CLOSE, "saveDoc('" + sURL + "') finished.");
  }
Example #22
0
  // create a calc document with content, which needs some time for saving
  private XInterface createBigCalcDoc() {
    m_aLog.log(Protocol.TYPE_SCOPE_OPEN, "createBigCalcDoc() started ...");
    try {
      m_aLog.log("Create empty calc document for testing.");
      XSpreadsheetDocument xSheetDoc = m_aSOF.createCalcDoc("_default");
      m_aLog.log("Retrieve first sheet from calc document.");
      XSpreadsheets xSheets = xSheetDoc.getSheets();
      XSpreadsheet xSheet =
          (XSpreadsheet)
              AnyConverter.toObject(
                  new Type(XSpreadsheet.class), xSheets.getByName(xSheets.getElementNames()[0]));
      m_aLog.log("Fill two cells with value and formula.");
      xSheet.getCellByPosition(0, 0).setValue(1);
      xSheet.getCellByPosition(0, 1).setFormula("=a1+1");
      m_aLog.log("Retrieve big range.");
      XCellRange xRange = xSheet.getCellRangeByName("A1:Z9999");
      XCellSeries xSeries = UnoRuntime.queryInterface(XCellSeries.class, xRange);
      m_aLog.log("Duplicate cells from top to bottom inside range.");
      xSeries.fillAuto(FillDirection.TO_BOTTOM, 2);
      m_aLog.log("Duplicate cells from left to right inside range.");
      xSeries.fillAuto(FillDirection.TO_RIGHT, 1);

      m_aLog.log(Protocol.TYPE_SCOPE_CLOSE | Protocol.TYPE_OK, "createBigCalcDoc() finished.");
      return xSheetDoc;
    } catch (Throwable ex) {
      m_aLog.log(ex);
    }

    m_aLog.log(Protocol.TYPE_SCOPE_CLOSE, "createBigCalcDoc() finished.");
    return null;
  }
Example #23
0
 @Test
 public void defaultValueTest() {
   Protocols protocols = getHabitat().getService(Protocols.class);
   for (Protocol protocol : protocols.getProtocol()) {
     Http http = protocol.getHttp();
     System.out.println(http.getCompressableMimeType());
   }
 }
 private void updateAuthGroup() {
   Protocol p = getProtocol();
   if (p != null) {
     hostText.setEnabled(p.hasHost());
     portText.setEnabled(p.hasPort());
     UIUtils.setEnabledRecursively(authGroup, p.canAuthenticate());
   }
 }
Example #25
0
 @Test
 public void testPropEquals() {
   Protocol p1 = new Protocol("P", null, "foo");
   p1.addProp("a", "1");
   Protocol p2 = new Protocol("P", null, "foo");
   p2.addProp("a", "2");
   assertFalse(p1.equals(p2));
 }
Example #26
0
  /**
   * Read a new Response from the given Protocol
   *
   * @param p the Protocol object
   */
  public Response(Protocol p) throws IOException, ProtocolException {
    // read one response into 'buffer'
    ByteArray ba = p.getResponseBuffer();
    ByteArray response = p.getInputStream().readResponse(ba);
    buffer = response.getBytes();
    size = response.getCount() - 2; // Skip the terminating CRLF

    parse();
  }
 @Test
 public void encodeSend() throws Exception {
   Message origin = messages.get(CommandType.MSG);
   Protocol protocol = new SerializationProtocol();
   byte[] data = protocol.encode(origin);
   Message copy = protocol.decode(data);
   System.out.println(copy);
   System.out.println(origin);
   assertTrue(copy.toString().equals(origin.toString()));
 }
Example #28
0
 public static Protocol getProtocol(String protocolName) {
   if (protocolName != null) {
     for (final Protocol protocol : Protocol.values()) {
       if (protocolName.equalsIgnoreCase(protocol.name())) {
         return protocol;
       }
     }
   }
   return null;
 }
 @Test
 public void testGco2() throws IOException {
   try (DataInputStream dataInputStream = streamSimulator.getDataInputStream();
       DataOutputStream dataOutputStream = streamSimulator.getDataOutputStream()) {
     Protocol protocol = new Protocol(dataInputStream, dataOutputStream);
     protocol.gco();
     Assert.fail();
   } catch (ProtocolStateException ignored) {
   }
 }
  /*
   *
   * This method is to set up protocol for get inquiry url test
   * @return
   */
  private Protocol initProtocol() {
    Protocol protocol = new Protocol();
    protocol.setLeadUnitNumber("000001");

    protocol.setPrincipalInvestigatorId("10000000001");
    ProtocolPerson protocolPerson = new ProtocolPerson();
    protocolPerson.setPersonId("10000000001");
    protocol.getProtocolPersons().add(protocolPerson);
    protocolPerson.setProtocolPersonRoleId("PI");
    return protocol;
  }