Skip to content

Commit

Permalink
reformatting, added release note
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronabebe committed Mar 24, 2021
1 parent 99439e7 commit f20f1fc
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 89 deletions.
2 changes: 1 addition & 1 deletion doc/news/_preparation_next_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ you up to date with the multi-language support provided by Elektra.
## Tests
- <<TODO>>
- Added small test for jna Return plugin (`Return.java`), `KeyNameIterator.java` _(@aaronabebe)_
- <<TODO>>
- <<TODO>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
import org.libelektra.plugin.ReturnTest;

@RunWith (Suite.class)
@SuiteClasses ({ KeySetTest.class, KeyTest.class, KeyNameIteratorTest.class, KDBTest.class, ExceptionMapperTest.class, KDBExceptionTest.class, PluginLoaderIT.class,
WarningEntryTest.class, ReturnTest.class, ExceptionMapperIT.class, GOptsTest.class })
@SuiteClasses ({ KeySetTest.class, KeyTest.class, KeyNameIteratorTest.class, KDBTest.class, ExceptionMapperTest.class,
KDBExceptionTest.class, PluginLoaderIT.class, WarningEntryTest.class, ReturnTest.class, ExceptionMapperIT.class,
GOptsTest.class })
public class AllTests
{
}
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
package org.libelektra;

import org.junit.Test;
import static org.junit.Assert.*;

import java.util.Iterator;
import org.junit.Test;

import static org.junit.Assert.*;

public class KeyNameIteratorTest {
public class KeyNameIteratorTest
{

static final String KEY_1_NAME = "/key_test/1/key_name";
static final String KEY_1_NAME_PART_1 = "\u0001";
static final String KEY_1_NAME_PART_2 = "key_test";
static final String KEY_1_NAME_PART_3 = "1";
static final String KEY_1_NAME_PART_4 = "key_name";
static final String KEY_1_VALUE = "key_value_1";
static final String KEY_1_NAME = "/key_test/1/key_name";
static final String KEY_1_NAME_PART_1 = "\u0001";
static final String KEY_1_NAME_PART_2 = "key_test";
static final String KEY_1_NAME_PART_3 = "1";
static final String KEY_1_NAME_PART_4 = "key_name";
static final String KEY_1_VALUE = "key_value_1";

@Test
public void test_keyNameIteratorHasNext_shouldPass() {
final Key key = Key.create (KEY_1_NAME, KEY_1_VALUE);
final Iterator<String> iterator = key.iterator ();
assertTrue (iterator.hasNext ());
assertEquals (KEY_1_NAME_PART_1, iterator.next ());
assertTrue (iterator.hasNext ());
assertEquals (KEY_1_NAME_PART_2, iterator.next ());
assertTrue (iterator.hasNext ());
assertEquals (KEY_1_NAME_PART_3, iterator.next ());
assertTrue (iterator.hasNext ());
assertEquals (KEY_1_NAME_PART_4, iterator.next ());
assertFalse (iterator.hasNext ());
}
@Test public void test_keyNameIteratorHasNext_shouldPass ()
{
final Key key = Key.create (KEY_1_NAME, KEY_1_VALUE);
final Iterator<String> iterator = key.iterator ();
assertTrue (iterator.hasNext ());
assertEquals (KEY_1_NAME_PART_1, iterator.next ());
assertTrue (iterator.hasNext ());
assertEquals (KEY_1_NAME_PART_2, iterator.next ());
assertTrue (iterator.hasNext ());
assertEquals (KEY_1_NAME_PART_3, iterator.next ());
assertTrue (iterator.hasNext ());
assertEquals (KEY_1_NAME_PART_4, iterator.next ());
assertFalse (iterator.hasNext ());
}

@Test(expected = UnsupportedOperationException.class)
public void test_keyNameIteratorDelete_shouldPass() {
final Key key = Key.create (KEY_1_NAME, KEY_1_VALUE);
final Iterator<String> iterator = key.iterator ();
assertTrue (iterator.hasNext ());
iterator.remove ();
}
@Test (expected = UnsupportedOperationException.class) public void test_keyNameIteratorDelete_shouldPass ()
{
final Key key = Key.create (KEY_1_NAME, KEY_1_VALUE);
final Iterator<String> iterator = key.iterator ();
assertTrue (iterator.hasNext ());
iterator.remove ();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import java.util.Iterator;
import org.junit.Before;
import org.junit.Test;
import org.libelektra.Key;
import org.libelektra.KeySet;

public class KeySetTest
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,61 +1,63 @@
package org.libelektra.plugin;

import static org.junit.Assert.assertEquals;

import org.junit.Before;
import org.junit.Test;
import org.libelektra.Key;
import org.libelektra.KeySet;

import static org.junit.Assert.assertEquals;

public class ReturnTest {

static final String ERROR_KEY_NAME = "/temporary/errorkey";
static final String ERROR_KEY_VALUE = "error";

private Return returnPlugin;
private Key errorKey;

@Before public void setup() {
returnPlugin = new Return();
errorKey = Key.create(ERROR_KEY_NAME, ERROR_KEY_VALUE);
}

@Test
public void test_returnOpen_shouldBeCode0(){
KeySet config = returnPlugin.getConfig();
int open = returnPlugin.open(config, errorKey);
assertEquals(0, open);
}

@Test
public void test_returnGet_ShouldBeCode10() {
KeySet config = returnPlugin.getConfig();
int open = returnPlugin.get(config, errorKey);
assertEquals(10, open);
}

@Test
public void test_returnSet_ShouldBeCode20() {
KeySet config = returnPlugin.getConfig();
int open = returnPlugin.set(config, errorKey);
assertEquals(20, open);
}

@Test
public void test_returnError_ShouldBeCode30() {
KeySet config = returnPlugin.getConfig();
int open = returnPlugin.error(config, errorKey);
assertEquals(30, open);
}

@Test
public void test_returnClose_ShouldBeCode0() {
int open = returnPlugin.close(errorKey);
assertEquals(0, open);
}

@Test
public void test_returnGetName_ShouldBeReturn() {
assertEquals(Return.PLUGIN_NAME, returnPlugin.getName());
}
public class ReturnTest
{

static final String ERROR_KEY_NAME = "/temporary/errorkey";
static final String ERROR_KEY_VALUE = "error";

private Return returnPlugin;
private Key errorKey;

@Before public void setup ()
{
returnPlugin = new Return ();
errorKey = Key.create (ERROR_KEY_NAME, ERROR_KEY_VALUE);
}

@Test public void test_returnOpen_shouldBeCode0 ()
{
KeySet config = returnPlugin.getConfig ();
int open = returnPlugin.open (config, errorKey);
assertEquals (0, open);
}

@Test public void test_returnGet_ShouldBeCode10 ()
{
KeySet config = returnPlugin.getConfig ();
int open = returnPlugin.get (config, errorKey);
assertEquals (10, open);
}

@Test public void test_returnSet_ShouldBeCode20 ()
{
KeySet config = returnPlugin.getConfig ();
int open = returnPlugin.set (config, errorKey);
assertEquals (20, open);
}

@Test public void test_returnError_ShouldBeCode30 ()
{
KeySet config = returnPlugin.getConfig ();
int open = returnPlugin.error (config, errorKey);
assertEquals (30, open);
}

@Test public void test_returnClose_ShouldBeCode0 ()
{
int open = returnPlugin.close (errorKey);
assertEquals (0, open);
}

@Test public void test_returnGetName_ShouldBeReturn ()
{
assertEquals (Return.PLUGIN_NAME, returnPlugin.getName ());
}
}

0 comments on commit f20f1fc

Please sign in to comment.