-
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.
- Loading branch information
Showing
6 changed files
with
159 additions
and
119 deletions.
There are no files selected for viewing
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
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
62 changes: 38 additions & 24 deletions
62
src/test/java/cz/mikealdo/struts2components/IndexActionTest.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 |
---|---|---|
@@ -1,36 +1,50 @@ | ||
/* | ||
* Copyright 2006 The Apache Software Foundation. | ||
* | ||
* 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 cz.mikealdo.struts2components; | ||
|
||
import cz.mikealdo.struts2components.actions.IndexAction; | ||
import cz.mikealdo.struts2components.components.FirstSimpleComponent; | ||
import cz.mikealdo.struts2components.components.SecondSimpleComponent; | ||
import cz.mikealdo.struts2components.components.SimpleComponent; | ||
import cz.mikealdo.struts2components.struts2.components.Component; | ||
import junit.framework.TestCase; | ||
|
||
import com.opensymphony.xwork2.Action; | ||
import org.hamcrest.Matcher; | ||
import org.hamcrest.MatcherAssert; | ||
import org.junit.Test; | ||
import org.mockito.Matchers; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertThat; | ||
|
||
public class IndexActionTest { | ||
|
||
private final FirstSimpleComponent firstComponent = new FirstSimpleComponent(); | ||
private final SecondSimpleComponent secondComponent = new SecondSimpleComponent(); | ||
private IndexAction action = new IndexAction(firstComponent, secondComponent);; | ||
|
||
@Test | ||
public void shouldReturnRightResultName() throws Exception { | ||
assertEquals(Action.INPUT, action.execute()); | ||
} | ||
|
||
@Test | ||
public void shouldReturnFirstComponent() throws Exception { | ||
Component component = action.getChild("firstComponent"); | ||
|
||
assertEquals(component, firstComponent); | ||
} | ||
|
||
|
||
@Test | ||
public void shouldReturnSecondComponent() throws Exception { | ||
Component component = action.getChild("secondComponent"); | ||
|
||
assertEquals(component, secondComponent); | ||
} | ||
|
||
@Test | ||
public void shouldReturnTwoComponents() throws Exception { | ||
assertEquals(action.getChildren().size(), 2); | ||
|
||
/** | ||
* | ||
*/ | ||
public class IndexActionTest extends TestCase { | ||
|
||
public void testIndexAction() throws Exception { | ||
IndexAction action = new IndexAction(new FirstSimpleComponent(), new SecondSimpleComponent()); | ||
String result = action.execute(); | ||
assertEquals(Action.INPUT, result); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/java/cz/mikealdo/struts2components/components/FirstSimpleComponentTest.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,15 @@ | ||
package cz.mikealdo.struts2components.components; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class FirstSimpleComponentTest { | ||
|
||
@Test | ||
public void shouldReturnRightId() throws Exception { | ||
String id = new FirstSimpleComponent(0).getId(); | ||
|
||
assertEquals("firstComponent", id); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/test/java/cz/mikealdo/struts2components/components/SecondSimpleComponentTest.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,16 @@ | ||
package cz.mikealdo.struts2components.components; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class SecondSimpleComponentTest { | ||
|
||
@Test | ||
public void shouldReturnRightId() throws Exception { | ||
String id = new SecondSimpleComponent(0).getId(); | ||
|
||
assertEquals("secondComponent", id); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/test/java/cz/mikealdo/struts2components/components/SimpleComponentTest.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,23 @@ | ||
package cz.mikealdo.struts2components.components; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class SimpleComponentTest { | ||
|
||
private SimpleComponent simpleComponent = new SimpleComponent() { | ||
@Override | ||
public String getId() { | ||
return "id"; | ||
} | ||
}; | ||
|
||
@Test | ||
public void shouldReturnPlusOneRightResult() throws Exception { | ||
String result = simpleComponent.plusOne(); | ||
|
||
assertEquals("success", result); | ||
assertEquals(simpleComponent.getIntegerInsideComponent(), Integer.valueOf(1)); | ||
} | ||
} |