Top Description Inners Fields Constructors Methods
org.eclipse.jgit.transport

public Class TestProtocol<C>

extends TransportProtocol
Class Inheritance
Type Parameters
<C>
the connection type
Imports
java.net.URISyntaxException, java.text.MessageFormat, java.util.Collections, .EnumSet, .HashMap, .Set, org.eclipse.jgit.errors.NotSupportedException, .TransportException, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.lib.Repository, org.eclipse.jgit.transport.BasePackFetchConnection.FetchConfig, org.eclipse.jgit.transport.resolver.ReceivePackFactory, .UploadPackFactory

Protocol for transport between manually-specified repositories in tests.

Remote repositories are registered using register(Object, Repository), after which they can be accessed using the returned URI. As this class provides both the client side (the protocol) and the server side, the caller is responsible for setting up and passing the connection context, whatever form that may take.

Unlike the other built-in protocols, which are automatically-registered singletons, callers are expected to register/unregister specific protocol instances on demand with org.eclipse.jgit.transport.Transport#register(TransportProtocol).

Since
4.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class

Field Summary

Modifier and TypeField and Description
private static BasePackFetchConnection.FetchConfig
private final HashMap<URIish, TestProtocol<C>.Handle>
pack-priv final ReceivePackFactory<C>
private static final String
pack-priv final UploadPackFactory<C>

Constructor Summary

AccessConstructor and Description
public
TestProtocol(UploadPackFactory<C>
factory for creating org.eclipse.jgit.transport.UploadPack used by all connections from this protocol instance.
uploadPackFactory
,
ReceivePackFactory<C>
factory for creating org.eclipse.jgit.transport.ReceivePack used by all connections from this protocol instance.
receivePackFactory
)

Constructor for TestProtocol.

Method Summary

Modifier and TypeMethod and Description
public String
getName()

Implements abstract org.eclipse.jgit.transport.TransportProtocol.getName.

Get text name of the protocol suitable for display to a user.

public Set<TransportProtocol.URIishField>
getOptionalFields()

Overrides org.eclipse.jgit.transport.TransportProtocol.getOptionalFields.

Get immutable set of URIishFields that may be filled in.

public Set<TransportProtocol.URIishField>
getRequiredFields()

Overrides org.eclipse.jgit.transport.TransportProtocol.getRequiredFields.

Get immutable set of URIishFields that must be filled in.

public Set<String>
getSchemes()

Overrides org.eclipse.jgit.transport.TransportProtocol.getSchemes.

Get immutable set of schemes supported by this protocol.

public Transport
open(URIish
address of the Git repository.
uri
,
Repository
the local repository that will communicate with the other Git repository.
local
,
String
name of the remote, if the remote as configured in local; otherwise null.
remoteName
)

Implements abstract org.eclipse.jgit.transport.TransportProtocol.open.

Open a Transport instance to the other repository.

public synchronized URIish

Returns:

a URI that can be used to connect to this repository for both fetch and push.
register
(C
connection context. This instance is reused for all connections made using this protocol; if it is stateful and usable only for one connection, the same repository should be registered multiple times.
req
,
Repository
remote repository to connect to.
remote
)

Register a repository connection over the internal test protocol.

pack-priv static void
Inherited from org.eclipse.jgit.transport.TransportProtocol:
canHandlecanHandlegetDefaultPortopen

Field Detail

fetchConfigback to summary
private static BasePackFetchConnection.FetchConfig fetchConfig
handlesback to summary
private final HashMap<URIish, TestProtocol<C>.Handle> handles
receivePackFactoryback to summary
pack-priv final ReceivePackFactory<C> receivePackFactory
SCHEMEback to summary
private static final String SCHEME
uploadPackFactoryback to summary
pack-priv final UploadPackFactory<C> uploadPackFactory

Constructor Detail

TestProtocolback to summary
public TestProtocol(UploadPackFactory<C> uploadPackFactory, ReceivePackFactory<C> receivePackFactory)

