예제 #1
0
 @Before
 public void setUp() throws Exception {
   ResumeTestData.init(storage.isSectionSupported());
   storage.save(ResumeTestData.R1);
   storage.save(ResumeTestData.R2);
   storage.save(ResumeTestData.R3);
 }
 public static String[] parseJarEntryFile(IStorage storage) {
   if (storage == null) return null;
   String s = storage.toString();
   if (!s.startsWith("JarEntryFile[")) return null; // $NON-NLS-1$
   s = s.substring("JarEntryFile[".length()); // $NON-NLS-1$
   int i = s.indexOf("::"); // $NON-NLS-1$
   if (i < 0) return null;
   String jarFile = s.substring(0, i);
   String entry = storage.getFullPath().toString();
   return new String[] {jarFile, entry};
 }
예제 #3
0
 @Override
 public boolean isReadOnly(Object element) {
   IStorage storage = EditorUtils.getStorageFromInput(element);
   if (storage != null) {
     return storage.isReadOnly();
   }
   File file = EditorUtils.getLocalFileFromInput(element);
   if (file != null) {
     return !file.isFile();
   }
   return super.isReadOnly(element);
 }
예제 #4
0
  @Before
  public void before() {
    R1 = new Resume("Полное Имя 1", "location1");
    R1.addContact(ContactType.MAIL, "*****@*****.**");
    R1.addContact(ContactType.PHONE, "11111");

    if (storage.isSectionSupported()) {
      R1.addObjective("Objective1");
      R1.addMultiTextSection(SectionType.ACHIEVEMENT, "Achivment11", "Achivment12");
      R1.addMultiTextSection(SectionType.QUALIFICATIONS, "Java", "Sql");
      R1.addOrganizationSection(
          SectionType.EXPERIENCE,
          new Organization(
              "Organization11",
              null,
              new Organization.Period(
                  LocalDate.of(2005, Month.JANUARY, 1),
                  Organization.Period.NOW,
                  "position1",
                  "content1"),
              new Organization.Period(
                  2001, Month.MARCH, 2005, Month.JANUARY, "position2", "content2")),
          new Organization("Organization12", "http://Organization12.ru"));

      R1.addOrganizationSection(
          SectionType.EDUCATION,
          new Organization(
              "Institute",
              null,
              new Organization.Period(
                  1996, Month.JANUARY, 2001, Month.DECEMBER, "aspirant", "IT facultet"),
              new Organization.Period(
                  2001, Month.MARCH, 2005, Month.JANUARY, "student", "IT facultet")),
          new Organization("Organization12", "http://Organization12.ru"));
    }

    R2 = new Resume("Полное Имя 2", "location2");
    R2.addContact(ContactType.SKYPE, "skype2");
    R2.addContact(ContactType.PHONE, "22222");

    R3 = new Resume("Полное Имя 3", "");

    storage.clear();

    storage.save(R3);
    storage.save(R1);
    storage.save(R2);
  }
예제 #5
0
 @Test
 public void testDeleteNotFound() throws Exception {
   thrown.expect(WebAppException.class);
   thrown.expectMessage(ExceptionType.NOT_FOUND.getMessage());
   thrown.expect(new ExceptionTypeMatcher(ExceptionType.NOT_FOUND));
   storage.load("dummy");
 }
예제 #6
0
 @Test
 public void testUpdateMissed() throws Exception {
   Resume resume = new Resume("fullName_U1", "location_U1");
   thrown.expect(WebAppException.class);
   thrown.expectMessage(ExceptionType.NOT_FOUND.getMessage());
   storage.update(resume);
 }
예제 #7
0
  @Override
  public void add(IStorage<T> item) {
    File subdir = new File(thisFolder, item.getName());
    subdir.mkdir();

    // TODO: save recursivelly the passed IStorage
    throw new UnsupportedOperationException("method is not implemented");
  }
예제 #8
0
 @Test
 public void testDelete() throws Exception {
   storage.delete(ResumeTestData.R1.getUuid());
   assertSize(2);
   assertGet(ResumeTestData.R2);
   assertGet(ResumeTestData.R3);
   thrown.expect(WebAppException.class);
   thrown.expectMessage(ExceptionType.NOT_FOUND.getMessage());
   assertGet(ResumeTestData.R1);
 }
예제 #9
0
 public StorageManager(List<StorageConf> confList) {
   for (StorageConf conf : confList) {
     if (conf == null || conf.getId() == null) {
       continue;
     }
     IStorage storage =
         ReflectionUtil.createInstanceByDefaultConstructor(
             conf.getStorageClassName(), IStorage.class);
     if (storage.init(
         conf.getId(),
         conf.getLineLimit(),
         conf.getByteLimit(),
         conf.getDestructLimit(),
         conf.getWaitTime())) {
       storage.getStat().setPeriodInSeconds(conf.getPeriod());
       storageMap.put(conf.getId(), storage);
     }
   }
 }
예제 #10
0
  @org.junit.Test
  public void testGetAllSorted() throws Exception {
    /*Resume[] src = new Resume[]{R1, R2, R3};
    Arrays.sort(src);
    Assert.assertArrayEquals(src, storage.getAllSorted().toArray());*/

    List<Resume> list = Arrays.asList(R1, R2, R3);
    Collections.sort(
        list,
        new Comparator<Resume>() {
          @Override
          public int compare(Resume o1, Resume o2) {
            return 0;
          }
        });
    Assert.assertEquals(list, storage.getAllSorted());
  }
