Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onlab.stc; |
| 17 | |
| 18 | import com.google.common.testing.EqualsTester; |
| 19 | import org.apache.commons.configuration.ConfigurationException; |
| 20 | import org.junit.Before; |
| 21 | import org.junit.Test; |
| 22 | |
| 23 | import static org.junit.Assert.assertEquals; |
| 24 | import static org.junit.Assert.assertSame; |
| 25 | |
| 26 | /** |
| 27 | * Test of the test step entity. |
| 28 | */ |
| 29 | public class StepTest { |
| 30 | |
| 31 | protected static final String NAME = "step"; |
| 32 | protected static final String CMD = "command"; |
Thomas Vachuska | 4bfccd54 | 2015-05-30 00:35:25 -0700 | [diff] [blame^] | 33 | protected static final String ENV = "environment"; |
| 34 | protected static final String CWD = "directory"; |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 35 | protected Group parent; |
| 36 | |
| 37 | @Before |
| 38 | public void setUp() throws ConfigurationException { |
Thomas Vachuska | 4bfccd54 | 2015-05-30 00:35:25 -0700 | [diff] [blame^] | 39 | parent = new Group("parent", null, null, null, null); |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | @Test |
| 43 | public void basics() { |
Thomas Vachuska | 4bfccd54 | 2015-05-30 00:35:25 -0700 | [diff] [blame^] | 44 | Step step = new Step(NAME, CMD, ENV, CWD, parent); |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 45 | assertEquals("incorrect name", NAME, step.name()); |
| 46 | assertEquals("incorrect command", CMD, step.command()); |
Thomas Vachuska | 4bfccd54 | 2015-05-30 00:35:25 -0700 | [diff] [blame^] | 47 | assertEquals("incorrect env", ENV, step.env()); |
| 48 | assertEquals("incorrect cwd", CWD, step.cwd()); |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 49 | assertSame("incorrect group", parent, step.group()); |
| 50 | } |
| 51 | |
| 52 | @Test |
| 53 | public void equality() { |
Thomas Vachuska | 4bfccd54 | 2015-05-30 00:35:25 -0700 | [diff] [blame^] | 54 | Step s1 = new Step(NAME, CMD, null, null, parent); |
| 55 | Step s2 = new Step(NAME, CMD, ENV, CWD, null); |
| 56 | Step s3 = new Step("foo", null, null, null, parent); |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 57 | new EqualsTester() |
| 58 | .addEqualityGroup(s1, s2) |
| 59 | .addEqualityGroup(s3) |
| 60 | .testEquals(); |
| 61 | } |
| 62 | } |