• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ResourceInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.common.reflect.ClassPath.ResourceInfo的典型用法代码示例。如果您正苦于以下问题:Java ResourceInfo类的具体用法?Java ResourceInfo怎么用?Java ResourceInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ResourceInfo类属于com.google.common.reflect.ClassPath包,在下文中一共展示了ResourceInfo类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: Path

import com.google.common.reflect.ClassPath.ResourceInfo; //导入依赖的package包/类
@AndroidIncompatible // Path (for symlink creation)

  public void testScanDirectory_symlinkToRootCycle() throws IOException {
    ClassLoader loader = ClassPathTest.class.getClassLoader();
    // directory with a cycle,
    // /root
    //    /child
    //       /[grandchild -> root]
    java.nio.file.Path root = createTempDirectory("ClassPathTest");
    try {
      createFile(root.resolve("some.txt"));
      java.nio.file.Path child = createDirectory(root.resolve("child"));
      createSymbolicLink(child.resolve("grandchild"), root);

      ClassPath.DefaultScanner scanner = new ClassPath.DefaultScanner();
      scanner.scan(root.toFile(), loader);

      assertEquals(ImmutableSet.of(new ResourceInfo("some.txt", loader)), scanner.getResources());
    } finally {
      deleteRecursively(root);
    }
  }
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:23,代码来源:ClassPathTest.java


示例2: testGetResources

import com.google.common.reflect.ClassPath.ResourceInfo; //导入依赖的package包/类
public void testGetResources() throws Exception {
  Map<String, ResourceInfo> byName = Maps.newHashMap();
  Map<String, ResourceInfo> byToString = Maps.newHashMap();
  ClassPath classpath = ClassPath.from(getClass().getClassLoader());
  for (ResourceInfo resource : classpath.getResources()) {
    assertThat(resource.getResourceName()).isNotEqualTo(JarFile.MANIFEST_NAME);
    assertThat(resource.toString()).isNotEqualTo(JarFile.MANIFEST_NAME);
    byName.put(resource.getResourceName(), resource);
    byToString.put(resource.toString(), resource);
    assertNotNull(resource.url());
  }
  String testResourceName = "com/google/common/reflect/test.txt";
  assertThat(byName.keySet()).containsAllOf(
      "com/google/common/reflect/ClassPath.class",
      "com/google/common/reflect/ClassPathTest.class",
      "com/google/common/reflect/ClassPathTest$Nested.class",
      testResourceName);
  assertThat(byToString.keySet()).containsAllOf(
      "com.google.common.reflect.ClassPath",
      "com.google.common.reflect.ClassPathTest",
      "com.google.common.reflect.ClassPathTest$Nested",
      testResourceName);
  assertEquals(getClass().getClassLoader().getResource(testResourceName),
      byName.get("com/google/common/reflect/test.txt").url());
}
 
开发者ID:sander120786,项目名称:guava-libraries,代码行数:26,代码来源:ClassPathTest.java


示例3: Path

import com.google.common.reflect.ClassPath.ResourceInfo; //导入依赖的package包/类
@AndroidIncompatible // Path (for symlink creation)

  public void testScanDirectory_symlinkToRootCycle() throws IOException {
    ClassLoader loader = ClassPathTest.class.getClassLoader();
    // directory with a cycle,
    // /root
    //    /child
    //       /[grandchild -> root]
    java.nio.file.Path root = createTempDirectory("ClassPathTest");
    try {
      createFile(root.resolve("some.txt"));
      java.nio.file.Path child = createDirectory(root.resolve("child"));
      createSymbolicLink(child.resolve("grandchild"), root);

      ClassPath.DefaultScanner scanner = new ClassPath.DefaultScanner();
      scanner.scan(root.toFile(), loader);

      assertEquals(ImmutableSet.of(new ResourceInfo("some.txt", loader)), scanner.getResources());
    } finally {
      deleteRecursivelyOrLog(root);
    }
  }
 
