Java 类android.test.suitebuilder.annotation.Suppress 实例源码

项目:core-doppl    文件:DatabaseLockTest.java   
@Suppress
public void testLockFairness() {
    startDatabaseFairnessThread();
    int previous = 0;
    for (int i = 0; i < NUM_ITERATIONS; i++) { 
        mDatabase.beginTransaction();
        int val = mCounter.get();
        if (i == 0) {
            previous = val - i;
        }
        assertTrue(previous == (val - i));
        try {
            Thread.currentThread().sleep(SLEEP_TIME); 
        } catch (InterruptedException e) {
            // ignore
        }
        mDatabase.endTransaction();
    }
}
项目:core-doppl    文件:DatabaseLockTest.java   
@Suppress
public void testLockLatency() {
    startDatabaseLatencyThread();
    long sumTime = 0;
    long maxTime = 0;
    for (int i = 0; i < NUM_ITERATIONS; i++) { 
        long startTime = System.currentTimeMillis();
        mDatabase.beginTransaction();
        long endTime = System.currentTimeMillis();
        long elapsedTime = endTime - startTime;
        if (maxTime < elapsedTime) {
            maxTime = elapsedTime;
        }
        sumTime += elapsedTime;
        try {
            Thread.sleep(SLEEP_TIME); 
        } catch (InterruptedException e) {
            // ignore
        }   
        mDatabase.endTransaction();
    }
    long averageTime = sumTime/NUM_ITERATIONS;
    Log.i("DatabaseLockLatency", "AverageTime: " + averageTime);
    Log.i("DatabaseLockLatency", "MaxTime: " + maxTime);
    assertTrue( (averageTime - SLEEP_TIME) <= MAX_ALLOWED_LATENCY_TIME);
}
项目:sqlite-android    文件:DatabaseLocaleTest.java   
@Suppress // not supporting localized collators
@MediumTest
public void testLocaleenUS() throws Exception {
    insertStrings();
    Log.i("LocaleTest", "about to call setLocale en_US");
    mDatabase.setLocale(new Locale("en", "US"));
    String[] results;
    results = query("SELECT data FROM test ORDER BY data COLLATE LOCALIZED ASC");

    // The database code currently uses PRIMARY collation strength,
    // meaning that all versions of a character compare equal (regardless
    // of case or accents), leaving the "cote" flavors in database order.
    MoreAsserts.assertEquals(results, new String[] {
            STRINGS[4],  // "boy"
            STRINGS[0],  // sundry forms of "cote"
            STRINGS[1],
            STRINGS[2],
            STRINGS[3],
            STRINGS[6],  // "COTE"
            STRINGS[5],  // "dog"
    });
}
项目:bean-sdk-android    文件:TestBeanAdvanced.java   
@Suppress
public void testFastSerialMessages() throws Exception {
    int times = 100;
    final CountDownLatch testCompletionLatch = new CountDownLatch(times);
    Bean bean = discoverBean();
    synchronousConnect(bean);
    for (int i = 0; i < times; i ++) {
        bean.readLed(new Callback<LedColor>() {
            @Override
            public void onResult(LedColor result) {
                testCompletionLatch.countDown();
            }
        });
    }
    testCompletionLatch.await(120, TimeUnit.SECONDS);
    synchronousDisconnect(bean);
}
项目:android-downloadprovider    文件:PublicApiFunctionalTest.java   
@Suppress
public void testExtremelyLarge() throws Exception {
    // NOTE: suppressed since this takes several minutes to run
    final long length = 3 * GB_IN_BYTES;
    final InputStream body = new FakeInputStream(length);

    enqueueResponse(new MockResponse().setResponseCode(HTTP_OK).setBody(body, length)
            .setHeader("Content-type", "text/plain")
            .setSocketPolicy(SocketPolicy.DISCONNECT_AT_END));

    final Download download = enqueueRequest(getRequest()
            .setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "extreme.bin"));
    download.runUntilStatus(DownloadManager.STATUS_SUCCESSFUL, 10 * DateUtils.MINUTE_IN_MILLIS);

    assertEquals(length, download.getLongField(DownloadManager.COLUMN_TOTAL_SIZE_BYTES));
    assertEquals(length, download.getLongField(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR));
}
项目:mobile-connector-sdk-android    文件:ManualConfigUtil_IT.java   
@Suppress
    public void testGetDatabaseMeta() throws Exception {
        final CountDownLatch signal = new CountDownLatch(1);

        XMLAPI getListMetaDataXml = XMLAPI.builder().operation(XMLAPIOperation.GET_LIST_META_DATA)
                .listId(getEngageConfigManager().engageListId())
//                .listId("29392")
                .build();
        getXMLAPIManager().postXMLAPI(getListMetaDataXml, new XMLAPIResponseHandler() {
            @Override
            public void onSuccess(EngageResponseXML response) {
                // test only exists so you can manually check this xml value
                String xml = response.getXml();
                Log.i(TAG, xml);

                signal.countDown();
            }

            @Override
            public void onFailure(XMLAPIResponseFailure exception) {
                fail();
            }
        });

        signal.await(5, TimeUnit.SECONDS);
    }
