You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by ke...@apache.org on 2010/07/14 21:32:44 UTC
svn commit: r964147 [3/3] - in /incubator/oodt/trunk/commons: ./
src/main/java/gov/nasa/jpl/oodt/commons/ src/main/java/org/
src/main/java/org/apache/ src/main/java/org/apache/oodt/
src/main/java/org/apache/oodt/commons/ src/main/java/org/apache/oodt/c...
Modified: incubator/oodt/trunk/commons/src/main/java/org/apache/oodt/commons/pagination/PaginationUtils.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/commons/src/main/java/org/apache/oodt/commons/pagination/PaginationUtils.java?rev=964147&r1=964122&r2=964147&view=diff
==============================================================================
--- incubator/oodt/trunk/commons/src/main/java/org/apache/oodt/commons/pagination/PaginationUtils.java (original)
+++ incubator/oodt/trunk/commons/src/main/java/org/apache/oodt/commons/pagination/PaginationUtils.java Wed Jul 14 19:32:42 2010
@@ -1,105 +1,105 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package gov.nasa.jpl.oodt.cas.commons.pagination;
-
-import java.util.List;
-
-/**
- * @author mattmann
- * @version $Revision$
- *
- * <p>
- * A set of utility methods to do pagination.
- * </p>
- *
- */
-public final class PaginationUtils {
-
- private PaginationUtils() throws InstantiationException {
- throw new InstantiationException("Don't construct utility classes!");
- }
-
- public static int hasRemainder(int divisor, int quotient) {
- if (divisor % quotient != 0) {
- return 1;
- } else {
- return 0;
- }
- }
-
- public static int computeCurrentPage(int startIdx, int productsPerPage) {
- return ((startIdx + 1) / productsPerPage)
- + hasRemainder(startIdx + 1, productsPerPage);
- }
-
- public static int computeCurrentWindow(int currPage, int pagesPerPage) {
- return (currPage / pagesPerPage) + hasRemainder(currPage, pagesPerPage);
- }
-
- public static int computeMinPage(int pagesPerPage, int currWindow) {
- return (pagesPerPage * (currWindow - 1)) + 1;
- }
-
- public static int computeMaxPage(int minPage, int pagesPerPage,
- int lastIdx, int productsPerPage) {
- return Math.min(minPage + (pagesPerPage - 1), computeCurrentPage(
- lastIdx, productsPerPage));
- }
-
- public static int computeEndIdx(int currPage, int productsPerPage,
- int totalProducts) {
- return Math.min((currPage * productsPerPage) - 1, totalProducts - 1);
- }
-
- public static int computePrevStartIdx(int minPage, int productsPerPage) {
- int prevPage = Math.max(minPage - 2, 1);
- return (prevPage * productsPerPage);
- }
-
- public static int computeNextStartIdx(int maxPage, int productsPerPage) {
- int nextPage = maxPage;
- return (nextPage * productsPerPage);
-
- }
-
- public static List iterateFrom(final int startIndex,
- final List originalList, int pageSize) {
- final int totalSize = originalList.size();
-
- int endIndex = startIndex + pageSize;
- if (endIndex > totalSize)
- endIndex = totalSize;
-
- return originalList.subList(startIndex, endIndex);
- }
-
- public static int getTotalPage(List originalList, int pageSize) {
- if (originalList == null || originalList.size() <= 0)
- return 0;
- final int totalSize = originalList.size();
- return ((totalSize - 1) / pageSize) + 1;
- }
-
- public static int getTotalPage(int numTotal, int pageSize) {
- if (numTotal <= 0)
- return 0;
- return ((numTotal - 1) / pageSize) + 1;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.oodt.commons.pagination;
+
+import java.util.List;
+
+/**
+ * @author mattmann
+ * @version $Revision$
+ *
+ * <p>
+ * A set of utility methods to do pagination.
+ * </p>
+ *
+ */
+public final class PaginationUtils {
+
+ private PaginationUtils() throws InstantiationException {
+ throw new InstantiationException("Don't construct utility classes!");
+ }
+
+ public static int hasRemainder(int divisor, int quotient) {
+ if (divisor % quotient != 0) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+
+ public static int computeCurrentPage(int startIdx, int productsPerPage) {
+ return ((startIdx + 1) / productsPerPage)
+ + hasRemainder(startIdx + 1, productsPerPage);
+ }
+
+ public static int computeCurrentWindow(int currPage, int pagesPerPage) {
+ return (currPage / pagesPerPage) + hasRemainder(currPage, pagesPerPage);
+ }
+
+ public static int computeMinPage(int pagesPerPage, int currWindow) {
+ return (pagesPerPage * (currWindow - 1)) + 1;
+ }
+
+ public static int computeMaxPage(int minPage, int pagesPerPage,
+ int lastIdx, int productsPerPage) {
+ return Math.min(minPage + (pagesPerPage - 1), computeCurrentPage(
+ lastIdx, productsPerPage));
+ }
+
+ public static int computeEndIdx(int currPage, int productsPerPage,
+ int totalProducts) {
+ return Math.min((currPage * productsPerPage) - 1, totalProducts - 1);
+ }
+
+ public static int computePrevStartIdx(int minPage, int productsPerPage) {
+ int prevPage = Math.max(minPage - 2, 1);
+ return (prevPage * productsPerPage);
+ }
+
+ public static int computeNextStartIdx(int maxPage, int productsPerPage) {
+ int nextPage = maxPage;
+ return (nextPage * productsPerPage);
+
+ }
+
+ public static List iterateFrom(final int startIndex,
+ final List originalList, int pageSize) {
+ final int totalSize = originalList.size();
+
+ int endIndex = startIndex + pageSize;
+ if (endIndex > totalSize)
+ endIndex = totalSize;
+
+ return originalList.subList(startIndex, endIndex);
+ }
+
+ public static int getTotalPage(List originalList, int pageSize) {
+ if (originalList == null || originalList.size() <= 0)
+ return 0;
+ final int totalSize = originalList.size();
+ return ((totalSize - 1) / pageSize) + 1;
+ }
+
+ public static int getTotalPage(int numTotal, int pageSize) {
+ if (numTotal <= 0)
+ return 0;
+ return ((numTotal - 1) / pageSize) + 1;
+ }
+
+}
Modified: incubator/oodt/trunk/commons/src/main/java/org/apache/oodt/commons/spring/SpringSetIdInjectionType.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/commons/src/main/java/org/apache/oodt/commons/spring/SpringSetIdInjectionType.java?rev=964147&r1=964122&r2=964147&view=diff
==============================================================================
--- incubator/oodt/trunk/commons/src/main/java/org/apache/oodt/commons/spring/SpringSetIdInjectionType.java (original)
+++ incubator/oodt/trunk/commons/src/main/java/org/apache/oodt/commons/spring/SpringSetIdInjectionType.java Wed Jul 14 19:32:42 2010
@@ -1,47 +1,47 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package gov.nasa.jpl.oodt.cas.commons.spring;
-
-//Spring imports
-import org.springframework.beans.factory.annotation.Required;
-
-/**
- *
- * @author bfoster
- * @version $Revision$
- *
- * <p>Describe your class here</p>.
- */
-public interface SpringSetIdInjectionType {
-
- /**
- * Get a unique String id that represents this objects instance
- * @return Unique String id
- */
- @Required
- public String getId();
-
- /**
- * Set a unique id that represents this objects instance
- * @param id Unique String id
- */
- @Required
- public void setId(String id);
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.oodt.commons.spring;
+
+//Spring imports
+import org.springframework.beans.factory.annotation.Required;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>Describe your class here</p>.
+ */
+public interface SpringSetIdInjectionType {
+
+ /**
+ * Get a unique String id that represents this objects instance
+ * @return Unique String id
+ */
+ @Required
+ public String getId();
+
+ /**
+ * Set a unique id that represents this objects instance
+ * @param id Unique String id
+ */
+ @Required
+ public void setId(String id);
+
+}
Modified: incubator/oodt/trunk/commons/src/main/java/org/apache/oodt/commons/spring/postprocessor/SetIdBeanPostProcessor.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/commons/src/main/java/org/apache/oodt/commons/spring/postprocessor/SetIdBeanPostProcessor.java?rev=964147&r1=964122&r2=964147&view=diff
==============================================================================
--- incubator/oodt/trunk/commons/src/main/java/org/apache/oodt/commons/spring/postprocessor/SetIdBeanPostProcessor.java (original)
+++ incubator/oodt/trunk/commons/src/main/java/org/apache/oodt/commons/spring/postprocessor/SetIdBeanPostProcessor.java Wed Jul 14 19:32:42 2010
@@ -1,49 +1,49 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package gov.nasa.jpl.oodt.cas.commons.spring.postprocessor;
-
-//OODT imports
-import gov.nasa.jpl.oodt.cas.commons.spring.SpringSetIdInjectionType;
-
-//Spring imports
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.config.BeanPostProcessor;
-
-/**
- *
- * @author bfoster
- * @version $Revision$
- *
- * <p>Describe your class here</p>.
- */
-public class SetIdBeanPostProcessor implements BeanPostProcessor {
-
- public Object postProcessAfterInitialization(Object bean, String beanName)
- throws BeansException {
- if (bean instanceof SpringSetIdInjectionType)
- ((SpringSetIdInjectionType) bean).setId(beanName);
- return bean;
- }
-
- public Object postProcessBeforeInitialization(Object bean, String beanName)
- throws BeansException {
- return bean;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.oodt.commons.spring.postprocessor;
+
+//OODT imports
+import org.apache.oodt.commons.spring.SpringSetIdInjectionType;
+
+//Spring imports
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>Describe your class here</p>.
+ */
+public class SetIdBeanPostProcessor implements BeanPostProcessor {
+
+ public Object postProcessAfterInitialization(Object bean, String beanName)
+ throws BeansException {
+ if (bean instanceof SpringSetIdInjectionType)
+ ((SpringSetIdInjectionType) bean).setId(beanName);
+ return bean;
+ }
+
+ public Object postProcessBeforeInitialization(Object bean, String beanName)
+ throws BeansException {
+ return bean;
+ }
+
+}
Modified: incubator/oodt/trunk/commons/src/main/java/org/apache/oodt/commons/xml/DOMUtil.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/commons/src/main/java/org/apache/oodt/commons/xml/DOMUtil.java?rev=964147&r1=964122&r2=964147&view=diff
==============================================================================
--- incubator/oodt/trunk/commons/src/main/java/org/apache/oodt/commons/xml/DOMUtil.java (original)
+++ incubator/oodt/trunk/commons/src/main/java/org/apache/oodt/commons/xml/DOMUtil.java Wed Jul 14 19:32:42 2010
@@ -1,107 +1,107 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package gov.nasa.jpl.oodt.cas.commons.xml;
-
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Node;
-import org.w3c.dom.Element;
-import org.w3c.dom.Text;
-
-/**
- *
- * <p>
- * This class was adapted from an O'Reilly site on DOM utilities. It contains a
- * few helper methods to make extracting out XML text from DOM representations a
- * little easier.
- * </p>
- *
- * @author mattmann
- * @version 1.0
- */
-public class DOMUtil {
-
- /**
- *
- * <p>
- * Method returns the First occurence of Element 'name' in the DOM Node
- * 'element'.
- * </p>
- *
- * @param element
- * The DOM Element node to traverse.
- * @param name
- * The XML name of the Element to return.
- * @return Element "element" with Name "name"'s first occurence.
- */
- public static Element getFirstElement(Element element, String name)
- throws Exception {
- NodeList n1 = element.getElementsByTagName(name);
-
- if (n1.getLength() < 1) {
- throw new Exception("Element: " + element + " does not contain: "
- + name);
- }
-
- return (Element) n1.item(0);
- }
-
- /**
- * *
- * <p>
- * This function is intended when you have a DOM element with no other DOM
- * elements inside (i.e. <Tag><Tag2>here is text</Tag2></Tag>)
- * </p> *
- *
- * @param node
- * The DOM 'SimpleElement' as defined in the Function definition.
- * @param name
- * The name of the Text to retreive.
- * @return the Text inbetween the simple element tags.
- */
- public static String getSimpleElementText(Element node, String name)
- throws Exception {
- Element namedElement = getFirstElement(node, name);
- return getSimpleElementText(namedElement);
- }
-
- /**
- * *
- * <p>
- * This function is intended for use when you have merely text between an
- * XML Element (i.e. <Tag>text here</Tag>).
- * </p>
- *
- * @param node
- * The DOM XML Tag, with text inbetween.
- * @return String text inbetween the simple element tag.
- */
- public static String getSimpleElementText(Element node) {
- StringBuffer sb = new StringBuffer();
- NodeList children = node.getChildNodes();
-
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child instanceof Text) {
- sb.append(child.getNodeValue());
- }
- }
-
- return sb.toString();
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.oodt.commons.xml;
+
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
+
+/**
+ *
+ * <p>
+ * This class was adapted from an O'Reilly site on DOM utilities. It contains a
+ * few helper methods to make extracting out XML text from DOM representations a
+ * little easier.
+ * </p>
+ *
+ * @author mattmann
+ * @version 1.0
+ */
+public class DOMUtil {
+
+ /**
+ *
+ * <p>
+ * Method returns the First occurence of Element 'name' in the DOM Node
+ * 'element'.
+ * </p>
+ *
+ * @param element
+ * The DOM Element node to traverse.
+ * @param name
+ * The XML name of the Element to return.
+ * @return Element "element" with Name "name"'s first occurence.
+ */
+ public static Element getFirstElement(Element element, String name)
+ throws Exception {
+ NodeList n1 = element.getElementsByTagName(name);
+
+ if (n1.getLength() < 1) {
+ throw new Exception("Element: " + element + " does not contain: "
+ + name);
+ }
+
+ return (Element) n1.item(0);
+ }
+
+ /**
+ * *
+ * <p>
+ * This function is intended when you have a DOM element with no other DOM
+ * elements inside (i.e. <Tag><Tag2>here is text</Tag2></Tag>)
+ * </p> *
+ *
+ * @param node
+ * The DOM 'SimpleElement' as defined in the Function definition.
+ * @param name
+ * The name of the Text to retreive.
+ * @return the Text inbetween the simple element tags.
+ */
+ public static String getSimpleElementText(Element node, String name)
+ throws Exception {
+ Element namedElement = getFirstElement(node, name);
+ return getSimpleElementText(namedElement);
+ }
+
+ /**
+ * *
+ * <p>
+ * This function is intended for use when you have merely text between an
+ * XML Element (i.e. <Tag>text here</Tag>).
+ * </p>
+ *
+ * @param node
+ * The DOM XML Tag, with text inbetween.
+ * @return String text inbetween the simple element tag.
+ */
+ public static String getSimpleElementText(Element node) {
+ StringBuffer sb = new StringBuffer();
+ NodeList children = node.getChildNodes();
+
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child instanceof Text) {
+ sb.append(child.getNodeValue());
+ }
+ }
+
+ return sb.toString();
+ }
+}
Modified: incubator/oodt/trunk/commons/src/main/java/org/apache/oodt/commons/xml/XMLUtils.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/commons/src/main/java/org/apache/oodt/commons/xml/XMLUtils.java?rev=964147&r1=964122&r2=964147&view=diff
==============================================================================
--- incubator/oodt/trunk/commons/src/main/java/org/apache/oodt/commons/xml/XMLUtils.java (original)
+++ incubator/oodt/trunk/commons/src/main/java/org/apache/oodt/commons/xml/XMLUtils.java Wed Jul 14 19:32:42 2010
@@ -1,234 +1,234 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package gov.nasa.jpl.oodt.cas.commons.xml;
-
-//JDK imports
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.OutputKeys;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.xml.sax.InputSource;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URLDecoder;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * @author mattmann
- * @author bfoster
- * @version $Revision$
- *
- *
- * <p>
- * A Utility class containing methods to write and transform XML objects.
- * </p>
- */
-
-public class XMLUtils {
-
- /* our log stream */
- private final static Logger LOG = Logger
- .getLogger(XMLUtils.class.getName());
-
- /**
- * <p>
- * This method writes a DOM document to a file
- * </p>.
- *
- * @param doc
- * The DOM document to write.
- * @param filename
- * The filename to write the DOM document to.
- */
- public static void writeXmlFile(Document doc, String filename) {
- // Prepare the output file
- Result result = new StreamResult(filename);
- transform(doc, result);
- }
-
- public static void writeXmlToStream(Document doc, OutputStream stream) {
- Result result = new StreamResult(stream);
- transform(doc, result);
- }
-
- private static void transform(Document doc, Result result) {
- try {
- // Prepare the DOM document for writing
- Source source = new DOMSource(doc);
-
- // Write the DOM document to the file
- Transformer xformer = TransformerFactory.newInstance()
- .newTransformer();
- xformer.setOutputProperty(OutputKeys.INDENT, "yes");
- xformer.transform(source, result);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
-
- public static List readMany(Element root, String elt) {
- return readMany(root, elt, "UTF-8");
- }
-
- public static List readMany(Element root, String elt, String encoding) {
- NodeList valueNodes = root.getElementsByTagName(elt);
- List values = new Vector();
-
- for (int i = 0; i < valueNodes.getLength(); i++) {
- Element valElem = (Element) valueNodes.item(i);
- String value = null;
-
- try {
- value = URLDecoder.decode(
- DOMUtil.getSimpleElementText(valElem), encoding);
- values.add(value);
- } catch (Exception e) {
- e.printStackTrace();
- LOG.log(Level.WARNING, "Error decoding tag: [" + elt
- + "]: val: [" + DOMUtil.getSimpleElementText(valElem)
- + "] from metadata. Message: " + e.getMessage());
- }
- }
-
- return values;
- }
-
- public static String read(Element root, String elt) {
- return read(root, elt, "UTF-8");
- }
-
- public static String read(Element root, String elt, String encoding) {
-
- String value = null;
- try {
- value = URLDecoder.decode(DOMUtil.getSimpleElementText(root, elt),
- encoding);
- } catch (Exception e) {
- LOG.log(Level.WARNING, "Error decoding " + elt + "from metadata. "
- + "Message: " + e.getMessage());
- }
- return value;
- }
-
- public static Element getFirstElement(String name, Element root) {
- NodeList list = root.getElementsByTagName(name);
- if (list != null) {
- return (Element) list.item(0);
- } else
- return null;
- }
-
- public static String getSimpleElementText(Element node, boolean trim) {
- if (node.getChildNodes().item(0) instanceof Text) {
- String elemTxt = null;
- if (trim) {
- elemTxt = node.getChildNodes().item(0).getNodeValue().trim();
- } else {
- elemTxt = node.getChildNodes().item(0).getNodeValue();
- }
-
- return elemTxt;
- } else
- return null;
- }
-
- public static String getSimpleElementText(Element node) {
- return getSimpleElementText(node, false);
- }
-
- public static String getElementText(String elemName, Element root,
- boolean trim) {
- Element elem = getFirstElement(elemName, root);
- if (elem != null) {
- return getSimpleElementText(elem, trim);
- } else
- return null;
- }
-
- public static String getElementText(String elemName, Element root) {
- return getElementText(elemName, root, false);
- }
-
- public static Document getDocumentRoot(InputStream is) {
- // open up the XML file
- DocumentBuilderFactory factory = null;
- DocumentBuilder parser = null;
- Document document = null;
- InputSource inputSource = null;
-
- inputSource = new InputSource(is);
-
- try {
- factory = DocumentBuilderFactory.newInstance();
- parser = factory.newDocumentBuilder();
- document = parser.parse(inputSource);
- } catch (Exception e) {
- LOG.log(Level.WARNING, "Unable to parse xml stream"
- + ": Reason is [" + e + "]");
- return null;
- }
-
- return document;
- }
-
- public static Element addNode(Document doc, Node parent, String name) {
- Element child = doc.createElement(name);
- parent.appendChild(child);
- return child;
- }
-
- public static void addNode(Document doc, Node parent, String name,
- String text) {
- Element child = doc.createElement(name);
- child.appendChild(doc.createTextNode(text));
- parent.appendChild(child);
- }
-
- public static void addNode(Document doc, Node parent, String ns,
- String name, String text, Map NS_MAP) {
- Element child = doc.createElementNS((String) NS_MAP.get(ns), ns + ":"
- + name);
- child.appendChild(doc.createTextNode(text));
- parent.appendChild(child);
- }
-
- public static void addAttribute(Document doc, Element node, String name,
- String value) {
- Attr attribute = doc.createAttribute(name);
- attribute.setValue(value);
- node.getAttributes().setNamedItem(attribute);
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.oodt.commons.xml;
+
+//JDK imports
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.OutputKeys;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.InputSource;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URLDecoder;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * @author mattmann
+ * @author bfoster
+ * @version $Revision$
+ *
+ *
+ * <p>
+ * A Utility class containing methods to write and transform XML objects.
+ * </p>
+ */
+
+public class XMLUtils {
+
+ /* our log stream */
+ private final static Logger LOG = Logger
+ .getLogger(XMLUtils.class.getName());
+
+ /**
+ * <p>
+ * This method writes a DOM document to a file
+ * </p>.
+ *
+ * @param doc
+ * The DOM document to write.
+ * @param filename
+ * The filename to write the DOM document to.
+ */
+ public static void writeXmlFile(Document doc, String filename) {
+ // Prepare the output file
+ Result result = new StreamResult(filename);
+ transform(doc, result);
+ }
+
+ public static void writeXmlToStream(Document doc, OutputStream stream) {
+ Result result = new StreamResult(stream);
+ transform(doc, result);
+ }
+
+ private static void transform(Document doc, Result result) {
+ try {
+ // Prepare the DOM document for writing
+ Source source = new DOMSource(doc);
+
+ // Write the DOM document to the file
+ Transformer xformer = TransformerFactory.newInstance()
+ .newTransformer();
+ xformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ xformer.transform(source, result);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ public static List readMany(Element root, String elt) {
+ return readMany(root, elt, "UTF-8");
+ }
+
+ public static List readMany(Element root, String elt, String encoding) {
+ NodeList valueNodes = root.getElementsByTagName(elt);
+ List values = new Vector();
+
+ for (int i = 0; i < valueNodes.getLength(); i++) {
+ Element valElem = (Element) valueNodes.item(i);
+ String value = null;
+
+ try {
+ value = URLDecoder.decode(
+ DOMUtil.getSimpleElementText(valElem), encoding);
+ values.add(value);
+ } catch (Exception e) {
+ e.printStackTrace();
+ LOG.log(Level.WARNING, "Error decoding tag: [" + elt
+ + "]: val: [" + DOMUtil.getSimpleElementText(valElem)
+ + "] from metadata. Message: " + e.getMessage());
+ }
+ }
+
+ return values;
+ }
+
+ public static String read(Element root, String elt) {
+ return read(root, elt, "UTF-8");
+ }
+
+ public static String read(Element root, String elt, String encoding) {
+
+ String value = null;
+ try {
+ value = URLDecoder.decode(DOMUtil.getSimpleElementText(root, elt),
+ encoding);
+ } catch (Exception e) {
+ LOG.log(Level.WARNING, "Error decoding " + elt + "from metadata. "
+ + "Message: " + e.getMessage());
+ }
+ return value;
+ }
+
+ public static Element getFirstElement(String name, Element root) {
+ NodeList list = root.getElementsByTagName(name);
+ if (list != null) {
+ return (Element) list.item(0);
+ } else
+ return null;
+ }
+
+ public static String getSimpleElementText(Element node, boolean trim) {
+ if (node.getChildNodes().item(0) instanceof Text) {
+ String elemTxt = null;
+ if (trim) {
+ elemTxt = node.getChildNodes().item(0).getNodeValue().trim();
+ } else {
+ elemTxt = node.getChildNodes().item(0).getNodeValue();
+ }
+
+ return elemTxt;
+ } else
+ return null;
+ }
+
+ public static String getSimpleElementText(Element node) {
+ return getSimpleElementText(node, false);
+ }
+
+ public static String getElementText(String elemName, Element root,
+ boolean trim) {
+ Element elem = getFirstElement(elemName, root);
+ if (elem != null) {
+ return getSimpleElementText(elem, trim);
+ } else
+ return null;
+ }
+
+ public static String getElementText(String elemName, Element root) {
+ return getElementText(elemName, root, false);
+ }
+
+ public static Document getDocumentRoot(InputStream is) {
+ // open up the XML file
+ DocumentBuilderFactory factory = null;
+ DocumentBuilder parser = null;
+ Document document = null;
+ InputSource inputSource = null;
+
+ inputSource = new InputSource(is);
+
+ try {
+ factory = DocumentBuilderFactory.newInstance();
+ parser = factory.newDocumentBuilder();
+ document = parser.parse(inputSource);
+ } catch (Exception e) {
+ LOG.log(Level.WARNING, "Unable to parse xml stream"
+ + ": Reason is [" + e + "]");
+ return null;
+ }
+
+ return document;
+ }
+
+ public static Element addNode(Document doc, Node parent, String name) {
+ Element child = doc.createElement(name);
+ parent.appendChild(child);
+ return child;
+ }
+
+ public static void addNode(Document doc, Node parent, String name,
+ String text) {
+ Element child = doc.createElement(name);
+ child.appendChild(doc.createTextNode(text));
+ parent.appendChild(child);
+ }
+
+ public static void addNode(Document doc, Node parent, String ns,
+ String name, String text, Map NS_MAP) {
+ Element child = doc.createElementNS((String) NS_MAP.get(ns), ns + ":"
+ + name);
+ child.appendChild(doc.createTextNode(text));
+ parent.appendChild(child);
+ }
+
+ public static void addAttribute(Document doc, Element node, String name,
+ String value) {
+ Attr attribute = doc.createAttribute(name);
+ attribute.setValue(value);
+ node.getAttributes().setNamedItem(attribute);
+ }
+
+}
Modified: incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/ActivityStoppedTest.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/ActivityStoppedTest.java?rev=964147&r1=964122&r2=964147&view=diff
==============================================================================
--- incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/ActivityStoppedTest.java (original)
+++ incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/ActivityStoppedTest.java Wed Jul 14 19:32:42 2010
@@ -1,9 +1,21 @@
-// Copyright 2003 California Institute of Technology. ALL RIGHTS RESERVED.
-// U.S. Government Sponsorship acknowledged.
-//
-// $Id: ActivityStoppedTest.java,v 1.1 2004-03-02 19:29:00 kelly Exp $
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
-package jpl.eda.activity;
+package org.apache.oodt.commons.activity;
import junit.framework.TestCase;
Modified: incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/ActivityTest.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/ActivityTest.java?rev=964147&r1=964122&r2=964147&view=diff
==============================================================================
--- incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/ActivityTest.java (original)
+++ incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/ActivityTest.java Wed Jul 14 19:32:42 2010
@@ -1,9 +1,21 @@
-// Copyright 2003 California Institute of Technology. ALL RIGHTS RESERVED.
-// U.S. Government Sponsorship acknowledged.
-//
-// $Id: ActivityTest.java,v 1.1 2004-03-02 19:29:00 kelly Exp $
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
-package jpl.eda.activity;
+package org.apache.oodt.commons.activity;
import junit.framework.TestCase;
Modified: incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/ActivityTrackerTest.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/ActivityTrackerTest.java?rev=964147&r1=964122&r2=964147&view=diff
==============================================================================
--- incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/ActivityTrackerTest.java (original)
+++ incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/ActivityTrackerTest.java Wed Jul 14 19:32:42 2010
@@ -1,9 +1,21 @@
-// Copyright 2003 California Institute of Technology. ALL RIGHTS RESERVED.
-// U.S. Government Sponsorship acknowledged.
-//
-// $Id: ActivityTrackerTest.java,v 1.1 2004-03-02 19:29:00 kelly Exp $
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
-package jpl.eda.activity;
+package org.apache.oodt.commons.activity;
import junit.framework.TestCase;
@@ -24,14 +36,14 @@ public class ActivityTrackerTest extends
}
/**
- * Save old values of the <code>jpl.eda.activity.factories</code> and
+ * Save old values of the <code>org.apache.oodt.commons.activity.factories</code> and
* <code>activity.factories</code> properties.
*
* @throws Exception if an error occurs.
*/
protected void setUp() throws Exception {
super.setUp();
- longName = System.getProperty("jpl.eda.activity.factories");
+ longName = System.getProperty("org.apache.oodt.commons.activity.factories");
shortName = System.getProperty("activity.factories");
}
@@ -41,39 +53,39 @@ public class ActivityTrackerTest extends
* @throws Exception if an error occurs.
*/
public void testInitialization() throws Exception {
- System.getProperties().remove("jpl.eda.activity.factories"); // Clear the long property
+ System.getProperties().remove("org.apache.oodt.commons.activity.factories"); // Clear the long property
System.getProperties().remove("activity.factories"); // And the short one
ActivityTracker.initializeFactories(); // And initalize
Activity activity = ActivityTracker.createActivity(); // Have it make an activity
assertTrue(activity instanceof NullActivity); // With neither set, it must be NullActivity
- System.setProperty("jpl.eda.activity.factories", // Now set the long name
- "jpl.eda.activity.ActivityTrackerTest$TestFactory"); // to point to our test factory
+ System.setProperty("org.apache.oodt.commons.activity.factories", // Now set the long name
+ "org.apache.oodt.commons.activity.ActivityTrackerTest$TestFactory"); // to point to our test factory
System.setProperty("activity.factories", "non-existent-class"); // And set the short name to nonsense
ActivityTracker.initializeFactories(); // And initialize
activity = ActivityTracker.createActivity(); // Have it make an activity
assertTrue(activity instanceof TestActivity); // With just one, it must be our TestActivity
- System.getProperties().remove("jpl.eda.activity.factories"); // Clear the long so it must look at short
+ System.getProperties().remove("org.apache.oodt.commons.activity.factories"); // Clear the long so it must look at short
System.setProperty("activity.factories", // And set the short name to...
- "jpl.eda.activity.ActivityTrackerTest$TestFactory" // ...not one, but...
- + ",jpl.eda.activity.ActivityTrackerTest$TestFactory"); // ...two factories
+ "org.apache.oodt.commons.activity.ActivityTrackerTest$TestFactory" // ...not one, but...
+ + ",org.apache.oodt.commons.activity.ActivityTrackerTest$TestFactory"); // ...two factories
ActivityTracker.initializeFactories(); // And initialize
activity = ActivityTracker.createActivity(); // Now create an activity
assertTrue(activity instanceof CompositeActivity); // With > 1, it must be a CompositeActivity
}
/**
- * Restore old values of the <code>jpl.eda.activity.factories</code> and
+ * Restore old values of the <code>org.apache.oodt.commons.activity.factories</code> and
* <code>activity.factories</code> properties.
*
* @throws Exception if an error occurs.
*/
protected void tearDown() throws Exception {
if (longName == null)
- System.getProperties().remove("jpl.eda.activity.factories");
+ System.getProperties().remove("org.apache.oodt.commons.activity.factories");
else
- System.setProperty("jpl.eda.activity.factories", longName);
+ System.setProperty("org.apache.oodt.commons.activity.factories", longName);
if (shortName == null)
System.getProperties().remove("activity.factories");
else
@@ -97,7 +109,7 @@ public class ActivityTrackerTest extends
}
}
- /** Old value of the <code>jpl.eda.activity.factories</code> property. */
+ /** Old value of the <code>org.apache.oodt.commons.activity.factories</code> property. */
private String longName;
/** Old value of the <code>activity.factories</code> property. */
Modified: incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/CompositeActivityTest.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/CompositeActivityTest.java?rev=964147&r1=964122&r2=964147&view=diff
==============================================================================
--- incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/CompositeActivityTest.java (original)
+++ incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/CompositeActivityTest.java Wed Jul 14 19:32:42 2010
@@ -1,9 +1,21 @@
-// Copyright 2003 California Institute of Technology. ALL RIGHTS RESERVED.
-// U.S. Government Sponsorship acknowledged.
-//
-// $Id: CompositeActivityTest.java,v 1.1 2004-03-02 19:29:00 kelly Exp $
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
-package jpl.eda.activity;
+package org.apache.oodt.commons.activity;
import java.util.Collections;
import junit.framework.TestCase;
Modified: incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/DatagramLoggingActivityFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/DatagramLoggingActivityFactoryTest.java?rev=964147&r1=964122&r2=964147&view=diff
==============================================================================
--- incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/DatagramLoggingActivityFactoryTest.java (original)
+++ incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/DatagramLoggingActivityFactoryTest.java Wed Jul 14 19:32:42 2010
@@ -1,147 +1,159 @@
-// Copyright 2003 California Institute of Technology. ALL RIGHTS RESERVED.
-// U.S. Government Sponsorship acknowledged.
-//
-// $Id: DatagramLoggingActivityFactoryTest.java,v 1.1 2004-03-02 19:29:01 kelly Exp $
-
-package jpl.eda.activity;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.SocketException;
-import junit.framework.TestCase;
-
-/**
- * Test the {@link DatagramLoggingActivityFactory} class.
- *
- * @author Kelly
- * @version $Revision: 1.1 $
- */
-public class DatagramLoggingActivityFactoryTest extends TestCase {
- /**
- * Creates a new {@link DatagramLoggingActivityFactoryTest} instance.
- *
- * @param name Case name.
- */
- public DatagramLoggingActivityFactoryTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- oldLongHost = System.getProperty("jpl.eda.activity.DatagramLoggingActivityFactory.host");
- oldShortHost = System.getProperty("activity.host");
- oldLongPort = System.getProperty("jpl.eda.activity.DatagramLoggingActivityFactory.port");
- oldShortPort = System.getProperty("activity.port");
- }
-
- protected void tearDown() throws Exception {
- restore("jpl.eda.activity.DatagramLoggingActivityFactory.host", oldLongHost);
- restore("activity.host", oldShortHost);
- restore("jpl.eda.activity.DatagramLoggingActivityFactory.port", oldLongPort);
- restore("activity.port", oldShortPort);
- super.tearDown();
- }
-
- /**
- * Test use of the system properties.
- *
- * @throws SocketException if an error occurs.
- */
- public void testPropertyPriority() throws SocketException {
- System.getProperties().remove("jpl.eda.activity.DatagramLoggingActivityFactory.host");
- System.getProperties().remove("jpl.eda.activity.DatagramLoggingActivityFactory.port");
- System.getProperties().remove("activity.host");
- System.getProperties().remove("activity.port");
- try {
- new DatagramLoggingActivityFactory();
- fail("Can make a DatagramLoggingActivityFactory without host property set");
- } catch (IllegalStateException ex) {}
-
- System.setProperty("jpl.eda.activity.DatagramLoggingActivityFactory.host", "localhost");
- System.setProperty("activity.host", "non-existent-host");
- DatagramLoggingActivityFactory fac = new DatagramLoggingActivityFactory();
- assertEquals(jpl.eda.net.Net.getLoopbackAddress(), fac.host);
- assertEquals(4556, fac.port);
- fac.socket.close();
-
- System.getProperties().remove("jpl.eda.activity.DatagramLoggingActivityFactory.host");
- System.setProperty("activity.host", "localhost");
- fac = new DatagramLoggingActivityFactory();
- assertEquals(jpl.eda.net.Net.getLoopbackAddress(), fac.host);
- assertEquals(4556, fac.port);
- fac.socket.close();
-
- DatagramSocket soc = new DatagramSocket();
- int portNum = soc.getLocalPort();
- System.setProperty("jpl.eda.activity.DatagramLoggingActivityFactory.port", String.valueOf(portNum));
- System.setProperty("activity.port", "illegal-port-value");
- fac = new DatagramLoggingActivityFactory();
- assertEquals(portNum, fac.port);
- fac.socket.close();
-
- System.getProperties().remove("jpl.eda.activity.DatagramLoggingActivityFactory.port");
- System.setProperty("activity.port", String.valueOf(portNum));
- fac = new DatagramLoggingActivityFactory();
- assertEquals(portNum, fac.port);
- fac.socket.close();
- soc.close();
- }
-
- /**
- * Test construction and transmission of datagrams.
- *
- * @throws SocketException if an error occurs.
- * @throws IOException if an error occurs.
- * @throws ClassNotFoundException if an error occurs.
- */
- public void testActivityReceipt() throws SocketException, IOException, ClassNotFoundException {
- DatagramSocket socket = null;
- try {
- byte[] buf = new byte[512];
- DatagramPacket packet = new DatagramPacket(buf, buf.length);
- socket = new DatagramSocket();
- System.setProperty("activity.host", "localhost");
- System.setProperty("activity.port", String.valueOf(socket.getLocalPort()));
- DatagramLoggingActivityFactory fac = new DatagramLoggingActivityFactory();
- Activity a = fac.createActivity();
- Incident i = new Incident();
- a.log(i);
- socket.receive(packet);
- ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(packet.getData(), packet.getOffset(),
- packet.getLength()));
- Incident j = (Incident) ois.readObject();
- assertEquals(i, j);
- } finally {
- if (socket != null)
- socket.close();
- }
- }
-
- /**
- * Restore a system property.
- *
- * @param propName Name of the property to restore.
- * @param value Old value of the system property, or null if the property wasn't previously set.
- */
- private static void restore(String propName, String value) {
- if (value == null)
- System.getProperties().remove(propName);
- else
- System.setProperty(propName, value);
- }
-
- /** Old value of <code>jpl.eda.activity.DatagramLoggingActivityFactory.host</code>. */
- private String oldLongHost;
-
- /** Old value of <code>activity.host</code>. */
- private String oldShortHost;
-
- /** Old value of <code>jpl.eda.activity.DatagramLoggingActivityFactory.port</code>. */
- private String oldLongPort;
-
- /** Old value of <code>activity.port</code>. */
- private String oldShortPort;
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.commons.activity;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.SocketException;
+import junit.framework.TestCase;
+
+/**
+ * Test the {@link DatagramLoggingActivityFactory} class.
+ *
+ * @author Kelly
+ * @version $Revision: 1.1 $
+ */
+public class DatagramLoggingActivityFactoryTest extends TestCase {
+ /**
+ * Creates a new {@link DatagramLoggingActivityFactoryTest} instance.
+ *
+ * @param name Case name.
+ */
+ public DatagramLoggingActivityFactoryTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ oldLongHost = System.getProperty("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.host");
+ oldShortHost = System.getProperty("activity.host");
+ oldLongPort = System.getProperty("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.port");
+ oldShortPort = System.getProperty("activity.port");
+ }
+
+ protected void tearDown() throws Exception {
+ restore("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.host", oldLongHost);
+ restore("activity.host", oldShortHost);
+ restore("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.port", oldLongPort);
+ restore("activity.port", oldShortPort);
+ super.tearDown();
+ }
+
+ /**
+ * Test use of the system properties.
+ *
+ * @throws SocketException if an error occurs.
+ */
+ public void testPropertyPriority() throws SocketException {
+ System.getProperties().remove("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.host");
+ System.getProperties().remove("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.port");
+ System.getProperties().remove("activity.host");
+ System.getProperties().remove("activity.port");
+ try {
+ new DatagramLoggingActivityFactory();
+ fail("Can make a DatagramLoggingActivityFactory without host property set");
+ } catch (IllegalStateException ex) {}
+
+ System.setProperty("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.host", "localhost");
+ System.setProperty("activity.host", "non-existent-host");
+ DatagramLoggingActivityFactory fac = new DatagramLoggingActivityFactory();
+ assertEquals(org.apache.oodt.commons.net.Net.getLoopbackAddress(), fac.host);
+ assertEquals(4556, fac.port);
+ fac.socket.close();
+
+ System.getProperties().remove("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.host");
+ System.setProperty("activity.host", "localhost");
+ fac = new DatagramLoggingActivityFactory();
+ assertEquals(org.apache.oodt.commons.net.Net.getLoopbackAddress(), fac.host);
+ assertEquals(4556, fac.port);
+ fac.socket.close();
+
+ DatagramSocket soc = new DatagramSocket();
+ int portNum = soc.getLocalPort();
+ System.setProperty("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.port", String.valueOf(portNum));
+ System.setProperty("activity.port", "illegal-port-value");
+ fac = new DatagramLoggingActivityFactory();
+ assertEquals(portNum, fac.port);
+ fac.socket.close();
+
+ System.getProperties().remove("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.port");
+ System.setProperty("activity.port", String.valueOf(portNum));
+ fac = new DatagramLoggingActivityFactory();
+ assertEquals(portNum, fac.port);
+ fac.socket.close();
+ soc.close();
+ }
+
+ /**
+ * Test construction and transmission of datagrams.
+ *
+ * @throws SocketException if an error occurs.
+ * @throws IOException if an error occurs.
+ * @throws ClassNotFoundException if an error occurs.
+ */
+ public void testActivityReceipt() throws SocketException, IOException, ClassNotFoundException {
+ DatagramSocket socket = null;
+ try {
+ byte[] buf = new byte[512];
+ DatagramPacket packet = new DatagramPacket(buf, buf.length);
+ socket = new DatagramSocket();
+ System.setProperty("activity.host", "localhost");
+ System.setProperty("activity.port", String.valueOf(socket.getLocalPort()));
+ DatagramLoggingActivityFactory fac = new DatagramLoggingActivityFactory();
+ Activity a = fac.createActivity();
+ Incident i = new Incident();
+ a.log(i);
+ socket.receive(packet);
+ ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(packet.getData(), packet.getOffset(),
+ packet.getLength()));
+ Incident j = (Incident) ois.readObject();
+ assertEquals(i, j);
+ } finally {
+ if (socket != null)
+ socket.close();
+ }
+ }
+
+ /**
+ * Restore a system property.
+ *
+ * @param propName Name of the property to restore.
+ * @param value Old value of the system property, or null if the property wasn't previously set.
+ */
+ private static void restore(String propName, String value) {
+ if (value == null)
+ System.getProperties().remove(propName);
+ else
+ System.setProperty(propName, value);
+ }
+
+ /** Old value of <code>org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.host</code>. */
+ private String oldLongHost;
+
+ /** Old value of <code>activity.host</code>. */
+ private String oldShortHost;
+
+ /** Old value of <code>org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.port</code>. */
+ private String oldLongPort;
+
+ /** Old value of <code>activity.port</code>. */
+ private String oldShortPort;
+}
Modified: incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/HistoryTest.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/HistoryTest.java?rev=964147&r1=964122&r2=964147&view=diff
==============================================================================
--- incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/HistoryTest.java (original)
+++ incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/HistoryTest.java Wed Jul 14 19:32:42 2010
@@ -1,222 +1,234 @@
-// Copyright 2003 California Institute of Technology. ALL RIGHTS RESERVED.
-// U.S. Government Sponsorship acknowledged.
-//
-// $Id: HistoryTest.java,v 1.1 2004-03-02 19:29:01 kelly Exp $
-
-package jpl.eda.activity;
-
-import java.util.List;
-import junit.framework.TestCase;
-
-/**
- * Test the {@link History} class.
- *
- * @author Kelly
- * @version $Revision: 1.1 $
- */
-public class HistoryTest extends TestCase implements Storage {
- /**
- * Creates a new {@link HistoryTest} instance.
- *
- * @param name Case name.
- */
- public HistoryTest(String name) {
- super(name);
- }
-
- /**
- * Save the old idle and close times.
- *
- * @throws Exception if an error occurs.
- */
- protected void setUp() throws Exception {
- super.setUp();
- oldIdle = History.idleTime;
- oldClose = History.closeTime;
- }
-
- /**
- * Restore the old idle and close times.
- *
- * @throws Exception if an error occurs.
- */
- protected void tearDown() throws Exception {
- History.idleTime = oldIdle;
- History.closeTime = oldClose;
- super.tearDown();
- }
-
- public void testIllegalIncidents() {
- History.closeTime = 50;
- Incident one = new Incident();
- one.setActivityID(new String("a")); // Want unique objects
- Incident two = new Incident();
- two.setActivityID(new String("a")); // Want unique objects
- Incident three = new Incident();
- three.setActivityID("b");
- History history = new History(one, this);
- history.addIncident(two);
- try {
- history.addIncident(three);
- fail("Able to add Incidents with non-matching activity IDs");
- } catch (IllegalArgumentException good) {}
- }
-
- /**
- * Test a normal, well-behaved lifecylce of (incident, incident, stop) with no
- * idle times.
- */
- public void testLifecycle() {
- History.closeTime = 50;
- Incident one = new Incident();
- one.setActivityID("test");
- History history = new History(one, this);
- rest();
- Incident two = new Incident();
- two.setActivityID("test");
- history.addIncident(two);
- rest();
- ActivityStopped three = new ActivityStopped();
- three.setActivityID("test");
- history.addIncident(three);
- rest();
- assertNotNull("History never called store", id);
- assertEquals("test", id);
- assertNotNull(incidents);
- assertEquals(3, incidents.size());
- assertEquals(one, incidents.get(0));
- assertEquals(two, incidents.get(1));
- assertEquals(three, incidents.get(2));
- }
-
- /**
- * Test arrival and recording of incidents <i>after</i> the stop incident.
- */
- public void testPostCloseIncidents() {
- History.closeTime = 300;
- Incident one = new Incident();
- one.setActivityID("test");
- rest();
- ActivityStopped two = new ActivityStopped();
- two.setActivityID("test");
- rest();
- Incident three = new Incident();
- three.setActivityID("test");
-
- History history = new History(one, this);
- history.addIncident(two);
- rest();
- history.addIncident(three);
- rest(200);
-
- assertNotNull("History never called store", id);
- assertEquals("test", id);
- assertNotNull(incidents);
- assertEquals(3, incidents.size());
- assertEquals(one, incidents.get(0));
- assertEquals(two, incidents.get(1));
- assertEquals(three, incidents.get(2));
- }
-
- /**
- * Test if an idle history is committed when a stop incident is late.
- */
- public void testIdleHistory() {
- History.idleTime = 300;
- History.closeTime = 100;
- Incident one = new Incident();
- one.setActivityID("test");
- rest();
- Incident two = new Incident();
- two.setActivityID("test");
- rest();
- ActivityStopped three = new ActivityStopped();
- three.setActivityID("test");
-
- History history = new History(one, this);
- rest();
- history.addIncident(two);
- rest(500);
- history.addIncident(three);
-
- assertNotNull("History never called store", id);
- assertEquals("test", id);
- assertNotNull(incidents);
- assertEquals(2, incidents.size());
- assertEquals(one, incidents.get(0));
- assertEquals(two, incidents.get(1));
- }
-
- /**
- * Test if an idle history is committed and the stop incident arrives in time to
- * be recorded.
- */
- public void testPostCommitActivityStop() {
- History.idleTime = 300;
- History.closeTime = 500;
- Incident one = new Incident();
- one.setActivityID("test");
- rest();
- Incident two = new Incident();
- two.setActivityID("test");
- rest();
- ActivityStopped three = new ActivityStopped();
- three.setActivityID("test");
-
- History history = new History(one, this);
- rest();
- history.addIncident(two);
- rest(500);
- history.addIncident(three);
- rest(400);
-
- assertNotNull("History never called store", id);
- assertEquals("test", id);
- assertNotNull(incidents);
- assertEquals(3, incidents.size());
- assertEquals(one, incidents.get(0));
- assertEquals(two, incidents.get(1));
- assertEquals(three, incidents.get(2));
- }
-
- /**
- * Our test storage just saves the last received ID and list of incidents.
- *
- * @param id ID, which should always be <code>test</code>.
- * @param incidents {@link List} of received {@link Incident}s.
- */
- public void store(String id, List incidents) {
- this.id = id;
- this.incidents = incidents;
- }
-
- /**
- * Pause the current thread for the given time.
- *
- * @param time Milliseconds to sleep.
- */
- private static void rest(long time) {
- try {
- Thread.sleep(time);
- } catch (InterruptedException ignore) {}
- }
-
- /**
- * Pause the current thread for 100 milliseconds.
- */
- private static void rest() {
- rest(100);
- }
-
- /** Last stored ID. */
- private String id;
-
- /** Last stored list of {@link Incident}s. */
- private List incidents;
-
- /** Idle time to restore. */
- private long oldIdle;
-
- /** Close time to restore. */
- private long oldClose;
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.commons.activity;
+
+import java.util.List;
+import junit.framework.TestCase;
+
+/**
+ * Test the {@link History} class.
+ *
+ * @author Kelly
+ * @version $Revision: 1.1 $
+ */
+public class HistoryTest extends TestCase implements Storage {
+ /**
+ * Creates a new {@link HistoryTest} instance.
+ *
+ * @param name Case name.
+ */
+ public HistoryTest(String name) {
+ super(name);
+ }
+
+ /**
+ * Save the old idle and close times.
+ *
+ * @throws Exception if an error occurs.
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ oldIdle = History.idleTime;
+ oldClose = History.closeTime;
+ }
+
+ /**
+ * Restore the old idle and close times.
+ *
+ * @throws Exception if an error occurs.
+ */
+ protected void tearDown() throws Exception {
+ History.idleTime = oldIdle;
+ History.closeTime = oldClose;
+ super.tearDown();
+ }
+
+ public void testIllegalIncidents() {
+ History.closeTime = 50;
+ Incident one = new Incident();
+ one.setActivityID(new String("a")); // Want unique objects
+ Incident two = new Incident();
+ two.setActivityID(new String("a")); // Want unique objects
+ Incident three = new Incident();
+ three.setActivityID("b");
+ History history = new History(one, this);
+ history.addIncident(two);
+ try {
+ history.addIncident(three);
+ fail("Able to add Incidents with non-matching activity IDs");
+ } catch (IllegalArgumentException good) {}
+ }
+
+ /**
+ * Test a normal, well-behaved lifecylce of (incident, incident, stop) with no
+ * idle times.
+ */
+ public void testLifecycle() {
+ History.closeTime = 50;
+ Incident one = new Incident();
+ one.setActivityID("test");
+ History history = new History(one, this);
+ rest();
+ Incident two = new Incident();
+ two.setActivityID("test");
+ history.addIncident(two);
+ rest();
+ ActivityStopped three = new ActivityStopped();
+ three.setActivityID("test");
+ history.addIncident(three);
+ rest();
+ assertNotNull("History never called store", id);
+ assertEquals("test", id);
+ assertNotNull(incidents);
+ assertEquals(3, incidents.size());
+ assertEquals(one, incidents.get(0));
+ assertEquals(two, incidents.get(1));
+ assertEquals(three, incidents.get(2));
+ }
+
+ /**
+ * Test arrival and recording of incidents <i>after</i> the stop incident.
+ */
+ public void testPostCloseIncidents() {
+ History.closeTime = 300;
+ Incident one = new Incident();
+ one.setActivityID("test");
+ rest();
+ ActivityStopped two = new ActivityStopped();
+ two.setActivityID("test");
+ rest();
+ Incident three = new Incident();
+ three.setActivityID("test");
+
+ History history = new History(one, this);
+ history.addIncident(two);
+ rest();
+ history.addIncident(three);
+ rest(1200);
+
+ assertNotNull("History never called store", id);
+ assertEquals("test", id);
+ assertNotNull(incidents);
+ assertEquals(3, incidents.size());
+ assertEquals(one, incidents.get(0));
+ assertEquals(two, incidents.get(1));
+ assertEquals(three, incidents.get(2));
+ }
+
+ /**
+ * Test if an idle history is committed when a stop incident is late.
+ */
+ public void testIdleHistory() {
+ History.idleTime = 300;
+ History.closeTime = 100;
+ Incident one = new Incident();
+ one.setActivityID("test");
+ rest();
+ Incident two = new Incident();
+ two.setActivityID("test");
+ rest();
+ ActivityStopped three = new ActivityStopped();
+ three.setActivityID("test");
+
+ History history = new History(one, this);
+ rest();
+ history.addIncident(two);
+ rest(500);
+ history.addIncident(three);
+
+ assertNotNull("History never called store", id);
+ assertEquals("test", id);
+ assertNotNull(incidents);
+ assertEquals(2, incidents.size());
+ assertEquals(one, incidents.get(0));
+ assertEquals(two, incidents.get(1));
+ }
+
+ /**
+ * Test if an idle history is committed and the stop incident arrives in time to
+ * be recorded.
+ */
+ public void testPostCommitActivityStop() {
+ History.idleTime = 300;
+ History.closeTime = 500;
+ Incident one = new Incident();
+ one.setActivityID("test");
+ rest();
+ Incident two = new Incident();
+ two.setActivityID("test");
+ rest();
+ ActivityStopped three = new ActivityStopped();
+ three.setActivityID("test");
+
+ History history = new History(one, this);
+ rest();
+ history.addIncident(two);
+ rest(500);
+ history.addIncident(three);
+ rest(400);
+
+ assertNotNull("History never called store", id);
+ assertEquals("test", id);
+ assertNotNull(incidents);
+ assertEquals(3, incidents.size());
+ assertEquals(one, incidents.get(0));
+ assertEquals(two, incidents.get(1));
+ assertEquals(three, incidents.get(2));
+ }
+
+ /**
+ * Our test storage just saves the last received ID and list of incidents.
+ *
+ * @param id ID, which should always be <code>test</code>.
+ * @param incidents {@link List} of received {@link Incident}s.
+ */
+ public void store(String id, List incidents) {
+ this.id = id;
+ this.incidents = incidents;
+ }
+
+ /**
+ * Pause the current thread for the given time.
+ *
+ * @param time Milliseconds to sleep.
+ */
+ private static void rest(long time) {
+ try {
+ Thread.sleep(time);
+ } catch (InterruptedException ignore) {}
+ }
+
+ /**
+ * Pause the current thread for 100 milliseconds.
+ */
+ private static void rest() {
+ rest(100);
+ }
+
+ /** Last stored ID. */
+ private String id;
+
+ /** Last stored list of {@link Incident}s. */
+ private List incidents;
+
+ /** Idle time to restore. */
+ private long oldIdle;
+
+ /** Close time to restore. */
+ private long oldClose;
+}
Modified: incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/IncidentTest.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/IncidentTest.java?rev=964147&r1=964122&r2=964147&view=diff
==============================================================================
--- incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/IncidentTest.java (original)
+++ incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/activity/IncidentTest.java Wed Jul 14 19:32:42 2010
@@ -1,9 +1,21 @@
-// Copyright 2003 California Institute of Technology. ALL RIGHTS RESERVED.
-// U.S. Government Sponsorship acknowledged.
-//
-// $Id: IncidentTest.java,v 1.1 2004-03-02 19:29:01 kelly Exp $
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
-package jpl.eda.activity;
+package org.apache.oodt.commons.activity;
import java.util.Date;
import junit.framework.TestCase;
Modified: incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/exec/TestEnvUtilities.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/exec/TestEnvUtilities.java?rev=964147&r1=964122&r2=964147&view=diff
==============================================================================
--- incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/exec/TestEnvUtilities.java (original)
+++ incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/exec/TestEnvUtilities.java Wed Jul 14 19:32:42 2010
@@ -1,9 +1,21 @@
-//Copyright (c) 2008, California Institute of Technology.
-//ALL RIGHTS RESERVED. U.S. Government sponsorship acknowledged.
-//
-//$Id$
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
-package gov.nasa.jpl.oodt.cas.commons.exec;
+package org.apache.oodt.commons.exec;
//JDK imports
import java.io.ByteArrayInputStream;
Modified: incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/option/handler/TestCmdLineOptionBeanHandler.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/option/handler/TestCmdLineOptionBeanHandler.java?rev=964147&r1=964122&r2=964147&view=diff
==============================================================================
--- incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/option/handler/TestCmdLineOptionBeanHandler.java (original)
+++ incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/option/handler/TestCmdLineOptionBeanHandler.java Wed Jul 14 19:32:42 2010
@@ -1,9 +1,21 @@
-//Copyright (c) 2008, California Institute of Technology.
-//ALL RIGHTS RESERVED. U.S. Government sponsorship acknowledged.
-//
-//$Id$
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
-package gov.nasa.jpl.oodt.cas.commons.option.handler;
+package org.apache.oodt.commons.option.handler;
//JDK imports
import java.util.Collections;
@@ -11,7 +23,7 @@ import java.util.List;
import java.util.Vector;
//OODT imports
-import gov.nasa.jpl.oodt.cas.commons.option.CmdLineOption;
+import org.apache.oodt.commons.option.CmdLineOption;
//Junit imports
import junit.framework.TestCase;