开发者ID:google,项目名称:guava,代码行数:23,代码来源:ClassPathTest.java


示例4: determineInstrumentableClasses

import com.google.common.reflect.ClassPath.ResourceInfo; //导入依赖的package包/类
public static Set< String > determineInstrumentableClasses() throws Throwable
{
	TaxonomyLoader loader = new AgentTaxonomyLoader();
	Set< ResourceInfo > resources = ClassPath.from( loader.getClassLoader() ).getResources();
	Set< Class< ? > > viewedClasses = new HashSet< Class< ? > >();
	resources.stream()
		.filter( resourceInfo -> resourceInfo.getResourceName().endsWith( ".tax" ) )
		.map( resourceInfo -> getTaxonomy( loader, resourceInfo.getResourceName() ) )
		.filter( taxonomy -> taxonomy != null )
		.forEach( taxonomy -> viewedClasses.addAll( getViewedClasses( taxonomy ) ) );
	Set< String > instrumentableClassNames = viewedClasses.stream()
		.filter( viewedClass -> isTopLevelClass( viewedClass, viewedClasses ) )
		.map( viewedClass -> viewedClass.getName() )
		.collect( Collectors.toSet() );
	
	return instrumentableClassNames;
}
 
开发者ID:liquid-mind,项目名称:inflection,代码行数:18,代码来源:MemoryManagementAgent.java


示例5: testEquals

