mil.dod.th.ose.controller/test/mil/dod/th/ose/controller/impl/TestTerraHarvestControllerImpl.java
@Test
    public void testLoadProperties() throws Exception
    {
        m_FileInputStream = FileInputStreamMocker.mockIt(
                "id=0xabcdefab\n name=stored-name\n operation.mode=operational");
        when(m_FileService.createFileInputStream(Mockito.any(File.class))).thenReturn(m_FileInputStream);
        
        m_SUT.activate(m_Context);
        
        ArgumentCaptor<File> fileCaptor = ArgumentCaptor.forClass(File.class);
        // should be twice, once during setup, once here
        verify(m_FileService, times(2)).createFileInputStream(fileCaptor.capture());
        assertThat(fileCaptor.getValue().getPath(), is(EXPECTED_TH_SYSTEM_PROPERTIES_FILENAME));
        
        assertThat(m_SUT.getName(), is("stored-name"));
        assertThat(m_SUT.getOperationMode(), is(OperationMode.OPERATIONAL_MODE));
        assertThat(m_SUT.getId(), is(0xabcdefab));
        
        // update only one property, make sure other props are still in file
        m_SUT.setName("new-name");
        verify(m_FileService, atLeastOnce()).createFileOutputStream(fileCaptor.capture());
        assertThat(fileCaptor.getValue().getPath(), is(EXPECTED_TH_SYSTEM_PROPERTIES_FILENAME));
        assertThat(new String(m_OutputData.toByteArray()), containsString("name=new-name"));
        assertThat(new String(m_OutputData.toByteArray()), containsString("id=0xabcdefab"));
        assertThat(new String(m_OutputData.toByteArray()), containsString("operation.mode=operational"));
    }
/**
     * Verify system properties are read in during activation and properties are set based on contents of file.
     */
Verify system properties are read in during activation and properties are set based on contents of file.
Verify system properties are read in during activation and properties are set based on contents of file .
@Test
    public void testLoadProperties() throws Exception
    {
        m_FileInputStream = FileInputStreamMocker.mockIt(
                "id=0xabcdefab\n name=stored-name\n operation.mode=operational");
        when(m_FileService.createFileInputStream(Mockito.any(File.class))).thenReturn(m_FileInputStream);
        m_SUT.activate(m_Context);
        ArgumentCaptor<File> fileCaptor = ArgumentCaptor.forClass(File.class);
        verify(m_FileService, times(2)).createFileInputStream(fileCaptor.capture());
        assertThat(fileCaptor.getValue().getPath(), is(EXPECTED_TH_SYSTEM_PROPERTIES_FILENAME));
        assertThat(m_SUT.getName(), is("stored-name"));
        assertThat(m_SUT.getOperationMode(), is(OperationMode.OPERATIONAL_MODE));
        assertThat(m_SUT.getId(), is(0xabcdefab));
        m_SUT.setName("new-name");
        verify(m_FileService, atLeastOnce()).createFileOutputStream(fileCaptor.capture());
        assertThat(fileCaptor.getValue().getPath(), is(EXPECTED_TH_SYSTEM_PROPERTIES_FILENAME));
        assertThat(new String(m_OutputData.toByteArray()), containsString("name=new-name"));
        assertThat(new String(m_OutputData.toByteArray()), containsString("id=0xabcdefab"));
        assertThat(new String(m_OutputData.toByteArray()), containsString("operation.mode=operational"));
    }
@ Test public void testLoadProperties ( ) throws Exception { m_FileInputStream = FileInputStreamMocker . mockIt ( "id=0xabcdefab\n name=stored-name\n operation.mode=operational" ) ; when ( m_FileService . createFileInputStream ( Mockito . any ( File . class ) ) ) . thenReturn ( m_FileInputStream ) ; m_SUT . activate ( m_Context ) ; ArgumentCaptor < File > fileCaptor = ArgumentCaptor . forClass ( File . class ) ; verify ( m_FileService , times ( 2 ) ) . createFileInputStream ( fileCaptor . capture ( ) ) ; assertThat ( fileCaptor . getValue ( ) . getPath ( ) , is ( EXPECTED_TH_SYSTEM_PROPERTIES_FILENAME ) ) ; assertThat ( m_SUT . getName ( ) , is ( "stored-name" ) ) ; assertThat ( m_SUT . getOperationMode ( ) , is ( OperationMode . OPERATIONAL_MODE ) ) ; assertThat ( m_SUT . getId ( ) , is ( 0xabcdefab ) ) ; m_SUT . setName ( "new-name" ) ; verify ( m_FileService , atLeastOnce ( ) ) . createFileOutputStream ( fileCaptor . capture ( ) ) ; assertThat ( fileCaptor . getValue ( ) . getPath ( ) , is ( EXPECTED_TH_SYSTEM_PROPERTIES_FILENAME ) ) ; assertThat ( new String ( m_OutputData . toByteArray ( ) ) , containsString ( "name=new-name" ) ) ; assertThat ( new String ( m_OutputData . toByteArray ( ) ) , containsString ( "id=0xabcdefab" ) ) ; assertThat ( new String ( m_OutputData . toByteArray ( ) ) , containsString ( "operation.mode=operational" ) ) ; }
Verify system properties are read in during activation and properties are set based on contents of file.
Verify system properties are read in during activation and properties are set based on contents of file .
// should be twice, once during setup, once here // update only one property, make sure other props are still in file