本文整理汇总了Java中com.google.testing.compile.JavaFileObjects.forResource方法的典型用法代码示例。如果您正苦于以下问题:Java JavaFileObjects.forResource方法的具体用法?Java JavaFileObjects.forResource怎么用?Java JavaFileObjects.forResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.testing.compile.JavaFileObjects
的用法示例。
在下文中一共展示了JavaFileObjects.forResource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_simple_interface_1
import com.google.testing.compile.JavaFileObjects; //导入方法依赖的package包/类
@Test
public void test_simple_interface_1() throws IOException {
JavaFileObject[] files = {JavaFileObjects.forResource("jts/dev/InterFaceTest.java")};
Compilation c = javac()
.withProcessors(new TsGenProcessor())
.withOptions("-AjtsgenModuleName=MyModule")
.compile(files);
assertEquals(0, c.errors().size());
// check debug is disabled
assertEquals(Logger.getLogger(TsGenProcessor.class.getPackage().getName()).getLevel(), Level.OFF);
assertTrue(c.generatedFile(StandardLocation.SOURCE_OUTPUT, StringConstForTest.JTSGEN_MYMODULE, PACKAGE_JSON).isPresent());
assertTrue(c.generatedFile(StandardLocation.SOURCE_OUTPUT, StringConstForTest.JTSGEN_MYMODULE, StringConstForTest.MY_MODULE_D_TS).isPresent());
JavaFileObject testee2 = c.generatedFile(StandardLocation.SOURCE_OUTPUT, StringConstForTest.JTSGEN_MYMODULE, StringConstForTest.MY_MODULE_D_TS).get();
ReferenceHelper.assertEquals(
c.generatedFile(StandardLocation.SOURCE_OUTPUT, StringConstForTest.JTSGEN_MYMODULE, PACKAGE_JSON).get()
, "simple_interface_1.package.json");
ReferenceHelper.assertEquals(
c.generatedFile(StandardLocation.SOURCE_OUTPUT, StringConstForTest.JTSGEN_MYMODULE, StringConstForTest.MY_MODULE_D_TS).get()
, "simple_interface_1.my-module.d.ts");
}
示例2: simpleShortcutActivity
import com.google.testing.compile.JavaFileObjects; //导入方法依赖的package包/类
@Test
public void simpleShortcutActivity() {
JavaFileObject source = JavaFileObjects.forResource("SimpleShortcutActivity.java");
JavaFileObject generated = JavaFileObjects.forResource("SimpleShortcutActivityGenerated.java");
assertAbout(javaSource()).that(source)
.processedWith(new ShortcutProcessor())
.compilesWithoutError()
.and()
.generatesSources(generated);
}
示例3: check_simple_ts_module_error
import com.google.testing.compile.JavaFileObjects; //导入方法依赖的package包/类
@Test
public void check_simple_ts_module_error() {
JavaFileObject[] files = {
JavaFileObjects.forResource("jts/modules/tsmodule_error/InterFaceTestTsModuleError.java"),
JavaFileObjects.forResource("jts/modules/tsmodule_error/package-info.java")
};
Compilation c = javac()
.withProcessors(new TsGenProcessor())
.withOptions("-AjtsgenLogLevel=none")
.compile(files);
assertTrue(c.errors().size() > 0);
boolean v1 = c.errors().stream().anyMatch( x -> x.getMessage(Locale.ENGLISH).contains("param not valid. Expecting a name space"));
boolean v2 = c.errors().stream().anyMatch( x -> x.getMessage(Locale.ENGLISH).contains("param not valid. Expecting origin and target"));
boolean v3 = c.errors().stream().anyMatch( x -> x.getMessage(Locale.ENGLISH).contains("param not valid. Expecting a regular Expression."));
// at least one of the error must exists
assertTrue( v1 || v2 || v3);
}
示例4: processSuccessfulWhereTypeResolvedInInheritanceHierarchy
import com.google.testing.compile.JavaFileObjects; //导入方法依赖的package包/类
@Test
public void processSuccessfulWhereTypeResolvedInInheritanceHierarchy()
throws Exception
{
final JavaFileObject source1 = JavaFileObjects.forResource( "input/com/example/type_params/AbstractModel.java" );
final JavaFileObject source2 = JavaFileObjects.forResource( "input/com/example/type_params/MiddleModel.java" );
final JavaFileObject source3 = JavaFileObjects.forResource( "input/com/example/type_params/ConcreteModel.java" );
final String output1 = "expected/com/example/type_params/Arez_ConcreteModel.java";
assertSuccessfulCompile( Arrays.asList( source1, source2, source3 ), Collections.singletonList( output1 ) );
}
示例5: testDummyGroup
import com.google.testing.compile.JavaFileObjects; //导入方法依赖的package包/类
@Test
public void testDummyGroup() throws FileNotFoundException {
JavaFileObject model = JavaFileObjects.forResource("input/ModelDummyGroup.java");
JavaFileObject autoModel = JavaFileObjects.forResource("expected/ModelDummyGroup.java");
assertAbout(javaSources())
.that(Arrays.asList(model))
.processedWith(autoValueProcessor)
.compilesWithoutError()
.and()
.generatesSources(autoModel);
}
示例6: processResolvedParameterizedType
import com.google.testing.compile.JavaFileObjects; //导入方法依赖的package包/类
@Test
public void processResolvedParameterizedType()
throws Exception
{
final JavaFileObject source1 =
JavaFileObjects.forResource( "input/com/example/parameterized_type/ParentModel.java" );
final JavaFileObject source2 =
JavaFileObjects.forResource( "input/com/example/parameterized_type/ResolvedModel.java" );
final String output1 = "expected/com/example/parameterized_type/Arez_ResolvedModel.java";
assertSuccessfulCompile( Arrays.asList( source1, source2 ), Collections.singletonList( output1 ) );
}
示例7: processUnresolvedParameterizedType
import com.google.testing.compile.JavaFileObjects; //导入方法依赖的package包/类
@Test
public void processUnresolvedParameterizedType()
throws Exception
{
final JavaFileObject source1 =
JavaFileObjects.forResource( "input/com/example/parameterized_type/ParentModel.java" );
final JavaFileObject source2 =
JavaFileObjects.forResource( "input/com/example/parameterized_type/UnresolvedModel.java" );
final String output1 = "expected/com/example/parameterized_type/Arez_UnresolvedModel.java";
assertSuccessfulCompile( Arrays.asList( source1, source2 ), Collections.singletonList( output1 ) );
}
示例8: disabledShortcutActivity
import com.google.testing.compile.JavaFileObjects; //导入方法依赖的package包/类
@Test
public void disabledShortcutActivity() {
JavaFileObject source = JavaFileObjects.forResource("DisabledShortcutActivity.java");
JavaFileObject generated = JavaFileObjects.forResource("DisabledShortcutActivityGenerated.java");
assertAbout(javaSource()).that(source)
.processedWith(new ShortcutProcessor())
.compilesWithoutError()
.and()
.generatesSources(generated);
}
示例9: processSuccessfulInheritedProtectedAccessInDifferentPackage
import com.google.testing.compile.JavaFileObjects; //导入方法依赖的package包/类
@Test
public void processSuccessfulInheritedProtectedAccessInDifferentPackage()
throws Exception
{
final JavaFileObject source1 =
JavaFileObjects.forResource( "input/com/example/tracked/InheritProtectedAccessTrackedModel.java" );
final JavaFileObject source2 =
JavaFileObjects.forResource( "input/com/example/tracked/other/BaseModelProtectedAccess.java" );
final String output = "expected/com/example/tracked/Arez_InheritProtectedAccessTrackedModel.java";
assertSuccessfulCompile( Arrays.asList( source1, source2 ), Collections.singletonList( output ) );
}
示例10: processSuccessfulWhereTraceInheritanceChain
import com.google.testing.compile.JavaFileObjects; //导入方法依赖的package包/类
@Test
public void processSuccessfulWhereTraceInheritanceChain()
throws Exception
{
final JavaFileObject source1 = JavaFileObjects.forResource( "input/com/example/inheritance/BaseModel.java" );
final JavaFileObject source2 = JavaFileObjects.forResource( "input/com/example/inheritance/ParentModel.java" );
final JavaFileObject source3 = JavaFileObjects.forResource( "input/com/example/inheritance/MyModel.java" );
final JavaFileObject source4 = JavaFileObjects.forResource( "input/com/example/inheritance/MyInterface1.java" );
final JavaFileObject source5 = JavaFileObjects.forResource( "input/com/example/inheritance/MyInterface2.java" );
final String output1 = "expected/com/example/inheritance/Arez_MyModel.java";
assertSuccessfulCompile( Arrays.asList( source1, source2, source3, source4, source5 ),
Collections.singletonList( output1 ) );
}
示例11: targetShortcutActivity
import com.google.testing.compile.JavaFileObjects; //导入方法依赖的package包/类
@Test
public void targetShortcutActivity() {
List<JavaFileObject> sources = Arrays.asList(
JavaFileObjects.forResource("EmptyActivity1.java"),
JavaFileObjects.forResource("TargetShortcutActivity.java")
);
JavaFileObject generated = JavaFileObjects.forResource("TargetShortcutActivityGenerated.java");
assertAbout(javaSources()).that(sources)
.processedWith(new ShortcutProcessor())
.compilesWithoutError()
.and()
.generatesSources(generated);
}
示例12: check_simple_interface_No_Logging
import com.google.testing.compile.JavaFileObjects; //导入方法依赖的package包/类
@Test
public void check_simple_interface_No_Logging() {
JavaFileObject[] files = {JavaFileObjects.forResource("jts/dev/InterFaceTest.java")};
Compilation c = javac()
.withProcessors(new TsGenProcessor())
.withOptions("-Agone=nowhere", "-AjtsgenLogLevel=DUMMY")
.compile(files);
// check that any logging is disabled is disabled
assertEquals(Logger.getLogger(TsGenProcessor.class.getPackage().getName()).getLevel(), Level.OFF);
}
示例13: advancedShortcutActivity
import com.google.testing.compile.JavaFileObjects; //导入方法依赖的package包/类
@Test
public void advancedShortcutActivity() {
JavaFileObject source = JavaFileObjects.forResource("AdvancedShortcutActivity.java");
JavaFileObject generated = JavaFileObjects.forResource("AdvancedShortcutActivityGenerated.java");
assertAbout(javaSource()).that(source)
.processedWith(new ShortcutProcessor())
.compilesWithoutError()
.and()
.generatesSources(generated);
}
示例14: backstackShortcutActivity
import com.google.testing.compile.JavaFileObjects; //导入方法依赖的package包/类
@Test
public void backstackShortcutActivity() {
List<JavaFileObject> sources = Arrays.asList(
JavaFileObjects.forResource("EmptyActivity1.java"),
JavaFileObjects.forResource("EmptyActivity2.java"),
JavaFileObjects.forResource("BackStackShortcutActivity.java")
);
JavaFileObject generated = JavaFileObjects.forResource("BackStackShortcutActivityGenerated.java");
assertAbout(javaSources()).that(sources)
.processedWith(new ShortcutProcessor())
.compilesWithoutError()
.and()
.generatesSources(generated);
}
示例15: testDefaultGroup
import com.google.testing.compile.JavaFileObjects; //导入方法依赖的package包/类
@Test
public void testDefaultGroup() throws FileNotFoundException {
JavaFileObject model = JavaFileObjects.forResource("input/ModelDefaultGroup.java");
JavaFileObject autoModel = JavaFileObjects.forResource("expected/ModelDefaultGroup.java");
assertAbout(javaSources())
.that(Arrays.asList(model))
.processedWith(autoValueProcessor)
.compilesWithoutError()
.and()
.generatesSources(autoModel);
}