-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for artifacts generated by the I18N annotation processor
- Loading branch information
Petter Holmstrom
committed
May 8, 2012
1 parent
35e7695
commit f368dc0
Showing
3 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...ors-tests/src/main/java/net/pkhsolutions/ceres/i18n/tests/pkga/ExampleLocalizedClass.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) 2012 Petter Holmström | ||
* | ||
* 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 net.pkhsolutions.ceres.i18n.tests.pkga; | ||
|
||
import net.pkhsolutions.ceres.i18n.annotations.Message; | ||
|
||
/** | ||
* Example class using the {@link Message} annotation. | ||
* | ||
* @author Petter Holmström | ||
* @since 1.0 | ||
*/ | ||
@Message(key = "ExampleLocalizedClass.key", defaultValue = "Hello world ExampleLocalizedClass") | ||
public class ExampleLocalizedClass { | ||
|
||
@Message(key = "ExampleLocalizedClass.aField.key", defaultValue = "Hello world ExampleLocalizedClass.aField\nAnd a new line") | ||
protected String aField; | ||
|
||
@Message(key = "ExampleLocalizedClass.aMethod.key", defaultValue = "Hello world ExampleLocalizedClass.aMethod") | ||
public void aMethod() { | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...rs-tests/src/main/java/net/pkhsolutions/ceres/i18n/tests/pkga/ExampleLocalizedClass2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2012 Petter Holmström | ||
* | ||
* 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 net.pkhsolutions.ceres.i18n.tests.pkga; | ||
|
||
import net.pkhsolutions.ceres.i18n.annotations.Message; | ||
import net.pkhsolutions.ceres.i18n.annotations.Messages; | ||
|
||
/** | ||
* Example class using the {@link Messages} annotation. | ||
* | ||
* @author Petter Holmström | ||
* @since 1.0 | ||
*/ | ||
@Messages({ | ||
@Message(key = "ExampleLocalizedClass2.key1", defaultValue = "Hello world ExampleLocalizedClass2.1"), | ||
@Message(key = "ExampleLocalizedClass2.key2", defaultValue = "Hello world ExampleLocalizedClass2.2") | ||
}) | ||
public class ExampleLocalizedClass2 { | ||
|
||
@Messages({ | ||
@Message(key = "ExampleLocalizedClass2.aField.key1", defaultValue = "Hello world ExampleLocalizedClass2.aField1"), | ||
@Message(key = "ExampleLocalizedClass2.aField.key2", defaultValue = "Hello world ExampleLocalizedClass2.aField2") | ||
}) | ||
protected String aField; | ||
|
||
@Messages({ | ||
@Message(key = "ExampleLocalizedClass2.aMethod.key1", defaultValue = "Hello world ExampleLocalizedClass2.aMethod1"), | ||
@Message(key = "ExampleLocalizedClass2.aMethod.key2", defaultValue = "Hello world ExampleLocalizedClass2.aMethod2") | ||
}) | ||
public void aMethod() { | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
i18n-processors-tests/src/test/java/net/pkhsolutions/ceres/i18n/tests/pkga/PkgaTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright (c) 2012 Petter Holmström | ||
* | ||
* 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 net.pkhsolutions.ceres.i18n.tests.pkga; | ||
|
||
import java.util.Arrays; | ||
import java.util.Locale; | ||
import net.pkhsolutions.ceres.common.holder.GlobalHolderStrategy; | ||
import net.pkhsolutions.ceres.i18n.DefaultI18N; | ||
import net.pkhsolutions.ceres.i18n.I18N; | ||
import net.pkhsolutions.ceres.i18n.I18NHolder; | ||
import static org.junit.Assert.assertEquals; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
/** | ||
* This test checks that the auto-generated artifacts in the {@code pkga} | ||
* package are working as they should. | ||
* | ||
* @author Petter Holmström | ||
* @since 1.0 | ||
*/ | ||
public class PkgaTest { | ||
|
||
@Before | ||
public void setUp() { | ||
I18N i18n = new DefaultI18N(Arrays.asList(Locale.ENGLISH)); | ||
I18NHolder.setStrategy(I18NHolder.class, new GlobalHolderStrategy<I18N>()); | ||
I18NHolder.set(i18n); | ||
} | ||
|
||
@Test | ||
public void messages_Class1() { | ||
assertEquals("Hello world ExampleLocalizedClass", Bundle.ExampleLocalizedClass_key()); | ||
assertEquals("Hello world ExampleLocalizedClass.aField\nAnd a new line", Bundle.ExampleLocalizedClass_aField_key()); | ||
assertEquals("Hello world ExampleLocalizedClass.aMethod", Bundle.ExampleLocalizedClass_aMethod_key()); | ||
} | ||
|
||
@Test | ||
public void messages_Class2() { | ||
assertEquals("Hello world ExampleLocalizedClass2.1", Bundle.ExampleLocalizedClass2_key1()); | ||
assertEquals("Hello world ExampleLocalizedClass2.2", Bundle.ExampleLocalizedClass2_key2()); | ||
assertEquals("Hello world ExampleLocalizedClass2.aField1", Bundle.ExampleLocalizedClass2_aField_key1()); | ||
assertEquals("Hello world ExampleLocalizedClass2.aField2", Bundle.ExampleLocalizedClass2_aField_key2()); | ||
assertEquals("Hello world ExampleLocalizedClass2.aMethod1", Bundle.ExampleLocalizedClass2_aMethod_key1()); | ||
assertEquals("Hello world ExampleLocalizedClass2.aMethod2", Bundle.ExampleLocalizedClass2_aMethod_key2()); | ||
} | ||
} |