Search in sources :

Example 1 with TestFileEventManager

use of org.commonjava.indy.test.fixture.core.TestFileEventManager in project indy by Commonjava.

the class NPMPackageMaskingTransferDecoratorTest method testDecorator2.

@Test
public void testDecorator2() throws Exception {
    String path = "package.json";
    KeyedLocation location = new GroupLocation(PKG_TYPE_NPM, "test");
    File file = new File(temp.newFolder(location.getName()), path);
    IOUtils.copy(getResourceAsStream("metadata/package-tar-fs.json"), new FileOutputStream(file));
    ConcreteResource resource = new ConcreteResource(location, path);
    TestCacheProvider provider = new TestCacheProvider(temp.getRoot(), new TestFileEventManager(), new TransferDecoratorManager(new NPMPackageMaskingTransferDecorator()));
    Transfer transfer = provider.getTransfer(resource);
    InputStream stream = transfer.openInputStream(false, new EventMetadata().set(ENTRY_POINT_BASE_URI, "http://localhost/api/content/npm"));
    String ret = IOUtils.toString(stream);
    String expected = IOUtils.toString(getResourceAsStream("metadata/package-tar-fs-decorated.json"));
    assertEquals(expected, ret);
}
Also used : KeyedLocation(org.commonjava.indy.model.galley.KeyedLocation) InputStream(java.io.InputStream) TestFileEventManager(org.commonjava.indy.test.fixture.core.TestFileEventManager) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) GroupLocation(org.commonjava.indy.model.galley.GroupLocation) FileOutputStream(java.io.FileOutputStream) TransferDecoratorManager(org.commonjava.maven.galley.io.TransferDecoratorManager) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) TestCacheProvider(org.commonjava.indy.test.fixture.core.TestCacheProvider) Transfer(org.commonjava.maven.galley.model.Transfer) File(java.io.File) Test(org.junit.Test)

Example 2 with TestFileEventManager

use of org.commonjava.indy.test.fixture.core.TestFileEventManager in project indy by Commonjava.

the class NPMPackageMaskingTransferDecoratorTest method testDecorator.

@Test
public void testDecorator() throws Exception {
    String path = "package.json";
    KeyedLocation location = new GroupLocation(PKG_TYPE_NPM, "test");
    File file = new File(temp.newFolder(location.getName()), path);
    IOUtils.copy(getResourceAsStream("metadata/package-1.json"), new FileOutputStream(file));
    ConcreteResource resource = new ConcreteResource(location, path);
    TestCacheProvider provider = new TestCacheProvider(temp.getRoot(), new TestFileEventManager(), new TransferDecoratorManager(new NPMPackageMaskingTransferDecorator()));
    Transfer transfer = provider.getTransfer(resource);
    InputStream stream = transfer.openInputStream(false, new EventMetadata().set(ENTRY_POINT_BASE_URI, "http://localhost/api/content/npm"));
    String ret = IOUtils.toString(stream);
    String expected = IOUtils.toString(getResourceAsStream("metadata/package-1-decorated.json"));
    assertEquals(expected, ret);
}
Also used : KeyedLocation(org.commonjava.indy.model.galley.KeyedLocation) InputStream(java.io.InputStream) TestFileEventManager(org.commonjava.indy.test.fixture.core.TestFileEventManager) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) GroupLocation(org.commonjava.indy.model.galley.GroupLocation) FileOutputStream(java.io.FileOutputStream) TransferDecoratorManager(org.commonjava.maven.galley.io.TransferDecoratorManager) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) TestCacheProvider(org.commonjava.indy.test.fixture.core.TestCacheProvider) Transfer(org.commonjava.maven.galley.model.Transfer) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 InputStream (java.io.InputStream)2 GroupLocation (org.commonjava.indy.model.galley.GroupLocation)2 KeyedLocation (org.commonjava.indy.model.galley.KeyedLocation)2 TestCacheProvider (org.commonjava.indy.test.fixture.core.TestCacheProvider)2 TestFileEventManager (org.commonjava.indy.test.fixture.core.TestFileEventManager)2 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)2 TransferDecoratorManager (org.commonjava.maven.galley.io.TransferDecoratorManager)2 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)2 Transfer (org.commonjava.maven.galley.model.Transfer)2 Test (org.junit.Test)2