项目:podio-android    文件:BasicPodioFilterTest.java   
@Suppress()
public void testAddPathSegments() {
    Uri reference = Uri.parse("scheme://authority/path1/path2");
    Filter filter = new EmptyProvider.Path();

    try {
        filter.addPathSegment(null);
        fail("should have thrown IllegalArgumentException");
    } catch (IllegalArgumentException e) {
    }

    filter.addPathSegment("path1");
    filter.addPathSegment("path2");

    Uri target = filter.buildUri("scheme", "authority");
    assertNotNull(target);
    assertEquals(reference, target);
}
项目:Anki-Android    文件:ImportTest.java   
@Suppress
public void testCsv2() throws  IOException, ConfirmModSchemaException {
    Collection deck = Shared.getEmptyCol(getContext());
    Models mm = deck.getModels();
    JSONObject m = mm.current();
    JSONObject f = mm.newField("Three");
    mm.addField(m, f);
    mm.save(m);
    Note n = deck.newNote();
    n.setItem("Front", "1");
    n.setItem("Back", "2");
    n.setItem("Three", "3");
    deck.addNote(n);
    // an update with unmapped fields should not clobber those fields
    String file = Shared.getTestFilePath(getContext(), "text-update.txt");
    TextImporter i = new TextImporter(deck, file);
    i.initMapping();
    i.run();
    n.load();
    assertTrue(n.getItem("Front").equals("1"));
    assertTrue(n.getItem("Back").equals("x"));
    assertTrue(n.getItem("Three").equals("3"));
    deck.close();
}
项目:RoviRunner    文件:MediaPlayerPresenterTest.java   
@Suppress // TODO [2013-09-29 KW] just trying some stuff out, there must be an easier way to do this...
public void testPlayRandomSong() throws IllegalArgumentException, IllegalStateException, IOException
{
    AssetFileDescriptor afd = Mockito.mock( AssetFileDescriptor.class );
    Mockito.doReturn( afd ).when( m_presenter ).getRandomSong();
    Mockito.doNothing().when( m_player ).prepareAsync();

    m_presenter.playSong( null );

    Mockito.verify( m_player )
           .setDataSource( (FileDescriptor)Mockito.any(),
                           Mockito.anyLong(),
                           Mockito.anyLong() );
    Mockito.verify( m_player )
           .prepareAsync();

    Mockito.verify( m_view )
           .setArtistText( Mockito.anyString() );
    Mockito.verify( m_view )
           .setSongText( Mockito.anyString() );
}
项目:NickleAndDimed    文件:EventDetailsTest.java   
@SmallTest
@Suppress
public void testMenuShare() {
    // When
    getActivity();
    onView(withId(R.id.action_share)).perform(click());

    // Then
    // TODO: execute is called on mock but test still fails
    verify(shareAction, times(1)).execute(any(EventDetails.class));
}
项目:Tabdilak    文件:KonvertorTests.java   
@Suppress
public void testIfScreenRotationHandledCorrectly() throws Exception {

    requestFocus(mTeNumber);
    sendKeys("1 0 0");
    requestFocus(mBtnConvert);
    sendKeys(KeyEvent.KEYCODE_ENTER);
    String expectedTvValue = mTvResult.getText().toString();
    String expectedTeValue = mTeNumber.getText().toString();

    for(int i=0; i<=10; i++) {
        if(i % 2 == 0) {
            mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

        } else {
            mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
        //FIXME :: Fix this problem.
        /*
         * The problem here is that after screen rotation mActivity and all of our fields still refer to the old activity that we had and so assertEquals
         * methods wrongly return true. So first we must renew our mActivity and all other references. The following solution does not solve our problem
         * But currently I do not have enough time to solve this issue so I @Suppress it for now. For more information refer to:
         * http://stackoverflow.com/questions/10982370/instrumentation-test-for-android-how-to-receive-new-activity-after-orientation
         * For now I use Instrumentation.callActivityOnSaveInstanceState.  
         */
        mActivity.finish();
        setActivity(null);
        setUp();
        getInstrumentation().waitForIdleSync();
        assertEquals("TeNumber value is not valid after rotation", expectedTeValue, mTeNumber.getText().toString());
        assertEquals("TvResult value is not valid after rotation",expectedTvValue, mTvResult.getText().toString());
    }   
}
项目:planyourexchange    文件:SensitiveDataUtilsTest.java   
/**
 * This method is used to generated encrypted keys and hashes
 * with the secret password and salt above
 * @throws UnsupportedEncodingException
 * @throws GeneralSecurityException
 */
@Suppress
public void testEncryptGenerate() throws UnsupportedEncodingException, GeneralSecurityException {
    Map<String,String> map = new HashMap<>();

    map.put("AdUnitId","?");
    map.put("TestDeviceId","?");
    map.put("service.url","?");
    map.put("service.userName","?");
    map.put("service.password","?");
    map.put("AnalyticsId", "?");
    map.put("test","test");

    StringBuilder stringBuilder = new StringBuilder();

    for (Map.Entry<String,String> entry : map.entrySet()) {
        stringBuilder.append(entry.getKey())
                .append(" = ")
                .append(sensitiveDataUtils.hashKey(entry.getKey()))
                .append("\n")
                .append(entry.getValue())
                .append(" = ")
                .append(sensitiveDataUtils.encrypt(entry.getValue()))
                .append("\n");
    }

    fail(stringBuilder.toString());
}
项目:TravelTracker    文件:ElasticSearchHelperTest.java   
@Suppress
public void testAddClaims() throws Exception{
    ArrayList<Claim> claims = new ArrayList<Claim>();
    claims.add(claim1);
    claims.add(claim2);

    es.saveDocuments(claims);
    Thread.sleep(1000);
    assertEquals(claims.size(), es.getClaims(user1.getUUID()).size());

    cleanUp(claims);
    assertEquals(0, es.getClaims(user1.getUUID()).size());
}
项目:TravelTracker    文件:ElasticSearchHelperTest.java   
@Suppress
public void testAddExpense() throws Exception{
    ArrayList<Item> items = new ArrayList<Item>();
    items.add(DataSourceUtils.addEmptyItem(claim1, ds));
    items.add(DataSourceUtils.addEmptyItem(claim1, ds));

    es.saveDocuments(items);
    Thread.sleep(1000);
    assertEquals(items.size(), es.getExpenses(claim1.getUUID()).size());

    cleanUp(items);
    assertEquals(0, es.getExpenses(claim1.getUUID()).size());
}
项目:TravelTracker    文件:ElasticSearchHelperTest.java   
@Suppress
public void testAAddUser() throws Exception {
    ArrayList<User> users = new ArrayList<User>();
    users.add(user1);


    es.saveDocuments(users);
    Thread.sleep(1000);
    assertTrue(user1.getUUID().equals(es.getUser(user1.getUserName()).getUUID()));

    cleanUp(users);
    //TODO test cleanup successful
}
项目:TravelTracker    文件:ElasticSearchHelperTest.java   
@Suppress
public void testAddTag() throws Exception {
    ArrayList<Tag> tags = new ArrayList<Tag>();
    tags.add(DataSourceUtils.addEmptyTag(user1, ds));

    es.saveDocuments(tags);
    Thread.sleep(1000);
    assertEquals(tags.size(), es.getTags(user1.getUUID()).size());

    cleanUp(tags);
    assertEquals(0, es.getTags(user1.getUUID()).size());
}
项目:TravelTracker    文件:ElasticSearchHelperTest.java   
@Suppress
public void testGetAllExpenses() throws Exception{
    ArrayList<Item> items = new ArrayList<Item>();
    items.add(DataSourceUtils.addEmptyItem(claim1, ds));
    items.add(DataSourceUtils.addEmptyItem(claim1, ds));

    es.saveDocuments(items);
    Thread.sleep(1000);
    assertEquals(items.size(), es.getAllItems().size());

    cleanUp(items);
    assertEquals(0, es.getAllItems().size());
}
项目:TravelTracker    文件:ElasticSearchHelperTest.java   
@Suppress
public void testGetAllClaims() throws Exception {
    ArrayList<Claim> claims = new ArrayList<Claim>();
    claims.add(claim1);
    claims.add(claim2);

    es.saveDocuments(claims);
    Thread.sleep(1000);
    assertEquals(claims.size(), es.getAllClaims().size());

    cleanUp(claims);
    assertEquals(0, es.getAllClaims().size());
}
项目:TravelTracker    文件:ElasticSearchHelperTest.java   
@Suppress
public void testGetAllTags() throws Exception {
    ArrayList<Tag> tags = new ArrayList<Tag>();
    tags.add(DataSourceUtils.addEmptyTag(user1, ds));

    es.saveDocuments(tags);
    Thread.sleep(1000);
    assertEquals(tags.size(), es.getAllTags().size());

    cleanUp(tags);
    assertEquals(0, es.getAllTags().size());
}
项目:TravelTracker    文件:ElasticSearchHelperTest.java   
@Suppress
public void testGetAllUsers() throws Exception {
    ArrayList<User> users = new ArrayList<User>();
    users.add(user1);


    es.saveDocuments(users);
    Thread.sleep(1000);
    assertEquals(1, es.getAllUsers().size());

    cleanUp(users);
    assertEquals(0, es.getAllUsers().size());
}
项目:TravelTracker    文件:ElasticSearchHelperTest.java   
@Suppress
public void testGetUserByID() throws Exception {
    ArrayList<User> users = new ArrayList<User>();
    users.add(user1);


    es.saveDocuments(users);
    Thread.sleep(1000);
    assertTrue(user1.getUUID().equals(es.getUser(user1.getUUID()).getUUID()));

    cleanUp(users);
}
项目:mobile-connector-sdk-android    文件:ManualConfigUtil_IT.java   
@Suppress
public void testGetLists() throws Exception {
    final CountDownLatch signal = new CountDownLatch(1);

    XMLAPI getLists = XMLAPI.builder()
            .operation(XMLAPIOperation.GET_LISTS)
            .param(XMLAPIElement.VISIBILITY, 0)
            .param(XMLAPIElement.LIST_TYPE, XMLAPIListType.DATABASES.toString())
            .build();
    getXMLAPIManager().postXMLAPI(getLists, new XMLAPIResponseHandler() {
        @Override
        public void onSuccess(EngageResponseXML response) {
            // test only exists so you can manually check this xml value
            String xml = response.getXml();
            Log.i(TAG, xml);

            if (!response.isSuccess()) {
                fail(response.getFaultString());
            }

            signal.countDown();
        }

        @Override
        public void onFailure(XMLAPIResponseFailure exception) {
            fail();
        }
    });

    signal.await(5, TimeUnit.SECONDS);
}
项目:podio-android    文件:ClientProviderTest.java   
@Suppress
public void testAuthenticateWithUserCredentials() {
    MockRestClient mockClient = new MockRestClient(getInstrumentation().getTargetContext());
    ClientProvider provider = new ClientProvider();
    provider.setClient(mockClient);

    provider.authenticateWithUserCredentials("USERNAME", "PASSWORD").withResultListener(resultListener);

    Mockito.verify(resultListener, Mockito.timeout(1000).times(0)).onRequestPerformed(null);

    assertEquals(Uri.parse("/oauth/token?grant_type=password&username=USERNAME&password=PASSWORD"), mockClient.uri);
}
项目:podio-android    文件:ClientProviderTest.java   
@Suppress
public void testAuthenticateWithAppCredentials() {
    MockRestClient mockClient = new MockRestClient(getInstrumentation().getTargetContext());
    ClientProvider provider = new ClientProvider();
    provider.setClient(mockClient);

    provider.authenticateWithAppCredentials("APPID", "APPTOKEN").withResultListener(resultListener);

    Mockito.verify(resultListener, Mockito.timeout(100).times(0)).onRequestPerformed(null);
    assertEquals(Uri.parse("/oauth/token?grant_type=app&app_id=APPID&app_token=APPTOKEN"), mockClient.uri);
}
项目:BillSplitter    文件:EventDetailsTest.java   
@SmallTest
@Suppress
public void testMenuShare() {
    // When
    getActivity();
    onView(withId(R.id.action_share)).perform(click());

    // Then
    // TODO: execute is called on mock but test still fails
    verify(shareAction, times(1)).execute(any(EventDetails.class));
}
项目:osmdroid    文件:TileSystemMathTest.java   
@Suppress // this test is here to test timings for issue 512
public void test_divide() {
    long start = System.currentTimeMillis();
    double delta = 0.0;
    for (int i=0; i<10000000; i++){
        delta = i/1E6;
    }
    long diff = System.currentTimeMillis() - start;
    assertEquals("fail", 0, diff);
}
项目:osmdroid    文件:TileSystemMathTest.java   
@Suppress // this test is here to test timings for issue 512
public void test_multiply() {
    long start = System.currentTimeMillis();
    double delta = 0.0;
    for (int i=0; i<10000000; i++){
        delta = i*1E-6;
    }
    long diff = System.currentTimeMillis() - start;
    assertEquals("fail", 0, diff);
}
项目:Anki-Android    文件:ImportTest.java   
@Suppress
public void testCsv() throws IOException {
    Collection deck = Shared.getEmptyCol(getContext());
    String file = Shared.getTestFilePath(getContext(), "text-2fields.txt");
    TextImporter i = new TextImporter(deck, file);
    i.initMapping();
    i.run();
    // four problems - too many & too few fields, a missing front, and a
    // duplicate entry
    assertTrue(i.getLog().size() == 5);
    assertTrue(i.getTotal() == 5);
    // if we run the import again, it should update instead
    i.run();
    assertTrue(i.getLog().size() == 10);
    assertTrue(i.getTotal() == 5);
    // but importing should not clobber tags if they're unmapped
    Note n = deck.getNote(deck.getDb().queryLongScalar("select id from notes"));
    n.addTag("test");
    n.flush();
    i.run();
    n.load();
    assertTrue((n.getTags().size() == 1) && (n.getTags().get(0) == "test"));
    // if add-only mode, count will be 0
    i.setImportMode(1);
    i.run();
    assertTrue(i.getTotal() == 0);
    // and if dupes mode, will reimport everything
    assertTrue(deck.cardCount() == 5);
    i.setImportMode(2);
    i.run();
    // includes repeated field
    assertTrue(i.getTotal() == 6);
    assertTrue(deck.cardCount() == 11);
    deck.close();
}
项目:crosswalk-cordova-android    文件:CordovaResourceApiTest.java   
@Suppress
public void testValidContentUri() throws IOException
{
    Uri contentUri = createTestImageContentUri();
    File localFile = resourceApi.mapUriToFile(contentUri);
    assertNotNull(localFile);
    performApiTest(contentUri, "image/jpeg", localFile, true, true);
}
项目:crosswalk-cordova-android    文件:ErrorUrlTest.java   
@Suppress
public void testUrl() throws Throwable
{
  sleep();
  runTestOnUiThread(new Runnable() {
      public void run()
      {
          String good_url = "file:///android_asset/www/htmlnotfound/error.html";
          String url = testView.getUrl();
          assertNotNull(url);
          assertEquals(good_url, url);

      }
  });
}
项目:sqlite-android    文件:DatabaseGeneralTest.java   
/**
 * Tests international matching issues for the PHONE_NUMBERS_EQUAL function.
 * 
 * @throws Exception
 */
@Suppress // PHONE_NUMBERS_EQUAL not supported
@SmallTest
public void testPhoneNumbersEqualInternationl() throws Exception {
    assertPhoneNumberEqual("1", "1");
    assertPhoneNumberEqual("123123", "123123");
    assertPhoneNumberNotEqual("123123", "923123");
    assertPhoneNumberNotEqual("123123", "123129");
    assertPhoneNumberNotEqual("123123", "1231234");
    assertPhoneNumberNotEqual("123123", "0123123", false);
    assertPhoneNumberNotEqual("123123", "0123123", true);
    assertPhoneNumberEqual("650-253-0000", "6502530000");
    assertPhoneNumberEqual("650-253-0000", "650 253 0000");
    assertPhoneNumberEqual("650 253 0000", "6502530000");
    assertPhoneNumberEqual("+1 650-253-0000", "6502530000");
    assertPhoneNumberEqual("001 650-253-0000", "6502530000");
    assertPhoneNumberEqual("0111 650-253-0000", "6502530000");

    // Russian trunk digit
    assertPhoneNumberEqual("+79161234567", "89161234567");

    // French trunk digit
    assertPhoneNumberEqual("+33123456789", "0123456789");

    // Trunk digit for city codes in the Netherlands
    assertPhoneNumberEqual("+31771234567", "0771234567");

    // Test broken caller ID seen on call from Thailand to the US
    assertPhoneNumberEqual("+66811234567", "166811234567");

    // Test the same in-country number with different country codes
    assertPhoneNumberNotEqual("+33123456789", "+1123456789");

    // Test one number with country code and the other without
    assertPhoneNumberEqual("5125551212", "+15125551212");

    // Test two NANP numbers that only differ in the area code
    assertPhoneNumberNotEqual("5125551212", "6505551212");

    // Japanese phone numbers
    assertPhoneNumberEqual("090-1234-5678", "+819012345678");
    assertPhoneNumberEqual("090(1234)5678", "+819012345678");
    assertPhoneNumberEqual("090-1234-5678", "+81-90-1234-5678");

    // Equador
    assertPhoneNumberEqual("+593(800)123-1234", "8001231234");
    assertPhoneNumberEqual("+593-2-1234-123", "21234123");

    // Two continuous 0 at the beginning of the phone string should not be
    // treated as trunk prefix in the strict comparation.
    assertPhoneNumberEqual("008001231234", "8001231234", false);
    assertPhoneNumberNotEqual("008001231234", "8001231234", true);

    // Confirm that the bug found before does not re-appear in the strict compalation
    assertPhoneNumberEqual("080-1234-5678", "+819012345678", false);
    assertPhoneNumberNotEqual("080-1234-5678", "+819012345678", true);
}
项目:Tabdilak    文件:KonvertorTests.java   
@Suppress
public void testTeNumberhasHint() {
    String hint = mTeNumber.getHint().toString();
    assertNotNull(hint);
    assertEquals(com.mevelopers.tabdilak.R.string.TeNumberDefaultText, hint);
}
项目:Tabdilak    文件:KonvertorTests.java   
@Suppress
public void testSupportedScreenSizes() {
    //Tests to see if we have <support-screens> tags in our manifest or not?!
    fail("<supports-screens> not implemented yet!");
}
项目:Tabdilak    文件:KonvertorTests.java   
@Suppress
public void testTvResultFontSize() {
    final float expected = 54.0f;
    assertEquals(expected, mTvResult.getTextSize());

}
项目:bean-sdk-android    文件:TestBeanAdvanced.java   
@Suppress
public void testBeanSketchUpload() throws Exception {
    final Bean bean = discoverBean();
    synchronousConnect(bean);
    String hwVersion = getDeviceInformation(bean).hardwareVersion();

    String hexPath = null;
    for (String filename : filesInAssetDir(getContext(), "bean_fw_advanced_callbacks")) {
        if (FilenameUtils.getExtension(filename).equals("hex")) {
            String[] pieces = FilenameUtils.getBaseName(filename).split("_");
            String hexHW = pieces[pieces.length - 1];
            if (hexHW.equals(hwVersion)) {
                hexPath = FilenameUtils.concat("bean_fw_advanced_callbacks", filename);
                break;
            }
        }
    }

    assertThat(hexPath).isNotNull();
    InputStream imageStream  = getContext().getAssets().open(hexPath);
    StringWriter writer = new StringWriter();
    IOUtils.copy(imageStream, writer);

    String timestamp = Long.toString(System.currentTimeMillis() / 1000);
    SketchHex sketchHex = SketchHex.create(timestamp, writer.toString());

    final CountDownLatch sketchLatch = new CountDownLatch(1);
    Callback<UploadProgress> onProgress = new Callback<UploadProgress>() {
        @Override
        public void onResult(UploadProgress result) {
            System.out.println("On Result: " + result);
        }
    };

    Runnable onComplete = new Runnable() {
        @Override
        public void run() {
            System.out.println("all done!");
            sketchLatch.countDown();
        }
    };

    bean.programWithSketch(sketchHex, onProgress, onComplete);
    sketchLatch.await(120, TimeUnit.SECONDS);

    SketchMetadata metadata = getSketchMetadata(bean);
    if (!metadata.hexName().equals(timestamp)) {
        fail(String.format("Unexpected Sketch name: %s != %s", metadata.hexName(), timestamp));
    }
}
项目:bean-sdk-android    文件:TestBeanAdvanced.java   
@Suppress
public void testConnectMultipleBeansWithSameListener() throws InterruptedException {
    /* This test requires at least 3 beans nearby to pass */

    final List<Bean> beans = discoverBeans(3);
    final Bean beanA = beans.get(0);
    final Bean beanB = beans.get(1);
    final Bean beanC = beans.get(2);
    final CountDownLatch connectionLatch = new CountDownLatch(2);
    final HashMap<String, Boolean> connectionState = new HashMap<>();
    connectionState.put("bean_a_connected", false);
    connectionState.put("bean_b_connected", false);

    BeanListener beanListener = new BeanListener() {

        @Override
        public void onConnected() {
            if (connectionState.get("bean_a_connected") == false) {
                if (beanA.isConnected()) {
                    connectionState.put("bean_a_connected", true);
                    connectionLatch.countDown();
                }
            }

            if (connectionState.get("bean_b_connected") == false) {
                if (beanB.isConnected()) {
                    connectionState.put("bean_b_connected", true);
                    connectionLatch.countDown();
                }
            }

            if (beanC.isConnected()) {
                fail("Bean C not suppose to connect!");
            }
        }

        @Override
        public void onConnectionFailed() {
            fail("Connection failed!");
        }

        @Override
        public void onDisconnected() {
        }

        @Override
        public void onSerialMessageReceived(byte[] data) {
        }

        @Override
        public void onScratchValueChanged(ScratchBank bank, byte[] value) {
        }

        @Override
        public void onError(BeanError error) {
            fail(error.toString());
        }

        @Override
        public void onReadRemoteRssi(final int rssi) {
            System.out.println("onReadRemoteRssi: " + rssi);
        }
    };

    beanA.connect(getContext(), beanListener);
    beanB.connect(getContext(), beanListener);
    connectionLatch.await(60, TimeUnit.SECONDS);
    // No need to assert anything, implicit success based on connection latch
}
项目:mobile-connector-sdk-android    文件:ManualConfigUtil_IT.java   
@Suppress
    public void testCreateDatabaseColumn() throws Exception {
        final CountDownLatch signal = new CountDownLatch(1);

        // String columnName = "Custom Integration Test Id";
        // String columnName = "Mobile User Id";
        // String columnName = getEngageConfigManager().mergedRecipientIdColumnName();
//        String columnName = getEngageConfigManager().mergedDateColumnName();
        String columnName = "Custom Integration Test Id 2";

        int columnType = XMLAPIColumnType.TEXT_COLUMN.code();
//        int columnType = XMLAPIColumnType.TIMESTAMP.value();

        XMLAPI addListColumnXml = XMLAPI.builder()
                .operation(XMLAPIOperation.ADD_LIST_COLUMN)
                .listId(getEngageConfigManager().engageListId())
                .param(XMLAPIElement.COLUMN_NAME, columnName)
                .param(XMLAPIElement.COLUMN_TYPE, columnType)
                 //  .param(XMLAPIElement.DEFAULT, "")
                .build();

        getXMLAPIManager().postXMLAPI(addListColumnXml, new XMLAPIResponseHandler() {
            @Override
            public void onSuccess(EngageResponseXML response) {
                String xml = response.getXml();
                Log.i(TAG, xml);

                if (!response.isSuccess()) {
                    fail(response.getFaultString());
                }

                signal.countDown();
            }

            @Override
            public void onFailure(XMLAPIResponseFailure exception) {
                fail();
            }
        });

        signal.await(10, TimeUnit.SECONDS);
    }
项目:mobile-connector-sdk-android    文件:ManualConfigUtil_IT.java   
@Suppress
public void testCreateAuditRecordTable() throws Exception {
    final CountDownLatch signal = new CountDownLatch(1);

    XMLAPI addListColumnXml = new XMLAPI(XMLAPIOperation.CREATE_TABLE) {
        // one way to hack the xml object ...you really shouldn't do this though... its not guaranteed to work forever
        @Override
        public String envelope() {
            return "<Envelope>\n" +
                    "\t<Body>\n" +
                    "\t\t<CreateTable>\n" +
                    "\t\t\t<TABLE_NAME>Audit Record Test</TABLE_NAME>\n" +
                    "\t\t\t<COLUMNS>\n" +
                    "\t\t\t\t<COLUMN>\n" +
                    "\t\t\t\t\t<NAME>Audit Record Id</NAME>\n" +
                    "\t\t\t\t\t<TYPE>TEXT</TYPE>\n" +
                    "\t\t\t\t\t<IS_REQUIRED>true</IS_REQUIRED>\n" +
                    "\t\t\t\t\t<KEY_COLUMN>true</KEY_COLUMN>\n" +
                    "\t\t\t\t</COLUMN>\n" +
                    "\t\t\t\t<COLUMN>\n" +
                    "\t\t\t\t\t<NAME>Old Recipient Id</NAME>\n" +
                    "\t\t\t\t\t<TYPE>TEXT</TYPE>\n" +
                    "\t\t\t\t\t<IS_REQUIRED>true</IS_REQUIRED>\n" +
                    "\t\t\t\t</COLUMN>\n" +
                    "\t\t\t\t<COLUMN>\n" +
                    "\t\t\t\t\t<NAME>New Recipient Id</NAME>\n" +
                    "\t\t\t\t\t<TYPE>TEXT</TYPE>\n" +
                    "\t\t\t\t\t<IS_REQUIRED>true</IS_REQUIRED>\n" +
                    "\t\t\t\t</COLUMN>\n" +
                    "\t\t\t\t<COLUMN>\n" +
                    "\t\t\t\t\t<NAME>Create Date</NAME>\n" +
                    "\t\t\t\t\t<TYPE>DATE_TIME</TYPE>\n" +
                    "\t\t\t\t\t<IS_REQUIRED>true</IS_REQUIRED>\n" +
                    "\t\t\t\t</COLUMN>\n" +
                    "\t\t\t</COLUMNS>\n" +
                    "\t\t</CreateTable>\n" +
                    "\t</Body>\n" +
                    "</Envelope>";
        }
    };

    getXMLAPIManager().postXMLAPI(addListColumnXml, new XMLAPIResponseHandler() {
        @Override
        public void onSuccess(EngageResponseXML response) {
            String xml = response.getXml();
            Log.i(TAG, xml);

            if (!response.isSuccess()) {
                fail(response.getFaultString());
            }

            signal.countDown();
        }

        @Override
        public void onFailure(XMLAPIResponseFailure exception) {
            fail();
        }
    });

    signal.await(10, TimeUnit.SECONDS);
}
项目:Anki-Android    文件:MediaTest.java   
@Suppress
private List<String> added(Collection d) {
    return d.getMedia().getDb().queryColumn(String.class, "select fname from media where csum is not null", 0);
}
项目:Anki-Android    文件:MediaTest.java   
@Suppress
private List<String> removed(Collection d) {
    return d.getMedia().getDb().queryColumn(String.class, "select fname from media where csum is null", 0);
}