@ -1307,6 +1307,102 @@ public class ObjectCheckerTest {
}
}
@Test
public void testInvalidTreeNameIsDotGitDot ( ) {
StringBuilder b = new StringBuilder ( ) ;
entry ( b , "100644 .git." ) ;
byte [ ] data = Constants . encodeASCII ( b . toString ( ) ) ;
try {
checker . checkTree ( data ) ;
fail ( "incorrectly accepted an invalid tree" ) ;
} catch ( CorruptObjectException e ) {
assertEquals ( "invalid name '.git.'" , e . getMessage ( ) ) ;
}
}
@Test
public void testValidTreeNameIsDotGitDotDot ( )
throws CorruptObjectException {
StringBuilder b = new StringBuilder ( ) ;
entry ( b , "100644 .git.." ) ;
checker . checkTree ( Constants . encodeASCII ( b . toString ( ) ) ) ;
}
@Test
public void testInvalidTreeNameIsDotGitSpace ( ) {
StringBuilder b = new StringBuilder ( ) ;
entry ( b , "100644 .git " ) ;
byte [ ] data = Constants . encodeASCII ( b . toString ( ) ) ;
try {
checker . checkTree ( data ) ;
fail ( "incorrectly accepted an invalid tree" ) ;
} catch ( CorruptObjectException e ) {
assertEquals ( "invalid name '.git '" , e . getMessage ( ) ) ;
}
}
@Test
public void testInvalidTreeNameIsDotGitSomething ( )
throws CorruptObjectException {
StringBuilder b = new StringBuilder ( ) ;
entry ( b , "100644 .gitfoobar" ) ;
byte [ ] data = Constants . encodeASCII ( b . toString ( ) ) ;
checker . checkTree ( data ) ;
}
@Test
public void testInvalidTreeNameIsDotGitSomethingSpaceSomething ( )
throws CorruptObjectException {
StringBuilder b = new StringBuilder ( ) ;
entry ( b , "100644 .gitfoo bar" ) ;
byte [ ] data = Constants . encodeASCII ( b . toString ( ) ) ;
checker . checkTree ( data ) ;
}
@Test
public void testInvalidTreeNameIsDotGitSomethingDot ( )
throws CorruptObjectException {
StringBuilder b = new StringBuilder ( ) ;
entry ( b , "100644 .gitfoobar." ) ;
byte [ ] data = Constants . encodeASCII ( b . toString ( ) ) ;
checker . checkTree ( data ) ;
}
@Test
public void testInvalidTreeNameIsDotGitSomethingDotDot ( )
throws CorruptObjectException {
StringBuilder b = new StringBuilder ( ) ;
entry ( b , "100644 .gitfoobar.." ) ;
byte [ ] data = Constants . encodeASCII ( b . toString ( ) ) ;
checker . checkTree ( data ) ;
}
@Test
public void testInvalidTreeNameIsDotGitDotSpace ( ) {
StringBuilder b = new StringBuilder ( ) ;
entry ( b , "100644 .git. " ) ;
byte [ ] data = Constants . encodeASCII ( b . toString ( ) ) ;
try {
checker . checkTree ( data ) ;
fail ( "incorrectly accepted an invalid tree" ) ;
} catch ( CorruptObjectException e ) {
assertEquals ( "invalid name '.git. '" , e . getMessage ( ) ) ;
}
}
@Test
public void testInvalidTreeNameIsDotGitSpaceDot ( ) {
StringBuilder b = new StringBuilder ( ) ;
entry ( b , "100644 .git . " ) ;
byte [ ] data = Constants . encodeASCII ( b . toString ( ) ) ;
try {
checker . checkTree ( data ) ;
fail ( "incorrectly accepted an invalid tree" ) ;
} catch ( CorruptObjectException e ) {
assertEquals ( "invalid name '.git . '" , e . getMessage ( ) ) ;
}
}
@Test
public void testInvalidTreeTruncatedInName ( ) {
final StringBuilder b = new StringBuilder ( ) ;