コード例 #1
0
ファイル: AnnotationTest.java プロジェクト: jingtaow/WALA
  @Test
  public void testClassAnnotations3() throws Exception {

    TypeReference typeRef =
        TypeReference.findOrCreate(
            ClassLoaderReference.Application, "Lannotations/AnnotatedClass3");
    IClass klass = cha.lookupClass(typeRef);
    Assert.assertNotNull(klass);
    ShrikeClass shrikeClass = (ShrikeClass) klass;
    Collection<Annotation> classAnnotations = shrikeClass.getAnnotations(true);
    Assert.assertEquals(
        "[Annotation type <Application,Lannotations/AnnotationWithParams> {strParam=classStrParam}]",
        classAnnotations.toString());

    MethodReference methodRefUnderTest =
        MethodReference.findOrCreate(typeRef, Selector.make("foo()V"));

    IMethod methodUnderTest = cha.resolveMethod(methodRefUnderTest);
    Assert.assertNotNull(methodRefUnderTest.toString() + " not found", methodUnderTest);
    Assert.assertTrue(methodUnderTest instanceof ShrikeCTMethod);
    ShrikeCTMethod shrikeCTMethodUnderTest = (ShrikeCTMethod) methodUnderTest;

    Collection<Annotation> runtimeInvisibleAnnotations =
        shrikeCTMethodUnderTest.getAnnotations(true);
    Assert.assertEquals(
        "[Annotation type <Application,Lannotations/AnnotationWithParams> {enumParam=EnumElementValue [type=Lannotations/AnnotationEnum;, val=VAL1], strArrParam=ArrayElementValue [vals=[biz, boz]], annotParam=AnnotationElementValue [type=Lannotations/AnnotationWithSingleParam;, elementValues={value=sdfevs}], strParam=sdfsevs, intParam=25, klassParam=Ljava/lang/Integer;}]",
        runtimeInvisibleAnnotations.toString());
  }
コード例 #2
0
 /** toString holds toString of elements */
 public void testToString() {
   assertEquals("[]", new CopyOnWriteArraySet().toString());
   Collection full = populatedSet(3);
   String s = full.toString();
   for (int i = 0; i < 3; ++i) assertTrue(s.contains(String.valueOf(i)));
   assertEquals(new ArrayList(full).toString(), full.toString());
 }
