Permalink
Browse files

using a groovy script is more smaller code to maintain

git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1352447 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent f1f6b5c commit 5a5467ffd9dc6f476f15ab14912800f7b9509098 @olamy olamy committed Jun 21, 2012
@@ -1,65 +0,0 @@
-
-/*
- * 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.
- */
-
-import java.io.*;
-
-import org.codehaus.plexus.util.*;
-
-boolean result = true;
-
-try
-{
- File target = new File( basedir, "target" );
- if ( !target.exists() || !target.isDirectory() )
- {
- System.err.println( "target file is missing or a directory." );
- return false;
- }
-
- File someResource = new File( target, "/classes/resource.txt" );
- if ( !someResource.exists() || someResource.isDirectory() )
- {
- System.err.println( "SomeResource.txt is missing or not a file." );
- return false;
- }
-
- String paramContent = FileUtils.fileRead( someResource );
-
- int indexOf = paramContent.indexOf( "fileValue=${foo.file}" );
- if ( indexOf < 0 )
- {
- System.err.println( "SomeResource.txt not contains fileValue=${foo.file}" );
- return false;
- }
-
- int indexOf = paramContent.indexOf( "export SERVER_ENV=${SERVER_ENV:sandbox}" );
- if ( indexOf < 0 )
- {
- System.err.println( "SomeResource.txt not contains export SERVER_ENV=${SERVER_ENV:sandbox}" );
- return false;
- }
-}
-catch( IOException e )
-{
- e.printStackTrace();
- result = false;
-}
-
-return result;
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+assert new File(basedir, 'target/classes/resource.txt').exists();
+
+filteredContent = new File(basedir, 'target/classes/resource.txt').text;
+assert filteredContent.contains( 'fileValue=${foo.file}');
+assert filteredContent.contains( 'export SERVER_ENV=${SERVER_ENV:sandbox}');
+
+return true;

0 comments on commit 5a5467f

Please sign in to comment.