text
stringlengths
30
1.67M
<s> package com . izforge . izpack . api . rules ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; public abstract class ConditionWithMultipleOperands extends Condition { protected List < Condition > nestedConditions = new ArrayList < Condition > ( ) ; public List < Condition > getOperands ( ) { return nestedConditions ; } public void addOperands ( Condition ... operands ) { Collections . addAll ( nestedConditions , operands ) ; } } </s>
<s> package com . izforge . izpack . api . rules ; import java . util . EnumSet ; import java . util . HashMap ; import java . util . Map ; public enum ComparisonOperator { EQUAL ( "<STR_LIT>" ) , NOTEQUAL ( "<STR_LIT>" ) , LESSEQUAL ( "<STR_LIT>" ) , LESS ( "<STR_LIT>" ) , GREATEREQUAL ( "<STR_LIT>" ) , GREATER ( "<STR_LIT>" ) ; private static Map < String , ComparisonOperator > lookup ; private String attribute ; ComparisonOperator ( String attribute ) { this . attribute = attribute ; } static { lookup = new HashMap < String , ComparisonOperator > ( ) ; for ( ComparisonOperator op : EnumSet . allOf ( ComparisonOperator . class ) ) { lookup . put ( op . getAttribute ( ) , op ) ; } } public String getAttribute ( ) { return attribute ; } public static ComparisonOperator getComparisonOperatorFromAttribute ( String attribute ) { if ( attribute != null && lookup . containsKey ( attribute ) ) { return lookup . get ( attribute ) ; } return null ; } } </s>
<s> package com . izforge . izpack . api . rules ; import java . io . Serializable ; import com . izforge . izpack . api . adaptator . IXMLElement ; import com . izforge . izpack . api . data . InstallData ; public abstract class Condition implements Serializable { private static final long serialVersionUID = <NUM_LIT> ; private String id ; private transient InstallData installData ; public Condition ( ) { this . setId ( "<STR_LIT>" ) ; } public String getId ( ) { return this . id ; } public void setId ( String id ) { this . id = id ; } public abstract void readFromXML ( IXMLElement xmlcondition ) throws Exception ; public abstract boolean isTrue ( ) ; public InstallData getInstallData ( ) { return installData ; } public void setInstallData ( InstallData installData ) { this . installData = installData ; } public String getDependenciesDetails ( ) { return "<STR_LIT>" ; } public abstract void makeXMLData ( IXMLElement conditionRoot ) ; } </s>
<s> package com . izforge . izpack . api . rules ; import com . izforge . izpack . api . adaptator . IXMLElement ; import com . izforge . izpack . api . adaptator . impl . XMLElementImpl ; public abstract class CompareCondition extends Condition { protected String operand1 ; protected String operand2 ; protected ComparisonOperator operator = ComparisonOperator . EQUAL ; public CompareCondition ( String op1 , String op2 ) { super ( ) ; operand1 = op1 ; operand2 = op2 ; } public CompareCondition ( ) { super ( ) ; } public String getLeftOperand ( ) { return operand1 ; } public void setLeftOperand ( String value ) { operand1 = value ; } public String getRightOperand ( ) { return operand2 ; } public void setRightOperand ( String value ) { operand2 = value ; } public ComparisonOperator getOperator ( ) { return operator ; } public void setOperator ( ComparisonOperator operator ) { this . operator = operator ; } @ Override public void readFromXML ( IXMLElement xmlcondition ) throws Exception { try { this . operand1 = xmlcondition . getFirstChildNamed ( "<STR_LIT>" ) . getContent ( ) ; this . operand2 = xmlcondition . getFirstChildNamed ( "<STR_LIT>" ) . getContent ( ) ; String operatorAttr = xmlcondition . getFirstChildNamed ( "<STR_LIT>" ) . getContent ( ) ; if ( operatorAttr != null ) { operator = ComparisonOperator . getComparisonOperatorFromAttribute ( operatorAttr ) ; } } catch ( Exception e ) { throw new Exception ( "<STR_LIT>" + getClass ( ) . getSimpleName ( ) + "<STR_LIT>" ) ; } } @ Override public String getDependenciesDetails ( ) { StringBuffer details = new StringBuffer ( ) ; details . append ( getId ( ) ) ; details . append ( "<STR_LIT>" ) ; details . append ( this . operand1 ) ; details . append ( "<STR_LIT>" ) ; details . append ( this . operand2 ) ; details . append ( "<STR_LIT>" ) ; details . append ( "<STR_LIT>" + this . operator ) ; details . append ( "<STR_LIT>" ) ; return details . toString ( ) ; } @ Override public void makeXMLData ( IXMLElement conditionRoot ) { XMLElementImpl nameXml = new XMLElementImpl ( "<STR_LIT>" , conditionRoot ) ; nameXml . setContent ( this . operand1 ) ; conditionRoot . addChild ( nameXml ) ; XMLElementImpl valueXml = new XMLElementImpl ( "<STR_LIT>" , conditionRoot ) ; valueXml . setContent ( this . operand2 ) ; conditionRoot . addChild ( valueXml ) ; XMLElementImpl opXml = new XMLElementImpl ( "<STR_LIT>" , conditionRoot ) ; opXml . setContent ( this . operator . getAttribute ( ) ) ; conditionRoot . addChild ( opXml ) ; } } </s>
<s> package com . izforge . izpack . api . rules ; import java . io . OutputStream ; import java . util . Map ; import java . util . Set ; import com . izforge . izpack . api . adaptator . IXMLElement ; import com . izforge . izpack . api . data . InstallData ; import com . izforge . izpack . api . data . Variables ; public interface RulesEngine { Set < String > getKnownConditionIds ( ) ; boolean isConditionTrue ( String id , InstallData installData ) ; boolean isConditionTrue ( Condition cond , InstallData installData ) ; boolean isConditionTrue ( String id ) ; boolean isConditionTrue ( Condition cond ) ; boolean canShowPanel ( String panelid , Variables variables ) ; boolean canInstallPack ( String packid , Variables variables ) ; boolean canInstallPackOptional ( String packid , Variables variables ) ; void addCondition ( Condition condition ) ; void writeRulesXML ( OutputStream out ) ; Condition getCondition ( String id ) ; void readConditionMap ( Map < String , Condition > rules ) ; void analyzeXml ( IXMLElement conditionsspec ) ; @ Deprecated Condition instanciateCondition ( IXMLElement condition ) ; Condition createCondition ( IXMLElement condition ) ; void resolveConditions ( ) throws Exception ; IXMLElement createConditionElement ( Condition condition , IXMLElement root ) ; } </s>
<s> package com . izforge . izpack . api . rules ; public abstract class ConditionReference extends Condition { private Condition referencedCondition ; public Condition getReferencedCondition ( ) { return referencedCondition ; } public void setReferencedCondition ( Condition referencedCondition ) { this . referencedCondition = referencedCondition ; } public abstract void resolveReference ( ) ; } </s>
<s> package com . izforge . izpack . api . container ; import com . izforge . izpack . api . exception . ContainerException ; import com . izforge . izpack . api . exception . IzPackClassNotFoundException ; public interface Container { < T > void addComponent ( Class < T > componentType ) ; void addComponent ( Object componentKey , Object implementation ) ; < T > T getComponent ( Class < T > componentType ) ; Object getComponent ( Object componentKeyOrType ) ; Container createChildContainer ( ) ; boolean removeChildContainer ( Container child ) ; void dispose ( ) ; < T > Class < T > getClass ( String className , Class < T > superType ) ; } </s>
<s> package com . izforge . izpack . api . adaptator ; import java . io . OutputStream ; public interface IXMLWriter { void write ( IXMLElement element ) ; void setOutput ( OutputStream outputStream ) ; void setOutput ( String systemId ) ; } </s>
<s> package com . izforge . izpack . api . adaptator ; import java . io . InputStream ; import java . net . URL ; public interface IXMLParser { public static final String XSL_FILE_NAME = "<STR_LIT>" ; IXMLElement parse ( InputStream inputStream ) ; IXMLElement parse ( InputStream inputStream , String systemId ) ; IXMLElement parse ( String inputString ) ; IXMLElement parse ( URL inputURL ) ; } </s>
<s> package com . izforge . izpack . api . adaptator . impl ; import java . util . LinkedList ; import java . util . Queue ; import java . util . Stack ; import javax . xml . transform . dom . DOMResult ; import org . w3c . dom . Element ; import org . w3c . dom . Node ; import org . xml . sax . Attributes ; import org . xml . sax . Locator ; import org . xml . sax . SAXException ; import org . xml . sax . XMLReader ; import org . xml . sax . helpers . XMLFilterImpl ; public class LineNumberFilter extends XMLFilterImpl { private Queue < Integer > lnQueue ; private Locator locator ; public LineNumberFilter ( XMLReader xmlReader ) { super ( xmlReader ) ; } @ Override public void startDocument ( ) throws SAXException { super . startDocument ( ) ; lnQueue = new LinkedList < Integer > ( ) ; } @ Override public void startElement ( String uri , String localName , String qName , Attributes atts ) throws SAXException { super . startElement ( uri , localName , qName , atts ) ; lnQueue . add ( locator . getLineNumber ( ) ) ; } @ Override public void setDocumentLocator ( Locator locator ) { super . setDocumentLocator ( locator ) ; this . locator = locator ; } public Locator getDocumentLocator ( ) { return locator ; } private Element getFirstFoundElement ( Node elt ) { while ( elt != null && elt . getNodeType ( ) != Node . ELEMENT_NODE ) { elt = elt . getNextSibling ( ) ; } return ( Element ) elt ; } private Element getNextSibling ( Node elt ) { return getFirstFoundElement ( elt . getNextSibling ( ) ) ; } private Element getFirstChild ( Node elt ) { return getFirstFoundElement ( elt . getFirstChild ( ) ) ; } private boolean hasChildElements ( Node elt ) { return getFirstChild ( elt ) != null ; } private void applyLN ( Element elt ) { elt . setUserData ( "<STR_LIT>" , lnQueue . poll ( ) , null ) ; } public void applyLN ( DOMResult result ) { Element elt = getFirstChild ( result . getNode ( ) ) ; boolean end = false ; Stack < Element > stack = new Stack < Element > ( ) ; while ( ! end ) { if ( hasChildElements ( elt ) ) { stack . push ( elt ) ; applyLN ( elt ) ; elt = getFirstChild ( elt ) ; } else { applyLN ( elt ) ; Element sibling = getNextSibling ( elt ) ; if ( sibling != null ) { elt = sibling ; } else { do { if ( stack . isEmpty ( ) ) { end = true ; } else { elt = stack . pop ( ) ; elt = getNextSibling ( elt ) ; } } while ( ! end && elt == null ) ; } } } } } </s>
<s> package com . izforge . izpack . api . adaptator . impl ; import com . izforge . izpack . api . adaptator . IXMLElement ; import com . izforge . izpack . api . adaptator . IXMLWriter ; import com . izforge . izpack . api . adaptator . XMLException ; import javax . xml . transform . * ; import javax . xml . transform . dom . DOMSource ; import javax . xml . transform . stream . StreamResult ; import java . io . OutputStream ; public class XMLWriter implements IXMLWriter { private OutputStream outputStream ; private String systemId ; public XMLWriter ( ) { } public XMLWriter ( OutputStream outputStream ) { this . outputStream = outputStream ; } public void write ( IXMLElement element ) { try { Source source = new DOMSource ( element . getElement ( ) . getOwnerDocument ( ) ) ; TransformerFactory fabrique = TransformerFactory . newInstance ( ) ; Transformer transformer = fabrique . newTransformer ( ) ; transformer . setOutputProperty ( OutputKeys . INDENT , "<STR_LIT:yes>" ) ; transformer . setOutputProperty ( OutputKeys . ENCODING , "<STR_LIT:UTF-8>" ) ; Result result ; if ( outputStream != null ) { result = new StreamResult ( outputStream ) ; } else { result = new StreamResult ( systemId ) ; } transformer . transform ( source , result ) ; } catch ( TransformerException e ) { throw new XMLException ( e ) ; } } public void setOutput ( OutputStream outputStream ) { this . outputStream = outputStream ; } public void setOutput ( String systemId ) { this . systemId = systemId ; } } </s>
<s> package com . izforge . izpack . api . adaptator . impl ; import com . izforge . izpack . api . adaptator . IXMLElement ; import com . izforge . izpack . api . adaptator . IXMLParser ; import com . izforge . izpack . api . adaptator . XMLException ; import org . w3c . dom . Node ; import org . xml . sax . InputSource ; import org . xml . sax . Locator ; import org . xml . sax . SAXException ; import org . xml . sax . XMLReader ; import javax . xml . parsers . ParserConfigurationException ; import javax . xml . parsers . SAXParserFactory ; import javax . xml . transform . Source ; import javax . xml . transform . Transformer ; import javax . xml . transform . TransformerException ; import javax . xml . transform . TransformerFactory ; import javax . xml . transform . dom . DOMResult ; import javax . xml . transform . sax . SAXSource ; import javax . xml . transform . stream . StreamSource ; import java . io . IOException ; import java . io . InputStream ; import java . net . URL ; import java . nio . ByteBuffer ; import java . nio . charset . Charset ; public class XMLParser implements IXMLParser { public class ByteBufferInputStream extends InputStream { private final ByteBuffer buf ; public ByteBufferInputStream ( ByteBuffer buf ) { this . buf = buf ; } @ Override public synchronized int read ( ) throws IOException { if ( ! buf . hasRemaining ( ) ) { return - <NUM_LIT:1> ; } int c = buf . get ( ) & <NUM_LIT> ; return c ; } @ Override public synchronized int read ( byte [ ] bytes , int off , int len ) throws IOException { if ( ! buf . hasRemaining ( ) ) { return - <NUM_LIT:1> ; } len = Math . min ( len , buf . remaining ( ) ) ; buf . get ( bytes , off , len ) ; return len ; } @ Override public int available ( ) throws IOException { return buf . remaining ( ) ; } } private LineNumberFilter filter ; private String parsedItem = null ; public XMLParser ( ) { try { SAXParserFactory saxParserFactory = SAXParserFactory . newInstance ( ) ; saxParserFactory . setNamespaceAware ( true ) ; saxParserFactory . setXIncludeAware ( true ) ; XMLReader xmlReader = saxParserFactory . newSAXParser ( ) . getXMLReader ( ) ; filter = new LineNumberFilter ( xmlReader ) ; } catch ( ParserConfigurationException e ) { throw new XMLException ( e ) ; } catch ( SAXException e ) { throw new XMLException ( e ) ; } } private IXMLElement searchFirstElement ( DOMResult domResult ) { for ( Node child = domResult . getNode ( ) . getFirstChild ( ) ; child != null ; child = child . getNextSibling ( ) ) { if ( child . getNodeType ( ) == Node . ELEMENT_NODE ) { return new XMLElementImpl ( child ) ; } } return null ; } private DOMResult parseLineNrFromInputSource ( InputSource inputSource ) { DOMResult result = null ; try { result = new DOMResult ( ) ; SAXSource source = new SAXSource ( inputSource ) ; source . setXMLReader ( filter ) ; URL xslResourceUrl = IXMLParser . class . getResource ( XSL_FILE_NAME ) ; if ( xslResourceUrl == null ) { throw new XMLException ( "<STR_LIT>" + XSL_FILE_NAME + "<STR_LIT:\">" ) ; } Source xsltSource = new StreamSource ( xslResourceUrl . openStream ( ) ) ; Transformer xformer = TransformerFactory . newInstance ( ) . newTransformer ( xsltSource ) ; xformer . transform ( source , result ) ; filter . applyLN ( result ) ; } catch ( TransformerException e ) { String extraInfos = null ; if ( this . parsedItem != null ) { extraInfos = "<STR_LIT>" + parsedItem ; } if ( e . getLocator ( ) == null && filter . getDocumentLocator ( ) != null ) { Locator locator = filter . getDocumentLocator ( ) ; extraInfos += "<STR_LIT>" + locator . getLineNumber ( ) + "<STR_LIT>" + locator . getColumnNumber ( ) ; } if ( extraInfos != null ) { throw new XMLException ( "<STR_LIT>" + extraInfos + "<STR_LIT:U+0020:U+0020>" + e . getMessage ( ) , e ) ; } throw new XMLException ( e ) ; } catch ( IOException e ) { throw new XMLException ( e ) ; } finally { this . parsedItem = null ; } return result ; } public IXMLElement parse ( InputStream inputStream ) { checkNotNullStream ( inputStream ) ; this . parsedItem = null ; InputSource inputSource = new InputSource ( inputStream ) ; DOMResult result = parseLineNrFromInputSource ( inputSource ) ; return searchFirstElement ( result ) ; } public IXMLElement parse ( InputStream inputStream , String systemId ) { checkNotNullStream ( inputStream ) ; this . parsedItem = systemId ; InputSource inputSource = new InputSource ( inputStream ) ; inputSource . setSystemId ( systemId ) ; DOMResult result = parseLineNrFromInputSource ( inputSource ) ; return searchFirstElement ( result ) ; } public IXMLElement parse ( String inputString ) { this . parsedItem = null ; final ByteBuffer buf = Charset . forName ( "<STR_LIT:UTF-8>" ) . encode ( inputString ) ; return parse ( new ByteBufferInputStream ( buf ) ) ; } public IXMLElement parse ( URL inputURL ) { this . parsedItem = inputURL . toString ( ) ; InputSource inputSource = new InputSource ( inputURL . toExternalForm ( ) ) ; DOMResult domResult = parseLineNrFromInputSource ( inputSource ) ; return searchFirstElement ( domResult ) ; } private void checkNotNullStream ( InputStream inputStream ) { if ( inputStream == null ) { throw new NullPointerException ( "<STR_LIT>" ) ; } } } </s>
<s> package com . izforge . izpack . api . adaptator . impl ; import com . izforge . izpack . api . adaptator . IXMLElement ; import org . w3c . dom . * ; import javax . xml . parsers . DocumentBuilder ; import javax . xml . parsers . DocumentBuilderFactory ; import javax . xml . parsers . ParserConfigurationException ; import java . util . ArrayList ; import java . util . Enumeration ; import java . util . List ; import java . util . Properties ; import java . util . regex . Pattern ; public class XMLElementImpl implements IXMLElement { private Element element ; private boolean hasChanged = true ; private List < IXMLElement > childrenList ; public XMLElementImpl ( String name ) { Document document ; try { DocumentBuilderFactory documentFactory = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder constructeur = documentFactory . newDocumentBuilder ( ) ; document = constructeur . newDocument ( ) ; document . setXmlVersion ( "<STR_LIT:1.0>" ) ; element = document . createElement ( name ) ; document . appendChild ( element ) ; } catch ( ParserConfigurationException e ) { e . printStackTrace ( ) ; } } public XMLElementImpl ( String name , Document inDocument ) { element = inDocument . createElement ( name ) ; } public XMLElementImpl ( String name , IXMLElement elementReference ) { element = elementReference . getElement ( ) . getOwnerDocument ( ) . createElement ( name ) ; } public XMLElementImpl ( Node node ) { if ( ! ( node instanceof Element ) ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } this . element = ( Element ) node ; } public String getName ( ) { return element . getNodeName ( ) ; } public void addChild ( IXMLElement child ) { hasChanged = true ; element . appendChild ( child . getElement ( ) ) ; } public void removeChild ( IXMLElement child ) { hasChanged = true ; element . removeChild ( child . getElement ( ) ) ; } public boolean hasChildren ( ) { for ( Node child = element . getFirstChild ( ) ; child != null ; child = child . getNextSibling ( ) ) { if ( child . getNodeType ( ) == Node . ELEMENT_NODE ) { return true ; } } return false ; } private void initChildrenList ( ) { if ( hasChanged ) { hasChanged = false ; childrenList = new ArrayList < IXMLElement > ( ) ; for ( Node child = element . getFirstChild ( ) ; child != null ; child = child . getNextSibling ( ) ) { if ( child . getNodeType ( ) == Node . ELEMENT_NODE ) { childrenList . add ( new XMLElementImpl ( child ) ) ; } } } } public int getChildrenCount ( ) { initChildrenList ( ) ; return childrenList . size ( ) ; } public List < IXMLElement > getChildren ( ) { initChildrenList ( ) ; return childrenList ; } public IXMLElement getChildAtIndex ( int index ) { initChildrenList ( ) ; return childrenList . get ( index ) ; } public IXMLElement getFirstChildNamed ( String name ) { XMLElementImpl res = null ; NodeList nodeList = element . getElementsByTagName ( name ) ; if ( nodeList . getLength ( ) > <NUM_LIT:0> ) { res = new XMLElementImpl ( nodeList . item ( <NUM_LIT:0> ) ) ; } return res ; } public List < IXMLElement > getChildrenNamed ( String name ) { List < IXMLElement > res = new ArrayList < IXMLElement > ( ) ; for ( IXMLElement child : getChildren ( ) ) { if ( child . getName ( ) != null && child . getName ( ) . equals ( name ) ) { res . add ( new XMLElementImpl ( child . getElement ( ) ) ) ; } } return res ; } public String getAttribute ( String name ) { return this . getAttribute ( name , null ) ; } public String getAttribute ( String name , String defaultValue ) { Node attribute = element . getAttributes ( ) . getNamedItem ( name ) ; if ( attribute != null ) { return attribute . getNodeValue ( ) ; } return defaultValue ; } public void setAttribute ( String name , String value ) { NamedNodeMap attributes = element . getAttributes ( ) ; Attr attribute = element . getOwnerDocument ( ) . createAttribute ( name ) ; attribute . setValue ( value ) ; attributes . setNamedItem ( attribute ) ; } public void removeAttribute ( String name ) { this . element . getAttributes ( ) . removeNamedItem ( name ) ; } public Enumeration enumerateAttributeNames ( ) { NamedNodeMap namedNodeMap = element . getAttributes ( ) ; Properties properties = new Properties ( ) ; for ( int i = <NUM_LIT:0> ; i < namedNodeMap . getLength ( ) ; i ++ ) { Node node = namedNodeMap . item ( i ) ; properties . put ( node . getNodeName ( ) , node . getNodeValue ( ) ) ; } return properties . keys ( ) ; } public boolean hasAttribute ( String name ) { return ( this . element . getAttributes ( ) . getNamedItem ( name ) != null ) ; } public Properties getAttributes ( ) { Properties properties = new Properties ( ) ; NamedNodeMap namedNodeMap = this . element . getAttributes ( ) ; for ( int i = <NUM_LIT:0> ; i < namedNodeMap . getLength ( ) ; ++ i ) { properties . put ( namedNodeMap . item ( i ) . getNodeName ( ) , namedNodeMap . item ( i ) . getNodeValue ( ) ) ; } return properties ; } public int getLineNr ( ) { Object ln = element . getUserData ( "<STR_LIT>" ) ; if ( ln == null ) { return NO_LINE ; } try { return ( Integer ) element . getUserData ( "<STR_LIT>" ) ; } catch ( ClassCastException e ) { return NO_LINE ; } } public String getContent ( ) { StringBuilder builder = new StringBuilder ( ) ; String content ; Node child = this . element . getFirstChild ( ) ; boolean err = ( child == null ) ; Pattern pattern = Pattern . compile ( "<STR_LIT>" ) ; while ( ! err && child != null ) { content = child . getNodeValue ( ) ; if ( child . getNodeType ( ) == Node . TEXT_NODE ) { if ( content != null && ! pattern . matcher ( content ) . matches ( ) ) { builder . append ( content ) ; } } else if ( child . getNodeType ( ) == Node . CDATA_SECTION_NODE ) { builder . append ( content ) ; } else { err = true ; } child = child . getNextSibling ( ) ; } return ( err ) ? null : builder . toString ( ) . trim ( ) ; } public void setContent ( String content ) { Node child ; while ( ( child = this . element . getFirstChild ( ) ) != null ) { this . element . removeChild ( child ) ; } element . appendChild ( element . getOwnerDocument ( ) . createTextNode ( content ) ) ; } public Node getElement ( ) { return element ; } @ Override public String toString ( ) { return element . getNodeName ( ) + "<STR_LIT:U+0020>" + element . getNodeValue ( ) ; } @ Override public boolean equals ( Object obj ) { if ( obj instanceof IXMLElement ) { IXMLElement o = ( IXMLElement ) obj ; Element elem = ( Element ) o . getElement ( ) ; Node child2 = elem . getFirstChild ( ) ; for ( Node child = element . getFirstChild ( ) ; child != null && child2 != null ; child = child . getNextSibling ( ) ) { if ( ! child . equals ( child2 ) ) { return false ; } child2 . getNextSibling ( ) ; } return true ; } return false ; } @ Override public int hashCode ( ) { int hashCode = <NUM_LIT:0> ; for ( Node child = element . getFirstChild ( ) ; child != null ; child = child . getNextSibling ( ) ) { hashCode += child . hashCode ( ) ; } return hashCode ; } } </s>
<s> package com . izforge . izpack . api . adaptator ; import com . izforge . izpack . api . exception . IzPackException ; public class XMLException extends IzPackException { public XMLException ( String message ) { super ( message ) ; } public XMLException ( String message , Throwable cause ) { super ( message , cause ) ; } public XMLException ( Throwable cause ) { super ( cause ) ; } } </s>
<s> package com . izforge . izpack . api . adaptator ; import org . w3c . dom . Node ; import java . io . Serializable ; import java . util . Enumeration ; import java . util . List ; import java . util . Properties ; public interface IXMLElement extends Serializable { int NO_LINE = - <NUM_LIT:1> ; String getName ( ) ; void addChild ( IXMLElement child ) ; void removeChild ( IXMLElement child ) ; boolean hasChildren ( ) ; int getChildrenCount ( ) ; List < IXMLElement > getChildren ( ) ; IXMLElement getChildAtIndex ( int index ) throws ArrayIndexOutOfBoundsException ; IXMLElement getFirstChildNamed ( String name ) ; List < IXMLElement > getChildrenNamed ( String name ) ; String getAttribute ( String name ) ; String getAttribute ( String name , String defaultValue ) ; void setAttribute ( String name , String value ) ; void removeAttribute ( String name ) ; Enumeration enumerateAttributeNames ( ) ; boolean hasAttribute ( String name ) ; Properties getAttributes ( ) ; int getLineNr ( ) ; String getContent ( ) ; void setContent ( String content ) ; Node getElement ( ) ; } </s>
<s> package com . izforge . izpack . api . data ; import java . io . Serializable ; import com . izforge . izpack . api . substitutor . VariableSubstitutor ; public interface ValueFilter extends Serializable { String filter ( String value , VariableSubstitutor ... substitutors ) throws Exception ; void validate ( ) throws Exception ; } </s>
<s> package com . izforge . izpack . api . data ; import com . izforge . izpack . api . substitutor . VariableSubstitutor ; public interface Value { void validate ( ) throws Exception ; String resolve ( ) throws Exception ; String resolve ( VariableSubstitutor ... substitutors ) throws Exception ; InstallData getInstallData ( ) ; void setInstallData ( InstallData installData ) ; } </s>
<s> package com . izforge . izpack . api . data ; public enum PackColor { WHITE , GREY , BLACK } </s>
<s> package com . izforge . izpack . api . data ; import java . io . Serializable ; import java . util . ArrayList ; import java . util . HashSet ; import java . util . Set ; public class Info implements Serializable { static final long serialVersionUID = <NUM_LIT> ; public static final int REBOOT_ACTION_IGNORE = <NUM_LIT:0> ; public static final int REBOOT_ACTION_NOTICE = <NUM_LIT:1> ; public static final int REBOOT_ACTION_ASK = <NUM_LIT:2> ; public static final int REBOOT_ACTION_ALWAYS = <NUM_LIT:3> ; private String appName = "<STR_LIT>" ; private String appVersion = "<STR_LIT>" ; private String installationSubPath = null ; private ArrayList < Author > authors = new ArrayList < Author > ( ) ; private String appURL = null ; private String javaVersion = "<STR_LIT>" ; private boolean jdkRequired = false ; private String installerBase = null ; private String webDirURL = null ; private String uninstallerName = "<STR_LIT>" ; private String uninstallerPath = "<STR_LIT>" ; private String uninstallerCondition = null ; private String summaryLogFilePath = "<STR_LIT>" ; private String packDecoderClassName = null ; private String unpackerClassName = null ; private boolean writeInstallationInformation = true ; private boolean pack200Compression ; private boolean requirePrivilegedExecution = false ; private boolean requirePrivilegedExecutionUninstaller = false ; private String privilegedExecutionConditionID = null ; private int rebootAction = REBOOT_ACTION_IGNORE ; private String rebootActionConditionID = null ; private Set < TempDir > tempdirs ; public boolean isPrivilegedExecutionRequired ( ) { return requirePrivilegedExecution ; } public void setRequirePrivilegedExecution ( boolean requirePrivilegedExecution ) { this . requirePrivilegedExecution = requirePrivilegedExecution ; } public boolean isPrivilegedExecutionRequiredUninstaller ( ) { return requirePrivilegedExecutionUninstaller ; } public void setRequirePrivilegedExecutionUninstaller ( boolean required ) { this . requirePrivilegedExecutionUninstaller = required ; } public String getPrivilegedExecutionConditionID ( ) { return privilegedExecutionConditionID ; } public void setPrivilegedExecutionConditionID ( String privilegedExecutionConditionID ) { this . privilegedExecutionConditionID = privilegedExecutionConditionID ; } public int getRebootAction ( ) { return rebootAction ; } public void setRebootAction ( int rebootAction ) { this . rebootAction = rebootAction ; } public String getRebootActionConditionID ( ) { return rebootActionConditionID ; } public void setRebootActionConditionID ( String rebootActionConditionID ) { this . rebootActionConditionID = rebootActionConditionID ; } public Info ( ) { } public void setAppName ( String appName ) { this . appName = appName ; } public String getAppName ( ) { return appName ; } public void setAppVersion ( String appVersion ) { this . appVersion = appVersion ; } public String getAppVersion ( ) { return appVersion ; } public void addAuthor ( Author author ) { authors . add ( author ) ; } public ArrayList < Author > getAuthors ( ) { return authors ; } public void setAppURL ( String appURL ) { this . appURL = appURL ; } public String getAppURL ( ) { return appURL ; } public void setJavaVersion ( String javaVersion ) { this . javaVersion = javaVersion ; } public String getJavaVersion ( ) { return javaVersion ; } public void setInstallerBase ( String installerBase ) { this . installerBase = installerBase ; } public String getInstallerBase ( ) { return installerBase ; } public void setWebDirURL ( String url ) { this . webDirURL = url ; } public String getWebDirURL ( ) { return webDirURL ; } public void setUninstallerName ( String name ) { this . uninstallerName = name ; } public String getUninstallerName ( ) { return this . uninstallerName ; } public void setUninstallerPath ( String path ) { this . uninstallerPath = path ; } public String getUninstallerPath ( ) { return this . uninstallerPath ; } public boolean isJdkRequired ( ) { return jdkRequired ; } public void setJdkRequired ( boolean jdkRequired ) { this . jdkRequired = jdkRequired ; } public void setPack200Compression ( boolean pack200Support ) { this . pack200Compression = pack200Support ; } public boolean isPack200Compression ( ) { return pack200Compression ; } public static class Author implements Serializable { static final long serialVersionUID = - <NUM_LIT> ; private String name ; private String email ; public String getName ( ) { return name ; } public String getEmail ( ) { return email ; } public Author ( String name , String email ) { this . name = name ; this . email = email ; } public String toString ( ) { return name + "<STR_LIT>" + email + "<STR_LIT:>>" ; } } public static class TempDir implements Serializable { private final String prefix ; private final String suffix ; private final String variableName ; public TempDir ( String variableName , String prefix , String suffix ) { this . variableName = variableName ; this . prefix = prefix ; this . suffix = suffix ; } public String getPrefix ( ) { return prefix ; } public String getSuffix ( ) { return suffix ; } public String getVariableName ( ) { return variableName ; } } public String getInstallationSubPath ( ) { return installationSubPath ; } public void setInstallationSubPath ( String installationSubPath ) { this . installationSubPath = installationSubPath ; } public String getSummaryLogFilePath ( ) { return summaryLogFilePath ; } public void setSummaryLogFilePath ( String summaryLogFilePath ) { this . summaryLogFilePath = summaryLogFilePath ; } public String getPackDecoderClassName ( ) { return packDecoderClassName ; } public void setPackDecoderClassName ( String packDecoderClassName ) { this . packDecoderClassName = packDecoderClassName ; } public String getUnpackerClassName ( ) { return unpackerClassName ; } public void setUnpackerClassName ( String unpackerClassName ) { this . unpackerClassName = unpackerClassName ; } public boolean isWriteInstallationInformation ( ) { return writeInstallationInformation ; } public void setWriteInstallationInformation ( boolean writeInstallationInformation ) { this . writeInstallationInformation = writeInstallationInformation ; } public String getUninstallerCondition ( ) { return uninstallerCondition ; } public void setUninstallerCondition ( String uninstallerCondition ) { this . uninstallerCondition = uninstallerCondition ; } public void addTempDir ( TempDir tempDir ) { if ( null == tempdirs ) { tempdirs = new HashSet < TempDir > ( ) ; } tempdirs . add ( tempDir ) ; } public Set < TempDir > getTempDirs ( ) { return tempdirs ; } } </s>
<s> package com . izforge . izpack . api . data ; import java . util . Properties ; import com . izforge . izpack . api . exception . IzPackException ; public interface Variables { void set ( String name , String value ) ; String get ( String name ) ; String get ( String name , String defaultValue ) ; boolean getBoolean ( String name ) ; boolean getBoolean ( String name , boolean defaultValue ) ; int getInt ( String name ) ; int getInt ( String name , int defaultValue ) ; long getLong ( String name ) ; long getLong ( String name , long defaultValue ) ; String replace ( String value ) ; void add ( DynamicVariable variable ) ; void refresh ( ) ; Properties getProperties ( ) ; } </s>
<s> package com . izforge . izpack . api . data ; import java . io . Serializable ; import java . util . HashMap ; import java . util . Map ; public class PanelActionConfiguration implements Serializable { private String actionClassName ; private Map < String , String > properties ; public PanelActionConfiguration ( String actionClassName ) { this . actionClassName = actionClassName ; this . properties = new HashMap < String , String > ( ) ; } public String getActionClassName ( ) { return actionClassName ; } public void addProperty ( String key , String value ) { this . properties . put ( key , value ) ; } public String getProperty ( String key ) { return this . properties . get ( key ) ; } public String getProperty ( String key , String defaultValue ) { String result = getProperty ( key ) ; if ( result == null ) { result = defaultValue ; } return result ; } public Map < String , String > getProperties ( ) { return properties ; } public void setProperties ( Map < String , String > properties ) { this . properties = properties ; } } </s>
<s> package com . izforge . izpack . api . data ; import java . util . EnumSet ; import java . util . HashMap ; import java . util . Map ; public enum LookAndFeels { LIQUID ( "<STR_LIT>" ) , LOOKS ( "<STR_LIT>" ) , SUBSTANCE ( "<STR_LIT>" ) , NIMBUS ( "<STR_LIT>" ) , KUNSTSTOFF ( "<STR_LIT>" ) ; private String name ; private static Map < String , LookAndFeels > lookup ; static { lookup = new HashMap < String , LookAndFeels > ( ) ; EnumSet < LookAndFeels > enumSet = EnumSet . allOf ( LookAndFeels . class ) ; for ( LookAndFeels elem : enumSet ) { lookup . put ( elem . name , elem ) ; } } LookAndFeels ( String name ) { this . name = name ; } public static LookAndFeels lookup ( String laf ) { if ( lookup . containsKey ( laf ) ) { return lookup . get ( laf ) ; } return null ; } } </s>
<s> package com . izforge . izpack . api . data ; import java . io . Serializable ; import java . util . Map ; import java . util . TreeMap ; public class GUIPrefs implements Serializable { static final long serialVersionUID = - <NUM_LIT> ; public boolean resizable ; public int width ; public int height ; public Map < String , String > lookAndFeelMapping = new TreeMap < String , String > ( ) ; public Map < String , Map < String , String > > lookAndFeelParams = new TreeMap < String , Map < String , String > > ( ) ; public Map < String , String > modifier = new TreeMap < String , String > ( ) ; } </s>
<s> package com . izforge . izpack . api . data ; import com . izforge . izpack . api . installer . DataValidator ; public interface DynamicInstallerRequirementValidator extends DataValidator { @ Override public Status validateData ( InstallData idata ) ; @ Override public String getErrorMessageId ( ) ; @ Override public String getWarningMessageId ( ) ; @ Override public boolean getDefaultAnswer ( ) ; } </s>
<s> package com . izforge . izpack . api . data ; import java . io . Serializable ; import java . util . ArrayList ; import java . util . Collections ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import com . izforge . izpack . api . data . binding . Action ; import com . izforge . izpack . api . data . binding . Help ; import com . izforge . izpack . api . data . binding . OsModel ; public class Panel implements Serializable { static final long serialVersionUID = <NUM_LIT> ; private String className ; private List < OsModel > osConstraints = Collections . emptyList ( ) ; private String panelId ; private String condition ; private String validator = null ; private List < Action > actions ; private List < PanelActionConfiguration > preConstructionActions = null ; private List < PanelActionConfiguration > preActivationActions = null ; private List < PanelActionConfiguration > preValidationActions = null ; private List < PanelActionConfiguration > postValidationActions = null ; private List < Help > helps = null ; private Map < String , String > configuration = null ; public String getClassName ( ) { return this . className ; } public void setClassName ( String className ) { this . className = className ; } public String getPanelId ( ) { if ( panelId == null ) { panelId = "<STR_LIT>" + className + "<STR_LIT:)>" ; } return panelId ; } public void setPanelId ( String panelId ) { this . panelId = panelId ; } @ Deprecated public String getPanelid ( ) { return getPanelId ( ) ; } @ Deprecated public void setPanelid ( String panelId ) { setPanelId ( panelId ) ; } public String getCondition ( ) { return this . condition ; } public void setCondition ( String condition ) { this . condition = condition ; } public boolean hasCondition ( ) { return this . condition != null ; } public String getValidator ( ) { return validator ; } public void setValidator ( String validator ) { this . validator = validator ; } public List < Help > getHelps ( ) { return helps ; } public void setHelps ( List < Help > helps ) { this . helps = helps ; } public List < PanelActionConfiguration > getPreConstructionActions ( ) { return preConstructionActions ; } public void addPreConstructionAction ( PanelActionConfiguration action ) { if ( this . preConstructionActions == null ) { this . preConstructionActions = new ArrayList < PanelActionConfiguration > ( ) ; } this . preConstructionActions . add ( action ) ; } public List < PanelActionConfiguration > getPreActivationActions ( ) { return preActivationActions ; } public void addPreActivationAction ( PanelActionConfiguration action ) { if ( this . preActivationActions == null ) { this . preActivationActions = new ArrayList < PanelActionConfiguration > ( ) ; } this . preActivationActions . add ( action ) ; } public List < PanelActionConfiguration > getPreValidationActions ( ) { return preValidationActions ; } public void addPreValidationAction ( PanelActionConfiguration action ) { if ( this . preValidationActions == null ) { this . preValidationActions = new ArrayList < PanelActionConfiguration > ( ) ; } this . preValidationActions . add ( action ) ; } public List < PanelActionConfiguration > getPostValidationActions ( ) { return postValidationActions ; } public void addPostValidationAction ( PanelActionConfiguration action ) { if ( this . postValidationActions == null ) { this . postValidationActions = new ArrayList < PanelActionConfiguration > ( ) ; } this . postValidationActions . add ( action ) ; } public boolean hasConfiguration ( ) { return this . configuration != null ; } public void addConfiguration ( String key , String value ) { if ( this . configuration == null ) { this . configuration = new HashMap < String , String > ( ) ; } this . configuration . put ( key , value ) ; } public String getConfiguration ( String key ) { String result = null ; if ( this . configuration != null ) { result = this . configuration . get ( key ) ; } return result ; } public List < OsModel > getOsConstraints ( ) { return osConstraints ; } public void setOsConstraints ( List < OsModel > osConstraints ) { this . osConstraints = osConstraints ; } public String getHelpUrl ( String localeISO3 ) { if ( helps == null ) { return null ; } for ( Help help : helps ) { if ( help . getIso3 ( ) . equals ( localeISO3 ) ) { return help . getSrc ( ) ; } } return null ; } public List < Action > getActions ( ) { return actions ; } public void setActions ( List < Action > actions ) { this . actions = actions ; } @ Override public String toString ( ) { return "<STR_LIT>" + "<STR_LIT>" + className + '<STR_LIT>' + "<STR_LIT>" + osConstraints + "<STR_LIT>" + panelId + '<STR_LIT>' + "<STR_LIT>" + condition + '<STR_LIT>' + "<STR_LIT>" + actions + "<STR_LIT>" + validator + '<STR_LIT>' + "<STR_LIT>" + helps + '<CHAR_LIT:}>' ; } } </s>
<s> package com . izforge . izpack . api . data ; import java . io . InputStream ; import java . text . MessageFormat ; import java . util . Collections ; import java . util . Map ; import java . util . TreeMap ; import java . util . logging . Level ; import java . util . logging . Logger ; import com . izforge . izpack . api . adaptator . IXMLElement ; import com . izforge . izpack . api . adaptator . IXMLParser ; import com . izforge . izpack . api . adaptator . XMLException ; import com . izforge . izpack . api . adaptator . impl . XMLParser ; import com . izforge . izpack . api . exception . ResourceException ; import com . izforge . izpack . api . resource . Locales ; import com . izforge . izpack . api . resource . Messages ; public class LocaleDatabase extends TreeMap < String , String > implements Messages { @ Deprecated public static final String LOCALE_DATABASE_DIRECTORY = "<STR_LIT>" ; @ Deprecated public static final String LOCALE_DATABASE_DEF_SUFFIX = "<STR_LIT>" ; private static final char TEMP_QUOTING_CHARACTER = '<STR_LIT>' ; private final Messages parent ; private final Locales locales ; private static final Logger logger = Logger . getLogger ( LocaleDatabase . class . getName ( ) ) ; public LocaleDatabase ( InputStream in , Locales locales ) { this ( in , null , locales ) ; } public LocaleDatabase ( Messages parent , Locales locales ) { this ( null , parent , locales ) ; } public LocaleDatabase ( InputStream in , Messages parent , Locales locales ) { this . parent = parent ; this . locales = locales ; if ( in != null ) { add ( in ) ; } } public void add ( InputStream in ) { IXMLElement data ; try { IXMLParser parser = new XMLParser ( ) ; data = parser . parse ( in ) ; } catch ( XMLException exception ) { throw new ResourceException ( "<STR_LIT>" , exception ) ; } if ( ! "<STR_LIT>" . equalsIgnoreCase ( data . getElement ( ) . getLocalName ( ) ) ) { throw new ResourceException ( "<STR_LIT>" ) ; } for ( IXMLElement child : data . getChildren ( ) ) { String text = child . getContent ( ) ; if ( text != null && ! "<STR_LIT>" . equals ( text ) ) { put ( child . getAttribute ( "<STR_LIT:id>" ) , text . trim ( ) ) ; } else { put ( child . getAttribute ( "<STR_LIT:id>" ) , child . getAttribute ( "<STR_LIT>" ) ) ; } } } @ Override public String get ( Object id ) { String result = super . get ( id ) ; return result != null ? result : id . toString ( ) ; } @ Override public String get ( String id , Object ... args ) { String result ; String pattern = super . get ( id ) ; if ( pattern != null ) { if ( args . length > <NUM_LIT:0> ) { try { pattern = pattern . replace ( '<STR_LIT>' , TEMP_QUOTING_CHARACTER ) ; pattern = MessageFormat . format ( pattern , args ) ; result = MessageFormat . format ( pattern , args ) ; result = result . replace ( TEMP_QUOTING_CHARACTER , '<STR_LIT>' ) ; } catch ( IllegalArgumentException exception ) { result = id ; logger . log ( Level . WARNING , "<STR_LIT>" + pattern + "<STR_LIT>" + id , exception ) ; } } else { result = pattern ; } } else if ( parent != null ) { result = parent . get ( id , args ) ; } else { result = id ; } return result ; } @ Override public void add ( Messages messages ) { putAll ( messages . getMessages ( ) ) ; } @ Override public Map < String , String > getMessages ( ) { return Collections . unmodifiableMap ( this ) ; } @ Override public Messages newMessages ( String name ) { Messages child = locales . getMessages ( name ) ; Messages result = new LocaleDatabase ( this , locales ) ; result . add ( child ) ; return result ; } @ Deprecated public String getString ( String key ) { String val = get ( key ) ; if ( val == null ) { val = key ; } return val ; } public String getString ( String key , String [ ] variables ) { for ( int i = <NUM_LIT:0> ; i < variables . length ; ++ i ) { if ( variables [ i ] == null ) { variables [ i ] = "<STR_LIT>" ; } else if ( variables [ i ] . startsWith ( "<STR_LIT:$>" ) ) { String curArg = variables [ i ] ; if ( curArg . startsWith ( "<STR_LIT>" ) ) { curArg = curArg . substring ( <NUM_LIT:2> , curArg . length ( ) - <NUM_LIT:1> ) ; } else { curArg = curArg . substring ( <NUM_LIT:1> ) ; } variables [ i ] = get ( curArg ) ; } } String message = get ( key ) ; message = message . replace ( '<STR_LIT>' , TEMP_QUOTING_CHARACTER ) ; message = MessageFormat . format ( message , ( Object [ ] ) variables ) ; return message . replace ( TEMP_QUOTING_CHARACTER , '<STR_LIT>' ) ; } } </s>
<s> package com . izforge . izpack . api . data ; import com . izforge . izpack . api . data . binding . OsModel ; import com . izforge . izpack . util . FileUtil ; import java . io . File ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . io . Serializable ; import java . util . List ; import java . util . Map ; public class PackFile implements Serializable { static final long serialVersionUID = - <NUM_LIT> ; public transient String sourcePath = null ; protected String relativePath = null ; private String targetPath = null ; private List < OsModel > osConstraints = null ; private long length = <NUM_LIT:0> ; private transient long size = <NUM_LIT:0> ; private long mtime = - <NUM_LIT:1> ; private boolean isDirectory = false ; private OverrideType override ; private String overrideRenameTo ; private Blockable blockable = Blockable . BLOCKABLE_NONE ; private Map additionals = null ; public String previousPackId = null ; public long offsetInPreviousPack = - <NUM_LIT:1> ; private boolean pack200Jar = false ; private String condition = null ; public PackFile ( File baseDir , File src , String target , List < OsModel > osList , OverrideType override , String overrideRenameTo , Blockable blockable ) throws IOException { this ( src , FileUtil . getRelativeFileName ( src , baseDir ) , target , osList , override , overrideRenameTo , blockable , null ) ; } public PackFile ( File src , String relativeSourcePath , String target , List < OsModel > osList , OverrideType override , String overrideRenameTo , Blockable blockable , Map additionals ) throws FileNotFoundException { if ( ! src . exists ( ) ) { throw new FileNotFoundException ( "<STR_LIT>" + src ) ; } if ( '<CHAR_LIT:/>' != File . separatorChar ) { target = target . replace ( File . separatorChar , '<CHAR_LIT:/>' ) ; } if ( target . endsWith ( "<STR_LIT:/>" ) ) { target = target . substring ( <NUM_LIT:0> , target . length ( ) - <NUM_LIT:1> ) ; } this . sourcePath = src . getPath ( ) . replace ( File . separatorChar , '<CHAR_LIT:/>' ) ; this . relativePath = ( relativeSourcePath != null ) ? relativeSourcePath . replace ( File . separatorChar , '<CHAR_LIT:/>' ) : relativeSourcePath ; this . targetPath = ( target != null ) ? target . replace ( File . separatorChar , '<CHAR_LIT:/>' ) : target ; this . osConstraints = osList ; this . override = override ; this . overrideRenameTo = overrideRenameTo ; this . blockable = blockable ; this . length = src . length ( ) ; this . size = this . length ; this . mtime = src . lastModified ( ) ; this . isDirectory = src . isDirectory ( ) ; this . additionals = additionals ; if ( isDirectory ) { length = <NUM_LIT:0> ; } } public PackFile ( File baseDir , File src , String target , List < OsModel > osList , OverrideType override , String overrideRenameTo , Blockable blockable , Map additionals ) throws IOException { this ( src , FileUtil . getRelativeFileName ( src , baseDir ) , target , osList , override , overrideRenameTo , blockable , additionals ) ; } public void setPreviousPackFileRef ( String previousPackId , Long offsetInPreviousPack ) { this . previousPackId = previousPackId ; this . offsetInPreviousPack = offsetInPreviousPack ; } public final List < OsModel > osConstraints ( ) { return osConstraints ; } public final long length ( ) { return length ; } public final long size ( ) { return size ; } public final long lastModified ( ) { return mtime ; } public final OverrideType override ( ) { return override ; } public final String overrideRenameTo ( ) { return overrideRenameTo ; } public final Blockable blockable ( ) { return blockable ; } public final boolean isDirectory ( ) { return isDirectory ; } public final boolean isBackReference ( ) { return ( previousPackId != null ) ; } public final String getTargetPath ( ) { return targetPath ; } public String getRelativeSourcePath ( ) { return relativePath ; } public Map getAdditionals ( ) { return additionals ; } public String getCondition ( ) { return this . condition ; } public void setCondition ( String condition ) { this . condition = condition ; } public boolean hasCondition ( ) { return this . condition != null ; } public boolean isPack200Jar ( ) { return pack200Jar ; } public void setPack200Jar ( boolean pack200Jar ) { this . pack200Jar = pack200Jar ; } public void setLoosePackInfo ( boolean loose ) { if ( loose ) { length = <NUM_LIT:0> ; } } } </s>
<s> package com . izforge . izpack . api . data . binding ; public enum Stage { install , uninstall , compiler ; public static boolean isInInstaller ( Stage stage ) { return uninstall . equals ( stage ) || install . equals ( stage ) ; } } </s>
<s> package com . izforge . izpack . api . data . binding ; import java . io . Serializable ; public class Action implements Serializable { private static final long serialVersionUID = <NUM_LIT:1L> ; private String classname ; private ActionStage actionStage ; public Action ( String classname , ActionStage actionStage ) { this . classname = classname ; this . actionStage = actionStage ; } public String getClassname ( ) { return classname ; } public ActionStage getActionStage ( ) { return actionStage ; } } </s>
<s> package com . izforge . izpack . api . data . binding ; public enum ActionStage { PRECONSTRUCT , PREACTIVATE , PREVALIDATE , POSTVALIDATE } </s>
<s> package com . izforge . izpack . api . data . binding ; import java . io . Serializable ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import com . izforge . izpack . api . data . Panel ; public class IzpackProjectInstaller implements Serializable { private List < Listener > listeners = new ArrayList < Listener > ( ) ; private List < Panel > panels ; public void add ( Listener listener ) { this . listeners . add ( listener ) ; } public List < Listener > getListeners ( ) { return listeners ; } public List < Panel > getPanels ( ) { return panels ; } public void fillWithDefault ( ) { if ( listeners == null ) { listeners = Collections . emptyList ( ) ; } } } </s>
<s> package com . izforge . izpack . api . data . binding ; import java . io . Serializable ; import java . util . ArrayList ; import java . util . List ; public class Listener implements Serializable { private String classname ; private Stage stage ; private List < OsModel > os ; private String jar ; private List < String > files ; public Listener ( String classname , Stage stage , List < OsModel > os , String jar ) { this . classname = classname ; this . stage = stage ; this . os = os ; this . jar = jar ; files = new ArrayList < String > ( ) ; } public String getClassname ( ) { return classname ; } public String getJar ( ) { return jar ; } public Stage getStage ( ) { return stage ; } public List < OsModel > getOs ( ) { return os ; } @ Override public String toString ( ) { return "<STR_LIT>" + "<STR_LIT>" + classname + '<STR_LIT>' + "<STR_LIT>" + stage + "<STR_LIT>" + os + '<CHAR_LIT:}>' ; } public List < String > getFiles ( ) { return files ; } public void setFiles ( List < String > files ) { this . files = files ; } } </s>
<s> package com . izforge . izpack . api . data . binding ; import java . io . Serializable ; public class Help implements Serializable { private static final long serialVersionUID = - <NUM_LIT> ; private String iso3 ; private String src ; public Help ( String iso3 , String src ) { this . iso3 = iso3 ; this . src = src ; } public String getIso3 ( ) { return iso3 ; } public void setIso3 ( String iso3 ) { this . iso3 = iso3 ; } public String getSrc ( ) { return src ; } public void setSrc ( String src ) { this . src = src ; } } </s>
<s> package com . izforge . izpack . api . data . binding ; import java . io . Serializable ; public class OsModel implements Serializable { private final String arch ; private final String family ; private final String jre ; private final String name ; private final String version ; public OsModel ( String arch , String family , String jre , String name , String version ) { this . arch = arch ; this . family = family ; this . jre = jre ; this . name = name ; this . version = version ; } public String getArch ( ) { return arch ; } public String getFamily ( ) { return family ; } public String getJre ( ) { return jre ; } public String getName ( ) { return name ; } public String getVersion ( ) { return version ; } @ Override public String toString ( ) { return "<STR_LIT>" + "<STR_LIT>" + arch + '<STR_LIT>' + "<STR_LIT>" + family + '<STR_LIT>' + "<STR_LIT>" + jre + '<STR_LIT>' + "<STR_LIT>" + name + '<STR_LIT>' + "<STR_LIT>" + version + '<STR_LIT>' + '<CHAR_LIT:}>' ; } } </s>
<s> package com . izforge . izpack . api . data ; public class ScriptParserConstant { public static final String JAVA_HOME = "<STR_LIT>" ; public static final String CLASS_PATH = "<STR_LIT>" ; public static final String USER_HOME = "<STR_LIT>" ; public static final String USER_NAME = "<STR_LIT>" ; public static final String HOST_NAME = "<STR_LIT>" ; public static final String IP_ADDRESS = "<STR_LIT>" ; public static final String FILE_SEPARATOR = "<STR_LIT>" ; public static final String APP_NAME = "<STR_LIT>" ; public static final String APP_URL = "<STR_LIT>" ; public static final String APP_VER = "<STR_LIT>" ; public static final String ISO3_LANG = "<STR_LIT>" ; public static final String LOCALE = "<STR_LIT>" ; } </s>
<s> package com . izforge . izpack . api . data ; import java . io . File ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . util . List ; import com . izforge . izpack . api . data . binding . OsModel ; public class XPackFile extends PackFile implements Comparable < XPackFile > { private static final long serialVersionUID = <NUM_LIT> ; private long position ; public XPackFile ( File baseDir , File src , String target , List < OsModel > osList , OverrideType override , String overrideRenameTo , Blockable blockable ) throws IOException { super ( baseDir , src , target , osList , override , overrideRenameTo , blockable ) ; this . position = <NUM_LIT:0> ; } public XPackFile ( PackFile file ) throws FileNotFoundException { super ( new File ( file . sourcePath ) , file . relativePath , file . getTargetPath ( ) , file . osConstraints ( ) , file . override ( ) , file . overrideRenameTo ( ) , file . blockable ( ) , file . getAdditionals ( ) ) ; this . position = <NUM_LIT:0> ; this . setCondition ( file . getCondition ( ) ) ; } public long getArchiveFilePosition ( ) { return position ; } public void setArchiveFilePosition ( long position ) { this . position = position ; } public int compareTo ( XPackFile arg0 ) { return this . getTargetPath ( ) . compareTo ( arg0 . getTargetPath ( ) ) ; } } </s>
<s> package com . izforge . izpack . api . data ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . List ; import java . util . Locale ; import java . util . Map ; import java . util . MissingResourceException ; import com . izforge . izpack . api . adaptator . IXMLElement ; import com . izforge . izpack . api . adaptator . impl . XMLElementImpl ; import com . izforge . izpack . api . event . InstallerListener ; import com . izforge . izpack . api . resource . Messages ; import com . izforge . izpack . api . rules . RulesEngine ; import com . izforge . izpack . util . Platform ; public class AutomatedInstallData implements InstallData { private RulesEngine rules ; private Locale locale ; private Messages messages ; private Info info ; private Platform platform ; private List < Pack > allPacks ; private List < Pack > availablePacks ; private List < Pack > selectedPacks ; private List < Panel > panelsOrder ; private int curPanelNumber ; private boolean canClose = false ; private boolean installSuccess = true ; private boolean rebootNecessary = false ; private IXMLElement xmlData ; private Map < String , List > customData = new HashMap < String , List > ( ) ; private final Variables variables ; private Map < String , List < DynamicVariable > > dynamicvariables ; private List < DynamicInstallerRequirementValidator > dynamicinstallerrequirements ; private List < InstallerRequirement > installerrequirements ; private Map < String , Object > attributes ; public final static String DEFAULT_INSTALL_PATH = "<STR_LIT>" ; public final static String INSTALL_DRIVE = "<STR_LIT>" ; public final static String DEFAULT_INSTALL_DRIVE = "<STR_LIT>" ; private List < InstallerListener > installerListener = new ArrayList < InstallerListener > ( ) ; public AutomatedInstallData ( Variables variables , Platform platform ) { this . variables = variables ; this . platform = platform ; setAvailablePacks ( new ArrayList < Pack > ( ) ) ; setSelectedPacks ( new ArrayList < Pack > ( ) ) ; setPanelsOrder ( new ArrayList < Panel > ( ) ) ; setXmlData ( new XMLElementImpl ( "<STR_LIT>" ) ) ; setAttributes ( new HashMap < String , Object > ( ) ) ; } @ Override public Variables getVariables ( ) { return variables ; } @ Override public void setVariable ( String name , String value ) { variables . set ( name , value ) ; } @ Override public String getVariable ( String name ) { return variables . get ( name ) ; } @ Override public void refreshVariables ( ) { variables . refresh ( ) ; } @ Override public void setInstallPath ( String path ) { setVariable ( INSTALL_PATH , path ) ; } @ Override public String getInstallPath ( ) { return getVariable ( INSTALL_PATH ) ; } @ Override public void setDefaultInstallPath ( String path ) { setVariable ( DEFAULT_INSTALL_PATH , path ) ; } @ Override public String getDefaultInstallPath ( ) { return getVariable ( DEFAULT_INSTALL_PATH ) ; } @ Override public void setMediaPath ( String path ) { setVariable ( MEDIA_PATH , path ) ; } @ Override public String getMediaPath ( ) { return getVariable ( MEDIA_PATH ) ; } @ Override public Object getAttribute ( String name ) { return getAttributes ( ) . get ( name ) ; } @ Override public void setAttribute ( String name , Object value ) { if ( value == null ) { getAttributes ( ) . remove ( name ) ; } else { getAttributes ( ) . put ( name , value ) ; } } @ Deprecated public void setAndProcessLocal ( String locale , LocaleDatabase localeDatabase ) { getXmlData ( ) . setAttribute ( "<STR_LIT>" , locale ) ; setVariable ( ScriptParserConstant . ISO3_LANG , getLocaleISO3 ( ) ) ; setMessages ( localeDatabase ) ; } @ Override public RulesEngine getRules ( ) { return rules ; } public void setRules ( RulesEngine rules ) { this . rules = rules ; } @ Override public String getLocaleISO3 ( ) { String result = null ; try { if ( locale != null ) { result = locale . getISO3Language ( ) ; } } catch ( MissingResourceException exception ) { } return result ; } @ Deprecated public void setLocaleISO3 ( String localeISO3 ) { } @ Override public Locale getLocale ( ) { return locale ; } public void setLocale ( Locale locale ) { this . locale = locale ; String code = locale . getISO3Language ( ) ; getXmlData ( ) . setAttribute ( "<STR_LIT>" , code ) ; setVariable ( ScriptParserConstant . ISO3_LANG , code ) ; } public void setMessages ( Messages messages ) { this . messages = messages ; } @ Override public Messages getMessages ( ) { return messages ; } @ Deprecated public LocaleDatabase getLangpack ( ) { return ( LocaleDatabase ) messages ; } @ Deprecated public void setLangpack ( LocaleDatabase langpack ) { setMessages ( langpack ) ; } @ Override public Info getInfo ( ) { return info ; } public void setInfo ( Info info ) { this . info = info ; } @ Override public Platform getPlatform ( ) { return platform ; } @ Override public List < Pack > getAllPacks ( ) { return allPacks ; } public void setAllPacks ( List < Pack > allPacks ) { this . allPacks = allPacks ; } @ Override public List < Pack > getAvailablePacks ( ) { return availablePacks ; } public void setAvailablePacks ( List < Pack > availablePacks ) { this . availablePacks = availablePacks ; } @ Override public List < Pack > getSelectedPacks ( ) { return selectedPacks ; } @ Override public void setSelectedPacks ( List < Pack > selectedPacks ) { this . selectedPacks = selectedPacks ; } @ Override public List < Panel > getPanelsOrder ( ) { return panelsOrder ; } public void setPanelsOrder ( List < Panel > panelsOrder ) { this . panelsOrder = panelsOrder ; } @ Deprecated public int getCurPanelNumber ( ) { return curPanelNumber ; } @ Deprecated public void setCurPanelNumber ( int curPanelNumber ) { this . curPanelNumber = curPanelNumber ; } @ Override public boolean isCanClose ( ) { return canClose ; } public void setCanClose ( boolean canClose ) { this . canClose = canClose ; } @ Override public boolean isInstallSuccess ( ) { return installSuccess ; } @ Override public void setInstallSuccess ( boolean installSuccess ) { this . installSuccess = installSuccess ; } @ Override public boolean isRebootNecessary ( ) { return rebootNecessary ; } @ Override public void setRebootNecessary ( boolean rebootNecessary ) { this . rebootNecessary = rebootNecessary ; } @ Override public IXMLElement getXmlData ( ) { return xmlData ; } public void setXmlData ( IXMLElement xmlData ) { this . xmlData = xmlData ; } @ Deprecated public Map < String , List > getCustomData ( ) { return customData ; } @ Deprecated public void setCustomData ( Map < String , List > customData ) { this . customData = customData ; } @ Deprecated public void setVariables ( Variables variables ) { } public Map < String , Object > getAttributes ( ) { return attributes ; } public void setAttributes ( Map < String , Object > attributes ) { this . attributes = attributes ; } @ Deprecated public Map < String , List < DynamicVariable > > getDynamicvariables ( ) { return this . dynamicvariables ; } @ Deprecated public void setDynamicvariables ( Map < String , List < DynamicVariable > > dynamicvariables ) { this . dynamicvariables = dynamicvariables ; } public List < DynamicInstallerRequirementValidator > getDynamicInstallerRequirements ( ) { return this . dynamicinstallerrequirements ; } @ Deprecated public List < DynamicInstallerRequirementValidator > getDynamicinstallerrequirements ( ) { return getDynamicInstallerRequirements ( ) ; } public void setDynamicInstallerRequirements ( List < DynamicInstallerRequirementValidator > requirements ) { this . dynamicinstallerrequirements = requirements ; } public void setInstallerRequirements ( List < InstallerRequirement > requirements ) { this . installerrequirements = requirements ; } @ Override public List < InstallerRequirement > getInstallerRequirements ( ) { return installerrequirements ; } @ Deprecated public List < InstallerRequirement > getInstallerrequirements ( ) { return getInstallerRequirements ( ) ; } @ Deprecated public List < InstallerListener > getInstallerListener ( ) { return installerListener ; } @ Deprecated public void setInstallerListener ( List < InstallerListener > installerListener ) { this . installerListener = installerListener ; } } </s>
<s> package com . izforge . izpack . api . data ; import java . io . Serializable ; import java . util . List ; import com . izforge . izpack . api . substitutor . VariableSubstitutor ; public interface DynamicVariable extends Serializable { String getName ( ) ; void setName ( String name ) ; Value getValue ( ) ; void setValue ( Value value ) ; String getConditionid ( ) ; void setConditionid ( String conditionid ) ; void validate ( ) throws Exception ; String evaluate ( VariableSubstitutor ... substitutors ) throws Exception ; void setCheckonce ( boolean checkonce ) ; void setIgnoreFailure ( boolean ignore ) ; void addFilter ( ValueFilter filter ) ; List < ValueFilter > getFilters ( ) ; } </s>
<s> package com . izforge . izpack . api . data ; import java . io . Serializable ; public class InstallerRequirement implements Serializable { private static final long serialVersionUID = <NUM_LIT> ; private String condition ; private String message ; public String getCondition ( ) { return condition ; } public void setCondition ( String condition ) { this . condition = condition ; } public String getMessage ( ) { return message ; } public void setMessage ( String message ) { this . message = message ; } } </s>
<s> package com . izforge . izpack . api . data ; import java . io . Serializable ; import java . text . DecimalFormat ; import java . util . ArrayList ; import java . util . HashSet ; import java . util . List ; import java . util . Set ; import com . izforge . izpack . api . data . binding . OsModel ; public class Pack implements Serializable { private String name ; private String langPackId ; private boolean loose ; private boolean uninstall ; private Set < String > installGroups = new HashSet < String > ( ) ; private String excludeGroup = "<STR_LIT>" ; private String group ; private String description ; private List < OsModel > osConstraints ; private String condition ; private List < String > dependencies ; private List < String > dependants ; private boolean required ; private long size ; private long fileSize ; private boolean preselected ; private String parent ; private String imageId ; private List < String > validators = new ArrayList < String > ( ) ; private boolean hidden ; private final static double KILOBYTES = <NUM_LIT> ; private final static double MEGABYTES = <NUM_LIT> * <NUM_LIT> ; private final static double GIGABYTES = <NUM_LIT> * <NUM_LIT> * <NUM_LIT> ; private final static DecimalFormat formatter = new DecimalFormat ( "<STR_LIT>" ) ; public Pack ( String name , String langPackId , String description , List < OsModel > osConstraints , List < String > dependencies , boolean required , boolean preselected , boolean loose , String excludeGroup , boolean uninstall , long size ) { this . name = name ; this . langPackId = langPackId ; this . description = description ; this . osConstraints = osConstraints ; this . dependencies = dependencies ; this . required = required ; this . preselected = preselected ; this . loose = loose ; this . excludeGroup = excludeGroup ; this . uninstall = uninstall ; this . size = size ; } public String getName ( ) { return name ; } public void setLangPackId ( String langPackId ) { this . langPackId = langPackId ; } public String getLangPackId ( ) { return langPackId ; } public String getDescription ( ) { return description ; } public void setOsConstraints ( List < OsModel > platforms ) { osConstraints = platforms ; } public List < OsModel > getOsConstraints ( ) { return osConstraints ; } public void setDependencies ( List < String > dependencies ) { this . dependencies = dependencies ; } public List < String > getDependencies ( ) { return dependencies ; } public void addDependency ( String name ) { if ( dependencies == null ) { dependencies = new ArrayList < String > ( ) ; } dependencies . add ( name ) ; } public void setDependants ( List < String > dependants ) { this . dependants = dependants ; } public List < String > getDependants ( ) { return dependants ; } public void addDependant ( String name ) { if ( dependants == null ) { dependants = new ArrayList < String > ( ) ; } dependants . add ( name ) ; } public boolean isRequired ( ) { return required ; } public void setPreselected ( boolean preselected ) { this . preselected = preselected ; } public boolean isPreselected ( ) { return preselected ; } public void setLoose ( boolean loose ) { this . loose = loose ; } public boolean isLoose ( ) { return loose ; } public void setExcludeGroup ( String group ) { excludeGroup = group ; } public String getExcludeGroup ( ) { return excludeGroup ; } public boolean isUninstall ( ) { return uninstall ; } public Set < String > getInstallGroups ( ) { return installGroups ; } public void setGroup ( String group ) { this . group = group ; } public String getGroup ( ) { return group ; } public void setSize ( long size ) { this . size = size ; } public long getSize ( ) { return size ; } public void setFileSize ( long size ) { fileSize = size ; } public void addFileSize ( long add ) { fileSize += add ; } public long getFileSize ( ) { return fileSize ; } public void setParent ( String parent ) { this . parent = parent ; } public String getParent ( ) { return parent ; } public void setImageId ( String imageId ) { this . imageId = imageId ; } public String getImageId ( ) { return imageId ; } public void setCondition ( String condition ) { this . condition = condition ; } public String getCondition ( ) { return this . condition ; } public boolean hasCondition ( ) { return condition != null ; } public void addValidator ( String validatorClassName ) { validators . add ( validatorClassName ) ; } public List < String > getValidators ( ) { return validators ; } public void setHidden ( boolean hidden ) { this . hidden = hidden ; } public boolean isHidden ( ) { return hidden ; } public String toString ( ) { return name + "<STR_LIT:U+0020(>" + description + "<STR_LIT:)>" ; } public static String toByteUnitsString ( long bytes ) { if ( bytes < KILOBYTES ) { return String . valueOf ( bytes ) + "<STR_LIT>" ; } else if ( bytes < ( MEGABYTES ) ) { double value = bytes / KILOBYTES ; return formatter . format ( value ) + "<STR_LIT>" ; } else if ( bytes < ( GIGABYTES ) ) { double value = bytes / MEGABYTES ; return formatter . format ( value ) + "<STR_LIT>" ; } else { double value = bytes / GIGABYTES ; return formatter . format ( value ) + "<STR_LIT>" ; } } } </s>
<s> package com . izforge . izpack . api . data ; import java . util . EnumSet ; import java . util . HashMap ; import java . util . Map ; public enum Blockable { BLOCKABLE_NONE ( "<STR_LIT:none>" ) , BLOCKABLE_AUTO ( "<STR_LIT>" ) , BLOCKABLE_FORCE ( "<STR_LIT>" ) ; private static Map < String , Blockable > lookup ; private String attribute ; Blockable ( String attribute ) { this . attribute = attribute ; } static { lookup = new HashMap < String , Blockable > ( ) ; for ( Blockable blockable : EnumSet . allOf ( Blockable . class ) ) { lookup . put ( blockable . getAttribute ( ) , blockable ) ; } } public String getAttribute ( ) { return attribute ; } public static Blockable getBlockableFromAttribute ( String attribute ) { if ( attribute != null && lookup . containsKey ( attribute ) ) { return lookup . get ( attribute ) ; } return null ; } } </s>
<s> package com . izforge . izpack . api . data ; import java . util . EnumSet ; import java . util . HashMap ; import java . util . Map ; public enum OverrideType { OVERRIDE_FALSE ( "<STR_LIT:false>" ) , OVERRIDE_TRUE ( "<STR_LIT:true>" ) , OVERRIDE_ASK_FALSE ( "<STR_LIT>" ) , OVERRIDE_ASK_TRUE ( "<STR_LIT>" ) , OVERRIDE_UPDATE ( "<STR_LIT>" ) ; private static Map < String , OverrideType > lookup ; private String attribute ; OverrideType ( String attribute ) { this . attribute = attribute ; } static { lookup = new HashMap < String , OverrideType > ( ) ; for ( OverrideType overridetype : EnumSet . allOf ( OverrideType . class ) ) { lookup . put ( overridetype . getAttribute ( ) , overridetype ) ; } } public String getAttribute ( ) { return attribute ; } public static OverrideType getOverrideTypeFromAttribute ( String attribute ) { if ( attribute != null && lookup . containsKey ( attribute ) ) { return lookup . get ( attribute ) ; } return null ; } } </s>
<s> package com . izforge . izpack . api . data ; import java . util . List ; import java . util . Locale ; import com . izforge . izpack . api . adaptator . IXMLElement ; import com . izforge . izpack . api . resource . Messages ; import com . izforge . izpack . api . rules . RulesEngine ; import com . izforge . izpack . util . Platform ; public interface InstallData { String MEDIA_PATH = "<STR_LIT>" ; String INSTALL_PATH = "<STR_LIT>" ; String MODIFY_INSTALLATION = "<STR_LIT>" ; String INSTALLATION_INFORMATION = "<STR_LIT>" ; void setVariable ( String name , String value ) ; String getVariable ( String name ) ; void refreshVariables ( ) ; Variables getVariables ( ) ; void setInstallPath ( String path ) ; String getInstallPath ( ) ; void setDefaultInstallPath ( String path ) ; String getDefaultInstallPath ( ) ; void setMediaPath ( String path ) ; String getMediaPath ( ) ; RulesEngine getRules ( ) ; Locale getLocale ( ) ; String getLocaleISO3 ( ) ; Messages getMessages ( ) ; Info getInfo ( ) ; Platform getPlatform ( ) ; List < Pack > getAllPacks ( ) ; List < Pack > getAvailablePacks ( ) ; List < Pack > getSelectedPacks ( ) ; void setSelectedPacks ( List < Pack > selectedPacks ) ; List < Panel > getPanelsOrder ( ) ; boolean isCanClose ( ) ; boolean isInstallSuccess ( ) ; void setInstallSuccess ( boolean success ) ; boolean isRebootNecessary ( ) ; void setRebootNecessary ( boolean reboot ) ; IXMLElement getXmlData ( ) ; List < InstallerRequirement > getInstallerRequirements ( ) ; List < DynamicInstallerRequirementValidator > getDynamicInstallerRequirements ( ) ; void setAttribute ( String name , Object value ) ; Object getAttribute ( String name ) ; } </s>
<s> package com . izforge . izpack . api . factory ; import com . izforge . izpack . api . exception . IzPackClassNotFoundException ; public interface ObjectFactory { < T > T create ( Class < T > type , Object ... parameters ) ; < T > T create ( String className , Class < T > superType , Object ... parameters ) ; } </s>
<s> package com . izforge . izpack . api . adaptator . xinclude ; import static junit . framework . Assert . assertEquals ; import static junit . framework . Assert . fail ; import static org . hamcrest . MatcherAssert . assertThat ; import static org . hamcrest . text . IsEqualIgnoringWhiteSpace . equalToIgnoringWhiteSpace ; import java . net . URL ; import java . util . List ; import org . junit . Test ; import com . izforge . izpack . api . adaptator . IXMLElement ; import com . izforge . izpack . api . adaptator . IXMLParser ; import com . izforge . izpack . api . adaptator . impl . XMLParser ; public abstract class BaseXIncludeTestCase { public abstract void doTest ( String fileBase ) throws Exception ; public void ensureFailure ( String fileBase ) throws Exception { try { URL baseURL = getClass ( ) . getResource ( fileBase + "<STR_LIT>" ) ; IXMLParser parser = new XMLParser ( ) ; parser . parse ( baseURL ) ; fail ( "<STR_LIT>" ) ; } catch ( Throwable t ) { } } public void deepEqual ( IXMLElement a , IXMLElement b ) { assertEquals ( "<STR_LIT>" , a . getName ( ) , b . getName ( ) ) ; if ( null != b . getContent ( ) && null != a . getContent ( ) ) { assertThat ( a . getContent ( ) , equalToIgnoringWhiteSpace ( b . getContent ( ) ) ) ; } assertEquals ( "<STR_LIT>" + a . getName ( ) , a . getChildrenCount ( ) , b . getChildrenCount ( ) ) ; List < IXMLElement > aChildren = a . getChildren ( ) ; List < IXMLElement > bChildren = b . getChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < bChildren . size ( ) ; i ++ ) { IXMLElement aChild = aChildren . get ( i ) ; IXMLElement bChild = bChildren . get ( i ) ; deepEqual ( aChild , bChild ) ; } } @ Test public void testIncludeOnly ( ) throws Exception { doTest ( "<STR_LIT>" ) ; } @ Test public void testIncludeSubdirectoryOnly ( ) throws Exception { doTest ( "<STR_LIT>" ) ; } @ Test public void testIncludeFragmentOnly ( ) throws Exception { doTest ( "<STR_LIT>" ) ; } @ Test public void testIncludeInElement ( ) throws Exception { doTest ( "<STR_LIT>" ) ; } @ Test public void testIncludeFragmentInElement ( ) throws Exception { doTest ( "<STR_LIT>" ) ; } @ Test public void _testIncludeTextInElement ( ) throws Exception { doTest ( "<STR_LIT>" ) ; } @ Test public void testParseAttributeText ( ) throws Exception { doTest ( "<STR_LIT>" ) ; } @ Test public void testParseAttributeXML ( ) throws Exception { doTest ( "<STR_LIT>" ) ; } @ Test public void testParseInvalidAttribute ( ) throws Exception { ensureFailure ( "<STR_LIT>" ) ; } @ Test public void testFallback ( ) throws Exception { doTest ( "<STR_LIT>" ) ; } @ Test public void testEmptyFallback ( ) throws Exception { doTest ( "<STR_LIT>" ) ; } @ Test public void testMultipleIncludes ( ) throws Exception { doTest ( "<STR_LIT>" ) ; } } </s>
<s> package com . izforge . izpack . api . adaptator . xinclude ; import com . izforge . izpack . api . adaptator . IXMLElement ; import com . izforge . izpack . api . adaptator . IXMLParser ; import com . izforge . izpack . api . adaptator . impl . XMLParser ; import java . io . File ; import java . io . FileInputStream ; import java . net . URL ; public class XIncludeParseFileTestCase extends BaseXIncludeTestCase { @ Override public void doTest ( String fileBase ) throws Exception { URL inputURL = getClass ( ) . getResource ( fileBase + "<STR_LIT>" ) ; URL expectURL = getClass ( ) . getResource ( fileBase + "<STR_LIT>" ) ; File fileInput = new File ( inputURL . toURI ( ) ) ; File fileExcept = new File ( expectURL . toURI ( ) ) ; IXMLParser parser = new XMLParser ( ) ; IXMLElement inputElement = parser . parse ( new FileInputStream ( fileInput ) , fileInput . getAbsolutePath ( ) ) ; IXMLElement expectedElement = parser . parse ( new FileInputStream ( fileExcept ) , fileInput . getAbsolutePath ( ) ) ; deepEqual ( expectedElement , inputElement ) ; } } </s>
<s> package com . izforge . izpack . api . adaptator . xinclude ; import com . izforge . izpack . api . adaptator . IXMLElement ; import com . izforge . izpack . api . adaptator . IXMLParser ; import com . izforge . izpack . api . adaptator . impl . XMLParser ; import java . net . URL ; public class XIncludeParseURLTestCase extends BaseXIncludeTestCase { @ Override public void doTest ( String fileBase ) throws Exception { URL inputURL = getClass ( ) . getResource ( fileBase + "<STR_LIT>" ) ; URL expectURL = getClass ( ) . getResource ( fileBase + "<STR_LIT>" ) ; IXMLParser parser = new XMLParser ( ) ; IXMLElement inputElement = parser . parse ( inputURL ) ; IXMLElement expectedElement = parser . parse ( expectURL ) ; deepEqual ( expectedElement , inputElement ) ; } } </s>
<s> package com . izforge . izpack . api . adaptator . xinclude ; import com . izforge . izpack . api . adaptator . IXMLElement ; import com . izforge . izpack . api . adaptator . IXMLParser ; import com . izforge . izpack . api . adaptator . impl . XMLParser ; import java . net . URL ; public class XIncludeParseStreamTestCase extends BaseXIncludeTestCase { @ Override public void doTest ( String fileBase ) throws Exception { URL inputURL = getClass ( ) . getResource ( fileBase + "<STR_LIT>" ) ; URL expectURL = getClass ( ) . getResource ( fileBase + "<STR_LIT>" ) ; IXMLParser parser = new XMLParser ( ) ; IXMLElement inputElement = parser . parse ( inputURL . openStream ( ) , inputURL . toExternalForm ( ) ) ; IXMLElement expectedElement = parser . parse ( expectURL . openStream ( ) ) ; deepEqual ( expectedElement , inputElement ) ; } } </s>
<s> package com . izforge . izpack . api . adaptator ; import com . izforge . izpack . api . adaptator . impl . XMLElementImpl ; import com . izforge . izpack . api . adaptator . impl . XMLParser ; import com . izforge . izpack . api . adaptator . impl . XMLWriter ; import org . junit . Assert ; import org . junit . Before ; import org . junit . Rule ; import org . junit . Test ; import org . junit . rules . TemporaryFolder ; import java . io . * ; public class XMLWriterTest { private static final String filename = "<STR_LIT>" ; private static final String output = "<STR_LIT>" ; private IXMLParser parser ; private IXMLElement root ; @ Rule public TemporaryFolder tempFolder = new TemporaryFolder ( ) ; @ Before public void setUp ( ) throws FileNotFoundException { parser = new XMLParser ( ) ; root = parser . parse ( XMLWriterTest . class . getResourceAsStream ( filename ) ) ; } @ Test public void testWriteFile ( ) throws IOException { IXMLWriter writer = new XMLWriter ( ) ; File file = tempFolder . newFile ( output ) ; FileOutputStream out = new FileOutputStream ( file ) ; writer . setOutput ( out ) ; writer . write ( root ) ; root = parser . parse ( XMLWriterTest . class . getResourceAsStream ( filename ) ) ; IXMLElement element = parser . parse ( new FileInputStream ( file ) ) ; Assert . assertEquals ( root . getName ( ) , element . getName ( ) ) ; } @ Test public void testWriteURL ( ) throws IOException { IXMLWriter writer = new XMLWriter ( ) ; File file = tempFolder . newFile ( output ) ; FileOutputStream out = new FileOutputStream ( file ) ; writer . setOutput ( out ) ; writer . write ( root ) ; root = parser . parse ( XMLWriterTest . class . getResourceAsStream ( filename ) ) ; IXMLElement element = parser . parse ( new FileInputStream ( file ) ) ; Assert . assertEquals ( root . getName ( ) , element . getName ( ) ) ; } @ Test ( expected = XMLException . class ) public void testFail ( ) { IXMLElement elt = new XMLElementImpl ( "<STR_LIT:root>" ) ; IXMLWriter writer = new XMLWriter ( ) ; writer . setOutput ( "<STR_LIT>" ) ; writer . write ( elt ) ; } } </s>
<s> package com . izforge . izpack . api . adaptator ; import com . izforge . izpack . api . adaptator . impl . XMLParser ; import org . apache . commons . io . FileUtils ; import org . junit . Assert ; import org . junit . Test ; import org . xml . sax . SAXException ; import javax . xml . parsers . ParserConfigurationException ; import javax . xml . transform . TransformerException ; import java . io . File ; import java . io . IOException ; import java . io . InputStream ; import java . net . URL ; import static junit . framework . Assert . assertEquals ; public class XMLParserTest { private static final String filename = "<STR_LIT>" ; private static final String shortFilename = "<STR_LIT>" ; private static final String lnFilename = "<STR_LIT>" ; private static final String xlnFilename = "<STR_LIT>" ; private static final String parseErrorFilename = "<STR_LIT>" ; private static final String parseErrorXincludeFilename = "<STR_LIT>" ; @ org . junit . Test public void testParseFile ( ) throws Exception { InputStream input ; IXMLElement spec ; input = XMLParserTest . class . getResourceAsStream ( shortFilename ) ; IXMLParser parser = new XMLParser ( ) ; spec = parser . parse ( input ) ; Assert . assertEquals ( "<STR_LIT>" , spec . getName ( ) ) ; } @ Test public void testParseString ( ) throws Exception { IXMLElement spec ; String substitutedSpec = FileUtils . readFileToString ( new File ( XMLParserTest . class . getResource ( filename ) . toURI ( ) ) ) ; IXMLParser parser = new XMLParser ( ) ; spec = parser . parse ( substitutedSpec ) ; Assert . assertEquals ( "<STR_LIT>" , spec . getName ( ) ) ; } private void checkEltLN ( IXMLElement elt ) { assertEquals ( Integer . parseInt ( elt . getAttribute ( "<STR_LIT>" ) ) , elt . getLineNr ( ) ) ; for ( IXMLElement child : elt . getChildren ( ) ) { checkEltLN ( child ) ; } } @ org . junit . Test public void testLineNumber ( ) throws SAXException , ParserConfigurationException , IOException , TransformerException { InputStream input = XMLParserTest . class . getResourceAsStream ( lnFilename ) ; IXMLElement elt ; IXMLParser parser = new XMLParser ( ) ; elt = parser . parse ( input ) ; checkEltLN ( elt ) ; } @ Test public void testXincludeLineNumber ( ) throws SAXException , ParserConfigurationException , IOException , TransformerException { URL url = XMLParserTest . class . getResource ( xlnFilename ) ; IXMLParser parser = new XMLParser ( ) ; IXMLElement elt = parser . parse ( url ) ; checkEltLN ( elt ) ; } @ Test ( expected = XMLException . class ) public void testXMLExceptionThrown ( ) { InputStream input = XMLParserTest . class . getResourceAsStream ( parseErrorFilename ) ; IXMLParser parser = new XMLParser ( ) ; parser . parse ( input , parseErrorFilename ) ; } @ Test ( expected = XMLException . class ) public void testXMLExceptionThrownXInclude ( ) { InputStream input = XMLParserTest . class . getResourceAsStream ( parseErrorXincludeFilename ) ; IXMLParser parser = new XMLParser ( ) ; parser . parse ( input , parseErrorXincludeFilename ) ; } @ Test ( expected = NullPointerException . class ) public void testNPE ( ) { IXMLParser parser = new XMLParser ( ) ; parser . parse ( ( InputStream ) null ) ; } @ Test ( expected = NullPointerException . class ) public void testWithSystemIdNPE ( ) { IXMLParser parser = new XMLParser ( ) ; parser . parse ( null , "<STR_LIT>" ) ; } } </s>
<s> package com . izforge . izpack . api . adaptator ; import com . izforge . izpack . api . adaptator . impl . XMLElementImpl ; import com . izforge . izpack . api . adaptator . impl . XMLParser ; import org . junit . Assert ; import org . junit . Before ; import org . junit . Test ; import java . io . FileNotFoundException ; import java . util . List ; public class XMLElementTest { private static final String filename = "<STR_LIT>" ; private IXMLElement root ; @ Before public void setUp ( ) throws FileNotFoundException { IXMLParser parser = new XMLParser ( ) ; root = parser . parse ( XMLElementTest . class . getResourceAsStream ( filename ) ) ; } @ Test public void testGetName ( ) { Assert . assertEquals ( "<STR_LIT>" , root . getName ( ) ) ; Assert . assertEquals ( root . getChildAtIndex ( <NUM_LIT:0> ) . getName ( ) , "<STR_LIT>" ) ; } @ Test public void testAddChild ( ) throws NoSuchMethodException { IXMLElement element = new XMLElementImpl ( "<STR_LIT>" , root ) ; root . addChild ( element ) ; element = root . getChildAtIndex ( root . getChildrenCount ( ) - <NUM_LIT:1> ) ; Assert . assertEquals ( element . getName ( ) , "<STR_LIT>" ) ; } @ Test public void testRemoveChild ( ) throws NoSuchMethodException { IXMLElement element = new XMLElementImpl ( "<STR_LIT>" , root ) ; root . addChild ( element ) ; element = root . getChildAtIndex ( root . getChildrenCount ( ) - <NUM_LIT:1> ) ; root . removeChild ( element ) ; Assert . assertEquals ( root . getChildrenNamed ( "<STR_LIT>" ) . size ( ) , <NUM_LIT:0> ) ; } @ Test public void testHasChildrenIfTrue ( ) { Assert . assertTrue ( root . hasChildren ( ) ) ; } @ Test public void testHasChildrenIfFalse ( ) { IXMLElement element = new XMLElementImpl ( "<STR_LIT:test>" ) ; Assert . assertFalse ( element . hasChildren ( ) ) ; } @ Test public void testGetChildrenCount ( ) { IXMLElement element = root . getChildAtIndex ( <NUM_LIT:0> ) ; Assert . assertEquals ( element . getChildrenCount ( ) , <NUM_LIT:9> ) ; } @ Test public void testGetChildAtIndex ( ) { IXMLElement element = root . getChildAtIndex ( <NUM_LIT:1> ) ; Assert . assertEquals ( "<STR_LIT>" , element . getName ( ) ) ; } @ Test public void testGetFirstChildNamed ( ) { IXMLElement element = root . getFirstChildNamed ( "<STR_LIT>" ) ; Assert . assertEquals ( element . getName ( ) , "<STR_LIT>" ) ; } @ Test public void testGetChildrenNamed ( ) { IXMLElement element = root . getChildAtIndex ( <NUM_LIT:2> ) ; List < IXMLElement > list = element . getChildrenNamed ( "<STR_LIT>" ) ; Assert . assertEquals ( <NUM_LIT:7> , list . size ( ) ) ; } } </s>
<s> package com . izforge . izpack . api . data ; import static org . junit . Assert . assertEquals ; import org . junit . Before ; import org . junit . Test ; import org . mockito . Mockito ; import com . izforge . izpack . api . resource . Locales ; public class LocaleDatabaseTest { private LocaleDatabase db ; @ Before public void setUp ( ) throws Exception { db = new LocaleDatabase ( LocaleDatabaseTest . class . getResourceAsStream ( "<STR_LIT>" ) , Mockito . mock ( Locales . class ) ) ; } @ Test public void testGet ( ) { assertEquals ( "<STR_LIT>" , db . get ( "<STR_LIT:string>" ) ) ; assertEquals ( "<STR_LIT:none>" , db . get ( "<STR_LIT:none>" ) ) ; } @ Test public void testGetWithArgs ( ) { assertEquals ( "<STR_LIT>" , db . get ( "<STR_LIT>" , "<STR_LIT:one>" , "<STR_LIT:two>" ) ) ; assertEquals ( "<STR_LIT>" , db . get ( "<STR_LIT>" , "<STR_LIT:one>" , "<STR_LIT:two>" ) ) ; } @ Test public void testGetString ( ) throws Exception { assertEquals ( "<STR_LIT>" , db . getString ( "<STR_LIT:string>" ) ) ; assertEquals ( "<STR_LIT:none>" , db . getString ( "<STR_LIT:none>" ) ) ; } @ Test public void testNpeHandling ( ) { assertEquals ( "<STR_LIT>" , db . getString ( "<STR_LIT>" , new String [ ] { "<STR_LIT:one>" , null } ) ) ; } @ Test public void testQuotedPlaceholder ( ) { assertEquals ( "<STR_LIT>" , db . getString ( "<STR_LIT>" , new String [ ] { "<STR_LIT:one>" , null } ) ) ; } } </s>
<s> package com . company . izpack . panels ; import com . izforge . izpack . api . data . GUIInstallData ; import com . izforge . izpack . api . data . Info ; import com . izforge . izpack . gui . IzPanelLayout ; import com . izforge . izpack . gui . LabelFactory ; import com . izforge . izpack . gui . LayoutConstants ; import com . izforge . izpack . installer . gui . InstallerFrame ; import com . izforge . izpack . installer . gui . IzPanel ; import java . util . ArrayList ; public class MyHelloPanel extends IzPanel { private static final long serialVersionUID = <NUM_LIT> ; public MyHelloPanel ( InstallerFrame parent , GUIInstallData idata ) { this ( parent , idata , new IzPanelLayout ( ) ) ; } public MyHelloPanel ( InstallerFrame parent , GUIInstallData idata , LayoutManager2 layout ) { super ( parent , idata , layout ) ; Messages messages = installData . getMessages ( ) ; String str ; str = messages . get ( "<STR_LIT>" ) + idata . getInfo ( ) . getAppName ( ) + "<STR_LIT:U+0020>" + idata . getInfo ( ) . getAppVersion ( ) + messages . get ( "<STR_LIT>" ) ; JLabel welcomeLabel = LabelFactory . create ( str , parent . getIcons ( ) . get ( "<STR_LIT>" ) , LEADING ) ; add ( welcomeLabel , NEXT_LINE ) ; add ( IzPanelLayout . createParagraphGap ( ) ) ; ArrayList < Info . Author > authors = idata . getInfo ( ) . getAuthors ( ) ; int size = authors . size ( ) ; if ( size > <NUM_LIT:0> ) { str = messages . get ( "<STR_LIT>" ) ; JLabel appAuthorsLabel = LabelFactory . create ( str , parent . getIcons ( ) . get ( "<STR_LIT>" ) , LEADING ) ; add ( appAuthorsLabel , LayoutConstants . NEXT_LINE ) ; JLabel label ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { Info . Author a = authors . get ( i ) ; String email = ( a . getEmail ( ) != null && a . getEmail ( ) . length ( ) > <NUM_LIT:0> ) ? ( "<STR_LIT>" + a . getEmail ( ) + "<STR_LIT:>>" ) : "<STR_LIT>" ; label = LabelFactory . create ( "<STR_LIT:U+0020-U+0020>" + a . getName ( ) + email , parent . getIcons ( ) . get ( "<STR_LIT>" ) , LEADING ) ; add ( label , NEXT_LINE ) ; } add ( IzPanelLayout . createParagraphGap ( ) ) ; } if ( idata . getInfo ( ) . getAppURL ( ) != null ) { str = messages . get ( "<STR_LIT>" ) + idata . getInfo ( ) . getAppURL ( ) ; JLabel appURLLabel = LabelFactory . create ( str , parent . getIcons ( ) . get ( "<STR_LIT>" ) , LEADING ) ; add ( appURLLabel , LayoutConstants . NEXT_LINE ) ; } getLayoutHelper ( ) . completeLayout ( ) ; } public boolean isValidated ( ) { return true ; } } </s>
<s> package com . izforge . izpack . sample ; import com . izforge . izpack . panels . userinput . processor . Processor ; import com . izforge . izpack . panels . userinput . processorclient . ProcessingClient ; public class Scrambler implements Processor { public String process ( ProcessingClient client ) { StringBuffer buffer = new StringBuffer ( ) ; for ( int i = client . getNumFields ( ) - <NUM_LIT:1> ; i > - <NUM_LIT:1> ; i -- ) { buffer . append ( client . getFieldContents ( i ) ) ; if ( i > <NUM_LIT:0> ) { buffer . append ( '<CHAR_LIT>' ) ; } } return ( buffer . toString ( ) ) ; } } </s>
<s> package com . izforge . izpack . sample ; import com . izforge . izpack . panels . userinput . processorclient . ProcessingClient ; import com . izforge . izpack . panels . userinput . validator . Validator ; public class IPValidator implements Validator { public boolean validate ( ProcessingClient client ) { if ( client . getNumFields ( ) != <NUM_LIT:4> ) { return ( false ) ; } boolean isIP = true ; for ( int i = <NUM_LIT:0> ; i < <NUM_LIT:4> ; i ++ ) { int value ; try { value = Integer . parseInt ( client . getFieldContents ( i ) ) ; if ( ( value < <NUM_LIT:0> ) || ( value > <NUM_LIT:255> ) ) { isIP = false ; } } catch ( Throwable exception ) { isIP = false ; } } return ( isIP ) ; } } </s>
<s> package com . myCompany . tools . install . listener ; import com . izforge . izpack . api . data . PackFile ; import com . izforge . izpack . api . exception . InstallerException ; import com . izforge . izpack . event . SimpleInstallerListener ; import com . izforge . izpack . util . FileExecutor ; import java . io . File ; import java . io . IOException ; public class ChmodInstallerListener extends SimpleInstallerListener { public boolean isFileListener ( ) { return true ; } public void afterFile ( File filePath , PackFile pf ) throws Exception { if ( pf . getAdditionals ( ) == null ) { return ; } Object file = pf . getAdditionals ( ) . get ( "<STR_LIT>" ) ; int fileVal = - <NUM_LIT:1> ; if ( file != null && file instanceof Integer ) { fileVal = ( ( Integer ) file ) . intValue ( ) ; } if ( fileVal != - <NUM_LIT:1> ) { chmod ( filePath , fileVal ) ; } } public void afterDir ( File dirPath , PackFile pf ) throws Exception { if ( pf . getAdditionals ( ) == null ) { return ; } if ( dirPath == null ) { return ; } Object dir = pf . getAdditionals ( ) . get ( "<STR_LIT>" ) ; int dirVal = - <NUM_LIT:1> ; if ( dir != null && dir instanceof Integer ) { dirVal = ( ( Integer ) dir ) . intValue ( ) ; } if ( dirVal != - <NUM_LIT:1> ) { if ( ( dirVal & <NUM_LIT> ) < <NUM_LIT> ) { throw new InstallerException ( "<STR_LIT>" + dirPath . getAbsolutePath ( ) + "<STR_LIT>" ) ; } chmod ( dirPath , dirVal ) ; } } private void chmod ( File path , int permissions ) throws IOException { String pathSep = System . getProperty ( "<STR_LIT>" ) ; if ( OsVersion . IS_WINDOWS ) { throw new IOException ( "<STR_LIT>" ) ; } if ( path == null ) { return ; } String permStr = Integer . toOctalString ( permissions ) ; String [ ] params = { "<STR_LIT>" , permStr , path . getAbsolutePath ( ) } ; String [ ] output = new String [ <NUM_LIT:2> ] ; FileExecutor fe = new FileExecutor ( ) ; fe . executeCommand ( params , output ) ; } } </s>
<s> package com . myCompany . tools . install . listener ; import com . izforge . izpack . api . exception . CompilerException ; import com . izforge . izpack . compiler . listener . SimpleCompilerListener ; import net . n3 . nanoxml . XMLElement ; import java . util . HashMap ; import java . util . Iterator ; import java . util . Map ; import java . util . Vector ; public class ChmodCompilerListener extends SimpleCompilerListener { public Map reviseAdditionalDataMap ( Map existentDataMap , XMLElement element ) throws CompilerException { Map retval = existentDataMap != null ? existentDataMap : new HashMap ( ) ; Vector dataList = element . getChildrenNamed ( "<STR_LIT>" ) ; Iterator iter = null ; if ( dataList == null || dataList . size ( ) == <NUM_LIT:0> ) { return ( existentDataMap ) ; } iter = dataList . iterator ( ) ; while ( iter . hasNext ( ) ) { XMLElement data = ( XMLElement ) iter . next ( ) ; String [ ] relevantKeys = { "<STR_LIT>" , "<STR_LIT>" } ; for ( int i = <NUM_LIT:0> ; i < relevantKeys . length ; ++ i ) { String key = data . getAttribute ( "<STR_LIT:key>" ) ; if ( key . equalsIgnoreCase ( relevantKeys [ i ] ) ) { String value = data . getAttribute ( "<STR_LIT:value>" ) ; if ( value == null || value . length ( ) == <NUM_LIT:0> ) { continue ; } try { int radix = value . startsWith ( "<STR_LIT:0>" ) ? <NUM_LIT:8> : <NUM_LIT:10> ; retval . put ( key , Integer . valueOf ( value , radix ) ) ; } catch ( NumberFormatException x ) { throw new CompilerException ( "<STR_LIT:'>" + relevantKeys [ i ] + "<STR_LIT>" ) ; } } } } return retval ; } } </s>
<s> package com . izforge . izpack . sample ; import com . izforge . izpack . panels . userinput . processor . Processor ; import com . izforge . izpack . panels . userinput . processorclient . ProcessingClient ; public class PWDEncryptor implements Processor { public String process ( ProcessingClient client ) { if ( client . getNumFields ( ) < <NUM_LIT:1> ) { return ( "<STR_LIT>" ) ; } char [ ] password = client . getFieldContents ( <NUM_LIT:0> ) . toCharArray ( ) ; char [ ] result = new char [ password . length ] ; int temp ; for ( int i = <NUM_LIT:0> ; i < password . length ; i ++ ) { temp = password [ i ] - <NUM_LIT> ; if ( i > <NUM_LIT:0> ) { temp = temp + password [ i - <NUM_LIT:1> ] ; } if ( ( temp % <NUM_LIT:3> ) == <NUM_LIT:0> ) { temp = temp + <NUM_LIT> ; } if ( temp < <NUM_LIT:0> ) { temp = temp + <NUM_LIT> ; } result [ i ] = ( char ) temp ; } return ( new String ( result ) ) ; } } </s>
<s> package com . izforge . izpack . sample ; import com . izforge . izpack . panels . userinput . processorclient . ProcessingClient ; import com . izforge . izpack . panels . userinput . validator . Validator ; public class PWDValidator implements Validator { public boolean validate ( ProcessingClient client ) { int numFields = client . getNumFields ( ) ; if ( numFields < <NUM_LIT:2> ) { return ( true ) ; } boolean match = true ; String content = client . getFieldContents ( <NUM_LIT:0> ) ; for ( int i = <NUM_LIT:1> ; i < numFields ; i ++ ) { if ( ! content . equals ( client . getFieldContents ( i ) ) ) { match = false ; } } return ( match ) ; } } </s>
<s> package org . izpack . mojo ; import java . io . File ; import java . util . List ; import java . util . Properties ; import org . apache . maven . model . Developer ; import org . apache . maven . plugin . AbstractMojo ; import org . apache . maven . plugin . MojoExecutionException ; import org . apache . maven . plugin . MojoFailureException ; import org . apache . maven . project . MavenProject ; import org . apache . maven . project . MavenProjectHelper ; import com . izforge . izpack . api . data . Info ; import com . izforge . izpack . api . data . binding . IzpackProjectInstaller ; import com . izforge . izpack . compiler . CompilerConfig ; import com . izforge . izpack . compiler . container . CompilerContainer ; import com . izforge . izpack . compiler . data . CompilerData ; import com . izforge . izpack . compiler . data . PropertyManager ; public class IzPackNewMojo extends AbstractMojo { private MavenProject project ; private MavenProjectHelper projectHelper ; private String comprFormat ; private String kind ; private String installFile ; private String baseDir ; private String output ; private boolean mkdirs ; private int comprLevel ; private boolean autoIncludeUrl ; private boolean autoIncludeDevelopers ; private File outputDirectory ; private String finalName ; private String classifier ; private boolean enableAttachArtifact ; private boolean enableOverrideArtifact ; public void execute ( ) throws MojoExecutionException , MojoFailureException { File jarFile = getJarFile ( ) ; CompilerData compilerData = initCompilerData ( jarFile ) ; CompilerContainer compilerContainer = new CompilerContainer ( ) ; compilerContainer . addConfig ( "<STR_LIT>" , installFile ) ; compilerContainer . getComponent ( IzpackProjectInstaller . class ) ; compilerContainer . addComponent ( CompilerData . class , compilerData ) ; CompilerConfig compilerConfig = compilerContainer . getComponent ( CompilerConfig . class ) ; PropertyManager propertyManager = compilerContainer . getComponent ( PropertyManager . class ) ; initMavenProperties ( propertyManager ) ; try { compilerConfig . executeCompiler ( ) ; } catch ( Exception e ) { throw new AssertionError ( e ) ; } if ( classifier != null && ! classifier . isEmpty ( ) ) { if ( enableAttachArtifact ) { projectHelper . attachArtifact ( project , getType ( ) , classifier , jarFile ) ; } } else { if ( enableOverrideArtifact ) { project . getArtifact ( ) . setFile ( jarFile ) ; } } } protected static final String getType ( ) { return "<STR_LIT>" ; } private File getJarFile ( ) { File file ; if ( output != null ) { file = new File ( output ) ; } else { if ( classifier == null || classifier . trim ( ) . isEmpty ( ) ) { classifier = "<STR_LIT>" ; } else if ( ! classifier . startsWith ( "<STR_LIT:->" ) ) { classifier = "<STR_LIT:->" + classifier ; } file = new File ( outputDirectory , finalName + classifier + "<STR_LIT>" ) ; } return file ; } private void initMavenProperties ( PropertyManager propertyManager ) { if ( project != null ) { Properties properties = project . getProperties ( ) ; for ( String propertyName : properties . stringPropertyNames ( ) ) { String value = properties . getProperty ( propertyName ) ; if ( propertyManager . addProperty ( propertyName , value ) ) { getLog ( ) . debug ( "<STR_LIT>" + propertyName + "<STR_LIT:=>" + value ) ; } else { getLog ( ) . warn ( "<STR_LIT>" + propertyName + "<STR_LIT>" ) ; } } } } private CompilerData initCompilerData ( File jarFile ) { Info info = new Info ( ) ; if ( project != null ) { if ( autoIncludeDevelopers ) { if ( project . getDevelopers ( ) != null ) { for ( Developer dev : ( List < Developer > ) project . getDevelopers ( ) ) { info . addAuthor ( new Info . Author ( dev . getName ( ) , dev . getEmail ( ) ) ) ; } } } if ( autoIncludeUrl ) { info . setAppURL ( project . getUrl ( ) ) ; } } return new CompilerData ( comprFormat , kind , installFile , null , baseDir , jarFile . getPath ( ) , mkdirs , comprLevel , info ) ; } } </s>
<s> package org . izpack . mojo ; import org . apache . maven . project . MavenProject ; import java . util . Collections ; import java . util . List ; public class IzPackMavenProjectStub extends MavenProject { @ Override public List getAttachedArtifacts ( ) { return Collections . emptyList ( ) ; } } </s>
<s> package org . izpack . mojo ; import static org . hamcrest . MatcherAssert . assertThat ; import java . io . File ; import java . io . InputStream ; import java . util . List ; import java . util . jar . JarFile ; import java . util . zip . ZipEntry ; import java . util . zip . ZipFile ; import org . apache . commons . io . IOUtils ; import org . apache . maven . plugin . testing . AbstractMojoTestCase ; import org . hamcrest . collection . IsCollectionContaining ; import org . hamcrest . core . Is ; import org . hamcrest . core . IsNull ; import org . junit . Test ; import com . izforge . izpack . matcher . ZipMatcher ; public class IzPackNewMojoTest extends AbstractMojoTestCase { @ Test public void testExecute ( ) throws Exception { File testPom = new File ( Thread . currentThread ( ) . getContextClassLoader ( ) . getResource ( "<STR_LIT>" ) . toURI ( ) ) ; IzPackNewMojo mojo = ( IzPackNewMojo ) lookupMojo ( "<STR_LIT>" , testPom ) ; assertThat ( mojo , IsNull . notNullValue ( ) ) ; initIzpackMojo ( mojo ) ; mojo . execute ( ) ; File file = new File ( "<STR_LIT>" ) ; assertThat ( file . exists ( ) , Is . is ( true ) ) ; JarFile jar = new JarFile ( file ) ; assertThat ( ( ZipFile ) jar , ZipMatcher . isZipMatching ( IsCollectionContaining . hasItems ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ) ) ; ZipEntry entry = jar . getEntry ( "<STR_LIT>" ) ; InputStream content = jar . getInputStream ( entry ) ; try { List < String > list = IOUtils . readLines ( content ) ; assertThat ( list , IsCollectionContaining . hasItem ( "<STR_LIT>" ) ) ; } finally { content . close ( ) ; } } private void initIzpackMojo ( IzPackNewMojo mojo ) throws IllegalAccessException { File installFile = new File ( "<STR_LIT>" ) ; setVariableValueToObject ( mojo , "<STR_LIT>" , "<STR_LIT:default>" ) ; setVariableValueToObject ( mojo , "<STR_LIT>" , installFile . getAbsolutePath ( ) ) ; setVariableValueToObject ( mojo , "<STR_LIT>" , "<STR_LIT>" ) ; setVariableValueToObject ( mojo , "<STR_LIT>" , new File ( "<STR_LIT>" ) . getAbsolutePath ( ) ) ; setVariableValueToObject ( mojo , "<STR_LIT>" , "<STR_LIT>" ) ; setVariableValueToObject ( mojo , "<STR_LIT>" , - <NUM_LIT:1> ) ; setVariableValueToObject ( mojo , "<STR_LIT>" , true ) ; } } </s>
<s> package com . izforge . izpack . test . listener ; import java . io . File ; import java . util . List ; import com . izforge . izpack . api . data . AutomatedInstallData ; import com . izforge . izpack . api . data . InstallData ; import com . izforge . izpack . api . data . Pack ; import com . izforge . izpack . api . data . PackFile ; import com . izforge . izpack . api . event . InstallerListener ; import com . izforge . izpack . api . event . ProgressListener ; import com . izforge . izpack . api . exception . IzPackException ; import com . izforge . izpack . api . handler . AbstractUIProgressHandler ; import com . izforge . izpack . event . AbstractProgressInstallerListener ; public class TestInstallerListener extends AbstractProgressInstallerListener { private int initialiseCount ; private int beforePacksCount ; private int afterPacksCount ; private int beforePackCount ; private int afterPackCount ; private int beforeDirCount ; private int afterDirCount ; private int beforeFileCount ; private int afterFileCount ; public TestInstallerListener ( InstallData installData ) { super ( installData ) ; } public int getInitialiseCount ( ) { return initialiseCount ; } public int getBeforePacksCount ( ) { return beforePacksCount ; } public int getAfterPacksCount ( ) { return afterPacksCount ; } public int getBeforePackCount ( ) { return beforePackCount ; } public int getAfterPackCount ( ) { return afterPackCount ; } public int getBeforeDirCount ( ) { return beforeDirCount ; } public int getAfterDirCount ( ) { return afterDirCount ; } public int getBeforeFileCount ( ) { return beforeFileCount ; } public int getAfterFileCount ( ) { return afterFileCount ; } @ Override public void initialise ( ) { ++ initialiseCount ; log ( "<STR_LIT>" ) ; } @ Override public void beforePacks ( List < Pack > packs ) { ++ beforePacksCount ; log ( "<STR_LIT>" + packs . size ( ) ) ; } @ Override public void beforePack ( Pack pack , int index ) { ++ beforePackCount ; log ( "<STR_LIT>" + pack ) ; } @ Override public void afterPack ( Pack pack , int index ) { ++ afterPackCount ; log ( "<STR_LIT>" + pack ) ; } @ Override public void afterPacks ( List < Pack > packs , ProgressListener listener ) { ++ afterPacksCount ; log ( "<STR_LIT>" ) ; } @ Override public void beforeDir ( File dir , PackFile packFile , Pack pack ) { ++ beforeDirCount ; log ( "<STR_LIT>" + dir ) ; } @ Override public void afterDir ( File dir , PackFile packFile , Pack pack ) { ++ afterDirCount ; log ( "<STR_LIT>" + dir ) ; } @ Override public void beforeFile ( File file , PackFile packFile , Pack pack ) { ++ beforeFileCount ; log ( "<STR_LIT>" + file ) ; } @ Override public void afterFile ( File file , PackFile packFile , Pack pack ) { ++ afterFileCount ; log ( "<STR_LIT>" + file ) ; } public void afterInstallerInitialization ( AutomatedInstallData data ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } public void beforePacks ( AutomatedInstallData data , Integer packs , AbstractUIProgressHandler handler ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } public void afterPacks ( AutomatedInstallData data , AbstractUIProgressHandler handler ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } public void beforePack ( Pack pack , Integer i , AbstractUIProgressHandler handler ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } public void afterPack ( Pack pack , Integer i , AbstractUIProgressHandler handler ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } public boolean isFileListener ( ) { return true ; } public void beforeDir ( File dir , PackFile packFile ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } public void afterDir ( File dir , PackFile packFile ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } public void beforeFile ( File file , PackFile packFile ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } public void afterFile ( File file , PackFile packFile ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } private void log ( String message ) { System . out . println ( "<STR_LIT>" + message ) ; } } </s>
<s> package com . izforge . izpack . test . listener ; import java . io . BufferedReader ; import java . io . File ; import java . io . FileInputStream ; import java . io . FileOutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . ObjectInputStream ; import java . io . ObjectOutputStream ; import java . io . Serializable ; import java . util . List ; import com . izforge . izpack . api . event . ProgressListener ; import com . izforge . izpack . api . event . UninstallerListener ; import com . izforge . izpack . api . exception . IzPackException ; import com . izforge . izpack . api . handler . AbstractUIProgressHandler ; public class TestUninstallerListener implements UninstallerListener { private String logPath ; private State state = new State ( ) ; public static class State implements Serializable { public int initialiseCount ; public int beforeListDeleteCount ; public int afterListDeleteCount ; public int beforeDeleteCount ; public int afterDeleteCount ; } public TestUninstallerListener ( ) { String installPath = getInstallPath ( ) ; if ( installPath != null ) { logPath = getStatePath ( installPath ) ; if ( logPath != null ) { log ( "<STR_LIT>" + logPath ) ; } } } public static String getStatePath ( String installPath ) { return new File ( System . getProperty ( "<STR_LIT>" ) , "<STR_LIT>" + installPath . hashCode ( ) ) . getAbsolutePath ( ) ; } public static State readState ( String path ) throws IOException , ClassNotFoundException { ObjectInputStream stream = new ObjectInputStream ( new FileInputStream ( path ) ) ; try { return ( State ) stream . readObject ( ) ; } finally { stream . close ( ) ; } } @ Override public void initialise ( ) { ++ state . initialiseCount ; log ( "<STR_LIT>" ) ; } public boolean isFileListener ( ) { return true ; } @ Override public void beforeDelete ( List < File > files ) { ++ state . beforeListDeleteCount ; log ( "<STR_LIT>" + files . size ( ) ) ; } @ Override public void beforeDelete ( File file ) { ++ state . beforeDeleteCount ; log ( "<STR_LIT>" + file ) ; } @ Override public void afterDelete ( File file ) { ++ state . afterDeleteCount ; log ( "<STR_LIT>" + file ) ; } @ Override public void afterDelete ( List < File > files , ProgressListener listener ) { ++ state . afterListDeleteCount ; log ( "<STR_LIT>" + files . size ( ) ) ; } public void beforeDeletion ( List files , AbstractUIProgressHandler handler ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } public void afterDeletion ( List files , AbstractUIProgressHandler handler ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } public void beforeDelete ( File file , AbstractUIProgressHandler handler ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } public void afterDelete ( File file , AbstractUIProgressHandler handler ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } private void log ( String message ) { System . out . println ( "<STR_LIT>" + message ) ; if ( logPath != null ) { ObjectOutputStream stream = null ; try { stream = new ObjectOutputStream ( new FileOutputStream ( logPath ) ) ; stream . writeObject ( state ) ; } catch ( IOException exception ) { exception . printStackTrace ( ) ; } finally { if ( stream != null ) { try { stream . close ( ) ; } catch ( IOException ignore ) { } } } } } private String getInstallPath ( ) { String result = null ; try { InputStream in = getClass ( ) . getResourceAsStream ( "<STR_LIT>" ) ; InputStreamReader inReader = new InputStreamReader ( in ) ; BufferedReader reader = new BufferedReader ( inReader ) ; result = reader . readLine ( ) ; reader . close ( ) ; } catch ( IOException exception ) { System . err . println ( "<STR_LIT>" + exception . getMessage ( ) ) ; } return result ; } } </s>
<s> package com . izforge . izpack . sample ; import com . izforge . izpack . panels . userinput . processorclient . ProcessingClient ; import com . izforge . izpack . panels . userinput . validator . Validator ; public class PWDValidator implements Validator { public boolean validate ( ProcessingClient client ) { int numFields = client . getNumFields ( ) ; if ( numFields < <NUM_LIT:2> ) { return ( true ) ; } boolean match = true ; String content = client . getFieldContents ( <NUM_LIT:0> ) ; for ( int i = <NUM_LIT:1> ; i < numFields ; i ++ ) { if ( ! content . equals ( client . getFieldContents ( i ) ) ) { match = false ; } } return ( match ) ; } } </s>
<s> package com . izforge . izpack . sample ; import com . izforge . izpack . panels . userinput . processor . Processor ; import com . izforge . izpack . panels . userinput . processorclient . ProcessingClient ; public class Scrambler implements Processor { public String process ( ProcessingClient client ) { StringBuffer buffer = new StringBuffer ( ) ; for ( int i = client . getNumFields ( ) - <NUM_LIT:1> ; i > - <NUM_LIT:1> ; i -- ) { buffer . append ( client . getFieldContents ( i ) ) ; if ( i > <NUM_LIT:0> ) { buffer . append ( '<CHAR_LIT>' ) ; } } return ( buffer . toString ( ) ) ; } } </s>
<s> package com . izforge . izpack . sample ; import com . izforge . izpack . panels . userinput . processor . Processor ; import com . izforge . izpack . panels . userinput . processorclient . ProcessingClient ; public class PWDEncryptor implements Processor { public String process ( ProcessingClient client ) { if ( client . getNumFields ( ) < <NUM_LIT:1> ) { return ( "<STR_LIT>" ) ; } char [ ] password = client . getFieldContents ( <NUM_LIT:0> ) . toCharArray ( ) ; char [ ] result = new char [ password . length ] ; int temp ; for ( int i = <NUM_LIT:0> ; i < password . length ; i ++ ) { temp = password [ i ] - <NUM_LIT> ; if ( i > <NUM_LIT:0> ) { temp = temp + password [ i - <NUM_LIT:1> ] ; } if ( ( temp % <NUM_LIT:3> ) == <NUM_LIT:0> ) { temp = temp + <NUM_LIT> ; } if ( temp < <NUM_LIT:0> ) { temp = temp + <NUM_LIT> ; } result [ i ] = ( char ) temp ; } return ( new String ( result ) ) ; } } </s>
<s> package com . izforge . izpack . sample ; import com . izforge . izpack . panels . userinput . processorclient . ProcessingClient ; import com . izforge . izpack . panels . userinput . validator . Validator ; public class IPValidator implements Validator { public boolean validate ( ProcessingClient client ) { if ( client . getNumFields ( ) != <NUM_LIT:4> ) { return ( false ) ; } boolean isIP = true ; for ( int i = <NUM_LIT:0> ; i < <NUM_LIT:4> ; i ++ ) { int value ; try { value = Integer . parseInt ( client . getFieldContents ( i ) ) ; if ( ( value < <NUM_LIT:0> ) || ( value > <NUM_LIT:255> ) ) { isIP = false ; } } catch ( Throwable exception ) { isIP = false ; } } return ( isIP ) ; } } </s>
<s> package com . myCompany . tools . install . listener ; import com . izforge . izpack . api . adaptator . IXMLElement ; import com . izforge . izpack . api . exception . CompilerException ; import com . izforge . izpack . compiler . listener . SimpleCompilerListener ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; public class ChmodCompilerListener extends SimpleCompilerListener { public Map reviseAdditionalDataMap ( Map existentDataMap , IXMLElement element ) throws CompilerException { Map retval = existentDataMap != null ? existentDataMap : new HashMap ( ) ; List < IXMLElement > dataList = element . getChildrenNamed ( "<STR_LIT>" ) ; if ( dataList == null || dataList . size ( ) == <NUM_LIT:0> ) { return ( existentDataMap ) ; } for ( IXMLElement data : dataList ) { String [ ] relevantKeys = { "<STR_LIT>" , "<STR_LIT>" } ; for ( String relevantKey : relevantKeys ) { String key = data . getAttribute ( "<STR_LIT:key>" ) ; if ( key . equalsIgnoreCase ( relevantKey ) ) { String value = data . getAttribute ( "<STR_LIT:value>" ) ; if ( value == null || value . length ( ) == <NUM_LIT:0> ) { continue ; } try { int radix = value . startsWith ( "<STR_LIT:0>" ) ? <NUM_LIT:8> : <NUM_LIT:10> ; retval . put ( key , Integer . valueOf ( value , radix ) ) ; } catch ( NumberFormatException x ) { throw new CompilerException ( "<STR_LIT:'>" + relevantKey + "<STR_LIT>" ) ; } } } } return retval ; } } </s>
<s> package com . myCompany . tools . install . listener ; import java . io . File ; import com . izforge . izpack . api . data . InstallData ; import com . izforge . izpack . api . data . Pack ; import com . izforge . izpack . api . data . PackFile ; import com . izforge . izpack . api . exception . InstallerException ; import com . izforge . izpack . event . AbstractProgressInstallerListener ; import com . izforge . izpack . util . FileExecutor ; import com . izforge . izpack . util . OsVersion ; public class ChmodInstallerListener extends AbstractProgressInstallerListener { public ChmodInstallerListener ( InstallData installData ) { super ( installData ) ; } @ Override public boolean isFileListener ( ) { return true ; } @ Override public void afterFile ( File filePath , PackFile pf , Pack pack ) { if ( pf . getAdditionals ( ) == null ) { return ; } Object file = pf . getAdditionals ( ) . get ( "<STR_LIT>" ) ; int fileVal = - <NUM_LIT:1> ; if ( file != null && file instanceof Integer ) { fileVal = ( Integer ) file ; } if ( fileVal != - <NUM_LIT:1> ) { chmod ( filePath , fileVal ) ; } } @ Override public void afterDir ( File dirPath , PackFile pf , Pack pack ) { if ( pf . getAdditionals ( ) == null ) { return ; } if ( dirPath == null ) { return ; } Object dir = pf . getAdditionals ( ) . get ( "<STR_LIT>" ) ; int dirVal = - <NUM_LIT:1> ; if ( dir != null && dir instanceof Integer ) { dirVal = ( Integer ) dir ; } if ( dirVal != - <NUM_LIT:1> ) { if ( ( dirVal & <NUM_LIT> ) < <NUM_LIT> ) { throw new InstallerException ( "<STR_LIT>" + dirPath . getAbsolutePath ( ) + "<STR_LIT>" ) ; } chmod ( dirPath , dirVal ) ; } } private void chmod ( File path , int permissions ) { String pathSep = System . getProperty ( "<STR_LIT>" ) ; if ( OsVersion . IS_WINDOWS ) { throw new InstallerException ( "<STR_LIT>" ) ; } if ( path == null ) { return ; } String permStr = Integer . toOctalString ( permissions ) ; String [ ] params = { "<STR_LIT>" , permStr , path . getAbsolutePath ( ) } ; String [ ] output = new String [ <NUM_LIT:2> ] ; FileExecutor fe = new FileExecutor ( ) ; fe . executeCommand ( params , output ) ; } } </s>
<s> package com . izforge . izpack . integration . panelaction ; import com . izforge . izpack . api . data . InstallData ; import com . izforge . izpack . api . data . Panel ; public class PreConstructPanelAction extends TestPanelAction { public PreConstructPanelAction ( Panel panel , InstallData installData ) { super ( panel , ActionStage . preconstruct , installData ) ; } } </s>
<s> package com . izforge . izpack . integration . panelaction ; import static org . junit . Assert . assertEquals ; import static org . junit . Assert . assertNotNull ; import static org . junit . Assert . assertNull ; import static org . junit . Assert . assertTrue ; import static org . junit . Assert . fail ; import java . util . Map ; import com . izforge . izpack . api . data . InstallData ; import com . izforge . izpack . api . data . Panel ; import com . izforge . izpack . api . data . PanelActionConfiguration ; import com . izforge . izpack . api . handler . AbstractUIHandler ; import com . izforge . izpack . api . installer . DataValidator ; import com . izforge . izpack . data . PanelAction ; import com . izforge . izpack . integration . datavalidator . TestDataValidator ; public class TestPanelAction extends TestDataValidator implements PanelAction { private final ActionStage stage ; public TestPanelAction ( Panel panel , ActionStage stage , InstallData installData ) { super ( panel , installData ) ; this . stage = stage ; } public static int getPreConstruct ( String panelId , InstallData installData ) { return getValue ( panelId + "<STR_LIT:.>" + ActionStage . preconstruct , installData ) ; } public static int getPreActivate ( String panelId , InstallData installData ) { return getValue ( panelId + "<STR_LIT:.>" + ActionStage . preactivate , installData ) ; } public static int getPreValidate ( String panelId , InstallData installData ) { return getValue ( panelId + "<STR_LIT:.>" + ActionStage . prevalidate , installData ) ; } public static int getPostValidate ( String panelId , InstallData installData ) { return getValue ( panelId + "<STR_LIT:.>" + ActionStage . postvalidate , installData ) ; } @ Override public void executeAction ( InstallData installData , AbstractUIHandler handler ) { String id = getPanelId ( ) ; if ( stage == ActionStage . preconstruct ) { assertNull ( handler ) ; } else { assertNotNull ( handler ) ; } String variable = id + "<STR_LIT:.>" + stage ; int value = increment ( variable ) ; System . err . println ( "<STR_LIT>" + variable + "<STR_LIT:=>" + value + "<STR_LIT>" + Thread . currentThread ( ) . getName ( ) ) ; int preConstruct = getPreConstruct ( ) ; int preActivate = getPreActivate ( ) ; int preValidate = getPreValidate ( ) ; int validate = getValidate ( ) ; int postValidate = getPostValidate ( ) ; switch ( stage ) { case preconstruct : assertEquals ( <NUM_LIT:1> , preConstruct ) ; assertEquals ( <NUM_LIT:0> , preActivate ) ; assertEquals ( <NUM_LIT:0> , preValidate ) ; assertEquals ( <NUM_LIT:0> , validate ) ; assertEquals ( <NUM_LIT:0> , postValidate ) ; break ; case preactivate : assertEquals ( <NUM_LIT:1> , preConstruct ) ; assertEquals ( <NUM_LIT:1> , preActivate ) ; assertEquals ( <NUM_LIT:0> , preValidate ) ; assertEquals ( <NUM_LIT:0> , validate ) ; assertEquals ( <NUM_LIT:0> , postValidate ) ; break ; case prevalidate : assertEquals ( <NUM_LIT:1> , preConstruct ) ; assertEquals ( <NUM_LIT:1> , preActivate ) ; assertTrue ( preValidate >= <NUM_LIT:1> ) ; assertEquals ( preValidate - <NUM_LIT:1> , validate ) ; assertEquals ( preValidate - <NUM_LIT:1> , postValidate ) ; break ; case postvalidate : assertEquals ( <NUM_LIT:1> , preConstruct ) ; assertEquals ( <NUM_LIT:1> , preActivate ) ; assertTrue ( preValidate >= <NUM_LIT:1> ) ; assertEquals ( preValidate , validate ) ; assertEquals ( preValidate , postValidate ) ; break ; default : fail ( "<STR_LIT>" + stage ) ; } } @ Override public Status validateData ( InstallData installData ) { Status status = super . validateData ( installData ) ; int preConstruct = getPreConstruct ( ) ; int preActivate = getPreActivate ( ) ; int preValidate = getPreValidate ( ) ; int validate = getValidate ( ) ; int postValidate = getPostValidate ( ) ; assertEquals ( <NUM_LIT:1> , preConstruct ) ; assertEquals ( <NUM_LIT:1> , preActivate ) ; assertTrue ( preValidate >= <NUM_LIT:1> ) ; assertEquals ( preValidate , validate ) ; assertEquals ( preValidate - <NUM_LIT:1> , postValidate ) ; return status ; } @ Override public void initialize ( PanelActionConfiguration configuration ) { if ( configuration != null ) { String prefix = getPanelId ( ) + "<STR_LIT:.>" + stage . toString ( ) . toLowerCase ( ) + "<STR_LIT>" ; InstallData installData = getInstallData ( ) ; for ( Map . Entry < String , String > entry : configuration . getProperties ( ) . entrySet ( ) ) { installData . setVariable ( prefix + entry . getKey ( ) , entry . getValue ( ) ) ; } } } private int getPreConstruct ( ) { return getValue ( getPanelId ( ) + "<STR_LIT:.>" + ActionStage . preconstruct ) ; } private int getPreActivate ( ) { return getValue ( getPanelId ( ) + "<STR_LIT:.>" + ActionStage . preactivate ) ; } private int getPreValidate ( ) { return getValue ( getPanelId ( ) + "<STR_LIT:.>" + ActionStage . prevalidate ) ; } private int getPostValidate ( ) { return getValue ( getPanelId ( ) + "<STR_LIT:.>" + ActionStage . postvalidate ) ; } } </s>
<s> package com . izforge . izpack . integration . panelaction ; import com . izforge . izpack . api . data . InstallData ; import com . izforge . izpack . api . data . Panel ; public class PostValidatePanelAction extends TestPanelAction { public PostValidatePanelAction ( Panel panel , InstallData installData ) { super ( panel , ActionStage . postvalidate , installData ) ; } } </s>
<s> package com . izforge . izpack . integration . panelaction ; import com . izforge . izpack . api . data . InstallData ; import com . izforge . izpack . api . data . Panel ; public class PreActivatePanelAction extends TestPanelAction { public PreActivatePanelAction ( Panel panel , InstallData installData ) { super ( panel , ActionStage . preactivate , installData ) ; } } </s>
<s> package com . izforge . izpack . integration . panelaction ; import static org . junit . Assert . assertEquals ; import static org . junit . Assert . assertFalse ; import static org . junit . Assert . assertNotNull ; import static org . junit . Assert . assertTrue ; import java . io . File ; import java . util . List ; import java . util . Set ; import org . fest . swing . core . matcher . JButtonMatcher ; import org . fest . swing . fixture . DialogFixture ; import org . fest . swing . fixture . FrameFixture ; import org . fest . swing . timing . Timeout ; import org . junit . After ; import org . junit . Before ; import org . junit . Rule ; import org . junit . Test ; import org . junit . rules . TemporaryFolder ; import org . junit . runner . RunWith ; import com . izforge . izpack . api . GuiId ; import com . izforge . izpack . api . data . InstallData ; import com . izforge . izpack . api . data . Panel ; import com . izforge . izpack . api . data . PanelActionConfiguration ; import com . izforge . izpack . api . data . binding . ActionStage ; import com . izforge . izpack . compiler . container . TestInstallationContainer ; import com . izforge . izpack . data . PanelAction ; import com . izforge . izpack . installer . gui . InstallerController ; import com . izforge . izpack . installer . gui . InstallerFrame ; import com . izforge . izpack . installer . gui . IzPanel ; import com . izforge . izpack . installer . gui . IzPanels ; import com . izforge . izpack . integration . HelperTestMethod ; import com . izforge . izpack . panels . hello . HelloPanel ; import com . izforge . izpack . panels . simplefinish . SimpleFinishPanel ; import com . izforge . izpack . test . Container ; import com . izforge . izpack . test . InstallFile ; import com . izforge . izpack . test . junit . PicoRunner ; import com . izforge . izpack . test . util . TestHousekeeper ; @ RunWith ( PicoRunner . class ) @ Container ( TestInstallationContainer . class ) public class PanelActionTest { @ Rule public TemporaryFolder temporaryFolder = new TemporaryFolder ( ) ; private final InstallData installData ; private final InstallerFrame frame ; private final InstallerController controller ; private final TestHousekeeper housekeeper ; private final IzPanels panels ; private FrameFixture frameFixture ; public PanelActionTest ( InstallData installData , InstallerFrame frame , InstallerController controller , TestHousekeeper housekeeper , IzPanels panels ) { this . installData = installData ; this . frame = frame ; this . controller = controller ; this . housekeeper = housekeeper ; this . panels = panels ; } @ Before public void setUp ( ) { File installPath = new File ( temporaryFolder . getRoot ( ) , "<STR_LIT>" ) ; assertTrue ( installPath . mkdirs ( ) ) ; installData . setInstallPath ( installPath . getAbsolutePath ( ) ) ; } @ After public void tearDown ( ) { if ( frameFixture != null ) { frameFixture . cleanUp ( ) ; } } @ Test @ InstallFile ( "<STR_LIT>" ) public void testPanelActions ( ) throws Exception { assertEquals ( <NUM_LIT:3> , panels . getPanels ( ) . size ( ) ) ; Panel hello1 = panels . getPanels ( ) . get ( <NUM_LIT:0> ) ; Panel hello2 = panels . getPanels ( ) . get ( <NUM_LIT:1> ) ; Panel finish = panels . getPanels ( ) . get ( <NUM_LIT:2> ) ; checkActions ( hello1 , PreConstructPanelAction . class , PreActivatePanelAction . class , PreValidatePanelAction . class , PostValidatePanelAction . class ) ; checkActions ( hello2 , TestPanelAction . class , TestPanelAction . class , TestPanelAction . class , TestPanelAction . class ) ; checkActions ( finish , PreConstructPanelAction . class , PreActivatePanelAction . class , PreValidatePanelAction . class , PostValidatePanelAction . class ) ; checkActionInvocations ( "<STR_LIT>" , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ; frameFixture = HelperTestMethod . prepareFrameFixture ( frame , controller ) ; checkActionsConfiguration ( hello1 ) ; checkActionInvocations ( "<STR_LIT>" , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ; Thread . sleep ( <NUM_LIT> ) ; checkCurrentPanel ( HelloPanel . class ) ; installData . setVariable ( "<STR_LIT>" , "<STR_LIT>" ) ; frameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; checkDialog ( "<STR_LIT>" ) ; checkActionInvocations ( "<STR_LIT>" , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) ; installData . setVariable ( "<STR_LIT>" , "<STR_LIT>" ) ; frameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; checkDialog ( "<STR_LIT>" ) ; checkActionInvocations ( "<STR_LIT>" , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> ) ; Thread . sleep ( <NUM_LIT:1000> ) ; checkCurrentPanel ( HelloPanel . class ) ; installData . setVariable ( "<STR_LIT>" , "<STR_LIT:OK>" ) ; frameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; checkActionInvocations ( "<STR_LIT>" , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) ; Thread . sleep ( <NUM_LIT:1000> ) ; checkCurrentPanel ( SimpleFinishPanel . class ) ; checkActionInvocations ( "<STR_LIT>" , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ; frameFixture . button ( GuiId . BUTTON_QUIT . id ) . click ( ) ; checkActionInvocations ( "<STR_LIT>" , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ; housekeeper . waitShutdown ( <NUM_LIT:2> * <NUM_LIT> * <NUM_LIT:1000> ) ; assertTrue ( housekeeper . hasShutdown ( ) ) ; assertEquals ( <NUM_LIT:0> , housekeeper . getExitCode ( ) ) ; assertFalse ( housekeeper . getReboot ( ) ) ; } private void checkCurrentPanel ( Class < ? extends IzPanel > type ) { Panel panel = panels . getPanel ( ) ; assertEquals ( type . getName ( ) , panel . getClassName ( ) ) ; } private void checkActionInvocations ( String panelId , int preConstruct , int preActivate , int preValidate , int validate , int postValidate ) { try { Thread . sleep ( <NUM_LIT> ) ; } catch ( InterruptedException ignore ) { } assertEquals ( preConstruct , TestPanelAction . getPreConstruct ( panelId , installData ) ) ; assertEquals ( preActivate , TestPanelAction . getPreActivate ( panelId , installData ) ) ; assertEquals ( preValidate , TestPanelAction . getPreValidate ( panelId , installData ) ) ; assertEquals ( validate , TestPanelAction . getValidate ( panelId , installData ) ) ; assertEquals ( postValidate , TestPanelAction . getPostValidate ( panelId , installData ) ) ; } private void checkActions ( Panel panel , Class preConstruction , Class preActivation , Class preValidation , Class postValidation ) { checkAction ( panel . getPreConstructionActions ( ) , preConstruction ) ; checkAction ( panel . getPreActivationActions ( ) , preActivation ) ; checkAction ( panel . getPreValidationActions ( ) , preValidation ) ; checkAction ( panel . getPostValidationActions ( ) , postValidation ) ; } private void checkAction ( List < PanelActionConfiguration > actions , Class type ) { assertNotNull ( actions ) ; assertEquals ( <NUM_LIT:1> , actions . size ( ) ) ; assertEquals ( type . getName ( ) , actions . get ( <NUM_LIT:0> ) . getActionClassName ( ) ) ; } private void checkActionsConfiguration ( Panel panel ) { checkActionConfiguration ( panel . getPanelId ( ) , ActionStage . PRECONSTRUCT ) ; checkActionConfiguration ( panel . getPanelId ( ) , ActionStage . PREACTIVATE ) ; checkActionConfiguration ( panel . getPanelId ( ) , ActionStage . PREVALIDATE , "<STR_LIT>" , "<STR_LIT:value1>" ) ; checkActionConfiguration ( panel . getPanelId ( ) , ActionStage . POSTVALIDATE , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; } private void checkActionConfiguration ( String panelId , ActionStage stage , String ... properties ) { String prefix = panelId + "<STR_LIT:.>" + stage . toString ( ) . toLowerCase ( ) + "<STR_LIT>" ; if ( properties . length == <NUM_LIT:0> ) { Set < Object > keys = installData . getVariables ( ) . getProperties ( ) . keySet ( ) ; for ( Object key : keys ) { assertFalse ( key . toString ( ) . startsWith ( prefix ) ) ; } } else { for ( int i = <NUM_LIT:0> ; i < properties . length ; i ++ ) { String name = prefix + properties [ i ] ; String value = properties [ ++ i ] ; assertEquals ( value , installData . getVariable ( name ) ) ; } } } private void checkDialog ( String text ) { DialogFixture dialog = frameFixture . dialog ( Timeout . timeout ( <NUM_LIT> ) ) ; assertEquals ( text , dialog . label ( "<STR_LIT>" ) . text ( ) ) ; dialog . button ( JButtonMatcher . withText ( "<STR_LIT:OK>" ) ) . click ( ) ; } } </s>
<s> package com . izforge . izpack . integration . panelaction ; import com . izforge . izpack . api . data . InstallData ; import com . izforge . izpack . api . data . Panel ; public class PreValidatePanelAction extends TestPanelAction { public PreValidatePanelAction ( Panel panel , InstallData installData ) { super ( panel , ActionStage . prevalidate , installData ) ; } } </s>
<s> package com . izforge . izpack . integration ; import java . io . File ; import org . junit . Before ; import org . junit . Rule ; import org . junit . rules . TemporaryFolder ; import com . izforge . izpack . api . data . InstallData ; public class AbstractInstallationTest { @ Rule public TemporaryFolder temporaryFolder = new TemporaryFolder ( ) ; private InstallData installData ; public AbstractInstallationTest ( InstallData installData ) { this . installData = installData ; } @ Before public void setUp ( ) throws Exception { File installPath = new File ( temporaryFolder . getRoot ( ) , "<STR_LIT>" ) ; installData . setInstallPath ( installPath . getAbsolutePath ( ) ) ; installData . setDefaultInstallPath ( installPath . getAbsolutePath ( ) ) ; } protected String getInstallPath ( ) { return installData . getInstallPath ( ) ; } protected InstallData getInstallData ( ) { return installData ; } } </s>
<s> package com . izforge . izpack . integration ; import static org . hamcrest . MatcherAssert . assertThat ; import static org . junit . Assert . assertEquals ; import static org . junit . Assert . assertNotNull ; import java . util . List ; import org . hamcrest . core . Is ; import org . junit . Test ; import org . junit . runner . RunWith ; import com . izforge . izpack . compiler . container . TestInstallationContainer ; import com . izforge . izpack . data . CustomData ; import com . izforge . izpack . event . RegistryInstallerListener ; import com . izforge . izpack . event . RegistryUninstallerListener ; import com . izforge . izpack . event . SummaryLoggerInstallerListener ; import com . izforge . izpack . installer . data . UninstallData ; import com . izforge . izpack . installer . event . InstallerListeners ; import com . izforge . izpack . test . Container ; import com . izforge . izpack . test . InstallFile ; import com . izforge . izpack . test . junit . PicoRunner ; @ RunWith ( PicoRunner . class ) @ Container ( TestInstallationContainer . class ) public class EventTest { private final InstallerListeners listeners ; private final UninstallData uninstallData ; public EventTest ( InstallerListeners listeners , UninstallData uninstallData ) { this . listeners = listeners ; this . uninstallData = uninstallData ; } @ Test @ InstallFile ( "<STR_LIT>" ) @ SuppressWarnings ( "<STR_LIT:unchecked>" ) public void eventInitialization ( ) throws Exception { assertThat ( listeners . size ( ) , Is . is ( <NUM_LIT:2> ) ) ; assertThat ( listeners . get ( <NUM_LIT:0> ) , Is . is ( SummaryLoggerInstallerListener . class ) ) ; assertThat ( listeners . get ( <NUM_LIT:1> ) , Is . is ( RegistryInstallerListener . class ) ) ; List < CustomData > uninstallListeners = uninstallData . getUninstallerListeners ( ) ; assertNotNull ( uninstallListeners ) ; assertThat ( uninstallListeners . size ( ) , Is . is ( <NUM_LIT:1> ) ) ; CustomData customData = uninstallListeners . get ( <NUM_LIT:0> ) ; assertEquals ( RegistryUninstallerListener . class . getName ( ) , customData . listenerName ) ; } } </s>
<s> package com . izforge . izpack . integration ; import static org . hamcrest . MatcherAssert . assertThat ; import java . io . File ; import java . util . ArrayList ; import java . util . List ; import org . apache . commons . lang . StringUtils ; import org . fest . swing . fixture . DialogFixture ; import org . fest . swing . fixture . FrameFixture ; import org . fest . swing . timing . Timeout ; import org . hamcrest . collection . IsCollectionContaining ; import org . hamcrest . core . Is ; import org . junit . After ; import org . junit . Before ; import org . junit . Rule ; import org . junit . Test ; import org . junit . rules . TemporaryFolder ; import org . junit . rules . TestRule ; import org . junit . runner . RunWith ; import com . izforge . izpack . api . GuiId ; import com . izforge . izpack . api . exception . NativeLibException ; import com . izforge . izpack . compiler . container . TestInstallationContainer ; import com . izforge . izpack . core . os . RegistryDefaultHandler ; import com . izforge . izpack . core . os . RegistryHandler ; import com . izforge . izpack . installer . data . GUIInstallData ; import com . izforge . izpack . installer . gui . InstallerController ; import com . izforge . izpack . installer . gui . InstallerFrame ; import com . izforge . izpack . installer . language . LanguageDialog ; import com . izforge . izpack . test . Container ; import com . izforge . izpack . test . InstallFile ; import com . izforge . izpack . test . junit . PicoRunner ; import com . izforge . izpack . util . OsVersion ; @ RunWith ( PicoRunner . class ) @ Container ( TestInstallationContainer . class ) public class IzpackInstallationTest { @ Rule public TemporaryFolder temporaryFolder = new TemporaryFolder ( ) ; @ Rule public TestRule globalTimeout = new org . junit . rules . Timeout ( HelperTestMethod . TIMEOUT ) ; private DialogFixture dialogFrameFixture ; private FrameFixture installerFrameFixture ; private LanguageDialog languageDialog ; private InstallerFrame installerFrame ; private GUIInstallData installData ; private InstallerController installerController ; private RegistryDefaultHandler handler ; public IzpackInstallationTest ( LanguageDialog languageDialog , InstallerFrame installerFrame , GUIInstallData installData , InstallerController installerController , RegistryDefaultHandler handler ) { this . installerController = installerController ; this . languageDialog = languageDialog ; this . installData = installData ; this . installerFrame = installerFrame ; this . handler = handler ; } @ Before public void setUp ( ) throws NativeLibException { RegistryHandler registry = handler . getInstance ( ) ; if ( registry != null ) { String uninstallName = registry . getUninstallName ( ) ; if ( ! StringUtils . isEmpty ( uninstallName ) ) { registry . setRoot ( RegistryHandler . HKEY_LOCAL_MACHINE ) ; String key = RegistryHandler . UNINSTALL_ROOT + uninstallName ; if ( registry . keyExist ( key ) ) { registry . deleteKey ( key ) ; } } } } @ After public void tearBinding ( ) throws NoSuchFieldException , IllegalAccessException { try { if ( dialogFrameFixture != null ) { dialogFrameFixture . cleanUp ( ) ; dialogFrameFixture = null ; } } finally { if ( installerFrameFixture != null ) { installerFrameFixture . cleanUp ( ) ; installerFrameFixture = null ; } } } @ Test @ InstallFile ( "<STR_LIT>" ) public void testIzpackInstallation ( ) throws Exception { File installPath = new File ( temporaryFolder . getRoot ( ) , "<STR_LIT>" ) ; installData . setInstallPath ( installPath . getAbsolutePath ( ) ) ; installData . setDefaultInstallPath ( installPath . getAbsolutePath ( ) ) ; HelperTestMethod . clickDefaultLang ( languageDialog ) ; installerFrameFixture = HelperTestMethod . prepareFrameFixture ( installerFrame , installerController ) ; Thread . sleep ( <NUM_LIT> ) ; Thread . sleep ( <NUM_LIT> ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; installerFrameFixture . radioButton ( GuiId . LICENCE_YES_RADIO . id ) . click ( ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; installerFrameFixture . optionPane ( Timeout . timeout ( <NUM_LIT:1000> ) ) . focus ( ) ; installerFrameFixture . optionPane ( ) . requireWarningMessage ( ) ; installerFrameFixture . optionPane ( ) . okButton ( ) . click ( ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; HelperTestMethod . waitAndCheckInstallation ( installData , installPath ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; if ( ! OsVersion . IS_MAC ) { Thread . sleep ( <NUM_LIT:1000> ) ; installerFrameFixture . checkBox ( GuiId . SHORTCUT_CREATE_CHECK_BOX . id ) . click ( ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; } Thread . sleep ( <NUM_LIT:1000> ) ; installerFrameFixture . button ( GuiId . BUTTON_QUIT . id ) . click ( ) ; Thread . sleep ( <NUM_LIT:1000> ) ; checkIzpackInstallation ( installPath ) ; File uninstaller = UninstallHelper . getUninstallerJar ( installData ) ; UninstallHelper . guiUninstall ( uninstaller ) ; } private void checkIzpackInstallation ( File installPath ) { List < String > paths = new ArrayList < String > ( ) ; File [ ] files = installPath . listFiles ( ) ; if ( files != null ) { for ( File file : files ) { paths . add ( file . getName ( ) ) ; } } assertThat ( paths , IsCollectionContaining . hasItems ( Is . is ( "<STR_LIT>" ) , Is . is ( "<STR_LIT>" ) , Is . is ( "<STR_LIT>" ) ) ) ; } } </s>
<s> package com . izforge . izpack . integration ; import static org . hamcrest . MatcherAssert . assertThat ; import java . awt . Image ; import java . io . File ; import org . fest . swing . fixture . FrameFixture ; import org . hamcrest . core . Is ; import org . hamcrest . core . IsNull ; import org . junit . After ; import org . junit . Ignore ; import org . junit . Rule ; import org . junit . Test ; import org . junit . rules . TestRule ; import org . junit . rules . Timeout ; import org . junit . runner . RunWith ; import com . izforge . izpack . api . GuiId ; import com . izforge . izpack . compiler . container . TestInstallationContainer ; import com . izforge . izpack . gui . IconsDatabase ; import com . izforge . izpack . installer . container . impl . InstallerContainer ; import com . izforge . izpack . installer . data . GUIInstallData ; import com . izforge . izpack . installer . gui . InstallerController ; import com . izforge . izpack . installer . gui . InstallerFrame ; import com . izforge . izpack . installer . language . LanguageDialog ; import com . izforge . izpack . panels . hello . HelloPanel ; import com . izforge . izpack . test . Container ; import com . izforge . izpack . test . InstallFile ; import com . izforge . izpack . test . junit . PicoRunner ; @ RunWith ( PicoRunner . class ) @ Container ( TestInstallationContainer . class ) public class InstallationTest { @ Rule public TestRule globalTimeout = new Timeout ( HelperTestMethod . TIMEOUT ) ; private FrameFixture installerFrameFixture ; private IconsDatabase icons ; private LanguageDialog languageDialog ; private InstallerFrame installerFrame ; private GUIInstallData installData ; private InstallerController installerController ; private InstallerContainer installerContainer ; public InstallationTest ( IconsDatabase icons , LanguageDialog languageDialog , InstallerFrame installerFrame , GUIInstallData installData , InstallerController installerController , InstallerContainer installerContainer ) { this . installerController = installerController ; this . icons = icons ; this . languageDialog = languageDialog ; this . installData = installData ; this . installerFrame = installerFrame ; this . installerContainer = installerContainer ; } @ After public void tearBinding ( ) throws NoSuchFieldException , IllegalAccessException { if ( installerFrameFixture != null ) { installerFrameFixture . cleanUp ( ) ; installerFrameFixture = null ; } } @ Test @ InstallFile ( "<STR_LIT>" ) public void testHelloAndFinishPanels ( ) throws Exception { Image image = icons . get ( "<STR_LIT>" ) . getImage ( ) ; assertThat ( image , IsNull . < Object > notNullValue ( ) ) ; languageDialog . initLangPack ( ) ; installerFrameFixture = HelperTestMethod . prepareFrameFixture ( installerFrame , installerController ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; installerFrameFixture . requireVisible ( ) ; } @ Test @ InstallFile ( "<STR_LIT>" ) public void testMultiplePanels ( ) throws Exception { installerController . buildInstallation ( ) ; HelloPanel firstHelloPanel = ( HelloPanel ) installerContainer . getComponent ( "<STR_LIT>" ) ; assertThat ( firstHelloPanel . getMetadata ( ) . getPanelId ( ) , Is . is ( "<STR_LIT>" ) ) ; HelloPanel secondHelloPanel = ( HelloPanel ) installerContainer . getComponent ( "<STR_LIT>" ) ; assertThat ( secondHelloPanel . getMetadata ( ) . getPanelId ( ) , Is . is ( "<STR_LIT>" ) ) ; } @ Test @ InstallFile ( "<STR_LIT>" ) public void testPanelConfiguration ( ) throws Exception { installerController . buildInstallation ( ) ; HelloPanel helloPanel = ( HelloPanel ) installerContainer . getComponent ( "<STR_LIT>" ) ; assertThat ( helloPanel . getMetadata ( ) . getConfiguration ( "<STR_LIT>" ) , Is . is ( "<STR_LIT:value1>" ) ) ; assertThat ( helloPanel . getMetadata ( ) . getConfiguration ( "<STR_LIT>" ) , Is . is ( "<STR_LIT>" ) ) ; } @ Test @ InstallFile ( "<STR_LIT>" ) public void testSubstanceLaf ( ) throws Exception { languageDialog . initLangPack ( ) ; installerFrameFixture = HelperTestMethod . prepareFrameFixture ( installerFrame , installerController ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; installerFrameFixture . requireVisible ( ) ; } @ Test @ InstallFile ( "<STR_LIT>" ) public void testSilverpeas ( ) throws Exception { languageDialog . initLangPack ( ) ; installerFrameFixture = HelperTestMethod . prepareFrameFixture ( installerFrame , installerController ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; installerFrameFixture . requireVisible ( ) ; } @ Test @ Ignore @ InstallFile ( "<STR_LIT>" ) public void testHelloAndFinishPanelsCompressed ( ) throws Exception { } @ Test @ InstallFile ( "<STR_LIT>" ) public void testBasicInstall ( ) throws Exception { File installPath = HelperTestMethod . prepareInstallation ( installData ) ; HelperTestMethod . clickDefaultLang ( languageDialog ) ; installerFrameFixture = HelperTestMethod . prepareFrameFixture ( installerFrame , installerController ) ; Thread . sleep ( <NUM_LIT> ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; Thread . sleep ( <NUM_LIT> ) ; installerFrameFixture . textBox ( GuiId . INFO_PANEL_TEXT_AREA . id ) . requireText ( "<STR_LIT>" ) ; installerFrameFixture . button ( GuiId . BUTTON_PREV . id ) . requireVisible ( ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; installerFrameFixture . button ( GuiId . BUTTON_PREV . id ) . requireEnabled ( ) ; Thread . sleep ( <NUM_LIT> ) ; installerFrameFixture . textBox ( GuiId . LICENCE_TEXT_AREA . id ) . requireText ( "<STR_LIT>" ) ; installerFrameFixture . radioButton ( GuiId . LICENCE_NO_RADIO . id ) . requireSelected ( ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . requireDisabled ( ) ; installerFrameFixture . radioButton ( GuiId . LICENCE_YES_RADIO . id ) . click ( ) ; Thread . sleep ( <NUM_LIT> ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; Thread . sleep ( <NUM_LIT:1000> ) ; installerFrameFixture . optionPane ( ) . requireWarningMessage ( ) ; installerFrameFixture . optionPane ( ) . okButton ( ) . click ( ) ; Thread . sleep ( <NUM_LIT> ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; HelperTestMethod . waitAndCheckInstallation ( installData , installPath ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; installerFrameFixture . button ( GuiId . FINISH_PANEL_AUTO_BUTTON . id ) . click ( ) ; Thread . sleep ( <NUM_LIT> ) ; installerFrameFixture . fileChooser ( GuiId . FINISH_PANEL_FILE_CHOOSER . id ) . fileNameTextBox ( ) . enterText ( "<STR_LIT>" ) ; Thread . sleep ( <NUM_LIT> ) ; installerFrameFixture . fileChooser ( GuiId . FINISH_PANEL_FILE_CHOOSER . id ) . approve ( ) ; assertThat ( new File ( installPath , "<STR_LIT>" ) . exists ( ) , Is . is ( true ) ) ; } } </s>
<s> package com . izforge . izpack . integration . datavalidator ; import com . izforge . izpack . api . data . InstallData ; import com . izforge . izpack . api . data . Panel ; import com . izforge . izpack . api . installer . DataValidator ; public class TestDataValidator implements DataValidator { private final Panel panel ; private final InstallData installData ; public TestDataValidator ( Panel panel , InstallData installData ) { this . installData = installData ; this . panel = panel ; } public static int getValidate ( String panelId , InstallData installData ) { return getValue ( panelId + "<STR_LIT>" , installData ) ; } @ Override public Status validateData ( InstallData installData ) { String id = getPanelId ( ) ; String status = installData . getVariable ( id + "<STR_LIT>" ) ; increment ( id + "<STR_LIT>" ) ; return ( status != null ) ? Status . valueOf ( status ) : Status . ERROR ; } @ Override public String getErrorMessageId ( ) { return getPanelId ( ) + "<STR_LIT>" ; } @ Override public String getWarningMessageId ( ) { return getPanelId ( ) + "<STR_LIT>" ; } @ Override public boolean getDefaultAnswer ( ) { return false ; } protected InstallData getInstallData ( ) { return installData ; } protected String getPanelId ( ) { return panel . getPanelId ( ) ; } protected int getValidate ( ) { return getValue ( getPanelId ( ) + "<STR_LIT>" ) ; } protected int getValue ( String variable ) { return getValue ( variable , installData ) ; } protected static int getValue ( String variable , InstallData installData ) { String value = installData . getVariable ( variable ) ; if ( value == null ) { value = "<STR_LIT:0>" ; } return Integer . valueOf ( value ) ; } protected int increment ( String variable ) { int value = getValue ( variable ) ; value ++ ; installData . setVariable ( variable , Integer . toString ( value ) ) ; return value ; } } </s>
<s> package com . izforge . izpack . integration . datavalidator ; import static org . junit . Assert . assertEquals ; import static org . junit . Assert . assertFalse ; import static org . junit . Assert . assertTrue ; import java . io . File ; import java . util . List ; import org . fest . swing . core . matcher . JButtonMatcher ; import org . fest . swing . fixture . DialogFixture ; import org . fest . swing . fixture . FrameFixture ; import org . fest . swing . timing . Timeout ; import org . junit . After ; import org . junit . Before ; import org . junit . Rule ; import org . junit . Test ; import org . junit . rules . TemporaryFolder ; import org . junit . runner . RunWith ; import com . izforge . izpack . api . GuiId ; import com . izforge . izpack . api . data . Panel ; import com . izforge . izpack . api . installer . DataValidator ; import com . izforge . izpack . compiler . container . TestInstallationContainer ; import com . izforge . izpack . installer . data . GUIInstallData ; import com . izforge . izpack . installer . gui . InstallerController ; import com . izforge . izpack . installer . gui . InstallerFrame ; import com . izforge . izpack . installer . gui . IzPanel ; import com . izforge . izpack . installer . gui . IzPanels ; import com . izforge . izpack . integration . HelperTestMethod ; import com . izforge . izpack . panels . hello . HelloPanel ; import com . izforge . izpack . panels . install . InstallPanel ; import com . izforge . izpack . panels . simplefinish . SimpleFinishPanel ; import com . izforge . izpack . test . Container ; import com . izforge . izpack . test . InstallFile ; import com . izforge . izpack . test . junit . PicoRunner ; import com . izforge . izpack . test . util . TestHousekeeper ; @ RunWith ( PicoRunner . class ) @ Container ( TestInstallationContainer . class ) public class DataValidatorTest { @ Rule public TemporaryFolder temporaryFolder = new TemporaryFolder ( ) ; private final GUIInstallData installData ; private final InstallerFrame frame ; private final InstallerController controller ; private final IzPanels panels ; private final TestHousekeeper housekeeper ; private FrameFixture frameFixture ; public DataValidatorTest ( GUIInstallData installData , InstallerFrame frame , InstallerController controller , IzPanels panels , TestHousekeeper housekeeper ) { this . installData = installData ; this . frame = frame ; this . controller = controller ; this . panels = panels ; this . housekeeper = housekeeper ; } @ Before public void setUp ( ) { File installPath = new File ( temporaryFolder . getRoot ( ) , "<STR_LIT>" ) ; assertTrue ( installPath . mkdirs ( ) ) ; installData . setInstallPath ( installPath . getAbsolutePath ( ) ) ; } @ After public void tearDown ( ) { if ( frameFixture != null ) { frameFixture . cleanUp ( ) ; } } @ Test @ InstallFile ( "<STR_LIT>" ) public void testDataValidators ( ) throws Exception { List < Panel > list = panels . getPanels ( ) ; assertEquals ( <NUM_LIT:3> , list . size ( ) ) ; Panel hello = list . get ( <NUM_LIT:0> ) ; Panel install = list . get ( <NUM_LIT:1> ) ; Panel finish = list . get ( <NUM_LIT:2> ) ; assertEquals ( HelloPanel . class . getName ( ) , hello . getClassName ( ) ) ; assertEquals ( TestDataValidator . class . getName ( ) , hello . getValidator ( ) ) ; assertEquals ( InstallPanel . class . getName ( ) , install . getClassName ( ) ) ; assertEquals ( TestDataValidator . class . getName ( ) , install . getValidator ( ) ) ; assertEquals ( SimpleFinishPanel . class . getName ( ) , finish . getClassName ( ) ) ; assertEquals ( TestDataValidator . class . getName ( ) , finish . getValidator ( ) ) ; frameFixture = HelperTestMethod . prepareFrameFixture ( frame , controller ) ; Thread . sleep ( <NUM_LIT> ) ; checkCurrentPanel ( HelloPanel . class ) ; installData . setVariable ( "<STR_LIT>" , "<STR_LIT>" ) ; frameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; checkDialog ( "<STR_LIT>" ) ; checkCurrentPanel ( HelloPanel . class ) ; installData . setVariable ( "<STR_LIT>" , "<STR_LIT>" ) ; frameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; checkDialog ( "<STR_LIT>" ) ; assertEquals ( <NUM_LIT:2> , TestDataValidator . getValidate ( "<STR_LIT>" , installData ) ) ; Thread . sleep ( <NUM_LIT:1000> ) ; checkCurrentPanel ( InstallPanel . class ) ; installData . setVariable ( "<STR_LIT>" , "<STR_LIT>" ) ; frameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; checkDialog ( "<STR_LIT>" ) ; installData . setVariable ( "<STR_LIT>" , "<STR_LIT:OK>" ) ; frameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; assertEquals ( <NUM_LIT:2> , TestDataValidator . getValidate ( "<STR_LIT>" , installData ) ) ; Thread . sleep ( <NUM_LIT:1000> ) ; checkCurrentPanel ( SimpleFinishPanel . class ) ; installData . setVariable ( "<STR_LIT>" , "<STR_LIT>" ) ; frameFixture . button ( GuiId . BUTTON_QUIT . id ) . click ( ) ; assertEquals ( <NUM_LIT:0> , TestDataValidator . getValidate ( "<STR_LIT>" , installData ) ) ; housekeeper . waitShutdown ( <NUM_LIT:2> * <NUM_LIT> * <NUM_LIT:1000> ) ; assertTrue ( housekeeper . hasShutdown ( ) ) ; assertEquals ( <NUM_LIT:0> , housekeeper . getExitCode ( ) ) ; assertFalse ( housekeeper . getReboot ( ) ) ; } private void checkCurrentPanel ( Class < ? extends IzPanel > type ) { Panel panel = panels . getPanel ( ) ; assertEquals ( type . getName ( ) , panel . getClassName ( ) ) ; } private void checkDialog ( String text ) { DialogFixture dialog = frameFixture . dialog ( Timeout . timeout ( <NUM_LIT> ) ) ; assertEquals ( text , dialog . label ( "<STR_LIT>" ) . text ( ) ) ; dialog . button ( JButtonMatcher . withText ( "<STR_LIT:OK>" ) ) . click ( ) ; } } </s>
<s> package com . izforge . izpack . integration . packvalidator ; import static org . junit . Assert . assertEquals ; import static org . junit . Assert . assertFalse ; import static org . junit . Assert . assertTrue ; import java . io . File ; import org . fest . swing . fixture . FrameFixture ; import org . junit . After ; import org . junit . Before ; import org . junit . Rule ; import org . junit . Test ; import org . junit . rules . TemporaryFolder ; import org . junit . runner . RunWith ; import com . izforge . izpack . api . GuiId ; import com . izforge . izpack . api . data . Panel ; import com . izforge . izpack . compiler . container . TestInstallationContainer ; import com . izforge . izpack . installer . data . GUIInstallData ; import com . izforge . izpack . installer . gui . InstallerController ; import com . izforge . izpack . installer . gui . InstallerFrame ; import com . izforge . izpack . installer . gui . IzPanel ; import com . izforge . izpack . installer . panel . Panels ; import com . izforge . izpack . integration . HelperTestMethod ; import com . izforge . izpack . panels . hello . HelloPanel ; import com . izforge . izpack . panels . install . InstallPanel ; import com . izforge . izpack . panels . packs . PacksPanel ; import com . izforge . izpack . panels . simplefinish . SimpleFinishPanel ; import com . izforge . izpack . panels . treepacks . PackValidator ; import com . izforge . izpack . test . Container ; import com . izforge . izpack . test . InstallFile ; import com . izforge . izpack . test . junit . PicoRunner ; import com . izforge . izpack . test . util . TestHousekeeper ; @ RunWith ( PicoRunner . class ) @ Container ( TestInstallationContainer . class ) public class PackValidatorTest { @ Rule public TemporaryFolder temporaryFolder = new TemporaryFolder ( ) ; private final GUIInstallData installData ; private final InstallerFrame frame ; private final InstallerController controller ; private final TestHousekeeper housekeeper ; private final Panels panels ; private FrameFixture frameFixture ; public PackValidatorTest ( GUIInstallData installData , InstallerFrame frame , InstallerController controller , TestHousekeeper housekeeper , Panels panels ) { this . installData = installData ; this . frame = frame ; this . controller = controller ; this . housekeeper = housekeeper ; this . panels = panels ; } @ Before public void setUp ( ) { File installPath = new File ( temporaryFolder . getRoot ( ) , "<STR_LIT>" ) ; assertTrue ( installPath . mkdirs ( ) ) ; installData . setInstallPath ( installPath . getAbsolutePath ( ) ) ; } @ After public void tearDown ( ) { if ( frameFixture != null ) { frameFixture . cleanUp ( ) ; } } @ Test @ InstallFile ( "<STR_LIT>" ) public void testPackValidator ( ) throws Exception { assertEquals ( <NUM_LIT:4> , panels . getPanels ( ) . size ( ) ) ; frameFixture = HelperTestMethod . prepareFrameFixture ( frame , controller ) ; Thread . sleep ( <NUM_LIT> ) ; checkCurrentPanel ( HelloPanel . class ) ; frameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; Thread . sleep ( <NUM_LIT:1000> ) ; checkCurrentPanel ( PacksPanel . class ) ; TestPackValidator . setValid ( "<STR_LIT>" , false , installData ) ; frameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; Thread . sleep ( <NUM_LIT:1000> ) ; checkCurrentPanel ( PacksPanel . class ) ; TestPackValidator . setValid ( "<STR_LIT>" , true , installData ) ; frameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; Thread . sleep ( <NUM_LIT:1000> ) ; checkCurrentPanel ( InstallPanel . class ) ; frameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; Thread . sleep ( <NUM_LIT:1000> ) ; checkCurrentPanel ( SimpleFinishPanel . class ) ; frameFixture . button ( GuiId . BUTTON_QUIT . id ) . click ( ) ; housekeeper . waitShutdown ( <NUM_LIT:2> * <NUM_LIT> * <NUM_LIT:1000> ) ; assertTrue ( housekeeper . hasShutdown ( ) ) ; assertEquals ( <NUM_LIT:0> , housekeeper . getExitCode ( ) ) ; assertFalse ( housekeeper . getReboot ( ) ) ; } private void checkCurrentPanel ( Class < ? extends IzPanel > type ) { Panel panel = panels . getPanel ( ) ; assertEquals ( type . getName ( ) , panel . getClassName ( ) ) ; } } </s>
<s> package com . izforge . izpack . integration . packvalidator ; import com . izforge . izpack . api . data . InstallData ; import com . izforge . izpack . api . handler . AbstractUIHandler ; import com . izforge . izpack . installer . data . GUIInstallData ; import com . izforge . izpack . panels . treepacks . PackValidator ; public class TestPackValidator implements PackValidator { public static void setValid ( String pack , boolean valid , InstallData installData ) { installData . setVariable ( pack + "<STR_LIT>" , Boolean . toString ( valid ) ) ; } @ Override public boolean validate ( AbstractUIHandler handler , GUIInstallData installData , String packName , boolean isSelected ) { String name = packName + "<STR_LIT>" ; String value = installData . getVariable ( name ) ; return Boolean . valueOf ( value ) ; } } </s>
<s> package com . izforge . izpack . integration ; import static org . hamcrest . MatcherAssert . assertThat ; import static org . junit . Assert . assertEquals ; import static org . junit . Assert . assertTrue ; import java . io . File ; import java . io . IOException ; import java . util . jar . JarFile ; import org . junit . After ; import org . junit . Before ; import org . junit . Test ; import org . junit . runner . RunWith ; import com . izforge . izpack . api . data . AutomatedInstallData ; import com . izforge . izpack . compiler . container . TestInstallationContainer ; import com . izforge . izpack . installer . data . UninstallData ; import com . izforge . izpack . installer . data . UninstallDataWriter ; import com . izforge . izpack . matcher . ZipMatcher ; import com . izforge . izpack . test . Container ; import com . izforge . izpack . test . InstallFile ; import com . izforge . izpack . test . junit . PicoRunner ; import com . izforge . izpack . test . listener . TestUninstallerListener ; import com . izforge . izpack . uninstaller . Destroyer ; @ RunWith ( PicoRunner . class ) @ Container ( TestInstallationContainer . class ) public class UninstallerListenerTest extends AbstractDestroyerTest { private final UninstallDataWriter uninstallDataWriter ; private final UninstallData uninstallData ; public UninstallerListenerTest ( UninstallDataWriter uninstallDataWriter , AutomatedInstallData installData , UninstallData uninstallData ) { super ( installData ) ; this . uninstallDataWriter = uninstallDataWriter ; this . uninstallData = uninstallData ; } @ Before public void setUp ( ) throws Exception { super . setUp ( ) ; removeState ( ) ; } @ After public void tearDown ( ) { removeState ( ) ; } @ Test @ InstallFile ( "<STR_LIT>" ) public void testUninstallerListenerInvocation ( ) throws Exception { String installPath = getInstallPath ( ) ; File installDir = new File ( installPath ) ; if ( ! installDir . exists ( ) ) { assertTrue ( installDir . mkdirs ( ) ) ; } int files = <NUM_LIT:3> ; for ( int i = <NUM_LIT:0> ; i < files ; ++ i ) { File file = new File ( installPath , "<STR_LIT:file>" + i ) ; assertTrue ( file . createNewFile ( ) ) ; uninstallData . addFile ( file . getAbsolutePath ( ) , true ) ; } assertTrue ( uninstallDataWriter . write ( ) ) ; File file = getUninstallerJar ( ) ; JarFile uninstallJar = new JarFile ( file ) ; assertThat ( uninstallJar , ZipMatcher . isZipContainingFiles ( "<STR_LIT>" , "<STR_LIT>" ) ) ; runDestroyer ( file ) ; String path = TestUninstallerListener . getStatePath ( installPath ) ; TestUninstallerListener . State state = TestUninstallerListener . readState ( path ) ; assertEquals ( <NUM_LIT:1> , state . initialiseCount ) ; assertEquals ( <NUM_LIT:1> , state . beforeListDeleteCount ) ; assertEquals ( files + <NUM_LIT:1> , state . beforeDeleteCount ) ; assertEquals ( state . beforeListDeleteCount , state . afterListDeleteCount ) ; assertEquals ( state . beforeDeleteCount , state . afterDeleteCount ) ; } private void removeState ( ) { String path = TestUninstallerListener . getStatePath ( getInstallPath ( ) ) ; File file = new File ( path ) ; if ( file . exists ( ) ) { assertTrue ( file . delete ( ) ) ; } } } </s>
<s> package com . izforge . izpack . integration ; import static org . junit . Assert . assertEquals ; import org . fest . swing . fixture . FrameFixture ; import org . junit . After ; import org . junit . Test ; import org . junit . runner . RunWith ; import com . izforge . izpack . api . GuiId ; import com . izforge . izpack . api . data . AutomatedInstallData ; import com . izforge . izpack . api . event . InstallerListener ; import com . izforge . izpack . compiler . container . TestInstallationContainer ; import com . izforge . izpack . installer . event . InstallerListeners ; import com . izforge . izpack . installer . gui . InstallerController ; import com . izforge . izpack . installer . gui . InstallerFrame ; import com . izforge . izpack . test . Container ; import com . izforge . izpack . test . InstallFile ; import com . izforge . izpack . test . junit . PicoRunner ; import com . izforge . izpack . test . listener . TestInstallerListener ; @ RunWith ( PicoRunner . class ) @ Container ( TestInstallationContainer . class ) public class InstallerListenerTest extends AbstractInstallationTest { private final InstallerListeners listeners ; private final InstallerFrame frame ; private final InstallerController controller ; private FrameFixture frameFixture ; public InstallerListenerTest ( InstallerListeners listeners , AutomatedInstallData installData , InstallerFrame frame , InstallerController controller ) { super ( installData ) ; this . listeners = listeners ; this . frame = frame ; this . controller = controller ; } @ After public void tearDown ( ) { if ( frameFixture != null ) { frameFixture . cleanUp ( ) ; } } @ Test @ InstallFile ( "<STR_LIT>" ) public void testInstallListenerInvocation ( ) throws Exception { frameFixture = HelperTestMethod . prepareFrameFixture ( frame , controller ) ; frameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; frameFixture . requireVisible ( ) ; HelperTestMethod . waitAndCheckInstallation ( getInstallData ( ) ) ; assertEquals ( <NUM_LIT:1> , listeners . size ( ) ) ; TestInstallerListener listener = ( TestInstallerListener ) listeners . getInstallerListeners ( ) . get ( <NUM_LIT:0> ) ; assertEquals ( <NUM_LIT:1> , listener . getInitialiseCount ( ) ) ; assertEquals ( <NUM_LIT:1> , listener . getBeforePacksCount ( ) ) ; assertEquals ( <NUM_LIT:3> , listener . getBeforePackCount ( ) ) ; assertEquals ( <NUM_LIT:5> , listener . getBeforeDirCount ( ) ) ; assertEquals ( <NUM_LIT:4> , listener . getBeforeFileCount ( ) ) ; assertEquals ( listener . getBeforePacksCount ( ) , listener . getAfterPacksCount ( ) ) ; assertEquals ( listener . getBeforePackCount ( ) , listener . getAfterPackCount ( ) ) ; assertEquals ( listener . getBeforeDirCount ( ) , listener . getAfterDirCount ( ) ) ; assertEquals ( listener . getBeforeFileCount ( ) , listener . getAfterFileCount ( ) ) ; } } </s>
<s> package com . izforge . izpack . integration . automation ; import static com . izforge . izpack . test . util . TestHelper . assertFileExists ; import static org . junit . Assert . assertFalse ; import static org . junit . Assert . assertNotNull ; import static org . junit . Assert . assertTrue ; import java . io . File ; import java . net . URL ; import org . junit . Test ; import org . junit . runner . RunWith ; import com . izforge . izpack . api . data . AutomatedInstallData ; import com . izforge . izpack . api . data . InstallData ; import com . izforge . izpack . compiler . container . TestConsoleInstallationContainer ; import com . izforge . izpack . installer . automation . AutomatedInstaller ; import com . izforge . izpack . integration . AbstractInstallationTest ; import com . izforge . izpack . integration . UninstallHelper ; import com . izforge . izpack . test . Container ; import com . izforge . izpack . test . InstallFile ; import com . izforge . izpack . test . junit . PicoRunner ; import com . izforge . izpack . util . FileUtil ; @ RunWith ( PicoRunner . class ) @ Container ( TestConsoleInstallationContainer . class ) public class AutomatedInstallerTest extends AbstractInstallationTest { private final AutomatedInstaller installer ; public AutomatedInstallerTest ( AutomatedInstaller installer , AutomatedInstallData installData ) { super ( installData ) ; this . installer = installer ; } @ Test @ InstallFile ( "<STR_LIT>" ) public void testAutomatedInstaller ( ) throws Exception { InstallData installData = getInstallData ( ) ; URL url = getClass ( ) . getResource ( "<STR_LIT>" ) ; assertNotNull ( url ) ; String config = FileUtil . convertUrlToFilePath ( url ) ; installer . init ( config , null ) ; installer . doInstall ( ) ; assertTrue ( installData . isInstallSuccess ( ) ) ; String installPath = getInstallPath ( ) ; File dir = new File ( installPath ) ; assertFileExists ( dir , "<STR_LIT>" ) ; assertFileExists ( dir , "<STR_LIT>" ) ; assertFileExists ( dir , "<STR_LIT>" ) ; UninstallHelper . uninstall ( installData ) ; assertFalse ( new File ( installPath ) . exists ( ) ) ; } } </s>
<s> package com . izforge . izpack . integration . windows ; import static org . junit . Assert . assertEquals ; import static org . junit . Assert . assertNotNull ; import static org . junit . Assert . assertTrue ; import java . io . File ; import javax . swing . SwingUtilities ; import com . coi . tools . os . win . RegDataContainer ; import com . izforge . izpack . api . exception . IzPackException ; import com . izforge . izpack . api . exception . NativeLibException ; import com . izforge . izpack . core . os . RegistryDefaultHandler ; import com . izforge . izpack . core . os . RegistryHandler ; import com . izforge . izpack . util . Librarian ; import com . izforge . izpack . util . os . ShellLink ; public class WindowsHelper { public static File checkShortcut ( final int linkType , final int userType , final String group , final String name , final File target , final String description , final Librarian librarian ) throws Exception { final File [ ] shortcut = new File [ <NUM_LIT:1> ] ; SwingUtilities . invokeAndWait ( new Runnable ( ) { @ Override public void run ( ) { ShellLink link ; try { link = new ShellLink ( linkType , userType , group , name , librarian ) ; } catch ( Exception exception ) { throw new IzPackException ( exception ) ; } assertEquals ( linkType , link . getLinkType ( ) ) ; assertEquals ( userType , link . getUserType ( ) ) ; assertEquals ( target , new File ( link . getTargetPath ( ) ) ) ; assertEquals ( description , link . getDescription ( ) ) ; shortcut [ <NUM_LIT:0> ] = new File ( link . getFileName ( ) ) ; assertTrue ( shortcut [ <NUM_LIT:0> ] . exists ( ) ) ; } } ) ; return shortcut [ <NUM_LIT:0> ] ; } public static boolean registryKeyExists ( RegistryDefaultHandler handler , String key ) throws NativeLibException { RegistryHandler registry = handler . getInstance ( ) ; assertNotNull ( registry ) ; registry . setRoot ( RegistryHandler . HKEY_LOCAL_MACHINE ) ; return registry . keyExist ( key ) ; } public static void registryValueStringEquals ( RegistryDefaultHandler handler , String key , String name , String expected ) throws NativeLibException { RegistryHandler registry = handler . getInstance ( ) ; assertNotNull ( registry ) ; registry . setRoot ( RegistryHandler . HKEY_LOCAL_MACHINE ) ; assertTrue ( registry . keyExist ( key ) ) ; assertTrue ( registry . valueExist ( key , name ) ) ; RegDataContainer value = registry . getValue ( key , name ) ; assertEquals ( "<STR_LIT>" + name + "<STR_LIT>" , RegDataContainer . REG_SZ , value . getType ( ) ) ; assertEquals ( expected , registry . getValue ( key , name ) . getStringData ( ) ) ; } public static void registryDeleteUninstallKey ( RegistryDefaultHandler handler , String key ) throws NativeLibException { RegistryHandler registry = handler . getInstance ( ) ; assertNotNull ( registry ) ; if ( ! key . matches ( "<STR_LIT>" ) ) { throw new IllegalArgumentException ( "<STR_LIT>" + key ) ; } registry . setRoot ( RegistryHandler . HKEY_LOCAL_MACHINE ) ; if ( registry . keyExist ( key ) ) { registry . deleteKey ( key ) ; } } } </s>
<s> package com . izforge . izpack . integration . windows ; import static com . izforge . izpack . integration . windows . WindowsHelper . registryDeleteUninstallKey ; import static com . izforge . izpack . integration . windows . WindowsHelper . registryKeyExists ; import static com . izforge . izpack . integration . windows . WindowsHelper . registryValueStringEquals ; import static com . izforge . izpack . util . Platform . Name . WINDOWS ; import static org . junit . Assert . assertEquals ; import static org . junit . Assert . assertFalse ; import static org . junit . Assert . assertNotNull ; import static org . junit . Assert . assertNull ; import static org . junit . Assert . assertTrue ; import java . io . File ; import org . junit . After ; import org . junit . Test ; import org . junit . runner . RunWith ; import com . izforge . izpack . api . data . AutomatedInstallData ; import com . izforge . izpack . api . data . InstallData ; import com . izforge . izpack . api . exception . NativeLibException ; import com . izforge . izpack . compiler . container . TestConsoleInstallationContainer ; import com . izforge . izpack . compiler . container . TestConsoleInstallerContainer ; import com . izforge . izpack . core . os . RegistryDefaultHandler ; import com . izforge . izpack . core . os . RegistryHandler ; import com . izforge . izpack . event . RegistryInstallerListener ; import com . izforge . izpack . event . RegistryUninstallerListener ; import com . izforge . izpack . installer . bootstrap . Installer ; import com . izforge . izpack . installer . console . TestConsoleInstaller ; import com . izforge . izpack . installer . container . impl . ConsoleInstallerContainer ; import com . izforge . izpack . integration . UninstallHelper ; import com . izforge . izpack . integration . console . AbstractConsoleInstallationTest ; import com . izforge . izpack . test . Container ; import com . izforge . izpack . test . InstallFile ; import com . izforge . izpack . test . RunOn ; import com . izforge . izpack . test . junit . PicoRunner ; import com . izforge . izpack . test . util . TestConsole ; import com . izforge . izpack . util . FileUtil ; import com . izforge . izpack . util . Platforms ; import com . izforge . izpack . util . PrivilegedRunner ; @ RunWith ( PicoRunner . class ) @ RunOn ( WINDOWS ) @ Container ( TestConsoleInstallationContainer . class ) public class WindowsConsoleInstallationTest extends AbstractConsoleInstallationTest { private final TestConsoleInstallerContainer container ; private final TestConsoleInstaller installer ; private final RegistryDefaultHandler handler ; private static final String APP_NAME = "<STR_LIT>" ; private static final String DEFAULT_UNINSTALL_KEY = RegistryHandler . UNINSTALL_ROOT + APP_NAME ; private static final String UNINSTALL_CMD_VALUE = "<STR_LIT>" ; private static final String UNINSTALL_KEY2 = RegistryHandler . UNINSTALL_ROOT + APP_NAME + "<STR_LIT>" ; private static final String [ ] UNINSTALL_KEYS = { DEFAULT_UNINSTALL_KEY , UNINSTALL_KEY2 } ; public WindowsConsoleInstallationTest ( TestConsoleInstallerContainer container , TestConsoleInstaller installer , AutomatedInstallData installData , RegistryDefaultHandler handler ) throws Exception { super ( installData ) ; this . container = container ; this . installer = installer ; this . handler = handler ; } @ Override public void setUp ( ) throws Exception { assertFalse ( "<STR_LIT>" , new PrivilegedRunner ( Platforms . WINDOWS ) . isElevationNeeded ( ) ) ; super . setUp ( ) ; String appName = getInstallData ( ) . getInfo ( ) . getAppName ( ) ; assertNotNull ( appName ) ; File file = FileUtil . getLockFile ( appName ) ; if ( file . exists ( ) ) { assertTrue ( file . delete ( ) ) ; } destroyRegistryEntries ( ) ; } @ After public void tearDown ( ) throws Exception { destroyRegistryEntries ( ) ; } @ Test @ InstallFile ( "<STR_LIT>" ) public void testInstallation ( ) throws Exception { checkInstall ( container , APP_NAME ) ; assertTrue ( registryKeyExists ( handler , DEFAULT_UNINSTALL_KEY ) ) ; File uninstaller = getUninstallerJar ( ) ; assertTrue ( uninstaller . exists ( ) ) ; UninstallHelper . consoleUninstall ( uninstaller ) ; assertFalse ( registryKeyExists ( handler , DEFAULT_UNINSTALL_KEY ) ) ; } @ Test @ InstallFile ( "<STR_LIT>" ) public void testMultipleInstallation ( ) throws Exception { checkInstall ( container , APP_NAME ) ; removeLock ( ) ; ConsoleInstallerContainer container2 = new TestConsoleInstallerContainer ( ) ; TestConsoleInstaller installer2 = container2 . getComponent ( TestConsoleInstaller . class ) ; InstallData installData2 = container2 . getComponent ( InstallData . class ) ; TestConsole console2 = installer2 . getConsole ( ) ; console2 . addScript ( "<STR_LIT>" , "<STR_LIT:y>" , "<STR_LIT:1>" ) ; console2 . addScript ( "<STR_LIT>" , "<STR_LIT:1>" ) ; console2 . addScript ( "<STR_LIT>" , "<STR_LIT:n>" , "<STR_LIT:1>" ) ; assertFalse ( registryKeyExists ( handler , UNINSTALL_KEY2 ) ) ; checkInstall ( installer2 , installData2 ) ; assertEquals ( APP_NAME + "<STR_LIT>" , installData2 . getVariable ( "<STR_LIT>" ) ) ; assertTrue ( registryKeyExists ( handler , UNINSTALL_KEY2 ) ) ; } @ Test @ InstallFile ( "<STR_LIT>" ) public void testRejectMultipleInstallation ( ) throws Exception { checkInstall ( container , APP_NAME ) ; removeLock ( ) ; ConsoleInstallerContainer container2 = new TestConsoleInstallerContainer ( ) ; TestConsoleInstaller installer2 = container2 . getComponent ( TestConsoleInstaller . class ) ; RegistryDefaultHandler handler2 = container2 . getComponent ( RegistryDefaultHandler . class ) ; InstallData installData2 = container2 . getComponent ( InstallData . class ) ; TestConsole console2 = installer2 . getConsole ( ) ; console2 . addScript ( "<STR_LIT>" , "<STR_LIT:n>" ) ; assertFalse ( registryKeyExists ( handler2 , UNINSTALL_KEY2 ) ) ; installer2 . run ( Installer . CONSOLE_INSTALL , null ) ; assertFalse ( installData2 . isInstallSuccess ( ) ) ; TestConsole console = installer2 . getConsole ( ) ; assertTrue ( "<STR_LIT>" + console . getScriptName ( ) , console . scriptCompleted ( ) ) ; assertFalse ( registryKeyExists ( handler2 , UNINSTALL_KEY2 ) ) ; } @ Test @ InstallFile ( "<STR_LIT>" ) public void testNonDefaultUninstaller ( ) throws Exception { assertFalse ( registryKeyExists ( handler , DEFAULT_UNINSTALL_KEY ) ) ; TestConsole console = installer . getConsole ( ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:1>" ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:1>" ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:n>" , "<STR_LIT:1>" ) ; InstallData installData = getInstallData ( ) ; checkInstall ( installer , installData , false ) ; String installPath = installData . getInstallPath ( ) ; assertTrue ( new File ( installPath , "<STR_LIT>" ) . exists ( ) ) ; assertTrue ( registryKeyExists ( handler , DEFAULT_UNINSTALL_KEY ) ) ; String command = "<STR_LIT:\">" + installData . getVariable ( "<STR_LIT>" ) + "<STR_LIT>" + installPath + "<STR_LIT>" ; registryValueStringEquals ( handler , DEFAULT_UNINSTALL_KEY , UNINSTALL_CMD_VALUE , command ) ; } private void checkInstall ( TestConsoleInstallerContainer container , String uninstallName ) throws NativeLibException { InstallData installData = container . getComponent ( InstallData . class ) ; TestConsoleInstaller installer = container . getComponent ( TestConsoleInstaller . class ) ; RegistryDefaultHandler handler = container . getComponent ( RegistryDefaultHandler . class ) ; assertNull ( installData . getVariable ( "<STR_LIT>" ) ) ; assertFalse ( registryKeyExists ( handler , DEFAULT_UNINSTALL_KEY ) ) ; TestConsole console = installer . getConsole ( ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:1>" ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:1>" ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:n>" , "<STR_LIT:1>" ) ; checkInstall ( installer , installData ) ; assertEquals ( uninstallName , installData . getVariable ( "<STR_LIT>" ) ) ; assertTrue ( registryKeyExists ( handler , DEFAULT_UNINSTALL_KEY ) ) ; } private void removeLock ( ) { String appName = getInstallData ( ) . getInfo ( ) . getAppName ( ) ; File file = FileUtil . getLockFile ( appName ) ; if ( file . exists ( ) ) { assertTrue ( file . delete ( ) ) ; } } private void destroyRegistryEntries ( ) throws NativeLibException { for ( String key : UNINSTALL_KEYS ) { registryDeleteUninstallKey ( handler , key ) ; } } } </s>
<s> package com . izforge . izpack . integration . windows ; import static com . izforge . izpack . integration . windows . WindowsHelper . checkShortcut ; import static com . izforge . izpack . integration . windows . WindowsHelper . registryDeleteUninstallKey ; import static com . izforge . izpack . integration . windows . WindowsHelper . registryKeyExists ; import static org . junit . Assert . assertEquals ; import static org . junit . Assert . assertFalse ; import static org . junit . Assert . assertNull ; import static org . junit . Assert . assertTrue ; import java . io . File ; import org . fest . swing . fixture . FrameFixture ; import org . junit . After ; import org . junit . Before ; import org . junit . Test ; import org . junit . runner . RunWith ; import com . izforge . izpack . api . GuiId ; import com . izforge . izpack . api . data . AutomatedInstallData ; import com . izforge . izpack . api . exception . NativeLibException ; import com . izforge . izpack . compiler . container . TestInstallationContainer ; import com . izforge . izpack . core . os . RegistryDefaultHandler ; import com . izforge . izpack . core . os . RegistryHandler ; import com . izforge . izpack . event . RegistryInstallerListener ; import com . izforge . izpack . event . RegistryUninstallerListener ; import com . izforge . izpack . installer . gui . InstallerController ; import com . izforge . izpack . installer . gui . InstallerFrame ; import com . izforge . izpack . integration . AbstractDestroyerTest ; import com . izforge . izpack . integration . HelperTestMethod ; import com . izforge . izpack . integration . UninstallHelper ; import com . izforge . izpack . test . Container ; import com . izforge . izpack . test . InstallFile ; import com . izforge . izpack . test . RunOn ; import com . izforge . izpack . test . junit . PicoRunner ; import com . izforge . izpack . test . util . TestHousekeeper ; import com . izforge . izpack . util . Librarian ; import com . izforge . izpack . util . Platform ; import com . izforge . izpack . util . Platforms ; import com . izforge . izpack . util . PrivilegedRunner ; import com . izforge . izpack . util . os . ShellLink ; @ RunWith ( PicoRunner . class ) @ RunOn ( Platform . Name . WINDOWS ) @ Container ( TestInstallationContainer . class ) public class WindowsInstallationTest extends AbstractDestroyerTest { private final InstallerFrame frame ; private final InstallerController controller ; private final Librarian librarian ; private final RegistryDefaultHandler handler ; private final TestHousekeeper housekeeper ; private FrameFixture installerFrameFixture ; private static final String UNINSTALL_KEY = RegistryHandler . UNINSTALL_ROOT + "<STR_LIT>" ; public WindowsInstallationTest ( InstallerFrame frame , InstallerController controller , AutomatedInstallData installData , Librarian librarian , RegistryDefaultHandler handler , TestHousekeeper housekeeper ) { super ( installData ) ; this . frame = frame ; this . controller = controller ; this . librarian = librarian ; this . handler = handler ; this . housekeeper = housekeeper ; } @ Before public void setUp ( ) throws Exception { super . setUp ( ) ; destroyRegistryEntries ( ) ; } @ After public void tearDown ( ) throws Exception { destroyRegistryEntries ( ) ; if ( installerFrameFixture != null ) { installerFrameFixture . cleanUp ( ) ; installerFrameFixture = null ; } } @ Test @ InstallFile ( "<STR_LIT>" ) public void testInstallation ( ) throws Exception { assertFalse ( "<STR_LIT>" , new PrivilegedRunner ( Platforms . WINDOWS ) . isElevationNeeded ( ) ) ; assertNull ( getInstallData ( ) . getVariable ( "<STR_LIT>" ) ) ; installerFrameFixture = HelperTestMethod . prepareFrameFixture ( frame , controller ) ; Thread . sleep ( <NUM_LIT> ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; assertEquals ( "<STR_LIT>" , getInstallData ( ) . getVariable ( "<STR_LIT>" ) ) ; Thread . sleep ( <NUM_LIT> ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; Thread . sleep ( <NUM_LIT> ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; Thread . sleep ( <NUM_LIT> ) ; installerFrameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; Thread . sleep ( <NUM_LIT> ) ; installerFrameFixture . button ( GuiId . BUTTON_QUIT . id ) . click ( ) ; housekeeper . waitShutdown ( <NUM_LIT:2> * <NUM_LIT> * <NUM_LIT:1000> ) ; assertTrue ( housekeeper . hasShutdown ( ) ) ; assertEquals ( <NUM_LIT:0> , housekeeper . getExitCode ( ) ) ; assertFalse ( housekeeper . getReboot ( ) ) ; File uninstaller = getUninstallerJar ( ) ; assertTrue ( registryKeyExists ( handler , UNINSTALL_KEY ) ) ; File shortcut = checkShortcut ( ShellLink . PROGRAM_MENU , ShellLink . ALL_USERS , "<STR_LIT>" , "<STR_LIT>" , uninstaller , "<STR_LIT>" , librarian ) ; UninstallHelper . guiUninstall ( uninstaller ) ; assertFalse ( registryKeyExists ( handler , UNINSTALL_KEY ) ) ; assertFalse ( shortcut . exists ( ) ) ; } private void destroyRegistryEntries ( ) throws NativeLibException { registryDeleteUninstallKey ( handler , UNINSTALL_KEY ) ; } } </s>
<s> package com . izforge . izpack . integration ; import static org . hamcrest . MatcherAssert . assertThat ; import java . util . jar . JarFile ; import java . util . zip . ZipFile ; import org . junit . Before ; import org . junit . Rule ; import org . junit . Test ; import org . junit . rules . TestRule ; import org . junit . rules . Timeout ; import org . junit . runner . RunWith ; import com . izforge . izpack . compiler . container . TestCompilationContainer ; import com . izforge . izpack . matcher . ZipMatcher ; import com . izforge . izpack . test . Container ; import com . izforge . izpack . test . InstallFile ; import com . izforge . izpack . test . junit . PicoRunner ; @ RunWith ( PicoRunner . class ) @ Container ( TestCompilationContainer . class ) public class IzpackGenerationTest { @ Rule public TestRule globalTimeout = new Timeout ( HelperTestMethod . TIMEOUT ) ; private JarFile jar ; private TestCompilationContainer container ; public IzpackGenerationTest ( TestCompilationContainer container ) { this . container = container ; } @ Before public void before ( ) { container . launchCompilation ( ) ; jar = container . getComponent ( JarFile . class ) ; } @ Test @ InstallFile ( "<STR_LIT>" ) public void testGeneratedIzpackInstaller ( ) throws Exception { assertThat ( ( ZipFile ) jar , ZipMatcher . isZipContainingFiles ( "<STR_LIT>" ) ) ; } } </s>
<s> package com . izforge . izpack . integration ; import static com . izforge . izpack . test . util . TestHelper . assertFileExists ; import java . io . File ; import java . io . IOException ; import java . lang . reflect . Method ; import java . net . MalformedURLException ; import java . net . URL ; import java . net . URLClassLoader ; import com . izforge . izpack . api . data . Info ; import com . izforge . izpack . api . data . InstallData ; import com . izforge . izpack . uninstaller . Destroyer ; import com . izforge . izpack . uninstaller . console . ConsoleUninstallerContainer ; import com . izforge . izpack . uninstaller . gui . GUIUninstallerContainer ; import com . izforge . izpack . util . IoHelper ; import com . izforge . izpack . util . file . FileUtils ; public class UninstallHelper { public static void uninstall ( InstallData installData ) throws Exception { File uninstallerJar = getUninstallerJar ( installData ) ; assertFileExists ( uninstallerJar ) ; consoleUninstall ( uninstallerJar ) ; } public static File getUninstallerJar ( InstallData installData ) { Info info = installData . getInfo ( ) ; String dir = IoHelper . translatePath ( info . getUninstallerPath ( ) , installData . getVariables ( ) ) ; String path = dir + File . separator + info . getUninstallerName ( ) ; return new File ( path ) ; } public static void consoleUninstall ( File uninstallJar ) throws Exception { File copy = copy ( uninstallJar ) ; ClassLoader loader = getClassLoader ( copy ) ; Class containerClass = loader . loadClass ( ConsoleUninstallerContainer . class . getName ( ) ) ; Object container = containerClass . newInstance ( ) ; runDestroyer ( container , loader , copy ) ; } public static void guiUninstall ( File uninstallJar ) throws Exception { File copy = copy ( uninstallJar ) ; ClassLoader loader = getClassLoader ( copy ) ; Class containerClass = loader . loadClass ( GUIUninstallerContainer . class . getName ( ) ) ; Object container = containerClass . newInstance ( ) ; runDestroyer ( container , loader , copy ) ; } private static ClassLoader getClassLoader ( File uninstallJar ) throws MalformedURLException { return new URLClassLoader ( new URL [ ] { uninstallJar . toURI ( ) . toURL ( ) } , null ) ; } private static void runDestroyer ( Object container , ClassLoader loader , File jar ) throws Exception { Method getComponent = container . getClass ( ) . getMethod ( "<STR_LIT>" , Class . class ) ; Class destroyerClass = loader . loadClass ( Destroyer . class . getName ( ) ) ; Object destroyer = getComponent . invoke ( container , destroyerClass ) ; Method forceDelete = destroyerClass . getMethod ( "<STR_LIT>" , boolean . class ) ; forceDelete . invoke ( destroyer , true ) ; Method run = destroyerClass . getMethod ( "<STR_LIT>" ) ; run . invoke ( destroyer ) ; FileUtils . delete ( jar ) ; } private static File copy ( File uninstallJar ) throws IOException { File copy = File . createTempFile ( "<STR_LIT>" , "<STR_LIT>" ) ; copy . deleteOnExit ( ) ; IoHelper . copyFile ( uninstallJar , copy ) ; return copy ; } } </s>
<s> package com . izforge . izpack . integration ; import static org . junit . Assert . assertEquals ; import static org . junit . Assert . assertFalse ; import static org . junit . Assert . assertTrue ; import java . io . File ; import java . io . IOException ; import java . util . List ; import org . apache . commons . lang . StringUtils ; import org . junit . Test ; import org . junit . runner . RunWith ; import com . izforge . izpack . api . data . AutomatedInstallData ; import com . izforge . izpack . api . handler . AbstractUIProgressHandler ; import com . izforge . izpack . compiler . container . TestInstallationContainer ; import com . izforge . izpack . installer . data . UninstallDataWriter ; import com . izforge . izpack . installer . unpacker . Unpacker ; import com . izforge . izpack . test . Container ; import com . izforge . izpack . test . InstallFile ; import com . izforge . izpack . test . RunOn ; import com . izforge . izpack . test . junit . PicoRunner ; import com . izforge . izpack . util . FileUtil ; import com . izforge . izpack . util . Platform . Name ; @ RunWith ( PicoRunner . class ) @ Container ( TestInstallationContainer . class ) public class ExecutableFileTest extends AbstractDestroyerTest { private final Unpacker unpacker ; private final UninstallDataWriter uninstallDataWriter ; public ExecutableFileTest ( Unpacker unpacker , UninstallDataWriter uninstallDataWriter , AutomatedInstallData installData ) { super ( installData ) ; this . unpacker = unpacker ; this . uninstallDataWriter = uninstallDataWriter ; } @ Test @ InstallFile ( "<STR_LIT>" ) @ RunOn ( { Name . WINDOWS , Name . UNIX } ) public void testExecutables ( ) throws Exception { getInstallData ( ) . refreshVariables ( ) ; checkNotExists ( "<STR_LIT>" ) ; checkNotExists ( "<STR_LIT>" ) ; checkNotExists ( "<STR_LIT>" ) ; unpacker . setProgressListener ( new NoOpProgressHandler ( ) ) ; unpacker . run ( ) ; assertTrue ( uninstallDataWriter . write ( ) ) ; File file = checkContains ( "<STR_LIT>" , "<STR_LIT>" ) ; assertTrue ( file . delete ( ) ) ; checkNotExists ( "<STR_LIT>" ) ; checkNotExists ( "<STR_LIT>" ) ; File jar = getUninstallerJar ( ) ; runDestroyer ( jar ) ; checkNotExists ( "<STR_LIT>" ) ; checkNotExists ( "<STR_LIT>" ) ; checkContains ( "<STR_LIT>" , "<STR_LIT>" ) ; } private File checkContains ( String name , String content ) throws IOException { checkExists ( name ) ; File file = new File ( temporaryFolder . getRoot ( ) , name ) ; List < String > fileContent = FileUtil . getFileContent ( file . getPath ( ) ) ; assertEquals ( <NUM_LIT:1> , fileContent . size ( ) ) ; assertEquals ( content , StringUtils . trim ( fileContent . get ( <NUM_LIT:0> ) ) ) ; return file ; } private void checkExists ( String name ) { File file = new File ( temporaryFolder . getRoot ( ) , name ) ; assertTrue ( file . exists ( ) ) ; } private void checkNotExists ( String name ) { File file = new File ( temporaryFolder . getRoot ( ) , name ) ; assertFalse ( file . exists ( ) ) ; } private static class NoOpProgressHandler implements AbstractUIProgressHandler { @ Override public void startAction ( String name , int no_of_steps ) { } @ Override public void stopAction ( ) { } @ Override public void nextStep ( String step_name , int step_no , int no_of_substeps ) { } @ Override public void setSubStepNo ( int no_of_substeps ) { } @ Override public void progress ( int substep_no , String message ) { } @ Override public void progress ( String message ) { } @ Override public void restartAction ( String name , String overallMessage , String tip , int steps ) { } @ Override public void emitNotification ( String message ) { } @ Override public boolean emitWarning ( String title , String message ) { return false ; } @ Override public void emitError ( String title , String message ) { } @ Override public void emitErrorAndBlockNext ( String title , String message ) { } @ Override public int askQuestion ( String title , String question , int choices ) { return <NUM_LIT:0> ; } @ Override public int askQuestion ( String title , String question , int choices , int default_choice ) { return <NUM_LIT:0> ; } } } </s>
<s> package com . izforge . izpack . integration . packaging ; import static org . hamcrest . MatcherAssert . assertThat ; import static org . junit . Assert . assertEquals ; import static org . junit . Assert . assertTrue ; import java . io . File ; import java . io . IOException ; import java . util . Enumeration ; import java . util . HashSet ; import java . util . Set ; import java . util . jar . JarFile ; import java . util . zip . ZipEntry ; import org . fest . swing . fixture . FrameFixture ; import org . junit . After ; import org . junit . Test ; import org . junit . runner . RunWith ; import com . izforge . izpack . api . GuiId ; import com . izforge . izpack . api . data . AutomatedInstallData ; import com . izforge . izpack . compiler . container . TestInstallationContainer ; import com . izforge . izpack . compiler . data . CompilerData ; import com . izforge . izpack . compiler . packager . impl . Packager ; import com . izforge . izpack . installer . gui . InstallerController ; import com . izforge . izpack . installer . gui . InstallerFrame ; import com . izforge . izpack . installer . unpacker . Unpacker ; import com . izforge . izpack . integration . AbstractInstallationTest ; import com . izforge . izpack . integration . HelperTestMethod ; import com . izforge . izpack . matcher . ZipMatcher ; import com . izforge . izpack . test . Container ; import com . izforge . izpack . test . InstallFile ; import com . izforge . izpack . test . junit . PicoRunner ; @ RunWith ( PicoRunner . class ) @ Container ( TestInstallationContainer . class ) public class PackagingTest extends AbstractInstallationTest { private final JarFile installer ; private final CompilerData compilerData ; private final InstallerFrame frame ; private final InstallerController controller ; private FrameFixture frameFixture ; public PackagingTest ( JarFile installer , CompilerData compilerData , AutomatedInstallData installData , InstallerFrame frame , InstallerController controller ) { super ( installData ) ; this . installer = installer ; this . compilerData = compilerData ; this . frame = frame ; this . controller = controller ; } @ After public void tearDown ( ) { if ( frameFixture != null ) { frameFixture . cleanUp ( ) ; } } @ Test @ InstallFile ( "<STR_LIT>" ) public void testPack200 ( ) throws Exception { File source = new File ( compilerData . getBasedir ( ) , "<STR_LIT>" ) ; assertTrue ( source . exists ( ) ) ; assertThat ( installer , ZipMatcher . isZipContainingFiles ( "<STR_LIT>" ) ) ; frameFixture = HelperTestMethod . prepareFrameFixture ( frame , controller ) ; frameFixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; frameFixture . requireVisible ( ) ; HelperTestMethod . waitAndCheckInstallation ( getInstallData ( ) ) ; File target = new File ( getInstallPath ( ) , "<STR_LIT>" ) ; assertTrue ( target . exists ( ) ) ; JarFile sourceJar = new JarFile ( source ) ; JarFile targetJar = new JarFile ( target ) ; Set < String > sourceEntries = getFiles ( sourceJar ) ; Set < String > targetEntries = getFiles ( targetJar ) ; assertEquals ( sourceEntries , targetEntries ) ; } private Set < String > getFiles ( JarFile file ) throws IOException { Set < String > result = new HashSet < String > ( ) ; Enumeration < ? extends ZipEntry > entries = file . entries ( ) ; while ( entries . hasMoreElements ( ) ) { ZipEntry entry = entries . nextElement ( ) ; if ( ! entry . isDirectory ( ) ) { result . add ( entry . getName ( ) ) ; } } return result ; } } </s>
<s> package com . izforge . izpack . integration . console ; import static org . junit . Assert . assertEquals ; import static org . junit . Assert . assertFalse ; import static org . junit . Assert . assertTrue ; import java . io . File ; import java . io . FileInputStream ; import java . io . FileOutputStream ; import java . util . Properties ; import org . junit . Test ; import org . junit . runner . RunWith ; import com . izforge . izpack . api . data . AutomatedInstallData ; import com . izforge . izpack . api . data . InstallData ; import com . izforge . izpack . compiler . container . TestConsoleInstallationContainer ; import com . izforge . izpack . installer . bootstrap . Installer ; import com . izforge . izpack . installer . console . ConsoleInstaller ; import com . izforge . izpack . installer . console . PanelConsole ; import com . izforge . izpack . installer . console . TestConsoleInstaller ; import com . izforge . izpack . test . Container ; import com . izforge . izpack . test . InstallFile ; import com . izforge . izpack . test . junit . PicoRunner ; import com . izforge . izpack . test . util . TestConsole ; @ RunWith ( PicoRunner . class ) @ Container ( TestConsoleInstallationContainer . class ) public class ConsoleInstallationTest extends AbstractConsoleInstallationTest { private final TestConsoleInstaller installer ; public ConsoleInstallationTest ( TestConsoleInstaller installer , AutomatedInstallData installData ) throws Exception { super ( installData ) ; this . installer = installer ; } @ Test @ InstallFile ( "<STR_LIT>" ) public void testInstallationWithDisabledUnInstaller ( ) throws Exception { TestConsole console = installer . getConsole ( ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:1>" ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:1>" ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:n>" , "<STR_LIT:1>" ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:n>" , "<STR_LIT:1>" ) ; checkInstall ( installer , getInstallData ( ) , false ) ; } @ Test @ InstallFile ( "<STR_LIT>" ) public void testInstallation ( ) throws Exception { TestConsole console = installer . getConsole ( ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:1>" ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:1>" ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:n>" , "<STR_LIT:1>" ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:n>" , "<STR_LIT:1>" ) ; checkInstall ( installer , getInstallData ( ) ) ; } @ Test @ InstallFile ( "<STR_LIT>" ) public void testRejectLicence ( ) { InstallData installData = getInstallData ( ) ; File installPath = new File ( temporaryFolder . getRoot ( ) , "<STR_LIT>" ) ; TestConsole console = installer . getConsole ( ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:1>" ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:1>" ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:n>" , "<STR_LIT:2>" ) ; installData . setInstallPath ( installPath . getAbsolutePath ( ) ) ; installer . run ( Installer . CONSOLE_INSTALL , null ) ; assertFalse ( installData . isInstallSuccess ( ) ) ; assertFalse ( installPath . exists ( ) ) ; assertTrue ( "<STR_LIT>" + console . getScriptName ( ) , console . scriptCompleted ( ) ) ; } @ Test @ InstallFile ( "<STR_LIT>" ) public void testRedisplayAndAcceptLicence ( ) { TestConsole console = installer . getConsole ( ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:1>" ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:1>" ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:n>" , "<STR_LIT:3>" , "<STR_LIT:n>" , "<STR_LIT:1>" ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:n>" , "<STR_LIT:1>" ) ; checkInstall ( installer , getInstallData ( ) ) ; } @ Test @ InstallFile ( "<STR_LIT>" ) public void testGenerateProperties ( ) throws Exception { InstallData installData = getInstallData ( ) ; File file = new File ( temporaryFolder . getRoot ( ) , "<STR_LIT>" ) ; File installPath = new File ( temporaryFolder . getRoot ( ) , "<STR_LIT>" ) ; installData . setInstallPath ( installPath . getAbsolutePath ( ) ) ; installer . run ( Installer . CONSOLE_GEN_TEMPLATE , file . getPath ( ) ) ; assertTrue ( installData . isInstallSuccess ( ) ) ; Properties properties = new Properties ( ) ; properties . load ( new FileInputStream ( file ) ) ; assertEquals ( <NUM_LIT:1> , properties . size ( ) ) ; assertTrue ( properties . containsKey ( InstallData . INSTALL_PATH ) ) ; assertEquals ( "<STR_LIT>" , properties . getProperty ( InstallData . INSTALL_PATH ) ) ; } @ Test @ InstallFile ( "<STR_LIT>" ) public void testInstallFromProperties ( ) throws Exception { InstallData installData = getInstallData ( ) ; File file = new File ( temporaryFolder . getRoot ( ) , "<STR_LIT>" ) ; File installPath = new File ( temporaryFolder . getRoot ( ) , "<STR_LIT>" ) ; Properties properties = new Properties ( ) ; properties . put ( InstallData . INSTALL_PATH , installPath . getPath ( ) ) ; properties . store ( new FileOutputStream ( file ) , "<STR_LIT>" ) ; TestConsole console = installer . getConsole ( ) ; installer . run ( Installer . CONSOLE_FROM_TEMPLATE , file . getPath ( ) ) ; assertEquals ( <NUM_LIT:0> , console . getReads ( ) ) ; assertTrue ( installData . isInstallSuccess ( ) ) ; assertTrue ( new File ( installPath , "<STR_LIT>" ) . exists ( ) ) ; assertTrue ( new File ( installPath , "<STR_LIT>" ) . exists ( ) ) ; assertTrue ( new File ( installPath , "<STR_LIT>" ) . exists ( ) ) ; } @ Test @ InstallFile ( "<STR_LIT>" ) public void testUnsupportedInstaller ( ) { InstallData installData = getInstallData ( ) ; File installPath = new File ( temporaryFolder . getRoot ( ) , "<STR_LIT>" ) ; installData . setInstallPath ( installPath . getAbsolutePath ( ) ) ; assertFalse ( installer . canInstall ( ) ) ; installer . run ( Installer . CONSOLE_INSTALL , null ) ; assertFalse ( installData . isInstallSuccess ( ) ) ; assertFalse ( installPath . exists ( ) ) ; } @ Override protected void checkInstall ( TestConsoleInstaller installer , InstallData installData , boolean expectUninstaller ) { super . checkInstall ( installer , installData , expectUninstaller ) ; String installPath = installData . getInstallPath ( ) ; assertTrue ( new File ( installPath , "<STR_LIT>" ) . exists ( ) ) ; assertTrue ( new File ( installPath , "<STR_LIT>" ) . exists ( ) ) ; } } </s>
<s> package com . izforge . izpack . integration . console ; import static org . junit . Assert . assertFalse ; import static org . junit . Assert . assertTrue ; import java . io . File ; import com . izforge . izpack . api . data . InstallData ; import com . izforge . izpack . installer . bootstrap . Installer ; import com . izforge . izpack . installer . console . ConsoleInstaller ; import com . izforge . izpack . installer . console . TestConsoleInstaller ; import com . izforge . izpack . integration . AbstractDestroyerTest ; import com . izforge . izpack . test . util . TestConsole ; public class AbstractConsoleInstallationTest extends AbstractDestroyerTest { public AbstractConsoleInstallationTest ( InstallData installData ) throws Exception { super ( installData ) ; } protected void checkInstall ( TestConsoleInstaller installer , InstallData installData ) { checkInstall ( installer , installData , true ) ; } protected void checkInstall ( TestConsoleInstaller installer , InstallData installData , boolean expectUninstaller ) { installer . run ( Installer . CONSOLE_INSTALL , null ) ; assertTrue ( installData . isInstallSuccess ( ) ) ; TestConsole console = installer . getConsole ( ) ; assertTrue ( "<STR_LIT>" + console . getScriptName ( ) , console . scriptCompleted ( ) ) ; String installPath = installData . getInstallPath ( ) ; if ( expectUninstaller ) { assertTrue ( new File ( installPath , "<STR_LIT>" ) . exists ( ) ) ; } else { assertFalse ( new File ( installPath , "<STR_LIT>" ) . exists ( ) ) ; } } } </s>
<s> package com . izforge . izpack . integration . console ; import java . io . File ; import com . izforge . izpack . api . data . InstallData ; import com . izforge . izpack . compiler . container . TestConsoleInstallerContainer ; import com . izforge . izpack . compiler . packager . impl . MultiVolumePackager ; import com . izforge . izpack . installer . bootstrap . Installer ; import com . izforge . izpack . installer . console . TestConsoleInstaller ; import com . izforge . izpack . installer . container . impl . InstallerContainer ; import com . izforge . izpack . installer . multiunpacker . MultiVolumeUnpacker ; import com . izforge . izpack . integration . multivolume . AbstractMultiVolumeInstallationTest ; import com . izforge . izpack . test . util . TestConsole ; public class MultiVolumeConsoleInstallationTest extends AbstractMultiVolumeInstallationTest { @ Override protected InstallerContainer createInstallerContainer ( ) { return new TestConsoleInstallerContainer ( ) ; } @ Override protected void install ( InstallerContainer container , InstallData installData , File installPath ) throws Exception { TestConsoleInstaller installer = container . getComponent ( TestConsoleInstaller . class ) ; TestConsole console = installer . getConsole ( ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:1>" ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:1>" ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:n>" , "<STR_LIT:1>" ) ; console . addScript ( "<STR_LIT>" , "<STR_LIT:n>" , "<STR_LIT:1>" ) ; console . addScript ( "<STR_LIT>" ) ; console . addScript ( "<STR_LIT>" ) ; installer . run ( Installer . CONSOLE_INSTALL , installPath . getPath ( ) ) ; } } </s>
<s> package com . izforge . izpack . integration ; import java . io . File ; import com . izforge . izpack . api . data . InstallData ; import com . izforge . izpack . uninstaller . Destroyer ; public class AbstractDestroyerTest extends AbstractInstallationTest { public AbstractDestroyerTest ( InstallData installData ) { super ( installData ) ; } protected void runDestroyer ( File uninstallJar ) throws Exception { UninstallHelper . consoleUninstall ( uninstallJar ) ; } protected File getUninstallerJar ( ) { return UninstallHelper . getUninstallerJar ( getInstallData ( ) ) ; } } </s>
<s> package com . izforge . izpack . integration . multivolume ; import static com . izforge . izpack . test . util . TestHelper . assertFileEquals ; import static com . izforge . izpack . test . util . TestHelper . assertFileExists ; import static com . izforge . izpack . test . util . TestHelper . assertFileNotExists ; import static org . junit . Assert . assertTrue ; import java . io . File ; import org . junit . Rule ; import org . junit . Test ; import org . junit . rules . TemporaryFolder ; import com . izforge . izpack . api . data . InstallData ; import com . izforge . izpack . compiler . container . TestCompilationContainer ; import com . izforge . izpack . installer . container . impl . InstallerContainer ; import com . izforge . izpack . integration . UninstallHelper ; import com . izforge . izpack . test . util . TestHelper ; public abstract class AbstractMultiVolumeInstallationTest { @ Rule public TemporaryFolder temporaryFolder = new TemporaryFolder ( ) ; @ Test public void testMultiVolume ( ) throws Exception { File targetDir = new File ( temporaryFolder . getRoot ( ) , "<STR_LIT:target>" ) ; assertTrue ( targetDir . mkdir ( ) ) ; TestCompilationContainer compiler = new TestCompilationContainer ( "<STR_LIT>" , targetDir ) ; File baseDir = compiler . getBaseDir ( ) ; File file1 = TestHelper . createFile ( baseDir , "<STR_LIT>" , <NUM_LIT> ) ; File file2 = TestHelper . createFile ( baseDir , "<STR_LIT>" , <NUM_LIT> ) ; File file3 = TestHelper . createFile ( baseDir , "<STR_LIT>" , <NUM_LIT> ) ; File file4 = TestHelper . createFile ( baseDir , "<STR_LIT>" , <NUM_LIT> ) ; File file5 = TestHelper . createFile ( baseDir , "<STR_LIT>" , <NUM_LIT> ) ; File file6 = TestHelper . createFile ( baseDir , "<STR_LIT>" , <NUM_LIT> ) ; compiler . launchCompilation ( ) ; assertFileExists ( targetDir , file5 . getName ( ) ) ; assertFileExists ( targetDir , file6 . getName ( ) ) ; assertFileNotExists ( targetDir , file1 . getName ( ) ) ; assertFileNotExists ( targetDir , file2 . getName ( ) ) ; assertFileNotExists ( targetDir , file3 . getName ( ) ) ; assertFileNotExists ( targetDir , file4 . getName ( ) ) ; InstallerContainer installer = createInstallerContainer ( ) ; InstallData installData = installer . getComponent ( InstallData . class ) ; File installPath = new File ( temporaryFolder . getRoot ( ) , "<STR_LIT>" ) ; installData . setInstallPath ( installPath . getAbsolutePath ( ) ) ; installData . setDefaultInstallPath ( installPath . getAbsolutePath ( ) ) ; installData . setMediaPath ( targetDir . getPath ( ) ) ; install ( installer , installData , installPath ) ; assertFileEquals ( file1 , installPath , file1 . getName ( ) ) ; assertFileEquals ( file2 , installPath , file2 . getName ( ) ) ; assertFileEquals ( file5 , installPath , file5 . getName ( ) ) ; assertFileEquals ( file6 , installPath , file6 . getName ( ) ) ; assertFileNotExists ( installPath , file3 . getName ( ) ) ; assertFileNotExists ( installPath , file4 . getName ( ) ) ; UninstallHelper . uninstall ( installData ) ; assertFileNotExists ( installPath , file1 . getName ( ) ) ; assertFileNotExists ( installPath , file2 . getName ( ) ) ; assertFileNotExists ( installPath , file5 . getName ( ) ) ; assertFileNotExists ( installPath , file6 . getName ( ) ) ; assertFileNotExists ( installPath ) ; } protected abstract InstallerContainer createInstallerContainer ( ) ; protected abstract void install ( InstallerContainer container , InstallData installData , File installPath ) throws Exception ; } </s>
<s> package com . izforge . izpack . integration . multivolume ; import java . io . File ; import org . fest . swing . fixture . FrameFixture ; import org . junit . After ; import com . izforge . izpack . api . GuiId ; import com . izforge . izpack . api . data . InstallData ; import com . izforge . izpack . compiler . container . TestGUIInstallerContainer ; import com . izforge . izpack . compiler . packager . impl . MultiVolumePackager ; import com . izforge . izpack . installer . container . impl . InstallerContainer ; import com . izforge . izpack . installer . gui . InstallerController ; import com . izforge . izpack . installer . gui . InstallerFrame ; import com . izforge . izpack . installer . language . LanguageDialog ; import com . izforge . izpack . installer . multiunpacker . MultiVolumeUnpacker ; import com . izforge . izpack . integration . HelperTestMethod ; public class MultiVolumeInstallationTest extends AbstractMultiVolumeInstallationTest { private FrameFixture fixture ; @ After public void tearDown ( ) { if ( fixture != null ) { fixture . cleanUp ( ) ; } } @ Override protected InstallerContainer createInstallerContainer ( ) { return new TestGUIInstallerContainer ( ) ; } protected void install ( InstallerContainer container , InstallData installData , File installPath ) throws Exception { InstallerController controller = container . getComponent ( InstallerController . class ) ; LanguageDialog languageDialog = container . getComponent ( LanguageDialog . class ) ; InstallerFrame installerFrame = container . getComponent ( InstallerFrame . class ) ; HelperTestMethod . clickDefaultLang ( languageDialog ) ; fixture = HelperTestMethod . prepareFrameFixture ( installerFrame , controller ) ; Thread . sleep ( <NUM_LIT> ) ; fixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; Thread . sleep ( <NUM_LIT> ) ; fixture . textBox ( GuiId . INFO_PANEL_TEXT_AREA . id ) . requireText ( "<STR_LIT>" ) ; fixture . button ( GuiId . BUTTON_PREV . id ) . requireVisible ( ) ; fixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; fixture . button ( GuiId . BUTTON_PREV . id ) . requireEnabled ( ) ; Thread . sleep ( <NUM_LIT> ) ; fixture . textBox ( GuiId . LICENCE_TEXT_AREA . id ) . requireText ( "<STR_LIT>" ) ; fixture . radioButton ( GuiId . LICENCE_NO_RADIO . id ) . requireSelected ( ) ; fixture . button ( GuiId . BUTTON_NEXT . id ) . requireDisabled ( ) ; fixture . radioButton ( GuiId . LICENCE_YES_RADIO . id ) . click ( ) ; Thread . sleep ( <NUM_LIT> ) ; fixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; fixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; Thread . sleep ( <NUM_LIT:1000> ) ; fixture . optionPane ( ) . requireWarningMessage ( ) ; fixture . optionPane ( ) . okButton ( ) . click ( ) ; HelperTestMethod . waitAndCheckInstallation ( installData , installPath ) ; fixture . button ( GuiId . BUTTON_NEXT . id ) . click ( ) ; Thread . sleep ( <NUM_LIT> ) ; fixture . button ( GuiId . BUTTON_QUIT . id ) . click ( ) ; } } </s>