@Test
  public void parseTest() {

    System.setProperty("http.proxyHost", "myproxy");
    System.setProperty("http.proxyPort", "80");
    System.setProperty("http.nonProxyHosts", "127.0.0.1|localhost|*.company.com");

    {
      final List<Proxy> proxyList =
          ProxySelector.getDefault().select(URI.create("http://localhost:8080/confluence/xmlrpc"));

      Assert.assertThat(proxyList.isEmpty(), Is.is(false));
      Assert.assertThat(proxyList.size(), Is.is(1));

      final Proxy p = proxyList.get(0);

      System.out.printf("type=[%s] address=[%s]\n", p.type(), p.address());

      Assert.assertThat(p.type(), Is.is(Type.DIRECT));
      Assert.assertThat(p.address(), IsNull.nullValue());
    }

    {
      final List<Proxy> proxyList =
          ProxySelector.getDefault()
              .select(URI.create("http://my.company.com:8033/confluence/xmlrpc"));

      Assert.assertThat(proxyList.isEmpty(), Is.is(false));
      Assert.assertThat(proxyList.size(), Is.is(1));

      final Proxy p = proxyList.get(0);

      System.out.printf("type=[%s] address=[%s]\n", p.type(), p.address());

      Assert.assertThat(p.type(), Is.is(Type.DIRECT));
      Assert.assertThat(p.address(), IsNull.nullValue());
    }

    {
      final List<Proxy> proxyList =
          ProxySelector.getDefault().select(URI.create("http://www.google.com/confluence/xmlrpc"));

      Assert.assertThat(proxyList.isEmpty(), Is.is(false));
      Assert.assertThat(proxyList.size(), Is.is(1));

      final Proxy p = proxyList.get(0);

      System.out.printf("type=[%s] address=[%s]\n", p.type(), p.address());

      Assert.assertThat(p.type(), Is.is(Type.HTTP));
      Assert.assertThat(p.address(), IsNull.notNullValue());
    }
  }
Exemplo n.º 2
0
  @Test
  public void responseWithoutDescriptionsCanBeRoundTripped() {
    // Act:
    final ErrorResponse response =
        createRoundTrippedResponse(new ErrorResponse(new TimeInstant(54), null, 890));

    // Assert:
    Assert.assertThat(response.getTimeStamp(), IsEqual.equalTo(new TimeInstant(54)));
    Assert.assertThat(response.getError(), IsNull.nullValue());
    Assert.assertThat(response.getMessage(), IsNull.nullValue());
    Assert.assertThat(response.getStatus(), IsEqual.equalTo(890));
  }
Exemplo n.º 3
0
  @Test
  public void shouldParseMotechProperties() {
    MotechProperties motechProperties =
        (MotechProperties) reader.readFromFile("/motech-properties.json", MotechProperties.class);

    assertThat(motechProperties.size(), IsEqual.equalTo(14));
    assertThat(motechProperties.get("case_name"), IsEqual.equalTo("Pankaja"));
    assertThat(motechProperties.get("family_number"), IsEqual.equalTo(""));
    assertThat(motechProperties.get("external_id"), IsNull.nullValue());
  }
 @Test
 public void ensureAPostCanHaveAValueNulled() throws IOException, ClassNotFoundException {
   Post tested = new Post().withAuthor(author).withText("ensureAPostCanHaveAValueNulled");
   tested = getPostService().create(tested);
   assertThat(tested.text, IsNull.notNullValue());
   tested.text = null;
   tested = getPostService().update(tested);
   // force reload from graph
   tested = ((IdBasedService<Post>) getPostService()).findById(tested.id);
   assertThat(tested.text, IsNull.nullValue());
 }
 @Test
 public void testFixture_SetterInjection() {
   MyCommandHandler commandHandler = new MyCommandHandler();
   commandHandler.setRepository(fixture.getRepository());
   fixture
       .registerAnnotatedCommandHandler(commandHandler)
       .given(new MyEvent("aggregateId", 1), new MyEvent("aggregateId", 2))
       .when(new TestCommand("aggregateId"))
       .expectReturnValue(IsNull.nullValue())
       .expectEvents(new MyEvent("aggregateId", 3));
 }
Exemplo n.º 6
0
  @Test
  public void canBeCreatedAroundUnknownHttpStatus() {
    // Arrange:
    final ErrorResponse response =
        new ErrorResponse(new TimeInstant(18), "exception message", -123);

    // Assert:
    Assert.assertThat(response.getTimeStamp(), IsEqual.equalTo(new TimeInstant(18)));
    Assert.assertThat(response.getError(), IsNull.nullValue());
    Assert.assertThat(response.getMessage(), IsEqual.equalTo("exception message"));
    Assert.assertThat(response.getStatus(), IsEqual.equalTo(-123));
  }
  @Test
  public void cannotReturnWalletAccountInClosedWallet() {
    // Arrange:
    final WalletAccount account = new WalletAccount();
    final TestContext context = new TestContext();
    context.originalWallet.addOtherAccount(account);

    // Act:
    context.walletServices.open(context.pair);
    context.walletServices.close(context.pair.getName());
    final WalletAccount resultAccount =
        context.walletServices.tryFindOpenAccount(account.getAddress());

    // Assert:
    Assert.assertThat(resultAccount, IsNull.nullValue());
  }
 @Test
 public void ensureDeletCascadesWell() {
   User other = new User().withId(2).withLogin("other login").withPassword("other password");
   long id = DELETABLE_POST;
   other.about = new Post(id, "a post about another user", 2, State.PUBLIC, other);
   getUserService().create(other);
   Post about = ((IdBasedService<Post>) getPostService()).findById(id);
   assertThat(about, IsNull.notNullValue());
   getUserService().delete(other);
   try {
     if (environment.getGraph() instanceof TransactionalGraph) {
       TransactionalGraph transactionalGraph = (TransactionalGraph) environment.getGraph();
       //				transactionalGraph.startTransaction();
     }
     about = ((IdBasedService<Post>) getPostService()).findById(id);
     assertThat(about, IsNull.nullValue());
   } catch (NoReturnableVertexException e) {
     // that exception is one of possible correct behaviours
   }
 }
Exemplo n.º 9
0
 /**
  * Test to show assertion using "org.junit.Assert.assertThat()" method<br>
  *
  * @see http ://junit.org/junit/javadoc/4.5/org/hamcrest/core/package-frame.html
  */
 @Test
 public void showAssertThat() {
   String localVar = null;
   // Assert True if "this.bean" object is a instance of "ProcessingBean"
   // class
   Assert.assertThat(this.bean, IsInstanceOf.instanceOf(ProcessingBean.class));
   // Assert True if at least one assert included in the "AnyOf" operator
   // is True
   Assert.assertThat(
       this.bean.getMessage(),
       AnyOf.anyOf(IsEqual.equalTo("Hello World !"), IsNot.not(IsEqual.equalTo("Hello World !"))));
   // Assert True if all assert included in the "AllOf" operator are True
   Assert.assertThat(
       this.bean.getMessage(),
       AllOf.allOf(IsEqual.equalTo("Hello World !"), Is.is("Hello World !")));
   // Assert True if "this.bean" is the same instance than
   // "this.bean.getInstance()"
   Assert.assertThat(this.bean, IsSame.sameInstance(this.bean.getInstance()));
   // Assert True if "localVar" is null
   Assert.assertThat(localVar, IsNull.nullValue());
   // Assert True if "localVar" is not null
   localVar = "value";
   Assert.assertThat(localVar, IsNull.notNullValue());
 }
Exemplo n.º 10
0
 public void isNull() {
   verifyUsingMatcher(IsNull.nullValue());
 }