org.apache.ivy.core.IvyContext Java Examples

The following examples show how to use org.apache.ivy.core.IvyContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IBiblioResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testErrorReport() throws Exception {
    IBiblioResolver resolver = new IBiblioResolver();
    resolver.setRoot("http://unknown.host.comx/");
    resolver.setName("test");
    resolver.setM2compatible(true);
    resolver.setSettings(settings);
    assertEquals("test", resolver.getName());

    MockMessageLogger mockMessageImpl = new MockMessageLogger();
    IvyContext.getContext().getIvy().getLoggerEngine().setDefaultLogger(mockMessageImpl);

    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "commons-fileupload",
        "1.0");
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid,
            false), data);
    assertNull(rmr);

    mockMessageImpl
            .assertLogContains("tried http://unknown.host.comx/org/apache/commons-fileupload/1.0/commons-fileupload-1.0.pom");
    mockMessageImpl
            .assertLogContains("tried http://unknown.host.comx/org/apache/commons-fileupload/1.0/commons-fileupload-1.0.jar");
}
 
Example #2
Source File: ModuleRevisionId.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
private ModuleRevisionId(ModuleId moduleId, String branch, String revision,
        Map<String, String> extraAttributes, boolean replaceNullBranchWithDefault) {
    super(null, extraAttributes);
    this.moduleId = moduleId;
    IvyContext context = IvyContext.getContext();
    this.branch = (replaceNullBranchWithDefault && branch == null)
    // we test if there's already an Ivy instance loaded, to avoid loading a default one
    // just to get the default branch
    ? (context.peekIvy() == null ? null : context.getSettings().getDefaultBranch(moduleId))
            : branch;
    this.revision = revision == null ? Ivy.getWorkingRevision() : normalizeRevision(revision);
    setStandardAttribute(IvyPatternHelper.ORGANISATION_KEY, this.moduleId.getOrganisation());
    setStandardAttribute(IvyPatternHelper.MODULE_KEY, this.moduleId.getName());
    setStandardAttribute(IvyPatternHelper.BRANCH_KEY, this.branch);
    setStandardAttribute(IvyPatternHelper.REVISION_KEY, this.revision);
}
 
Example #3
Source File: PublishEngine.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
private void publish(Artifact artifact, File src, DependencyResolver resolver, boolean overwrite)
        throws IOException {
    IvyContext.getContext().checkInterrupted();
    // notify triggers that an artifact is about to be published
    eventManager
            .fireIvyEvent(new StartArtifactPublishEvent(resolver, artifact, src, overwrite));
    boolean successful = false; // set to true once the publish succeeds
    try {
        if (src.exists()) {
            resolver.publish(artifact, src, overwrite);
            successful = true;
        }
    } finally {
        // notify triggers that the publish is finished, successfully or not.
        eventManager.fireIvyEvent(new EndArtifactPublishEvent(resolver, artifact, src,
                overwrite, successful));
    }
}
 
Example #4
Source File: Match.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
public Matcher getPatternMatcher(ModuleRevisionId askedMrid) {
    String revision = askedMrid.getRevision();

    List<String> args = split(getArgs());
    List<String> argValues = getRevisionArgs(revision);

    if (args.size() != argValues.size()) {
        return new NoMatchMatcher();
    }

    Map<String, String> variables = new HashMap<>();
    for (String arg : args) {
        variables.put(arg, argValues.get(args.indexOf(arg)));
    }

    String pattern = getPattern();
    pattern = IvyPatternHelper.substituteVariables(pattern, variables);

    PatternMatcher pMatcher = IvyContext.getContext().getSettings().getMatcher(matcher);
    return pMatcher.getMatcher(pattern);
}
 
