Java 类org.jetbrains.annotations.TestOnly 实例源码

项目:strictfp-back-end    文件:MySqlAdapterTest.java   
/**
     * test passed
     *
     * @throws Exception is a rubbish
     */
    @Test
    @TestOnly
    public void insert() throws Exception {
//      MySqlAdapter.getSharedInstance().insert(
//              "article",
//              "1,20170101,0,'Tech, Startalk','Tech','How to mo the older?','Tech you how to mo the older'," +
//                      "'Mo is the best way to increase your knowledge.',10000,0,1000",
//              "2,20170101,0,'Tech, Startalk','Tech','How to mo the older?'," +
//                      "'Tech you how to mo the older','Mo is the best way to increase your knowledge.',10000,0,10000"
//      );
//      System.out.println("INSERT INTO `article` VALUES (" +
//              "1,20170101,0,'Tech, Startalk','Tech','How to mo the older?','Tech you how to mo the older'," +
//              "'Mo is the best way to increase your knowledge.',10000,0,1000" +
//              "),(" +
//              "2,20170101,0,'Tech, Startalk','Tech','How to mo the older?'," +
//              "'Tech you how to mo the older','Mo is the best way to increase your knowledge.',10000,0,10000);"
//      );
    }
项目:strictfp-back-end    文件:MySqlAdapterTest.java   
/**
 * test passed
 *
 * @throws Exception is a rubbish
 */
