alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Groovy example source code file (Java2GroovyTest.java)

This example Groovy source code file (Java2GroovyTest.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

c, exception, exception, file, file, foo, foo, groovytestcase, java2groovytest, string, string

The Groovy Java2GroovyTest.java source code

/**
 *
 * Copyright 2005 Jeremy Rayner
 *
 * Licensed 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.codehaus.groovy.antlr.treewalker;

import groovy.util.GroovyTestCase;
import org.codehaus.groovy.antlr.java.Java2GroovyMain;

public class Java2GroovyTest extends GroovyTestCase {

    public void testSimpleClass() throws Exception {
        assertEquals("private class Foo {int x = 1}", convert("private class Foo{int x=1;}"));
    }

    public void testStringLiteral() throws Exception {
        assertEquals("class Foo {String x = \"mooky\"}", convert("public class Foo{String x = \"mooky\";}"));
        assertEquals("class C {void m(String s) {File f = new File(\"sl\" + s)}}", convert("public class C{void m(String s) {File f=new File(\"sl\" + s);}}"));
    }

    private String convert(String input) throws Exception {
        return Java2GroovyMain.convert("Java2GroovyTest.java", input);
    }

    private String mindmap(String input) throws Exception {
        return Java2GroovyMain.mindmap(input);
    }

    private String nodePrinter(String input) throws Exception {
        return Java2GroovyMain.nodePrinter(input);
    }
}

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy Java2GroovyTest.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.