import com.google.common.reflect.ClassPath.ResourceInfo; //导入依赖的package包/类
public void testEquals() {
  new EqualsTester()
      .addEqualityGroup(classInfo(ClassPathTest.class), classInfo(ClassPathTest.class))
      .addEqualityGroup(classInfo(Test.class), classInfo(Test.class, getClass().getClassLoader()))
      .addEqualityGroup(
          new ResourceInfo("a/b/c.txt", getClass().getClassLoader()),
          new ResourceInfo("a/b/c.txt", getClass().getClassLoader()))
      .addEqualityGroup(
          new ResourceInfo("x.txt", getClass().getClassLoader()))
      .testEquals();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:12,代码来源:ClassPathTest.java


示例6: registerVanillaPasses

import com.google.common.reflect.ClassPath.ResourceInfo; //导入依赖的package包/类
private void registerVanillaPasses()
{
    try
    {
        for(ResourceInfo info : ClassPath.from(Thread.currentThread().getContextClassLoader()).getResources())
        {
            if(info.getResourceName().startsWith("assets/minecraft/shaders/program/") && info.getResourceName().endsWith(".json"))
            {
                String[] parts = info.getResourceName().split("/");
                String file = parts[parts.length - 1];
                String name = file.substring(0, file.indexOf("."));
                if(name.equals("phosphor"))
                {
                    PassRegistry.register(name, new PhosphorPass());
                }
                else if(name.equals("notch"))
                {
                    PassRegistry.register(name, new NotchPass());
                }
                else
                    PassRegistry.register(name, new VanillaPass(name));
            }
        }
    }
    catch(IOException e)
    {
        e.printStackTrace();
    }
}
 
开发者ID:jglrxavpok,项目名称:ShadyMod,代码行数:30,代码来源:ShadyMod.java


示例7: ApiDocumentMetadata

import com.google.common.reflect.ClassPath.ResourceInfo; //导入依赖的package包/类
/**
 * 
 * @param document The resource pointing to the document to be represented
 * @param docSuffix The portion of the filename that should be removed for Title generation
 */
public ApiDocumentMetadata(ResourceInfo document, String docSuffix) {
	this.document = document;

	String name = document.getResourceName();
	String title = name;
	if (name.contains("/") && !name.endsWith("/")) {
		name = name.substring(name.lastIndexOf("/") + 1);
		title = StringUtils.capitalize(name).replace(docSuffix, "");
	}
	this.path = name;
	this.title = title;
}
 
开发者ID:phoenixnap,项目名称:springmvc-raml-plugin,代码行数:18,代码来源:ApiDocumentMetadata.java


示例8: testEquals

import com.google.common.reflect.ClassPath.ResourceInfo; //导入依赖的package包/类
public void testEquals() {
  new EqualsTester()
      .addEqualityGroup(classInfo(ClassPathTest.class), classInfo(ClassPathTest.class))
      .addEqualityGroup(classInfo(Test.class), classInfo(Test.class, getClass().getClassLoader()))
      .addEqualityGroup(
          new ResourceInfo("a/b/c.txt", getClass().getClassLoader()),
          new ResourceInfo("a/b/c.txt", getClass().getClassLoader()))
      .addEqualityGroup(new ResourceInfo("x.txt", getClass().getClassLoader()))
      .testEquals();
}
 
开发者ID:google,项目名称:guava,代码行数:11,代码来源:ClassPathTest.java


示例9: doTestExistsThrowsSecurityException

import com.google.common.reflect.ClassPath.ResourceInfo; //导入依赖的package包/类
private void doTestExistsThrowsSecurityException() throws IOException, URISyntaxException {
  File file = null;
  // In Java 9, Logger may read the TZ database. Only disallow reading the class path URLs.
  final PermissionCollection readClassPathFiles =
      new FilePermission("", "read").newPermissionCollection();
  for (URL url : ClassPath.Scanner.parseJavaClassPath()) {
    if (url.getProtocol().equalsIgnoreCase("file")) {
      file = new File(url.toURI());
      readClassPathFiles.add(new FilePermission(file.getAbsolutePath(), "read"));
    }
  }
  assertThat(file).isNotNull();
  SecurityManager disallowFilesSecurityManager =
      new SecurityManager() {
        @Override
        public void checkPermission(Permission p) {
          if (readClassPathFiles.implies(p)) {
            throw new SecurityException("Disallowed: " + p);
          }
        }
      };
  System.setSecurityManager(disallowFilesSecurityManager);
  try {
    file.exists();
    fail("Did not get expected SecurityException");
  } catch (SecurityException expected) {
  }
  ClassPath classPath = ClassPath.from(getClass().getClassLoader());
  // ClassPath may contain resources from the boot class loader; just not from the class path.
  for (ResourceInfo resource : classPath.getResources()) {
    assertThat(resource.getResourceName()).doesNotContain("com/google/common/reflect/");
  }
}
 
开发者ID:google,项目名称:guava,代码行数:34,代码来源:ClassPathTest.java


示例10: resourceInfo

import com.google.common.reflect.ClassPath.ResourceInfo; //导入依赖的package包/类
private static ResourceInfo resourceInfo(Class<?> cls) {
  String resource = cls.getName().replace('.', '/') + ".class";
  ClassLoader loader = cls.getClassLoader();
  return ResourceInfo.of(resource, loader);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:6,代码来源:ClassPathTest.java


示例11: resourceInfo

import com.google.common.reflect.ClassPath.ResourceInfo; //导入依赖的package包/类
private static ResourceInfo resourceInfo(Class<?> cls) {
  return ResourceInfo.of(cls.getName().replace('.', '/') + ".class", cls.getClassLoader());
}
 
开发者ID:sander120786,项目名称:guava-libraries,代码行数:4,代码来源:ClassPathTest.java


示例12: setup

import com.google.common.reflect.ClassPath.ResourceInfo; //导入依赖的package包/类
@BeforeMethod
public void setup() throws IOException {
  dataContext = new AnnotationConfigApplicationContext();
  dataContext.getEnvironment().setActiveProfiles(Profiles.UNIT_TEST);
  dataContext.scan("org.diqube");
  dataContext.refresh();

  tableRegistry = dataContext.getBean(TableRegistry.class);
  metadataManagerMock = Mockito.mock(TableMetadataManager.class);

  ServerTableMetadataPublisher metadataPublisher =
      ServerTableMetadataPublisherTestUtil.create(dataContext.getBean(TableRegistry.class),
          dataContext.getBean(TableShardMetadataBuilderFactory.class), metadataManagerMock);

  controlFileFactory = new Function<File, ControlFileLoader>() {
    @Override
    public ControlFileLoader apply(File controlFile) {
      return new ControlFileLoader( //
          tableRegistry, //
          dataContext.getBean(TableFactory.class), //
          dataContext.getBean(CsvLoader.class), //
          dataContext.getBean(JsonLoader.class), //
          dataContext.getBean(DiqubeLoader.class), //
          dataContext.getBean(ClusterFlattenServiceHandler.class), //
          metadataPublisher, //
          controlFile);
    }
  };

  testDir = File.createTempFile(ControlFileLoaderTest.class.getSimpleName(), Long.toString(System.nanoTime()));
  testDir.delete();
  testDir.mkdir();

  for (ResourceInfo resInfo : ClassPath.from(this.getClass().getClassLoader()).getResources()) {
    if (resInfo.getResourceName().startsWith(TESTDATA_CLASSPATH)) {
      String targetFileName = resInfo.getResourceName().substring(TESTDATA_CLASSPATH.length());
      try (FileOutputStream fos = new FileOutputStream(new File(testDir, targetFileName))) {
        InputStream is = this.getClass().getClassLoader().getResourceAsStream(resInfo.getResourceName());
        ByteStreams.copy(is, fos);
      }
    }
  }
}
 
开发者ID:diqube,项目名称:diqube,代码行数:44,代码来源:ControlFileLoaderTest.java


示例13: data

import com.google.common.reflect.ClassPath.ResourceInfo; //导入依赖的package包/类
@Parameters(name = "{index}: {0}")
public static Iterable<Object[]> data() throws IOException {
  Path testDataPath = Paths.get("com/google/googlejavaformat/java/testdata");
  ClassLoader classLoader = FormatterIntegrationTest.class.getClassLoader();
  Map<String, String> inputs = new TreeMap<>();
  Map<String, String> outputs = new TreeMap<>();
  for (ResourceInfo resourceInfo : ClassPath.from(classLoader).getResources()) {
    String resourceName = resourceInfo.getResourceName();
    Path resourceNamePath = Paths.get(resourceName);
    if (resourceNamePath.startsWith(testDataPath)) {
      Path subPath = testDataPath.relativize(resourceNamePath);
      assertEquals("bad testdata file names", 1, subPath.getNameCount());
      String baseName = getNameWithoutExtension(subPath.getFileName().toString());
      String extension = getFileExtension(subPath.getFileName().toString());
      String contents;
      try (InputStream stream =
          FormatterIntegrationTest.class.getClassLoader().getResourceAsStream(resourceName)) {
        contents = CharStreams.toString(new InputStreamReader(stream, UTF_8));
      }
      switch (extension) {
        case "input":
          inputs.put(baseName, contents);
          break;
        case "output":
          outputs.put(baseName, contents);
          break;
        default:
      }
    }
  }
  List<Object[]> testInputs = new ArrayList<>();
  assertEquals("unmatched inputs and outputs", inputs.size(), outputs.size());
  for (Map.Entry<String, String> entry : inputs.entrySet()) {
    String fileName = entry.getKey();
    String input = inputs.get(fileName);
    assertTrue("unmatched input", outputs.containsKey(fileName));
    String expectedOutput = outputs.get(fileName);
    testInputs.add(new Object[] {fileName, input, expectedOutput});
  }
  return testInputs;
}
 
开发者ID:google,项目名称:google-java-format,代码行数:42,代码来源:FormatterIntegrationTest.java



注:本文中的com.google.common.reflect.ClassPath.ResourceInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CompilationCustomizer类代码示例发布时间:2022-05-22
下一篇:
Java SpellingContext类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap