@Before public void setUp() throws Exception { dbHelper.onSetUp(); configHelper = new GoConfigFileHelper(goConfigDao); configHelper.onSetUp(); configHelper.addPipeline( "bar", "stage", MaterialConfigsMother.defaultMaterialConfigs(), "build"); pipelineConfig = configHelper.addPipeline( "foo", "stage", MaterialConfigsMother.defaultMaterialConfigs(), "build"); configHelper.addMingleConfigToPipeline( "foo", new MingleConfig("https://some-tracking-tool:8443", "project-super-secret", "hello=world")); CruiseConfig cruiseConfig = configHelper.load(); PipelineConfigs group = cruiseConfig.findGroup("defaultGroup"); group.setAuthorization( new Authorization( new ViewConfig(new AdminUser(new CaseInsensitiveString("authorized_user"))))); configHelper.writeConfigFile(cruiseConfig); SecurityConfig securityConfig = new SecurityConfig( new LdapConfig(new GoCipher()), new PasswordFileConfig("/tmp/foo.passwd"), true); securityConfig.adminsConfig().add(new AdminUser(new CaseInsensitiveString("admin"))); configHelper.addSecurity(securityConfig); }
@Test public void getStagesUsedAsMaterials() { HgMaterialConfig hg = MaterialConfigsMother.hgMaterialConfig(); StageConfig upStage = new StageConfig(new CaseInsensitiveString("stage1"), new JobConfigs()); PipelineConfig up1 = new PipelineConfig(new CaseInsensitiveString("up1"), new MaterialConfigs(hg), upStage); PipelineConfig up2 = new PipelineConfig( new CaseInsensitiveString("up2"), new MaterialConfigs(hg), new StageConfig(new CaseInsensitiveString("stage2"), new JobConfigs())); DependencyMaterialConfig dependency1 = MaterialConfigsMother.dependencyMaterialConfig("up1", "stage1"); DependencyMaterialConfig dependency2 = MaterialConfigsMother.dependencyMaterialConfig("up2", "stage2"); PipelineConfig down1 = new PipelineConfig( new CaseInsensitiveString("down1"), new MaterialConfigs(dependency1, dependency2, hg)); PipelineConfig down2 = new PipelineConfig( new CaseInsensitiveString("down2"), new MaterialConfigs(dependency1, dependency2, hg)); CruiseConfig config = new CruiseConfig(new PipelineConfigs(up1, up2, down1, down2)); Set<StageConfig> stages = config.getStagesUsedAsMaterials(up1); assertThat(stages.size(), is(1)); assertThat(stages.contains(upStage), is(true)); }
private PipelineConfig pipelineWithManyMaterials(boolean autoUpdate) { SvnMaterialConfig svnMaterialConfig = MaterialConfigsMother.svnMaterialConfig(); svnMaterialConfig.setAutoUpdate(autoUpdate); MaterialConfig gitMaterialConfig = MaterialConfigsMother.gitMaterialConfig("/foo/bar.git"); HgMaterialConfig hgMaterialConfig = MaterialConfigsMother.hgMaterialConfig(); P4MaterialConfig p4MaterialConfig = MaterialConfigsMother.p4MaterialConfig(); return new PipelineConfig( new CaseInsensitiveString("pipeline1"), new MaterialConfigs( svnMaterialConfig, hgMaterialConfig, gitMaterialConfig, p4MaterialConfig)); }
@Test public void shouldHaveBothMaterialsIfTheTypeIsDifferent() { SvnMaterialConfig svn = MaterialConfigsMother.svnMaterialConfig("url", "folder1", true); HgMaterialConfig hg = MaterialConfigsMother.hgMaterialConfig("url", "folder2"); PipelineConfig pipeline1 = new PipelineConfig(new CaseInsensitiveString("pipeline1"), new MaterialConfigs(svn)); PipelineConfig pipeline2 = new PipelineConfig(new CaseInsensitiveString("pipeline2"), new MaterialConfigs(hg)); CruiseConfig config = new CruiseConfig(new PipelineConfigs(pipeline1, pipeline2)); assertThat(config.getAllUniqueMaterialsBelongingToAutoPipelines().size(), is(2)); }
@Test public void shouldOnlyHaveOneCopyOfAMaterialIfOnlyTheFolderIsDifferent() { SvnMaterialConfig svn = MaterialConfigsMother.svnMaterialConfig("url", "folder1", true); SvnMaterialConfig svnInDifferentFolder = MaterialConfigsMother.svnMaterialConfig("url", "folder2"); PipelineConfig pipeline1 = new PipelineConfig(new CaseInsensitiveString("pipeline1"), new MaterialConfigs(svn)); PipelineConfig pipeline2 = new PipelineConfig( new CaseInsensitiveString("pipeline2"), new MaterialConfigs(svnInDifferentFolder)); CruiseConfig config = new CruiseConfig(new PipelineConfigs(pipeline1, pipeline2)); assertThat(config.getAllUniqueMaterialsBelongingToAutoPipelines().size(), is(1)); }
@Test public void shouldCreateRootNodeForPluggableSCMMaterial() { MaterialConfig material = MaterialConfigsMother.pluggableSCMMaterialConfig(); FanInNode node = FanInNodeFactory.create(material); assertThat(node instanceof RootFanInNode, is(true)); assertThat(node.materialConfig, is(material)); }
@Test public void shouldCreateDependencyNodeForScmMaterial() { MaterialConfig material = MaterialConfigsMother.dependencyMaterialConfig(); FanInNode node = FanInNodeFactory.create(material); assertThat(node instanceof DependencyFanInNode, is(true)); assertThat(node.materialConfig, is(material)); }
@Test public void shouldProvideSetOfSchedulableMaterials() { SvnMaterialConfig svnMaterialConfig = MaterialConfigsMother.svnMaterialConfig("url", "svnDir", true); PipelineConfig pipeline1 = new PipelineConfig( new CaseInsensitiveString("pipeline1"), new MaterialConfigs(svnMaterialConfig)); CruiseConfig config = new CruiseConfig(new PipelineConfigs(pipeline1)); assertThat(config.getAllUniqueMaterialsBelongingToAutoPipelines(), hasItem(svnMaterialConfig)); }
private PipelineConfig configurePipeline( String pipelineName, String stageName, String... jobConfigNames) { final String[] defaultBuildPlanNames = {"functional", "unit"}; jobConfigNames = jobConfigNames.length == 0 ? defaultBuildPlanNames : jobConfigNames; StageConfig stageConfig = StageConfigMother.stageConfig(stageName, BuildPlanMother.withBuildPlans(jobConfigNames)); MaterialConfigs materialConfigs = MaterialConfigsMother.multipleMaterialConfigs(); PipelineConfig pipelineConfig = new PipelineConfig(new CaseInsensitiveString(pipelineName), materialConfigs, stageConfig); return pipelineConfig; }
public PipelineConfig addPipelineWithTemplate( String groupName, String pipelineName, String templateName) { CruiseConfig cruiseConfig = loadForEdit(); PipelineConfig pipelineConfig = new PipelineConfig( new CaseInsensitiveString(pipelineName), MaterialConfigsMother.mockMaterialConfigs("svn:///user:pass@tmp/foo")); pipelineConfig.setTemplateName(new CaseInsensitiveString(templateName)); cruiseConfig.findGroup(groupName).add(pipelineConfig); writeConfigFile(cruiseConfig); return pipelineConfig; }
public PipelineConfig addPipelineWithGroup( String groupName, String pipelineName, SvnCommand svnCommand, String stageName, String... buildNames) { return addPipelineWithGroupAndTimer( groupName, pipelineName, new MaterialConfigs( MaterialConfigsMother.mockMaterialConfigs(svnCommand.getUrlForDisplay())), stageName, null, buildNames); }
@Test public void shouldIncludeDependencyMaterialsFromManualPipelinesInSchedulableMaterials() { DependencyMaterialConfig dependencyMaterialConfig = MaterialConfigsMother.dependencyMaterialConfig(); PipelineConfig pipeline1 = new PipelineConfig( new CaseInsensitiveString("pipeline1"), new MaterialConfigs(dependencyMaterialConfig)); pipeline1.add( new StageConfig( new CaseInsensitiveString("manual-stage"), new JobConfigs(), new Approval())); CruiseConfig config = new CruiseConfig(new PipelineConfigs(pipeline1)); Set<MaterialConfig> materialConfigs = config.getAllUniqueMaterialsBelongingToAutoPipelines(); assertThat(materialConfigs.size(), is(1)); assertThat(materialConfigs.contains(dependencyMaterialConfig), is(true)); }
private PipelineConfig setupPipelineWithScmMaterial( String pipelineName, String stageName, String jobName) { PluggableSCMMaterialConfig pluggableSCMMaterialConfig = MaterialConfigsMother.pluggableSCMMaterialConfigWithConfigProperties("url", "password"); SCMPropertyConfiguration configuration = new SCMPropertyConfiguration(); configuration.add( new SCMProperty("url", null).with(PackageConfiguration.PART_OF_IDENTITY, true)); configuration.add( new SCMProperty("password", null).with(PackageConfiguration.PART_OF_IDENTITY, false)); SCMMetadataStore.getInstance() .addMetadataFor( pluggableSCMMaterialConfig.getPluginId(), new SCMConfigurations(configuration), null); PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig( pipelineName, stageName, new MaterialConfigs(pluggableSCMMaterialConfig), jobName); configHelper.addSCMConfig(pluggableSCMMaterialConfig.getSCMConfig()); configHelper.addPipeline(pipelineConfig); return pipelineConfig; }
@Before public void setup() throws Exception { CONFIG_HELPER = new GoConfigFileHelper(); dbHelper.onSetUp(); CONFIG_HELPER.usingCruiseConfigDao(goConfigDao).initializeConfigFile(); CONFIG_HELPER.onSetUp(); repository = new SvnCommand(null, testRepo.projectRepositoryUrl()); goConfigService.forceNotifyListeners(); agentAssignment.clear(); goCache.clear(); CONFIG_HELPER.addPipeline( "blahPipeline", "blahStage", MaterialConfigsMother.hgMaterialConfig( "file:///home/cruise/projects/cruisen/manual-testing/ant_hg/dummy"), "job1", "job2"); CONFIG_HELPER.makeJobRunOnAllAgents("blahPipeline", "blahStage", "job2"); }
public void replaceMaterialWithHgRepoForPipeline(String pipelinename, String hgUrl) { replaceMaterialForPipeline(pipelinename, MaterialConfigsMother.hgMaterialConfig(hgUrl)); }
@Test public void shouldSetAServerHealthMessageWhenMaterialForPipelineWithBuildCauseIsNotFound() throws IllegalArtifactLocationException, IOException { PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig( "last", new StageConfig( new CaseInsensitiveString("stage"), new JobConfigs(new JobConfig("job-one")))); pipelineConfig.materialConfigs().clear(); SvnMaterialConfig onDirOne = MaterialConfigsMother.svnMaterialConfig( "google.com", "dirOne", "loser", "boozer", false, "**/*.html"); final P4MaterialConfig onDirTwo = MaterialConfigsMother.p4MaterialConfig( "host:987654321", "zoozer", "secret", "through-the-window", true); onDirTwo.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "dirTwo")); pipelineConfig.addMaterialConfig(onDirOne); pipelineConfig.addMaterialConfig(onDirTwo); configHelper.addPipeline(pipelineConfig); Pipeline building = PipelineMother.building(pipelineConfig); final Pipeline pipeline = dbHelper.savePipelineWithMaterials(building); CruiseConfig cruiseConfig = configHelper.currentConfig(); PipelineConfig cfg = cruiseConfig.pipelineConfigByName(new CaseInsensitiveString("last")); cfg.removeMaterialConfig(cfg.materialConfigs().get(1)); configHelper.writeConfigFile(cruiseConfig); assertThat( serverHealthService.filterByScope(HealthStateScope.forPipeline("last")).size(), is(0)); final long jobId = pipeline.getStages().get(0).getJobInstances().get(0).getId(); Date currentTime = new Date(System.currentTimeMillis() - 1); Pipeline loadedPipeline = (Pipeline) transactionTemplate.execute( new TransactionCallback() { public Object doInTransaction(TransactionStatus status) { Pipeline loadedPipeline = null; try { loadedPipeline = loader.pipelineWithPasswordAwareBuildCauseByBuildId(jobId); fail( "should not have loaded pipeline with build-cause as one of the necessary materials was not found"); } catch (Exception e) { assertThat(e, is(instanceOf(StaleMaterialsOnBuildCause.class))); assertThat( e.getMessage(), is( "Cannot load job 'last/" + pipeline.getCounter() + "/stage/1/job-one' because material " + onDirTwo + " was not found in config.")); } return loadedPipeline; } }); assertThat(loadedPipeline, is(nullValue())); JobInstance reloadedJobInstance = jobInstanceService.buildById(jobId); assertThat(reloadedJobInstance.getState(), is(JobState.Completed)); assertThat(reloadedJobInstance.getResult(), is(JobResult.Failed)); assertThat( serverHealthService .filterByScope(HealthStateScope.forJob("last", "stage", "job-one")) .size(), is(1)); ServerHealthState error = serverHealthService .filterByScope(HealthStateScope.forJob("last", "stage", "job-one")) .get(0); assertThat( error, is( ServerHealthState.error( "Cannot load job 'last/" + pipeline.getCounter() + "/stage/1/job-one' because material " + onDirTwo + " was not found in config.", "Job for pipeline 'last/" + pipeline.getCounter() + "/stage/1/job-one' has been failed as one or more material configurations were either changed or removed.", HealthStateType.general(HealthStateScope.forJob("last", "stage", "job-one"))))); DateTime expiryTime = (DateTime) ReflectionUtil.getField(error, "expiryTime"); assertThat(expiryTime.toDate().after(currentTime), is(true)); assertThat( expiryTime.toDate().before(new Date(System.currentTimeMillis() + 5 * 60 * 1000 + 1)), is(true)); String logText = FileUtil.readToEnd(consoleService.findConsoleArtifact(reloadedJobInstance.getIdentifier())); assertThat( logText, containsString( "Cannot load job 'last/" + pipeline.getCounter() + "/stage/1/job-one' because material " + onDirTwo + " was not found in config.")); assertThat( logText, containsString( "Job for pipeline 'last/" + pipeline.getCounter() + "/stage/1/job-one' has been failed as one or more material configurations were either changed or removed.")); }
public class IgnoreTest { private MaterialConfig hgMaterialConfig = MaterialConfigsMother.hgMaterialConfig(); private String separator = File.separator; @Test public void shouldIncludeWhenTheTextDoesnotMatchDocumentUnderRoot() { IgnoredFiles ignore = new IgnoredFiles("a.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "b.doc"), is(false)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "a.doc1"), is(false)); assertThat( ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "B" + separator + "a.doc"), is(false)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "a.doc"), is(false)); } @Test public void shouldIgnoreWhenTheTextDoesMatchDocumentUnderRoot() { IgnoredFiles ignore = new IgnoredFiles("a.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "a.doc"), is(true)); } @Test public void shouldIncludeWhenTheTextUnderRootIsNotADocument() { IgnoredFiles ignore = new IgnoredFiles("*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "a.pdf"), is(false)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "a.doc.aaa"), is(false)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "a.doc"), is(false)); } @Test public void shouldIgnoreWhenTheTextUnderRootIsADocument() { IgnoredFiles ignore = new IgnoredFiles("*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "a.doc"), is(true)); } @Test public void shouldIncludeWhenTextIsNotDocumentInChildOfRootFolder() throws Exception { IgnoredFiles ignore = new IgnoredFiles("*/*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "a.doc"), is(false)); assertThat( ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "B" + separator + "c.doc"), is(false)); } @Test public void shouldIgnoreWhenTextIsDocumentInChildOfRootFolder() throws Exception { IgnoredFiles ignore = new IgnoredFiles("*/*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "a.doc"), is(true)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "B" + separator + "c.doc"), is(true)); } @Test public void shouldNormalizeRegex() throws Exception { IgnoredFiles ignore = new IgnoredFiles("*\\*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "a.doc"), is(true)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "B" + separator + "c.doc"), is(true)); } @Test public void shouldIncludeWhenTextIsNotADocumentInAnyFolder() throws Exception { IgnoredFiles ignore = new IgnoredFiles("**/*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "a.pdf"), is(false)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "B" + separator + "a.pdf"), is(false)); assertThat( ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "B" + separator + "a.pdf"), is(false)); } @Test public void shouldIgnoreWhenTextIsADocumentInAnyFolder() throws Exception { IgnoredFiles ignore = new IgnoredFiles("**/*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "a.doc"), is(true)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "a.doc"), is(true)); assertThat( ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "B" + separator + "a.doc"), is(true)); } @Test public void shouldIgnoreWhenTextIsADocumentInAnyFolderWhenDirectoryWildcardNotInTheBegining() throws Exception { IgnoredFiles ignore = new IgnoredFiles("foo*/**/*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "foo-hi/bar/a.doc"), is(true)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "bar/baz/b.doc"), is(false)); } @Test public void shouldIgnoreWhenTextIsADocumentInAnyFolderWhenDirectoryWildcardNotInTheBeginingAndTerminatesInWildcard() throws Exception { IgnoredFiles ignore = new IgnoredFiles("**/foo*/**/*"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "foo-hi/bar/a.doc"), is(true)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "bar/baz/b.doc"), is(false)); assertThat( ignore.shouldIgnore(hgMaterialConfig, "hello-world/woods/foo-hi/bar/a.doc"), is(true)); } @Test public void shouldIncludeIfTheTextIsNotADocumentInTheSpecifiedFolder() throws Exception { IgnoredFiles ignore = new IgnoredFiles("ROOTFOLDER/*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "shouldNotBeIgnored.doc"), is(false)); assertThat( ignore.shouldIgnore(hgMaterialConfig, "ANYFOLDER" + separator + "shouldNotBeIgnored.doc"), is(false)); assertThat( ignore.shouldIgnore( hgMaterialConfig, "ROOTFOLDER" + separator + "" + "ANYFOLDER" + separator + "shouldNotBeIgnored.doc"), is(false)); } @Test public void shouldIncludIgnoreIfTextIsADocumentInTheSpecifiedFolder() throws Exception { IgnoredFiles ignore = new IgnoredFiles("ROOTFOLDER/*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "ROOTFOLDER" + separator + "a.doc"), is(true)); } @Test public void shouldIncludeIfTextIsNotUnderAGivenFolder() throws Exception { IgnoredFiles ignore = new IgnoredFiles("**/DocumentFolder/*"); assertThat( ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "shouldNotBeIgnored.doc"), is(false)); assertThat( ignore.shouldIgnore( hgMaterialConfig, "A" + separator + "DocumentFolder" + separator + "B" + separator + "d.doc"), is(false)); } @Test public void shouldIgnoreIfTextIsUnderAGivenFolder() throws Exception { IgnoredFiles ignore = new IgnoredFiles("**/DocumentFolder/*"); assertThat( ignore.shouldIgnore( hgMaterialConfig, "A" + separator + "DocumentFolder" + separator + "d.doc"), is(true)); } @Test public void shouldIncludeIfTextIsNotUnderAFolderMatchingTheGivenFolder() throws Exception { IgnoredFiles ignore = new IgnoredFiles("**/*Test*/*"); assertThat( ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "shouldNotBeIgnored.doc"), is(false)); assertThat( ignore.shouldIgnore(hgMaterialConfig, "B/NotIgnored" + separator + "isIgnored"), is(false)); } @Test public void shouldIgnoreIfTextIsUnderAFolderMatchingTheGivenFolder() throws Exception { IgnoredFiles ignore = new IgnoredFiles("**/*Test*/*"); assertThat( ignore.shouldIgnore( hgMaterialConfig, "B" + separator + "SomethingTestThis" + separator + "isIgnored"), is(true)); } @Test public void shouldIgnoreEverythingUnderAFolderWithWildcards() throws Exception { IgnoredFiles ignore = new IgnoredFiles("Test/**/*.*"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "Test" + separator + "foo.txt"), is(true)); assertThat( ignore.shouldIgnore( hgMaterialConfig, "Test" + separator + "subdir" + separator + "foo.txt"), is(true)); assertThat( ignore.shouldIgnore( hgMaterialConfig, "Test" + separator + "subdir" + separator + "subdir" + separator + "foo.txt"), is(true)); assertThat( ignore.shouldIgnore( hgMaterialConfig, "Test" + separator + "subdir" + separator + "subdir" + separator + "foo"), is(false)); } @Test public void shouldIgnoreEverythingUnderAFolderWithWildcardsWithoutExtension() throws Exception { IgnoredFiles ignore = new IgnoredFiles("Test/**/*"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "Test" + separator + "foo.txt"), is(true)); assertThat( ignore.shouldIgnore( hgMaterialConfig, "Test" + separator + "subdir" + separator + "foo.txt"), is(true)); assertThat( ignore.shouldIgnore( hgMaterialConfig, "Test" + separator + "subdir" + separator + "subdir" + separator + "foo.txt"), is(true)); assertThat( ignore.shouldIgnore( hgMaterialConfig, "Test" + separator + "subdir" + separator + "subdir" + separator + "foo"), is(true)); } @Test public void shouldSkipDiot() throws Exception { IgnoredFiles ignore = new IgnoredFiles("helper/*.*"); assertThat( ignore.shouldIgnore( hgMaterialConfig, "helper" + separator + "configuration_reference.html"), is(true)); assertThat( ignore.shouldIgnore( hgMaterialConfig, "helper" + separator + "conf-docs" + separator + "configuration_reference.html"), is(false)); assertThat( ignore.shouldIgnore( hgMaterialConfig, "helper" + separator + "resources" + separator + "images" + separator + "cruise" + separator + "dependent_build.png"), is(false)); } @Test public void shouldAddErrorToItsErrorCollection() { IgnoredFiles ignore = new IgnoredFiles("helper/*.*"); ignore.addError("pattern", "not allowed"); assertThat(ignore.errors().on("pattern"), is("not allowed")); } @Test public void shouldEscapeAllValidSpecialCharactersInPattern() { // see mingle #5700 hgMaterialConfig = new TfsMaterialConfig(new GoCipher()); IgnoredFiles ignore = new IgnoredFiles("$/tfs_repo/Properties/*.*"); assertThat( ignore.shouldIgnore( hgMaterialConfig, "$/tfs_repo" + separator + "Properties" + separator + "AssemblyInfo.cs"), is(true)); } @Test public void understandPatternPunct() { assertThat(Pattern.matches("a\\.doc", "a.doc"), is(true)); assertThat(Pattern.matches("\\p{Punct}", "*"), is(true)); assertThat(Pattern.matches("\\p{Punct}", "{"), is(true)); assertThat(Pattern.matches("\\p{Punct}", "]"), is(true)); assertThat(Pattern.matches("\\p{Punct}", "-"), is(true)); assertThat(Pattern.matches("\\p{Punct}", "."), is(true)); } }