Examples of IniFileReader


Examples of org.apache.qpid.info.util.IniFileReader

        {
            // invalid state
            return;
        }

        IniFileReader ifr = new IniFileReader();
        try
        {
            String QPID_HOME = System.getProperty("QPID_HOME");
            String cfgFilePath = QPID_HOME + File.separator + "etc"
                                 + File.separator + "qpidinfo.ini";
            ifr.load(cfgFilePath);
        }
        catch (Throwable ex)
        {
            // drop everything to be silent
            return;
        }

        // Only send Messages if we have some sections.
        if (ifr.getSections().size() != 0)
        {
            Info<? extends Map<String, ?>> info = _service.invoke(action);
            String protocol = ifr.getSections().get("").getProperty("protocol");
            sendMessages(protocol, ifr, info);
        }
    }
View Full Code Here

Examples of org.apache.qpid.info.util.IniFileReader

        {
            // invalid state
            return;
        }

        IniFileReader ifr = new IniFileReader();
        try
        {
            String QPID_HOME = System.getProperty("QPID_HOME");
            String cfgFilePath = QPID_HOME + File.separator + "etc"
                                 + File.separator + "qpidinfo.ini";
            ifr.load(cfgFilePath);
        }
        catch (Throwable ex)
        {
            // drop everything to be silent
            return;
        }

        // Only send Messages if we have some sections.
        if (ifr.getSections().size() != 0)
        {
            Info<? extends Map<String, ?>> info = _service.invoke(action);
            String protocol = ifr.getSections().get("").getProperty("protocol");
            sendMessages(protocol, ifr, info);
        }
    }
View Full Code Here

Examples of org.apache.qpid.info.util.IniFileReader

public class IniFileReaderTest extends TestCase
{

    public void testLoad()
    {
        IniFileReader ifr = new IniFileReader();
        File iniFile = null;
        try
        {
            iniFile = File.createTempFile("temp", "ini");
            iniFile.deleteOnExit();
            BufferedWriter writer = new BufferedWriter(new FileWriter(iniFile));
            writer.write("# Global Comment1\n");
            writer.write("globalprop1=globalval1\n");
            writer.write("globalprop2=globalval2\n");
            writer.write("\n");
            writer.write("[Section1] # Comment on Section\n");
            writer.write("key1=val1 # Comment on Value\n");
            writer.write("key2=val2\n");
            writer.write("\n");
            writer.write("#Section2 Comment\n");
            writer.write("[Section2]\n");
            writer.write("key3=val3\n");
            writer.write("key4=val4\n");
            writer.write("key5=val5\n");
            writer.write("\n");
            writer.write("[Section3]\n");
            writer.write("key6=val6\n");
            writer.write("key7=val7\n");
            writer.write("\n");
            writer.close();
        }
        catch (IOException e)
        {
            e.printStackTrace();
            fail("Unable to create temporary File");
        }
        ifr.load(iniFile.getAbsolutePath());
        Map<String, Properties> sections = ifr.getSections();
        assertNotNull("Sections not null", sections);
        assertEquals("Have 4 sections", sections.keySet().size(), 4);
        assertTrue("Get globalprop1", sections.get("").getProperty("globalprop1").equals("globalval1"));
        assertTrue("Get globalprop2", sections.get("").getProperty("globalprop2").equals("globalval2"));
        assertNotNull("Section1 not null", sections.get("Section1"));
View Full Code Here

Examples of org.apache.qpid.info.util.IniFileReader

     *
     * Section needs to be fully enclosed in square brackets '[<name>]'
     */
    public void testIncompleteSection1Load()
    {
        IniFileReader ifr = new IniFileReader();
        File iniFile = null;
        try
        {
            iniFile = File.createTempFile(getName(), "ini");
            iniFile.deleteOnExit();
            BufferedWriter writer = new BufferedWriter(new FileWriter(iniFile));
            writer.write("# Global Comment1\n");
            writer.write("globalprop1=globalval1\n");
            writer.write("globalprop2=globalval2\n");
            writer.write("\n");
            writer.write("[Section1\n")// Note '[Section1' not complete
            writer.write("key1=val1\n");
            writer.write("key2=val2\n");
            writer.write("\n");
            writer.close();           
        }
        catch (IOException e)
        {
            e.printStackTrace();
            fail("Unable to create temporary File");
        }
        try
        {
            ifr.load(iniFile.getAbsolutePath());
            fail("File should fail to parse");
        }
        catch (IllegalArgumentException iae)
        {
            assertEquals("Incorrect Exception", "Section1 is not closed", iae.getMessage());
View Full Code Here

Examples of util.io.IniFileReader

* @author bodum
*/
public class IniFileReaderTest extends TestCase {
 
  public void testIniReader() throws IOException {
    IniFileReader reader = new IniFileReader(this.getClass().getResourceAsStream("index.theme"));
   
    assertEquals(81, reader.getAllSections().length);
   
    assertNull(reader.getSection("nadaSection"));
   
    assertEquals(5, reader.getSection("scalable/emotes").size());
    assertEquals(3, reader.getSection("96x96/devices").size());
   
    assertEquals("Tango", reader.getSection("Icon Theme").get("_Name"));
    assertEquals("gnome,crystalsvg", reader.getSection("Icon Theme").get("Inherits"));
  }
View Full Code Here

Examples of util.io.IniFileReader

     
      if (!entryExists("index.theme")) {
        return false;
      }

      IniFileReader iniReader = new IniFileReader(getInputStream("index.theme"));

      HashMap<String, String> iconSection = iniReader.getSection("Icon Theme");
     
      mThemeName = iconSection.get("Name");
      mThemeComment = iconSection.get("Comment");

      String[] directories = (iconSection.get("Directories")).split(",");
     
      int len = directories.length;
      for (int i = 0;i<len;i++) {
        HashMap<String, String> dirMap = iniReader.getSection(directories[i]);
       
        String context = dirMap.get("Context");
        String type = dirMap.get("Type");
        int size = parseInt(dirMap.get("Size"));
        int maxsize = parseInt(dirMap.get("MaxSize"));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.