NATTraversalTechniqueUtil { public Set<NATSituation> parseNATSituations(final String resourceName) throws Exception { final Set<NATSituation> result = new HashSet<NATSituation>(); final Set<NATSituation> tmp = new HashSet<NATSituation>(); final InputStream resourceAsStream = this.getResourceAsStream(resourceName); final BufferedReader reader = new BufferedReader(new InputStreamReader(resourceAsStream)); String line = ""; while ((line = reader.readLine()) != null) { final String[] lineContent = line.split(VALUE_SEPARATOR); final NATSituation traversaledNATBehavior = this.createNATBehaviorFromValues(lineContent); tmp.add(traversaledNATBehavior); } for (NATSituation natSituation : tmp) { result.addAll(this.resolveWildcards(natSituation)); } return Collections.unmodifiableSet(result); } private  NATTraversalTechniqueUtil(); Set<NATSituation> parseNATSituations(final String resourceName); Set<NATSituation> resolveWildcards(final NATSituation withWildcard); Set<NATSituation> getAllPossibleNATSituations(); static NATTraversalTechniqueUtil getInstance();  }
@Test public void testParseNATBehavior() throws Exception { this.expectedResult.add(new NATSituation(NATFeatureRealization.ENDPOINT_INDEPENDENT, NATFeatureRealization.ENDPOINT_INDEPENDENT, NATFeatureRealization.CONNECTION_DEPENDENT, NATFeatureRealization.CONNECTION_DEPENDENT)); this.expectedResult.add(new NATSituation(NATFeatureRealization.ADDRESS_DEPENDENT, NATFeatureRealization.ADDRESS_AND_PORT_DEPENDENT, NATFeatureRealization.NOT_REALIZED, NATFeatureRealization.CONNECTION_DEPENDENT)); this.actualResult = this.util.parseNATSituations(RESOURCE_PREFIX + RESOURCE_TRAVERSALED_BEHAVIOR); assertEquals("The NAT behavior was not parsed correctlay.", this.expectedResult, this.actualResult); }
@Test(expected = Exception.class) public void testParseFaultyNATBehavior() throws Exception { this.util.parseNATSituations(RESOURCE_PREFIX + RESOURCE_FAULTY_TRAVERSALED_BEHAVIOR); }
@Test public void testParseNATBehaviorWithWildcards() throws Exception { final int actualResult = this.util.parseNATSituations(RESOURCE_PREFIX + RESOURCE_WILDCARD_TRAVERSALED_BEHAVIOR) .size(); final int expectedResult = 26; assertEquals(expectedResult, actualResult); }