Author: simoneg
Date: Fri Dec 11 15:57:30 2009
New Revision: 889670

URL: http://svn.apache.org/viewvc?rev=889670&view=rev
Log:
Test methods

Added:
    
labs/magma/trunk/magma-test-utilities/src/main/java/org/apache/magma/testing/AssertStringStructure.java
Modified:
    labs/magma/trunk/magma-test-utilities/pom.xml

Modified: labs/magma/trunk/magma-test-utilities/pom.xml
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/magma-test-utilities/pom.xml?rev=889670&r1=889669&r2=889670&view=diff
==============================================================================
--- labs/magma/trunk/magma-test-utilities/pom.xml (original)
+++ labs/magma/trunk/magma-test-utilities/pom.xml Fri Dec 11 15:57:30 2009
@@ -4,6 +4,18 @@
   <artifactId>magma-test-utilities</artifactId>
   <name>Magma Testing Utilities</name>
   <version>0.0.3-SNAPSHOT</version>
+  <build>
+       <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+       </plugins>
+  </build>
   <dependencies>
     <dependency>
       <groupId>junit</groupId>

Added: 
labs/magma/trunk/magma-test-utilities/src/main/java/org/apache/magma/testing/AssertStringStructure.java
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/magma-test-utilities/src/main/java/org/apache/magma/testing/AssertStringStructure.java?rev=889670&view=auto
==============================================================================
--- 
labs/magma/trunk/magma-test-utilities/src/main/java/org/apache/magma/testing/AssertStringStructure.java
 (added)
+++ 
labs/magma/trunk/magma-test-utilities/src/main/java/org/apache/magma/testing/AssertStringStructure.java
 Fri Dec 11 15:57:30 2009
@@ -0,0 +1,46 @@
+/*
+ * 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.magma.testing;
+
+import junit.framework.AssertionFailedError;
+
+public class AssertStringStructure {
+
+       public static void assertStructure(String actual, String... components) 
{
+               int lp = 0;
+               for (int i = 0; i < components.length; i++) {
+                       if (components[i].startsWith("!!")) {
+                               String comp = components[i].substring(2);
+                               int acp = actual.indexOf(comp, lp);
+                               if (acp != -1) {
+                                       throw new AssertionFailedError("NOT 
Expecting \"" + components[i] + "\" (" + i + ") but found it in \"" + 
actual.substring(lp) + "\"");
+                               }
+                       } else if (components[i].equals("$$")) {
+                               if (lp < actual.length()) {
+                                       throw new AssertionFailedError("String 
is not finished, still '" + actual.substring(lp) + "'");
+                               }
+                       } else {
+                               int acp = actual.indexOf(components[i], lp);
+                               if (acp == -1) {
+                                       throw new 
AssertionFailedError("Expecting \"" + components[i] + "\" (" + i + ") but not 
found in \"" + actual.substring(lp) + "\"");
+                               }
+                               lp = acp + components[i].length();
+                       }
+               }
+       }
+       
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to