コード例 #3
0
  /**
   * Get a textual description of this rule.
   *
   * @return a textual description of this rule.
   */
  public String toString() {
    StringBuffer result = new StringBuffer();

    result.append(
        m_premise.toString()
            + ": "
            + m_premiseSupport
            + " ==> "
            + m_consequence.toString()
            + ": "
            + m_totalSupport
            + "   ");
    for (DefaultAssociationRule.METRIC_TYPE m : METRIC_TYPE.values()) {
      if (m.equals(m_metricType)) {
        result.append(
            "<"
                + m.toStringMetric(
                    m_premiseSupport, m_consequenceSupport, m_totalSupport, m_totalTransactions)
                + "> ");
      } else {
        result.append(
            ""
                + m.toStringMetric(
                    m_premiseSupport, m_consequenceSupport, m_totalSupport, m_totalTransactions)
                + " ");
      }
    }
    return result.toString();
  }
  /**
   * Verify that overriding a transitive compile time dependency as provided in a WAR ensures it is
   * not included.
   */
  public void testitMNG1233() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-1233");

    Verifier verifier = newVerifier(testDir.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteDirectory("target");
    verifier.deleteArtifacts("org.apache.maven.its.it0083");
    verifier.filterFile(
        "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties());
    verifier.addCliOption("--settings");
    verifier.addCliOption("settings.xml");
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    Collection<String> compileArtifacts = verifier.loadLines("target/compile.txt", "UTF-8");
    assertTrue(
        compileArtifacts.toString(),
        compileArtifacts.contains("org.apache.maven.its.it0083:direct-dep:jar:0.1"));
    assertTrue(
        compileArtifacts.toString(),
        compileArtifacts.contains("org.apache.maven.its.it0083:trans-dep:jar:0.1"));

    Collection<String> runtimeArtifacts = verifier.loadLines("target/runtime.txt", "UTF-8");
    assertTrue(
        runtimeArtifacts.toString(),
        runtimeArtifacts.contains("org.apache.maven.its.it0083:direct-dep:jar:0.1"));
    assertFalse(
        runtimeArtifacts.toString(),
        runtimeArtifacts.contains("org.apache.maven.its.it0083:trans-dep:jar:0.1"));
  }
コード例 #5
0
ファイル: MimeUtil2.java プロジェクト: deric/clueminer
  public final Collection getMimeTypes(final URL url, final MimeType unknownMimeType)
      throws MimeException {
    Collection mimeTypes = new MimeTypeHashSet();

    if (url == null) {
      log.error("URL reference cannot be null.");
    } else {
      if (log.isDebugEnabled()) {
        log.debug("Getting MIME types for URL [" + url + "].");
      }

      // Test if this is a directory
      File file = new File(url.getPath());
      if (file.isDirectory()) {
        mimeTypes.add(MimeUtil2.DIRECTORY_MIME_TYPE);
      } else {
        // defer these calls to the file name and stream methods
        mimeTypes.addAll(mimeDetectorRegistry.getMimeTypes(url));

        // We don't want the unknownMimeType added to the collection by MimeDetector(s)
        mimeTypes.remove(unknownMimeType);
      }
    }
    // If the collection is empty we want to add the unknownMimetype
    if (mimeTypes.isEmpty()) {
      mimeTypes.add(unknownMimeType);
    }
    if (log.isDebugEnabled()) {
      log.debug("Retrieved MIME types [" + mimeTypes.toString() + "]");
    }
    return mimeTypes;
  }
コード例 #6
0
ファイル: MimeUtil2.java プロジェクト: deric/clueminer
  /**
   * Get all of the matching mime types for this file name . The method delegates down to each of
   * the registered MimeHandler(s) and returns a normalised list of all matching mime types. If no
   * matching mime types are found the returned Collection will contain the unknownMimeType passed
   * in.
   *
   * @param fileName the name of a file to detect.
   * @param unknownMimeType.
   * @return the Collection of matching mime types. If the collection would be empty i.e. no matches
   *     then this will contain the passed in parameter unknownMimeType
   * @throws MimeException if there are problems such as reading files generated when the
   *     MimeHandler(s) executed.
   */
  public final Collection getMimeTypes(final String fileName, final MimeType unknownMimeType)
      throws MimeException {
    Collection mimeTypes = new MimeTypeHashSet();

    if (fileName == null) {
      log.error("fileName cannot be null.");
    } else {
      if (log.isDebugEnabled()) {
        log.debug("Getting MIME types for file name [" + fileName + "].");
      }

      // Test if this is a directory
      File file = new File(fileName);

      if (file.isDirectory()) {
        mimeTypes.add(MimeUtil2.DIRECTORY_MIME_TYPE);
      } else {
        mimeTypes.addAll(mimeDetectorRegistry.getMimeTypes(fileName));

        // We don't want the unknownMimeType added to the collection by MimeDetector(s)
        mimeTypes.remove(unknownMimeType);
      }
    }
    // If the collection is empty we want to add the unknownMimetype
    if (mimeTypes.isEmpty()) {
      mimeTypes.add(unknownMimeType);
    }
    if (log.isDebugEnabled()) {
      log.debug("Retrieved MIME types [" + mimeTypes.toString() + "]");
    }
    return mimeTypes;
  }
コード例 #7
0
ファイル: MimeUtil2.java プロジェクト: deric/clueminer
  /**
   * Get all of the matching mime types for this InputStream object. The method delegates down to
   * each of the registered MimeHandler(s) and returns a normalised list of all matching mime types.
   * If no matching mime types are found the returned Collection will contain the unknownMimeType
   * passed in.
   *
   * @param in the InputStream object to detect.
   * @param unknownMimeType.
   * @return the Collection of matching mime types. If the collection would be empty i.e. no matches
   *     then this will contain the passed in parameter unknownMimeType
   * @throws MimeException if there are problems such as reading files generated when the
   *     MimeHandler(s) executed.
   */
  public final Collection getMimeTypes(final InputStream in, final MimeType unknownMimeType)
      throws MimeException {
    Collection mimeTypes = new MimeTypeHashSet();

    if (in == null) {
      log.error("InputStream reference cannot be null.");
    } else {
      if (!in.markSupported()) {
        throw new MimeException("InputStream must support the mark() and reset() methods.");
      }
      if (log.isDebugEnabled()) {
        log.debug("Getting MIME types for InputSteam [" + in + "].");
      }
      mimeTypes.addAll(mimeDetectorRegistry.getMimeTypes(in));

      // We don't want the unknownMimeType added to the collection by MimeDetector(s)
      mimeTypes.remove(unknownMimeType);
    }
    // If the collection is empty we want to add the unknownMimetype
    if (mimeTypes.isEmpty()) {
      mimeTypes.add(unknownMimeType);
    }
    if (log.isDebugEnabled()) {
      log.debug("Retrieved MIME types [" + mimeTypes.toString() + "]");
    }
    return mimeTypes;
  }
コード例 #8
0
  /** @throws Exception If failed. */
  public void testNames() throws Exception {
    assertEquals("value1", svc.cacheable(1));

    Collection<String> names = mgr.getCacheNames();

    assertEquals(names.toString(), 2, names.size());
  }
コード例 #9
0
  /**
   * Loads all GROUPValueObjects through the business facade using information in the
   * HttpServletRequest.
   *
   * @return String as result
   * @exception ProcessingException
   */
  public String loadAllGROUPs() throws ProcessingException {
    String sReturnValue = null;

    logMessage(FrameworkLogEventType.DEBUG_LOG_EVENT_TYPE, "Inside GROUPWorkerBean::loadAllGROUPs");

    try {
      // load the GROUPValueObject
      Collection coll = GROUPProxy.getGROUPs();

      if (coll != null) {
        logMessage(
            FrameworkLogEventType.DEBUG_LOG_EVENT_TYPE,
            "GROUPWorkerBean:loadAllGROUPs() - successfully loaded all GROUPValueObjects - "
                + coll.toString());

        // assign the GROUPValueObject to the ApplicationUSOM
        ApplicationUSOM objectManager = (ApplicationUSOM) getUSOM();
        objectManager.setGROUPs(coll);
      }
    } catch (Exception exc) {
      throw new ProcessingException(
          "GROUPWorkerBean:loadAllGROUPs() - successfully loaded all GROUPValueObjects - " + exc,
          exc);
    }

    return (sReturnValue);
  }
コード例 #10
0
ファイル: MimeUtil2.java プロジェクト: deric/clueminer
  /**
   * Get a Collection of possible MimeType(s) that this byte array could represent according to the
   * registered MimeDetector(s). If no MimeType(s) are detected then the returned Collection will
   * contain only the passed in unknownMimeType
   *
   * @param data
   * @param unknownMimeType used if the registered MimeDetector(s) fail to match any MimeType(s)
   * @return all matching MimeType(s)
   * @throws MimeException
   */
  public final Collection getMimeTypes(final byte[] data, final MimeType unknownMimeType)
      throws MimeException {
    Collection mimeTypes = new MimeTypeHashSet();
    if (data == null) {
      log.error("byte array cannot be null.");
    } else {
      if (log.isDebugEnabled()) {
        try {
          log.trace("Getting MIME types for byte array [" + StringUtil.getHexString(data) + "].");
        } catch (UnsupportedEncodingException e) {
          throw new MimeException(e);
        }
      }
      mimeTypes.addAll(mimeDetectorRegistry.getMimeTypes(data));

      // We don't want the unknownMimeType added to the collection by MimeDetector(s)
      mimeTypes.remove(unknownMimeType);
    }

    // If the collection is empty we want to add the unknownMimetype
    if (mimeTypes.isEmpty()) {
      mimeTypes.add(unknownMimeType);
    }
    if (log.isDebugEnabled()) {
      log.debug("Retrieved MIME types [" + mimeTypes.toString() + "]");
    }
    return mimeTypes;
  }
コード例 #11
0
  @Override
  protected void formOK(UserRequest ureq) {
    if (importKeys.isVisible() && importKeys.getSelectedKeys().size() > 0) {
      Collection<String> importLangKeys = importKeys.getSelectedKeys();
      Set<String> alreadyInstalledLangs = new HashSet<String>();
      for (String langKey : importLangKeys) {
        if (I18nModule.getAvailableLanguageKeys().contains(langKey)) {
          alreadyInstalledLangs.add(langKey);
        }
      }
      if (I18nModule.isTransToolEnabled()) {
        // In translation mode importing will copy the language package
        // over an existing language or create a new language
        File tmpJar = importFile.getUploadFile();
        I18nManager.getInstance().copyLanguagesFromJar(tmpJar, importLangKeys);
        logAudit("Uploaded languages from jar::" + importFile.getUploadFileName(), null);
        showInfo("configuration.management.package.import.success", importLangKeys.toString());

      } else {
        // In language adaption mode: import is copied to user managed i18n package space in
        // olatdata
        if (alreadyInstalledLangs.size() == importLangKeys.size()) {
          showError("configuration.management.package.import.failure.installed");
          return;
        }
        // Ok, contains at least one language, copy to lang pack dir
        importFile.moveUploadFileTo(I18nModule.LANG_PACKS_DIRECTORY);
        logAudit("Uploaded language pack::" + importFile.getUploadFileName(), null);

        if (alreadyInstalledLangs.size() > 0) {
          getWindowControl()
              .setWarning(
                  getTranslator()
                      .translate(
                          "configuration.management.package.import.success.with.existing",
                          new String[] {
                            importLangKeys.toString(), alreadyInstalledLangs.toString()
                          }));
        } else {
          showInfo("configuration.management.package.import.success", importLangKeys.toString());
        }
      }
      // Reset i18n system
      I18nModule.reInitializeAndFlushCache();
      fireEvent(ureq, Event.DONE_EVENT);
    }
  }
 @Override
 public Optional<String> getValueDescription(MutableModelNode modelNodeInternal) {
   Collection<?> values = ScalarCollectionSchema.get(modelNodeInternal);
   if (values == null) {
     return Optional.absent();
   }
   return Optional.of(values.toString());
 }
コード例 #13
0
 protected boolean fail(
     String reasonForFailure, Collection<? extends E> item, Description mismatchDescription) {
   mismatchDescription.appendText(reasonForFailure);
   mismatchDescription.appendText(" <");
   mismatchDescription.appendText(item.toString());
   mismatchDescription.appendText(">");
   return false;
 }
コード例 #14
0
 // fail with helpful message if e.g. we are asserting a Set .equals a List
 private static void compatibleCollections(Collection a, Collection b) {
   if (a.getClass().isAssignableFrom(b.getClass())
       || b.getClass().isAssignableFrom(a.getClass())) {
     TestCase.assertEquals(a, b);
   } else {
     TestCase.fail(
         "Collections are of incompatible types: "
             + a.getClass()
             + " ("
             + a.toString()
             + ") and "
             + b.getClass()
             + " ("
             + b.toString()
             + ").");
   }
 }
コード例 #15
0
  @SuppressWarnings("rawtypes")
  @Override
  protected Collection acquireJobs() {
    Collection jobs = Collections.EMPTY_LIST;

    if ((isActive) && (!alfrescoJobExecutor.getTransactionService().isReadOnly())) {
      try {
        jobs =
            alfrescoJobExecutor
                .getTransactionService()
                .getRetryingTransactionHelper()
                .doInTransaction(
                    new RetryingTransactionHelper.RetryingTransactionCallback<Collection>() {
                      public Collection execute() throws Throwable {
                        if (jobLockToken != null) {
                          refreshExecutorLock(jobLockToken);
                        } else {
                          jobLockToken = getExecutorLock();
                        }

                        try {
                          return AlfrescoJobExecutorThread.super.acquireJobs();
                        } catch (Throwable t) {
                          logger.error("Failed to acquire jobs");
                          releaseExecutorLock(jobLockToken);
                          jobLockToken = null;
                          throw t;
                        }
                      }
                    });

        if (jobs != null) {
          if (logger.isDebugEnabled() && (!logger.isTraceEnabled()) && (!jobs.isEmpty())) {
            logger.debug("acquired " + jobs.size() + " job" + ((jobs.size() != 1) ? "s" : ""));
          }

          if (logger.isTraceEnabled()) {
            logger.trace(
                "acquired "
                    + jobs.size()
                    + " job"
                    + ((jobs.size() != 1) ? "s" : "")
                    + ((jobs.size() > 0) ? ": " + jobs.toString() : ""));
          }

          if (jobs.size() == 0) {
            releaseExecutorLock(jobLockToken);
            jobLockToken = null;
          }
        }
      } catch (LockAcquisitionException e) {
        // ignore
        jobLockToken = null;
      }
    }

    return jobs;
  }
コード例 #16
0
  @Override
  public void doDefaultSearch() {

    if (LOGGER.isTraceEnabled()) {
      LOGGER.trace("Starting search.");

      Collection<EntityID> unknown = worldModel.getUnknownBuildings();
      Collection<EntityID> safeUnsearched = worldModel.getSafeUnsearchedBuildings();

      LOGGER.trace("Unknown: " + unknown.toString());
      LOGGER.trace("Safe Unsearched: " + safeUnsearched.toString());
    }

    IPath searchPath = goInsideClosestUnsearchedBuilding();

    if (!searchPath.isValid()) {
      // System.out.println("no building to go inside");
      searchPath = goToClosestUnseenBuilding();
      if (!searchPath.isValid()) {
        // System.out.println("no building to go to");
        if (blockades) {
          searchPath = goToClosestUnseenRoad();
          if (!searchPath.isValid()) {
            // System.out.println("no close road");
            searchPath = goToRandomLocation();
          }
        } else {
          searchPath = goToRandomLocation();
        }
      }
    }
    // System.out.println("going to" + searchPath.getDestination());
    // if(searchPath.isValid()){
    // System.out.println("valid path");
    // }

    MoveCommand move = new MoveCommand(searchPath);
    if (searchPath.getLocations().size() > 0) {
      executionService.execute(move);
    }
    // System.out.println(searchPath.toString());
    // }else{
    // System.out.println("null path in search behaviour");
    // }
  }
  public void testGetReducedValueFrequenciesVanilla() throws Exception {
    AbstractValueCountingAnalyzerResult analyzerResult = new MockValueCountingAnalyzerResult(list);

    Collection<ValueFrequency> reduced = analyzerResult.getReducedValueFrequencies(10);
    assertEquals(list.size(), reduced.size());
    assertEquals(
        "[[hey->40], [yo->40], [bah->30], [buh->20], [bar->10], [baz->10], [foo->10]]",
        reduced.toString());
  }
コード例 #18
0
 public void testDuplicateObjectInBinaryAndSources() throws Exception {
   Collection<DeclarationDescriptor> allDescriptors =
       analyzeAndGetAllDescriptors(compileLibrary("library"));
   assertEquals(allDescriptors.toString(), 2, allDescriptors.size());
   for (DeclarationDescriptor descriptor : allDescriptors) {
     assertTrue("Wrong name: " + descriptor, descriptor.getName().asString().equals("Lol"));
     assertTrue("Should be an object: " + descriptor, isObject(descriptor));
   }
 }
コード例 #19
0
ファイル: HotPotatoes.java プロジェクト: nbronson/snaptree
  private static void testImplementation(Class<? extends Collection> implClazz) throws Throwable {
    testPotato(implClazz, Vector.class);
    testPotato(implClazz, CopyOnWriteArrayList.class);

    final Constructor<? extends Collection> constr = implClazz.getConstructor(Collection.class);
    final Collection<Object> coll = constr.newInstance(Arrays.asList(new String[] {}));
    coll.add(1);
    equal(coll.toString(), "[1]");
  }
コード例 #20
0
 PBEMLocalPlayerComboBoxSelector(
     final String playerName,
     final Map<String, String> reloadSelections,
     final Collection<String> disableable,
     final HashMap<String, Boolean> playersEnablementListing,
     final Collection<String> playerAlliances,
     final String[] types,
     final SetupPanel parent) {
   m_playerName = playerName;
   m_name = new JLabel(m_playerName + ":");
   m_enabledCheckBox = new JCheckBox();
   final ActionListener m_disablePlayerActionListener =
       new ActionListener() {
         @Override
         public void actionPerformed(final ActionEvent e) {
           if (m_enabledCheckBox.isSelected()) {
             m_enabled = true;
             // the 1st in the list should be human
             m_playerTypes.setSelectedItem(m_types[0]);
           } else {
             m_enabled = false;
             // the 2nd in the list should be Weak AI
             m_playerTypes.setSelectedItem(m_types[Math.max(0, Math.min(m_types.length - 1, 1))]);
           }
           setWidgetActivation();
         }
       };
   m_enabledCheckBox.addActionListener(m_disablePlayerActionListener);
   m_enabledCheckBox.setSelected(playersEnablementListing.get(playerName));
   m_enabledCheckBox.setEnabled(disableable.contains(playerName));
   m_disableable = disableable;
   m_parent = parent;
   m_types = types;
   m_playerTypes = new JComboBox<>(types);
   String previousSelection = reloadSelections.get(playerName);
   if (previousSelection.equalsIgnoreCase("Client")) {
     previousSelection = types[0];
   }
   if (!(previousSelection.equals("no_one")) && Arrays.asList(types).contains(previousSelection)) {
     m_playerTypes.setSelectedItem(previousSelection);
   } else if (m_playerName.startsWith("Neutral") || playerName.startsWith("AI")) {
     // the 4th in the list should be Pro AI (Hard AI)
     m_playerTypes.setSelectedItem(types[Math.max(0, Math.min(types.length - 1, 3))]);
   }
   // we do not set the default for the combobox because the default is the top item, which in this
   // case is human
   String m_playerAlliances;
   if (playerAlliances.contains(playerName)) {
     m_playerAlliances = "";
   } else {
     m_playerAlliances = playerAlliances.toString();
   }
   m_alliances = new JLabel(m_playerAlliances);
   setWidgetActivation();
 }
コード例 #21
0
 public Collection<String> getSiteNamesToUpload() {
   final Collection<String> set = new HashSet<String>();
   for (final FileObject file : toUpload(false)) set.add(file.updateSite);
   for (final FileObject file : toRemove()) set.add(file.updateSite);
   // keep the update sites' order
   final List<String> result = new ArrayList<String>();
   for (final String name : getUpdateSiteNames(false)) if (set.contains(name)) result.add(name);
   if (result.size() != set.size())
     throw new RuntimeException(
         "Unknown update site in " + set.toString() + " (known: " + result.toString() + ")");
   return result;
 }
コード例 #22
0
 /**
  * Returns a string representation of the object.
  *
  * @return String - representation of the object as a String
  */
 public String toString() {
   StringBuilder builder = new StringBuilder();
   builder.append("Data Request Event Properties");
   builder.append("-------------------------------------");
   builder.append(super.toString());
   builder
       .append(" Data Identifiers : ")
       .append(dataIdentifiers != null ? dataIdentifiers.toString() : "");
   builder.append(" repetition Count : ").append(repetitionCount);
   builder.append(" Interval between consecutive events : ").append(interval);
   return builder.toString();
 }
コード例 #23
0
  /**
   * Retrieved batch boundary from the given content-type header values.
   *
   * @param contentType content-types.
   * @return batch boundary.
   */
  public static String getBoundaryFromHeader(final Collection<String> contentType) {
    final String boundaryKey = ODataBatchConstants.BOUNDARY + "=";

    if (contentType == null
        || contentType.isEmpty()
        || !contentType.toString().contains(boundaryKey)) {
      throw new IllegalArgumentException("Invalid content type");
    }

    final String headerValue = contentType.toString();

    final int start = headerValue.indexOf(boundaryKey) + boundaryKey.length();
    int end = headerValue.indexOf(';', start);

    if (end < 0) {
      end = headerValue.indexOf(']', start);
    }

    final String res = headerValue.substring(start, end);
    return res.startsWith("--") ? res : "--" + res;
  }
コード例 #24
0
  public void testArchetype() throws Exception {
    String term = "proptest";

    Query bq = new PrefixQuery(new Term(ArtifactInfo.GROUP_ID, term));
    TermQuery tq = new TermQuery(new Term(ArtifactInfo.PACKAGING, "maven-archetype"));
    Query query = new FilteredQuery(tq, new QueryWrapperFilter(bq));

    FlatSearchResponse response = nexusIndexer.searchFlat(new FlatSearchRequest(query));

    Collection<ArtifactInfo> r = response.getResults();

    assertEquals(r.toString(), 1, r.size());
  }
コード例 #25
0
ファイル: ParsingTests.java プロジェクト: huiqing/erlide
 @Test
 public void parseCompileDirective() throws ErlModelException {
   final String sourceContent = "[inline,{hipe,[{regalloc,linear_scan}]}]";
   final String source = "-compile(" + sourceContent + ").";
   assertTrue(parse(source));
   final IErlElement attribute =
       TestingSupport.createErlAttribute(module, "compile", null, sourceContent, 0, 50);
   final List<IErlElement> expected = new ArrayList<IErlElement>(1);
   expected.add(attribute);
   final Collection<IErlElement> actual = module.getChildren();
   // assertEquals(expected, actual);
   assertEquals(expected.toString(), actual.toString());
 }
コード例 #26
0
  @Test
  public void test() throws Exception {

    String cluster = "server";
    String nodeNameFormat = "%s/%s";
    String nodeName1 = String.format(nodeNameFormat, NODE_1, cluster);
    String nodeName2 = String.format(nodeNameFormat, NODE_2, cluster);

    ContextSelector<EJBClientContext> selector = EJBClientContextSelector.setup(CLIENT_PROPERTIES);

    try {
      ServiceProviderRetriever bean =
          context.lookupStateless(
              ServiceProviderRetrieverBean.class, ServiceProviderRetriever.class);
      Collection<String> names = bean.getProviders();
      assertEquals(2, names.size());
      assertTrue(names.toString(), names.contains(nodeName1));
      assertTrue(names.toString(), names.contains(nodeName2));

      undeploy(DEPLOYMENT_1);

      names = bean.getProviders();
      assertEquals(1, names.size());
      assertTrue(names.contains(nodeName2));

      deploy(DEPLOYMENT_1);

      names = bean.getProviders();
      assertEquals(2, names.size());
      assertTrue(names.contains(nodeName1));
      assertTrue(names.contains(nodeName2));

      stop(CONTAINER_2);

      names = bean.getProviders();
      assertEquals(1, names.size());
      assertTrue(names.contains(nodeName1));

      start(CONTAINER_2);

      names = bean.getProviders();
      assertEquals(2, names.size());
      assertTrue(names.contains(nodeName1));
      assertTrue(names.contains(nodeName2));
    } finally {
      // reset the selector
      if (selector != null) {
        EJBClientContext.setSelector(selector);
      }
    }
  }
  public void testGetReducedValueFrequenciesExpandUniques() throws Exception {
    Collection<String> values =
        Arrays.asList("this is a long test split into many individual word tokens".split(" "));
    list.add(new CompositeValueFrequency("<uniques>", values, 1));

    AbstractValueCountingAnalyzerResult analyzerResult = new MockValueCountingAnalyzerResult(list);

    Collection<ValueFrequency> reduced = analyzerResult.getReducedValueFrequencies(40);
    assertEquals(
        "[[hey->40], [yo->40], [bah->30], [buh->20], [bar->10], [baz->10], [foo->10], "
            + "[a->1], [individual->1], [into->1], [is->1], [long->1], [many->1], [split->1], "
            + "[test->1], [this->1], [tokens->1], [word->1]]",
        reduced.toString());
  }
コード例 #28
0
 protected void verifyGroupMembership(
     final String realmName, final String userName, final String password, final String... groups)
     throws Exception {
   Set<RealmGroup> groupPrincipals = getUsersGroups(realmName, userName, password);
   assertEquals("Number of groups", groups.length, groupPrincipals.size());
   Collection<String> expectedGroups = new HashSet<String>(Arrays.asList(groups));
   for (RealmGroup current : groupPrincipals) {
     assertTrue(
         String.format("User not expected to be in group '%s'", current.getName()),
         expectedGroups.remove(current.getName()));
   }
   assertTrue(
       String.format("User not in expected groups '%s'", expectedGroups.toString()),
       expectedGroups.isEmpty());
 }
コード例 #29
0
  public static final <T> String CollectionToString(Collection<T> cv) {
    if (cv != null) {
      return cv.toString();
    }
    return "";

    //		StringBuilder sBuilder = new StringBuilder();
    //		for (T t : cv) {
    //			sBuilder.append(t.toString() + ",");
    //		}
    //		if (sBuilder.length() > 0) {
    //			sBuilder.deleteCharAt(sBuilder.length() - 1);
    //		}
    //
    //		return sBuilder.toString();
  }
コード例 #30
0
  @Ignore
  @Test
  public void drainToWithNonEmptyDeque() {
    BlockingDeque<String> deque = new TransactionalLinkedList<String>();
    deque.add("1");
    deque.add("2");
    deque.add("3");

    Collection<String> c = new LinkedList<String>();
    long version = stm.getTime();
    int result = deque.drainTo(c);
    assertEquals(3, result);
    assertEquals(version + 1, stm.getTime());
    assertEquals("[1, 2, 3]", c.toString());
    assertEquals(0, deque.size());
    testIncomplete();
  }