Constructor for TestProtocol.

Parameters
uploadPackFactory:UploadPackFactory<C>

factory for creating org.eclipse.jgit.transport.UploadPack used by all connections from this protocol instance.

receivePackFactory:ReceivePackFactory<C>

factory for creating org.eclipse.jgit.transport.ReceivePack used by all connections from this protocol instance.

Method Detail

getNameback to summary
public String getName()

Implements abstract org.eclipse.jgit.transport.TransportProtocol.getName.

Doc from org.eclipse.jgit.transport.TransportProtocol.getName.

Get text name of the protocol suitable for display to a user.

Returns:String

text name of the protocol suitable for display to a user.

Annotations
@Override
getOptionalFieldsback to summary
public Set<TransportProtocol.URIishField> getOptionalFields()

Overrides org.eclipse.jgit.transport.TransportProtocol.getOptionalFields.

Doc from org.eclipse.jgit.transport.TransportProtocol.getOptionalFields.

Get immutable set of URIishFields that may be filled in.

Returns:Set<TransportProtocol.URIishField>

immutable set of URIishFields that may be filled in.

Annotations
@Override
getRequiredFieldsback to summary
public Set<TransportProtocol.URIishField> getRequiredFields()

Overrides org.eclipse.jgit.transport.TransportProtocol.getRequiredFields.

Doc from org.eclipse.jgit.transport.TransportProtocol.getRequiredFields.

Get immutable set of URIishFields that must be filled in.

Returns:Set<TransportProtocol.URIishField>

immutable set of URIishFields that must be filled in.

Annotations
@Override
getSchemesback to summary
public Set<String> getSchemes()

Overrides org.eclipse.jgit.transport.TransportProtocol.getSchemes.

Doc from org.eclipse.jgit.transport.TransportProtocol.getSchemes.

Get immutable set of schemes supported by this protocol.

Returns:Set<String>

immutable set of schemes supported by this protocol.

Annotations
@Override
openback to summary
public Transport open(URIish uri, Repository local, String remoteName) throws NotSupportedException, TransportException

Implements abstract org.eclipse.jgit.transport.TransportProtocol.open.

Doc from org.eclipse.jgit.transport.TransportProtocol.open.

Open a Transport instance to the other repository.

Implementations should avoid making remote connections until an operation on the returned Transport is invoked, however they may fail fast here if they know a connection is impossible, such as when using the local filesystem and the target path does not exist.

Implementations may access implementation-specific configuration options within local.getConfig() using the remote block named by the remoteName, if the name is non-null.

Parameters
uri:URIish

address of the Git repository.

local:Repository

the local repository that will communicate with the other Git repository.

remoteName:String

name of the remote, if the remote as configured in local; otherwise null.

Returns:Transport

the transport.

Annotations
@Override
Exceptions
NotSupportedException:
this protocol does not support the URI.
TransportException:
the transport cannot open this URI.
registerback to summary
public synchronized URIish register(C req, Repository remote)

Register a repository connection over the internal test protocol.

Parameters
req:C

connection context. This instance is reused for all connections made using this protocol; if it is stateful and usable only for one connection, the same repository should be registered multiple times.

remote:Repository

remote repository to connect to.

Returns:URIish

a URI that can be used to connect to this repository for both fetch and push.

setFetchConfigback to summary
pack-priv static void setFetchConfig(BasePackFetchConnection.FetchConfig c)
org.eclipse.jgit.transport back to summary

private Class TestProtocol.Handle

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final Repository
pack-priv final C

Constructor Summary

AccessConstructor and Description
pack-priv
Handle(C req, Repository remote)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

remoteback to summary
pack-priv final Repository remote
reqback to summary
pack-priv final C req

Constructor Detail

Handleback to summary
pack-priv Handle(C req, Repository remote)
org.eclipse.jgit.transport back to summary

private Class TestProtocol.TransportInternal

