@Test
public void testPiSystemWithCarbokation() throws Exception {

    logger.info("Entering testPiSystemWithCarbokation.");
    IAtomContainer mol = null;
    String filename = "data/mdl/piSystemWithCarbokation.mol";
    InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
    MDLReader reader = new MDLReader(ins);
    IChemFile chemFile = (IChemFile) reader.read((ChemObject) new ChemFile());
    mol = chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainer(0);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
    Aromaticity.cdkLegacy().apply(mol);
    IAtomContainerSet acSet = ConjugatedPiSystemsDetector.detect(mol);
    Assert.assertEquals(2, acSet.getAtomContainerCount());
    IAtomContainer ac1 = acSet.getAtomContainer(0);
    Assert.assertEquals(4, ac1.getAtomCount());
    Assert.assertEquals(3, ac1.getBondCount());
    for (int i = 0; i < ac1.getAtomCount(); i++)
        Assert.assertTrue(mol.contains(ac1.getAtom(i)));
    for (int i = 0; i < ac1.getBondCount(); i++)
        Assert.assertTrue(mol.contains(ac1.getBond(i)));
    IAtomContainer ac2 = acSet.getAtomContainer(0);
    Assert.assertEquals(4, ac2.getAtomCount());
    Assert.assertEquals(3, ac2.getBondCount());
    for (int i = 0; i < ac2.getAtomCount(); i++)
        Assert.assertTrue(mol.contains(ac2.getAtom(i)));
    for (int i = 0; i < ac2.getBondCount(); i++)
        Assert.assertTrue(mol.contains(ac2.getBond(i)));
}