Search in sources :

Example 1 with I2PSocketManagerFull

use of net.i2p.client.streaming.impl.I2PSocketManagerFull in project i2p.i2p by i2p.

the class I2PSocketManagerFactoryTest method testCreateDiscMgr_customI2CP.

@Test
public void testCreateDiscMgr_customI2CP() throws Exception {
    I2PSocketManagerFull mgr = (I2PSocketManagerFull) I2PSocketManagerFactory.createDisconnectedManager(null, "example.com", 3333, null);
    assertThat(mgr, is(not(nullValue())));
    assertThat(mgr.getName(), is("manager"));
    assertTrue(mgr.getOpts().containsKey(I2PClient.PROP_TCP_HOST));
    assertThat(mgr.getOpts().getProperty(I2PClient.PROP_TCP_HOST), is("example.com"));
    assertTrue(mgr.getOpts().containsKey(I2PClient.PROP_TCP_PORT));
    assertThat(mgr.getOpts().getProperty(I2PClient.PROP_TCP_PORT), is("3333"));
}
Also used : I2PSocketManagerFull(net.i2p.client.streaming.impl.I2PSocketManagerFull) Test(org.junit.Test)

Example 2 with I2PSocketManagerFull

use of net.i2p.client.streaming.impl.I2PSocketManagerFull in project i2p.i2p by i2p.

the class I2PSocketManagerFactoryTest method testCreateDiscMgr_customDest.

@Test
public void testCreateDiscMgr_customDest() throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Destination dest = I2PClientFactory.createClient().createDestination(baos);
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    I2PSocketManagerFull mgr = (I2PSocketManagerFull) I2PSocketManagerFactory.createDisconnectedManager(bais, null, 0, null);
    assertThat(mgr, is(not(nullValue())));
    assertThat(mgr.getName(), is("manager"));
    assertThat(mgr.getSession().getMyDestination(), is(equalTo(dest)));
}
Also used : Destination(net.i2p.data.Destination) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) I2PSocketManagerFull(net.i2p.client.streaming.impl.I2PSocketManagerFull) Test(org.junit.Test)

Example 3 with I2PSocketManagerFull

use of net.i2p.client.streaming.impl.I2PSocketManagerFull in project i2p.i2p by i2p.

the class I2PSocketManagerFactoryTest method testCreateDiscMgr_customOpts.

@Test
public void testCreateDiscMgr_customOpts() throws Exception {
    Properties opts = new Properties();
    opts.setProperty(I2PClient.PROP_RELIABILITY, I2PClient.PROP_RELIABILITY_BEST_EFFORT);
    opts.setProperty("foo", "bar");
    I2PSocketManagerFull mgr = (I2PSocketManagerFull) I2PSocketManagerFactory.createDisconnectedManager(null, null, 0, opts);
    assertThat(mgr, is(not(nullValue())));
    assertThat(mgr.getName(), is("manager"));
    assertTrue(mgr.getOpts().containsKey(I2PClient.PROP_RELIABILITY));
    assertThat(mgr.getOpts().getProperty(I2PClient.PROP_RELIABILITY), is(I2PClient.PROP_RELIABILITY_BEST_EFFORT));
    assertTrue(mgr.getOpts().containsKey("foo"));
    assertThat(mgr.getOpts().getProperty("foo"), is("bar"));
}
Also used : Properties(java.util.Properties) I2PSocketManagerFull(net.i2p.client.streaming.impl.I2PSocketManagerFull) Test(org.junit.Test)

Example 4 with I2PSocketManagerFull

use of net.i2p.client.streaming.impl.I2PSocketManagerFull in project i2p.i2p by i2p.

the class I2PSocketManagerFactoryTest method testCreateDiscMgr.

@Test
public void testCreateDiscMgr() throws Exception {
    I2PSocketManagerFull mgr = (I2PSocketManagerFull) I2PSocketManagerFactory.createDisconnectedManager(null, null, 0, null);
    assertThat(mgr, is(not(nullValue())));
    assertThat(mgr.getName(), is("manager"));
    assertTrue(mgr.getOpts().containsKey(I2PClient.PROP_RELIABILITY));
    assertThat(mgr.getOpts().getProperty(I2PClient.PROP_RELIABILITY), is(I2PClient.PROP_RELIABILITY_NONE));
}
Also used : I2PSocketManagerFull(net.i2p.client.streaming.impl.I2PSocketManagerFull) Test(org.junit.Test)

Aggregations

I2PSocketManagerFull (net.i2p.client.streaming.impl.I2PSocketManagerFull)4 Test (org.junit.Test)4 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Properties (java.util.Properties)1 Destination (net.i2p.data.Destination)1