Skip to content

Commit

Permalink
More #74 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Jan 20, 2020
1 parent 2bc77ba commit ba75036
Showing 1 changed file with 58 additions and 4 deletions.
62 changes: 58 additions & 4 deletions src/test/java/com/helger/jcodemodel/JResourceDirTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ public void testNoCollisionDotInDir () throws JCodeModelException
}

@Test
public void testIntermediateDirAsFile () throws JCodeModelException
public void testCollisionIntermediateDirNameFilenameLinux () throws JCodeModelException
{
final JCodeModel cm = new JCodeModel ().setFileSystemConvention (EFileSystemConvention.LINUX);
cm.resourceDir ("a/b/c");
Expand All @@ -459,14 +459,41 @@ public void testIntermediateDirAsFile () throws JCodeModelException
}
catch (final JCodeModelException jcme)
{
// pass
// expected
}
// Using a different case works
cm.resourceDir ("a").addResourceFile (JTextFile.createFully ("B", StandardCharsets.UTF_8, "bla"));
}

@Test
public void testIntermediateDirAsClass () throws JCodeModelException
public void testCollisionIntermediateDirNameFilenameWindows () throws JCodeModelException
{
final JCodeModel cm = new JCodeModel ().setFileSystemConvention (EFileSystemConvention.WINDOWS);
cm.resourceDir ("a/b/c");
try
{
// should fail
cm.resourceDir ("a").addResourceFile (JTextFile.createFully ("b", StandardCharsets.UTF_8, "bla"));
fail ();
}
catch (final JCodeModelException jcme)
{
// expected
}
try
{
// Using a different case doesn't help us
cm.resourceDir ("a").addResourceFile (JTextFile.createFully ("B", StandardCharsets.UTF_8, "bla"));
fail ();
}
catch (final JCodeModelException jcme)
{
// expected
}
}

@Test
public void testCollisionIntermediateDirNameClassNameLinux () throws JCodeModelException
{
final JCodeModel cm = new JCodeModel ().setFileSystemConvention (EFileSystemConvention.LINUX);
cm.resourceDir ("a/B.java/c");
Expand All @@ -478,9 +505,36 @@ public void testIntermediateDirAsClass () throws JCodeModelException
}
catch (final JCodeModelException jcme)
{
// pass
// expected
}
// Using a different case works
cm._package ("a")._class ("b");
}

@Test
public void testCollisionIntermediateDirNameClassNameWindows () throws JCodeModelException
{
final JCodeModel cm = new JCodeModel ().setFileSystemConvention (EFileSystemConvention.WINDOWS);
cm.resourceDir ("a/B.java/c");
try
{
// should fail
cm._package ("a")._class ("B");
fail ();
}
catch (final JCodeModelException jcme)
{
// expected
}
try
{
// Using a different case doesn't help us here
cm._package ("a")._class ("b");
fail ();
}
catch (final JCodeModelException jcme)
{
// expected
}
}
}

0 comments on commit ba75036

Please sign in to comment.