コード例 #1
0
 /**
  * This will create a ChannelXmlBean that describes a release as it is found in the specified
  * directory, using the specified releaseName and version. This will excluded files that match any
  * patterns in the excludePatterns array. Files that are excluded are also deleted from the
  * release directory as they will not be shipped with the update site, and are therefore not
  * required.
  *
  * @param channelName the name of the channel.
  * @param releaseName the name of the release.
  * @param version the version of the release.
  * @param directory the directory to use as the top-level of the release.
  * @return a ChannelXmlBean that represents the specified parameters and files found in the
  *     release directory that don't match any exclude pattern.
  */
 private ChannelXmlBean buildChannelRelease(
     String channelName, String releaseName, String version, String directory) throws IOException {
   ChannelXmlBean result = new ChannelXmlBean();
   result.setName(channelName);
   ReleaseXmlBean releaseBean = new ReleaseXmlBean(releaseName, version);
   releaseBean.setCreateTime(new Date());
   File dir = new File(directory);
   for (File f : dir.listFiles()) {
     if (log.isInfoEnabled()) {
       log.info("Processing module directory: " + f);
     }
     if (f.isDirectory()) {
       // f is a module
       ModuleXmlBean module = new ModuleXmlBean();
       module.setName(f.getName());
       for (File a : f.listFiles()) {
         String filename = a.getName();
         if (isExcluded(filename)) {
           a.delete();
           continue;
         }
         if (log.isDebugEnabled()) {
           log.debug("Processing artifact file: " + filename);
         }
         String type = filename.substring(filename.indexOf(".") + 1);
         ArtifactXmlBean artifact = new ArtifactXmlBean();
         artifact.setName(a.getName());
         artifact.setType(type);
         artifact.setVersion(version);
         artifact.setSize(a.length());
         artifact.setChecksum(_iou.getCheckSum(a));
         module.addArtifact(artifact);
       }
       releaseBean.addmodule(module);
     }
   }
   result.setCurrentRelease(releaseBean);
   return result;
 }
コード例 #2
0
  @Before
  public void setUp() throws Exception {
    mockCoreArtifactXmlBean = mockHelper.createMock(ArtifactXmlBean.class);
    expect(mockCoreArtifactXmlBean.getName()).andStubReturn(coreArtifactName);
    expect(mockCoreArtifactXmlBean.isInstalled()).andStubReturn(coreIsInstalled);
    expect(mockCoreArtifactXmlBean.getSize()).andStubReturn(coreSize);
    expect(mockCoreArtifactXmlBean.getChecksum()).andStubReturn(coreChecksum);
    expect(mockCoreArtifactXmlBean.getType()).andStubReturn(coreType);

    mockPluginArtifactXmlBean = mockHelper.createMock(ArtifactXmlBean.class);
    expect(mockPluginArtifactXmlBean.getName()).andStubReturn(pluginArtifactName);
    expect(mockPluginArtifactXmlBean.isInstalled()).andStubReturn(pluginIsInstalled);
    expect(mockPluginArtifactXmlBean.getSize()).andStubReturn(pluginSize);
    expect(mockPluginArtifactXmlBean.getChecksum()).andStubReturn(pluginChecksum);
    expect(mockPluginArtifactXmlBean.getType()).andStubReturn(pluginType);

    mockTranslationArtifactXmlBean = mockHelper.createMock(ArtifactXmlBean.class);
    expect(mockTranslationArtifactXmlBean.getName()).andStubReturn(translationArtifactName);
    expect(mockTranslationArtifactXmlBean.isInstalled()).andStubReturn(translationIsInstalled);
    expect(mockTranslationArtifactXmlBean.getSize()).andStubReturn(translationSize);
    expect(mockTranslationArtifactXmlBean.getChecksum()).andStubReturn(translationChecksum);
    expect(mockTranslationArtifactXmlBean.getType()).andStubReturn(translationType);

    // For the serialization test in superclass - cannot use mockHelper because the replay needs to
    // be
    // done here.
    ArtifactXmlBean mockArtifactXmlBean = EasyMock.createMock(ArtifactXmlBean.class);
    expect(mockArtifactXmlBean.getName()).andStubReturn(coreArtifactName);
    expect(mockArtifactXmlBean.isInstalled()).andStubReturn(coreIsInstalled);
    expect(mockArtifactXmlBean.getSize()).andStubReturn(coreSize);
    expect(mockArtifactXmlBean.getChecksum()).andStubReturn(coreChecksum);
    expect(mockArtifactXmlBean.getType()).andStubReturn(coreType);
    replay(mockArtifactXmlBean);
    super.serializableToTest = new ArtifactStatus(mockArtifactXmlBean);
    verify(mockArtifactXmlBean);
  }