@Test
@TestOnly
public void update() throws Exception {
    MySqlAdapter.getInstance().update(
            "article",
            new Pair[]{new Pair("click", "=23333")},
            new Pair("Id", ">=1")
    );
    /*
     * the above operation will generate query string as below
     * this is a simple example
     * but I think you can understand it
     */
    String testStr = "UPDATE article SET click=23333 WHERE Id>=1";
}
项目:intellij-ce-playground    文件:UIUtil.java   
/** @see #dispatchAllInvocationEvents() */
@TestOnly
public static void pump() {
  assert !SwingUtilities.isEventDispatchThread();
  final BlockingQueue<Object> queue = new LinkedBlockingQueue<Object>();
  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
      queue.offer(queue);
    }
  });
  try {
    queue.take();
  }
  catch (InterruptedException e) {
    LOG.error(e);
  }
}
项目:intellij-ce-playground    文件:ExtractMethodProcessor.java   
@TestOnly
public void testPrepare(PsiType returnType, boolean makeStatic) throws PrepareFailedException{
  if (makeStatic) {
    if (!isCanBeStatic()) {
      throw new PrepareFailedException("Failed to make static", myElements[0]);
    }
    myInputVariables.setPassFields(true);
    myStatic = true;
  }
  if (PsiType.VOID.equals(myReturnType)) {
    myArtificialOutputVariable = getArtificialOutputVariable();
  }
  testPrepare();
  if (returnType != null) {
    myReturnType = returnType;
  }
}
项目:intellij-ce-playground    文件:UpdateRequestsQueue.java   
@TestOnly
public void waitUntilRefreshed() {
  while (true) {
    final Semaphore semaphore = new Semaphore();
    synchronized (myLock) {
      if (!myRequestSubmitted && !myRequestRunning) {
        return;
      }

      if (!myRequestRunning) {
        myExecutor.get().schedule(new MyRunnable(), 0, TimeUnit.MILLISECONDS);
      }

      semaphore.down();
      myWaitingUpdateCompletionSemaphores.add(semaphore);
    }
    if (!semaphore.waitFor(100*1000)) {
      LOG.error("Too long VCS update");
      return;
    }
  }
}
项目:strictfp-back-end    文件:TagTest.java   
@Test
@TestOnly
public void testToString() {
    Assert.assertEquals(
            "Van",
            new Tag("Van").getName()
    );
    Random random = new Random(System.currentTimeMillis());
    run(1000, () -> {
        String s = Integer.toString(random.nextInt());
        assertEquals(s, new Tag(s).toString());
    });
}
项目:strictfp-back-end    文件:TimeLine.java   
@Test
@TestOnly
public void test() throws IOException {
    Connection con = Jsoup.connect("http://strictfp.duapp.com/timeline")
            .data("start", "2017-01-01")
            .data("end", "2017-01-02").timeout(8000);
    Document doc = con.get();
    System.out.println(doc.text());
}
项目:strictfp-back-end    文件:User.java   
@Test
@TestOnly
public void test() throws IOException {
    Connection con = Jsoup.connect("http://localhost:40000/api/v0/user").data("name", "\"Eldath\"").timeout(80000);
    Document doc = con.get();
    System.out.println(doc.text());
}
项目:strictfp-back-end    文件:JsonTest.java   
@Test
@TestOnly
public void testJson() {
    JSONObject object = new JSONObject();
    object.put("look", "quite");
    object.put("age", 16);
    object.put("haveDick", true);
    object.put("boyNextDoor", new Pair("233", "666"));
    object.put("assWeCan", new JSONObject());
    System.out.println(object.toString());
}
项目:strictfp-back-end    文件:MySqlAdapterTest.java   
@Test
@TestOnly
public void delete() throws Exception {
    MySqlAdapter.getInstance().delete(
            "article",
            new Pair("Id", "=1")
    );
    /*
     * the above code shows how to delete elements from
     * a table.
     * I think you guys can understand that.
     * LOL
     */
}
项目:intellij-ce-playground    文件:SmartPointerManagerImpl.java   
@TestOnly
public int getPointersNumber(@NotNull PsiFile containingFile) {
  synchronized (lock) {
    VirtualFile file = containingFile.getViewProvider().getVirtualFile();
    FilePointersList pointers = getPointers(file);
    return pointers == null ? 0 : pointers.size;
  }
}
项目:intellij-ce-playground    文件:PersistentFSImpl.java   
@TestOnly
private void cleanPersistedContentsRecursively(int id) {
  if (isDirectory(getFileAttributes(id))) {
    for (int child : FSRecords.list(id)) {
      cleanPersistedContentsRecursively(child);
    }
  }
  else {
    setFlag(id, MUST_RELOAD_CONTENT, true);
  }
}
项目:intellij-ce-playground    文件:DumbServiceImpl.java   
@TestOnly
public void setDumb(boolean dumb) {
  if (dumb) {
    myDumb = true;
    myPublisher.enteredDumbMode();
  }
  else {
    updateFinished();
  }
}
项目:intellij-ce-playground    文件:FileManagerImpl.java   
@TestOnly
public void checkConsistency() {
  HashMap<VirtualFile, FileViewProvider> fileToViewProvider = new HashMap<VirtualFile, FileViewProvider>(myVFileToViewProviderMap);
  myVFileToViewProviderMap.clear();
  for (VirtualFile vFile : fileToViewProvider.keySet()) {
    final FileViewProvider fileViewProvider = fileToViewProvider.get(vFile);

    LOG.assertTrue(vFile.isValid());
    PsiFile psiFile1 = findFile(vFile);
    if (psiFile1 != null && fileViewProvider != null && fileViewProvider.isPhysical()) { // might get collected
      PsiFile psi = fileViewProvider.getPsi(fileViewProvider.getBaseLanguage());
      assert psi != null : fileViewProvider +"; "+fileViewProvider.getBaseLanguage()+"; "+psiFile1;
      assert psiFile1.getClass().equals(psi.getClass()) : psiFile1 +"; "+psi + "; "+psiFile1.getClass() +"; "+psi.getClass();
    }
  }

  HashMap<VirtualFile, PsiDirectory> fileToPsiDirMap = new HashMap<VirtualFile, PsiDirectory>(myVFileToPsiDirMap);
  myVFileToPsiDirMap.clear();

  for (VirtualFile vFile : fileToPsiDirMap.keySet()) {
    LOG.assertTrue(vFile.isValid());
    PsiDirectory psiDir1 = findDirectory(vFile);
    LOG.assertTrue(psiDir1 != null);

    VirtualFile parent = vFile.getParent();
    if (parent != null) {
      LOG.assertTrue(myVFileToPsiDirMap.containsKey(parent));
    }
  }
}
项目:intellij-ce-playground    文件:MavenIndex.java   
@TestOnly
public synchronized void printInfo() {
  doIndexTask(new IndexTask<Set<String>>() {
    public Set<String> doTask() throws Exception {
      System.out.println("BaseFile: " + myData.groupToArtifactMap.getBaseFile());
      System.out.println("All data objects: " + myData.groupToArtifactMap.getAllDataObjects(null));
      return Collections.<String>emptySet();
    }
  }, Collections.<String>emptySet());
}
项目:intellij-ce-playground    文件:ExecutionEnvironment.java   
@TestOnly
public ExecutionEnvironment() {
  myProject = null;
  myContentToReuse = null;
  myRunnerAndConfigurationSettings = null;
  myExecutor = null;
  myRunner = null;
}
项目:intellij-ce-playground    文件:ExtractMethodProcessor.java   
@TestOnly
public void testPrepare() {
  myInputVariables.setFoldingAvailable(myInputVariables.isFoldingSelectedByDefault());
  myMethodName = myInitialMethodName;
  myVariableDatum = new VariableData[myInputVariables.getInputVariables().size()];
  for (int i = 0; i < myInputVariables.getInputVariables().size(); i++) {
    myVariableDatum[i] = myInputVariables.getInputVariables().get(i);
  }
}
项目:intellij-ce-playground    文件:VfsRootAccess.java   
@TestOnly
public static void allowRootAccessTemporarily(@NotNull Disposable disposable, @NotNull final String... roots) {
  for (String root : roots) {
    ourAdditionalRoots.add(FileUtil.toSystemIndependentName(root));
  }
  Disposer.register(disposable, new Disposable() {
    @Override
    public void dispose() {
      disallowRootAccess(roots);
    }
  });
}
项目:intellij-ce-playground    文件:FileWatcher.java   
@TestOnly
public void startup(@Nullable Runnable notifier) throws IOException {
  myTestNotifier = notifier;
  for (PluggableFileWatcher watcher : myWatchers) {
    watcher.startup();
  }
}
项目:intellij-ce-playground    文件:ApplicationImpl.java   
@TestOnly
public void disableEventsUntil(@NotNull Disposable disposable) {
  final List<ApplicationListener> listeners = new ArrayList<ApplicationListener>(myDispatcher.getListeners());
  myDispatcher.getListeners().removeAll(listeners);
  Disposer.register(disposable, new Disposable() {
    @Override
    public void dispose() {
      myDispatcher.getListeners().addAll(listeners);
    }
  });
}
项目:intellij-ce-playground    文件:VcsInitialization.java   
@TestOnly
public void waitForInitialized() {
  try {
    myFuture.get();
    myFuture = null;
  }
  catch (Exception e) {
    throw new RuntimeException(e);
  }
}
项目:intellij-ce-playground    文件:DaemonCodeAnalyzerImpl.java   
@NotNull
@TestOnly
public List<HighlightInfo> runPasses(@NotNull PsiFile file,
                                     @NotNull Document document,
                                     @NotNull TextEditor textEditor,
                                     @NotNull int[] toIgnore,
                                     boolean canChangeDocument,
                                     @Nullable Runnable callbackWhileWaiting) throws ProcessCanceledException {
  return runPasses(file, document, Collections.singletonList(textEditor), toIgnore, canChangeDocument, callbackWhileWaiting);
}
项目:intellij-ce-playground    文件:MultiplePsiFilesPerDocumentFileViewProvider.java   
@TestOnly
public void checkAllTreesEqual() {
  Collection<PsiFileImpl> roots = myRoots.values();
  PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getManager().getProject());
  documentManager.commitAllDocuments();
  for (PsiFile root : roots) {
    Document document = documentManager.getDocument(root);
    PsiDocumentManagerBase.checkConsistency(root, document);
    assert root.getText().equals(document.getText());
  }
}
项目:intellij-ce-playground    文件:InjectedLanguageManagerImpl.java   
@TestOnly
public static void pushInjectors(@NotNull Project project) {
  InjectedLanguageManagerImpl cachedManager = (InjectedLanguageManagerImpl)project.getUserData(INSTANCE_CACHE);
  if (cachedManager == null) return;
  try {
    assert cachedManager.myInjectorsClone.isEmpty() : cachedManager.myInjectorsClone;
  }
  finally {
    cachedManager.myInjectorsClone.clear();
  }
  cachedManager.myInjectorsClone.putAll(cachedManager.getInjectorMap().getBackingMap());
}
项目:intellij-ce-playground    文件:LiveTemplateCompletionContributor.java   
@TestOnly
public static void setShowTemplatesInTests(boolean show, @NotNull Disposable parentDisposable) {
  ourShowTemplatesInTests = show;
  Disposer.register(parentDisposable, new Disposable() {
    @Override
    public void dispose() {
      //noinspection AssignmentToStaticFieldFromInstanceMethod
      ourShowTemplatesInTests = false;
    }
  });
}
项目:intellij-ce-playground    文件:VirtualFilePointerManagerImpl.java   
@TestOnly
int numberOfPointers() {
  int number = 0;
  for (FilePointerPartNode root : myPointers.values()) {
    number = root.getPointersUnder();
  }
  return number;
}
项目:intellij-ce-playground    文件:DaemonCodeAnalyzerImpl.java   
@NotNull
@TestOnly
public static List<HighlightInfo> getHighlights(@NotNull Document document, HighlightSeverity minSeverity, @NotNull Project project) {
  List<HighlightInfo> infos = new ArrayList<HighlightInfo>();
  processHighlights(document, project, minSeverity, 0, document.getTextLength(),
                    new CommonProcessors.CollectProcessor<HighlightInfo>(infos));
  return infos;
}
项目:intellij-ce-playground    文件:LookupManagerImpl.java   
@TestOnly
public void clearLookup() {
  if (myActiveLookup != null) {
    myActiveLookup.hide();
    myActiveLookup = null;
  }
}
项目:intellij-ce-playground    文件:MavenEmbeddersManager.java   
@TestOnly
public synchronized void releaseInTests() {
  if (!myEmbeddersInUse.isEmpty()) {
    MavenLog.LOG.warn("embedders should be release first");
  }
  releasePooledEmbedders(false);
}
项目:intellij-ce-playground    文件:StatisticsManagerImpl.java   
@TestOnly
public void enableStatistics(@NotNull Disposable parentDisposable) {
  myTestingStatistics = true;
  Disposer.register(parentDisposable, new Disposable() {
    @Override
    public void dispose() {
      synchronized (LOCK) {
        Arrays.fill(myUnits, null);
      }
      myTestingStatistics = false;
    }
  });
}
项目:intellij-ce-playground    文件:MavenIndexerWrapper.java   
@TestOnly
public void releaseInTests() {
  MavenServerIndexer w = getWrappee();
  if (w == null) return;
  try {
    w.release();
  }
  catch (RemoteException e) {
    handleRemoteError(e);
  }
}
项目:intellij-ce-playground    文件:RecursionManager.java   
@TestOnly
public static void assertOnRecursionPrevention(@NotNull Disposable parentDisposable) {
  ourAssertOnPrevention = true;
  Disposer.register(parentDisposable, new Disposable() {
    @Override
    public void dispose() {
      //noinspection AssignmentToStaticFieldFromInstanceMethod
      ourAssertOnPrevention = false;
    }
  });
}
项目:intellij-ce-playground    文件:CommandTestTools.java   
/**
 * <pre>command --available-option=available_argument --option-no-argument positional_argument</pre>
 *
 * @return list cosists of fake command with opts and arguments
 */
