本文整理汇总了Java中org.jboss.forge.roaster.model.source.JavaClassSource.getAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java JavaClassSource.getAnnotation方法的具体用法?Java JavaClassSource.getAnnotation怎么用?Java JavaClassSource.getAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.forge.roaster.model.source.JavaClassSource
的用法示例。
在下文中一共展示了JavaClassSource.getAnnotation方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUniqueComponentPrefix
import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
private String getUniqueComponentPrefix(JavaClassSource clazz) {
AnnotationSource<JavaClassSource> annotation = clazz.getAnnotation(Unique.class);
if (annotation != null) {
return annotation.getStringValue("prefix");
}
return "is";
}
示例2: extractContextNames
import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
private List<String> extractContextNames(JavaClassSource clazz) {
AnnotationSource<JavaClassSource> annotation = clazz.getAnnotation(Contexts.class);
if (annotation != null) {
return Arrays.asList(annotation.getStringArrayValue("names"));
}
return new ArrayList<>();
}
示例3: getComponentNames
import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
List<String> getComponentNames(JavaClassSource type) {
AnnotationSource<JavaClassSource> annotation = type.getAnnotation(CustomComponentName.class);
if (annotation != null) {
return Arrays.asList(annotation.getStringArrayValue("componentNames"));
} else {
return new ArrayList<>();
}
}
示例4: should_create_incontainer_test
import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
@Test
public void should_create_incontainer_test() throws Exception
{
assertThat(project.hasFacet(WildFlySwarmFacet.class), is(true));
try (CommandController controller = uiTestHarness.createCommandController(CreateTestClassCommand.class,
project.getRoot()))
{
controller.initialize();
controller.setValueFor("targetPackage", "org.example");
controller.setValueFor("named", "HelloWorldTest");
assertThat(controller.isValid(), is(true));
final AtomicBoolean flag = new AtomicBoolean();
controller.getContext().addCommandExecutionListener(new AbstractCommandExecutionListener()
{
@Override
public void postCommandExecuted(UICommand command, UIExecutionContext context, Result result)
{
if (result.getMessage().equals("Test Class org.example.HelloWorldTest was created"))
{
flag.set(true);
}
}
});
controller.execute();
assertThat(flag.get(), is(true));
}
JavaResource javaResource = project.getFacet(JavaSourceFacet.class)
.getTestJavaResource("org.example.HelloWorldTest");
assertThat(javaResource.exists(), is(true));
JavaClassSource testClass = Roaster.parse(JavaClassSource.class, javaResource.getContents());
assertThat(testClass.getAnnotation(RunWith.class), is((notNullValue())));
final AnnotationSource<JavaClassSource> defaultDeployment = testClass.getAnnotation("DefaultDeployment");
assertThat(defaultDeployment, is((notNullValue())));
assertThat(defaultDeployment.getValues().size(), is(0));
final MethodSource<JavaClassSource> testMethod = testClass.getMethod("should_start_service");
assertThat(testMethod, is(notNullValue()));
assertThat(testMethod.getAnnotation(Test.class), is(notNullValue()));
}
示例5: should_create_asclient_test
import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
@Test
public void should_create_asclient_test() throws Exception
{
assertThat(project.hasFacet(WildFlySwarmFacet.class), is(true));
try (CommandController controller = uiTestHarness.createCommandController(CreateTestClassCommand.class,
project.getRoot()))
{
controller.initialize();
controller.setValueFor("targetPackage", "org.example");
controller.setValueFor("named", "HelloWorldTest");
controller.setValueFor("asClient", true);
assertThat(controller.isValid(), is(true));
final AtomicBoolean flag = new AtomicBoolean();
controller.getContext().addCommandExecutionListener(new AbstractCommandExecutionListener()
{
@Override
public void postCommandExecuted(UICommand command, UIExecutionContext context, Result result)
{
if (result.getMessage().equals("Test Class org.example.HelloWorldTest was created"))
{
flag.set(true);
}
}
});
controller.execute();
assertThat(flag.get(), is(true));
}
JavaResource javaResource = project.getFacet(JavaSourceFacet.class)
.getTestJavaResource("org.example.HelloWorldTest");
assertThat(javaResource.exists(), is(true));
JavaClassSource testClass = Roaster.parse(JavaClassSource.class, javaResource.getContents());
assertThat(testClass.getAnnotation(RunWith.class), is((notNullValue())));
final AnnotationSource<JavaClassSource> defaultDeployment = testClass.getAnnotation("DefaultDeployment");
assertThat(defaultDeployment, is((notNullValue())));
final String testable = defaultDeployment.getLiteralValue("testable");
assertThat(testable, is("false"));
final MethodSource<JavaClassSource> testMethod = testClass.getMethod("should_start_service");
assertThat(testMethod, is(notNullValue()));
assertThat(testMethod.getAnnotation(Test.class), is(notNullValue()));
}
示例6: should_set_archivetype_test
import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
@Test
public void should_set_archivetype_test() throws Exception
{
assertThat(project.hasFacet(WildFlySwarmFacet.class), is(true));
try (CommandController controller = uiTestHarness.createCommandController(CreateTestClassCommand.class,
project.getRoot()))
{
controller.initialize();
controller.setValueFor("targetPackage", "org.example");
controller.setValueFor("named", "HelloWorldTest");
controller.setValueFor("archiveType", "WAR");
assertThat(controller.isValid(), is(true));
final AtomicBoolean flag = new AtomicBoolean();
controller.getContext().addCommandExecutionListener(new AbstractCommandExecutionListener()
{
@Override
public void postCommandExecuted(UICommand command, UIExecutionContext context, Result result)
{
if (result.getMessage().equals("Test Class org.example.HelloWorldTest was created"))
{
flag.set(true);
}
}
});
controller.execute();
assertThat(flag.get(), is(true));
}
JavaResource javaResource = project.getFacet(JavaSourceFacet.class)
.getTestJavaResource("org.example.HelloWorldTest");
assertThat(javaResource.exists(), is(true));
JavaClassSource testClass = Roaster.parse(JavaClassSource.class, javaResource.getContents());
assertThat(testClass.getAnnotation(RunWith.class), is((notNullValue())));
final AnnotationSource<JavaClassSource> defaultDeployment = testClass.getAnnotation("DefaultDeployment");
assertThat(defaultDeployment, is((notNullValue())));
final String testable = defaultDeployment.getLiteralValue("type");
assertThat(testable, is("DefaultDeployment.Type.WAR"));
final MethodSource<JavaClassSource> testMethod = testClass.getMethod("should_start_service");
assertThat(testMethod, is(notNullValue()));
assertThat(testMethod.getAnnotation(Test.class), is(notNullValue()));
}
示例7: should_set_mainclass_test
import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
@Test
public void should_set_mainclass_test() throws Exception
{
assertThat(project.hasFacet(WildFlySwarmFacet.class), is(true));
try (CommandController controller = uiTestHarness.createCommandController(CreateTestClassCommand.class,
project.getRoot()))
{
controller.initialize();
controller.setValueFor("targetPackage", "org.example");
controller.setValueFor("named", "HelloWorldTest");
controller.setValueFor("archiveType", "WAR");
controller.setValueFor("mainClass", "org.example.Main");
assertThat(controller.isValid(), is(true));
final AtomicBoolean flag = new AtomicBoolean();
controller.getContext().addCommandExecutionListener(new AbstractCommandExecutionListener()
{
@Override
public void postCommandExecuted(UICommand command, UIExecutionContext context, Result result)
{
if (result.getMessage().equals("Test Class org.example.HelloWorldTest was created"))
{
flag.set(true);
}
}
});
controller.execute();
assertThat(flag.get(), is(true));
}
JavaResource javaResource = project.getFacet(JavaSourceFacet.class)
.getTestJavaResource("org.example.HelloWorldTest");
assertThat(javaResource.exists(), is(true));
JavaClassSource testClass = Roaster.parse(JavaClassSource.class, javaResource.getContents());
assertThat(testClass.getAnnotation(RunWith.class), is((notNullValue())));
final AnnotationSource<JavaClassSource> defaultDeployment = testClass.getAnnotation("DefaultDeployment");
assertThat(defaultDeployment, is((notNullValue())));
final String testable = defaultDeployment.getLiteralValue("type");
assertThat(testable, is("DefaultDeployment.Type.WAR"));
final String main = defaultDeployment.getLiteralValue("main");
assertThat(main, is("org.example.Main"));
final MethodSource<JavaClassSource> testMethod = testClass.getMethod("should_start_service");
assertThat(testMethod, is(notNullValue()));
assertThat(testMethod.getAnnotation(Test.class), is(notNullValue()));
}