-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored the UI code to move the XDF and BDF reading functions to t…
…heir own package. [27334143]
- Loading branch information
1 parent
0d253f3
commit f19d229
Showing
14 changed files
with
350 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) 2012 Chris Ellison, Mike Deats, Liron Yahdav, Ryan Neal, | ||
* Brandon Sutherlin, Scott Griffin | ||
* | ||
* This software is released under the MIT license | ||
* (http://www.opensource.org/licenses/mit-license.php) | ||
* | ||
* Created on Apr 3, 2012 | ||
*/ | ||
package edu.cmu.sv.arinc838.reader; | ||
|
||
import java.io.File; | ||
|
||
import edu.cmu.sv.arinc838.binary.BdfFile; | ||
import edu.cmu.sv.arinc838.dao.SoftwareDefinitionFileDao; | ||
|
||
public class BdfReader implements SdfReader { | ||
|
||
@Override | ||
public SoftwareDefinitionFileDao read(String sdfFile) throws Exception { | ||
BdfFile bdf = new BdfFile(new File(sdfFile)); | ||
|
||
SoftwareDefinitionFileDao sdfDao = new SoftwareDefinitionFileDao(bdf); | ||
|
||
return sdfDao; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright (c) 2012 Chris Ellison, Mike Deats, Liron Yahdav, Ryan Neal, | ||
* Brandon Sutherlin, Scott Griffin | ||
* | ||
* This software is released under the MIT license | ||
* (http://www.opensource.org/licenses/mit-license.php) | ||
* | ||
* Created on Apr 3, 2012 | ||
*/ | ||
package edu.cmu.sv.arinc838.reader; | ||
|
||
import edu.cmu.sv.arinc838.dao.SoftwareDefinitionFileDao; | ||
|
||
public interface SdfReader { | ||
|
||
public abstract SoftwareDefinitionFileDao read(String sdfFile) throws Exception; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2012 Chris Ellison, Mike Deats, Liron Yahdav, Ryan Neal, | ||
* Brandon Sutherlin, Scott Griffin | ||
* | ||
* This software is released under the MIT license | ||
* (http://www.opensource.org/licenses/mit-license.php) | ||
* | ||
* Created on Apr 3, 2012 | ||
*/ | ||
package edu.cmu.sv.arinc838.reader; | ||
|
||
import java.io.File; | ||
|
||
import javax.xml.bind.JAXBContext; | ||
import javax.xml.bind.Unmarshaller; | ||
|
||
import com.arinc.arinc838.SdfFile; | ||
|
||
import edu.cmu.sv.arinc838.dao.SoftwareDefinitionFileDao; | ||
|
||
public class XdfReader implements SdfReader { | ||
|
||
@Override | ||
public SoftwareDefinitionFileDao read(String filename) throws Exception { | ||
File file = new File(filename); | ||
|
||
JAXBContext jaxbContext = JAXBContext.newInstance(SdfFile.class); | ||
Unmarshaller jaxbMarshaller = jaxbContext.createUnmarshaller(); | ||
|
||
SdfFile jaxbFile = (SdfFile) jaxbMarshaller.unmarshal(file); | ||
|
||
SoftwareDefinitionFileDao sdfDao = new SoftwareDefinitionFileDao(jaxbFile); | ||
|
||
|
||
return sdfDao; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/test/java/edu/cmu/sv/arinc838/reader/BdfReaderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package edu.cmu.sv.arinc838.reader; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
import edu.cmu.sv.arinc838.dao.FileDefinitionDao; | ||
import edu.cmu.sv.arinc838.dao.SoftwareDefinitionFileDao; | ||
import edu.cmu.sv.arinc838.dao.TargetHardwareDefinitionDao; | ||
import edu.cmu.sv.arinc838.validation.ReferenceData; | ||
|
||
public class BdfReaderTest { | ||
|
||
@Test | ||
public void testRead() throws Exception { | ||
BdfReader reader = new BdfReader(); | ||
SoftwareDefinitionFileDao sdfDao = reader.read("src/test/resources/ACM4712345678.BDF"); | ||
|
||
assertEquals(sdfDao.getFileFormatVersion(), | ||
ReferenceData.SDF_TEST_FILE.getFileFormatVersion()); | ||
assertEquals(sdfDao.getSoftwareDescription().getSoftwarePartnumber(), | ||
ReferenceData.SDF_TEST_FILE.getSoftwareDescription() | ||
.getSoftwarePartnumber()); | ||
assertEquals(sdfDao.getSoftwareDescription() | ||
.getSoftwareTypeDescription(), ReferenceData.SDF_TEST_FILE | ||
.getSoftwareDescription().getSoftwareTypeDescription()); | ||
assertEquals(sdfDao.getSoftwareDescription().getSoftwareTypeId(), | ||
ReferenceData.SDF_TEST_FILE.getSoftwareDescription() | ||
.getSoftwareTypeId()); | ||
|
||
for (int i = 0; i < ReferenceData.SDF_TEST_FILE | ||
.getTargetHardwareDefinitions().size(); i++) { | ||
TargetHardwareDefinitionDao actual = sdfDao | ||
.getTargetHardwareDefinitions().get(i); | ||
TargetHardwareDefinitionDao expected = ReferenceData.SDF_TEST_FILE | ||
.getTargetHardwareDefinitions().get(i); | ||
assertEquals(actual.getThwId(), expected.getThwId()); | ||
for (int j = 0; j < expected.getPositions().size(); j++) { | ||
String actPos = actual.getPositions().get(j); | ||
String expPos = expected.getPositions().get(j); | ||
assertEquals(actPos, expPos); | ||
} | ||
} | ||
|
||
for (int i = 0; i < ReferenceData.SDF_TEST_FILE.getFileDefinitions() | ||
.size(); i++) { | ||
FileDefinitionDao actual = sdfDao.getFileDefinitions().get(i); | ||
FileDefinitionDao expected = ReferenceData.SDF_TEST_FILE | ||
.getFileDefinitions().get(i); | ||
assertEquals(actual.getFileName(), expected.getFileName()); | ||
assertEquals(actual.getFileSize(), expected.getFileSize()); | ||
assertEquals( | ||
actual.getFileIntegrityDefinition().getIntegrityType(), | ||
expected.getFileIntegrityDefinition().getIntegrityType()); | ||
assertEquals(actual.getFileIntegrityDefinition() | ||
.getIntegrityValue(), expected.getFileIntegrityDefinition() | ||
.getIntegrityValue()); | ||
} | ||
|
||
assertEquals(sdfDao.getSdfIntegrityDefinition().getIntegrityType(), | ||
ReferenceData.SDF_TEST_FILE.getSdfIntegrityDefinition() | ||
.getIntegrityType()); | ||
assertEquals(sdfDao.getSdfIntegrityDefinition().getIntegrityValue(), | ||
ReferenceData.SDF_TEST_FILE.getSdfIntegrityDefinition() | ||
.getIntegrityValue()); | ||
|
||
assertEquals(sdfDao.getLspIntegrityDefinition().getIntegrityType(), | ||
ReferenceData.SDF_TEST_FILE.getLspIntegrityDefinition() | ||
.getIntegrityType()); | ||
assertEquals(sdfDao.getLspIntegrityDefinition().getIntegrityValue(), | ||
ReferenceData.SDF_TEST_FILE.getLspIntegrityDefinition() | ||
.getIntegrityValue()); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
src/test/java/edu/cmu/sv/arinc838/reader/XdfReaderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package edu.cmu.sv.arinc838.reader; | ||
|
||
import static org.testng.Assert.*; | ||
import java.io.File; | ||
|
||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
|
||
import edu.cmu.sv.arinc838.dao.FileDefinitionDao; | ||
import edu.cmu.sv.arinc838.dao.SoftwareDefinitionFileDao; | ||
import edu.cmu.sv.arinc838.dao.TargetHardwareDefinitionDao; | ||
import edu.cmu.sv.arinc838.validation.ReferenceData; | ||
|
||
public class XdfReaderTest { | ||
|
||
@Test | ||
public void testRead() throws Exception { | ||
XdfReader reader = new XdfReader(); | ||
SoftwareDefinitionFileDao sdfDao = reader.read("src/test/resources/ACM4712345678.XDF"); | ||
|
||
assertEquals(sdfDao.getFileFormatVersion(), | ||
ReferenceData.SDF_TEST_FILE.getFileFormatVersion()); | ||
assertEquals(sdfDao.getSoftwareDescription().getSoftwarePartnumber(), | ||
ReferenceData.SDF_TEST_FILE.getSoftwareDescription() | ||
.getSoftwarePartnumber()); | ||
assertEquals(sdfDao.getSoftwareDescription() | ||
.getSoftwareTypeDescription(), ReferenceData.SDF_TEST_FILE | ||
.getSoftwareDescription().getSoftwareTypeDescription()); | ||
assertEquals(sdfDao.getSoftwareDescription().getSoftwareTypeId(), | ||
ReferenceData.SDF_TEST_FILE.getSoftwareDescription() | ||
.getSoftwareTypeId()); | ||
|
||
for (int i = 0; i < ReferenceData.SDF_TEST_FILE | ||
.getTargetHardwareDefinitions().size(); i++) { | ||
TargetHardwareDefinitionDao actual = sdfDao | ||
.getTargetHardwareDefinitions().get(i); | ||
TargetHardwareDefinitionDao expected = ReferenceData.SDF_TEST_FILE | ||
.getTargetHardwareDefinitions().get(i); | ||
assertEquals(actual.getThwId(), expected.getThwId()); | ||
for (int j = 0; j < expected.getPositions().size(); j++) { | ||
String actPos = actual.getPositions().get(j); | ||
String expPos = expected.getPositions().get(j); | ||
assertEquals(actPos, expPos); | ||
} | ||
} | ||
|
||
for (int i = 0; i < ReferenceData.SDF_TEST_FILE.getFileDefinitions() | ||
.size(); i++) { | ||
FileDefinitionDao actual = sdfDao.getFileDefinitions().get(i); | ||
FileDefinitionDao expected = ReferenceData.SDF_TEST_FILE | ||
.getFileDefinitions().get(i); | ||
assertEquals(actual.getFileName(), expected.getFileName()); | ||
assertEquals(actual.getFileSize(), expected.getFileSize()); | ||
assertEquals( | ||
actual.getFileIntegrityDefinition().getIntegrityType(), | ||
expected.getFileIntegrityDefinition().getIntegrityType()); | ||
assertEquals(actual.getFileIntegrityDefinition() | ||
.getIntegrityValue(), expected.getFileIntegrityDefinition() | ||
.getIntegrityValue()); | ||
} | ||
|
||
assertEquals(sdfDao.getSdfIntegrityDefinition().getIntegrityType(), | ||
ReferenceData.SDF_TEST_FILE.getSdfIntegrityDefinition() | ||
.getIntegrityType()); | ||
assertEquals(sdfDao.getSdfIntegrityDefinition().getIntegrityValue(), | ||
ReferenceData.SDF_TEST_FILE.getSdfIntegrityDefinition() | ||
.getIntegrityValue()); | ||
|
||
assertEquals(sdfDao.getLspIntegrityDefinition().getIntegrityType(), | ||
ReferenceData.SDF_TEST_FILE.getLspIntegrityDefinition() | ||
.getIntegrityType()); | ||
assertEquals(sdfDao.getLspIntegrityDefinition().getIntegrityValue(), | ||
ReferenceData.SDF_TEST_FILE.getLspIntegrityDefinition() | ||
.getIntegrityValue()); | ||
} | ||
} |
Oops, something went wrong.