FileUtil { public static String sessionIdFileName(SessionID sessionID) { return replaceIllegalCharactersInFileName(sessionID.getBeginString() + "-" + sessionID.getSenderCompID() + optionalField("_", sessionID.getSenderSubID()) + optionalField("_", sessionID.getSenderLocationID()) + "-" + sessionID.getTargetCompID() + optionalField("_", sessionID.getTargetSubID()) + optionalField("_", sessionID.getTargetLocationID()) + optionalField("-", sessionID.getSessionQualifier())); }  static String fileAppendPath(String pathPrefix, String pathSuffix); static String sessionIdFileName(SessionID sessionID); static InputStream open(Class<?> clazz, String name); static InputStream open(Class<?> clazz, String name, Location... locations);  }
@Test public void testSessionIDFileName() { SessionID sessionID = new SessionID(FixVersions.BEGINSTRING_FIX44, "SENDER???", "bla_/--/#()_bla", "!!!TARGET", "foo::bar"); String sessionIdFileName = FileUtil.sessionIdFileName(sessionID); assertEquals("FIX.4.4-SENDER____bla__--_____bla-___TARGET_foo__bar", sessionIdFileName); assertTrue(sessionIdFileName.matches("[a-zA-Z0-9-._]*")); sessionID = new SessionID(FixVersions.BEGINSTRING_FIX44, "SENDER", "TARGET"); sessionIdFileName = FileUtil.sessionIdFileName(sessionID); assertEquals("FIX.4.4-SENDER-TARGET", sessionIdFileName); }