예제 #11
0
 protected boolean setDocumentContent(IDocument document, IStorage storage) throws CoreException {
   try {
     InputStream contentStream = storage.getContents();
     try {
       String encoding =
           (storage instanceof IEncodedStorage
               ? ((IEncodedStorage) storage).getCharset()
               : GeneralUtils.getDefaultFileEncoding());
       setDocumentContent(document, contentStream, encoding);
     } finally {
       ContentUtils.close(contentStream);
     }
   } catch (IOException e) {
     throw new CoreException(GeneralUtils.makeExceptionStatus(e));
   }
   return true;
 }
예제 #12
0
 @org.junit.Test(expected = WebAppException.class)
 public void testDeleteNotFound() throws Exception {
   storage.load("dummy");
 }
예제 #13
0
 @org.junit.Test
 public void testUpdate() throws Exception {
   R2.setFullName("Updated N2");
   storage.update(R2);
   Assert.assertEquals(R2, storage.load(R2.getUuid()));
 }
예제 #14
0
 @org.junit.Test
 public void testClear() throws Exception {
   storage.clear();
   Assert.assertEquals(0, storage.size());
 }
  /** Serializes, batches, and sends events */
  protected void send() {
    // Ensure that the serialized event string is under MAXEVENTSIZEINBYTES.
    // If it is over MAXEVENTSIZEINBYTES then we should use 2 or more strings and send them
    for (IStorage storage : storages) {
      if (executorService.isShutdown()) {
        return;
      }

      List<String> events = storage.drain();
      for (String event : events) {
        this.clientTelemetry.IncrementEventsQueuedForUpload();

        // Check to see if this single serialized event is greater than MAX_BUFFER_SIZE, if it is we
        // drop it.
        if (event.length()
            > SettingsStore.getCllSettingsAsInt(SettingsStore.Settings.MAXEVENTSIZEINBYTES)) {

          // This could cause big problems if the host application decides to do a ton of processing
          // for each
          // dropped event.
          for (ICllEvents cllEvent : cllEvents) {
            cllEvent.eventDropped(event);
          }

          continue;
        }

        if (batcher.canAddToBatch(event)) {
          try {
            batcher.addEventToBatch(event);
          } catch (EventBatcher.BatchFullException e) {
            logger.error(TAG, "Could not add to batch");
          }
        } else {
          // Full batch, send events
          String batchedEvents = batcher.getBatchedEvents();

          try {
            batcher.addEventToBatch(event);
          } catch (EventBatcher.BatchFullException e) {
            logger.error(TAG, "Could not add to batch");
          }

          boolean sendResult = sendBatch(batchedEvents, storage);
          if (sendResult == false) {
            storage.close();
            return;
          }
        }
      }

      // Send remaining events that didn't fill a whole batch
      String batchedEvents = batcher.getBatchedEvents();
      boolean sendResult = sendBatch(batchedEvents, storage);
      if (sendResult == false) {
        storage.close();
        return;
      }

      storage.discard();
    }

    logger.info(TAG, "Sent " + clientTelemetry.snapshot.getEventsQueuedForUpload() + " events.");

    for (ICllEvents event : cllEvents) {
      event.sendComplete();
    }
  }
예제 #16
0
 @org.junit.Test(expected = WebAppException.class)
 public void testUpdateMissed() throws Exception {
   Resume resume = new Resume("dummy", "fullName_U1", "location_U1");
   storage.update(resume);
 }
예제 #17
0
 @org.junit.Test(expected = WebAppException.class)
 public void testSavePresented() throws Exception {
   storage.save(R1);
 }
예제 #18
0
 @org.junit.Test(expected = WebAppException.class)
 public void testDeleteMissed() throws Exception {
   storage.delete("dummy");
 }
예제 #19
0
 private void assertGet(Resume r) {
   assertEquals(r, storage.load(r.getUuid()));
 }
예제 #20
0
 @org.junit.Test
 public void testLoad() throws Exception {
   Assert.assertEquals(R1, storage.load(R1.getUuid()));
   Assert.assertEquals(R2, storage.load(R2.getUuid()));
   Assert.assertEquals(R3, storage.load(R3.getUuid()));
 }
예제 #21
0
 @org.junit.Test
 public void testDelete() throws Exception {
   storage.delete(R1.getUuid());
   Assert.assertEquals(2, storage.size());
 }
예제 #22
0
 private void assertSize(int size) {
   assertEquals(size, storage.size());
 }
예제 #23
0
 @Test
 public void testGetAllSorted() throws Exception {
   List<Resume> list = Arrays.asList(ResumeTestData.R1, ResumeTestData.R2, ResumeTestData.R3);
   assertEquals(list, new ArrayList<>(storage.getAllSorted()));
 }
예제 #24
0
 @Test
 public void testUpdate() throws Exception {
   ResumeTestData.R2.setFullName("Updated N2");
   storage.update(ResumeTestData.R2);
   assertGet(ResumeTestData.R2);
 }
예제 #25
0
 @Test
 public void testClear() throws Exception {
   storage.clear();
   assertSize(0);
 }
예제 #26
0
 @org.junit.Test
 public void testSize() throws Exception {
   Assert.assertEquals(3, storage.size());
 }
예제 #27
0
 @Test
 public void testSaveAlreadyExist() throws Exception {
   thrown.expect(WebAppException.class);
   thrown.expectMessage(ExceptionType.ALREADY_EXISTS.getMessage());
   storage.save(ResumeTestData.R1);
 }