當前位置: 首頁>>代碼示例>>Java>>正文


Java JavaFileObjects.forResource方法代碼示例

本文整理匯總了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");
}
 
開發者ID:dzuvic,項目名稱:jtsgen,代碼行數:27,代碼來源:TsGenProcessorTest.java

示例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);
}
 
開發者ID:MatthiasRobbers,項目名稱:shortbread,代碼行數:11,代碼來源:ActivityShortcutTest.java

示例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);
}
 
開發者ID:dzuvic,項目名稱:jtsgen,代碼行數:20,代碼來源:TsGenProcessorTest.java

示例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 ) );
}
 
開發者ID:arez,項目名稱:arez,代碼行數:11,代碼來源:ArezProcessorTest.java

示例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);
}
 
開發者ID:ccheptea,項目名稱:auto-value-variant,代碼行數:12,代碼來源:AutoValueVariantExtensionTest.java

示例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 ) );
}
 
開發者ID:arez,項目名稱:arez,代碼行數:12,代碼來源:ArezProcessorTest.java

示例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 ) );
}
 
開發者ID:arez,項目名稱:arez,代碼行數:12,代碼來源:ArezProcessorTest.java

示例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);
}
 
開發者ID:MatthiasRobbers,項目名稱:shortbread,代碼行數:11,代碼來源:ActivityShortcutTest.java

示例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 ) );
}
 
開發者ID:arez,項目名稱:arez,代碼行數:12,代碼來源:ArezProcessorTest.java

示例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 ) );
}
 
開發者ID:arez,項目名稱:arez,代碼行數:14,代碼來源:ArezProcessorTest.java

示例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);
}
 
開發者ID:MatthiasRobbers,項目名稱:shortbread,代碼行數:14,代碼來源:ActivityShortcutTest.java

示例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);
}
 
開發者ID:dzuvic,項目名稱:jtsgen,代碼行數:12,代碼來源:TsGenProcessorTest.java

示例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);
}
 
開發者ID:MatthiasRobbers,項目名稱:shortbread,代碼行數:11,代碼來源:ActivityShortcutTest.java

示例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);
}
 
開發者ID:MatthiasRobbers,項目名稱:shortbread,代碼行數:15,代碼來源:ActivityShortcutTest.java

示例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);
}
 
開發者ID:ccheptea,項目名稱:auto-value-variant,代碼行數:12,代碼來源:AutoValueVariantExtensionTest.java


注:本文中的com.google.testing.compile.JavaFileObjects.forResource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。