示例#1
0
  /** Only submit one of two intents because one is too new. */
  @Test
  public void skipPoll() {
    IntentStoreDelegate mockDelegate =
        new IntentStoreDelegate() {
          @Override
          public void process(IntentData intentData) {
            intentData.setState(CORRUPT);
            store.write(intentData);
          }

          @Override
          public void notify(IntentEvent event) {}
        };
    store.setDelegate(mockDelegate);

    Intent intent = new MockIntent(1L);
    IntentData data = new IntentData(intent, INSTALL_REQ, null);
    store.addPending(data);

    Intent intent2 = new MockIntent(2L);
    Timestamp version = new SystemClockTimestamp(1L);
    data = new IntentData(intent2, INSTALL_REQ, version);
    store.addPending(data);

    cleanup.run();
    assertEquals("Expect number of submits incorrect", 1, service.submitCounter());
  }
示例#2
0
  @Before
  public void setUp() {
    service = new MockIntentService();
    store = new SimpleIntentStore();
    cleanup = new IntentCleanup();
    idGenerator = new MockIdGenerator();

    cleanup.cfgService = new ComponentConfigAdapter();
    cleanup.service = service;
    cleanup.store = store;
    cleanup.period = 10;
    cleanup.retryThreshold = 3;
    cleanup.activate();

    assertTrue("store should be empty", Sets.newHashSet(cleanup.store.getIntents()).isEmpty());

    Intent.bindIdGenerator(idGenerator);
  }
示例#3
0
  @After
  public void tearDown() {
    cleanup.deactivate();

    Intent.unbindIdGenerator(idGenerator);
  }