コード例 #1
0
  @Before
  public void setUp() throws Exception {
    simplePDP = SimplePDPFactory.getSimplePDP();
    pdp =
        new PolicyDecisionPointImpl(
            dataMock,
            requestGeneratorMock,
            documentAccessorMock,
            documentXmlConverterMock,
            auditServiceMock);

    doNothing()
        .when(auditServiceMock)
        .audit(
            anyObject(),
            anyString(),
            isA(AuditVerb.class),
            anyString(),
            anyMapOf(PredicateKey.class, String.class));

    try {
      InputStream is = new FileInputStream(policyFile);
      policy = PolicyMarshaller.unmarshal(is);
    } catch (Exception e) {
      LOGGER.error(e.getMessage(), e);
    }
    InputStream requestis = null;
    try {
      requestis = new FileInputStream(requestFile);
      request = RequestMarshaller.unmarshal(requestis);
    } catch (Exception e) {
      LOGGER.error(e.getMessage(), e);
    }
    policies = new LinkedList<Evaluatable>();
    policies.add(policy);
  }
コード例 #2
0
ファイル: OperationTake.java プロジェクト: alexo/RxJava
    @Test
    public void testUnsubscribeAfterTake() {
      Subscription s = mock(Subscription.class);
      TestObservable w = new TestObservable(s, "one", "two", "three");

      @SuppressWarnings("unchecked")
      Observer<String> aObserver = mock(Observer.class);
      Observable<String> take = Observable.create(take(w, 1));
      take.subscribe(aObserver);

      // wait for the Observable to complete
      try {
        w.t.join();
      } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
      }

      System.out.println("TestObservable thread finished");
      verify(aObserver, times(1)).onNext("one");
      verify(aObserver, never()).onNext("two");
      verify(aObserver, never()).onNext("three");
      verify(s, times(1)).unsubscribe();
    }