extends Transport
implements PackTransport
Class Inheritance
All Implemented Interfaces
org.eclipse.jgit.transport.PackTransport

Field Summary

Modifier and TypeField and Description
private final TestProtocol<C>.Handle
Inherited from org.eclipse.jgit.transport.Transport:
DEFAULT_FETCH_THINDEFAULT_PUSH_THINDEFAULT_PUSH_USE_BITMAPSlocalprotocolREFSPEC_PUSH_ALLREFSPEC_TAGSuri

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract org.eclipse.jgit.transport.Transport.close.

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

public FetchConnection
openFetch()

Implements abstract org.eclipse.jgit.transport.Transport.openFetch.

Begins a new connection for fetching from the remote repository.

public PushConnection
openPush()

Implements abstract org.eclipse.jgit.transport.Transport.openPush.

Begins a new connection for pushing into the remote repository.

Inherited from org.eclipse.jgit.transport.Transport:
applyConfigfetchfetchfindRemoteRefUpdatesForfindRemoteRefUpdatesForfindRemoteRefUpdatesForfindRemoteRefUpdatesForfindTrackingRefNamegetCredentialsProvidergetDeepenNotsgetDeepenSincegetDepthgetFilterSpecgetObjectCheckergetOptionReceivePackgetOptionUploadPackgetPackConfiggetPushOptionsgetTagOptgetTimeoutgetTransportProtocolsgetURIisCheckFetchedObjectsisDryRunisFetchThinisPushAtomicisPushThinisPushUseBitmapsisRemoveDeletedRefsopenopenopenopenopenopenopenopenAllopenAllopenAllopenAllopenFetchpushpushregistersetCheckFetchedObjectssetCredentialsProvidersetDeepenNotssetDeepenSincesetDepthsetDepthsetDryRunsetFetchThinsetFilterSpecsetHookErrorStreamsetHookOutputStreamsetObjectCheckersetOptionReceivePacksetOptionUploadPacksetPackConfigsetPushAtomicsetPushOptionssetPushThinsetPushUseBitmapssetRemoveDeletedRefssetTagOptsetTimeoutunregister

Field Detail

handleback to summary
private final TestProtocol<C>.Handle handle

Constructor Detail

TransportInternalback to summary
pack-priv TransportInternal(Repository local, URIish uri, TestProtocol<C>.Handle handle)

Method Detail

closeback to summary
public void close()

Implements abstract org.eclipse.jgit.transport.Transport.close.

Implements java.lang.AutoCloseable.close.

Doc from org.eclipse.jgit.transport.Transport.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Close any resources used by this transport.

If the remote repository is contacted by a network socket this method must close that network socket, disconnecting the two peers. If the remote repository is actually local (same system) this method must close any open file handles used to read the "remote" repository.

AutoClosable.close() declares that it throws Exception. Implementers shouldn't throw checked exceptions. This override narrows the signature to prevent them from doing so.

Annotations
@Override
openFetchback to summary
public FetchConnection openFetch() throws NotSupportedException, TransportException

Implements abstract org.eclipse.jgit.transport.Transport.openFetch.

Doc from org.eclipse.jgit.transport.Transport.openFetch.

Begins a new connection for fetching from the remote repository.

If the transport has no local repository, the fetch connection can only be used for reading remote refs.

Returns:FetchConnection

a fresh connection to fetch from the remote repository.

Annotations
@Override
Exceptions
NotSupportedException:
the implementation does not support fetching.
TransportException:
the remote connection could not be established.
openPushback to summary
public PushConnection openPush() throws NotSupportedException, TransportException

Implements abstract org.eclipse.jgit.transport.Transport.openPush.

Doc from org.eclipse.jgit.transport.Transport.openPush.

Begins a new connection for pushing into the remote repository.

Returns:PushConnection

a fresh connection to push into the remote repository.

Annotations
@Override
Exceptions
NotSupportedException:
the implementation does not support pushing.
TransportException:
the remote connection could not be established