### Question:
JarScriptArchive implements ScriptArchive { @Override public ScriptModuleSpec getModuleSpec() { return moduleSpec; } protected  JarScriptArchive(ScriptModuleSpec moduleSpec, Path jarPath, long createTime); protected  JarScriptArchive(ScriptModuleSpec moduleSpec, Path jarPath, String moduleSpecEntry, long createTime); @Override ScriptModuleSpec getModuleSpec(); @Override void setModuleSpec(ScriptModuleSpec spec); @Override URL getRootUrl(); @Override Set<String> getArchiveEntryNames(); @Override @Nullable URL getEntry(String entryName); @Override long getCreateTime(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); final static String DEFAULT_MODULE_SPEC_FILE_NAME; }### Answer:
@Test public void testDefaultModuleId() throws Exception { URL rootPathUrl = getClass().getClassLoader().getResource(TEST_DEFAULT_MODULE_SPEC_JAR.getResourcePath()); Path rootPath = Paths.get(rootPathUrl.toURI()).toAbsolutePath(); JarScriptArchive scriptArchive = new JarScriptArchive.Builder(rootPath).build(); assertEquals(scriptArchive.getModuleSpec().getModuleId(), TEST_DEFAULT_MODULE_SPEC_JAR.getModuleId()); rootPathUrl = getClass().getClassLoader().getResource(TEST_DEFAULT_MODULE_SPEC_JAR2.getResourcePath()); rootPath = Paths.get(rootPathUrl.toURI()).toAbsolutePath(); scriptArchive = new JarScriptArchive.Builder(rootPath).build(); assertEquals(scriptArchive.getModuleSpec().getModuleId(), TEST_DEFAULT_MODULE_SPEC_JAR2.getModuleId()); }
@Test public void testLoadWithModuleSpec() throws Exception { URL rootPathUrl = getClass().getClassLoader().getResource(TEST_MODULE_SPEC_JAR.getResourcePath()); Path rootPath = Paths.get(rootPathUrl.toURI()).toAbsolutePath(); JarScriptArchive scriptArchive = new JarScriptArchive.Builder(rootPath).build(); ScriptModuleSpec moduleSpec = scriptArchive.getModuleSpec(); assertEquals(moduleSpec.getModuleId(), TEST_MODULE_SPEC_JAR.getModuleId()); assertEquals(moduleSpec.getModuleDependencies(), Collections.emptySet()); Map<String, String> expectedMetadata = new HashMap<String, String>(); expectedMetadata.put("metadataName1", "metadataValue1"); expectedMetadata.put("metadataName2", "metadataValue2"); }