Example #5
Source File: LatestCompatibleConflictManager.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Override
public void handleAllBlacklistedRevisions(DependencyDescriptor dd,
        Collection<ModuleRevisionId> foundBlacklisted) {
    ResolveData resolveData = IvyContext.getContext().getResolveData();
    Collection<IvyNode> blacklisted = new HashSet<>();
    for (ModuleRevisionId mrid : foundBlacklisted) {
        blacklisted.add(resolveData.getNode(mrid));
    }

    for (IvyNode node : blacklisted) {
        IvyNodeBlacklist bdata = node.getBlacklistData(resolveData.getReport()
                .getConfiguration());
        handleUnsolvableConflict(bdata.getConflictParent(),
            Arrays.asList(bdata.getEvictedNode(), bdata.getSelectedNode()),
            bdata.getEvictedNode(), bdata.getSelectedNode());
    }
}
 
Example #6
Source File: PublishEventsTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@After
public void tearDown() {
    // reset test state.
    resetCounters();

    // test case is finished, pop the test context off the stack.
    IvyContext.getContext().pop(PublishEventsTest.class.getName());

    // cleanup ivy resources
    if (ivy != null) {
        ivy.popContext();
        ivy = null;
    }
    publishEngine = null;
    if (dataFile != null) {
        dataFile.delete();
    }
    dataFile = null;
    ivyFile = null;
}
 
Example #7
Source File: IvyDependencyResolverAdapter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void getDependency(DependencyMetaData dependency, BuildableModuleVersionMetaDataResolveResult result) {
    IvyContext.getContext().setResolveData(resolveData);
    try {
        ResolvedModuleRevision revision = resolver.getDependency(dependency.getDescriptor(), resolveData);
        if (revision == null) {
            LOGGER.debug("Performed resolved of module '{}' in repository '{}': not found", dependency.getRequested(), getName());
            result.missing();
        } else {
            LOGGER.debug("Performed resolved of module '{}' in repository '{}': found", dependency.getRequested(), getName());
            ModuleDescriptorAdapter metaData = new ModuleDescriptorAdapter(revision.getDescriptor());
            metaData.setChanging(isChanging(revision));
            result.resolved(metaData, null);
        }
    } catch (ParseException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}
 
Example #8
Source File: LoopbackDependencyResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public ResolvedModuleRevision getDependency(final DependencyDescriptor dd, final ResolveData data) throws ParseException {
    final DependencyResolver loopback = this;
    return cacheLockingManager.useCache(String.format("Resolve %s", dd), new Factory<ResolvedModuleRevision>() {
        public ResolvedModuleRevision create() {
            DefaultBuildableComponentResolveResult result = new DefaultBuildableComponentResolveResult();
            DefaultDependencyMetaData dependency = new DefaultDependencyMetaData(dd);
            IvyContext ivyContext = IvyContext.pushNewCopyContext();
            try {
                ivyContext.setResolveData(data);
                dependencyResolver.resolve(dependency, result);
            } finally {
                IvyContext.popContext();
            }
            return new ResolvedModuleRevision(loopback, loopback, result.getMetaData().getDescriptor(), null);
        }
    });
}
 
Example #9
Source File: DefaultRepositoryCacheManagerTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    File f = File.createTempFile("ivycache", ".dir");
    ivy = new Ivy();
    ivy.configureDefault();
    ivy.getLoggerEngine().setDefaultLogger(new DefaultMessageLogger(Message.MSG_DEBUG));
    IvyContext.pushNewContext().setIvy(ivy);

    IvySettings settings = ivy.getSettings();
    f.delete(); // we want to use the file as a directory, so we delete the file itself
    cacheManager = new DefaultRepositoryCacheManager();
    cacheManager.setSettings(settings);
    cacheManager.setBasedir(f);

    artifact = createArtifact("org", "module", "rev", "name", "type", "ext");

    Artifact originArtifact = createArtifact("org", "module", "rev", "name", "pom.original",
        "pom");
    origin = new ArtifactOrigin(originArtifact, true, "file:/some/where.pom");

    cacheManager.saveArtifactOrigin(originArtifact, origin);
    cacheManager.saveArtifactOrigin(artifact, origin);
}
 