@TestOnly
@NotNull
static List<Command> createCommands() {
  //command positional_argument --available-option=available_argument
  final Command command = EasyMock.createMock(Command.class);
  EasyMock.expect(command.getName()).andReturn("command").anyTimes();
  EasyMock.expect(command.getHelp(true)).andReturn(new Help("some_text")).anyTimes();
  EasyMock.expect(command.getHelp(false)).andReturn(new Help("some_text")).anyTimes();
  final List<Option> options = new ArrayList<Option>();


  final Pair<List<String>, Boolean> argument = Pair.create(Collections.singletonList("available_argument"), true);
  options.add(new Option(Pair.create(1, new Argument(new Help("option argument"), argument)), new Help(""),
                                     Collections.<String>emptyList(),
                                     Collections.singletonList("--available-option")));


  options.add(new Option(null, new Help(""),
                         Collections.<String>emptyList(),
                         Collections.singletonList("--option-no-argument")));

  EasyMock.expect(command.getOptions()).andReturn(options).anyTimes();


  final ArgumentsInfo argumentInfo = new KnownArgumentsInfo(Collections.singletonList(
    new Argument(new Help("positional_argument"),
                 Pair.create(Collections.singletonList("positional_argument"), true))), 1, 1);

  EasyMock.expect(command.getArgumentsInfo()).andReturn(argumentInfo)
    .anyTimes();

  EasyMock.replay(command);
  return Collections.singletonList(command);
}
项目:intellij-ce-playground    文件:VfsRootAccess.java   
@TestOnly
private static VirtualFile[] getAllRoots(@NotNull Project project) {
  insideGettingRoots = true;
  final Set<VirtualFile> roots = new THashSet<VirtualFile>();

  final OrderEnumerator enumerator = ProjectRootManager.getInstance(project).orderEntries();
  ContainerUtil.addAll(roots, enumerator.getClassesRoots());
  ContainerUtil.addAll(roots, enumerator.getSourceRoots());

  insideGettingRoots = false;
  return VfsUtilCore.toVirtualFileArray(roots);
}
项目:intellij-ce-playground    文件:Extensions.java   
@TestOnly
public static void cleanRootArea(@NotNull Disposable parentDisposable) {
  final ExtensionsAreaImpl oldRootArea = (ExtensionsAreaImpl)getRootArea();
  final ExtensionsAreaImpl newArea = createRootArea();
  ourRootArea = newArea;
  oldRootArea.notifyAreaReplaced();
  Disposer.register(parentDisposable, new Disposable() {
    @Override
    public void dispose() {
      ourRootArea = oldRootArea;
      newArea.notifyAreaReplaced();
    }
  });
}
项目:intellij-ce-playground    文件:ExtensionPointImpl.java   
@TestOnly
final synchronized void notifyAreaReplaced(final ExtensionsArea area) {
  for (final ExtensionPointListener<T> listener : myEPListeners) {
    if (listener instanceof ExtensionPointAndAreaListener) {
      ((ExtensionPointAndAreaListener)listener).areaReplaced(area);
    }
  }
}
项目:intellij-ce-playground    文件:ProductivityFeaturesRegistryImpl.java   
@TestOnly
public void prepareForTest() {
  myAdditionalFeaturesLoaded = false;
  myFeatures.clear();
  myApplicabilityFilters.clear();
  myGroups.clear();
  reloadFromXml();
}
项目:intellij-ce-playground    文件:EditorTestUtil.java   
/**
 * Configures given editor to wrap at given character count.
 *
 * @return whether any actual wraps of editor contents were created as a result of turning on soft wraps
 */
@TestOnly
public static boolean configureSoftWraps(Editor editor, final int charCountToWrapAt) {
  int charWidthInPixels = 10;
  // we're adding 1 to charCountToWrapAt, to account for wrap character width, and 1 to overall width to overcome wrapping logic subtleties
  return configureSoftWraps(editor, (charCountToWrapAt + 1) * charWidthInPixels + 1, charWidthInPixels);
}
项目:strictfp-back-end    文件:UrlTest.java   
/**
 * @throws MalformedURLException fuck it
 * @see URL#toString()
 */
@Test
@TestOnly
public void testUrlToString() throws MalformedURLException {
    DangerousWebsiteList.getInstance();
}
项目:strictfp-back-end    文件:MySqlAdapterTest.java   
@Test
@TestOnly
public void select() throws Exception {

}