### Question:
PathValueFactory extends AbstractValueFactory<Path> implements PathFactory { String[] splitPath( String rawPath ) { List<String> segments = new LinkedList<String>(); int curr = 0; int nextBrace = rawPath.indexOf('{'); int nextSlash = rawPath.indexOf('/'); while (true) { if ((nextSlash == -1 && nextBrace > -1) || (nextBrace > -1 && nextBrace < nextSlash)) { int nextClosingBrace = rawPath.indexOf('}', nextBrace); if (nextClosingBrace == -1) { throw new ValueFormatException(rawPath, getPropertyType(), GraphI18n.missingClosingBrace.text(rawPath)); } nextSlash = rawPath.indexOf('/', nextClosingBrace + 1); nextBrace = rawPath.indexOf('{', nextClosingBrace + 1); } else if ((nextBrace == -1 && nextSlash > -1) || (nextSlash > -1 && nextSlash < nextBrace)) { if (nextSlash > 0) { segments.add(rawPath.substring(curr, nextSlash)); } curr = nextSlash + 1; nextSlash = rawPath.indexOf('/', curr); } else { segments.add(rawPath.substring(curr)); return segments.toArray(new String[segments.size()]); } } } PathValueFactory( TextDecoder decoder,
                             ValueFactory<String> stringValueFactory,
                             ValueFactory<Name> nameValueFactory ); Path createRootPath(); Path create( String value ); Path create( final String value,
                        TextDecoder decoder ); Path create( int value ); Path create( long value ); Path create( boolean value ); Path create( float value ); Path create( double value ); Path create( BigDecimal value ); Path create( Calendar value ); Path create( Date value ); Path create( DateTime value ); Path create( Name value ); Path create( Path value ); Path create( Path.Segment value ); Path createAbsolutePath( Name... segmentNames ); Path createAbsolutePath( Segment... segments ); Path createAbsolutePath( Iterable<Segment> segments ); Path createRelativePath(); Path createRelativePath( Name... segmentNames ); Path createRelativePath( Segment... segments ); Path createRelativePath( Iterable<Segment> segments ); Path create( Path parentPath,
                        Path childPath ); Path create( Path parentPath,
                        Name segmentName,
                        int index ); Path create( Path parentPath,
                        String segmentName,
                        int index ); Path create( Path parentPath,
                        Name... segmentNames ); Path create( Path parentPath,
                        Segment... segments ); Path create( Path parentPath,
                        Iterable<Segment> segments ); Path create( Path parentPath,
                        String subpath ); Segment createSegment( Name segmentName ); Segment createSegment( Name segmentName,
                                  int index ); Segment createSegment( String segmentName ); Segment createSegment( String segmentName,
                                  TextDecoder decoder ); Segment createSegment( String segmentName,
                                  int index ); Path create( Reference value ); Path create( URI value ); Path create( UUID value ); Path create( byte[] value ); Path create( Binary value ); Path create( InputStream stream,
                        long approximateLength ); Path create( Reader reader,
                        long approximateLength );  }### Answer:
@Test public void shouldSplitPathWithExpandedNamespace() { String[] splits = factory.splitPath("/{http: String[] correctSplits = new String[] {"{http: assertThat(splits, is(correctSplits)); }
@Test public void shouldSplitPathWithoutExpandedNamespace() { String[] splits = factory.splitPath("/jcr:foo/bar/blah:baz"); String[] correctSplits = new String[] {"jcr:foo", "bar", "blah:baz"}; assertThat(splits, is(correctSplits)); }
@Test( expected = ValueFormatException.class ) public void shouldThrowValueFormatExceptionOnMalformedName() { factory.splitPath("/jcr:foo/{foobar"); }