Example #10
Source File: IvyDependencyResolverAdapter.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void getDependency(DependencyMetaData dependency, BuildableModuleVersionMetaDataResolveResult result) {
    IvyContext.getContext().setResolveData(resolveData);
    try {
        ResolvedModuleRevision revision = resolver.getDependency(dependency.getDescriptor(), resolveData);
        if (revision == null) {
            LOGGER.debug("Performed resolved of module '{}' in repository '{}': not found", dependency.getRequested(), getName());
            result.missing();
        } else {
            LOGGER.debug("Performed resolved of module '{}' in repository '{}': found", dependency.getRequested(), getName());
            ModuleDescriptorAdapter metaData = new ModuleDescriptorAdapter(revision.getDescriptor());
            metaData.setChanging(isChanging(revision));
            result.resolved(metaData, null);
        }
    } catch (ParseException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}
 
Example #11
Source File: LoopbackDependencyResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public ResolvedModuleRevision getDependency(final DependencyDescriptor dd, final ResolveData data) throws ParseException {
    final DependencyResolver loopback = this;
    return cacheLockingManager.useCache(String.format("Resolve %s", dd), new Factory<ResolvedModuleRevision>() {
        public ResolvedModuleRevision create() {
            DefaultBuildableComponentResolveResult result = new DefaultBuildableComponentResolveResult();
            DefaultDependencyMetaData dependency = new DefaultDependencyMetaData(dd);
            IvyContext ivyContext = IvyContext.pushNewCopyContext();
            try {
                ivyContext.setResolveData(data);
                dependencyResolver.resolve(dependency, result);
            } finally {
                IvyContext.popContext();
            }
            return new ResolvedModuleRevision(loopback, loopback, result.getMetaData().getDescriptor(), null);
        }
    });
}
 
Example #12
Source File: BintrayResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testErrorReport() throws Exception {
    BintrayResolver resolver = new BintrayResolver();
    resolver.setSubject("unknown");
    resolver.setRepo("unknown");
    resolver.setName("test");
    resolver.setM2compatible(true);
    resolver.setSettings(settings);
    assertEquals("test", resolver.getName());

    MockMessageLogger mockMessageImpl = new MockMessageLogger();
    IvyContext.getContext().getIvy().getLoggerEngine().setDefaultLogger(mockMessageImpl);

    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "commons-fileupload",
        "1.0");
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid,
            false), data);
    assertNull(rmr);

    mockMessageImpl
            .assertLogContains("trying https://dl.bintray.com/unknown/unknown/org/apache/commons-fileupload/1.0/commons-fileupload-1.0.jar");
    mockMessageImpl
            .assertLogContains("tried https://dl.bintray.com/unknown/unknown/org/apache/commons-fileupload/1.0/commons-fileupload-1.0.jar");
}
 
Example #13
Source File: AbstractLogCircularDependencyStrategy.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
protected String getCircularDependencyId(ModuleRevisionId[] mrids) {
    String contextPrefix = "";
    ResolveData data = IvyContext.getContext().getResolveData();
    if (data != null) {
        contextPrefix = data.getOptions().getResolveId() + " ";
    }
    return contextPrefix + Arrays.asList(mrids);
}
 
Example #14
Source File: Ivy.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
/**
 * Pushes a new IvyContext bound to this Ivy instance if the current context is not already
 * bound to this Ivy instance. If the current context is already bound to this Ivy instance, it
 * pushes the current context on the context stack, so that you can (and must) always call
 * {@link #popContext()} when you're done.
 * <p>
 * Alternatively, you can use the {@link #execute(org.apache.ivy.Ivy.IvyCallback)} method which
 * takes care of everything for you.
 * </p>
 */
