Search in sources :

Example 1 with StringEndsWith

use of org.hamcrest.core.StringEndsWith in project eclipse.platform.ui by eclipse-platform.

the class TestUnitDesktopFileWriter method keepsComments.

@Test
public void keepsComments() {
    String comment = "# comment=test";
    ArrayList<String> fileContent = new ArrayList<>(fileContentWith("Exec=/usr/bin/eclipse %u", NO_MIME));
    fileContent.add(comment);
    DesktopFileWriter writer = getWriterFor(fileContent);
    assertThat(new String(writer.getResult()), new StringEndsWith(comment));
}
Also used : StringEndsWith(org.hamcrest.core.StringEndsWith) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 2 with StringEndsWith

use of org.hamcrest.core.StringEndsWith in project hive by apache.

the class TestMetastoreConf method dumpConfig.

@Test
public void dumpConfig() throws IOException {
    createConfFile("metastore-site.xml", true, "METASTORE_HOME", instaMap("test.long", "23"));
    conf = MetastoreConf.newMetastoreConf();
    String dump = MetastoreConf.dumpConfig(conf);
    Assert.assertThat(dump, new StringContains("Used metastore-site file: file:/"));
    Assert.assertThat(dump, new StringContains("Key: <test.long> old hive key: <hive.test.long>  value: <23>"));
    Assert.assertThat(dump, new StringContains("Key: <test.str> old hive key: <hive.test.str>  value: <defaultval>"));
    Assert.assertThat(dump, new StringEndsWith("Finished MetastoreConf object.\n"));
    // Make sure the hidden keys didn't get published
    Assert.assertThat(dump, CoreMatchers.not(new StringContains(ConfVars.PWD.getVarname())));
}
Also used : StringEndsWith(org.hamcrest.core.StringEndsWith) StringContains(org.hamcrest.core.StringContains) MetastoreUnitTest(org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest) Test(org.junit.Test)

Example 3 with StringEndsWith

use of org.hamcrest.core.StringEndsWith in project oauth2-server by gw2auth.

the class AccountControllerTest method addAccountFederationAlreadyLinkedToOtherAccount.

@WithGw2AuthLogin(issuer = "dummyIssuer", idAtIssuer = "A")
public void addAccountFederationAlreadyLinkedToOtherAccount(MockHttpSession session) throws Exception {
    final long otherUserAccountId = this.accountRepository.save(new AccountEntity(null, Instant.now())).id();
    this.accountFederationRepository.save(new AccountFederationEntity("dummyIssuer", "B", otherUserAccountId));
    final long accountId = AuthenticationHelper.getUser(session).orElseThrow().getAccountId();
    final String loginURL = this.mockMvc.perform(get("/api/account/federation/{provider}", "dummyIssuer").session(session)).andExpect(status().is3xxRedirection()).andReturn().getResponse().getRedirectedUrl();
    this.gw2AuthLoginExtension.login(loginURL, "dummyIssuer", "B").andExpect(status().is3xxRedirection()).andExpect(header().string("Location", new StringEndsWith("?error")));
    // only the initial federation should be present
    final List<AccountFederationEntity> result = this.accountFederationRepository.findAllByAccountId(accountId);
    assertEquals(1, result.size());
}
Also used : StringEndsWith(org.hamcrest.core.StringEndsWith) AccountFederationEntity(com.gw2auth.oauth2.server.repository.account.AccountFederationEntity) AccountEntity(com.gw2auth.oauth2.server.repository.account.AccountEntity)

Aggregations

StringEndsWith (org.hamcrest.core.StringEndsWith)3 Test (org.junit.Test)2 AccountEntity (com.gw2auth.oauth2.server.repository.account.AccountEntity)1 AccountFederationEntity (com.gw2auth.oauth2.server.repository.account.AccountFederationEntity)1 ArrayList (java.util.ArrayList)1 MetastoreUnitTest (org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest)1 StringContains (org.hamcrest.core.StringContains)1