Search in sources :

Example 41 with SimpleLocation

use of org.commonjava.maven.galley.model.SimpleLocation in project indy by Commonjava.

the class ContentControllerTest method detectHtml_SingleHtmlElementBeginsOnLine.

@Test
public void detectHtml_SingleHtmlElementBeginsOnLine() throws Exception {
    final ConcreteResource res = new ConcreteResource(new SimpleLocation("test:uri"), "file.html");
    final Transfer tx = fixture.getCache().getTransfer(res);
    PrintWriter writer = null;
    try {
        writer = new PrintWriter(new OutputStreamWriter(tx.openOutputStream(TransferOperation.GENERATE)));
        writer.print("<html ng-app=\"foo\"");
        writer.flush();
    } finally {
        IOUtils.closeQuietly(writer);
    }
    assertThat(content.isHtmlContent(tx), equalTo(true));
}
Also used : ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) Transfer(org.commonjava.maven.galley.model.Transfer) SimpleLocation(org.commonjava.maven.galley.model.SimpleLocation) OutputStreamWriter(java.io.OutputStreamWriter) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 42 with SimpleLocation

use of org.commonjava.maven.galley.model.SimpleLocation in project indy by Commonjava.

the class ExpiringMemoryNotFoundCacheTest method expireUsingConfiguredValue_DirectCheckDoesntAffectAggregateChecks.

@Test
public void expireUsingConfiguredValue_DirectCheckDoesntAffectAggregateChecks() throws Exception {
    final DefaultIndyConfiguration config = new DefaultIndyConfiguration();
    config.setNotFoundCacheTimeoutSeconds(1);
    final ExpiringMemoryNotFoundCache nfc = new ExpiringMemoryNotFoundCache(config);
    final ConcreteResource res = new ConcreteResource(new SimpleLocation("test:uri"), "/path/to/expired/object");
    nfc.addMissing(res);
    assertThat(nfc.isMissing(res), equalTo(true));
    Thread.sleep(TimeUnit.SECONDS.toMillis(1));
    Set<String> locMissing = nfc.getMissing(res.getLocation());
    assertThat(locMissing == null || locMissing.isEmpty(), equalTo(true));
    Map<Location, Set<String>> allMissing = nfc.getAllMissing();
    assertThat(allMissing == null || allMissing.isEmpty(), equalTo(true));
    assertThat(nfc.isMissing(res), equalTo(false));
    locMissing = nfc.getMissing(res.getLocation());
    assertThat(locMissing == null || locMissing.isEmpty(), equalTo(true));
    allMissing = nfc.getAllMissing();
    assertThat(allMissing == null || allMissing.isEmpty(), equalTo(true));
}
Also used : Set(java.util.Set) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) SimpleLocation(org.commonjava.maven.galley.model.SimpleLocation) DefaultIndyConfiguration(org.commonjava.indy.conf.DefaultIndyConfiguration) SimpleLocation(org.commonjava.maven.galley.model.SimpleLocation) Location(org.commonjava.maven.galley.model.Location) Test(org.junit.Test)

Aggregations

SimpleLocation (org.commonjava.maven.galley.model.SimpleLocation)42 Test (org.junit.Test)39 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)35 Location (org.commonjava.maven.galley.model.Location)26 Transfer (org.commonjava.maven.galley.model.Transfer)22 InputStream (java.io.InputStream)12 OutputStream (java.io.OutputStream)10 CacheProvider (org.commonjava.maven.galley.spi.cache.CacheProvider)10 ByteArrayOutputStream (java.io.ByteArrayOutputStream)8 SimpleProjectVersionRef (org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef)7 TestDownload (org.commonjava.maven.galley.testing.core.transport.job.TestDownload)7 ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)6 OutputStreamWriter (java.io.OutputStreamWriter)5 PrintWriter (java.io.PrintWriter)5 URI (java.net.URI)5 LinkedHashMap (java.util.LinkedHashMap)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 JoinString (org.commonjava.maven.atlas.ident.util.JoinString)5 MavenPomView (org.commonjava.maven.galley.maven.model.view.MavenPomView)5 File (java.io.File)4