示例#1
0
 @Override
 public void prepareTestInstance(TestContext context) {
   List<Field> mocks = context.introspector().selectFields(fieldsAnnotatedBy(Mock.class));
   Mockery mockery = findProvidedMockery(context);
   if (mockery == null) {
     mockery = new Mockery();
     for (Field mock : mocks) {
       if (!mock.getType().isInterface()) {
         mockery.setImposteriser(ClassImposteriser.INSTANCE);
         break;
       }
     }
   }
   context.attributes().set(MOCKERY, mockery);
   for (Field field :
       context
           .introspector()
           .selectFields(
               and(fieldsAccepting(Mockery.class), fieldsAnnotatedBy(MockContext.class)))) {
     context.introspector().set(field, mockery);
   }
   for (Field field : mocks) {
     context
         .introspector()
         .set(
             field,
             mockery.mock(
                 field.getType(), field.getDeclaringClass().getName() + "." + field.getName()));
   }
 }
示例#2
0
  @Before
  public void before() throws IOException, URISyntaxException {
    context = new Mockery();
    context.setImposteriser(ClassImposteriser.INSTANCE);
    taskContext = context.mock(TaskInputOutputContext.class, "taskContext");
    conf = new Configuration();

    conf.set("mapred.output.dir", INDEX_TMP_DIR.toString());
    conf.setLong(TripleIndexGenerator.NUMBER_OF_DOCUMENTS, 8);

    fs.initialize(new URI("file:///"), new Configuration());
  }
示例#3
0
 @Before
 public void setUp() {
   super.setUp();
   context.setImposteriser(ClassImposteriser.INSTANCE);
   wrapper = createTask(Wrapper.class);
   wrapperScriptGeneratorMock = context.mock(WrapperScriptGenerator.class);
   wrapper.setScriptDestinationPath("scriptDestination");
   wrapper.setGradleVersion("1.0");
   targetWrapperJarPath = "jarPath";
   expectedTargetWrapperJar =
       new TestFile(
           getProject().getProjectDir(), targetWrapperJarPath + "/" + Wrapper.WRAPPER_JAR);
   expectedTargetWrapperProperties =
       new File(
           getProject().getProjectDir(), targetWrapperJarPath + "/" + Wrapper.WRAPPER_PROPERTIES);
   new File(getProject().getProjectDir(), targetWrapperJarPath).mkdirs();
   distributionPath = "somepath";
   wrapper.setJarPath(targetWrapperJarPath);
   wrapper.setDistributionPath(distributionPath);
   wrapper.setUnixWrapperScriptGenerator(wrapperScriptGeneratorMock);
 }
 @Before
 public void setUp() {
   mockery.setImposteriser(ClassImposteriser.INSTANCE);
 }