public void pushContext() {
    if (IvyContext.getContext().peekIvy() != this) {
        // the current Ivy context is associated with another Ivy instance, we push a new
        // instance
        IvyContext.pushNewContext();
        IvyContext.getContext().setIvy(this);
    } else {
        // the current Ivy context is already associated with this Ivy instance, we only push it
        // for popping consistency
        IvyContext.pushContext(IvyContext.getContext());
    }
}
 
Example #15
Source File: IvyContextualiser.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static IvyContext getIvyContext() {
    IvyContext context = IvyContext.getContext();
    if (context.peekIvy() == null) {
        throw new IllegalStateException("Ivy context not established");
    }
    return context;
}
 
Example #16
Source File: DefaultIvyContextManager.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public <T> T withIvy(Transformer<? extends T, ? super Ivy> action) {
    Integer currentDepth = depth.get();

    if (currentDepth != null) {
        depth.set(currentDepth + 1);
        try {
            return action.transform(IvyContext.getContext().getIvy());
        } finally {
            depth.set(currentDepth);
        }
    }

    IvyContext.pushNewContext();
    try {
        depth.set(1);
        try {
            Ivy ivy = getIvy();
            try {
                IvyContext.getContext().setIvy(ivy);
                return action.transform(ivy);
            } finally {
                releaseIvy(ivy);
            }
        } finally {
            depth.set(null);
        }
    } finally {
        IvyContext.popContext();
    }
}
 
Example #17
Source File: VisitNode.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private VisitNode traverse(VisitNode parent, String parentConf, IvyNode node, IvyNodeUsage usage) {
    if (getPath().contains(node)) {
        IvyContext.getContext().getCircularDependencyStrategy()
                .handleCircularDependency(toMrids(getPath(), node.getId()));
        // we do not use the new parent, but the first one, to always be able to go up to the
        // root
        // parent = getVisitNode(depNode).getParent();
    }
    return new VisitNode(data, node, parent, rootModuleConf, parentConf, usage);
}
 
Example #18
Source File: IvyNode.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public void addCaller(String rootModuleConf, IvyNode callerNode, String callerConf,
        String requestedConf, String[] dependencyConfs, DependencyDescriptor dd) {
    callers.addCaller(rootModuleConf, callerNode, callerConf, requestedConf, dependencyConfs,
        dd);
    boolean isCircular = callers.getAllCallersModuleIds().contains(getId().getModuleId());
    if (isCircular) {
        IvyContext.getContext().getCircularDependencyStrategy()
                .handleCircularDependency(toMrids(findPath(getId().getModuleId()), this));
    }
}
 
Example #19
Source File: IvyContextualiser.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static IvyContext getIvyContext() {
    IvyContext context = IvyContext.getContext();
    if (context.peekIvy() == null) {
        throw new IllegalStateException("Ivy context not established");
    }
    return context;
}
 
Example #20
Source File: XmlModuleDescriptorParser.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public void toIvyFile(InputStream is, Resource res, File destFile, ModuleDescriptor md)
        throws IOException, ParseException {
    try {
        Namespace ns = null;
        if (md instanceof DefaultModuleDescriptor) {
            DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) md;
            ns = dmd.getNamespace();
        }
        XmlModuleDescriptorUpdater.update(
            is,
            res,
            destFile,
            new UpdateOptions().setSettings(IvyContext.getContext().getSettings())
                    .setStatus(md.getStatus())
                    .setRevision(md.getResolvedModuleRevisionId().getRevision())
                    .setPubdate(md.getResolvedPublicationDate()).setUpdateBranch(false)
                    .setNamespace(ns));
    } catch (SAXException e) {
        ParseException pe = new ParseException("exception occurred while parsing " + res, 0);
        pe.initCause(e);
        throw pe;
    } finally {
        if (is != null) {
            is.close();
        }
    }
}
 
