微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

org.mockito.internal.matchers.InstanceOf的实例源码

项目:samBox    文件PDDocumentWriterTest.java   
@Test
public void writeBodySync() throws Exception
{
    PDDocument document = mock(PDDocument.class);
    COSDocument cosDoc = mock(COSDocument.class);
    FileTrailer trailer = new FileTrailer();
    when(document.getDocument()).thenReturn(cosDoc);
    when(cosDoc.getTrailer()).thenReturn(trailer);
    this.victim = new PDDocumentWriter(from(new DevNullWritableByteChannel()),null,WriteOption.SYNC_BODY_WRITE);
    TestUtils.setProperty(victim,"writer",this.writer);
    ArgumentCaptor<PDFBodyWriter> bodyWriter = ArgumentCaptor.forClass(PDFBodyWriter.class);
    victim.write(document);
    verify(cosDoc).accept(bodyWriter.capture());
    assertthat(bodyWriter.getValue().objectsWriter,new InstanceOf(SyncPDFBodyObjectsWriter.class));
}
项目:samBox    文件PDDocumentWriterTest.java   
@Test
public void writeBodyCompressed() throws Exception
{
    PDDocument document = mock(PDDocument.class);
    COSDocument cosDoc = mock(COSDocument.class);
    FileTrailer trailer = new FileTrailer();
    when(document.getDocument()).thenReturn(cosDoc);
    when(cosDoc.getTrailer()).thenReturn(trailer);
    this.victim = new PDDocumentWriter(from(new DevNullWritableByteChannel()),WriteOption.SYNC_BODY_WRITE,WriteOption.OBJECT_STREAMS);
    TestUtils.setProperty(victim,new InstanceOf(ObjectsstreamPDFBodyObjectsWriter.class));
}
项目:joynr    文件JoynrEnd2EndTest.java   
public JoynrEnd2Endtest() {
    Answer<AbstractSubscriptionPublisher> answer = new Answer<AbstractSubscriptionPublisher>() {

        @Override
        public AbstractSubscriptionPublisher answer(InvocationOnMock invocation) throws Throwable {
            Object provider = invocation.getArguments()[0];
            if (provider instanceof testProvider) {
                ((testProvider) provider).setSubscriptionPublisher(testSubscriptionPublisher);
            }
            return testSubscriptionPublisher;
        }
    };
    Mockito.doAnswer(answer)
           .when(subscriptionPublisherFactory)
           .create((JoynrProvider) Mockito.argThat(new InstanceOf(testProvider.class)));
}
项目:Bucket    文件BucketArgsTest.java   
@Test
public void testGetNullKey() throws Exception {
    bucket = createCache();

    try {
        bucket.get(null,SimpleObject.class);
        fail("Should throw an exception");
    } catch (Exception e) {
        assertthat(e,new InstanceOf(IllegalArgumentException.class));
        assertEquals("key is null or empty",e.getMessage());
    }
}
项目:Bucket    文件BucketArgsTest.java   
@Test
public void testGetNullType() throws Exception {
    bucket = createCache();

    try {
        bucket.get("TEST_KEY",null);
        fail("Should throw an exception");
    } catch (Exception e) {
        assertthat(e,new InstanceOf(IllegalArgumentException.class));
        assertEquals("typeOfT is null",e.getMessage());
    }
}
项目:Bucket    文件BucketArgsTest.java   
@Test
public void testPutNullKey() throws Exception {
    bucket = createCache();

    try {
        bucket.put(null,new SimpleObject("TEST_VALUE"));
        fail("Should throw an exception");
    } catch (Exception e) {
        assertthat(e,e.getMessage());
    }
}
项目:Bucket    文件BucketArgsTest.java   
@Test
public void testPutNullObject() throws Exception {
    bucket = createCache();

    try {
        bucket.put("TEST_KEY",new InstanceOf(IllegalArgumentException.class));
        assertEquals("object is null",e.getMessage());
    }
}
项目:Bucket    文件BucketArgsTest.java   
@Test
public void testContainsNullKey() throws Exception {
    bucket = createCache();

    try {
        bucket.contains(null);
        fail("Should throw an exception");
    } catch (Exception e) {
        assertthat(e,e.getMessage());
    }
}
项目:Bucket    文件BucketArgsTest.java   
@Test
public void testRemoveNullKey() throws Exception {
    bucket = createCache();

    try {
        bucket.remove(null);
        fail("Should throw an exception");
    } catch (Exception e) {
        assertthat(e,e.getMessage());
    }
}
项目:Bucket    文件BucketArgsTest.java   
@Test
public void testGetAsyncNullKey() throws Exception {
    bucket = createCache();

    try {
        bucket.getAsync(null,SimpleObject.class,e.getMessage());
    }
}
项目:Bucket    文件BucketArgsTest.java   
@Test
public void testGetAsyncNullType() throws Exception {
    bucket = createCache();

    try {
        bucket.getAsync("TEST_KEY",e.getMessage());
    }
}
项目:Bucket    文件BucketArgsTest.java   
@Test
public void testPutAsyncNullKey() throws Exception {
    bucket = createCache();

    try {
        bucket.putAsync(null,new SimpleObject("TEST_VALUE"),e.getMessage());
    }
}
项目:Bucket    文件BucketArgsTest.java   
@Test
public void testPutAsyncNullObject() throws Exception {
    bucket = createCache();

    try {
        bucket.putAsync("TEST_KEY",e.getMessage());
    }
}
项目:Bucket    文件BucketArgsTest.java   
@Test
public void testContainsAsyncNullKey() throws Exception {
    bucket = createCache();

    try {
        bucket.containsAsync(null,e.getMessage());
    }
}
项目:Bucket    文件BucketArgsTest.java   
@Test
public void testRemoveAsyncNullKey() throws Exception {
    bucket = createCache();

    try {
        bucket.removeAsync(null,e.getMessage());
    }
}
项目:Bucket    文件BucketArgsTest.java   
@Test
public void testGetRxKey() throws Exception {
    bucket = createCache();

    try {
        bucket.getRx(null,e.getMessage());
    }
}
项目:Bucket    文件BucketArgsTest.java   
@Test
public void testGetRxnullType() throws Exception {
    bucket = createCache();

    try {
        bucket.getRx("TEST_KEY",e.getMessage());
    }
}
项目:Bucket    文件BucketArgsTest.java   
@Test
public void testPutRxnullKey() throws Exception {
    bucket = createCache();

    try {
        bucket.putRx(null,e.getMessage());
    }
}
项目:Bucket    文件BucketArgsTest.java   
@Test
public void testPutRxnullObject() throws Exception {
    bucket = createCache();

    try {
        bucket.putRx("TEST_KEY",e.getMessage());
    }
}
项目:Bucket    文件BucketArgsTest.java   
@Test
public void testContainsRxnullKey() throws Exception {
    bucket = createCache();

    try {
        bucket.containsRx(null);
        fail("Should throw an exception");
    } catch (Exception e) {
        assertthat(e,e.getMessage());
    }
}
项目:Bucket    文件BucketArgsTest.java   
@Test
public void testRemoveRxnullKey() throws Exception {
    bucket = createCache();

    try {
        bucket.removeRx(null);
        fail("Should throw an exception");
    } catch (Exception e) {
        assertthat(e,e.getMessage());
    }
}
项目:samBox    文件PDDocumentWriterTest.java   
@Test
public void writeBodyAsync() throws Exception
{
    PDDocument document = mock(PDDocument.class);
    COSDocument cosDoc = mock(COSDocument.class);
    FileTrailer trailer = new FileTrailer();
    when(document.getDocument()).thenReturn(cosDoc);
    when(cosDoc.getTrailer()).thenReturn(trailer);
    ArgumentCaptor<PDFBodyWriter> bodyWriter = ArgumentCaptor.forClass(PDFBodyWriter.class);
    victim.write(document);
    verify(cosDoc).accept(bodyWriter.capture());
    assertthat(bodyWriter.getValue().objectsWriter,new InstanceOf(AsyncPDFBodyObjectsWriter.class));
}
项目:Rando-android    文件UserFetchResultListenerTest.java   
@Test
public void testFetchUserInRandosParsing() throws Exception {
    OnFetchUser onFetchUseMock = spy(new OnFetchUserAssertions());
    new UserFetchResultListener(context,onFetchUseMock).onResponse(APITestHelper.getUserFetchJSONObject());
    verify(onFetchUseMock,times(1)).onFetch((User) argThat(new InstanceOf(User.class)));
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。