org.jboss.shrinkwrap.api.Archive.addHandlers()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(103)

本文整理了Java中org.jboss.shrinkwrap.api.Archive.addHandlers()方法的一些代码示例,展示了Archive.addHandlers()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Archive.addHandlers()方法的具体详情如下:
包路径:org.jboss.shrinkwrap.api.Archive
类名称:Archive
方法名:addHandlers

Archive.addHandlers介绍

[英]Add an array of listeners for call back based.
[中]添加一个侦听器数组,用于基于回调的侦听器。

代码示例

代码示例来源:origin: wildfly/wildfly-arquillian

@Override
public T addHandlers(final ArchiveEventHandler... handlers) {
  return delegate.addHandlers(handlers);
}

代码示例来源:origin: org.jboss.shrinkwrap/shrinkwrap-impl-base

/**
 * {@inheritDoc}
 *
 * @see org.jboss.shrinkwrap.api.Archive#addHandlers(org.jboss.shrinkwrap.api.Filter,
 *      org.jboss.shrinkwrap.api.ArchiveEventHandler)
 */
@Override
public T addHandlers(ArchiveEventHandler... handlers) {
  for (ArchiveEventHandler handler : handlers) {
    this.getArchive().addHandlers(handler);
  }
  return covarientReturn();
}

代码示例来源:origin: shrinkwrap/shrinkwrap

/**
 * {@inheritDoc}
 *
 * @see org.jboss.shrinkwrap.api.Archive#addHandlers(org.jboss.shrinkwrap.api.Filter,
 *      org.jboss.shrinkwrap.api.ArchiveEventHandler)
 */
@Override
public T addHandlers(ArchiveEventHandler... handlers) {
  for (ArchiveEventHandler handler : handlers) {
    this.getArchive().addHandlers(handler);
  }
  return covarientReturn();
}

代码示例来源:origin: shrinkwrap/shrinkwrap

@Test
public void testHandlerIsCalledWhenAddingDirectoriesWithStringPath() throws Exception {
  final SimpleHandler simpleHandler1 = new SimpleHandler();
  final SimpleHandler simpleHandler2 = new SimpleHandler();
  getArchive().addHandlers(simpleHandler1, simpleHandler2);
  getArchive().addAsDirectories("/path/to/dir1");
  Assert.assertTrue("Handler not called", simpleHandler1.called);
  Assert.assertTrue("Handler not called", simpleHandler2.called);
}

代码示例来源:origin: shrinkwrap/shrinkwrap

@Test
public void testHandlerIsCalledWhenAddingAssetWithArchivePathAndExporter() throws Exception {
  final ReplaceAssetHandler handler1 = new ReplaceAssetHandler("unexpected");
  final ReplaceAssetHandler handler2 = new ReplaceAssetHandler("EXPECTED");
  getArchive().addHandlers(handler1, handler2);
  final ArchivePath path = ArchivePaths.create("/path/to/dir");
  final Archive<JavaArchive> asset = ShrinkWrap
     .create(JavaArchive.class, "asset.zip")
     .add(new StringAsset("asset content"), "content.txt");
  getArchive().add(asset, path, ZipExporter.class);
  Assert.assertTrue("Handler not called", handler1.called);
  Assert.assertEquals("Wrong asset received by handler", handler1.returnedAsset, handler2.savedAsset);
}

代码示例来源:origin: shrinkwrap/shrinkwrap

@Test
public void testHandlerIsCalledWhenAddingDirectoriesWithArchivePath() throws Exception {
  final SimpleHandler simpleHandler1 = new SimpleHandler();
  final SimpleHandler simpleHandler2 = new SimpleHandler();
  getArchive().addHandlers(simpleHandler1, simpleHandler2);
  getArchive().addAsDirectories(ArchivePaths.create("/path/to/dir1"));
  Assert.assertTrue("Handler not called", simpleHandler1.called);
  Assert.assertTrue("Handler not called", simpleHandler2.called);
}

代码示例来源:origin: shrinkwrap/shrinkwrap

@Test
public void testHandlerIsCalledWhenAddingAssetWithArchivePath() throws Exception {
  final ReplaceAssetHandler handler1 = new ReplaceAssetHandler("unexpected");
  final ReplaceAssetHandler handler2 = new ReplaceAssetHandler("EXPECTED");
  getArchive().addHandlers(handler1, handler2);
  final ArchivePath path = ArchivePaths.create("/path/to/dir/test1.txt");
  final StringAsset asset = new StringAsset("Asset content");
  getArchive().add(asset, path);
  Assert.assertEquals("Handler not called", "EXPECTED", readStringAsset(path));
  Assert.assertEquals("Wrong asset received by handler", asset, handler1.savedAsset);
  Assert.assertEquals("Wrong asset received by handler", handler1.returnedAsset, handler2.savedAsset);
}

代码示例来源:origin: shrinkwrap/shrinkwrap

@Test
public void testHandlerIsCalledWhenAddingAssetWithStringPath() throws Exception {
  final ReplaceAssetHandler handler1 = new ReplaceAssetHandler("unexpected");
  final ReplaceAssetHandler handler2 = new ReplaceAssetHandler("EXPECTED");
  getArchive().addHandlers(handler1, handler2);
  final ArchivePath path = ArchivePaths.create("/path/to/dir/test1.txt");
  final StringAsset asset = new StringAsset("Original");
  getArchive().add(asset, path.get());
  Assert.assertEquals("Handler not called", "EXPECTED", readStringAsset(path));
  Assert.assertEquals("Wrong asset received by handler", asset, handler1.savedAsset);
  Assert.assertEquals("Wrong asset received by handler", handler1.returnedAsset, handler2.savedAsset);
}

代码示例来源:origin: shrinkwrap/shrinkwrap

@Test
public void testHandlerIsCalledWhenAddingAssetWithArchivePathAndName() throws Exception {
  final ReplaceAssetHandler handler1 = new ReplaceAssetHandler("unexpected");
  final ReplaceAssetHandler handler2 = new ReplaceAssetHandler("EXPECTED");
  getArchive().addHandlers(handler1, handler2);
  final ArchivePath path = ArchivePaths.create("/path/to/dir");
  final StringAsset asset = new StringAsset("Original");
  getArchive().add(asset, path, "asset.txt");
  String actual = readStringAsset(ArchivePaths.create(path, "/asset.txt"));
  Assert.assertEquals("Handler not called", "EXPECTED", actual);
  Assert.assertEquals("Wrong asset received by handler", asset, handler1.savedAsset);
  Assert.assertEquals("Wrong asset received by handler", handler1.returnedAsset, handler2.savedAsset);    }

代码示例来源:origin: shrinkwrap/shrinkwrap

@Test
public void testHandlerIsCalledWhenAddingAssetWithtStringPathAndName() throws Exception {
  final ReplaceAssetHandler handler1 = new ReplaceAssetHandler("unexpected");
  final ReplaceAssetHandler handler2 = new ReplaceAssetHandler("EXPECTED");
  getArchive().addHandlers(handler1, handler2);
  final ArchivePath path = ArchivePaths.create("/path/to/dir");
  final StringAsset asset = new StringAsset("Original");
  getArchive().add(asset, path.get(), "asset.txt");
  String actual = readStringAsset(ArchivePaths.create(path, "asset.txt"));
  Assert.assertEquals("Handler not called", "EXPECTED", actual);
  Assert.assertEquals("Wrong asset received by handler", asset, handler1.savedAsset);
  Assert.assertEquals("Wrong asset received by handler", handler1.returnedAsset, handler2.savedAsset);
}

相关文章