Example #21
Source File: ChainResolverTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testDownloadWithDual() {
    ChainResolver chain = new ChainResolver();
    chain.setName("chain");
    chain.setSettings(settings);
    chain.setDual(true);

    // first resolver has only an artifact pattern which don't lead to anything: it won't find
    // the module
    FileSystemResolver resolver = new FileSystemResolver();
    resolver.setName("1");
    resolver.setSettings(settings);
    resolver.addArtifactPattern(settings.getBaseDir()
            + "/test/repositories/nowhere/[organisation]/[module]/[type]s/[artifact]-[revision].[type]");

    chain.add(resolver);

    resolver = new FileSystemResolver();
    resolver.setName("2");
    resolver.setSettings(settings);

    resolver.addIvyPattern(settings.getBaseDir()
            + "/test/repositories/1/[organisation]/[module]/ivys/ivy-[revision].xml");
    resolver.addArtifactPattern(settings.getBaseDir()
            + "/test/repositories/1/[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
    chain.add(resolver);

    settings.addResolver(chain);

    MockMessageLogger mockLogger = new MockMessageLogger();
    IvyContext.getContext().getIvy().getLoggerEngine().setDefaultLogger(mockLogger);
    DownloadReport report = chain.download(
        new Artifact[] {new DefaultArtifact(ModuleRevisionId.parse("org1#mod1.1;1.0"),
                new Date(), "mod1.1", "jar", "jar")}, new DownloadOptions());
    assertNotNull(report);
    assertEquals(1, report.getArtifactsReports().length);
    assertEquals(DownloadStatus.SUCCESSFUL, report.getArtifactsReports()[0].getDownloadStatus());
    mockLogger.assertLogDoesntContain("[FAILED     ] org1#mod1.1;1.0!mod1.1.jar");
}
 
Example #22
Source File: SshCache.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public Entry(Session newSession, String newUser, String newHost, int newPort) {
    session = newSession;
    host = newHost;
    user = newUser;
    port = newPort;
    IvyContext.getContext().getEventManager().addIvyListener(new IvyListener() {
        public void progress(IvyEvent event) {
            event.getSource().removeIvyListener(this);
            clearSession(session);
        }
    }, EndResolveEvent.NAME);
}
 
Example #23
Source File: DefaultRepositoryCacheManagerTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() {
    IvyContext.popContext();
    Delete del = new Delete();
    del.setProject(new Project());
    del.setDir(cacheManager.getRepositoryCacheRoot());
    del.execute();
}
 
Example #24
Source File: BasicResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
protected void logAttempt(String attempt) {
    Artifact currentArtifact = IvyContext.getContext().get(getName() + ".artifact");
    if (currentArtifact == null) {
        logIvyAttempt(attempt);
    } else {
        logArtifactAttempt(currentArtifact, attempt);
    }
}
 
Example #25
Source File: IgnoreCircularDependencyStrategyTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private MessageLoggerEngine setupMockLogger(final MockMessageLogger mockLogger) {
    if (mockLogger == null) {
        return null;
    }
    final MessageLoggerEngine loggerEngine = IvyContext.getContext().getIvy().getLoggerEngine();
    loggerEngine.pushLogger(mockLogger);
    return loggerEngine;
}
 
Example #26
Source File: WarnCircularDependencyStrategyTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private MessageLoggerEngine setupMockLogger(final MockMessageLogger mockLogger) {
    if (mockLogger == null) {
        return null;
    }
    final MessageLoggerEngine loggerEngine = IvyContext.getContext().getIvy().getLoggerEngine();
    loggerEngine.pushLogger(mockLogger);
    return loggerEngine;
}
 
Example #27
Source File: PublishEventsTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public void progress(IvyEvent event) {

            PublishEventsTest test = (PublishEventsTest) IvyContext.getContext().peek(
                PublishEventsTest.class.getName());
            assertTrue("event is of correct concrete type",
                event instanceof StartArtifactPublishEvent);
            StartArtifactPublishEvent startEvent = (StartArtifactPublishEvent) event;

            // verify that the artifact being publish was in the expected set. set the
            // 'currentTestCase'
            // pointer so that the resolver and post-publish trigger can check against it.
            Artifact artifact = startEvent.getArtifact();
            assertNotNull("event defines artifact", artifact);

            PublishTestCase currentTestCase = test.expectedPublications.remove(artifact.getId());
            assertNotNull("artifact " + artifact.getId() + " was expected for publication",
                currentTestCase);
            assertFalse("current publication has not been visited yet",
                currentTestCase.preTriggerFired);
            assertFalse("current publication has not been visited yet", currentTestCase.published);
            assertFalse("current publication has not been visited yet",
                currentTestCase.postTriggerFired);
            test.currentTestCase = currentTestCase;

            // superclass tests common attributes of publish events
            super.progress(event);

            // increment the call counter in the test
            currentTestCase.preTriggerFired = true;
            ++test.preTriggers;
        }
 
Example #28
Source File: PublishEventsTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public void progress(IvyEvent event) {
    // superclass tests common attributes of publish events
    super.progress(event);

    PublishEventsTest test = (PublishEventsTest) IvyContext.getContext().peek(
        PublishEventsTest.class.getName());

    // test the proper sequence of events by comparing the current count of pre-events,
    // post-events, and actual publications.
    assertTrue("event is of correct concrete type",
        event instanceof EndArtifactPublishEvent);
    assertTrue("pre-publish event has been triggered", test.preTriggers > 0);

    // test sequence of events
    assertTrue("pre-trigger event has already been fired for this artifact",
        test.currentTestCase.preTriggerFired);
    assertEquals("publication has been done if possible",
        test.currentTestCase.expectedSuccess, test.currentTestCase.published);
    assertFalse("post-publish event has not yet been fired for this artifact",
        test.currentTestCase.postTriggerFired);

    // test the "status" attribute of the post- event.
    EndArtifactPublishEvent endEvent = (EndArtifactPublishEvent) event;
    assertEquals("status bit is set correctly", test.currentTestCase.expectedSuccess,
        endEvent.isSuccessful());

    String expectedStatus = test.currentTestCase.expectedSuccess ? "successful" : "failed";
    assertEquals("status attribute is set to correct value", expectedStatus, endEvent
            .getAttributes().get("status"));

    // increment the call counter in the wrapper test
    test.currentTestCase.postTriggerFired = true;
    ++test.postTriggers;
}
 
Example #29
Source File: PublishEventsTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public void publish(Artifact artifact, File src, boolean overwrite) throws IOException {

            // verify that the data from the current test case has been handed down to us
            PublishEventsTest test = (PublishEventsTest) IvyContext.getContext().peek(
                PublishEventsTest.class.getName());

            // test sequence of events.
            assertNotNull(test.currentTestCase);
            assertTrue("preTrigger has already fired", test.currentTestCase.preTriggerFired);
            assertFalse("postTrigger has not yet fired", test.currentTestCase.postTriggerFired);
            assertFalse("publish has not been called", test.currentTestCase.published);

            // test event data
            assertSameArtifact("publisher has received correct artifact",
                test.currentTestCase.expectedArtifact, artifact);
            assertEquals("publisher has received correct datafile",
                test.currentTestCase.expectedData.getCanonicalPath(), src.getCanonicalPath());
            assertEquals("publisher has received correct overwrite setting",
                test.expectedOverwrite, overwrite);
            assertTrue("publisher only invoked when source file exists",
                test.currentTestCase.expectedData.exists());

            // simulate a publisher error if the current test case demands it.
            if (test.publishError != null) {
                throw test.publishError;
            }

            // all assertions pass. increment the publication count
            test.currentTestCase.published = true;
            ++test.publications;
        }
 
Example #30
Source File: WarnCircularDependencyStrategyTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    // setup a new IvyContext for each test
    IvyContext.pushNewContext();
    strategy = WarnCircularDependencyStrategy.getInstance();
    mockMessageLogger = new MockMessageLogger();
    loggerEngine = setupMockLogger(mockMessageLogger);
}