public Builder addClass(Class<?> clazz) { archive.add(new ClassAsset(clazz), ClassPath.ROOT_ARCHIVE_PATH + clazz.getName()); return this; }
Asset resource = new ClassAsset(clazz); ArchivePath location = new BasicPath(getClassesPath(), AssetUtil.getFullPathForClassResource(clazz)); add(resource, location);
@Test public void shouldBeAbleToReturnThisClass() throws Exception { final Class<?> clazz = ClassAssetTestCase.class; final Asset asset = new ClassAsset(clazz); Assert.assertTrue(clazz.getName().equals(((ClassAsset)asset).getSource().getName())); } }
Asset resource = new ClassAsset(clazz); ArchivePath location = new BasicPath(getClassesPath(), AssetUtil.getFullPathForClassResource(clazz)); add(resource, location);
classesPackage = clazz.getPackage(); Asset resource = new ClassAsset(clazz); ArchivePath location = ArchivePaths.create(resolveClassesPath(archive), AssetUtil.getFullPathForClassResource(clazz)); archive.add(resource, location);
@Test public void shouldThrowExceptionOnNullClass() throws Exception { try { new ClassAsset(null); Assert.fail("Should have thrown IllegalArgumentException"); } catch (Exception e) { Assert.assertEquals("A null clazz argument should result in a IllegalArgumentException", IllegalArgumentException.class, e.getClass()); } }
Asset classAsset = new ClassAsset(klass); ArchivePath classArchivePath = new BasicPath("/classes", AssetUtil.getFullPathForClassResource(klass));
@Test public void shouldBeAbleToReadThisClass() throws Exception { Class<?> clazz = ClassAssetTestCase.class; Asset asset = new ClassAsset(clazz); InputStream io = asset.openStream(); Assert.assertNotNull(io); Assert.assertEquals("Loaded class should have the same size", ApiTestUtils.findLengthOfStream(io), ApiTestUtils.findLengthOfClass(clazz)); }
/** * https://jira.jboss.org/jira/browse/TMPARCH-19 <br/> * <br/> * A {@link Class} loaded by the Bootstrap ClassLoader will return a null {@link ClassLoader}, should use * {@link Thread} current context {@link ClassLoader} instead. * * @throws Exception */ @Test public void shouldBeAbleAddBootstrapClass() throws Exception { Class<?> bootstrapClass = Class.class; Asset asset = new ClassAsset(bootstrapClass); InputStream io = asset.openStream(); Assert.assertNotNull(io); Assert.assertEquals("Loaded class should have the same size", ApiTestUtils.findLengthOfStream(io), ApiTestUtils.findLengthOfClass(bootstrapClass)); }